Skip to content
Permalink
Browse files
[LFC][IFC] Adjust the logical left side of the line with line spannin…
…g 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.


Canonical link: https://commits.webkit.org/243122@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284327 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Oct 16, 2021
1 parent 03ad788 commit 2f74255eca5b1bae9efc762f03578a56e8515ac1
Showing 6 changed files with 66 additions and 4 deletions.
@@ -1,3 +1,13 @@
2021-10-16 Alan Bujtas <zalan@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 <zalan@apple.com>

Undo some rebaseline in r284296.
@@ -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>
@@ -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>
@@ -1,3 +1,20 @@
2021-10-16 Alan Bujtas <zalan@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_horton@apple.com>

Unreviewed, reverting r284143.
@@ -57,8 +57,25 @@ void Line::initialize(const Vector<InlineItem>& lineSpanningInlineBoxes)
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& zeroWidhtInlineItem, InlineLayoutUnit logicalLe
{
}

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());
}
@@ -114,7 +114,7 @@ class Line {
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; }

0 comments on commit 2f74255

Please sign in to comment.