Skip to content
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

Handle floats in BlockContainer::inline_content_sizes #29887

Merged
merged 1 commit into from
Jun 19, 2023

Conversation

Loirooriol
Copy link
Contributor

@Loirooriol Loirooriol commented Jun 17, 2023

Typically, block-level contents are stacked vertically, so this was just taking the maximum size among all contents. However, floats can be stacked horizontally, so we need to sum their sizes.


  • There are tests for these changes OR
  • These changes do not require tests because ___

@Loirooriol
Copy link
Contributor Author

@bors-servo try=wpt-2020

@bors-servo
Copy link
Contributor

⌛ Trying commit 4c3670c with merge 2f66102...

bors-servo added a commit that referenced this pull request Jun 17, 2023
Handle floats in BlockContainer::inline_content_sizes

Typically, block-level contents are stacked vertically, so this was just taking the maximum size among all contents. However, floats can be stacked horizontally, so we need to sum their sizes.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #29874

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@github-actions
Copy link

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

Stable unexpected results that are known to be intermittent (1)
  • PASS [expected TIMEOUT] /css/css-color/animation/opacity-animation-ending-correctly-002.html (#29216)

@bors-servo
Copy link
Contributor

☀️ Test successful - checks-github
State: approved= try=True

@Loirooriol
Copy link
Contributor Author

The tests changes are kinda by chance since width: max/min-content aren't supported yet. Should I add more tests, or does it suffice that with this patch, #29870 will no longer have regressions?

Copy link
Member

@mrobinson mrobinson left a comment

Choose a reason for hiding this comment

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

This is a really elegant solution. I only have a few small nits, but otherwise I think it looks good.

There's enough going on here that this should probably move to a free function like calculate_inline_content_size_for_block_level_boxes which gives a short rustdoc description of the approach taken along the lines of:

Find the maximum inline size of all the block level boxes and the summation of floated boxes, respecting the clear property of their siblings.

components/layout_2020/flow/mod.rs Outdated Show resolved Hide resolved
components/layout_2020/flow/mod.rs Outdated Show resolved Hide resolved
components/layout_2020/flow/mod.rs Outdated Show resolved Hide resolved
@Loirooriol Loirooriol force-pushed the float-inline-size-complete branch 2 times, most recently from 53b871a to 9d11f6f Compare June 19, 2023 13:40
@Loirooriol
Copy link
Contributor Author

@bors-servo try=wpt-2020

@bors-servo
Copy link
Contributor

⌛ Trying commit 9d11f6f with merge f8ad331...

bors-servo added a commit that referenced this pull request Jun 19, 2023
Handle floats in BlockContainer::inline_content_sizes

Typically, block-level contents are stacked vertically, so this was just taking the maximum size among all contents. However, floats can be stacked horizontally, so we need to sum their sizes.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #29874

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@bors-servo
Copy link
Contributor

💔 Test failed - checks-github

Typically, block-level contents are stacked vertically, so this was just
taking the maximum size among all contents. However, floats can be
stacked horizontally, so we need to sum their sizes.
@Loirooriol
Copy link
Contributor Author

@bors-servo try=wpt-2020

@bors-servo
Copy link
Contributor

⌛ Trying commit 4ec6dd1 with merge a7dc915...

bors-servo added a commit that referenced this pull request Jun 19, 2023
Handle floats in BlockContainer::inline_content_sizes

Typically, block-level contents are stacked vertically, so this was just taking the maximum size among all contents. However, floats can be stacked horizontally, so we need to sum their sizes.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #29874

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@bors-servo
Copy link
Contributor

☀️ Test successful - checks-github
State: approved= try=True

@Loirooriol
Copy link
Contributor Author

@bors-servo r=mrobinson

@bors-servo
Copy link
Contributor

📌 Commit 4ec6dd1 has been approved by mrobinson

@bors-servo
Copy link
Contributor

⌛ Testing commit 4ec6dd1 with merge 836ae5f...

@github-actions
Copy link

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

Flaky unexpected result (2)
  • OK /_mozilla/mozilla/task_queue_throttling.any.html (#22519)
    • FAIL [expected PASS] subtest: Throttling the performance timeline task queue. assert_true: expected true got false
  • TIMEOUT [expected FAIL] /css/css-backgrounds/background-size/vector/background-size-vector-013.html

@github-actions
Copy link

Test results for linux-wpt-layout-2013 from try job (#5313368453):

Flaky unexpected result (15)
  • TIMEOUT [expected OK] /FileAPI/url/url-charset.window.html (#26997)
    • TIMEOUT [expected PASS] subtest: Blob charset should override any auto-detected charset. Test timed out
  • TIMEOUT [expected OK] /_webgl/conformance/glsl/misc/shader-uniform-packing-restrictions.html (#28103)
    • NOTRUN [expected PASS] subtest: Overall test
  • TIMEOUT [expected OK] /_webgl/conformance/glsl/misc/shader-with-non-reserved-words.html (#16216)
    • 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/offsetTopLeft-border-box.html (#24237)
    • FAIL [expected PASS] subtest: container: 0 assert_equals: offsetTop expected 2 but got 0
    • FAIL [expected PASS] subtest: container: 1 assert_equals: offsetTop expected 2 but got 0
  • OK [expected TIMEOUT] /fetch/api/redirect/redirect-keepalive.any.html (#29536)
  • TIMEOUT [expected OK] /html/browsers/browsing-the-web/navigating-across-documents/navigate-to-unparseable-url.html (#29050)
    • TIMEOUT [expected FAIL] subtest: location.href setter throws a SyntaxError DOMException for unparseable URLs Test timed out
    • NOTRUN [expected FAIL] subtest: <a> tag navigate fails for unparseable URLs
  • TIMEOUT [expected OK] /html/browsers/origin/cross-origin-objects/cross-origin-objects.html (#28569)
  • OK /html/canvas/element/manual/image-smoothing/imagesmoothing.html (#28417)
    • FAIL [expected PASS] subtest: Test that imageSmoothingEnabled = false (nearest-neighbor interpolation) works with stroke() and createPattern(). assert_array_equals: expected property 1 to be 255 but got 96 (expected array [0, 255, 0, 255] got object "0,96,255,0")
  • TIMEOUT [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html (#22154)
    • NOTRUN [expected FAIL] subtest: Check that popups from a sandboxed iframe do not escape the sandbox
  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/sandbox-top-navigation-child-special-cases.tentative.sub.window.html (#29069)
  • TIMEOUT [expected OK] /html/semantics/forms/form-submission-0/reparent-form-during-planned-navigation-task.html (#29724)
    • TIMEOUT [expected PASS] subtest: reparent-form-during-planned-navigation-task Test timed out
  • OK /html/semantics/forms/form-submission-0/urlencoded2.window.html (#28687)
    • PASS [expected FAIL] subtest: application/x-www-form-urlencoded: 0x00 in filename (formdata event)
  • TIMEOUT [expected OK] /html/webappapis/scripting/processing-model-2/integration-with-the-javascript-job-queue/promise-job-entry-different-function-realm.html (#25805)
    • TIMEOUT [expected FAIL] subtest: Fulfillment handler on pending-then-fulfilled promise Test timed out
  • 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 (18)
  • OK [expected TIMEOUT] /_mozilla/mozilla/img_placeholder_load.html (#28717)
    • PASS [expected TIMEOUT] subtest: Loading a placeholder image should trigger an error on the img element
  • OK /_mozilla/mozilla/task_queue_throttling.any.html (#22519)
    • PASS [expected FAIL] subtest: Throttling the performance timeline task queue.
  • TIMEOUT /fetch/metadata/generated/css-images.sub.tentative.html (#29047)
    • TIMEOUT [expected PASS] subtest: background-image sec-fetch-user - Not sent to non-trustworthy same-site destination Test timed out
  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow.html (#28681)
    • FAIL [expected PASS] subtest: load & pageshow events do not fire on contentWindow of <iframe> element created with src='' assert_unreached: load should not be fired Reached unreachable code
    • FAIL [expected PASS] subtest: load & pageshow events do not fire on contentWindow of <iframe> element created with src='about:blank' assert_unreached: load should not be fired Reached unreachable code
    • PASS [expected FAIL] subtest: load & pageshow events do not fire on contentWindow of <iframe> element created with src='about:blank#foo'
  • OK [expected TIMEOUT] /html/browsers/browsing-the-web/read-media/pageload-image-in-popup.html (#23849)
    • FAIL [expected NOTRUN] subtest: The document for a standalone media file should have one child in the body. assert_equals: expected "image/png" but got "text/html"
  • OK /html/browsers/the-window-object/open-close/creating_browsing_context_test_01.html (#29046)
    • PASS [expected FAIL] subtest: first argument: absolute url
  • CRASH [expected OK] /html/browsers/windows/embedded-opener-remove-frame.html (#23867)
  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html (#22667)
    • FAIL [expected TIMEOUT] subtest: Check that popups from a sandboxed iframe escape the sandbox if
      allow-popups-to-escape-sandbox is used assert_equals: It came from a sandboxed iframe expected "null" but got "http://web-platform.test:8000"
  • OK [expected CRASH] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.html (#24066)
  • TIMEOUT [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.html (#24066)
    • NOTRUN [expected FAIL] subtest: Check that popups from a sandboxed iframe do not escape the sandbox
  • OK /html/semantics/forms/form-submission-0/multipart-formdata.window.html (#28725)
    • FAIL [expected PASS] subtest: multipart/form-data: \r\n in value (formdata event) assert_equals: expected "\r\nContent-Disposition: form-data; name="a"\r\n\r\nb\r\nc\r\n--\r\n" but got ""
  • OK /html/semantics/forms/historical.html (#28568)
    • FAIL [expected PASS] subtest: <input name=isindex> should not be supported assert_regexp_match: expected object "/?isindex=x$/" but got "about:blank"
  • TIMEOUT [expected OK] /html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_noopener.html (#23205)
    • NOTRUN [expected FAIL] subtest: Check that rel=noopener with target=_self does a normal load
  • TIMEOUT /html/webappapis/scripting/events/compile-event-handler-settings-objects.html (#24246)
    • FAIL [expected PASS] subtest: The entry settings object while executing the compiled callback via Web IDL's invoke must be that of the node document assert_equals: expected "/html/webappapis/scripting/events/resources/open-window.html" but got "blank"
  • TIMEOUT [expected OK] /webaudio/the-audio-api/the-audiocontext-interface/audiocontext-not-fully-active.html (#27664)
  • TIMEOUT [expected CRASH] /webmessaging/broadcastchannel/cross-partition.https.tentative.html (#29058)
  • OK [expected TIMEOUT] /webmessaging/with-ports/017.html (#24486)
    • PASS [expected TIMEOUT] subtest: origin of the script that invoked the method, about:blank
  • OK [expected TIMEOUT] /webmessaging/without-ports/018.html (#24485)
    • PASS [expected TIMEOUT] subtest: origin of the script that invoked the method, javascript:

@bors-servo
Copy link
Contributor

☀️ Test successful - checks-github
Approved by: mrobinson
Pushing 836ae5f to master...

@bors-servo bors-servo merged commit 836ae5f into servo:master Jun 19, 2023
@Loirooriol Loirooriol deleted the float-inline-size-complete branch June 19, 2023 20:26
Loirooriol added a commit to Loirooriol/servo that referenced this pull request Jul 19, 2023
calculate_inline_content_size_for_block_level_boxes was relying on
inline_content_sizes to get the size of each block-level box child.
For absolutely positioned boxes, this was 0x0.

That was no-op before servo#29887, but then it prevented adding the sizes
of a sequence of floats. Abspos should just be ignored instead of
treated as 0x0.

This patch removes inline_content_sizes, moves the logic into
calculate_inline_content_size_for_block_level_boxes (the only caller),
and handles abspos correctly.
bors-servo added a commit that referenced this pull request Jul 19, 2023
… r=<try>

Totally ignore abspos children for intrinsic sizing

calculate_inline_content_size_for_block_level_boxes was relying on inline_content_sizes to get the size of each block-level box child. For absolutely positioned boxes, this was 0x0.

That was no-op before #29887, but then it prevented adding the sizes of a sequence of floats. Abspos should just be ignored instead of treated as 0x0.

This patch removes inline_content_sizes, moves the logic into calculate_inline_content_size_for_block_level_boxes (the only caller), and handles abspos correctly.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #30009

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
github-merge-queue bot pushed a commit that referenced this pull request Jul 19, 2023
calculate_inline_content_size_for_block_level_boxes was relying on
inline_content_sizes to get the size of each block-level box child.
For absolutely positioned boxes, this was 0x0.

That was no-op before #29887, but then it prevented adding the sizes
of a sequence of floats. Abspos should just be ignored instead of
treated as 0x0.

This patch removes inline_content_sizes, moves the logic into
calculate_inline_content_size_for_block_level_boxes (the only caller),
and handles abspos correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Layout 2020: Implement preferred widths for floats
3 participants