[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

rniwa at webkit.org rniwa at webkit.org
Wed Dec 22 18:12:59 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 2798e0267dd5416e37e9c5d973b940d404540bb0
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Dec 8 21:55:54 2010 +0000

    2010-12-08  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Dan Bernstein.
    
            REGRESSION: LayoutTests/editing/selection/caret-rtl-2.html fails
            https://bugs.webkit.org/show_bug.cgi?id=33503
    
            The bug was caused by Font::offsetForPosition's not taking into account the containing block's text direction.
            When RTL text appears in a LTR block, the offset at the beginning of RTL text is on the left of RTL text,
            adn the offset at the end of RTL text is on the right of RTL text. For example, if we had RTL text CBA,
            then the correspondance between letters and offsets in logical order are: A -> 0, B -> 1, and C -> 2.
    
            Case 1. CBA appears in a RTL block:
              In this case, clicking on the visual left of CBA puts the caret naturally at Position("CBA", 2).
              Clicking on the visual right of CBA puts the caret at Position("CBA", 0) as expected.
            Case 2. CBA appears in a LTR block:
              Because the containing block flows from left to right, by covention, Position("CBA", 2") coresponds
              to the visual right of CBA, and Position("CBA", 0) corresponds to the visual left of CBA.
              Therefore, clicking on the visual left of CBA should put the caret at Positoin("CBA", 0),
              and clicking on the visual right should put it at Position("CBA", 2).
    
            The bug was caused by WebKit's not considering case 2. The same bug also existe for LTR text in a RTL block.
            Fixed the bug by taking care of the case 2 in InlineTextBox::offsetForPosition.
    
            Tests: editing/selection/caret-ltr-2-left.html
                   editing/selection/caret-ltr-2.html
                   editing/selection/caret-ltr-right.html
                   editing/selection/caret-ltr.html
                   editing/selection/caret-rtl-2-left.html
                   editing/selection/caret-rtl-right.html
    
            * rendering/InlineTextBox.cpp:
            (WebCore::InlineTextBox::offsetForPosition):
    2010-12-08  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Dan Bernstein.
    
            REGRESSION: LayoutTests/editing/selection/caret-rtl-2.html fails
            https://bugs.webkit.org/show_bug.cgi?id=33503
    
            Added tests to ensure WebKit places the caret at a right place for LTR text in a LTR block,
            LTR text in a RTL block, RTL text in a RTL block, and RTL text in a LTR block.
    
            Because we need to verify both rendering of the caret and (node, offset) pair of the caret,
            these tests cannot be combined or done without pixel results.
    
            * editing/selection/caret-ltr-2-left.html: Added.
            * editing/selection/caret-ltr-2.html: Added.
            * editing/selection/caret-ltr-right.html: Added.
            * editing/selection/caret-ltr.html: Added.
            * editing/selection/caret-rtl-2-left.html: Added.
            * editing/selection/caret-rtl-2.html:
            * editing/selection/caret-rtl-right.html: Added.
            * editing/selection/caret-rtl.html:
            * editing/selection/resources/caret-edge-shared.js: Added.
            (runTest):
            (verify):
            (log):
            * platform/mac/editing/selection/caret-ltr-2-expected.checksum: Added.
            * platform/mac/editing/selection/caret-ltr-2-expected.png: Added.
            * platform/mac/editing/selection/caret-ltr-2-expected.txt: Added.
            * platform/mac/editing/selection/caret-ltr-2-left-expected.checksum: Added.
            * platform/mac/editing/selection/caret-ltr-2-left-expected.png: Added.
            * platform/mac/editing/selection/caret-ltr-2-left-expected.txt: Added.
            * platform/mac/editing/selection/caret-ltr-expected.checksum: Added.
            * platform/mac/editing/selection/caret-ltr-expected.png: Added.
            * platform/mac/editing/selection/caret-ltr-expected.txt: Added.
            * platform/mac/editing/selection/caret-ltr-right-expected.checksum: Added.
            * platform/mac/editing/selection/caret-ltr-right-expected.png: Added.
            * platform/mac/editing/selection/caret-ltr-right-expected.txt: Added.
            * platform/mac/editing/selection/caret-rtl-2-expected.checksum:
            * platform/mac/editing/selection/caret-rtl-2-expected.png:
            * platform/mac/editing/selection/caret-rtl-2-expected.txt:
            * platform/mac/editing/selection/caret-rtl-2-left-expected.checksum: Added.
            * platform/mac/editing/selection/caret-rtl-2-left-expected.png: Added.
            * platform/mac/editing/selection/caret-rtl-2-left-expected.txt: Added.
            * platform/mac/editing/selection/caret-rtl-expected.checksum:
            * platform/mac/editing/selection/caret-rtl-expected.png:
            * platform/mac/editing/selection/caret-rtl-expected.txt:
            * platform/mac/editing/selection/caret-rtl-right-expected.checksum: Added.
            * platform/mac/editing/selection/caret-rtl-right-expected.png: Added.
            * platform/mac/editing/selection/caret-rtl-right-expected.txt: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73548 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index fbac93b..cf17a65 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,53 @@
+2010-12-08  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Dan Bernstein.
+
+        REGRESSION: LayoutTests/editing/selection/caret-rtl-2.html fails
+        https://bugs.webkit.org/show_bug.cgi?id=33503
+
+        Added tests to ensure WebKit places the caret at a right place for LTR text in a LTR block,
+        LTR text in a RTL block, RTL text in a RTL block, and RTL text in a LTR block.
+
+        Because we need to verify both rendering of the caret and (node, offset) pair of the caret,
+        these tests cannot be combined or done without pixel results.
+
+        * editing/selection/caret-ltr-2-left.html: Added.
+        * editing/selection/caret-ltr-2.html: Added.
+        * editing/selection/caret-ltr-right.html: Added.
+        * editing/selection/caret-ltr.html: Added.
+        * editing/selection/caret-rtl-2-left.html: Added.
+        * editing/selection/caret-rtl-2.html:
+        * editing/selection/caret-rtl-right.html: Added.
+        * editing/selection/caret-rtl.html:
+        * editing/selection/resources/caret-edge-shared.js: Added.
+        (runTest):
+        (verify):
+        (log):
+        * platform/mac/editing/selection/caret-ltr-2-expected.checksum: Added.
+        * platform/mac/editing/selection/caret-ltr-2-expected.png: Added.
+        * platform/mac/editing/selection/caret-ltr-2-expected.txt: Added.
+        * platform/mac/editing/selection/caret-ltr-2-left-expected.checksum: Added.
+        * platform/mac/editing/selection/caret-ltr-2-left-expected.png: Added.
+        * platform/mac/editing/selection/caret-ltr-2-left-expected.txt: Added.
+        * platform/mac/editing/selection/caret-ltr-expected.checksum: Added.
+        * platform/mac/editing/selection/caret-ltr-expected.png: Added.
+        * platform/mac/editing/selection/caret-ltr-expected.txt: Added.
+        * platform/mac/editing/selection/caret-ltr-right-expected.checksum: Added.
+        * platform/mac/editing/selection/caret-ltr-right-expected.png: Added.
+        * platform/mac/editing/selection/caret-ltr-right-expected.txt: Added.
+        * platform/mac/editing/selection/caret-rtl-2-expected.checksum:
+        * platform/mac/editing/selection/caret-rtl-2-expected.png:
+        * platform/mac/editing/selection/caret-rtl-2-expected.txt:
+        * platform/mac/editing/selection/caret-rtl-2-left-expected.checksum: Added.
+        * platform/mac/editing/selection/caret-rtl-2-left-expected.png: Added.
+        * platform/mac/editing/selection/caret-rtl-2-left-expected.txt: Added.
+        * platform/mac/editing/selection/caret-rtl-expected.checksum:
+        * platform/mac/editing/selection/caret-rtl-expected.png:
+        * platform/mac/editing/selection/caret-rtl-expected.txt:
+        * platform/mac/editing/selection/caret-rtl-right-expected.checksum: Added.
+        * platform/mac/editing/selection/caret-rtl-right-expected.png: Added.
+        * platform/mac/editing/selection/caret-rtl-right-expected.txt: Added.
+
 2010-12-08  Alexey Proskuryakov  <ap at apple.com>
 
         Touch a file that's sporadically giving 207 Multi-Status error on svn update, hoping that
diff --git a/LayoutTests/editing/selection/caret-ltr-2-left.html b/LayoutTests/editing/selection/caret-ltr-2-left.html
new file mode 100644
index 0000000..e13bdd2
--- /dev/null
+++ b/LayoutTests/editing/selection/caret-ltr-2-left.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>
+This tests that clicking in a contenteditable div will set the caret in the right position for LTR text in a RTL block.
+To test manually, click the left of the text. The caret should be on the left edge.
+</p>
+<div style="direction: rtl; font-size: 20px; width: 20ex; border: solid thin black; padding: 10px;" contenteditable>WebKit2</div>
+<script src="resources/caret-edge-shared.js"></script>
+<script>
+
+var clickOn = 'left';
+var expectedOffset = 7;
+
+runTest();
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/caret-ltr-2.html b/LayoutTests/editing/selection/caret-ltr-2.html
new file mode 100644
index 0000000..ab1eda1
--- /dev/null
+++ b/LayoutTests/editing/selection/caret-ltr-2.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>
+This tests that clicking in a contenteditable div will set the caret in the right position for LTR text in a RTL block.
+To test manually, click the right of the text. The caret should be on the right edge.
+</p>
+<div style="direction: rtl; font-size: 20px; width: 20ex; border: solid thin black; padding: 10px;" contenteditable>WebKit2</div>
+<script src="resources/caret-edge-shared.js"></script>
+<script>
+
+var clickOn = 'right';
+var expectedOffset = 0;
+
+runTest();
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/caret-ltr-right.html b/LayoutTests/editing/selection/caret-ltr-right.html
new file mode 100644
index 0000000..281bdc4
--- /dev/null
+++ b/LayoutTests/editing/selection/caret-ltr-right.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>
+This tests that clicking in a contenteditable div will set the caret in the right position for LTR text in a LTR block.
+To test manually, click the right of the text. The caret should be on the right edge.
+</p>
+<div style="font-size: 20px; width: 20ex; border: solid thin black; padding: 10px;" contenteditable>WebKit2</div>
+<script src="resources/caret-edge-shared.js"></script>
+<script>
+
+var clickOn = 'right';
+var expectedOffset = 7;
+
+runTest();
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/caret-ltr.html b/LayoutTests/editing/selection/caret-ltr.html
new file mode 100644
index 0000000..15febbc
--- /dev/null
+++ b/LayoutTests/editing/selection/caret-ltr.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>
+This tests that clicking in a contenteditable div will set the caret in the right position for LTR text in a LTR block.
+To test manually, click the left of the text. The caret should be on the left edge.
+</p>
+<div style="font-size: 20px; width: 20ex; border: solid thin black; padding: 10px;" contenteditable>WebKit2</div>
+<script src="resources/caret-edge-shared.js"></script>
+<script>
+
+var clickOn = 'left';
+var expectedOffset = 0;
+
+runTest();
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/caret-rtl-2-left.html b/LayoutTests/editing/selection/caret-rtl-2-left.html
new file mode 100644
index 0000000..4627b03
--- /dev/null
+++ b/LayoutTests/editing/selection/caret-rtl-2-left.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>
+This tests that clicking in a contenteditable div will set the caret in the right position for RTL text in a LTR block.
+To test manually, click the left of the text. The caret should be on the left edge.
+</p>
+<div style="font-size: 20px; width: 20ex; border: solid thin black; padding: 10px;" contenteditable>&#x05e9;&#x05d3;&#x05d4; &#x05d1;&#x05d5;&#x05e8;</div>
+<script src="resources/caret-edge-shared.js"></script>
+<script>
+
+var clickOn = 'left';
+var expectedOffset = 0;
+
+runTest();
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/caret-rtl-2.html b/LayoutTests/editing/selection/caret-rtl-2.html
index ef7b956..ada1cd8 100644
--- a/LayoutTests/editing/selection/caret-rtl-2.html
+++ b/LayoutTests/editing/selection/caret-rtl-2.html
@@ -1,28 +1,19 @@
+<!DOCTYPE html>
 <html>
-<head>
+<body>
+<p>
+This tests that clicking in a contenteditable div will set the caret in the right position for RTL text in a RTL block.
+To test manually, click the right of the text. The caret should be on the right edge.
+</p>
+<div style="font-size: 20px; width: 20ex; border: solid thin black; padding: 10px;" contenteditable>&#x05e9;&#x05d3;&#x05d4; &#x05d1;&#x05d5;&#x05e8;</div>
+<script src="resources/caret-edge-shared.js"></script>
 <script>
-if (window.layoutTestController)
-     layoutTestController.dumpEditingCallbacks();
-</script>
 
-<script>
-function test()
-{    
-    if (window.layoutTestController) {
-        eventSender.mouseMoveTo(145, 75);
-        eventSender.mouseDown();
-        eventSender.mouseUp();
-    }
-}
+var clickOn = 'right';
+var expectedOffset = 7;
+
+runTest();
+
 </script>
-</head>
-<body onload="test()">
-This tests that clicking in a contenteditable div will set the caret in the right position for rtl text.
-<br>
-<p>
-    Click in the middle of the field.  The caret should be on the edge of the text closer to where you clicked.
-</p>
-<div style="width:150px; border: solid thin black; position: absolute; top: 70; left: 10;" contenteditable>&#x05e9;&#x05d3;&#x05d4; &#x05d1;&#x05d5;&#x05e8;</div>
 </body>
 </html>
-
diff --git a/LayoutTests/editing/selection/caret-rtl-right.html b/LayoutTests/editing/selection/caret-rtl-right.html
new file mode 100644
index 0000000..49165f2
--- /dev/null
+++ b/LayoutTests/editing/selection/caret-rtl-right.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>
+This tests that clicking in a contenteditable div will set the caret in the right position for RTL text in a RTL block.
+To test manually, click the right of the text. The caret should be on the right edge.
+</p>
+<div style="direction: rtl; font-size: 20px; width: 20ex; border: solid thin black; padding: 10px;" contenteditable>&#x05e9;&#x05d3;&#x05d4; &#x05d1;&#x05d5;&#x05e8;</div>
+<script src="resources/caret-edge-shared.js"></script>
+<script>
+
+var clickOn = 'right';
+var expectedOffset = 0;
+
+runTest();
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/caret-rtl.html b/LayoutTests/editing/selection/caret-rtl.html
index 26a744c..5424545 100644
--- a/LayoutTests/editing/selection/caret-rtl.html
+++ b/LayoutTests/editing/selection/caret-rtl.html
@@ -1,28 +1,19 @@
+<!DOCTYPE html>
 <html>
-<head>
+<body>
+<p>
+This tests that clicking in a contenteditable div will set the caret in the right position for RTL text in a RTL block.
+To test manually, click the left of the text. The caret should be on the left edge.
+</p>
+<div style="direction: rtl; font-size: 20px; width: 20ex; border: solid thin black; padding: 10px;" contenteditable>&#x05e9;&#x05d3;&#x05d4; &#x05d1;&#x05d5;&#x05e8;</div>
+<script src="resources/caret-edge-shared.js"></script>
 <script>
-if (window.layoutTestController)
-     layoutTestController.dumpEditingCallbacks();
-</script>
 
-<script>
-function test()
-{    
-    if (window.layoutTestController) {
-        eventSender.mouseMoveTo(25, 75);
-        eventSender.mouseDown();
-        eventSender.mouseUp();
-    }
-}
+var clickOn = 'left';
+var expectedOffset = 7;
+
+runTest();
+
 </script>
-</head>
-<body onload="test()">
-This tests that clicking in a contenteditable div will set the caret in the right position for rtl text.
-<br>
-<p>
-    Click in the middle of the field.  The caret should be on the edge of the text closer to where you clicked.
-</p>
-<div style="direction: rtl; width:150px; border: solid thin black; position: absolute; top: 70; left: 10;" contenteditable>&#x05e9;&#x05d3;&#x05d4; &#x05d1;&#x05d5;&#x05e8;</div>
 </body>
 </html>
-
diff --git a/LayoutTests/editing/selection/resources/caret-edge-shared.js b/LayoutTests/editing/selection/resources/caret-edge-shared.js
new file mode 100644
index 0000000..6ee364c
--- /dev/null
+++ b/LayoutTests/editing/selection/resources/caret-edge-shared.js
@@ -0,0 +1,41 @@
+
+function runTest() {
+    var div = document.getElementsByTagName('div')[0];
+
+    if (!window.layoutTestController) {
+        div.addEventListener('mouseup', verify);
+        return;
+    }
+
+    if (clickOn == 'left')
+        x = 5;
+    else
+        x = div.offsetWidth - 5;
+
+    eventSender.mouseMoveTo(div.offsetLeft + x, div.offsetTop + div.offsetHeight / 2);
+    eventSender.leapForward(200);
+    eventSender.mouseDown();
+    eventSender.leapForward(200);
+    eventSender.mouseUp();
+    verify();
+}
+
+function verify() {
+    var div = document.getElementsByTagName('div')[0];
+
+    if (!window.getSelection().isCollapsed)
+        return log('FAIL: selection not collapsed');
+
+    var range = window.getSelection().getRangeAt(0);
+    if (range.startContainer != div.firstChild)
+        return log('FAIL: wrong container');
+    if (range.startOffset != expectedOffset)
+        return log('FAIL: wrong offset ' + range.startOffset + ', expected ' + expectedOffset);
+
+    return log('PASS');
+}
+
+function log(message) {
+    document.body.appendChild(document.createTextNode(message));
+    document.body.appendChild(document.createElement('br'));
+}
diff --git a/LayoutTests/platform/mac/editing/selection/caret-ltr-2-expected.checksum b/LayoutTests/platform/mac/editing/selection/caret-ltr-2-expected.checksum
new file mode 100644
index 0000000..fd3ddf2
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/selection/caret-ltr-2-expected.checksum
@@ -0,0 +1 @@
+3b7687855f10767b95fc2ed1debdd1bd
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/selection/caret-ltr-2-expected.png b/LayoutTests/platform/mac/editing/selection/caret-ltr-2-expected.png
new file mode 100644
index 0000000..ca29f68
Binary files /dev/null and b/LayoutTests/platform/mac/editing/selection/caret-ltr-2-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/selection/caret-ltr-2-expected.txt b/LayoutTests/platform/mac/editing/selection/caret-ltr-2-expected.txt
new file mode 100644
index 0000000..6e7182f
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/selection/caret-ltr-2-expected.txt
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x139
+  RenderBlock {HTML} at (0,0) size 800x139
+    RenderBody {BODY} at (8,16) size 784x115
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 758x36
+          text run at (0,0) width 758: "This tests that clicking in a contenteditable div will set the caret in the right position for LTR text in a RTL block. To test"
+          text run at (0,18) width 465: "manually, click the right of the text. The caret should be on the right edge."
+      RenderBlock {DIV} at (0,52) size 213x45 [border: (1px solid #000000)]
+        RenderText {#text} at (128,11) size 74x23
+          text run at (128,11) width 74: "WebKit2"
+      RenderBlock (anonymous) at (0,97) size 784x18
+        RenderText {#text} at (0,0) size 39x18
+          text run at (0,0) width 39: "PASS"
+        RenderBR {BR} at (39,0) size 0x18
+caret: position 0 of child 0 {#text} of child 3 {DIV} of body
diff --git a/LayoutTests/platform/mac/editing/selection/caret-ltr-2-left-expected.checksum b/LayoutTests/platform/mac/editing/selection/caret-ltr-2-left-expected.checksum
new file mode 100644
index 0000000..52f1e07
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/selection/caret-ltr-2-left-expected.checksum
@@ -0,0 +1 @@
+abf9975e7d33a61d42e3bf9c12dc266f
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/selection/caret-ltr-2-left-expected.png b/LayoutTests/platform/mac/editing/selection/caret-ltr-2-left-expected.png
new file mode 100644
index 0000000..c321fbb
Binary files /dev/null and b/LayoutTests/platform/mac/editing/selection/caret-ltr-2-left-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/selection/caret-ltr-2-left-expected.txt b/LayoutTests/platform/mac/editing/selection/caret-ltr-2-left-expected.txt
new file mode 100644
index 0000000..21b842d
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/selection/caret-ltr-2-left-expected.txt
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x139
+  RenderBlock {HTML} at (0,0) size 800x139
+    RenderBody {BODY} at (8,16) size 784x115
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 758x36
+          text run at (0,0) width 758: "This tests that clicking in a contenteditable div will set the caret in the right position for LTR text in a RTL block. To test"
+          text run at (0,18) width 447: "manually, click the left of the text. The caret should be on the left edge."
+      RenderBlock {DIV} at (0,52) size 213x45 [border: (1px solid #000000)]
+        RenderText {#text} at (128,11) size 74x23
+          text run at (128,11) width 74: "WebKit2"
+      RenderBlock (anonymous) at (0,97) size 784x18
+        RenderText {#text} at (0,0) size 39x18
+          text run at (0,0) width 39: "PASS"
+        RenderBR {BR} at (39,0) size 0x18
+caret: position 7 of child 0 {#text} of child 3 {DIV} of body
diff --git a/LayoutTests/platform/mac/editing/selection/caret-ltr-expected.checksum b/LayoutTests/platform/mac/editing/selection/caret-ltr-expected.checksum
new file mode 100644
index 0000000..8d0d126
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/selection/caret-ltr-expected.checksum
@@ -0,0 +1 @@
+a31a4482ad7fcdd403375c5f0b305e6e
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/selection/caret-ltr-expected.png b/LayoutTests/platform/mac/editing/selection/caret-ltr-expected.png
new file mode 100644
index 0000000..a12510b
Binary files /dev/null and b/LayoutTests/platform/mac/editing/selection/caret-ltr-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/selection/caret-ltr-expected.txt b/LayoutTests/platform/mac/editing/selection/caret-ltr-expected.txt
new file mode 100644
index 0000000..d6c3052
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/selection/caret-ltr-expected.txt
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x139
+  RenderBlock {HTML} at (0,0) size 800x139
+    RenderBody {BODY} at (8,16) size 784x115
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 758x36
+          text run at (0,0) width 758: "This tests that clicking in a contenteditable div will set the caret in the right position for LTR text in a LTR block. To test"
+          text run at (0,18) width 447: "manually, click the left of the text. The caret should be on the left edge."
+      RenderBlock {DIV} at (0,52) size 213x45 [border: (1px solid #000000)]
+        RenderText {#text} at (11,11) size 74x23
+          text run at (11,11) width 74: "WebKit2"
+      RenderBlock (anonymous) at (0,97) size 784x18
+        RenderText {#text} at (0,0) size 39x18
+          text run at (0,0) width 39: "PASS"
+        RenderBR {BR} at (39,0) size 0x18
+caret: position 0 of child 0 {#text} of child 3 {DIV} of body
diff --git a/LayoutTests/platform/mac/editing/selection/caret-ltr-right-expected.checksum b/LayoutTests/platform/mac/editing/selection/caret-ltr-right-expected.checksum
new file mode 100644
index 0000000..853f6da
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/selection/caret-ltr-right-expected.checksum
@@ -0,0 +1 @@
+718b063b269f4d9ba938a143e61de7f2
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/selection/caret-ltr-right-expected.png b/LayoutTests/platform/mac/editing/selection/caret-ltr-right-expected.png
new file mode 100644
index 0000000..d6f5319
Binary files /dev/null and b/LayoutTests/platform/mac/editing/selection/caret-ltr-right-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/selection/caret-ltr-right-expected.txt b/LayoutTests/platform/mac/editing/selection/caret-ltr-right-expected.txt
new file mode 100644
index 0000000..96248e8
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/selection/caret-ltr-right-expected.txt
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x139
+  RenderBlock {HTML} at (0,0) size 800x139
+    RenderBody {BODY} at (8,16) size 784x115
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 758x36
+          text run at (0,0) width 758: "This tests that clicking in a contenteditable div will set the caret in the right position for LTR text in a LTR block. To test"
+          text run at (0,18) width 465: "manually, click the right of the text. The caret should be on the right edge."
+      RenderBlock {DIV} at (0,52) size 213x45 [border: (1px solid #000000)]
+        RenderText {#text} at (11,11) size 74x23
+          text run at (11,11) width 74: "WebKit2"
+      RenderBlock (anonymous) at (0,97) size 784x18
+        RenderText {#text} at (0,0) size 39x18
+          text run at (0,0) width 39: "PASS"
+        RenderBR {BR} at (39,0) size 0x18
+caret: position 7 of child 0 {#text} of child 3 {DIV} of body
diff --git a/LayoutTests/platform/mac/editing/selection/caret-rtl-2-expected.checksum b/LayoutTests/platform/mac/editing/selection/caret-rtl-2-expected.checksum
index e36d547..fd2904b 100644
--- a/LayoutTests/platform/mac/editing/selection/caret-rtl-2-expected.checksum
+++ b/LayoutTests/platform/mac/editing/selection/caret-rtl-2-expected.checksum
@@ -1 +1 @@
-7fe6fd218948722ede6f6937ad29c6e3
\ No newline at end of file
+8c48e5709f8fded01efd36c9590039de
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/selection/caret-rtl-2-expected.png b/LayoutTests/platform/mac/editing/selection/caret-rtl-2-expected.png
index 4e3fb6f..0c61a7c 100644
Binary files a/LayoutTests/platform/mac/editing/selection/caret-rtl-2-expected.png and b/LayoutTests/platform/mac/editing/selection/caret-rtl-2-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/selection/caret-rtl-2-expected.txt b/LayoutTests/platform/mac/editing/selection/caret-rtl-2-expected.txt
index 5bdc68f..8cb5739 100644
--- a/LayoutTests/platform/mac/editing/selection/caret-rtl-2-expected.txt
+++ b/LayoutTests/platform/mac/editing/selection/caret-rtl-2-expected.txt
@@ -1,22 +1,17 @@
-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
-EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x576
-      RenderBlock (anonymous) at (0,0) size 784x18
-        RenderText {#text} at (0,0) size 596x18
-          text run at (0,0) width 596: "This tests that clicking in a contenteditable div will set the caret in the right position for rtl text. "
-        RenderBR {BR} at (596,14) size 0x0
-      RenderBlock {P} at (0,34) size 784x18
-        RenderText {#text} at (0,0) size 649x18
-          text run at (0,0) width 200: "Click in the middle of the field. "
-          text run at (200,0) width 449: "The caret should be on the edge of the text closer to where you clicked."
-layer at (10,70) size 152x20
-  RenderBlock (positioned) {DIV} at (10,70) size 152x20 [border: (1px solid #000000)]
-    RenderText {#text} at (1,1) size 58x18
-      text run at (1,1) width 58 RTL: "\x{5E9}\x{5D3}\x{5D4} \x{5D1}\x{5D5}\x{5E8}"
-caret: position 0 of child 0 {#text} of child 5 {DIV} of body
+layer at (0,0) size 800x139
+  RenderBlock {HTML} at (0,0) size 800x139
+    RenderBody {BODY} at (8,16) size 784x115
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 758x36
+          text run at (0,0) width 758: "This tests that clicking in a contenteditable div will set the caret in the right position for RTL text in a RTL block. To test"
+          text run at (0,18) width 465: "manually, click the right of the text. The caret should be on the right edge."
+      RenderBlock {DIV} at (0,52) size 213x45 [border: (1px solid #000000)]
+        RenderText {#text} at (11,11) size 72x23
+          text run at (11,11) width 72 RTL: "\x{5E9}\x{5D3}\x{5D4} \x{5D1}\x{5D5}\x{5E8}"
+      RenderBlock (anonymous) at (0,97) size 784x18
+        RenderText {#text} at (0,0) size 39x18
+          text run at (0,0) width 39: "PASS"
+        RenderBR {BR} at (39,0) size 0x18
+caret: position 7 of child 0 {#text} of child 3 {DIV} of body
diff --git a/LayoutTests/platform/mac/editing/selection/caret-rtl-2-left-expected.checksum b/LayoutTests/platform/mac/editing/selection/caret-rtl-2-left-expected.checksum
new file mode 100644
index 0000000..2f10fa7
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/selection/caret-rtl-2-left-expected.checksum
@@ -0,0 +1 @@
+ed60d2811467440815682849d7bfda8b
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/selection/caret-rtl-2-left-expected.png b/LayoutTests/platform/mac/editing/selection/caret-rtl-2-left-expected.png
new file mode 100644
index 0000000..13132be
Binary files /dev/null and b/LayoutTests/platform/mac/editing/selection/caret-rtl-2-left-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/selection/caret-rtl-2-left-expected.txt b/LayoutTests/platform/mac/editing/selection/caret-rtl-2-left-expected.txt
new file mode 100644
index 0000000..7b2e857
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/selection/caret-rtl-2-left-expected.txt
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x139
+  RenderBlock {HTML} at (0,0) size 800x139
+    RenderBody {BODY} at (8,16) size 784x115
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 758x36
+          text run at (0,0) width 758: "This tests that clicking in a contenteditable div will set the caret in the right position for RTL text in a LTR block. To test"
+          text run at (0,18) width 447: "manually, click the left of the text. The caret should be on the left edge."
+      RenderBlock {DIV} at (0,52) size 213x45 [border: (1px solid #000000)]
+        RenderText {#text} at (11,11) size 72x23
+          text run at (11,11) width 72 RTL: "\x{5E9}\x{5D3}\x{5D4} \x{5D1}\x{5D5}\x{5E8}"
+      RenderBlock (anonymous) at (0,97) size 784x18
+        RenderText {#text} at (0,0) size 39x18
+          text run at (0,0) width 39: "PASS"
+        RenderBR {BR} at (39,0) size 0x18
+caret: position 0 of child 0 {#text} of child 3 {DIV} of body
diff --git a/LayoutTests/platform/mac/editing/selection/caret-rtl-expected.checksum b/LayoutTests/platform/mac/editing/selection/caret-rtl-expected.checksum
index 8ceb647..6f8f4fb 100644
--- a/LayoutTests/platform/mac/editing/selection/caret-rtl-expected.checksum
+++ b/LayoutTests/platform/mac/editing/selection/caret-rtl-expected.checksum
@@ -1 +1 @@
-6a84f0df35ac5f65f199cba48dcd50bc
\ No newline at end of file
+9b45da74056c05d3be1203a87812ef3b
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/selection/caret-rtl-expected.png b/LayoutTests/platform/mac/editing/selection/caret-rtl-expected.png
index cdbe4b4..1ca3449 100644
Binary files a/LayoutTests/platform/mac/editing/selection/caret-rtl-expected.png and b/LayoutTests/platform/mac/editing/selection/caret-rtl-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/selection/caret-rtl-expected.txt b/LayoutTests/platform/mac/editing/selection/caret-rtl-expected.txt
index 7e6601b..9d7a8fb 100644
--- a/LayoutTests/platform/mac/editing/selection/caret-rtl-expected.txt
+++ b/LayoutTests/platform/mac/editing/selection/caret-rtl-expected.txt
@@ -1,22 +1,17 @@
-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
-EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 7 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x576
-      RenderBlock (anonymous) at (0,0) size 784x18
-        RenderText {#text} at (0,0) size 596x18
-          text run at (0,0) width 596: "This tests that clicking in a contenteditable div will set the caret in the right position for rtl text. "
-        RenderBR {BR} at (596,14) size 0x0
-      RenderBlock {P} at (0,34) size 784x18
-        RenderText {#text} at (0,0) size 649x18
-          text run at (0,0) width 200: "Click in the middle of the field. "
-          text run at (200,0) width 449: "The caret should be on the edge of the text closer to where you clicked."
-layer at (10,70) size 152x20
-  RenderBlock (positioned) {DIV} at (10,70) size 152x20 [border: (1px solid #000000)]
-    RenderText {#text} at (93,1) size 58x18
-      text run at (93,1) width 58 RTL: "\x{5E9}\x{5D3}\x{5D4} \x{5D1}\x{5D5}\x{5E8}"
-caret: position 7 of child 0 {#text} of child 5 {DIV} of body
+layer at (0,0) size 800x139
+  RenderBlock {HTML} at (0,0) size 800x139
+    RenderBody {BODY} at (8,16) size 784x115
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 758x36
+          text run at (0,0) width 758: "This tests that clicking in a contenteditable div will set the caret in the right position for RTL text in a RTL block. To test"
+          text run at (0,18) width 447: "manually, click the left of the text. The caret should be on the left edge."
+      RenderBlock {DIV} at (0,52) size 213x45 [border: (1px solid #000000)]
+        RenderText {#text} at (130,11) size 72x23
+          text run at (130,11) width 72 RTL: "\x{5E9}\x{5D3}\x{5D4} \x{5D1}\x{5D5}\x{5E8}"
+      RenderBlock (anonymous) at (0,97) size 784x18
+        RenderText {#text} at (0,0) size 39x18
+          text run at (0,0) width 39: "PASS"
+        RenderBR {BR} at (39,0) size 0x18
+caret: position 7 of child 0 {#text} of child 3 {DIV} of body
diff --git a/LayoutTests/platform/mac/editing/selection/caret-rtl-right-expected.checksum b/LayoutTests/platform/mac/editing/selection/caret-rtl-right-expected.checksum
new file mode 100644
index 0000000..2311bc0
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/selection/caret-rtl-right-expected.checksum
@@ -0,0 +1 @@
+6dfdf308f2743206380d4994d5977bee
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/selection/caret-rtl-right-expected.png b/LayoutTests/platform/mac/editing/selection/caret-rtl-right-expected.png
new file mode 100644
index 0000000..b8b4f8b
Binary files /dev/null and b/LayoutTests/platform/mac/editing/selection/caret-rtl-right-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/selection/caret-rtl-right-expected.txt b/LayoutTests/platform/mac/editing/selection/caret-rtl-right-expected.txt
new file mode 100644
index 0000000..5c4dbef
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/selection/caret-rtl-right-expected.txt
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x139
+  RenderBlock {HTML} at (0,0) size 800x139
+    RenderBody {BODY} at (8,16) size 784x115
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 758x36
+          text run at (0,0) width 758: "This tests that clicking in a contenteditable div will set the caret in the right position for RTL text in a RTL block. To test"
+          text run at (0,18) width 465: "manually, click the right of the text. The caret should be on the right edge."
+      RenderBlock {DIV} at (0,52) size 213x45 [border: (1px solid #000000)]
+        RenderText {#text} at (130,11) size 72x23
+          text run at (130,11) width 72 RTL: "\x{5E9}\x{5D3}\x{5D4} \x{5D1}\x{5D5}\x{5E8}"
+      RenderBlock (anonymous) at (0,97) size 784x18
+        RenderText {#text} at (0,0) size 39x18
+          text run at (0,0) width 39: "PASS"
+        RenderBR {BR} at (39,0) size 0x18
+caret: position 0 of child 0 {#text} of child 3 {DIV} of body
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2a8cf4e..32711cb 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,37 @@
+2010-12-08  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Dan Bernstein.
+
+        REGRESSION: LayoutTests/editing/selection/caret-rtl-2.html fails
+        https://bugs.webkit.org/show_bug.cgi?id=33503
+
+        The bug was caused by Font::offsetForPosition's not taking into account the containing block's text direction.
+        When RTL text appears in a LTR block, the offset at the beginning of RTL text is on the left of RTL text,
+        adn the offset at the end of RTL text is on the right of RTL text. For example, if we had RTL text CBA,
+        then the correspondance between letters and offsets in logical order are: A -> 0, B -> 1, and C -> 2.
+
+        Case 1. CBA appears in a RTL block:
+          In this case, clicking on the visual left of CBA puts the caret naturally at Position("CBA", 2).
+          Clicking on the visual right of CBA puts the caret at Position("CBA", 0) as expected.
+        Case 2. CBA appears in a LTR block:
+          Because the containing block flows from left to right, by covention, Position("CBA", 2") coresponds
+          to the visual right of CBA, and Position("CBA", 0) corresponds to the visual left of CBA.
+          Therefore, clicking on the visual left of CBA should put the caret at Positoin("CBA", 0),
+          and clicking on the visual right should put it at Position("CBA", 2).
+
+        The bug was caused by WebKit's not considering case 2. The same bug also existe for LTR text in a RTL block.
+        Fixed the bug by taking care of the case 2 in InlineTextBox::offsetForPosition.
+
+        Tests: editing/selection/caret-ltr-2-left.html
+               editing/selection/caret-ltr-2.html
+               editing/selection/caret-ltr-right.html
+               editing/selection/caret-ltr.html
+               editing/selection/caret-rtl-2-left.html
+               editing/selection/caret-rtl-right.html
+
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::offsetForPosition):
+
 2010-12-08  Anders Carlsson  <andersca at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/rendering/InlineTextBox.cpp b/WebCore/rendering/InlineTextBox.cpp
index 109597f..b77ee9e 100644
--- a/WebCore/rendering/InlineTextBox.cpp
+++ b/WebCore/rendering/InlineTextBox.cpp
@@ -1097,11 +1097,21 @@ int InlineTextBox::offsetForPosition(int lineOffset, bool includePartialGlyphs)
     if (isLineBreak())
         return 0;
 
+    int leftOffset = isLeftToRightDirection() ? 0 : m_len;
+    int rightOffset = isLeftToRightDirection() ? m_len : 0;
+    if (renderer()->containingBlock()->style()->isLeftToRightDirection() != isLeftToRightDirection())
+        swap(leftOffset, rightOffset);
+
+    if (lineOffset - logicalLeft() > logicalWidth())
+        return rightOffset;
+    if (lineOffset - logicalLeft() < 0)
+        return leftOffset;
+
     RenderText* text = toRenderText(renderer());
     RenderStyle* style = text->style(m_firstLine);
     const Font* f = &style->font();
     return f->offsetForPosition(TextRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered()),
-                                lineOffset - logicalLeft(), includePartialGlyphs);
+        lineOffset - logicalLeft(), includePartialGlyphs);
 }
 
 int InlineTextBox::positionForOffset(int offset) const

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list