Title: [269231] trunk/Source/WebCore
Revision
269231
Author
[email protected]
Date
2020-11-01 05:57:56 -0800 (Sun, 01 Nov 2020)

Log Message

[LFC][IFC] InlineLevelBox logical rect should only be accessed through LineBox
https://bugs.webkit.org/show_bug.cgi?id=218418

Reviewed by Antti Koivisto.

InlineLevelBox logical rect is relative to the parent inline box. Calling InlineLevelBox::logicalRect
and expect a line relative rect is an easy mistake to make (and one I made myself).
Only the LineBuilder and the LineBox should really need access to the relative rect, others should
continue to use LineBox::logicalRectForInlineLevelBox.

* layout/inlineformatting/InlineLineBox.cpp:
(WebCore::Layout::LineBox::logicalRectForInlineLevelBox const):
* layout/inlineformatting/InlineLineBox.h:
(WebCore::Layout::LineBox::InlineLevelBox::logicalTop const):
(WebCore::Layout::LineBox::InlineLevelBox::logicalBottom const):
(WebCore::Layout::LineBox::InlineLevelBox::logicalLeft const):
(WebCore::Layout::LineBox::InlineLevelBox::logicalWidth const):
(WebCore::Layout::LineBox::InlineLevelBox::logicalHeight const):
(WebCore::Layout::LineBox::InlineLevelBox::logicalRect const): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (269230 => 269231)


--- trunk/Source/WebCore/ChangeLog	2020-11-01 13:55:39 UTC (rev 269230)
+++ trunk/Source/WebCore/ChangeLog	2020-11-01 13:57:56 UTC (rev 269231)
@@ -1,5 +1,27 @@
 2020-11-01  Zalan Bujtas  <[email protected]>
 
+        [LFC][IFC] InlineLevelBox logical rect should only be accessed through LineBox
+        https://bugs.webkit.org/show_bug.cgi?id=218418
+
+        Reviewed by Antti Koivisto.
+
+        InlineLevelBox logical rect is relative to the parent inline box. Calling InlineLevelBox::logicalRect 
+        and expect a line relative rect is an easy mistake to make (and one I made myself).
+        Only the LineBuilder and the LineBox should really need access to the relative rect, others should
+        continue to use LineBox::logicalRectForInlineLevelBox.
+
+        * layout/inlineformatting/InlineLineBox.cpp:
+        (WebCore::Layout::LineBox::logicalRectForInlineLevelBox const):
+        * layout/inlineformatting/InlineLineBox.h:
+        (WebCore::Layout::LineBox::InlineLevelBox::logicalTop const):
+        (WebCore::Layout::LineBox::InlineLevelBox::logicalBottom const):
+        (WebCore::Layout::LineBox::InlineLevelBox::logicalLeft const):
+        (WebCore::Layout::LineBox::InlineLevelBox::logicalWidth const):
+        (WebCore::Layout::LineBox::InlineLevelBox::logicalHeight const):
+        (WebCore::Layout::LineBox::InlineLevelBox::logicalRect const): Deleted.
+
+2020-11-01  Zalan Bujtas  <[email protected]>
+
         [LFC][IFC] Set the descent layout bounds for atomic inline level boxes
         https://bugs.webkit.org/show_bug.cgi?id=218421
 

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp (269230 => 269231)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp	2020-11-01 13:55:39 UTC (rev 269230)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp	2020-11-01 13:57:56 UTC (rev 269231)
@@ -101,14 +101,15 @@
 InlineRect LineBox::logicalRectForInlineLevelBox(const Box& layoutBox) const
 {
     auto* inlineBox = &inlineLevelBoxForLayoutBox(layoutBox);
+    if (inlineBox->hasLineBoxRelativeAlignment())
+        return inlineBox->logicalRect();
+
     auto inlineBoxLogicalRect = inlineBox->logicalRect();
-    auto inlineBoxAbsolutelogicalTop = inlineBox->logicalTop();
-    if (!inlineBox->hasLineBoxRelativeAlignment()) {
-        while (inlineBox != m_rootInlineBox.get() && !inlineBox->hasLineBoxRelativeAlignment()) {
-            inlineBox = &inlineLevelBoxForLayoutBox(inlineBox->layoutBox().parent());
-            ASSERT(inlineBox->isInlineBox());
-            inlineBoxAbsolutelogicalTop += inlineBox->logicalTop();
-        }
+    auto inlineBoxAbsolutelogicalTop = inlineBoxLogicalRect.top();
+    while (inlineBox != m_rootInlineBox.get() && !inlineBox->hasLineBoxRelativeAlignment()) {
+        inlineBox = &inlineLevelBoxForLayoutBox(inlineBox->layoutBox().parent());
+        ASSERT(inlineBox->isInlineBox());
+        inlineBoxAbsolutelogicalTop += inlineBox->logicalTop();
     }
     return { inlineBoxAbsolutelogicalTop, inlineBoxLogicalRect.left(), inlineBoxLogicalRect.width(), inlineBoxLogicalRect.height() };
 }

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h (269230 => 269231)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h	2020-11-01 13:55:39 UTC (rev 269230)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h	2020-11-01 13:57:56 UTC (rev 269231)
@@ -66,13 +66,6 @@
         static std::unique_ptr<LineBox::InlineLevelBox> createLineBreakBox(const Box&, InlineLayoutUnit logicalLeft);
         static std::unique_ptr<LineBox::InlineLevelBox> createGenericInlineLevelBox(const Box&, InlineLayoutUnit logicalLeft);
 
-        const InlineRect& logicalRect() const { return m_logicalRect; }
-        InlineLayoutUnit logicalTop() const { return m_logicalRect.top(); }
-        InlineLayoutUnit logicalBottom() const { return m_logicalRect.bottom(); }
-        InlineLayoutUnit logicalLeft() const { return m_logicalRect.left(); }
-        InlineLayoutUnit logicalWidth() const { return m_logicalRect.width(); }
-        InlineLayoutUnit logicalHeight() const { return m_logicalRect.height(); }
-
         InlineLayoutUnit baseline() const { return m_baseline; }
         Optional<InlineLayoutUnit> descent() const { return m_descent; }
         // See https://www.w3.org/TR/css-inline-3/#layout-bounds
@@ -109,7 +102,15 @@
 
     private:
         friend class LineBoxBuilder;
+        friend class LineBox;
 
+        const InlineRect& logicalRect() const { return m_logicalRect; }
+        InlineLayoutUnit logicalTop() const { return m_logicalRect.top(); }
+        InlineLayoutUnit logicalBottom() const { return m_logicalRect.bottom(); }
+        InlineLayoutUnit logicalLeft() const { return m_logicalRect.left(); }
+        InlineLayoutUnit logicalWidth() const { return m_logicalRect.width(); }
+        InlineLayoutUnit logicalHeight() const { return m_logicalRect.height(); }
+
         void setLogicalTop(InlineLayoutUnit logicalTop) { m_logicalRect.setTop(logicalTop); }
         void setLogicalWidth(InlineLayoutUnit logicalWidth) { m_logicalRect.setWidth(logicalWidth); }
         void setLogicalHeight(InlineLayoutUnit logicalHeight) { m_logicalRect.setHeight(logicalHeight); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to