Title: [210831] trunk
Revision
210831
Author
[email protected]
Date
2017-01-17 16:02:42 -0800 (Tue, 17 Jan 2017)

Log Message

Editing nested RTL-LTR content makes the process unresponsive.
https://bugs.webkit.org/show_bug.cgi?id=167140
rdar://problem/29057611

Reviewed by Ryosuke Niwa.

Source/WebCore:

Break out of the loop if we keep coming back to the same position.
This is a workaround for the underlying editing/position bug -> webkit.org/b/167138.

Test: editing/rtl-to-ltr-editing-word-move-spin.html

* editing/VisibleUnits.cpp:
(WebCore::visualWordPosition):

LayoutTests:

* editing/rtl-to-ltr-editing-word-move-spin-expected.txt: Added.
* editing/rtl-to-ltr-editing-word-move-spin.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (210830 => 210831)


--- trunk/LayoutTests/ChangeLog	2017-01-17 23:57:09 UTC (rev 210830)
+++ trunk/LayoutTests/ChangeLog	2017-01-18 00:02:42 UTC (rev 210831)
@@ -1,3 +1,14 @@
+2017-01-17  Zalan Bujtas  <[email protected]>
+
+        Editing nested RTL-LTR content makes the process unresponsive.
+        https://bugs.webkit.org/show_bug.cgi?id=167140
+        rdar://problem/29057611
+
+        Reviewed by Ryosuke Niwa.
+
+        * editing/rtl-to-ltr-editing-word-move-spin-expected.txt: Added.
+        * editing/rtl-to-ltr-editing-word-move-spin.html: Added.
+
 2017-01-17  Ryan Haddad  <[email protected]>
 
         Marking http/tests/media/hls/hls-video-resize.html as flaky on mac.

Added: trunk/LayoutTests/editing/rtl-to-ltr-editing-word-move-spin-expected.txt (0 => 210831)


--- trunk/LayoutTests/editing/rtl-to-ltr-editing-word-move-spin-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/rtl-to-ltr-editing-word-move-spin-expected.txt	2017-01-18 00:02:42 UTC (rev 210831)
@@ -0,0 +1,4 @@
+Pass if no hang.
+‫ foobar foobar‫
+
+

Added: trunk/LayoutTests/editing/rtl-to-ltr-editing-word-move-spin.html (0 => 210831)


--- trunk/LayoutTests/editing/rtl-to-ltr-editing-word-move-spin.html	                        (rev 0)
+++ trunk/LayoutTests/editing/rtl-to-ltr-editing-word-move-spin.html	2017-01-18 00:02:42 UTC (rev 210831)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This test that we can jump word by word over rtl-ltr content.</title>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+</head>
+<body contenteditable="true";>
+Pass if no hang.
+<div style="direction: rtl;">&#x202B foobar foobar&#x202B</div></br>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+    getSelection().setPosition(document.querySelector('div').firstChild, 2);
+    getSelection().modify('move', 'right', 'word');
+    getSelection().modify('move', 'right', 'word');
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (210830 => 210831)


--- trunk/Source/WebCore/ChangeLog	2017-01-17 23:57:09 UTC (rev 210830)
+++ trunk/Source/WebCore/ChangeLog	2017-01-18 00:02:42 UTC (rev 210831)
@@ -1,3 +1,19 @@
+2017-01-17  Zalan Bujtas  <[email protected]>
+
+        Editing nested RTL-LTR content makes the process unresponsive.
+        https://bugs.webkit.org/show_bug.cgi?id=167140
+        rdar://problem/29057611
+
+        Reviewed by Ryosuke Niwa.
+
+        Break out of the loop if we keep coming back to the same position.
+        This is a workaround for the underlying editing/position bug -> webkit.org/b/167138.
+
+        Test: editing/rtl-to-ltr-editing-word-move-spin.html
+
+        * editing/VisibleUnits.cpp:
+        (WebCore::visualWordPosition):
+
 2017-01-16  Filip Pizlo  <[email protected]>
 
         JSCell::classInfo() shouldn't have a bunch of mitigations for being called during destruction

Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (210830 => 210831)


--- trunk/Source/WebCore/editing/VisibleUnits.cpp	2017-01-17 23:57:09 UTC (rev 210830)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp	2017-01-18 00:02:42 UTC (rev 210831)
@@ -352,6 +352,7 @@
     TextDirection blockDirection = directionOfEnclosingBlock(visiblePosition.deepEquivalent());
     InlineBox* previouslyVisitedBox = nullptr;
     VisiblePosition current = visiblePosition;
+    std::optional<VisiblePosition> previousPosition;
     UBreakIterator* iter = nullptr;
 
     CachedLogicallyOrderedLeafBoxes leafBoxes;
@@ -361,6 +362,9 @@
         VisiblePosition adjacentCharacterPosition = direction == MoveRight ? current.right(true) : current.left(true); 
         if (adjacentCharacterPosition == current || adjacentCharacterPosition.isNull())
             return VisiblePosition();
+        // FIXME: This is a workaround for webkit.org/b/167138.
+        if (previousPosition && adjacentCharacterPosition == previousPosition.value())
+            return VisiblePosition();
     
         InlineBox* box;
         int offsetInBox;
@@ -409,6 +413,7 @@
         if (isWordBreak)
             return adjacentCharacterPosition;
     
+        previousPosition = current;
         current = adjacentCharacterPosition;
     }
     return VisiblePosition();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to