LayoutTests:
authorddkilzer <ddkilzer@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jul 2006 10:55:32 +0000 (10:55 +0000)
committerddkilzer <ddkilzer@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jul 2006 10:55:32 +0000 (10:55 +0000)
        Reviewed by Justin.  Patch by Mitz.

        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=9978
          REGRESSION (r12949-r12988): Clicking the first letter on a line places the caret at the end of the previous line

        * editing/selection/click-start-of-line-expected.checksum: Added.
        * editing/selection/click-start-of-line-expected.png: Added.
        * editing/selection/click-start-of-line-expected.txt: Added.
        * editing/selection/click-start-of-line.html: Added.

WebCore:

        Reviewed by Justin.  Patch by Mitz.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9978
          REGRESSION (r12949-r12988): Clicking the first letter on a line places the caret at the end of the previous line

        Test: editing/selection/click-start-of-line.html

        * rendering/RenderText.cpp:
        (WebCore::RenderText::positionForCoordinates): Changed to return downstream
        affinity if the x coordinate is to the left of the middle of the first character
        in the text box.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15500 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/selection/click-start-of-line-expected.checksum [new file with mode: 0644]
LayoutTests/editing/selection/click-start-of-line-expected.png [new file with mode: 0644]
LayoutTests/editing/selection/click-start-of-line-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/click-start-of-line.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderText.cpp

index febf4ffdd9018fec53fccd11480f4473476289a9..194aaa6e93fb6aaa4b519481d17f9c427c0c6444 100644 (file)
@@ -1,3 +1,15 @@
+2006-07-18  Mitz Pettel  <opendarwin.org@mitzpettel.com>
+
+        Reviewed by Justin.
+
+        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=9978
+          REGRESSION (r12949-r12988): Clicking the first letter on a line places the caret at the end of the previous line
+
+        * editing/selection/click-start-of-line-expected.checksum: Added.
+        * editing/selection/click-start-of-line-expected.png: Added.
+        * editing/selection/click-start-of-line-expected.txt: Added.
+        * editing/selection/click-start-of-line.html: Added.
+
 2006-07-18  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Darin.
diff --git a/LayoutTests/editing/selection/click-start-of-line-expected.checksum b/LayoutTests/editing/selection/click-start-of-line-expected.checksum
new file mode 100644 (file)
index 0000000..2ff9d26
--- /dev/null
@@ -0,0 +1 @@
+0ae1bf3a2dafe9015ad3af924968faac
\ No newline at end of file
diff --git a/LayoutTests/editing/selection/click-start-of-line-expected.png b/LayoutTests/editing/selection/click-start-of-line-expected.png
new file mode 100644 (file)
index 0000000..1d74fb4
Binary files /dev/null and b/LayoutTests/editing/selection/click-start-of-line-expected.png differ
diff --git a/LayoutTests/editing/selection/click-start-of-line-expected.txt b/LayoutTests/editing/selection/click-start-of-line-expected.txt
new file mode 100644 (file)
index 0000000..d07d972
--- /dev/null
@@ -0,0 +1,32 @@
+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 10 of #text > DIV > BODY > HTML > #document to 10 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 784x584
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 104x18
+          text run at (0,0) width 104: "This is a test for "
+        RenderInline {I} at (0,0) size 776x36
+          RenderInline {A} at (0,0) size 348x18 [color=#0000EE]
+            RenderText {#text} at (104,0) size 348x18
+              text run at (104,0) width 348: "http://bugzilla.opendarwin.org/show_bug.cgi?id=9978"
+          RenderText {#text} at (452,0) size 776x36
+            text run at (452,0) width 4: " "
+            text run at (456,0) width 320: "REGRESSION (r12949-r12988): Clicking the first"
+            text run at (0,18) width 384: "letter on a line places the caret at the end of the previous line"
+        RenderText {#text} at (384,18) size 4x18
+          text run at (384,18) width 4: "."
+      RenderBlock {P} at (0,52) size 784x18
+        RenderText {#text} at (0,0) size 730x18
+          text run at (0,0) width 551: "To test interactively, click the left side of the W on the second line. The caret should be "
+          text run at (551,0) width 179: "move to the start of that line."
+      RenderBlock {HR} at (0,86) size 784x2 [border: (1px inset #000000)]
+      RenderBlock {DIV} at (0,96) size 250x110
+        RenderText {#text} at (0,0) size 236x110
+          text run at (0,0) width 164: "Alice in "
+          text run at (0,55) width 236: "Wonderland"
+caret: position 10 of child 0 {#text} of child 7 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/selection/click-start-of-line.html b/LayoutTests/editing/selection/click-start-of-line.html
new file mode 100644 (file)
index 0000000..652601c
--- /dev/null
@@ -0,0 +1,35 @@
+<html> 
+<head>
+
+<script>
+
+function editingTest() {
+    var target = document.getElementById("test");
+    
+    x = target.offsetLeft + 10;
+    y = target.offsetTop + target.offsetHeight - 10;
+    
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+</script>
+</head>
+<body>
+<p>
+    This is a test for <i><a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=9978">http://bugzilla.opendarwin.org/show_bug.cgi?id=9978</a>
+    REGRESSION (r12949-r12988): Clicking the first letter on a line places the caret at the end of the previous line</i>.
+</p>
+<p>
+    To test interactively, click the left side of the W on the second line. The caret should be
+    move to the start of that line.
+</p>
+<hr>
+<div contenteditable id="test" style="font-size: 48; width: 250px;">
+Alice in Wonderland
+</div>
+<script>
+editingTest();
+</script>
+</html>
index e24d823734e9d9ec892f0b0b86e6be2c086f2e55..9265543e3478bcaf45654940a36972cd6e3aab5c 100644 (file)
@@ -1,3 +1,17 @@
+2006-07-18  Mitz Pettel  <opendarwin.org@mitzpettel.com>
+
+        Reviewed by Justin.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9978
+          REGRESSION (r12949-r12988): Clicking the first letter on a line places the caret at the end of the previous line
+
+        Test: editing/selection/click-start-of-line.html
+
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::positionForCoordinates): Changed to return downstream
+        affinity if the x coordinate is to the left of the middle of the first character
+        in the text box.
+
 2006-07-18  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Darin.
index 692c90ba3a076058038e1afeb7b5f230f812c7aa..806f0bb8ef3edfb80f646f795b3f5359f916353a 100644 (file)
@@ -287,7 +287,7 @@ VisiblePosition RenderText::positionForCoordinates(int _x, int _y)
             if (_x < absx + box->m_x + box->m_width)
                 // and the x coordinate is to the left of the right edge of this box
                 // check to see if position goes in this box
-                return VisiblePosition(element(), offset + box->m_start, VP_UPSTREAM_IF_POSSIBLE);
+                return VisiblePosition(element(), offset + box->m_start, offset > 0 ? VP_UPSTREAM_IF_POSSIBLE : DOWNSTREAM);
 
             if (!box->prevOnLine() && _x < absx + box->m_x)
                 // box is first on line