8000 [IFC] theverge.com: Article underlines don't appear and disappear whe… · WebKit/WebKit@4f7c6e8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f7c6e8

Browse files
committed
[IFC] theverge.com: Article underlines don't appear and disappear when expected
https://bugs.webkit.org/show_bug.cgi?id=250615 <rdar://103991852> Reviewed by Antti Koivisto. While LineLayout::contentBoxLogicalHeight should return the distance between the top of the first and the bottom of the last line box, for repaint we need the combination of the content height and the content box height, whichever is "taller": - line box may be taller than content e.g. line-height: 100; (spread out lines) - content may be taller than line box e.g. line-height: 0.5 (overlapping lines) * LayoutTests/fast/repaint/overlapping-lines-with-ink-overflow-expected.txt: Added. * LayoutTests/fast/repaint/overlapping-lines-with-ink-overflow.html: Added. * Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLine.h: (WebCore::InlineDisplay::Line::enclosingLogicalTopAndBottom const): (WebCore::InlineDisplay::Line::Line): (WebCore::InlineDisplay::Line::enclosingTopAndBottom const): Deleted. * Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp: (WebCore::LayoutIntegration::showInlineContent): * Source/WebCore/layout/integration/inline/InlineIteratorLineBoxModernPath.h: (WebCore::InlineIterator::LineBoxIteratorModernPath::contentLogicalTop const): (WebCore::InlineIterator::LineBoxIteratorModernPath::contentLogicalBottom const): * Source/WebCore/layout/integration/inline/LayoutIntegrationInlineContentBuilder.cpp: (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLines const): (WebCore::LayoutIntegration::operator+): Deleted. * Source/WebCore/layout/integration/inline/LayoutIntegrationLine.h: (WebCore::LayoutIntegration::Line::Line): (WebCore::LayoutIntegration::Line::enclosingContentLogicalTop const): (WebCore::LayoutIntegration::Line::enclosingContentLogicalBottom const): (WebCore::LayoutIntegration::Line::enclosingContentTop const): Deleted. (WebCore::LayoutIntegration::Line::enclosingContentBottom const): Deleted. * Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp: (WebCore::LayoutIntegration::LineLayout::contentLogicalHeight const): * Source/WebCore/layout/integration/inline/LayoutIntegrationPagination.cpp: (WebCore::LayoutIntegration::makeAdjustedContent): * Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp: (WebCore::Layout::showInlineTreeAndRuns): Canonical link: https://commits.webkit.org/258914@main
1 parent e6b6765 commit 4f7c6e8

12 files changed

+64
-LayoutTests/fast/repaint/overlapping-lines-with-ink-overflow-expected.txt
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
XXX
2+
XXX
3+
XXX
4+
XXX
5+
(repaint rects
6+
(rect 50 37 700 66)
7+
(rect 37 140 66 72)
8+
)
9+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<style>
2+
body {
3+
margin: 0px;
4+
}
5+
6+
div {
7+
line-height: 0.5;
8+
margin: 50px;
9+
font-family: Monospace;
10+
font-size: 40px;
11+
}
12+
</style>
13+
<!-- Pass if both lines are "underlined". -->
14+
<div><span id=box_shadow_horizontal>XXX<br>XXX</span></div>
15+
<div style="writing-mode: vertical-lr"><span id=box_shadow_vertical>XXX<br>XXX</span></div>
16+
<script src="resources/text-based-repaint.js" type="text/javascript"></script>
17+
<script>
18+
repaintTest = function() {
19+
box_shadow_horizontal.style.boxShadow = "inset green 0px -2px";
20+
box_shadow_vertical.style.boxShadow = "inset green -2px 0px";
21+
};
22+
runRepaintTest();
23+
</script>

Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLine.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Line {
5252
const FloatRect& lineBoxLogicalRect() const { return m_lineBoxLogicalRect; }
5353
const FloatRect& scrollableOverflow() const { return m_scrollableOverflow; }
5454

55-
EnclosingTopAndBottom enclosingTopAndBottom() const { return m_enclosingTopAndBottom; }
55+
EnclosingTopAndBottom enclosingLogicalTopAndBottom() const { return m_enclosingLogicalTopAndBottom; }
5656

5757
float baseline() const { return m_aligmentBaseline; }
5858
FontBaseline baselineType() const { return m_baselineType; }
@@ -74,7 +74,7 @@ class Line {
7474
// Enclosing top and bottom includes all inline level boxes (border box) vertically.
7575
// While the line box usually enclose them as well, its vertical geometry is based on
7676
// the layout bounds of the inline level boxes which may be different when line-height is present.
77-
EnclosingTopAndBottom m_enclosingTopAndBottom;
77+
EnclosingTopAndBottom m_enclosingLogicalTopAndBottom;
7878
float m_aligmentBaseline { 0.f };
7979
float m_contentVisualOffsetInInlineDirection { 0.f };
8080
float m_contentLogicalWidth { 0.f };
@@ -84,11 +84,11 @@ class Line {
8484
std::optional<FloatRect> m_ellipsisVisualRect { };
8585
};
8686

87-
inline Line::Line(const FloatRect& lineBoxLogicalRect, const FloatRect& lineBoxRect, const FloatRect& scrollableOverflow, EnclosingTopAndBottom enclosingTopAndBottom, float aligmentBaseline, FontBaseline baselineType, float contentVisualOffsetInInlineDirection, float contentLogicalWidth, bool isHorizontal, std::optional<FloatRect> ellipsisVisualRect)
87+
inline Line::Line(const FloatRect& lineBoxLogicalRect, const FloatRect& lineBoxRect, const FloatRect& scrollableOverflow, EnclosingTopAndBottom enclosingLogicalTopAndBottom, float aligmentBaseline, FontBaseline baselineType, float contentVisualOffsetInInlineDirection, float contentLogicalWidth, bool isHorizontal, std::optional<FloatRect> ellipsisVisualRect)
8888
: m_lineBoxRect(lineBoxRect)
8989
, m_lineBoxLogicalRect(lineBoxLogicalRect)
9090
, m_scrollableOverflow(scrollableOverflow)
91-
, m_enclosingTopAndBottom(enclosingTopAndBottom)
91+
, m_enclosingLogicalTopAndBottom(enclosingLogicalTopAndBottom)
9292
, m_aligmentBaseline(aligmentBaseline)
9393
, m_contentVisualOffsetInInlineDirection(contentVisualOffsetInInlineDirection)
9494
, m_contentLogicalWidth(contentLogicalWidth)

Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ void showInlineContent(TextStream& stream, const InlineContent& inlineContent, s
340340
};
341341
addSpacing(stream);
342342
auto& line = lines[lineIndex];
343-
stream << "line at (" << line.lineBoxLeft() << "," << line.lineBoxTop() << ") size (" << line.lineBoxRight() - line.lineBoxLeft() << "x" << line.lineBoxBottom() - line.lineBoxTop() << ") baseline (" << line.baseline() << ") enclosing top (" << line.enclosingContentTop() << ") bottom (" << line.enclosingContentBottom() << ")";
343+
stream << "line at (" << line.lineBoxLeft() << "," << line.lineBoxTop() << ") size (" << line.lineBoxRight() - line.lineBoxLeft() << "x" << line.lineBoxBottom() - line.lineBoxTop() << ") baseline (" << line.baseline() <&l 6D38 t; ") enclosing top (" << line.enclosingContentLogicalTop() << ") bottom (" << line.enclosingContentLogicalBottom() << ")";
344344
stream.nextLine();
345345

346346
addSpacing(stream);

Source/WebCore/layout/integration/inline/InlineIteratorLineBoxModernPath.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class LineBoxIteratorModernPath {
4747
LineBoxIteratorModernPath& operator=(const LineBoxIteratorModernPath&) = default;
4848
LineBoxIteratorModernPath& operator=(LineBoxIteratorModernPath&&) = default;
4949

50-
float contentLogicalTop() const { return line().enclosingContentTop(); }
51-
float contentLogicalBottom() const { return line().enclosingContentBottom(); }
50+
float contentLogicalTop() const { return line().enclosingContentLogicalTop(); }
51+
float contentLogicalBottom() const { return line().enclosingContentLogicalBottom(); }
5252
float logicalTop() const { return line().lineBoxLogicalRect().y(); }
5353
float logicalBottom() const { return line().lineBoxLogicalRect().maxY(); }
5454
float logicalWidth() const { return line().lineBoxLogicalRect().width(); }

Source/WebCore/layout/integration/inline/LayoutIntegrationInlineContentBuilder.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@
3838
namespace WebCore {
3939
namespace LayoutIntegration {
4040

41-
inline InlineDisplay::Line::EnclosingTopAndBottom operator+(const InlineDisplay::Line::EnclosingTopAndBottom enclosingTopAndBottom, float offset)
42-
{
43-
return { enclosingTopAndBottom.top + offset, enclosingTopAndBottom.bottom + offset };
44-
}
45-
4641
inline static float lineOverflowLogicalWidth(const RenderBlockFlow& flow, Layout::InlineLayoutUnit lineContentLogicalWidth)
4742
{
4843
// FIXME: It's the copy of the lets-adjust-overflow-for-the-caret behavior from LegacyLineLayout::addOverflowFromInlineChildren.
@@ -148,7 +143,7 @@ void InlineContentBuilder::createDisplayLines(Layout::InlineFormattingState& inl
148143
auto ellipsis = std::optional<Line::Ellipsis> { };
149144
if (auto ellipsisVisualRect = line.ellipsisVisualRect())
150145
ellipsis = { *ellipsisVisualRect, rootBoxStyle.isLeftToRightDirection() };
151-
inlineContent.lines.append({ firstBoxIndex, boxCount, line.lineBoxLogicalRect(), line.lineBoxRect(), line.enclosingTopAndBottom().top, line.enclosingTopAndBottom().bottom, scrollableOverflowRect, lineInkOverflowRect, line.baseline(), line.baselineType(), line.contentVisualOffsetInInlineDirection(), line.contentLogicalWidth(), line.isHorizontal(), ellipsis });
146+
inlineContent.lines.append({ firstBoxIndex, boxCount, line.lineBoxLogicalRect(), line.lineBoxRect(), line.enclosingLogicalTopAndBottom().top, line.enclosingLogicalTopAndBottom().bottom, scrollableOverflowRect, lineInkOverflowRect, line.baseline(), line.baselineType(), line.contentVisualOffsetInInlineDirection(), line.contentLogicalWidth(), line.isHorizontal(), ellipsis });
152147
}
153148
}
154149

Source/WebCore/layout/integration/inline/LayoutIntegrationLine.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ class Line {
4141
FloatRect visualRect;
4242
bool isLeftPositioned { true };
4343
};
44-
Line(size_t firstBoxIndex, size_t boxCount, const FloatRect& lineBoxLogicalRect, const FloatRect& lineBoxRect, float enclosingContentTop, float enclosingContentBottom, const FloatRect& scrollableOverflow, const FloatRect& inkOverflow, float baseline, FontBaseline baselineType, float contentVisualOffsetInInlineDirection, float contentLogicalWidth, bool isHorizontal, std::optional<Ellipsis> ellipsis, bool isFirstAfterPageBreak = false)
44+
Line(size_t firstBoxIndex, size_t boxCount, const FloatRect& lineBoxLogicalRect, const FloatRect& lineBoxRect, float enclosingContentLogicalTop, float enclosingContentLogicalBottom, const FloatRect& scrollableOverflow, const FloatRect& inkOverflow, float baseline, FontBaseline baselineType, float contentVisualOffsetInInlineDirection, float contentLogicalWidth, bool isHorizontal, std::optional<Ellipsis> ellipsis, bool isFirstAfterPageBreak = false)
4545
: m_firstBoxIndex(firstBoxIndex)
4646
, m_boxCount(boxCount)
4747
, m_lineBoxRect(lineBoxRect)
4848
, m_lineBoxLogicalRect(lineBoxLogicalRect)
49-
, m_enclosingContentTop(enclosingContentTop)
50-
, m_enclosingContentBottom(enclosingContentBottom)
49+
, m_enclosingContentLogicalTop(enclosingContentLogicalTop)
50+
, m_enclosingContentLogicalBottom(enclosingContentLogicalBottom)
5151
, m_scrollableOverflow(scrollableOverflow)
5252
, m_inkOverflow(inkOverflow)
5353
, m_baseline(baseline)
@@ -72,8 +72,8 @@ class Line {
7272

7373
FloatRect lineBoxLogicalRect() const { return m_lineBoxLogicalRect; }
7474

75-
float enclosingContentTop() const { return m_enclosingContentTop; }
76-
float enclosingContentBottom() const { return m_enclosingContentBottom; }
75+
float enclosingContentLogicalTop() const { return m_enclosingContentLogicalTop; }
76+
float enclosingContentLogicalBottom() const { return m_enclosingContentLogicalBottom; }
7777

7878
const FloatRect& scrollableOverflow() const { return m_scrollableOverflow; }
7979
const FloatRect& inkOverflow() const { return m_inkOverflow; }
@@ -102,8 +102,8 @@ class Line {
102102
// Enclosing top and bottom includes all inline level boxes (border box) vertically.
103103
// While the line box usually enclose them as well, its vertical geometry is based on
104104
// the layout bounds of the inline level boxes which may be different when line-height is present.
105-
float m_enclosingContentTop { 0 };
106-
float m_enclosingContentBottom { 0 };
105+
float m_enclosingContentLogicalTop { 0 };
106+
float m_enclosingContentLogicalBottom { 0 };
107107
FloatRect m_scrollableOverflow;
108108
FloatRect m_inkOverflow;
109109
float m_baseline { 0.f };

Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ std::optional<size_t> LineLayout::lastLineIndexForContentHeight() const
737737
return lines.size() - 1;
738738
}
739739

740-
LayoutUnit LineLayout::contentLogicalHeight() const
740+
LayoutUnit LineLayout::contentBoxLogicalHeight() const
741741
{
742742
if (!m_inlineContent)
743743
return { };
@@ -747,10 +747,9 @@ LayoutUnit LineLayout::contentLogicalHeight() const
747747
return { };
748748

749749
auto& lines = m_inlineContent->lines;
750-
auto flippedContentHeightForWritingMode = rootLayoutBox().style().isHorizontalWritingMode()
751-
? lines[*lastLineIndex].lineBoxBottom() - lines.first().lineBoxTop()
752-
: lines[*lastLineIndex].lineBoxRight() - lines.first().lineBoxLeft();
753-
return LayoutUnit { m_inlineContent->clearGapBeforeFirstLine + flippedContentHeightForWritingMode + m_inlineContent->clearGapAfterLastLine };
750+
auto& firstLine = lines[0];
751+
auto& lastLine = lines[*lastLineIndex];
752+
return LayoutUnit { m_inlineContent->clearGapBeforeFirstLine + (lastLine.lineBoxLogicalRect().maxY() - firstLine.lineBoxLogicalRect().y()) + m_inlineContent->clearGapAfterLastLine };
754753
}
755754

756755
size_t LineLayout::lineCount() const

Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class LineLayout : public CanMakeCheckedPtr {
9393
Vector<FloatRect> collectInlineBoxRects(const RenderInline&) const;
9494

9595
bool isPaginated() const { return m_isPaginatedContent; }
96-
LayoutUnit contentLogicalHeight() const;
96+
LayoutUnit contentBoxLogicalHeight() const;
9797
size_t lineCount() const;
9898
bool hasVisualOverflow() const;
9999
LayoutUnit firstLinePhysicalBaseline() const;

Source/WebCore/layout/integration/inline/LayoutIntegrationPagination.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ static std::unique_ptr<InlineContent> makeAdjustedContent(const InlineContent& i
133133
line.boxCount(),
134134
moveVertically(line.lineBoxLogicalRect(), offset),
135135
moveVertically({ FloatPoint { line.lineBoxLeft(), line.lineBoxTop() }, FloatPoint { line.lineBoxRight(), line.lineBoxBottom() } }, offset),
136-
line.enclosingContentTop() + offset,
137-
line.enclosingContentBottom() + offset,
136+
line.enclosingContentLogicalTop() + offset,
137+
line.enclosingContentLogicalBottom() + offset,
138138
moveVertically(line.scrollableOverflow(), offset),
139139
moveVertically(line.inkOverflow(), offset),
140140
line.baseline(),

0 commit comments

Comments
 (0)
0