LayoutTests:
authoradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Jul 2006 02:24:06 +0000 (02:24 +0000)
committeradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Jul 2006 02:24:06 +0000 (02:24 +0000)
        Reviewed by Darin.

        Test for: <rdar://problem/4643238> REGRESSION: Can't set insertion point at the end of a line of text

        * fast/forms/textarea-scrolled-endline-caret-expected.txt: Added.
        * fast/forms/textarea-scrolled-endline-caret.html: Added.

WebCore:

        Reviewed by Darin.

        Fix for: <rdar://problem/4643238> REGRESSION: Can't set insertion point at the end of a line of text

        Test: fast/forms/textarea-scrolled-endline-caret.html

        * rendering/RenderBlock.cpp: (WebCore::RenderBlock::positionForCoordinates):
        When looking for the closest line box, take the scroll offset into account.

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

LayoutTests/ChangeLog
LayoutTests/fast/forms/textarea-scrolled-endline-caret-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/textarea-scrolled-endline-caret.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderBlock.cpp

index 0e5d7b27347cd65d7a233a24bbdbea1a3d94a71f..b36fcadb0769bc7cde91d1ef735213184b6956e9 100644 (file)
@@ -1,3 +1,12 @@
+2006-07-21  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Darin.
+
+        Test for: <rdar://problem/4643238> REGRESSION: Can't set insertion point at the end of a line of text
+
+        * fast/forms/textarea-scrolled-endline-caret-expected.txt: Added.
+        * fast/forms/textarea-scrolled-endline-caret.html: Added.
+
 2006-07-21  Geoffrey Garen  <ggaren@apple.com>
 
         RS by Adele.
diff --git a/LayoutTests/fast/forms/textarea-scrolled-endline-caret-expected.txt b/LayoutTests/fast/forms/textarea-scrolled-endline-caret-expected.txt
new file mode 100644 (file)
index 0000000..ee06033
--- /dev/null
@@ -0,0 +1,4 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of #text > DIV to 2 of #text > DIV toDOMRange:range from 1 of #text > DIV to 1 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+Test Succeeded
diff --git a/LayoutTests/fast/forms/textarea-scrolled-endline-caret.html b/LayoutTests/fast/forms/textarea-scrolled-endline-caret.html
new file mode 100644 (file)
index 0000000..9beb219
--- /dev/null
@@ -0,0 +1,35 @@
+<head>
+<script>
+function test()
+{
+    var ta = document.getElementById('ta')
+    ta.focus();
+    // click
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        eventSender.mouseMoveTo(90, 20);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+    }
+    var res = document.getElementById('res');
+    if (ta.selectionEnd == 17)
+        res.innerHTML = "Test Succeeded";
+    else
+        res.innerHTML = "Test Failed: caret is at " + ta.selectionEnd;
+}
+</script>
+</head>
+<body onload="test()">
+<textarea id="ta">
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+</textarea>
+<div id="res"></div>
\ No newline at end of file
index a3f0a8099490422f69ca8369ebf5595868445892..e38fc34ff08d510366bbabf20effaa37ed424eb4 100644 (file)
@@ -1,3 +1,14 @@
+2006-07-21  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Darin.
+
+        Fix for: <rdar://problem/4643238> REGRESSION: Can't set insertion point at the end of a line of text
+
+        Test: fast/forms/textarea-scrolled-endline-caret.html
+
+        * rendering/RenderBlock.cpp: (WebCore::RenderBlock::positionForCoordinates):
+        When looking for the closest line box, take the scroll offset into account.
+
 2006-07-21  Tim Omernick  <timo@apple.com>
 
         Reviewed by Geoff & Maciej.
index 19f6783873bb7fca527c113770a3536a05e16ef9..a3577b4f40c528fb9f9e5cca89b80edafb62b3e4 100644 (file)
@@ -2664,24 +2664,29 @@ VisiblePosition RenderBlock::positionForCoordinates(int x, int y)
         if (!firstRootBox())
             return VisiblePosition(n, 0, DOWNSTREAM);
             
-        if (y >= top && y < absy + firstRootBox()->topOverflow())
+        int contentsX = absx;
+        int contentsY = absy;
+        if (hasOverflowClip())
+            layer()->subtractScrollOffset(contentsX, contentsY); 
+
+        if (y >= top && y < contentsY + firstRootBox()->topOverflow())
             // y coordinate is above first root line box
             return VisiblePosition(positionForBox(firstRootBox()->firstLeafChild(), true), DOWNSTREAM);
         
         // look for the closest line box in the root box which is at the passed-in y coordinate
         for (RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox()) {
-            top = absy + root->topOverflow();
+            top = contentsY + root->topOverflow();
             // set the bottom based on whether there is a next root box
             if (root->nextRootBox())
-                bottom = absy + root->nextRootBox()->topOverflow();
+                bottom = contentsY + root->nextRootBox()->topOverflow();
             else
-                bottom = absy + root->bottomOverflow();
+                bottom = contentsY + root->bottomOverflow();
             // check if this root line box is located at this y coordinate
             if (y >= top && y < bottom && root->firstChild()) {
-                InlineBox* closestBox = root->closestLeafChildForXPos(x, absx);
+                InlineBox* closestBox = root->closestLeafChildForXPos(x, contentsX);
                 if (closestBox)
                     // pass the box a y position that is inside it
-                    return closestBox->object()->positionForCoordinates(x, absy + closestBox->m_y);
+                    return closestBox->object()->positionForCoordinates(x, contentsY + closestBox->m_y);
             }
         }