Skip to content

Measure the content of a float before its shrink-to-fit width - #290

Open
eXpl0it3r wants to merge 1 commit into
masterfrom
fix/float-first-layout
Open

eXpl0it3r wants to merge 1 commit into
masterfrom
fix/float-first-layout

Conversation

@eXpl0it3r

Copy link
Copy Markdown
Collaborator

Description

A float with an auto width got a width of 0 on the first layout pass, so it wasn't painted and the text next to it was only indented by the float's margin. Calling PerformLayout a second time fixed it, which is why exported images looked fine, as HtmlRender.RenderToImage* measures and then lays out again, while HtmlPanel usually lays out once per Text change and the float stayed invisible.

The shrink-to-fit width (CSS 2.1 §10.3.5 and §10.3.7) adds up the widths of the words inside the box, but a box only measures its own words once its layout runs, and the float's children come after it. On the second pass the measurements were cached. Tables already measure all their descendants first, so that helper moved to CssBox and the float and absolute position path uses it too.

This was already recorded as a gap in the spec manifests, both gap tests pass now and lost their [Ignore]:

  • AutoWidthFloat_ShrinksToFitItsContent
  • Absolute_WithAutoWidth_ShrinksToFitItsContent

10.3.5 is supported now and the gap is removed from 10.3.7, css-sizing-3/4 and css-position-3. AutoWidthFloat_IsSizedByTheFirstLayout additionally covers the reported case, a float with a large font in an overflow: hidden block, laid out once, and checks that a second pass doesn't change the container's size.

How to test this PR?

CI should succeed. The image regression baselines are unchanged and the spec compliance check reports no problems.

The words of the descendants were only measured once their own layout ran, so on the first layout pass an auto width float or absolutely positioned box got a width of 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant