Title: [101561] trunk
Revision
101561
Author
rn...@webkit.org
Date
2011-11-30 15:27:07 -0800 (Wed, 30 Nov 2011)

Log Message

Cannot select RTL text inside LTR text from right to left by a mouse drag
https://bugs.webkit.org/show_bug.cgi?id=73056

Reviewed by Eric Seidel.

Source/WebCore: 

The bug was caused by positionAtRightBoundaryOfBiDiRun using current inline box's offset
even when creating a position with previous inline box. Fixed the bug by using the correct offset.

* editing/RenderedPosition.cpp:
(WebCore::RenderedPosition::positionAtLeftBoundaryOfBiDiRun):
(WebCore::RenderedPosition::positionAtRightBoundaryOfBiDiRun):

LayoutTests: 

Added a test case to ensure WebKit can select "A" in "aCBAb" when selecting text by a mouse drag
from the position between "A" and "b" to the position between "B" and "A".

* editing/selection/select-bidi-run-expected.txt:
* editing/selection/select-bidi-run.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (101560 => 101561)


--- trunk/LayoutTests/ChangeLog	2011-11-30 23:25:40 UTC (rev 101560)
+++ trunk/LayoutTests/ChangeLog	2011-11-30 23:27:07 UTC (rev 101561)
@@ -1,3 +1,16 @@
+2011-11-30  Ryosuke Niwa  <rn...@webkit.org>
+
+        Cannot select RTL text inside LTR text from right to left by a mouse drag
+        https://bugs.webkit.org/show_bug.cgi?id=73056
+
+        Reviewed by Eric Seidel.
+
+        Added a test case to ensure WebKit can select "A" in "aCBAb" when selecting text by a mouse drag
+        from the position between "A" and "b" to the position between "B" and "A".
+
+        * editing/selection/select-bidi-run-expected.txt:
+        * editing/selection/select-bidi-run.html:
+
 2011-11-30  Chris Fleizach  <cfleiz...@apple.com>
 
         AX: Searching mechanism gets stuck when searching tables

Modified: trunk/LayoutTests/editing/selection/select-bidi-run-expected.txt (101560 => 101561)


--- trunk/LayoutTests/editing/selection/select-bidi-run-expected.txt	2011-11-30 23:25:40 UTC (rev 101560)
+++ trunk/LayoutTests/editing/selection/select-bidi-run-expected.txt	2011-11-30 23:27:07 UTC (rev 101561)
@@ -112,6 +112,16 @@
 PASS selected "ABC 1"
 FAIL selected "123" but expected "ABC 123"
 
+Test "ABC" in "aABCb":
+Selecting from left to right
+PASS selected "C"
+PASS selected "BC"
+PASS selected "ABC"
+Selecting from right to left
+PASS selected "A"
+PASS selected "AB"
+PASS selected "ABC"
+
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/editing/selection/select-bidi-run.html (101560 => 101561)


--- trunk/LayoutTests/editing/selection/select-bidi-run.html	2011-11-30 23:25:40 UTC (rev 101560)
+++ trunk/LayoutTests/editing/selection/select-bidi-run.html	2011-11-30 23:27:07 UTC (rev 101561)
@@ -8,6 +8,7 @@
 dt { width: 15ex; padding: 0px 10px; margin: 0px; }
 dd { font-size: 0.6em; margin: 0px; padding: 0px 10px; }
 .target { background-color: #bbeeff; }
+.targetContainer { position: absolute; left: 10px; top: 0px; z-index: -5; }
 </style>
 </head>
 <body>
@@ -44,6 +45,9 @@
 <dt contenteditable><span class="target">אבג 123</span></dt>
 <dd>1,12, 123,C 123,BC 123,ABC 123|A,AB,ABC,ABC ,ABC 12,ABC 1,ABC 123</dd>
 
+<dt contenteditable style="position: relative;">aאבגb<div class="targetContainer">a<span class="target">אבג</span>b</div></dt>
+<dd>C,BC,ABC|A,AB,ABC</dd>
+
 <!--<dt contenteditable><span class="target">אבג 123 - 456</span></dt>
 <dd>1,12, 123,C 123,BC 123,ABC 123|A,AB,ABC,ABC ,ABC 12,ABC 1,ABC 123</dd>-->
 
@@ -71,6 +75,13 @@
     var y = target.offsetTop + target.offsetHeight / 2;
     var left = target.offsetLeft;
 
+    offsetParent = target.offsetParent;
+    while (offsetParent) {
+        y += offsetParent.offsetTop;
+        left += offsetParent.offsetLeft;
+        offsetParent = offsetParent.offsetParent;
+    }
+
     var startX = left + (leftToRight ? 0 : target.offsetWidth);
     eventSender.dragMode = false;
 
@@ -114,6 +125,7 @@
         testExpectations[i].style.display = null;
 
         var target = tests[i].getElementsByClassName('target')[0];
+        var relativeTargets = tests[i].getElementsByClassName('relativeTarget');
         var testExpectation = testExpectations[i].textContent;
 
         debug('Test "' + target.textContent.fold() + '" in "' + target.parentNode.textContent.fold() + '":');

Modified: trunk/Source/WebCore/ChangeLog (101560 => 101561)


--- trunk/Source/WebCore/ChangeLog	2011-11-30 23:25:40 UTC (rev 101560)
+++ trunk/Source/WebCore/ChangeLog	2011-11-30 23:27:07 UTC (rev 101561)
@@ -1,3 +1,17 @@
+2011-11-30  Ryosuke Niwa  <rn...@webkit.org>
+
+        Cannot select RTL text inside LTR text from right to left by a mouse drag
+        https://bugs.webkit.org/show_bug.cgi?id=73056
+
+        Reviewed by Eric Seidel.
+
+        The bug was caused by positionAtRightBoundaryOfBiDiRun using current inline box's offset
+        even when creating a position with previous inline box. Fixed the bug by using the correct offset.
+
+        * editing/RenderedPosition.cpp:
+        (WebCore::RenderedPosition::positionAtLeftBoundaryOfBiDiRun):
+        (WebCore::RenderedPosition::positionAtRightBoundaryOfBiDiRun):
+
 2011-11-30 Chris Fleizach  <cfleiz...@apple.com>
 
         AX: Searching mechanism gets stuck when searching tables

Modified: trunk/Source/WebCore/editing/RenderedPosition.cpp (101560 => 101561)


--- trunk/Source/WebCore/editing/RenderedPosition.cpp	2011-11-30 23:25:40 UTC (rev 101560)
+++ trunk/Source/WebCore/editing/RenderedPosition.cpp	2011-11-30 23:27:07 UTC (rev 101561)
@@ -211,7 +211,7 @@
     if (atLeftmostOffsetInBox())
         return createLegacyEditingPosition(m_renderer->node(), m_offset);
 
-    return createLegacyEditingPosition(nextLeafChild()->renderer()->node(), m_offset);
+    return createLegacyEditingPosition(nextLeafChild()->renderer()->node(), nextLeafChild()->caretLeftmostOffset());
 }
 
 Position RenderedPosition::positionAtRightBoundaryOfBiDiRun() const
@@ -221,7 +221,7 @@
     if (atRightmostOffsetInBox())
         return createLegacyEditingPosition(m_renderer->node(), m_offset);
 
-    return createLegacyEditingPosition(prevLeafChild()->renderer()->node(), m_offset);
+    return createLegacyEditingPosition(prevLeafChild()->renderer()->node(), prevLeafChild()->caretRightmostOffset());
 }
 
 LayoutRect RenderedPosition::absoluteRect(int* extraWidthToEndOfLine) const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to