Title: [255257] trunk/Source/WebCore
Revision
255257
Author
za...@apple.com
Date
2020-01-28 10:26:02 -0800 (Tue, 28 Jan 2020)

Log Message

[LFC][IFC] Decouple Display::LineBox and Layout::LineBoxBuilder
https://bugs.webkit.org/show_bug.cgi?id=206861
<rdar://problem/58945284>

Reviewed by Antti Koivisto.

We should not mix logical and physical coordinates.

* WebCore.xcodeproj/project.pbxproj:
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::contentHeightForFormattingContextRoot const):
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
* layout/displaytree/DisplayLineBox.h:
(WebCore::Display::LineBox::Baseline::ascent const):
(WebCore::Display::LineBox::Baseline::descent const):
(WebCore::Display::LineBox::rect const):
(WebCore::Display::LineBox::left const):
(WebCore::Display::LineBox::right const):
(WebCore::Display::LineBox::top const):
(WebCore::Display::LineBox::bottom const):
(WebCore::Display::LineBox::width const):
(WebCore::Display::LineBox::height const):
(WebCore::Display::LineBox::baseline const):
(WebCore::Display::LineBox::baselineOffset const):
(WebCore::Display::LineBox::isConsideredEmpty const):
(WebCore::Display::LineBox::LineBox):
(WebCore::Display::LineBox::Baseline::Baseline):
(WebCore::Display::LineBox::logicalRect const): Deleted.
(WebCore::Display::LineBox::logicalTopLeft const): Deleted.
(WebCore::Display::LineBox::logicalLeft const): Deleted.
(WebCore::Display::LineBox::logicalRight const): Deleted.
(WebCore::Display::LineBox::logicalTop const): Deleted.
(WebCore::Display::LineBox::logicalBottom const): Deleted.
(WebCore::Display::LineBox::logicalWidth const): Deleted.
(WebCore::Display::LineBox::logicalHeight const): Deleted.
(WebCore::Display::LineBox::resetDescent): Deleted.
(WebCore::Display::LineBox::setLogicalTopLeft): Deleted.
(WebCore::Display::LineBox::setLogicalHeight): Deleted.
(WebCore::Display::LineBox::setLogicalWidth): Deleted.
(WebCore::Display::LineBox::setScrollableOverflow): Deleted.
(WebCore::Display::LineBox::setInkOverflow): Deleted.
(WebCore::Display::LineBox::moveHorizontally): Deleted.
(WebCore::Display::LineBox::expandHorizontally): Deleted.
(WebCore::Display::LineBox::shrinkHorizontally): Deleted.
(WebCore::Display::LineBox::expandVertically): Deleted.
(WebCore::Display::LineBox::shrinkVertically): Deleted.
(WebCore::Display::LineBox::setIsConsideredEmpty): Deleted.
(WebCore::Display::LineBox::setIsConsideredNonEmpty): Deleted.
(WebCore::Display::LineBox::setLogicalHeightIfGreater): Deleted.
(WebCore::Display::LineBox::setBaselineOffsetIfGreater): Deleted.
(WebCore::Display::LineBox::setAscentIfGreater): Deleted.
(WebCore::Display::LineBox::setDescentIfGreater): Deleted.
(WebCore::Display::LineBox::resetBaseline): Deleted.
(WebCore::Display::LineBox::Baseline::setAscent): Deleted.
(WebCore::Display::LineBox::Baseline::setDescent): Deleted.
(WebCore::Display::LineBox::Baseline::reset): Deleted.
* layout/displaytree/DisplayPainter.cpp:
(WebCore::Display::paintInlineContent):
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine):
* layout/inlineformatting/InlineFormattingContextQuirks.cpp:
(WebCore::Layout::InlineFormattingContext::Quirks::lineHeightConstraints const):
* layout/inlineformatting/InlineLineBox.h: Copied from Source/WebCore/layout/displaytree/DisplayLineBox.h.
(WebCore::Layout::LineBox::Baseline::height const):
(WebCore::Layout::LineBox::logicalRect const):
(WebCore::Layout::LineBox::scrollableOverflow const):
(WebCore::Layout::LineBox::logicalLeft const):
(WebCore::Layout::LineBox::logicalRight const):
(WebCore::Layout::LineBox::logicalTop const):
(WebCore::Layout::LineBox::logicalBottom const):
(WebCore::Layout::LineBox::logicalWidth const):
(WebCore::Layout::LineBox::logicalHeight const):
(WebCore::Layout::LineBox::resetDescent):
(WebCore::Layout::LineBox::setLogicalHeight):
(WebCore::Layout::LineBox::setLogicalWidth):
(WebCore::Layout::LineBox::setScrollableOverflow):
(WebCore::Layout::LineBox::moveHorizontally):
(WebCore::Layout::LineBox::expandHorizontally):
(WebCore::Layout::LineBox::shrinkHorizontally):
(WebCore::Layout::LineBox::expandVertically):
(WebCore::Layout::LineBox::shrinkVertically):
(WebCore::Layout::LineBox::isConsideredEmpty const):
(WebCore::Layout::LineBox::setIsConsideredEmpty):
(WebCore::Layout::LineBox::setIsConsideredNonEmpty):
(WebCore::Layout::LineBox::LineBox):
(WebCore::Layout::LineBox::setLogicalHeightIfGreater):
(WebCore::Layout::LineBox::baseline const):
(WebCore::Layout::LineBox::setBaselineOffsetIfGreater):
(WebCore::Layout::LineBox::setAscentIfGreater):
(WebCore::Layout::LineBox::setDescentIfGreater):
(WebCore::Layout::LineBox::baselineOffset const):
(WebCore::Layout::LineBox::resetBaseline):
(WebCore::Layout::LineBox::Baseline::Baseline):
(WebCore::Layout::LineBox::Baseline::setAscent):
(WebCore::Layout::LineBox::Baseline::setDescent):
(WebCore::Layout::LineBox::Baseline::reset):
(WebCore::Layout::LineBox::Baseline::ascent const):
(WebCore::Layout::LineBox::Baseline::descent const):
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::initialize):
(WebCore::Layout::LineBuilder::close):
(WebCore::Layout::LineBuilder::halfLeadingMetrics):
* layout/inlineformatting/InlineLineBuilder.h:
(WebCore::Layout::LineBuilder::contentLogicalRight const):
(WebCore::Layout::LineBuilder::lineBox const):
(WebCore::Layout::LineBuilder::contentLogicalWidth const):
* layout/inlineformatting/LineLayoutContext.cpp:
(WebCore::Layout::LineLayoutContext::layoutLine):
* layout/inlineformatting/LineLayoutContext.h:
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::contentLogicalHeight const):
(WebCore::LayoutIntegration::LineLayout::firstLineBaseline const):
(WebCore::LayoutIntegration::LineLayout::lastLineBaseline const):
(WebCore::LayoutIntegration::LineLayout::paint):
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::outputInlineRuns):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (255256 => 255257)


--- trunk/Source/WebCore/ChangeLog	2020-01-28 18:22:43 UTC (rev 255256)
+++ trunk/Source/WebCore/ChangeLog	2020-01-28 18:26:02 UTC (rev 255257)
@@ -1,3 +1,123 @@
+2020-01-28  Zalan Bujtas  <za...@apple.com>
+
+        [LFC][IFC] Decouple Display::LineBox and Layout::LineBoxBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=206861
+        <rdar://problem/58945284>
+
+        Reviewed by Antti Koivisto.
+
+        We should not mix logical and physical coordinates.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::contentHeightForFormattingContextRoot const):
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+        * layout/displaytree/DisplayLineBox.h:
+        (WebCore::Display::LineBox::Baseline::ascent const):
+        (WebCore::Display::LineBox::Baseline::descent const):
+        (WebCore::Display::LineBox::rect const):
+        (WebCore::Display::LineBox::left const):
+        (WebCore::Display::LineBox::right const):
+        (WebCore::Display::LineBox::top const):
+        (WebCore::Display::LineBox::bottom const):
+        (WebCore::Display::LineBox::width const):
+        (WebCore::Display::LineBox::height const):
+        (WebCore::Display::LineBox::baseline const):
+        (WebCore::Display::LineBox::baselineOffset const):
+        (WebCore::Display::LineBox::isConsideredEmpty const):
+        (WebCore::Display::LineBox::LineBox):
+        (WebCore::Display::LineBox::Baseline::Baseline):
+        (WebCore::Display::LineBox::logicalRect const): Deleted.
+        (WebCore::Display::LineBox::logicalTopLeft const): Deleted.
+        (WebCore::Display::LineBox::logicalLeft const): Deleted.
+        (WebCore::Display::LineBox::logicalRight const): Deleted.
+        (WebCore::Display::LineBox::logicalTop const): Deleted.
+        (WebCore::Display::LineBox::logicalBottom const): Deleted.
+        (WebCore::Display::LineBox::logicalWidth const): Deleted.
+        (WebCore::Display::LineBox::logicalHeight const): Deleted.
+        (WebCore::Display::LineBox::resetDescent): Deleted.
+        (WebCore::Display::LineBox::setLogicalTopLeft): Deleted.
+        (WebCore::Display::LineBox::setLogicalHeight): Deleted.
+        (WebCore::Display::LineBox::setLogicalWidth): Deleted.
+        (WebCore::Display::LineBox::setScrollableOverflow): Deleted.
+        (WebCore::Display::LineBox::setInkOverflow): Deleted.
+        (WebCore::Display::LineBox::moveHorizontally): Deleted.
+        (WebCore::Display::LineBox::expandHorizontally): Deleted.
+        (WebCore::Display::LineBox::shrinkHorizontally): Deleted.
+        (WebCore::Display::LineBox::expandVertically): Deleted.
+        (WebCore::Display::LineBox::shrinkVertically): Deleted.
+        (WebCore::Display::LineBox::setIsConsideredEmpty): Deleted.
+        (WebCore::Display::LineBox::setIsConsideredNonEmpty): Deleted.
+        (WebCore::Display::LineBox::setLogicalHeightIfGreater): Deleted.
+        (WebCore::Display::LineBox::setBaselineOffsetIfGreater): Deleted.
+        (WebCore::Display::LineBox::setAscentIfGreater): Deleted.
+        (WebCore::Display::LineBox::setDescentIfGreater): Deleted.
+        (WebCore::Display::LineBox::resetBaseline): Deleted.
+        (WebCore::Display::LineBox::Baseline::setAscent): Deleted.
+        (WebCore::Display::LineBox::Baseline::setDescent): Deleted.
+        (WebCore::Display::LineBox::Baseline::reset): Deleted.
+        * layout/displaytree/DisplayPainter.cpp:
+        (WebCore::Display::paintInlineContent):
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine):
+        * layout/inlineformatting/InlineFormattingContextQuirks.cpp:
+        (WebCore::Layout::InlineFormattingContext::Quirks::lineHeightConstraints const):
+        * layout/inlineformatting/InlineLineBox.h: Copied from Source/WebCore/layout/displaytree/DisplayLineBox.h.
+        (WebCore::Layout::LineBox::Baseline::height const):
+        (WebCore::Layout::LineBox::logicalRect const):
+        (WebCore::Layout::LineBox::scrollableOverflow const):
+        (WebCore::Layout::LineBox::logicalLeft const):
+        (WebCore::Layout::LineBox::logicalRight const):
+        (WebCore::Layout::LineBox::logicalTop const):
+        (WebCore::Layout::LineBox::logicalBottom const):
+        (WebCore::Layout::LineBox::logicalWidth const):
+        (WebCore::Layout::LineBox::logicalHeight const):
+        (WebCore::Layout::LineBox::resetDescent):
+        (WebCore::Layout::LineBox::setLogicalHeight):
+        (WebCore::Layout::LineBox::setLogicalWidth):
+        (WebCore::Layout::LineBox::setScrollableOverflow):
+        (WebCore::Layout::LineBox::moveHorizontally):
+        (WebCore::Layout::LineBox::expandHorizontally):
+        (WebCore::Layout::LineBox::shrinkHorizontally):
+        (WebCore::Layout::LineBox::expandVertically):
+        (WebCore::Layout::LineBox::shrinkVertically):
+        (WebCore::Layout::LineBox::isConsideredEmpty const):
+        (WebCore::Layout::LineBox::setIsConsideredEmpty):
+        (WebCore::Layout::LineBox::setIsConsideredNonEmpty):
+        (WebCore::Layout::LineBox::LineBox):
+        (WebCore::Layout::LineBox::setLogicalHeightIfGreater):
+        (WebCore::Layout::LineBox::baseline const):
+        (WebCore::Layout::LineBox::setBaselineOffsetIfGreater):
+        (WebCore::Layout::LineBox::setAscentIfGreater):
+        (WebCore::Layout::LineBox::setDescentIfGreater):
+        (WebCore::Layout::LineBox::baselineOffset const):
+        (WebCore::Layout::LineBox::resetBaseline):
+        (WebCore::Layout::LineBox::Baseline::Baseline):
+        (WebCore::Layout::LineBox::Baseline::setAscent):
+        (WebCore::Layout::LineBox::Baseline::setDescent):
+        (WebCore::Layout::LineBox::Baseline::reset):
+        (WebCore::Layout::LineBox::Baseline::ascent const):
+        (WebCore::Layout::LineBox::Baseline::descent const):
+        * layout/inlineformatting/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineBuilder::initialize):
+        (WebCore::Layout::LineBuilder::close):
+        (WebCore::Layout::LineBuilder::halfLeadingMetrics):
+        * layout/inlineformatting/InlineLineBuilder.h:
+        (WebCore::Layout::LineBuilder::contentLogicalRight const):
+        (WebCore::Layout::LineBuilder::lineBox const):
+        (WebCore::Layout::LineBuilder::contentLogicalWidth const):
+        * layout/inlineformatting/LineLayoutContext.cpp:
+        (WebCore::Layout::LineLayoutContext::layoutLine):
+        * layout/inlineformatting/LineLayoutContext.h:
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::contentLogicalHeight const):
+        (WebCore::LayoutIntegration::LineLayout::firstLineBaseline const):
+        (WebCore::LayoutIntegration::LineLayout::lastLineBaseline const):
+        (WebCore::LayoutIntegration::LineLayout::paint):
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::outputInlineRuns):
+
 2020-01-28  Jonathan Bedard  <jbed...@apple.com>
 
         WebCore: Guard uneven corners in rounded rectangles

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (255256 => 255257)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-01-28 18:22:43 UTC (rev 255256)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-01-28 18:26:02 UTC (rev 255257)
@@ -2072,6 +2072,7 @@
 		6F995A3A1A70833700A735F4 /* JSWebGLVertexArrayObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F995A301A70833700A735F4 /* JSWebGLVertexArrayObject.h */; };
 		6FA4454E898F2FC168BC38C1 /* JSBeforeUnloadEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 29E04A27BED2F81F98E9022B /* JSBeforeUnloadEvent.h */; };
 		6FB11B5C21783FD000E2A574 /* TextUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB11B5921783FCF00E2A574 /* TextUtil.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		6FB2400523DFF12800796458 /* InlineLineBoxBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB2400323DFF12700796458 /* InlineLineBoxBuilder.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6FB47E632277425A00C7BCB0 /* DisplayLineBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB47E612277425A00C7BCB0 /* DisplayLineBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6FB5E214221F2453003989CF /* ContentChangeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB5E212221F2447003989CF /* ContentChangeObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6FCE1A1A22618ABD004F0343 /* DisplayRun.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FCE1A1822618AB3004F0343 /* DisplayRun.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9348,6 +9349,7 @@
 		6FB11B5921783FCF00E2A574 /* TextUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUtil.h; sourceTree = "<group>"; };
 		6FB11B5B21783FCF00E2A574 /* TextUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextUtil.cpp; sourceTree = "<group>"; };
 		6FB22E30230097E300C20866 /* TableGrid.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TableGrid.h; sourceTree = "<group>"; };
+		6FB2400323DFF12700796458 /* InlineLineBoxBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineLineBoxBuilder.h; sourceTree = "<group>"; };
 		6FB47E612277425A00C7BCB0 /* DisplayLineBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayLineBox.h; sourceTree = "<group>"; };
 		6FB5E212221F2447003989CF /* ContentChangeObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentChangeObserver.h; sourceTree = "<group>"; };
 		6FBB860520B464B600DAD938 /* FormattingContextGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FormattingContextGeometry.cpp; sourceTree = "<group>"; };
@@ -16776,6 +16778,7 @@
 				115CFA7C208B8E10001E6991 /* InlineFormattingState.h */,
 				6F7B8CEC23626E6600C9FF15 /* InlineItem.cpp */,
 				6FE7CFA02177EEF1005B1573 /* InlineItem.h */,
+				6FB2400323DFF12700796458 /* InlineLineBoxBuilder.h */,
 				6FE198132178397B00446F08 /* InlineLineBreaker.cpp */,
 				6FE198152178397C00446F08 /* InlineLineBreaker.h */,
 				6F0CD692229ED31900C5994E /* InlineLineBuilder.cpp */,
@@ -30311,6 +30314,7 @@
 				115CFA7E208B8E10001E6991 /* InlineFormattingState.h in Headers */,
 				6FE7CFA22177EEF2005B1573 /* InlineItem.h in Headers */,
 				BCE789161120D6080060ECE5 /* InlineIterator.h in Headers */,
+				6FB2400523DFF12800796458 /* InlineLineBoxBuilder.h in Headers */,
 				6FE198172178397C00446F08 /* InlineLineBreaker.h in Headers */,
 				6F0CD695229ED32700C5994E /* InlineLineBuilder.h in Headers */,
 				6F360E5023999421001512A7 /* InlineSoftLineBreakItem.h in Headers */,

Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (255256 => 255257)


--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2020-01-28 18:22:43 UTC (rev 255256)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2020-01-28 18:26:02 UTC (rev 255257)
@@ -136,8 +136,8 @@
         auto& lineBoxes = layoutState.establishedInlineFormattingState(formattingRootContainer).displayInlineContent()->lineBoxes;
         // Even empty containers generate one line. 
         ASSERT(!lineBoxes.isEmpty());
-        top = lineBoxes.first().logicalTop();
-        bottom = lineBoxes.last().logicalBottom();
+        top = lineBoxes.first().top();
+        bottom = lineBoxes.last().bottom();
     } else if (formattingRootContainer.establishesBlockFormattingContext() || formattingRootContainer.establishesTableFormattingContext() || formattingRootContainer.isDocumentBox()) {
         if (formattingRootContainer.hasInFlowChild()) {
             auto& firstBoxGeometry = formattingContext.geometryForBox(*formattingRootContainer.firstInFlowChild(), EscapeReason::NeedsGeometryFromEstablishedFormattingContext);

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (255256 => 255257)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2020-01-28 18:22:43 UTC (rev 255256)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2020-01-28 18:26:02 UTC (rev 255257)
@@ -77,7 +77,7 @@
             auto& lineBoxes = layoutState().establishedInlineFormattingState(layoutContainer).displayInlineContent()->lineBoxes;
             // Even empty containers generate one line. 
             ASSERT(!lineBoxes.isEmpty());
-            return { toLayoutUnit(lineBoxes.last().logicalBottom()) - borderAndPaddingTop, nonCollapsedMargin };
+            return { toLayoutUnit(lineBoxes.last().bottom()) - borderAndPaddingTop, nonCollapsedMargin };
         }
 
         // 2. the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin...

Modified: trunk/Source/WebCore/layout/displaytree/DisplayLineBox.h (255256 => 255257)


--- trunk/Source/WebCore/layout/displaytree/DisplayLineBox.h	2020-01-28 18:22:43 UTC (rev 255256)
+++ trunk/Source/WebCore/layout/displaytree/DisplayLineBox.h	2020-01-28 18:26:02 UTC (rev 255257)
@@ -27,7 +27,6 @@
 
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
-#include "DisplayBox.h"
 #include "DisplayInlineRect.h"
 
 namespace WebCore {
@@ -38,46 +37,34 @@
 public:
     struct Baseline {
         Baseline(InlineLayoutUnit ascent, InlineLayoutUnit descent);
-        Baseline() = default;
 
-        void setAscent(InlineLayoutUnit);
-        void setDescent(InlineLayoutUnit);
-
-        void reset();
-
         InlineLayoutUnit height() const { return ascent() + descent(); }
-        InlineLayoutUnit ascent() const;
-        InlineLayoutUnit descent() const;
+        InlineLayoutUnit ascent() const { return m_ascent; }
+        InlineLayoutUnit descent() const { return m_descent; }
 
     private:
-#if ASSERT_ENABLED
-        bool m_hasValidAscent { false };
-        bool m_hasValidDescent { false };
-#endif
-        InlineLayoutUnit m_ascent;
-        InlineLayoutUnit m_descent;
+        InlineLayoutUnit m_ascent { 0 };
+        InlineLayoutUnit m_descent { 0 };
     };
 
-    LineBox(const InlineRect&, const Baseline&, InlineLayoutUnit baselineOffset);
-    LineBox() = default;
+    LineBox(const InlineRect&, const InlineRect& scrollableOverflow, const InlineRect& inkOverflow, const Baseline&, InlineLayoutUnit baselineOffset, bool isConsideredEmpty);
 
-    const InlineRect& logicalRect() const { return m_rect; }
+    const InlineRect& rect() const { return m_rect; }
     const InlineRect& scrollableOverflow() const { return m_scrollableOverflow; }
     const InlineRect& inkOverflow() const { return m_inkOverflow; }
 
-    InlineLayoutPoint logicalTopLeft() const { return m_rect.topLeft(); }
-    InlineLayoutUnit logicalLeft() const { return m_rect.left(); }
-    InlineLayoutUnit logicalRight() const { return m_rect.right(); }
-    InlineLayoutUnit logicalTop() const { return m_rect.top(); }
-    InlineLayoutUnit logicalBottom() const { return m_rect.bottom(); }
+    InlineLayoutUnit left() const { return m_rect.left(); }
+    InlineLayoutUnit right() const { return m_rect.right(); }
+    InlineLayoutUnit top() const { return m_rect.top(); }
+    InlineLayoutUnit bottom() const { return m_rect.bottom(); }
 
-    InlineLayoutUnit logicalWidth() const { return m_rect.width(); }
-    InlineLayoutUnit logicalHeight() const { return m_rect.height(); }
+    InlineLayoutUnit width() const { return m_rect.width(); }
+    InlineLayoutUnit height() const { return m_rect.height(); }
 
-    const Baseline& baseline() const;
-    // Baseline offset from line logical top. Note that offset does not necessarily equal to ascent.
+    const Baseline& baseline() const { return m_baseline; }
+    // Baseline offset from line top. Note that offset does not necessarily equal to ascent.
     //
-    // -------------------    line logical top     ------------------- (top align)
+    // -------------------        line top         ------------------- (top align)
     //             ^                                              ^
     //             |                                  ^           |
     //   ^         | baseline offset                  |           | baseline offset
@@ -89,166 +76,36 @@
     //   ^                                            | descent
     //   | descent                                    v
     //   v
-    // -------------------    line logical bottom  -------------------
-    InlineLayoutUnit baselineOffset() const;
-    void setBaselineOffsetIfGreater(InlineLayoutUnit);
-    void setAscentIfGreater(InlineLayoutUnit);
-    void setDescentIfGreater(InlineLayoutUnit);
-
-    void resetBaseline();
-    void resetDescent() { m_baseline.setDescent(0_lu); }
-
-    void setLogicalTopLeft(const InlineLayoutPoint& logicalTopLeft) { m_rect.setTopLeft(logicalTopLeft); }
-    void setLogicalHeight(InlineLayoutUnit logicalHeight) { m_rect.setHeight(logicalHeight); }
-
-    void setLogicalHeightIfGreater(InlineLayoutUnit);
-    void setLogicalWidth(InlineLayoutUnit logicalWidth) { m_rect.setWidth(logicalWidth); }
-
-    void setScrollableOverflow(const InlineRect& rect) { m_scrollableOverflow = rect; }
-    void setInkOverflow(const InlineRect& rect) { m_inkOverflow = rect; }
-
-    void moveHorizontally(InlineLayoutUnit delta) { m_rect.moveHorizontally(delta); }
-
-    void expandHorizontally(InlineLayoutUnit delta) { m_rect.expandHorizontally(delta); }
-    void shrinkHorizontally(InlineLayoutUnit delta) { expandHorizontally(-delta); }
-
-    void expandVertically(InlineLayoutUnit delta) { m_rect.expandVertically(delta); }
-    void shrinkVertically(InlineLayoutUnit delta) { expandVertically(-delta); }
-
-    // https://www.w3.org/TR/CSS22/visuren.html#inline-formatting
-    // Line boxes that contain no text, no preserved white space, no inline elements with non-zero margins, padding, or borders,
-    // and no other in-flow content (such as images, inline blocks or inline tables), and do not end with a preserved newline
-    // must be treated as zero-height line boxes for the purposes of determining the positions of any elements inside of them,
-    // and must be treated as not existing for any other purpose.
-    // Note that it does not necessarily mean visually non-empty line. <span style="font-size: 0px">this is still considered non-empty</span>
+    // -------------------       line bottom       -------------------
+    InlineLayoutUnit baselineOffset() const { return m_baselineOffset; }
     bool isConsideredEmpty() const { return m_isConsideredEmpty; }
-    void setIsConsideredEmpty() { m_isConsideredEmpty = true; }
-    void setIsConsideredNonEmpty() { m_isConsideredEmpty = false; }
 
 private:
-#if ASSERT_ENABLED
-    bool m_hasValidBaseline { false };
-    bool m_hasValidBaselineOffset { false };
-#endif
     InlineRect m_rect;
     InlineRect m_scrollableOverflow;
     InlineRect m_inkOverflow;
     Baseline m_baseline;
-    InlineLayoutUnit m_baselineOffset;
+    InlineLayoutUnit m_baselineOffset { 0 };
     bool m_isConsideredEmpty { true };
 };
 
-inline LineBox::LineBox(const InlineRect& rect, const Baseline& baseline, InlineLayoutUnit baselineOffset)
+inline LineBox::LineBox(const InlineRect& rect, const InlineRect& scrollableOverflow, const InlineRect& inkOverflow, const Baseline& baseline, InlineLayoutUnit baselineOffset, bool isConsideredEmpty)
     : m_rect(rect)
+    , m_scrollableOverflow(scrollableOverflow)
+    , m_inkOverflow(inkOverflow)
     , m_baseline(baseline)
     , m_baselineOffset(baselineOffset)
+    , m_isConsideredEmpty(isConsideredEmpty)
 {
-#if ASSERT_ENABLED
-    m_hasValidBaseline = true;
-    m_hasValidBaselineOffset = true;
-#endif
 }
 
-inline void LineBox::setLogicalHeightIfGreater(InlineLayoutUnit logicalHeight)
-{
-    if (logicalHeight <= m_rect.height())
-        return;
-    m_rect.setHeight(logicalHeight);
-}
-
-inline const LineBox::Baseline& LineBox::baseline() const
-{
-    ASSERT(m_hasValidBaseline);
-    return m_baseline;
-}
-
-inline void LineBox::setBaselineOffsetIfGreater(InlineLayoutUnit baselineOffset)
-{
-#if ASSERT_ENABLED
-    m_hasValidBaselineOffset = true;
-#endif
-    m_baselineOffset = std::max(baselineOffset, m_baselineOffset);
-}
-
-inline void LineBox::setAscentIfGreater(InlineLayoutUnit ascent)
-{
-    if (ascent < m_baseline.ascent())
-        return;
-    setBaselineOffsetIfGreater(ascent);
-    m_baseline.setAscent(ascent);
-}
-
-inline void LineBox::setDescentIfGreater(InlineLayoutUnit descent)
-{
-    if (descent < m_baseline.descent())
-        return;
-    m_baseline.setDescent(descent);
-}
-
-inline InlineLayoutUnit LineBox::baselineOffset() const
-{
-    ASSERT(m_hasValidBaselineOffset);
-    return m_baselineOffset;
-}
-
-inline void LineBox::resetBaseline()
-{
-#if ASSERT_ENABLED
-    m_hasValidBaselineOffset = true;
-#endif
-    m_baselineOffset = 0_lu;
-    m_baseline.reset();
-}
-
 inline LineBox::Baseline::Baseline(InlineLayoutUnit ascent, InlineLayoutUnit descent)
     : m_ascent(ascent)
     , m_descent(descent)
 {
-#if ASSERT_ENABLED
-    m_hasValidAscent = true;
-    m_hasValidDescent = true;
-#endif
 }
 
-inline void LineBox::Baseline::setAscent(InlineLayoutUnit ascent)
-{
-#if ASSERT_ENABLED
-    m_hasValidAscent = true;
-#endif
-    m_ascent = ascent;
 }
-
-inline void LineBox::Baseline::setDescent(InlineLayoutUnit descent)
-{
-#if ASSERT_ENABLED
-    m_hasValidDescent = true;
-#endif
-    m_descent = descent;
 }
 
-inline void LineBox::Baseline::reset()
-{
-#if ASSERT_ENABLED
-    m_hasValidAscent = true;
-    m_hasValidDescent = true;
 #endif
-    m_ascent = 0_lu;
-    m_descent = 0_lu;
-}
-
-inline InlineLayoutUnit LineBox::Baseline::ascent() const
-{
-    ASSERT(m_hasValidAscent);
-    return m_ascent;
-}
-
-inline InlineLayoutUnit LineBox::Baseline::descent() const
-{
-    ASSERT(m_hasValidDescent);
-    return m_descent;
-}
-
-}
-}
-
-#endif

Modified: trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp (255256 => 255257)


--- trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp	2020-01-28 18:22:43 UTC (rev 255256)
+++ trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp	2020-01-28 18:26:02 UTC (rev 255257)
@@ -129,9 +129,9 @@
             auto absoluteLeft = absoluteOffset.x() + run.left();
             // FIXME: Add non-baseline align painting
             auto& lineBox = displayInlineContent->lineBoxForRun(run);
-            auto baselineOffset = absoluteOffset.y() + lineBox.logicalTop() + lineBox.baselineOffset();
+            auto baselineOffset = absoluteOffset.y() + lineBox.top() + lineBox.baselineOffset();
             auto expansionContext = textContext->expansion();
-            auto textRun = TextRun { textContext->content(), run.left() - lineBox.logicalLeft(),
+            auto textRun = TextRun { textContext->content(), run.left() - lineBox.left(),
                 expansionContext ? expansionContext->horizontalExpansion : 0,
                 expansionContext ? expansionContext->behavior : DefaultExpansion };
             textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize());

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (255256 => 255257)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2020-01-28 18:22:43 UTC (rev 255256)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2020-01-28 18:26:02 UTC (rev 255257)
@@ -424,6 +424,7 @@
 void InlineFormattingContext::setDisplayBoxesForLine(const LineLayoutContext::LineContent& lineContent, const HorizontalConstraints& horizontalConstraints)
 {
     auto& formattingState = this->formattingState();
+    auto& lineBox = lineContent.lineBox;
 
     if (!lineContent.floats.isEmpty()) {
         auto floatingContext = FloatingContext { root(), *this, formattingState.floatingState() };
@@ -432,7 +433,6 @@
             auto& floatBox = floatItem->layoutBox();
             auto& displayBox = formattingState.displayBox(floatBox);
             // Set static position first.
-            auto& lineBox = lineContent.lineBox;
             displayBox.setTopLeft({ lineBox.logicalLeft(), lineBox.logicalTop() });
             // Float it.
             displayBox.setTopLeft(floatingContext.positionForFloat(floatBox));
@@ -448,8 +448,7 @@
         initialContaingBlockSize = geometryForBox(root().initialContainingBlock(), EscapeReason::StrokeOverflowNeedsViewportGeometry).contentBox().size();
     auto& inlineContent = formattingState.ensureDisplayInlineContent();
     auto lineIndex = inlineContent.lineBoxes.size();
-    inlineContent.lineBoxes.append(lineContent.lineBox);
-    auto lineInkOverflow = lineContent.lineBox.scrollableOverflow();
+    auto lineInkOverflow = lineBox.scrollableOverflow();
     Optional<unsigned> lastTextItemIndex;
     // Compute box final geometry.
     auto& lineRuns = lineContent.runList;
@@ -540,7 +539,9 @@
     // Make sure the trailing text run gets a hyphen when it needs one.
     if (lineContent.partialContent && lineContent.partialContent->trailingContentNeedsHyphen)
         inlineContent.runs[*lastTextItemIndex].textContext()->setNeedsHyphen();
-    inlineContent.lineBoxes.last().setInkOverflow(lineInkOverflow);
+    // FIXME: This is where the logical to physical translate should happen.
+    auto& baseline = lineBox.baseline();
+    inlineContent.lineBoxes.append({ lineBox.logicalRect(), lineBox.scrollableOverflow(), lineInkOverflow, { baseline.ascent(), baseline.descent() }, lineBox.baselineOffset(), lineBox.isConsideredEmpty() });
 }
 
 void InlineFormattingContext::invalidateFormattingState(const InvalidationState&)

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp (255256 => 255257)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp	2020-01-28 18:22:43 UTC (rev 255256)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp	2020-01-28 18:26:02 UTC (rev 255257)
@@ -83,12 +83,12 @@
     auto lineHeight = formattingRoot.style().lineHeight();
     if (lineHeight.isPercentOrCalculated()) {
         auto initialBaselineOffset = LineBuilder::halfLeadingMetrics(formattingRoot.style().fontMetrics(), 0_lu).ascent();
-        return { initialBaselineOffset, initialBaselineOffset, Display::LineBox::Baseline { strutBaselineOffset, strutHeight - strutBaselineOffset } };
+        return { initialBaselineOffset, initialBaselineOffset, LineBoxBuilder::Baseline { strutBaselineOffset, strutHeight - strutBaselineOffset } };
     }
     // FIXME: The only reason why we use intValue() here is to match current inline tree (integral)behavior.
     InlineLayoutUnit initialLineHeight = lineHeight.intValue();
     auto initialBaselineOffset = LineBuilder::halfLeadingMetrics(formattingRoot.style().fontMetrics(), initialLineHeight).ascent();
-    return { initialLineHeight, initialBaselineOffset, Display::LineBox::Baseline { strutBaselineOffset, strutHeight - strutBaselineOffset } };
+    return { initialLineHeight, initialBaselineOffset, LineBoxBuilder::Baseline { strutBaselineOffset, strutHeight - strutBaselineOffset } };
 }
 
 }

Copied: trunk/Source/WebCore/layout/inlineformatting/InlineLineBoxBuilder.h (from rev 255256, trunk/Source/WebCore/layout/displaytree/DisplayLineBox.h) (0 => 255257)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBoxBuilder.h	                        (rev 0)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBoxBuilder.h	2020-01-28 18:26:02 UTC (rev 255257)
@@ -0,0 +1,249 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "DisplayBox.h"
+#include "DisplayInlineRect.h"
+
+namespace WebCore {
+namespace Layout {
+
+class LineBoxBuilder {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    struct Baseline {
+        Baseline(InlineLayoutUnit ascent, InlineLayoutUnit descent);
+        Baseline() = default;
+
+        void setAscent(InlineLayoutUnit);
+        void setDescent(InlineLayoutUnit);
+
+        void reset();
+
+        InlineLayoutUnit height() const { return ascent() + descent(); }
+        InlineLayoutUnit ascent() const;
+        InlineLayoutUnit descent() const;
+
+    private:
+#if ASSERT_ENABLED
+        bool m_hasValidAscent { false };
+        bool m_hasValidDescent { false };
+#endif
+        InlineLayoutUnit m_ascent { 0 };
+        InlineLayoutUnit m_descent { 0 };
+    };
+
+    LineBoxBuilder(const Display::InlineRect&, const Baseline&, InlineLayoutUnit baselineOffset);
+    LineBoxBuilder() = default;
+
+    const Display::InlineRect& logicalRect() const { return m_rect; }
+    const Display::InlineRect& scrollableOverflow() const { return m_scrollableOverflow; }
+
+    InlineLayoutUnit logicalLeft() const { return m_rect.left(); }
+    InlineLayoutUnit logicalRight() const { return m_rect.right(); }
+    InlineLayoutUnit logicalTop() const { return m_rect.top(); }
+    InlineLayoutUnit logicalBottom() const { return m_rect.bottom(); }
+
+    InlineLayoutUnit logicalWidth() const { return m_rect.width(); }
+    InlineLayoutUnit logicalHeight() const { return m_rect.height(); }
+
+    const Baseline& baseline() const;
+    // Baseline offset from line logical top. Note that offset does not necessarily equal to ascent.
+    //
+    // -------------------    line logical top     ------------------- (top align)
+    //             ^                                              ^
+    //             |                                  ^           |
+    //   ^         | baseline offset                  |           | baseline offset
+    //   |         |                                  |           |
+    //   | ascent  |                                  | ascent    |
+    //   |         |                                  v           v
+    //   v         v                               ------------------- baseline
+    //   ----------------- baseline                   ^
+    //   ^                                            | descent
+    //   | descent                                    v
+    //   v
+    // -------------------    line logical bottom  -------------------
+    InlineLayoutUnit baselineOffset() const;
+    void setBaselineOffsetIfGreater(InlineLayoutUnit);
+    void setAscentIfGreater(InlineLayoutUnit);
+    void setDescentIfGreater(InlineLayoutUnit);
+
+    void resetBaseline();
+    void resetDescent() { m_baseline.setDescent(0_lu); }
+
+    void setLogicalHeight(InlineLayoutUnit logicalHeight) { m_rect.setHeight(logicalHeight); }
+
+    void setLogicalHeightIfGreater(InlineLayoutUnit);
+    void setLogicalWidth(InlineLayoutUnit logicalWidth) { m_rect.setWidth(logicalWidth); }
+
+    void setScrollableOverflow(const Display::InlineRect& rect) { m_scrollableOverflow = rect; }
+
+    void moveHorizontally(InlineLayoutUnit delta) { m_rect.moveHorizontally(delta); }
+
+    void expandHorizontally(InlineLayoutUnit delta) { m_rect.expandHorizontally(delta); }
+    void shrinkHorizontally(InlineLayoutUnit delta) { expandHorizontally(-delta); }
+
+    void expandVertically(InlineLayoutUnit delta) { m_rect.expandVertically(delta); }
+    void shrinkVertically(InlineLayoutUnit delta) { expandVertically(-delta); }
+
+    // https://www.w3.org/TR/CSS22/visuren.html#inline-formatting
+    // Line boxes that contain no text, no preserved white space, no inline elements with non-zero margins, padding, or borders,
+    // and no other in-flow content (such as images, inline blocks or inline tables), and do not end with a preserved newline
+    // must be treated as zero-height line boxes for the purposes of determining the positions of any elements inside of them,
+    // and must be treated as not existing for any other purpose.
+    // Note that it does not necessarily mean visually non-empty line. <span style="font-size: 0px">this is still considered non-empty</span>
+    bool isConsideredEmpty() const { return m_isConsideredEmpty; }
+    void setIsConsideredEmpty() { m_isConsideredEmpty = true; }
+    void setIsConsideredNonEmpty() { m_isConsideredEmpty = false; }
+
+private:
+#if ASSERT_ENABLED
+    bool m_hasValidBaseline { false };
+    bool m_hasValidBaselineOffset { false };
+#endif
+    Display::InlineRect m_rect;
+    Display::InlineRect m_scrollableOverflow;
+    Baseline m_baseline;
+    InlineLayoutUnit m_baselineOffset { 0 };
+    bool m_isConsideredEmpty { true };
+};
+
+inline LineBoxBuilder::LineBoxBuilder(const Display::InlineRect& rect, const Baseline& baseline, InlineLayoutUnit baselineOffset)
+    : m_rect(rect)
+    , m_baseline(baseline)
+    , m_baselineOffset(baselineOffset)
+{
+#if ASSERT_ENABLED
+    m_hasValidBaseline = true;
+    m_hasValidBaselineOffset = true;
+#endif
+}
+
+inline void LineBoxBuilder::setLogicalHeightIfGreater(InlineLayoutUnit logicalHeight)
+{
+    if (logicalHeight <= m_rect.height())
+        return;
+    m_rect.setHeight(logicalHeight);
+}
+
+inline const LineBoxBuilder::Baseline& LineBoxBuilder::baseline() const
+{
+    ASSERT(m_hasValidBaseline);
+    return m_baseline;
+}
+
+inline void LineBoxBuilder::setBaselineOffsetIfGreater(InlineLayoutUnit baselineOffset)
+{
+#if ASSERT_ENABLED
+    m_hasValidBaselineOffset = true;
+#endif
+    m_baselineOffset = std::max(baselineOffset, m_baselineOffset);
+}
+
+inline void LineBoxBuilder::setAscentIfGreater(InlineLayoutUnit ascent)
+{
+    if (ascent < m_baseline.ascent())
+        return;
+    setBaselineOffsetIfGreater(ascent);
+    m_baseline.setAscent(ascent);
+}
+
+inline void LineBoxBuilder::setDescentIfGreater(InlineLayoutUnit descent)
+{
+    if (descent < m_baseline.descent())
+        return;
+    m_baseline.setDescent(descent);
+}
+
+inline InlineLayoutUnit LineBoxBuilder::baselineOffset() const
+{
+    ASSERT(m_hasValidBaselineOffset);
+    return m_baselineOffset;
+}
+
+inline void LineBoxBuilder::resetBaseline()
+{
+#if ASSERT_ENABLED
+    m_hasValidBaselineOffset = true;
+#endif
+    m_baselineOffset = 0_lu;
+    m_baseline.reset();
+}
+
+inline LineBoxBuilder::Baseline::Baseline(InlineLayoutUnit ascent, InlineLayoutUnit descent)
+    : m_ascent(ascent)
+    , m_descent(descent)
+{
+#if ASSERT_ENABLED
+    m_hasValidAscent = true;
+    m_hasValidDescent = true;
+#endif
+}
+
+inline void LineBoxBuilder::Baseline::setAscent(InlineLayoutUnit ascent)
+{
+#if ASSERT_ENABLED
+    m_hasValidAscent = true;
+#endif
+    m_ascent = ascent;
+}
+
+inline void LineBoxBuilder::Baseline::setDescent(InlineLayoutUnit descent)
+{
+#if ASSERT_ENABLED
+    m_hasValidDescent = true;
+#endif
+    m_descent = descent;
+}
+
+inline void LineBoxBuilder::Baseline::reset()
+{
+#if ASSERT_ENABLED
+    m_hasValidAscent = true;
+    m_hasValidDescent = true;
+#endif
+    m_ascent = 0_lu;
+    m_descent = 0_lu;
+}
+
+inline InlineLayoutUnit LineBoxBuilder::Baseline::ascent() const
+{
+    ASSERT(m_hasValidAscent);
+    return m_ascent;
+}
+
+inline InlineLayoutUnit LineBoxBuilder::Baseline::descent() const
+{
+    ASSERT(m_hasValidDescent);
+    return m_descent;
+}
+
+}
+}
+
+#endif

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (255256 => 255257)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp	2020-01-28 18:22:43 UTC (rev 255256)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp	2020-01-28 18:26:02 UTC (rev 255257)
@@ -91,8 +91,8 @@
         m_initialStrut = { };
 
     auto lineRect = Display::InlineRect { constraints.logicalTopLeft, 0_lu, initialLineHeight };
-    auto baseline = Display::LineBox::Baseline { initialBaselineOffset, initialLineHeight - initialBaselineOffset };
-    m_lineBox = Display::LineBox { lineRect, baseline, initialBaselineOffset };
+    auto baseline = LineBoxBuilder::Baseline { initialBaselineOffset, initialLineHeight - initialBaselineOffset };
+    m_lineBox = LineBoxBuilder { lineRect, baseline, initialBaselineOffset };
     m_lineLogicalWidth = constraints.availableLogicalWidth;
     m_hasIntrusiveFloat = constraints.lineIsConstrainedByFloat;
 
@@ -124,7 +124,7 @@
         }
         if (isVisuallyEmpty()) {
             m_lineBox.resetBaseline();
-            m_lineBox.setLogicalHeight(0_lu);
+            m_lineBox.setLogicalHeight({ });
         }
         // Remove descent when all content is baseline aligned but none of them have descent.
         if (formattingContext().quirks().lineDescentNeedsCollapsing(m_runs)) {
@@ -658,7 +658,7 @@
     return false;
 }
 
-Display::LineBox::Baseline LineBuilder::halfLeadingMetrics(const FontMetrics& fontMetrics, InlineLayoutUnit lineLogicalHeight)
+LineBoxBuilder::Baseline LineBuilder::halfLeadingMetrics(const FontMetrics& fontMetrics, InlineLayoutUnit lineLogicalHeight)
 {
     auto ascent = fontMetrics.ascent();
     auto descent = fontMetrics.descent();

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h (255256 => 255257)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h	2020-01-28 18:22:43 UTC (rev 255256)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h	2020-01-28 18:26:02 UTC (rev 255257)
@@ -27,9 +27,9 @@
 
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
-#include "DisplayLineBox.h"
 #include "DisplayRun.h"
 #include "InlineItem.h"
+#include "InlineLineBoxBuilder.h"
 #include "InlineTextItem.h"
 
 namespace WebCore {
@@ -50,7 +50,7 @@
         struct HeightAndBaseline {
             InlineLayoutUnit height { 0 };
             InlineLayoutUnit baselineOffset { 0 };
-            Optional<Display::LineBox::Baseline> strut;
+            Optional<LineBoxBuilder::Baseline> strut;
         };
         Optional<HeightAndBaseline> heightAndBaseline;
     };
@@ -69,7 +69,7 @@
     InlineLayoutUnit trimmableTrailingWidth() const { return m_trimmableTrailingContent.width(); }
     bool isTrailingRunFullyTrimmable() const { return m_trimmableTrailingContent.isTrailingRunFullyTrimmable(); }
 
-    const Display::LineBox& lineBox() const { return m_lineBox; }
+    const LineBoxBuilder& lineBox() const { return m_lineBox; }
     void moveLogicalLeft(InlineLayoutUnit);
     void moveLogicalRight(InlineLayoutUnit);
     void setHasIntrusiveFloat() { m_hasIntrusiveFloat = true; }
@@ -143,7 +143,7 @@
     enum class IsLastLineWithInlineContent { No, Yes };
     RunList close(IsLastLineWithInlineContent = IsLastLineWithInlineContent::No);
 
-    static Display::LineBox::Baseline halfLeadingMetrics(const FontMetrics&, InlineLayoutUnit lineLogicalHeight);
+    static LineBoxBuilder::Baseline halfLeadingMetrics(const FontMetrics&, InlineLayoutUnit lineLogicalHeight);
 
 private:
     InlineLayoutUnit logicalTop() const { return m_lineBox.logicalTop(); }
@@ -211,12 +211,12 @@
     const InlineFormattingContext& m_inlineFormattingContext;
     RunList m_runs;
     TrimmableTrailingContent m_trimmableTrailingContent;
-    Optional<Display::LineBox::Baseline> m_initialStrut;
+    Optional<LineBoxBuilder::Baseline> m_initialStrut;
     InlineLayoutUnit m_lineLogicalWidth { 0 };
     Optional<TextAlignMode> m_horizontalAlignment;
     bool m_isIntrinsicSizing { false };
     bool m_hasIntrusiveFloat { false };
-    Display::LineBox m_lineBox;
+    LineBoxBuilder m_lineBox;
     Optional<bool> m_lineIsVisuallyEmptyBeforeTrimmableTrailingContent;
     bool m_shouldIgnoreTrailingLetterSpacing { false };
 };

Modified: trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h (255256 => 255257)


--- trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h	2020-01-28 18:22:43 UTC (rev 255256)
+++ trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h	2020-01-28 18:26:02 UTC (rev 255257)
@@ -48,7 +48,7 @@
         Optional<PartialContent> partialContent;
         Vector<const InlineItem*> floats;
         const LineBuilder::RunList runList;
-        const Display::LineBox lineBox;
+        const LineBoxBuilder lineBox;
     };
     struct InlineItemRange {
         bool isEmpty() const { return start == end; }

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (255256 => 255257)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-01-28 18:22:43 UTC (rev 255256)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-01-28 18:26:02 UTC (rev 255257)
@@ -115,7 +115,7 @@
 LayoutUnit LineLayout::contentLogicalHeight() const
 {
     auto& lineBoxes = displayInlineContent()->lineBoxes;
-    return LayoutUnit { lineBoxes.last().logicalBottom() - lineBoxes.first().logicalTop() };
+    return LayoutUnit { lineBoxes.last().bottom() - lineBoxes.first().top() };
 }
 
 size_t LineLayout::lineCount() const
@@ -137,7 +137,7 @@
     }
 
     auto& firstLineBox = inlineContent->lineBoxes.first();
-    return Layout::toLayoutUnit(firstLineBox.logicalTop() + firstLineBox.baselineOffset());
+    return Layout::toLayoutUnit(firstLineBox.top() + firstLineBox.baselineOffset());
 }
 
 LayoutUnit LineLayout::lastLineBaseline() const
@@ -149,7 +149,7 @@
     }
 
     auto& lastLineBox = inlineContent->lineBoxes.last();
-    return Layout::toLayoutUnit(lastLineBox.logicalTop() + lastLineBox.baselineOffset());
+    return Layout::toLayoutUnit(lastLineBox.top() + lastLineBox.baselineOffset());
 }
 
 void LineLayout::collectOverflow(RenderBlockFlow& flow)
@@ -258,7 +258,7 @@
         }
 
         auto& lineBox = inlineContent.lineBoxForRun(run);
-        auto baselineOffset = paintOffset.y() + lineBox.logicalTop() + lineBox.baselineOffset();
+        auto baselineOffset = paintOffset.y() + lineBox.top() + lineBox.baselineOffset();
 
         auto behavior = textContext.expansion() ? textContext.expansion()->behavior : DefaultExpansion;
         auto horizontalExpansion = textContext.expansion() ? textContext.expansion()->horizontalExpansion : 0;
@@ -266,7 +266,7 @@
         String textWithHyphen;
         if (textContext.needsHyphen())
             textWithHyphen = makeString(textContext.content(), style.hyphenString());
-        TextRun textRun { !textWithHyphen.isEmpty() ? textWithHyphen : textContext.content(), run.left() - lineBox.logicalLeft(), horizontalExpansion, behavior };
+        TextRun textRun { !textWithHyphen.isEmpty() ? textWithHyphen : textContext.content(), run.left() - lineBox.left(), horizontalExpansion, behavior };
         textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
         FloatPoint textOrigin { rect.x() + paintOffset.x(), roundToDevicePixel(baselineOffset, deviceScaleFactor) };
 

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (255256 => 255257)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2020-01-28 18:22:43 UTC (rev 255256)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2020-01-28 18:26:02 UTC (rev 255257)
@@ -330,7 +330,7 @@
 
     stream << "lines are -> ";
     for (auto& lineBox : lineBoxes)
-        stream << "[" << lineBox.logicalLeft() << "," << lineBox.logicalTop() << " " << lineBox.logicalWidth() << "x" << lineBox.logicalHeight() << "] ";
+        stream << "[" << lineBox.left() << "," << lineBox.top() << " " << lineBox.width() << "x" << lineBox.height() << "] ";
     stream.nextLine();
 
     for (auto& displayRun : displayRuns) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to