Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@mdebbar
Copy link
Contributor

@mdebbar mdebbar commented May 5, 2023

In order to make HtmlElementView more useful, we need to expose an API for getting the created platform view element. This would allow HtmlElementView to set attributes and styles on the element.

This would allow us to add a new callback to the HtmlElementView that would return the result of calling the registered platformViewFactory to the user, after it's been created and added to the DOM, so the user can do with it as they please.

Part of flutter/flutter#127030

@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label May 5, 2023
@mdebbar mdebbar force-pushed the html_element_view branch from d6edc89 to dee9ab6 Compare May 23, 2023 19:23
@mdebbar mdebbar changed the title [web] Support new API for making HtmlElementView more useful [web] New platform view API to get view by ID May 23, 2023
@mdebbar mdebbar requested a review from ditman May 23, 2023 19:23
@mdebbar mdebbar marked this pull request as ready for review May 23, 2023 19:23
@ditman
Copy link
Member

ditman commented Jun 2, 2023

(Modified the description a little bit, since we're going to use this API to implement the new onPlatformViewCreated(Object contents) or onPlatformViewInjected(Object contents) or whatever is called :P)

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let's go!

/// Throws an [AssertionError] if [viewId] hasn't been rendered before.
DomElement getViewById(int viewId) {
assert(knowsViewId(viewId), 'No view has been rendered for viewId: $viewId');
return _contents[viewId]!.firstElementChild!;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, document that we return the firstElementChild because we cache the created view wrapped with the <flt-slot-content> tag (right?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_contents[viewId] is the wrapper (i.e. the slot element). The first child of the slot is the element created by the factory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I think this is exactly what you are saying. Sorry I misread your comment.

Sounds good, I'll document why I'm returning firstElementChild.

{bool isVisible = true}) {
assert(factoryFunction is PlatformViewFactory ||
factoryFunction is ParameterizedPlatformViewFactory);
assert(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should revert these changes so this PR doesn't conflict with #42255

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I'll just move this change to the other PR.

@mdebbar mdebbar force-pushed the html_element_view branch from dee9ab6 to e7b6f07 Compare June 2, 2023 20:20
@mdebbar mdebbar added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 2, 2023
@auto-submit auto-submit bot merged commit c7358ab into flutter:main Jun 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 2, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jun 2, 2023
@mdebbar mdebbar deleted the html_element_view branch June 22, 2023 21:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants