Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement CSS floats #25167
Implement CSS floats #25167
Comments
|
So I'm starting to look into this. I'll add questions as I get to them (cc @nox):
|
|
Could Maybe @mrobinson can say more: my understanding of why we have hoisting with this indirection at all, effectively turning a tree into a DAG, is the tension between:
This is why we need some fragments to "be in two places" in the fragment DAG pseudo-tree. We may also want to rethink the terminology: which of these two do we call hoisted, and which do we call "real"? Should we call the latter something else? The current name of the |
|
I think the description that @SimonSapin gave is great. For the case of absolutely positioned items we need to move them close to their parents for computing their position, but for building the display list we need them in tree order. I do have one question about floating content though. Do they need information from ancestors for size or position computation? If it's only about painting order, then we can probably use the "pseudo stacking context" approach which is more-or-less perfect for this case and already implemented. |
|
Ah, I see, it's a painting order thing. Makes sense. I don't believe that floats need information from ancestors for size/position calculation, but my memory is a bit fuzzy. |
|
Right, I believe floats do not have a "backward" data dependency like abspos does with the
That sounds appropriate since https://drafts.csswg.org/css2/zindex.html does say to handle a float “as if it created a new stacking context” anyway. @mrobinson Could you say more about what this approach does in our code? Especially in terms of how the data structures end up being shaped. |
Sure, there's currently a list of types of stacking contexts:
Looking over the code, it looks like this is halfway implemented. I think all that's required is to:
|
|
Another question:
|
|
Like all granularity levels of incremental, I think we can start without and still have the option to add this later. |
|
Spec questions/potential bugs/ambiguities discovered so far, from https://www.w3.org/TR/CSS2/visuren.html#float-position:
Is
Rule 3 states that "the right outer edge of a left-floating box may not be to the right of the left outer edge of any right-floating box that is next to it. Analogous rules hold for right-floating elements." This seems to indicate that I'm unsure what to do here, but for now I'll follow what I understand the spec to be rather than reverse engineering Gecko and Blink. |
…layout 2020, not yet wired to the rest of layout. This commit implements an object that handles the 10 rules in CSS 2.1: https://www.w3.org/TR/CSS2/visuren.html#float-position The implementation strategy is that of a persistent balanced binary search tree of float bands. Binary search trees are commonly used for implementing float positioning; e.g. by WebKit. Persistence enables each object that interacts with floats to efficiently contain a snapshot of the float list at the time that object was laid out. That way, incremental layout can invalidate and start reflow at any point in a containing block. This commit features extensive use of [QuickCheck](https://github.com/BurntSushi/quickcheck) to ensure that the rules of the CSS specification are followed. Because this is not yet connected to layout, floats will not actually be laid out in Web pages yet. Note that unit tests as set up in Servo currently require types that they access to be public. Therefore, some internal layout 2020 types that were previously private have been made public. This is somewhat unfortunate. Part of servo#25167.
|
@mrobinson I'm still a bit confused. Why can we not keep track of the position of the absolute/fixed containing block in addition to the position of the parent when traversing the tree for display list construction? Wouldn't we not need to hoist absolutely positioned objects at all then? |
|
Layout also needs hoisting. For example |
|
@pcwalton Currently, I think we track the containing block like you suggest during |
|
@SimonSapin Oh, OK, that makes sense. I guess the other option would be to store a link from every absolutely-positioned element to its containing block (WebKit has a |
|
Even with that link, we’d still need to delay laying out the abspos box until the height of its containing block is known which make require having finished laying out all of the in-flow content of that containing block. How does WebKit handle that? |
…layout 2020, not yet wired to the rest of layout. This commit implements an object that handles the 10 rules in CSS 2.1: https://www.w3.org/TR/CSS2/visuren.html#float-position The implementation strategy is that of a persistent balanced binary search tree of float bands. Binary search trees are commonly used for implementing float positioning; e.g. by WebKit. Persistence enables each object that interacts with floats to efficiently contain a snapshot of the float list at the time that object was laid out. That way, incremental layout can invalidate and start reflow at any point in a containing block. This commit features extensive use of [QuickCheck](https://github.com/BurntSushi/quickcheck) to ensure that the rules of the CSS specification are followed. Because this is not yet connected to layout, floats will not actually be laid out in Web pages yet. Note that unit tests as set up in Servo currently require types that they access to be public. Therefore, some internal layout 2020 types that were previously private have been made public. This is somewhat unfortunate. Part of servo#25167.
…layout 2020, not yet wired to the rest of layout. This commit implements an object that handles the 10 rules in CSS 2.1: https://www.w3.org/TR/CSS2/visuren.html#float-position The implementation strategy is that of a persistent balanced binary search tree of float bands. Binary search trees are commonly used for implementing float positioning; e.g. by WebKit. Persistence enables each object that interacts with floats to efficiently contain a snapshot of the float list at the time that object was laid out. That way, incremental layout can invalidate and start reflow at any point in a containing block. This commit features extensive use of [QuickCheck](https://github.com/BurntSushi/quickcheck) to ensure that the rules of the CSS specification are followed. Because this is not yet connected to layout, floats will not actually be laid out in Web pages yet. Note that unit tests as set up in Servo currently require types that they access to be public. Therefore, some internal layout 2020 types that were previously private have been made public. This is somewhat unfortunate. Part of servo#25167.
…layout 2020, not yet wired to the rest of layout. This commit implements an object that handles the 10 rules in CSS 2.1: https://www.w3.org/TR/CSS2/visuren.html#float-position The implementation strategy is that of a persistent balanced binary search tree of float bands. Binary search trees are commonly used for implementing float positioning; e.g. by WebKit. Persistence enables each object that interacts with floats to efficiently contain a snapshot of the float list at the time that object was laid out. That way, incremental layout can invalidate and start reflow at any point in a containing block. This commit features extensive use of [QuickCheck](https://github.com/BurntSushi/quickcheck) to ensure that the rules of the CSS specification are followed. Because this is not yet connected to layout, floats will not actually be laid out in Web pages yet. Note that unit tests as set up in Servo currently require types that they access to be public. Therefore, some internal layout 2020 types that were previously private have been made public. This is somewhat unfortunate. Part of servo#25167.
Used on https://servo.org for two-column layout.
We already have logic for disabling parallelism in a block formatting context that contains any float.
Drawing the rest of the owlactual layout implementation is missing as of this writing.