Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit e3090e0

Browse files
author
antti@apple.com
committed
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. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@282202 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 93d52a4 commit e3090e0

File tree

10 files changed

+83
-22
lines changed

10 files changed

+83
-22
lines changed

LayoutTests/ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2021-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+
112
2021-09-09 Youenn Fablet <youenn@apple.com>
213

314
Add support for RTCDataChannel closing event

LayoutTests/editing/selection/doubleclick-beside-cr-span.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@
149149
doTest("totest_linebreak_out", "select3\n");
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 ");
157157
doTest("totest_word_before_here_in_line", "select10 ");
@@ -176,8 +176,8 @@
176176
doTest("totest_tab_out_preline", "select2\t");
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");
183183
doTest("totest_tab_out_nowrap", "select2\t");

LayoutTests/imported/w3c/ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2021-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+
111
2021-09-09 Martin Robinson <mrobinson@webkit.org>
212

313
Position sticky does not work within table cells

LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/offsetTopLeft-empty-inline-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ref
55

66
ref
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
8+
PASS offsetTop/Left of empty inline elements should work as if they were not empty: 0
99
FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 1 assert_equals: offsetLeft expected 34 but got 0
1010
FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 2 assert_equals: offsetLeft expected 34 but got 0
1111

LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/offsetTopLeft-leading-space-inline-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ref
55

66
ref
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
8+
PASS offsetTop/Left of empty inline elements should work as if they were not empty: 0
99
FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 1 assert_equals: offsetLeft expected 34 but got 0
1010
FAIL offsetTop/Left of empty inline elements should work as if they were not empty: 2 assert_equals: offsetLeft expected 34 but got 0
1111

Source/WebCore/ChangeLog

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
2021-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+
123
2021-09-09 Martin Robinson <mrobinson@webkit.org>
224

325
Position sticky does not work within table cells

Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,16 @@ LineIterator LineLayout::lastLine() const
411411
return { LineIteratorModernPath(*m_inlineContent, m_inlineContent->lines.isEmpty() ? 0 : m_inlineContent->lines.size() - 1) };
412412
}
413413

414+
LayoutRect 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+
414424
LayoutRect LineLayout::enclosingBorderBoxRectFor(const RenderInline& renderInline) const
415425
{
416426
if (!m_inlineContent)

Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class LineLayout : public CanMakeWeakPtr<LineLayout> {
9696
LineIterator firstLine() const;
9797
LineIterator lastLine() const;
9898

99+
LayoutRect firstInlineBoxRect(const RenderInline&) const;
99100
LayoutRect enclosingBorderBoxRectFor(const RenderInline&) const;
100101
LayoutRect visualOverflowBoundingBoxRectFor(const RenderInline&) const;
101102
Vector<FloatRect> collectInlineBoxRects(const RenderInline&) const;

Source/WebCore/rendering/RenderInline.cpp

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -433,26 +433,23 @@ void RenderInline::absoluteQuadsForSelection(Vector<FloatQuad>& quads) const
433433

434434
LayoutUnit RenderInline::offsetLeft() const
435435
{
436-
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
437-
if (auto* lineLayout = LayoutIntegration::LineLayout::containing(const_cast<RenderInline&>(*this)))
438-
lineLayout->flow().ensureLineBoxes();
439-
#endif
440-
LayoutPoint topLeft;
441-
if (LegacyInlineBox* firstBox = firstLineBoxIncludingCulling())
442-
topLeft = flooredLayoutPoint(firstBox->topLeft());
443-
return adjustedPositionRelativeToOffsetParent(topLeft).x();
436+
return adjustedPositionRelativeToOffsetParent(firstInlineBoxTopLeft()).x();
444437
}
445438

446439
LayoutUnit RenderInline::offsetTop() const
440+
{
441+
return adjustedPositionRelativeToOffsetParent(firstInlineBoxTopLeft()).y();
442+
}
443+
444+
LayoutPoint RenderInline::firstInlineBoxTopLeft() const
447445
{
448446
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
449-
if (auto* lineLayout = LayoutIntegration::LineLayout::containing(const_cast<RenderInline&>(*this)))
450-
lineLayout->flow().ensureLineBoxes();
447+
if (auto* lineLayout = LayoutIntegration::LineLayout::containing(*this))
448+
return lineLayout->firstInlineBoxRect(*this).location();
451449
#endif
452-
LayoutPoint topLeft;
453450
if (LegacyInlineBox* firstBox = firstLineBoxIncludingCulling())
454-
topLeft = flooredLayoutPoint(firstBox->topLeft());
455-
return adjustedPositionRelativeToOffsetParent(topLeft).y();
451+
return flooredLayoutPoint(firstBox->topLeft());
452+
return { };
456453
}
457454

458455
static LayoutUnit computeMargin(const RenderInline* renderer, const Length& margin)
@@ -582,8 +579,17 @@ VisiblePosition RenderInline::positionForPoint(const LayoutPoint& point, const R
582579
{
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);
589595
}

Source/WebCore/rendering/RenderInline.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ class RenderInline : public RenderBoxModelObject {
125125
LayoutUnit offsetTop() const final;
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;
130131
LayoutRect rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const final;

0 commit comments

Comments
 (0)