-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Review request for ResizeObserver #187
Comments
In future it might be helpful to request API design feedback more than a few weeks before your intended branch cut; any changes we propose seem unlikely at this late date. |
One thing that came up in today's TAG meeting was the relationship to the rendering pipeline description in the HTML spec (how this spec is patching it), which is also related to our #72. |
@slightlyoff sorry about the short notice, I was unaware of the TAG until this week. We can delay the release... @dbaron side note about rendering pipeline: I maintain an informal version of "what should happen in the event loop" explainer: https://github.com/atotic/event-loop/, with some "what actually happens" results https://rawgit.com/atotic/event-loop/master/rendering-events.html |
Questions!
Regarding Explainer style, we've put together a draft outline here that might assist you. Thanks again for filing for TAG review and for providing an Explainer! |
Abbreviation: RO - ResizeObserver Answers:
The need to report the old size never came up. We tried to keep the API simple.
I read this question as "Is getComputedStyle() guaranteed not to trigger reflow".
ResizeObserver notifications are delivered after Intersection Observer: https://wicg.github.io/ResizeObserver/#html-event-loop When RO spec was designed, Intersection Observer used to deliver records with delay, without specific delivery timing guarantees. Therefore, the ordering of notification delivery between Intersection Observer and Resize Observer was not an issue. Looking at the existing Intersection Observer spec, I do not see anything about delayed delivery. If Intersection Observer has started providing stronger delivery guarantees, I should open an issue to discuss RO/IO relationship. What is the current status of Intersection Observer delivery guarantees?
I'll update the explainer shortly. So far, there are only 2 usage scenarios we've come upon, if more are discovered, I can add them to the explainer.
ResizeObserver only works with visible DOM elements. How is Offscreen Canvas related?
Design alternatives for what? Different parts of RO API? We've had several design discussions:
|
1 more interesting usage scenario: iframe sizing, will provide example. |
In my last big reply, I've left one question open: interaction between ResizeObserver and IntersectionObserver. I've talked to IO authors, and now understand the relationship between the two:
|
Hey @atotic; we had a chance to discuss at today's F2F in Nice. Overall:
|
I was not thinking Origin Trial, but after talking it over, seems like a good idea. This is the current plan.
I am unsure about the usefullness of "previous value". None of the current examples use it. My guiding principle was not to include anything that is not obviously useful. It is trivial to implement it on top of RO. Did you have any particular examples in mind?
This is an interesting question. In theory, RO handlers should not depend on other sizes. If it does, and other size changes, RO will not be notified (unless other size change also triggers content size change), and RO element will be out of sync. We cannot enforce not using other sizes, but not having other sizes reported discourages their use. I've also noticed that TAG was wondering about 2nd implementation. In summer of 2016, an intern at FF started a ResizeObserver implementation. It never landed, but we did have spec clarification discussions, they did use my tests, |
There's a fundamental problem here that ROs are presuming a single rect per element. Elements can fragment and have multiple boxes that can span columns, pages, and (eventually) regions. Each of those boxes can resize independently. In general I'm not happy with new APIs that continue to bake in conflation of DOM and layout. Ideally this would be based on a box tree API rather than the DOM. I also wonder if many of the prospective use cases for this wouldn't be better handled with custom layout worklets. |
Yes, RO does not observe fragments. The reason is implementation constraints:
I regret that we were also unable to observe other CSS rects (border box, padding box) for performance reasons. I can imagine v2 of the API being extended to support these and maybe fragments.
Layout worklets can solve the same problem, but would be more complex. |
Gecko also has a notion of "prev/next in flow" which allows traversal of all fragmented boxes very efficiently.
This is changing, given multicol layout, and will continue to change as paged overflow and regions get implemented. Expect custom layout to get fragmentation support as well (if not in V1) leading to all sorts of new ways to fragment content. I'm very reluctant to have new APIs continue the incorrect assumption made in the older DOM APIs of presuming a single box for each node. This will be a disservice in the long run and will work to prevent adoption (and implementation) of newer page layout techniques. If nothing else, craft the API to handle multiple boxes per node and allow current implementations to only return the first one, or the bounding rect (but then be clear it's a bounding rect), so that multiple boxes can be seamlessly handled in the future. |
@atotic @plinss I was talking about this with Martin Auswöger this morning and he pointed out that while ResizeObserver callbacks have access to the DOM, layout worklets do not. Many container-query-type use cases for ResizeObserver modify properties of observed elements’ decendants which are not related to layout (e.g., font sizes and colors). |
Please ignore the reference above, incorrectly linked from another issue. |
Thanks so much for the feedback! At our TAG f2f in Paris today we considered what the next steps should be, and believe that our initial review is complete. It does seem like there will be some new additions coming down the road, and we are excited to see what comes. For now, we'll close this issue, but hope that you consider filing a new issue or reactivating this one when you'd like to get some additional feedback from us! As always, thank you for the opportunity to provide feedback and thanks for flying TAG! |
Hello TAG!
I'm requesting a TAG review of:
Further details (optional):
Previous discussions/implementations:
Many of the interesting design decisions have been discussed on ResizeObserver github issues.
Chrome has implemented ResizeObserver behind a flag.
Firefox has worked on ResizeObserver implementation.
ResizeObserver has been discussed at TPAC meeting in Lisbon 2016.
We'd prefer the TAG provide feedback as (please select one):
The text was updated successfully, but these errors were encountered: