Description
From w3c/IntersectionObserver#263 (comment) , I think the event loop section is pretty unclear about what it means by "update the rendering or user interface ... to reflect the current state". I've always assumed that bit meant to flush style and layout -- though I actually don't see where the spec even defines the concepts of flushing style and layout. But others have clearly assumed it meant the opposite.
I think this becomes important as we consider where to insert new things within the event loop:
- To get ideal performance characteristics, things that are primarily intended to write style information and in many cases don't need to read the results of style or layout should be before the implementation does its default flush of style and layout, so that if they do write style information, but don't ever read results of style or layout calculations, then no duplicate flushes are needed; if they end up writing then they can cause style or layout recalculation an extra time for part or all of the tree. An example of this would be
requestAnimationFrame
. - Likewise, things that are intended primarily to read the results of layout and not to write anything should be after the implementation does its default flush of style and layout, so that if they do only reading and not any writing of style, we'll likewise avoid flushing layout and/or style extra times. I think an example of this is the IntersectionObserver update steps (assuming I'm understanding the spec correctly).
Together, these factors mean that describing when the implementation does its default style and layout recalculation in the steps is important for the process of inserting new items into that list in a way that produces better performance characteristics for the web.
So I think the spec needs to be clearer about how the default per-refresh-cycle flush of style and layout fits into the steps to update the rendering. This may involve specifying flushing more clearly.
There was some work (which sort of petered out) in the Houdini group to try to define some of this stuff better, and this work may have some usable material to draw from. I think the primary information on that I have is the minutes from 2015-08-29 Part III.
/cc @ojanvafai @esprehn