⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 282202 in webkit


Ignore:
Timestamp:
Sep 9, 2021, 1:17:06 AM (5 years ago)
Author:
Antti Koivisto
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.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r282198 r282202  
     12021-09-09  Antti Koivisto  <antti@apple.com>
     2
     3        RenderInline offsetTop/Left should not switch to legacy layout
     4        https://bugs.webkit.org/show_bug.cgi?id=230040
     5
     6        Reviewed by Alan Bujtas.
     7
     8        * editing/selection/doubleclick-beside-cr-span.html:
     9
     10        Update the test for more standards compliant first inline box position.
     11
    1122021-09-09  Youenn Fablet  <youenn@apple.com>
    213
  • trunk/LayoutTests/editing/selection/doubleclick-beside-cr-span.html

    r145849 r282202  
    150150        doTest("totest_tab_out", "select4\t");
    151151        doTest("totest_multiple_whitespaces_out", "select5 ");
    152         doTest("totest_linebreak_in", "select6\n");
    153         doTest("totest_tab_in", "select7\t");
    154         doTest("totest_multiple_whitespaces_in", "select8 ");
     152        doTest("totest_linebreak_in", "select6\n", getPositionOfNextLineHeadOf("totest_linebreak_in"));
     153        doTest("totest_tab_in", "select7\t", getPositionOfNextLineHeadOf("totest_tab_in"));
     154        doTest("totest_multiple_whitespaces_in", "select8 ", getPositionOfNextLineHeadOf("totest_multiple_whitespaces_in"));
    155155
    156156        doTest("totest_multiple_word_in_span", "select9 ");
    … …  
    177177        doTest("totest_multiple_whitespaces_out_preline", "select3 ");
    178178        doTest("totest_linebreak_in_preline", "select4\n", getPositionOfNextLineHeadOf("totest_linebreak_in_preline"));
    179         doTest("totest_tab_in_preline", "select5\t");
    180         doTest("totest_multiple_whitespaces_in_preline", "select6 ");
     179        doTest("totest_tab_in_preline", "select5\t", getPositionOfNextLineHeadOf("totest_tab_in_preline"));
     180        doTest("totest_multiple_whitespaces_in_preline", "select6 ", getPositionOfNextLineHeadOf("totest_multiple_whitespaces_in_preline"));
    181181
    182182        doTest("totest_linebreak_out_nowrap", "select1\n");
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r282201 r282202  
     12021-09-09  Antti Koivisto  <antti@apple.com>
     2
     3        RenderInline offsetTop/Left should not switch to legacy layout
     4        https://bugs.webkit.org/show_bug.cgi?id=230040
     5
     6        Reviewed by Alan Bujtas.
     7
     8        * web-platform-tests/css/cssom-view/offsetTopLeft-empty-inline-expected.txt:
     9        * web-platform-tests/css/cssom-view/offsetTopLeft-leading-space-inline-expected.txt:
     10
    1112021-09-09  Martin Robinson  <mrobinson@webkit.org>
    212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/offsetTopLeft-empty-inline-expected.txt

    r247193 r282202  
    66ref
    77
    8 FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 0 assert_equals: offsetLeft expected 16 but got 0
     8PASS offsetTop/Left of empty inline elements should work as if they were not empty: 0
    99FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 1 assert_equals: offsetLeft expected 34 but got 0
    1010FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 2 assert_equals: offsetLeft expected 34 but got 0
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/offsetTopLeft-leading-space-inline-expected.txt

    r247193 r282202  
    66ref
    77
    8 FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 0 assert_equals: offsetLeft expected 16 but got 0
     8PASS offsetTop/Left of empty inline elements should work as if they were not empty: 0
    99FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 1 assert_equals: offsetLeft expected 34 but got 0
    1010FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 2 assert_equals: offsetLeft expected 34 but got 0
  • trunk/Source/WebCore/ChangeLog

    r282201 r282202  
     12021-09-09  Antti Koivisto  <antti@apple.com>
     2
     3        RenderInline offsetTop/Left should not switch to legacy layout
     4        https://bugs.webkit.org/show_bug.cgi?id=230040
     5
     6        Reviewed by Alan Bujtas.
     7
     8        Get position of the LFC inline box.
     9
     10        * layout/integration/LayoutIntegrationLineLayout.cpp:
     11        (WebCore::LayoutIntegration::LineLayout::firstInlineBoxRect const):
     12        * layout/integration/LayoutIntegrationLineLayout.h:
     13        * rendering/RenderInline.cpp:
     14        (WebCore::RenderInline::offsetLeft const):
     15        (WebCore::RenderInline::offsetTop const):
     16        (WebCore::RenderInline::firstInlineBoxTopLeft const):
     17        (WebCore::RenderInline::positionForPoint const):
     18
     19        Also fix positionForPoint as a failing test revealed a missing LFC path here.
     20
     21        * rendering/RenderInline.h:
     22
    1232021-09-09  Martin Robinson  <mrobinson@webkit.org>
    224
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp

    r282150 r282202  
    412412}
    413413
     414LayoutRect LineLayout::firstInlineBoxRect(const RenderInline& renderInline) const
     415{
     416    auto& layoutBox = m_boxTree.layoutBoxForRenderer(renderInline);
     417    for (auto& run : m_inlineContent->runs) {
     418        if (&run.layoutBox() == &layoutBox)
     419            return Layout::toLayoutRect(run.logicalRect());
     420    }
     421    return { };
     422}
     423
    414424LayoutRect LineLayout::enclosingBorderBoxRectFor(const RenderInline& renderInline) const
    415425{
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h

    r282150 r282202  
    9797    LineIterator lastLine() const;
    9898
     99    LayoutRect firstInlineBoxRect(const RenderInline&) const;
    99100    LayoutRect enclosingBorderBoxRectFor(const RenderInline&) const;
    100101    LayoutRect visualOverflowBoundingBoxRectFor(const RenderInline&) const;
  • trunk/Source/WebCore/rendering/RenderInline.cpp

    r282150 r282202  
    434434LayoutUnit RenderInline::offsetLeft() const
    435435{
     436    return adjustedPositionRelativeToOffsetParent(firstInlineBoxTopLeft()).x();
     437}
     438
     439LayoutUnit RenderInline::offsetTop() const
     440{
     441    return adjustedPositionRelativeToOffsetParent(firstInlineBoxTopLeft()).y();
     442}
     443
     444LayoutPoint RenderInline::firstInlineBoxTopLeft() const
     445{
    436446#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    437     if (auto* lineLayout = LayoutIntegration::LineLayout::containing(const_cast<RenderInline&>(*this)))
    438         lineLayout->flow().ensureLineBoxes();
     447    if (auto* lineLayout = LayoutIntegration::LineLayout::containing(*this))
     448        return lineLayout->firstInlineBoxRect(*this).location();
    439449#endif
    440     LayoutPoint topLeft;
    441450    if (LegacyInlineBox* firstBox = firstLineBoxIncludingCulling())
    442         topLeft = flooredLayoutPoint(firstBox->topLeft());
    443     return adjustedPositionRelativeToOffsetParent(topLeft).x();
    444 }
    445 
    446 LayoutUnit RenderInline::offsetTop() const
    447 {
    448 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    449     if (auto* lineLayout = LayoutIntegration::LineLayout::containing(const_cast<RenderInline&>(*this)))
    450         lineLayout->flow().ensureLineBoxes();
    451 #endif
    452     LayoutPoint topLeft;
    453     if (LegacyInlineBox* firstBox = firstLineBoxIncludingCulling())
    454         topLeft = flooredLayoutPoint(firstBox->topLeft());
    455     return adjustedPositionRelativeToOffsetParent(topLeft).y();
     451        return flooredLayoutPoint(firstBox->topLeft());
     452    return { };
    456453}
    457454
    … …  
    583580    // FIXME: Does not deal with relative or sticky positioned inlines (should it?)
    584581    RenderBlock& containingBlock = *this->containingBlock();
    585     if (firstLineBox()) {
    586         // This inline actually has a line box.  We must have clicked in the border/padding of one of these boxes.  We
     582
     583    auto hasInlineBox = [&] {
     584#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
     585        if (LayoutIntegration::LineLayout::containing(*this))
     586            return true;
     587#endif
     588        return !!firstLineBox();
     589    };
     590
     591    if (hasInlineBox()) {
     592        // This inline actually has an inline box. We must have clicked in the border/padding of one of these boxes. We
    587593        // should try to find a result by asking our containing block.
    588594        return containingBlock.positionForPoint(point, fragment);
  • trunk/Source/WebCore/rendering/RenderInline.h

    r282129 r282202  
    126126    LayoutUnit offsetWidth() const final { return linesBoundingBox().width(); }
    127127    LayoutUnit offsetHeight() const final { return linesBoundingBox().height(); }
     128    LayoutPoint firstInlineBoxTopLeft() const;
    128129
    129130    LayoutRect clippedOverflowRect(const RenderLayerModelObject* repaintContainer, VisibleRectContext) const override;
Note: See TracChangeset for help on using the changeset viewer.