Skip to content

Commit

Permalink
Merge r222539 - Fall back to normal line layout position, when simple…
Browse files Browse the repository at this point in the history
… line layout fails to find one.

https://bugs.webkit.org/show_bug.cgi?id=176220
<rdar://problem/34205774>

Reviewed by Brent Fulgham.

Source/WebCore:

In case of empty content, let's just fall back to normal line layout and try to
find the visually correct one.

Test: fast/text/invalid-positionForPoint-offset.html

* rendering/RenderText.cpp:
(WebCore::RenderText::positionForPoint):
* rendering/SimpleLineLayoutResolver.cpp:
(WebCore::SimpleLineLayout::RunResolver::runForPoint const):

LayoutTests:

* fast/text/invalid-positionForPoint-offset-expected.txt: Added.
* fast/text/invalid-positionForPoint-offset.html: Added.
  • Loading branch information
alanbaradlay authored and carlosgcampos committed Oct 17, 2017
1 parent 50d3b7e commit b82882b
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 1 deletion.
11 changes: 11 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
2017-09-26 Zalan Bujtas <zalan@apple.com>

Fall back to normal line layout position, when simple line layout fails to find one.
https://bugs.webkit.org/show_bug.cgi?id=176220
<rdar://problem/34205774>

Reviewed by Brent Fulgham.

* fast/text/invalid-positionForPoint-offset-expected.txt: Added.
* fast/text/invalid-positionForPoint-offset.html: Added.

2017-09-26 Joanmarie Diggs <jdiggs@igalia.com>

AX: ARIA grids claim to be multiselectable even with aria-multiselectable is set to false
Expand Down
@@ -0,0 +1 @@

25 changes: 25 additions & 0 deletions LayoutTests/fast/text/invalid-positionForPoint-offset.html
@@ -0,0 +1,25 @@
<style>
* {
border-bottom: green solid;
margin: 0px;
}
</style>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
function eventhandler() {
dd.before(a);
document.caretRangeFromPoint(0,0);
if (window.testRunner)
testRunner.notifyDone();
}
</script>
<h6>
<a id="a"></a>
</h6>
<dd id="dd"></dd>
<svg>
PASS if no crash.
<set attributeName="dominant-baseline" onbegin="eventhandler()" />
18 changes: 18 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,21 @@
2017-09-26 Zalan Bujtas <zalan@apple.com>

Fall back to normal line layout position, when simple line layout fails to find one.
https://bugs.webkit.org/show_bug.cgi?id=176220
<rdar://problem/34205774>

Reviewed by Brent Fulgham.

In case of empty content, let's just fall back to normal line layout and try to
find the visually correct one.

Test: fast/text/invalid-positionForPoint-offset.html

* rendering/RenderText.cpp:
(WebCore::RenderText::positionForPoint):
* rendering/SimpleLineLayoutResolver.cpp:
(WebCore::SimpleLineLayout::RunResolver::runForPoint const):

2017-09-26 Joanmarie Diggs <jdiggs@igalia.com>

AX: ARIA grids claim to be multiselectable even with aria-multiselectable is set to false
Expand Down
6 changes: 5 additions & 1 deletion Source/WebCore/rendering/RenderText.cpp
Expand Up @@ -447,7 +447,11 @@ Vector<FloatQuad> RenderText::absoluteQuadsForRange(unsigned start, unsigned end
Position RenderText::positionForPoint(const LayoutPoint& point)
{
if (simpleLineLayout() && parent()->firstChild() == parent()->lastChild()) {
auto position = Position(textNode(), SimpleLineLayout::textOffsetForPoint(point, *this, *simpleLineLayout()));
auto offset = SimpleLineLayout::textOffsetForPoint(point, *this, *simpleLineLayout());
// Did not find a valid offset. Fall back to the normal line layout based Position.
if (offset == textLength())
return positionForPoint(point, nullptr).deepEquivalent();
auto position = Position(textNode(), offset);
ASSERT(position == positionForPoint(point, nullptr).deepEquivalent());
return position;
}
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/rendering/SimpleLineLayoutResolver.cpp
Expand Up @@ -239,6 +239,8 @@ RunResolver::Iterator RunResolver::runForPoint(const LayoutPoint& point) const
{
if (!m_lineHeight)
return end();
if (begin() == end())
return end();
unsigned lineIndex = lineIndexForHeight(point.y(), IndexType::Last);
auto x = point.x() - m_borderAndPaddingBefore;
auto it = begin();
Expand Down

0 comments on commit b82882b

Please sign in to comment.