Modified: trunk/Source/WebCore/ChangeLog (287319 => 287320)
--- trunk/Source/WebCore/ChangeLog 2021-12-21 17:46:03 UTC (rev 287319)
+++ trunk/Source/WebCore/ChangeLog 2021-12-21 17:58:56 UTC (rev 287320)
@@ -1,5 +1,20 @@
2021-12-21 Alan Bujtas <[email protected]>
+ [LFC][IFC] Move enclosing line geometry computation to a dedicated function
+ https://bugs.webkit.org/show_bug.cgi?id=234537
+
+ Reviewed by Antti Koivisto.
+
+ * layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
+ (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):
+ * layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp:
+ (WebCore::Layout::InlineDisplayLineBuilder::collectEnclosingLineGeometry const):
+ (WebCore::Layout::InlineDisplayLineBuilder::build const):
+ (WebCore::Layout::InlineDisplayLineBuilder::build): Deleted.
+ * layout/formattingContexts/inline/display/InlineDisplayLineBuilder.h:
+
+2021-12-21 Alan Bujtas <[email protected]>
+
[LFC][IFC] Start using Display::Line geometry in InlineDisplayContentBuilder
https://bugs.webkit.org/show_bug.cgi?id=234532
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp (287319 => 287320)
--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp 2021-12-21 17:46:03 UTC (rev 287319)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp 2021-12-21 17:58:56 UTC (rev 287320)
@@ -35,19 +35,10 @@
{
}
-InlineDisplay::Line InlineDisplayLineBuilder::build(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, InlineLayoutUnit lineBoxLogicalHeight, size_t lineIndex)
+InlineDisplayLineBuilder::EnclosingLineGeometry InlineDisplayLineBuilder::collectEnclosingLineGeometry(const LineBox& lineBox, const InlineRect& lineBoxRect) const
{
- auto& rootStyle = lineIndex ? root().firstLineStyle() : root().style();
- auto visualLeft = lineContent.lineLogicalTopLeft.x();
- if (!rootStyle.isLeftToRightDirection()) {
- // https://drafts.csswg.org/css-text/#text-indent-property
- // Since text-indent only initiates margin start, we just need to pull the linebox back to the left.
- visualLeft -= lineContent.lineMarginStart;
- }
- // FIXME: Use physical geometry here.
- auto lineBoxRect = InlineRect { lineContent.lineLogicalTopLeft.y(), visualLeft, lineContent.lineLogicalWidth, lineBoxLogicalHeight };
+ auto& rootInlineBox = lineBox.rootInlineBox();
auto scrollableOverflowRect = lineBoxRect;
- auto& rootInlineBox = lineBox.rootInlineBox();
auto enclosingTopAndBottom = InlineDisplay::Line::EnclosingTopAndBottom { lineBoxRect.top() + rootInlineBox.logicalTop(), lineBoxRect.top() + rootInlineBox.logicalBottom() };
for (auto& inlineLevelBox : lineBox.nonRootInlineLevelBoxes()) {
@@ -79,9 +70,26 @@
enclosingTopAndBottom.top = std::min(enclosingTopAndBottom.top, borderBox.top());
enclosingTopAndBottom.bottom = std::max(enclosingTopAndBottom.bottom, borderBox.bottom());
}
+ return { enclosingTopAndBottom, scrollableOverflowRect };
+}
+
+InlineDisplay::Line InlineDisplayLineBuilder::build(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, InlineLayoutUnit lineBoxLogicalHeight, size_t lineIndex) const
+{
+ auto& rootStyle = lineIndex ? root().firstLineStyle() : root().style();
+ auto lineBoxVisualLeft = lineContent.lineLogicalTopLeft.x();
+ if (!rootStyle.isLeftToRightDirection()) {
+ // https://drafts.csswg.org/css-text/#text-indent-property
+ // Since text-indent only initiates margin start, we just need to pull the linebox back to the left.
+ lineBoxVisualLeft -= lineContent.lineMarginStart;
+ }
+ // FIXME: Use physical geometry here.
+ auto lineBoxRect = InlineRect { lineContent.lineLogicalTopLeft.y(), lineBoxVisualLeft, lineContent.lineLogicalWidth, lineBoxLogicalHeight };
+ auto enclosingLineGeometry = collectEnclosingLineGeometry(lineBox, lineBoxRect);
+
+ auto& rootInlineBox = lineBox.rootInlineBox();
return InlineDisplay::Line { lineBoxRect
- , scrollableOverflowRect
- , enclosingTopAndBottom
+ , enclosingLineGeometry.scrollableOverflowRect
+ , enclosingLineGeometry.enclosingTopAndBottom
, rootInlineBox.logicalTop() + rootInlineBox.baseline()
, lineBox.rootInlineBoxAlignmentOffset() + rootInlineBox.logicalLeft()
, rootInlineBox.logicalWidth()
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.h (287319 => 287320)
--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.h 2021-12-21 17:46:03 UTC (rev 287319)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.h 2021-12-21 17:58:56 UTC (rev 287320)
@@ -40,9 +40,15 @@
public:
InlineDisplayLineBuilder(const InlineFormattingContext&);
- InlineDisplay::Line build(const LineBuilder::LineContent&, const LineBox&, InlineLayoutUnit lineBoxLogicalHeight, size_t lineIndex);
+ InlineDisplay::Line build(const LineBuilder::LineContent&, const LineBox&, InlineLayoutUnit lineBoxLogicalHeight, size_t lineIndex) const;
private:
+ struct EnclosingLineGeometry {
+ InlineDisplay::Line::EnclosingTopAndBottom enclosingTopAndBottom;
+ InlineRect scrollableOverflowRect;
+ };
+ EnclosingLineGeometry collectEnclosingLineGeometry(const LineBox&, const InlineRect& lineBoxRect) const;
+
const InlineFormattingContext& formattingContext() const { return m_inlineFormattingContext; }
const Box& root() const { return formattingContext().root(); }
LayoutState& layoutState() const { return formattingContext().layoutState(); }