2007-08-25 Mitz Pettel <mitz@webkit.org>
authorbdash <bdash@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Aug 2007 12:26:19 +0000 (12:26 +0000)
committerbdash <bdash@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Aug 2007 12:26:19 +0000 (12:26 +0000)
        Reviewed by Dave Hyatt.

        - fix http://bugs.webkit.org/show_bug.cgi?id=14972
          Moving cursor down in contentEditable section fails if styled line-height:1em

        Test: editing/selection/move-by-line-003.html

        * rendering/RenderText.cpp:
        (WebCore::RenderText::positionForCoordinates): Changed hit testing so that each
        line is tested for hits between its overflow top and the next line's overflow top.
        This matches RenderBlock::positionForCoordinates.

2007-08-25  Mitz Pettel  <mitz@webkit.org>

        Reviewed by Dave Hyatt.

        - test for http://bugs.webkit.org/show_bug.cgi?id=14972
          Moving cursor down in contentEditable section fails if styled line-height:1em

        * editing/selection/move-by-line-003-expected.txt: Added.
        * editing/selection/move-by-line-003.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/editing/selection/move-by-line-003-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/move-by-line-003.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderText.cpp

index 7ce2a583e9c90ec97ba97d98c26ec04ef0c38761..fa356ccc717780ef12c7b8a900671077411accb7 100644 (file)
@@ -1,3 +1,13 @@
+2007-08-25  Mitz Pettel  <mitz@webkit.org>
+
+        Reviewed by Dave Hyatt.
+
+        - test for http://bugs.webkit.org/show_bug.cgi?id=14972
+          Moving cursor down in contentEditable section fails if styled line-height:1em
+
+        * editing/selection/move-by-line-003-expected.txt: Added.
+        * editing/selection/move-by-line-003.html: Added.
+
 2007-08-25  Mitz Pettel  <mitz@webkit.org>
 
         Reviewed by Justin.
diff --git a/LayoutTests/editing/selection/move-by-line-003-expected.txt b/LayoutTests/editing/selection/move-by-line-003-expected.txt
new file mode 100644 (file)
index 0000000..fa1c4c5
--- /dev/null
@@ -0,0 +1,5 @@
+Test for http://bugs.webkit.org/show_bug.cgi?id=14972 Moving cursor down in contentEditable section fails if styled line-height:1em.
+
+PASS
+
+Pressing the down arrow when the caret is on this line should move it to this line. 
diff --git a/LayoutTests/editing/selection/move-by-line-003.html b/LayoutTests/editing/selection/move-by-line-003.html
new file mode 100644 (file)
index 0000000..55788b4
--- /dev/null
@@ -0,0 +1,30 @@
+<html>
+<head>
+    <script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+    <script>
+        function test()
+        {
+            if (window.layoutTestController)
+                layoutTestController.dumpAsText();
+
+            var target = document.getElementById("target");
+            getSelection().setBaseAndExtent(target.firstChild, 0, target.frstChild, 0);
+            moveSelectionForwardByLineCommand();
+
+            document.getElementById("result").innerText = getSelection().baseOffset == 63 ? "PASS" : "FAIL";
+        }
+    </script>
+</head>
+<body onload="test()">
+    <p>
+        Test for <i><a href="http://bugs.webkit.org/show_bug.cgi?id=14972">http://bugs.webkit.org/show_bug.cgi?id=14972</a>
+        Moving cursor down in contentEditable section fails if styled line-height:1em</i>.
+    </p>
+    <p id="result">
+        Test did not run
+    </p>
+    <p contenteditable="true" id="target" style="white-space: pre-line; line-height: 1em;">Pressing the down arrow when the caret is on this line
+        should move it to this line.
+    </p>
+</body>
+</html>
index a8dcd5ef7687a5ec7d857b8d2826a58c62db4a87..2a30bfcc39a46c7987e15ca943faa1a313a2bbda 100644 (file)
@@ -1,3 +1,17 @@
+2007-08-25  Mitz Pettel  <mitz@webkit.org>
+
+        Reviewed by Dave Hyatt.
+
+        - fix http://bugs.webkit.org/show_bug.cgi?id=14972
+          Moving cursor down in contentEditable section fails if styled line-height:1em
+
+        Test: editing/selection/move-by-line-003.html
+
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::positionForCoordinates): Changed hit testing so that each
+        line is tested for hits between its overflow top and the next line's overflow top.
+        This matches RenderBlock::positionForCoordinates.
+
 2007-08-25  Mitz Pettel  <mitz@webkit.org>
 
         Reviewed by Justin.
index 422166d76d11f81b1995fb0b30084b08f8348579..6d90dd87302db80ae65d508c12051b46bc0a34a6 100644 (file)
@@ -265,7 +265,8 @@ VisiblePosition RenderText::positionForCoordinates(int x, int y)
     InlineTextBox* lastBoxAbove = 0;
     for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
         if (y >= box->root()->topOverflow()) {
-            if (y < box->root()->bottomOverflow()) {
+            int bottom = box->root()->nextRootBox() ? box->root()->nextRootBox()->topOverflow() : box->root()->bottomOverflow();
+            if (y < bottom) {
                 offset = box->offsetForPosition(x);
 
                 if (x == box->m_x)