Title: [222539] trunk
Revision
222539
Author
[email protected]
Date
2017-09-26 18:15:07 -0700 (Tue, 26 Sep 2017)

Log Message

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.

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (222538 => 222539)


--- trunk/LayoutTests/ChangeLog	2017-09-27 01:00:31 UTC (rev 222538)
+++ trunk/LayoutTests/ChangeLog	2017-09-27 01:15:07 UTC (rev 222539)
@@ -1,3 +1,14 @@
+2017-09-26  Zalan Bujtas  <[email protected]>
+
+        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  Matt Lewis  <[email protected]>
 
         Unreviewed, rolling out r222525.

Added: trunk/LayoutTests/fast/text/invalid-positionForPoint-offset-expected.txt (0 => 222539)


--- trunk/LayoutTests/fast/text/invalid-positionForPoint-offset-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/text/invalid-positionForPoint-offset-expected.txt	2017-09-27 01:15:07 UTC (rev 222539)
@@ -0,0 +1 @@
+

Added: trunk/LayoutTests/fast/text/invalid-positionForPoint-offset.html (0 => 222539)


--- trunk/LayoutTests/fast/text/invalid-positionForPoint-offset.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/invalid-positionForPoint-offset.html	2017-09-27 01:15:07 UTC (rev 222539)
@@ -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()" />

Modified: trunk/Source/WebCore/ChangeLog (222538 => 222539)


--- trunk/Source/WebCore/ChangeLog	2017-09-27 01:00:31 UTC (rev 222538)
+++ trunk/Source/WebCore/ChangeLog	2017-09-27 01:15:07 UTC (rev 222539)
@@ -1,3 +1,21 @@
+2017-09-26  Zalan Bujtas  <[email protected]>
+
+        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  Matt Lewis  <[email protected]>
 
         Unreviewed, rolling out r222525.

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (222538 => 222539)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2017-09-27 01:00:31 UTC (rev 222538)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2017-09-27 01:15:07 UTC (rev 222539)
@@ -446,7 +446,11 @@
 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;
     }

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp (222538 => 222539)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp	2017-09-27 01:00:31 UTC (rev 222538)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp	2017-09-27 01:15:07 UTC (rev 222539)
@@ -239,6 +239,8 @@
 {
     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();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to