From 70982dfa5aaf176a46308aa4075128e8edd53da2 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Tue, 18 Jun 2024 18:19:00 +0200 Subject: [PATCH] layout: Allocate inline box start space on segment (#32486) Instead of allocating the inline padding and border space on the line, allocate it on the segment -- which where the inline box start goes. Co-authored-by: Rakhi Sharma --- components/layout_2020/flow/inline/mod.rs | 24 +++++++-------- tests/wpt/meta/MANIFEST.json | 30 +++++++++++++++++++ .../inline-box-border-line-break-ref.html | 22 ++++++++++++++ .../inline-box-border-line-break.html | 26 ++++++++++++++++ .../inline-box-padding-line-break.html | 26 ++++++++++++++++ 5 files changed, 116 insertions(+), 12 deletions(-) create mode 100644 tests/wpt/tests/css/CSS2/normal-flow/inline-box-border-line-break-ref.html create mode 100644 tests/wpt/tests/css/CSS2/normal-flow/inline-box-border-line-break.html create mode 100644 tests/wpt/tests/css/CSS2/normal-flow/inline-box-padding-line-break.html diff --git a/components/layout_2020/flow/inline/mod.rs b/components/layout_2020/flow/inline/mod.rs index 773c93a0a978..9b2fa77ab767 100644 --- a/components/layout_2020/flow/inline/mod.rs +++ b/components/layout_2020/flow/inline/mod.rs @@ -771,18 +771,6 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> { .map(|index| &self.fonts[index].metrics), ); - if inline_box.is_first_fragment { - self.current_line.inline_position += Length::from( - inline_box_state.pbm.padding.inline_start + - inline_box_state.pbm.border.inline_start, - ) + inline_box_state - .pbm - .margin - .inline_start - .auto_is(Au::zero) - .into() - } - // If we are starting a `
` element prepare to clear after its deferred linebreak has been // processed. Note that a `
` is composed of the element itself and the inner pseudo-element // with the actual linebreak. Both will have this `FragmentFlag`; that's why this code only @@ -796,6 +784,18 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> { self.deferred_br_clear = inline_box_state.base.style.clone_clear(); } + if inline_box.is_first_fragment { + self.current_line_segment.inline_size += Length::from( + inline_box_state.pbm.padding.inline_start + + inline_box_state.pbm.border.inline_start, + ) + inline_box_state + .pbm + .margin + .inline_start + .auto_is(Au::zero) + .into() + } + let line_item = inline_box_state .layout_into_line_item(inline_box.is_first_fragment, inline_box.is_last_fragment); self.push_line_item_to_unbreakable_segment(LineItem::StartInlineBox(line_item)); diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index f11458176717..0625de8d1dec 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -79166,6 +79166,32 @@ {} ] ], + "inline-box-border-line-break.html": [ + "6688d5e3ada2483288fc5f23c42a915d44a6300b", + [ + null, + [ + [ + "/css/CSS2/normal-flow/inline-box-border-line-break-ref.html", + "==" + ] + ], + {} + ] + ], + "inline-box-padding-line-break.html": [ + "70d518f411efb383debce5cd06cf604569217aee", + [ + null, + [ + [ + "/css/CSS2/normal-flow/inline-box-border-line-break-ref.html", + "==" + ] + ], + {} + ] + ], "inline-non-replaced-height-002.xht": [ "e3568f555d516824c3ccdb2a92cb925fadebf311", [ @@ -378853,6 +378879,10 @@ "22204233d95d1deb05ca71ae04a885434db1d3ac", [] ], + "inline-box-border-line-break-ref.html": [ + "6b66951fcc76b42253fb1486563a029bb845b9b2", + [] + ], "inline-non-replaced-height-002-ref.xht": [ "0cc109939200d47938bf06729b150ce54d8dcb55", [] diff --git a/tests/wpt/tests/css/CSS2/normal-flow/inline-box-border-line-break-ref.html b/tests/wpt/tests/css/CSS2/normal-flow/inline-box-border-line-break-ref.html new file mode 100644 index 000000000000..6b66951fcc76 --- /dev/null +++ b/tests/wpt/tests/css/CSS2/normal-flow/inline-box-border-line-break-ref.html @@ -0,0 +1,22 @@ + + + + + + + + + +
+ xx +
x
+ xx +
+ + + + + diff --git a/tests/wpt/tests/css/CSS2/normal-flow/inline-box-border-line-break.html b/tests/wpt/tests/css/CSS2/normal-flow/inline-box-border-line-break.html new file mode 100644 index 000000000000..6688d5e3ada2 --- /dev/null +++ b/tests/wpt/tests/css/CSS2/normal-flow/inline-box-border-line-break.html @@ -0,0 +1,26 @@ + + + + + + + + + + + +
+ xx + + x + xx +
+ + + + + diff --git a/tests/wpt/tests/css/CSS2/normal-flow/inline-box-padding-line-break.html b/tests/wpt/tests/css/CSS2/normal-flow/inline-box-padding-line-break.html new file mode 100644 index 000000000000..70d518f411ef --- /dev/null +++ b/tests/wpt/tests/css/CSS2/normal-flow/inline-box-padding-line-break.html @@ -0,0 +1,26 @@ + + + + + + + + + + + +
+ xx + + x + xx +
+ + + + +