Title: [284327] trunk
Revision
284327
Author
za...@apple.com
Date
2021-10-16 16:36:42 -0700 (Sat, 16 Oct 2021)

Log Message

[LFC][IFC] Adjust the logical left side of the line with line spanning inline boxes
https://bugs.webkit.org/show_bug.cgi?id=231851

Reviewed by Antti Koivisto.

Source/WebCore:

This is in preparation for supporting "box-decoration-break: clone", where the
line spanning inline boxes do take up some space on the line with their horizontal margin, border and padding.

Test: fast/inline/inline-box-with-left-decoration-clone.html

* layout/formattingContexts/inline/InlineLine.cpp:
(WebCore::Layout::Line::initialize):
(WebCore::Layout::Line::Run::Run):
* layout/formattingContexts/inline/InlineLine.h:

LayoutTests:

* fast/inline/inline-box-with-left-decoration-clone-expected.html: Added.
* fast/inline/inline-box-with-left-decoration-clone.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (284326 => 284327)


--- trunk/LayoutTests/ChangeLog	2021-10-16 23:35:49 UTC (rev 284326)
+++ trunk/LayoutTests/ChangeLog	2021-10-16 23:36:42 UTC (rev 284327)
@@ -1,5 +1,15 @@
 2021-10-16  Alan Bujtas  <za...@apple.com>
 
+        [LFC][IFC] Adjust the logical left side of the line with line spanning inline boxes
+        https://bugs.webkit.org/show_bug.cgi?id=231851
+
+        Reviewed by Antti Koivisto.
+
+        * fast/inline/inline-box-with-left-decoration-clone-expected.html: Added.
+        * fast/inline/inline-box-with-left-decoration-clone.html: Added.
+
+2021-10-16  Alan Bujtas  <za...@apple.com>
+
         Undo some rebaseline in r284296.
 
         Unreviewed.

Added: trunk/LayoutTests/fast/inline/inline-box-with-left-decoration-clone-expected.html (0 => 284327)


--- trunk/LayoutTests/fast/inline/inline-box-with-left-decoration-clone-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/inline-box-with-left-decoration-clone-expected.html	2021-10-16 23:36:42 UTC (rev 284327)
@@ -0,0 +1,4 @@
+<div style="padding-left: 30px">this<br>inline box<br>has padding<br>and margin clone</div>
+<div style="padding-left: 60px">this<br>inline box<br>has padding<br>and margin clone</div>
+<div style="padding-left: 30px">this<br><span style="padding-left: 30px">inline box</span><br><span style="padding-left: 30px">has padding</span><br><span style="padding-left: 30px">and margin clone</span></div>
+<div style="padding-left: 30px">this<br>inline box<br>has padding<br><span style="padding-left: 30px">and margin clone</span></div>

Added: trunk/LayoutTests/fast/inline/inline-box-with-left-decoration-clone.html (0 => 284327)


--- trunk/LayoutTests/fast/inline/inline-box-with-left-decoration-clone.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/inline-box-with-left-decoration-clone.html	2021-10-16 23:36:42 UTC (rev 284327)
@@ -0,0 +1,12 @@
+<style>
+span { 
+  -webkit-box-decoration-break: clone;
+  padding-left: 10px;
+  margin-left: 20px;
+}
+</style>
+<!-- test the start side of the decoration clone -->
+<div><span>this<br>inline box<br>has padding<br>and margin clone</span></div>
+<div><span><span>this<br>inline box<br>has padding<br>and margin clone</span></span></div>
+<div><span>this<br><span>inline box<br>has padding<br>and margin clone</span></span></div>
+<div><span>this<br>inline box<br>has padding<br><span>and margin clone</span></span></div>

Modified: trunk/Source/WebCore/ChangeLog (284326 => 284327)


--- trunk/Source/WebCore/ChangeLog	2021-10-16 23:35:49 UTC (rev 284326)
+++ trunk/Source/WebCore/ChangeLog	2021-10-16 23:36:42 UTC (rev 284327)
@@ -1,3 +1,20 @@
+2021-10-16  Alan Bujtas  <za...@apple.com>
+
+        [LFC][IFC] Adjust the logical left side of the line with line spanning inline boxes
+        https://bugs.webkit.org/show_bug.cgi?id=231851
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for supporting "box-decoration-break: clone", where the
+        line spanning inline boxes do take up some space on the line with their horizontal margin, border and padding.
+
+        Test: fast/inline/inline-box-with-left-decoration-clone.html
+
+        * layout/formattingContexts/inline/InlineLine.cpp:
+        (WebCore::Layout::Line::initialize):
+        (WebCore::Layout::Line::Run::Run):
+        * layout/formattingContexts/inline/InlineLine.h:
+
 2021-10-16  Tim Horton  <timothy_hor...@apple.com>
 
         Unreviewed, reverting r284143.

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp (284326 => 284327)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2021-10-16 23:35:49 UTC (rev 284326)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2021-10-16 23:36:42 UTC (rev 284327)
@@ -57,8 +57,25 @@
     m_runs.clear();
     resetTrailingContent();
     auto appendLineSpanningInlineBoxes = [&] {
-        for (auto& inlineBoxStartItem : lineSpanningInlineBoxes)
-            m_runs.append({ inlineBoxStartItem });
+        for (auto& inlineBoxStartItem : lineSpanningInlineBoxes) {
+            auto shouldCheckForMarginBorderAndPadding = false;
+#if ENABLE(CSS_BOX_DECORATION_BREAK)
+            shouldCheckForMarginBorderAndPadding = inlineBoxStartItem.style().boxDecorationBreak() == BoxDecorationBreak::Clone;
+#endif
+            if (!shouldCheckForMarginBorderAndPadding) {
+                m_runs.append({ inlineBoxStartItem, contentLogicalRight(), { } });
+                continue;
+            }
+            // https://drafts.csswg.org/css-break/#break-decoration
+            // clone: Each box fragment is independently wrapped with the border, padding, and margin.
+            auto& inlineBoxGeometry = formattingContext().geometryForBox(inlineBoxStartItem.layoutBox());
+            auto runLogicalLeft = contentLogicalRight();
+            auto marginBorderAndPadding = inlineBoxGeometry.marginStart() + inlineBoxGeometry.borderLeft() + inlineBoxGeometry.paddingLeft().value_or(0_lu);
+            m_runs.append({ inlineBoxStartItem, runLogicalLeft, marginBorderAndPadding });
+            // Do not let negative margin make the content shorter than it already is.
+            auto runLogicalRight = runLogicalLeft + marginBorderAndPadding;
+            m_contentLogicalWidth = std::max(m_contentLogicalWidth, runLogicalRight);
+        }
     };
     appendLineSpanningInlineBoxes();
 }
@@ -515,9 +532,11 @@
 {
 }
 
-Line::Run::Run(const InlineItem& lineSpanningInlineBoxItem)
+Line::Run::Run(const InlineItem& lineSpanningInlineBoxItem, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
     : m_type(Type::LineSpanningInlineBoxStart)
     , m_layoutBox(&lineSpanningInlineBoxItem.layoutBox())
+    , m_logicalLeft(logicalLeft)
+    , m_logicalWidth(logicalWidth)
 {
     ASSERT(lineSpanningInlineBoxItem.isInlineBoxStart());
 }

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h (284326 => 284327)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h	2021-10-16 23:35:49 UTC (rev 284326)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h	2021-10-16 23:36:42 UTC (rev 284327)
@@ -114,7 +114,7 @@
         Run(const InlineSoftLineBreakItem&, InlineLayoutUnit logicalLeft);
         Run(const InlineItem&, const RenderStyle&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
         Run(const InlineItem&, InlineLayoutUnit logicalLeft);
-        Run(const InlineItem& lineSpanningInlineBoxItem);
+        Run(const InlineItem& lineSpanningInlineBoxItem, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
 
         void expand(const InlineTextItem&, InlineLayoutUnit logicalWidth);
         void moveHorizontally(InlineLayoutUnit offset) { m_logicalLeft += offset; }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to