Skip to content

Conversation

mrobinson
Copy link
Member

When layout was split into two phases, floats were laid out as direct
children of the inline formatting context. This meant that they were
positioned properly, but not properly made children of their inline
ancestors' stacking contexts. This change maintains the proper
positioning of floats, but positions them relatively to their inline
ancestors.

The big change here is that text-align needs to be taken into account
before actually laying out LineItems. This has the added benefit of
setting inline layout for the implementation of text-align: full. Now
all line items are laid out at the real final position and we can adjust
the start_corner property of float BoxFragments when their ancestors
are laid out.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • There are tests for these changes

@mrobinson mrobinson force-pushed the layout-float-inline branch from 32bd2a0 to 0de5c89 Compare August 21, 2023 17:00
}
}

/// Given the amount of whitespace trimmed from the start of the line and taking into consideration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment here says 'amount of whitespace trimmed from the start of the line' but in code, the value for whitespace_trimmed is set by the 'trim_whitespace_at_end` method. Is the comment here wrong or am I misunderstanding it?

Copy link
Member Author

@mrobinson mrobinson Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's a good point. I've updated this to simply say "the amount of whitespace trimmed from the line."

match text_align {
TextAlign::Start => line_start_position_from_indent,
TextAlign::End => {
containing_block.inline_size - real_line_length_without_indent +
Copy link
Member

@mukilan mukilan Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the calculation here correct?
For this test html, both layout 2020 master and legacy-layout have the same output as Firefox and Chrome, but this PR doesn't match those.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The calculation was incorrect! I have updated this in a way that I think corrects the case you mentioned and also have put a specification link and quote explaining why it's correct now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The text-align: end case doesn't seem to work similar to the other layouts & master for this case.

IIUC, the spec says 'text-indent' is treated as margin at the 'start' edge of the linebox and 'text-align: end' will align the contents to the 'end' edge of the box, so the margin cannot not influence the end edge unless the margin exceeds the available width.

@mrobinson mrobinson force-pushed the layout-float-inline branch from 0de5c89 to ed5f8a7 Compare August 22, 2023 12:39
@mrobinson
Copy link
Member Author

@bors-servo try=wpt-2020

@github-actions
Copy link

🔨 Triggering try run (#5938918429) with platform=linux and layout=2020

@github-actions
Copy link

Test results for linux-wpt-layout-2020 from try job (#5938918429):

Flaky unexpected result (7)
  • TIMEOUT [expected OK] /_webgl/conformance/reading/read-pixels-test.html (#28337)
    • NOTRUN [expected PASS] subtest: Overall test
  • TIMEOUT [expected OK] /_webgl/conformance/uniforms/out-of-bounds-uniform-array-access.html (#26225)
    • NOTRUN [expected PASS] subtest: Overall test
  • OK /css/cssom-view/scroll-behavior-smooth-navigation.html (#29564)
    • PASS [expected FAIL] subtest: Instant scrolling while doing history navigation.
  • OK /html/browsers/history/the-history-interface/traverse_the_history_4.html (#21383)
    • PASS [expected FAIL] subtest: Multiple history traversals, last would be aborted
  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html (#22154)
    • FAIL [expected NOTRUN] subtest: Check that popups from a sandboxed iframe do not escape the sandbox assert_equals: It came from a sandboxed iframe expected "null" but got "http://web-platform.test:8000"
  • OK /html/syntax/parsing/DOMContentLoaded-defer.html (#21550)
    • PASS [expected FAIL] subtest: The end: DOMContentLoaded and defer scripts
  • ERROR /resource-timing/content-type-parsing.html (#29131)
    • FAIL [expected TIMEOUT] subtest: mime-type 16 : text/html;charset=�gbk assert_equals: expected (string) "text/html" but got (undefined) undefined
    • TIMEOUT [expected NOTRUN] subtest: mime-type 17 : text/html;charset= gbk Test timed out
Stable unexpected results that are known to be intermittent (30)

@github-actions
Copy link

✨ Try run (#5938918429) succeeded.

@mrobinson
Copy link
Member Author

@mukilan Thanks for the review. I think this is ready to look at again, when you have a moment.

@mukilan
Copy link
Member

mukilan commented Aug 22, 2023

Thanks @mrobinson for updating the PR with the spec and comments! I've found one more case where 'text-end' doesn't work as other browsers. Please let me know if that is not in scope for this PR and needs to fixed separately as part of 'text-indent' stuff.

@mrobinson mrobinson force-pushed the layout-float-inline branch from ed5f8a7 to 1b4800e Compare August 22, 2023 15:30
@mrobinson
Copy link
Member Author

Thanks @mrobinson for updating the PR with the spec and comments! I've found one more case where 'text-end' doesn't work as other browsers. Please let me know if that is not in scope for this PR and needs to fixed separately as part of 'text-indent' stuff.

Thanks for pointing out this issue. I believe I've fixed it and have also added two WPT tests corresponding to the issues your raised above.

@servo-wpt-sync
Copy link
Collaborator

🤖 Opened new upstream WPT pull request (web-platform-tests/wpt#41585) with upstreamable changes.

@mrobinson mrobinson force-pushed the layout-float-inline branch from 1b4800e to c8fb806 Compare August 22, 2023 15:42
@servo-wpt-sync
Copy link
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#41585).

@mrobinson mrobinson force-pushed the layout-float-inline branch from c8fb806 to 59c187e Compare August 22, 2023 16:18
@servo-wpt-sync
Copy link
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#41585).

@mrobinson mrobinson force-pushed the layout-float-inline branch from 59c187e to ef93c51 Compare August 22, 2023 16:41
@servo-wpt-sync
Copy link
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#41585).

@mrobinson mrobinson added this pull request to the merge queue Aug 22, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 22, 2023
When layout was split into two phases, floats were laid out as direct
children of the inline formatting context. This meant that they were
positioned properly, but not properly made children of their inline
ancestors' stacking contexts. This change maintains the proper
positioning of floats, but positions them relatively to their inline
ancestors.

The big change here is that `text-align` needs to be taken into account
before actually laying out LineItems. This has the added benefit of
setting inline layout for the implementation of `text-align: full`. Now
all line items are laid out at the real final position and we can adjust
the `start_corner` property of float `BoxFragments` when their ancestors
are laid out.
@mrobinson mrobinson force-pushed the layout-float-inline branch from ef93c51 to 0c00c1a Compare August 22, 2023 19:48
@mrobinson
Copy link
Member Author

It seems that Layout 2013 does not pass this test...it looks like due to line breaking issues. All pipelines are passing in upstream WPT issue. I've updated the result and will send it back to the MQ.

@mrobinson mrobinson enabled auto-merge August 22, 2023 19:49
@servo-wpt-sync
Copy link
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#41585).

@mrobinson mrobinson added this pull request to the merge queue Aug 22, 2023
Merged via the queue into servo:master with commit bd285f5 Aug 23, 2023
@mrobinson mrobinson deleted the layout-float-inline branch August 23, 2023 00:19
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.

3 participants