Title: [282202] trunk
Revision
282202
Author
[email protected]
Date
2021-09-09 01:17:06 -0700 (Thu, 09 Sep 2021)

Log Message

RenderInline offsetTop/Left should not switch to legacy layout
https://bugs.webkit.org/show_bug.cgi?id=230040

Reviewed by Alan Bujtas.

LayoutTests/imported/w3c:

* web-platform-tests/css/cssom-view/offsetTopLeft-empty-inline-expected.txt:
* web-platform-tests/css/cssom-view/offsetTopLeft-leading-space-inline-expected.txt:

Source/WebCore:

Get position of the LFC inline box.

* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::firstInlineBoxRect const):
* layout/integration/LayoutIntegrationLineLayout.h:
* rendering/RenderInline.cpp:
(WebCore::RenderInline::offsetLeft const):
(WebCore::RenderInline::offsetTop const):
(WebCore::RenderInline::firstInlineBoxTopLeft const):
(WebCore::RenderInline::positionForPoint const):

Also fix positionForPoint as a failing test revealed a missing LFC path here.

* rendering/RenderInline.h:

LayoutTests:

* editing/selection/doubleclick-beside-cr-span.html:

Update the test for more standards compliant first inline box position.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (282201 => 282202)


--- trunk/LayoutTests/ChangeLog	2021-09-09 08:16:24 UTC (rev 282201)
+++ trunk/LayoutTests/ChangeLog	2021-09-09 08:17:06 UTC (rev 282202)
@@ -1,3 +1,14 @@
+2021-09-09  Antti Koivisto  <[email protected]>
+
+        RenderInline offsetTop/Left should not switch to legacy layout
+        https://bugs.webkit.org/show_bug.cgi?id=230040
+
+        Reviewed by Alan Bujtas.
+
+        * editing/selection/doubleclick-beside-cr-span.html:
+
+        Update the test for more standards compliant first inline box position.
+
 2021-09-09  Youenn Fablet  <[email protected]>
 
         Add support for RTCDataChannel closing event

Modified: trunk/LayoutTests/editing/selection/doubleclick-beside-cr-span.html (282201 => 282202)


--- trunk/LayoutTests/editing/selection/doubleclick-beside-cr-span.html	2021-09-09 08:16:24 UTC (rev 282201)
+++ trunk/LayoutTests/editing/selection/doubleclick-beside-cr-span.html	2021-09-09 08:17:06 UTC (rev 282202)
@@ -149,9 +149,9 @@
         doTest("totest_linebreak_out", "select3\n");
         doTest("totest_tab_out", "select4\t");
         doTest("totest_multiple_whitespaces_out", "select5 ");
-        doTest("totest_linebreak_in", "select6\n");
-        doTest("totest_tab_in", "select7\t");
-        doTest("totest_multiple_whitespaces_in", "select8 ");
+        doTest("totest_linebreak_in", "select6\n", getPositionOfNextLineHeadOf("totest_linebreak_in"));
+        doTest("totest_tab_in", "select7\t", getPositionOfNextLineHeadOf("totest_tab_in"));
+        doTest("totest_multiple_whitespaces_in", "select8 ", getPositionOfNextLineHeadOf("totest_multiple_whitespaces_in"));
 
         doTest("totest_multiple_word_in_span", "select9 ");
         doTest("totest_word_before_here_in_line", "select10 ");
@@ -176,8 +176,8 @@
         doTest("totest_tab_out_preline", "select2\t");
         doTest("totest_multiple_whitespaces_out_preline", "select3 ");
         doTest("totest_linebreak_in_preline", "select4\n", getPositionOfNextLineHeadOf("totest_linebreak_in_preline"));
-        doTest("totest_tab_in_preline", "select5\t");
-        doTest("totest_multiple_whitespaces_in_preline", "select6 ");
+        doTest("totest_tab_in_preline", "select5\t", getPositionOfNextLineHeadOf("totest_tab_in_preline"));
+        doTest("totest_multiple_whitespaces_in_preline", "select6 ", getPositionOfNextLineHeadOf("totest_multiple_whitespaces_in_preline"));
 
         doTest("totest_linebreak_out_nowrap", "select1\n");
         doTest("totest_tab_out_nowrap", "select2\t");

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (282201 => 282202)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-09 08:16:24 UTC (rev 282201)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-09 08:17:06 UTC (rev 282202)
@@ -1,3 +1,13 @@
+2021-09-09  Antti Koivisto  <[email protected]>
+
+        RenderInline offsetTop/Left should not switch to legacy layout
+        https://bugs.webkit.org/show_bug.cgi?id=230040
+
+        Reviewed by Alan Bujtas.
+
+        * web-platform-tests/css/cssom-view/offsetTopLeft-empty-inline-expected.txt:
+        * web-platform-tests/css/cssom-view/offsetTopLeft-leading-space-inline-expected.txt:
+
 2021-09-09  Martin Robinson  <[email protected]>
 
         Position sticky does not work within table cells

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/offsetTopLeft-empty-inline-expected.txt (282201 => 282202)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/offsetTopLeft-empty-inline-expected.txt	2021-09-09 08:16:24 UTC (rev 282201)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/offsetTopLeft-empty-inline-expected.txt	2021-09-09 08:17:06 UTC (rev 282202)
@@ -5,7 +5,7 @@
 
 ref
 
-FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 0 assert_equals: offsetLeft expected 16 but got 0
+PASS offsetTop/Left of empty inline elements should work as if they were not empty: 0
 FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 1 assert_equals: offsetLeft expected 34 but got 0
 FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 2 assert_equals: offsetLeft expected 34 but got 0
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/offsetTopLeft-leading-space-inline-expected.txt (282201 => 282202)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/offsetTopLeft-leading-space-inline-expected.txt	2021-09-09 08:16:24 UTC (rev 282201)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/offsetTopLeft-leading-space-inline-expected.txt	2021-09-09 08:17:06 UTC (rev 282202)
@@ -5,7 +5,7 @@
 
 ref
 
-FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 0 assert_equals: offsetLeft expected 16 but got 0
+PASS offsetTop/Left of empty inline elements should work as if they were not empty: 0
 FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 1 assert_equals: offsetLeft expected 34 but got 0
 FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 2 assert_equals: offsetLeft expected 34 but got 0
 

Modified: trunk/Source/WebCore/ChangeLog (282201 => 282202)


--- trunk/Source/WebCore/ChangeLog	2021-09-09 08:16:24 UTC (rev 282201)
+++ trunk/Source/WebCore/ChangeLog	2021-09-09 08:17:06 UTC (rev 282202)
@@ -1,3 +1,25 @@
+2021-09-09  Antti Koivisto  <[email protected]>
+
+        RenderInline offsetTop/Left should not switch to legacy layout
+        https://bugs.webkit.org/show_bug.cgi?id=230040
+
+        Reviewed by Alan Bujtas.
+
+        Get position of the LFC inline box.
+
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::firstInlineBoxRect const):
+        * layout/integration/LayoutIntegrationLineLayout.h:
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::offsetLeft const):
+        (WebCore::RenderInline::offsetTop const):
+        (WebCore::RenderInline::firstInlineBoxTopLeft const):
+        (WebCore::RenderInline::positionForPoint const):
+
+        Also fix positionForPoint as a failing test revealed a missing LFC path here.
+
+        * rendering/RenderInline.h:
+
 2021-09-09  Martin Robinson  <[email protected]>
 
         Position sticky does not work within table cells

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (282201 => 282202)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2021-09-09 08:16:24 UTC (rev 282201)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2021-09-09 08:17:06 UTC (rev 282202)
@@ -411,6 +411,16 @@
     return { LineIteratorModernPath(*m_inlineContent, m_inlineContent->lines.isEmpty() ? 0 : m_inlineContent->lines.size() - 1) };
 }
 
+LayoutRect LineLayout::firstInlineBoxRect(const RenderInline& renderInline) const
+{
+    auto& layoutBox = m_boxTree.layoutBoxForRenderer(renderInline);
+    for (auto& run : m_inlineContent->runs) {
+        if (&run.layoutBox() == &layoutBox)
+            return Layout::toLayoutRect(run.logicalRect());
+    }
+    return { };
+}
+
 LayoutRect LineLayout::enclosingBorderBoxRectFor(const RenderInline& renderInline) const
 {
     if (!m_inlineContent)

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (282201 => 282202)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2021-09-09 08:16:24 UTC (rev 282201)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2021-09-09 08:17:06 UTC (rev 282202)
@@ -96,6 +96,7 @@
     LineIterator firstLine() const;
     LineIterator lastLine() const;
 
+    LayoutRect firstInlineBoxRect(const RenderInline&) const;
     LayoutRect enclosingBorderBoxRectFor(const RenderInline&) const;
     LayoutRect visualOverflowBoundingBoxRectFor(const RenderInline&) const;
     Vector<FloatRect> collectInlineBoxRects(const RenderInline&) const;

Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (282201 => 282202)


--- trunk/Source/WebCore/rendering/RenderInline.cpp	2021-09-09 08:16:24 UTC (rev 282201)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp	2021-09-09 08:17:06 UTC (rev 282202)
@@ -433,26 +433,23 @@
 
 LayoutUnit RenderInline::offsetLeft() const
 {
-#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-    if (auto* lineLayout = LayoutIntegration::LineLayout::containing(const_cast<RenderInline&>(*this)))
-        lineLayout->flow().ensureLineBoxes();
-#endif
-    LayoutPoint topLeft;
-    if (LegacyInlineBox* firstBox = firstLineBoxIncludingCulling())
-        topLeft = flooredLayoutPoint(firstBox->topLeft());
-    return adjustedPositionRelativeToOffsetParent(topLeft).x();
+    return adjustedPositionRelativeToOffsetParent(firstInlineBoxTopLeft()).x();
 }
 
 LayoutUnit RenderInline::offsetTop() const
 {
+    return adjustedPositionRelativeToOffsetParent(firstInlineBoxTopLeft()).y();
+}
+
+LayoutPoint RenderInline::firstInlineBoxTopLeft() const
+{
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-    if (auto* lineLayout = LayoutIntegration::LineLayout::containing(const_cast<RenderInline&>(*this)))
-        lineLayout->flow().ensureLineBoxes();
+    if (auto* lineLayout = LayoutIntegration::LineLayout::containing(*this))
+        return lineLayout->firstInlineBoxRect(*this).location();
 #endif
-    LayoutPoint topLeft;
     if (LegacyInlineBox* firstBox = firstLineBoxIncludingCulling())
-        topLeft = flooredLayoutPoint(firstBox->topLeft());
-    return adjustedPositionRelativeToOffsetParent(topLeft).y();
+        return flooredLayoutPoint(firstBox->topLeft());
+    return { };
 }
 
 static LayoutUnit computeMargin(const RenderInline* renderer, const Length& margin)
@@ -582,8 +579,17 @@
 {
     // FIXME: Does not deal with relative or sticky positioned inlines (should it?)
     RenderBlock& containingBlock = *this->containingBlock();
-    if (firstLineBox()) {
-        // This inline actually has a line box.  We must have clicked in the border/padding of one of these boxes.  We
+
+    auto hasInlineBox = [&] {
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+        if (LayoutIntegration::LineLayout::containing(*this))
+            return true;
+#endif
+        return !!firstLineBox();
+    };
+
+    if (hasInlineBox()) {
+        // This inline actually has an inline box. We must have clicked in the border/padding of one of these boxes. We
         // should try to find a result by asking our containing block.
         return containingBlock.positionForPoint(point, fragment);
     }

Modified: trunk/Source/WebCore/rendering/RenderInline.h (282201 => 282202)


--- trunk/Source/WebCore/rendering/RenderInline.h	2021-09-09 08:16:24 UTC (rev 282201)
+++ trunk/Source/WebCore/rendering/RenderInline.h	2021-09-09 08:17:06 UTC (rev 282202)
@@ -125,6 +125,7 @@
     LayoutUnit offsetTop() const final;
     LayoutUnit offsetWidth() const final { return linesBoundingBox().width(); }
     LayoutUnit offsetHeight() const final { return linesBoundingBox().height(); }
+    LayoutPoint firstInlineBoxTopLeft() const;
 
     LayoutRect clippedOverflowRect(const RenderLayerModelObject* repaintContainer, VisibleRectContext) const override;
     LayoutRect rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const final;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to