Skip to content

Commit 6d41054

Browse files
committed
[LFC][IFC] Assign top/left to LineBox
https://bugs.webkit.org/show_bug.cgi?id=219218 Reviewed by Antti Koivisto. It makes the LineBox class more aligned with the spec (https://www.w3.org/TR/css-inline-3/#line-box). * layout/inlineformatting/InlineFormattingContextGeometry.cpp: (WebCore::Layout::LineBoxBuilder::build): (WebCore::Layout::InlineFormattingContext::Geometry::computedLineLogicalRect const): * layout/inlineformatting/InlineLineBox.cpp: (WebCore::Layout::LineBox::LineBox): * layout/inlineformatting/InlineLineBox.h: (WebCore::Layout::LineBox::logicalWidth const): (WebCore::Layout::LineBox::logicalHeight const): (WebCore::Layout::LineBox::logicalTopLeft const): (WebCore::Layout::LineBox::logicalSize const): (WebCore::Layout::LineBox::setLogicalHeight): Canonical link: https://commits.webkit.org/231844@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270135 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 2a2a0ee commit 6d41054

4 files changed

Lines changed: 32 additions & 10 deletions

File tree

Source/WebCore/ChangeLog

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
2020-11-20 Zalan Bujtas <zalan@apple.com>
2+
3+
[LFC][IFC] Assign top/left to LineBox
4+
https://bugs.webkit.org/show_bug.cgi?id=219218
5+
6+
Reviewed by Antti Koivisto.
7+
8+
It makes the LineBox class more aligned with the spec (https://www.w3.org/TR/css-inline-3/#line-box).
9+
10+
* layout/inlineformatting/InlineFormattingContextGeometry.cpp:
11+
(WebCore::Layout::LineBoxBuilder::build):
12+
(WebCore::Layout::InlineFormattingContext::Geometry::computedLineLogicalRect const):
13+
* layout/inlineformatting/InlineLineBox.cpp:
14+
(WebCore::Layout::LineBox::LineBox):
15+
* layout/inlineformatting/InlineLineBox.h:
16+
(WebCore::Layout::LineBox::logicalWidth const):
17+
(WebCore::Layout::LineBox::logicalHeight const):
18+
(WebCore::Layout::LineBox::logicalTopLeft const):
19+
(WebCore::Layout::LineBox::logicalSize const):
20+
(WebCore::Layout::LineBox::setLogicalHeight):
21+
122
2020-11-20 Simon Fraser <simon.fraser@apple.com>
223

324
Dispatch main-thread overflow scrolls to the scrolling thread as we do for page scrolls

Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ LineBox LineBoxBuilder::build(const LineBuilder::LineContent& lineContent)
157157
auto lineLogicalWidth = lineContent.lineLogicalWidth;
158158
auto contentLogicalWidth = lineContent.lineContentLogicalWidth;
159159
auto isLineConsideredEmpty = lineContent.isLineConsideredEmpty ? LineBox::IsLineConsideredEmpty::Yes : LineBox::IsLineConsideredEmpty::No;
160-
auto lineBox = LineBox { contentLogicalWidth, isLineConsideredEmpty };
160+
auto lineBox = LineBox { lineContent.logicalTopLeft, contentLogicalWidth, isLineConsideredEmpty };
161161

162162
if (auto horizontalAlignmentOffset = Layout::horizontalAlignmentOffset(runs, rootBox().style().textAlign(), lineLogicalWidth, contentLogicalWidth, lineContent.isLastLineWithInlineContent))
163163
lineBox.setHorizontalAlignmentOffset(*horizontalAlignmentOffset);
@@ -530,7 +530,7 @@ LineBox InlineFormattingContext::Geometry::lineBoxForLineContent(const LineBuild
530530

531531
InlineRect InlineFormattingContext::Geometry::computedLineLogicalRect(const LineBox& lineBox, const LineBuilder::LineContent& lineContent) const
532532
{
533-
return { lineContent.logicalTopLeft, lineContent.lineLogicalWidth, lineBox.logicalHeight() };
533+
return { lineBox.logicalTopLeft(), lineContent.lineLogicalWidth, lineBox.logicalHeight() };
534534
}
535535

536536
InlineLayoutUnit InlineFormattingContext::Geometry::logicalTopForNextLine(const LineBuilder::LineContent& lineContent, InlineLayoutUnit previousLineLogicalBottom, const FloatingContext& floatingContext) const

Source/WebCore/layout/inlineformatting/InlineLineBox.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ bool LineBox::InlineLevelBox::hasLineBoxRelativeAlignment() const
7575
return verticalAlignment == VerticalAlign::Top || verticalAlignment == VerticalAlign::Bottom;
7676
}
7777

78-
LineBox::LineBox(InlineLayoutUnit contentLogicalWidth, IsLineConsideredEmpty isLineConsideredEmpty)
79-
: m_logicalSize(contentLogicalWidth, { })
78+
LineBox::LineBox(const InlineLayoutPoint& logicalTopleft, InlineLayoutUnit contentLogicalWidth, IsLineConsideredEmpty isLineConsideredEmpty)
79+
: m_logicalRect(logicalTopleft, InlineLayoutSize { contentLogicalWidth, { } })
8080
, m_isConsideredEmpty(isLineConsideredEmpty == IsLineConsideredEmpty::Yes)
8181
{
8282
}

Source/WebCore/layout/inlineformatting/InlineLineBox.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,12 @@ class LineBox {
129129
};
130130

131131
enum class IsLineConsideredEmpty { No, Yes };
132-
LineBox(InlineLayoutUnit logicalWidth, IsLineConsideredEmpty);
132+
LineBox(const InlineLayoutPoint& logicalTopLeft, InlineLayoutUnit logicalWidth, IsLineConsideredEmpty);
133133

134-
InlineLayoutUnit logicalWidth() const { return m_logicalSize.width(); }
135-
InlineLayoutUnit logicalHeight() const { return m_logicalSize.height(); }
136-
InlineLayoutSize logicalSize() const { return m_logicalSize; }
134+
InlineLayoutUnit logicalWidth() const { return logicalSize().width(); }
135+
InlineLayoutUnit logicalHeight() const { return logicalSize().height(); }
136+
InlineLayoutPoint logicalTopLeft() const { return m_logicalRect.topLeft(); }
137+
InlineLayoutSize logicalSize() const { return m_logicalRect.size(); }
137138

138139
Optional<InlineLayoutUnit> horizontalAlignmentOffset() const { return m_horizontalAlignmentOffset; }
139140
bool isConsideredEmpty() const { return m_isConsideredEmpty; }
@@ -155,7 +156,7 @@ class LineBox {
155156
private:
156157
friend class LineBoxBuilder;
157158

158-
void setLogicalHeight(InlineLayoutUnit logicalHeight) { m_logicalSize.setHeight(logicalHeight); }
159+
void setLogicalHeight(InlineLayoutUnit logicalHeight) { m_logicalRect.setHeight(logicalHeight); }
159160
void setHorizontalAlignmentOffset(InlineLayoutUnit horizontalAlignmentOffset) { m_horizontalAlignmentOffset = horizontalAlignmentOffset; }
160161

161162
void addRootInlineBox(std::unique_ptr<InlineLevelBox>&&);
@@ -166,7 +167,7 @@ class LineBox {
166167
InlineLevelBox& inlineLevelBoxForLayoutBox(const Box& layoutBox) { return *m_inlineLevelBoxRectMap.get(&layoutBox); }
167168

168169
private:
169-
InlineLayoutSize m_logicalSize;
170+
InlineRect m_logicalRect;
170171
Optional<InlineLayoutUnit> m_horizontalAlignmentOffset;
171172
bool m_isConsideredEmpty { true };
172173

0 commit comments

Comments
 (0)