-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Layout 2020: Float clearance can be negative #29904
Comments
This is my understanding of the spec. First we consider the hypothetical position as if This hypothetical position of the element’s top border edge is not past the relevant floats, so clearance is introduced, and margins collapse according to the rules in 8.3.1. That is, the margin no longer collapses with the start margin of the parent because they are no longer adjoining since they are separated by clearance. So now we are working with something like this (but the magenta element will be moved by the clearance): The spec allows 2 options:
It seems that, at least in this case, browsers use option 1, resulting in a clearance of Servo is doing something that looks closer to option 2, but it's wrong because:
Note the spec says:
If browsers are using option 1 then that's what a future CSS Flow spec will choose, so we should probably align with them. |
So, the problem is that when I have checked other browsers. Blink always inserts clearance when we would otherwise collapse with the parent, and this could move a relevant float. Firefox and WebKit only do so when the bottom outer edge of the float would overlap the element with Firefox and WebKit may seem to make more sense, but it seems more tricky so I guess aligning with Blink would be good enough. |
I definitely want to work on this, but I want to look at it a little bit more to come up with a concrete plan before making any changes |
Servo does not seem to be behaving the same way that it did when the ticket was created. It is now behaving as if Regardless, this can be fixed. @Loirooriol , I'm not sure I understand your previous comment, especially regarding "collapsing". It seems to me like the margin should be "collapsing" when However, I do understand the comment before that. I think that option 1 is the simplest and probably easiest to maintain. Another option that I've considered is simply ignoring the |
@joshua-holmes No, applying However, I don't recommend working on this issue as an introduction to Servo. Doing it properly requires doing speculative layouts, and undoing if the assumptions were wrong. I discussed some approaches with Ian Kilpatrick, who did a similar work in Blink, and he said that these details of block layout are the most tricky to implement in layout, and that things like flex and grid are much more straightforward. So maybe you would be interested in some flexbox work instead? There is a partial implementation, but lots of things missing or needing refinement. |
@Loirooriol , thanks for the insight! I didn't realize I picked such a complex task. I agree, I shouldn't pick something complex until I have some experience in the system. I'll take your advice and look into one of the recommended topics. |
https://drafts.csswg.org/css2/#clearance says
I need to check the spec in detail, but I suspect that this is one of these cases:
All Firefox, Blink and WebKit do something like this:
But the margin separates the cyan and magenta boxes in both layout 2013 and 2020.
Also, not sure if having a clearance of zero might be different than having no clearance in some corner cases.
The text was updated successfully, but these errors were encountered: