WebCore:
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jul 2006 09:24:22 +0000 (09:24 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jul 2006 09:24:22 +0000 (09:24 +0000)
2006-07-18  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Darin.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=9695
        <rdar://problem/4614085>
        TOT REGRESSION: NativeTextArea: Text area does not respond to Cmd-UpArrow/Cmd-DownArrow (9695)

        * editing/SelectionController.cpp:
        (WebCore::SelectionController::modifyExtendingRightForward):
        (WebCore::SelectionController::modifyMovingRightForward):
        (WebCore::SelectionController::modifyExtendingLeftBackward):
        (WebCore::SelectionController::modifyMovingLeftBackward):
        If the caret is inside an editable region, the beginning/end of the document should actually be the
        beginning/end of the editable region.

LayoutTests:

2006-07-18  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Darin.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=9695
        <rdar://problem/4614085>
        TOT REGRESSION: NativeTextArea: Text area does not respond to Cmd-UpArrow/Cmd-DownArrow (9695)

        * editing/selection/move-begin-end-expected.txt: Added.
        * editing/selection/move-begin-end.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/editing/selection/move-begin-end-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/move-begin-end.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/SelectionController.cpp

index b31fcf4..febf4ff 100644 (file)
@@ -1,3 +1,14 @@
+2006-07-18  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Darin.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=9695
+        <rdar://problem/4614085> 
+        TOT REGRESSION: NativeTextArea: Text area does not respond to Cmd-UpArrow/Cmd-DownArrow (9695)
+        
+        * editing/selection/move-begin-end-expected.txt: Added.
+        * editing/selection/move-begin-end.html: Added.
+
 2006-07-17  Maciej Stachowiak  <mjs@apple.com>
 
         Test cases not reviewed but the corresponding fix was.
diff --git a/LayoutTests/editing/selection/move-begin-end-expected.txt b/LayoutTests/editing/selection/move-begin-end-expected.txt
new file mode 100644 (file)
index 0000000..b9a42d0
--- /dev/null
@@ -0,0 +1,16 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > DIV to 9 of #text > DIV toDOMRange:range from 8 of #text > DIV to 8 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > DIV to 8 of #text > DIV toDOMRange:range from 9 of #text > DIV to 9 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > DIV to 9 of #text > DIV toDOMRange:range from 0 of #text > DIV to 0 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of #text > DIV to 0 of #text > DIV toDOMRange:range from 0 of #text > DIV to 9 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of #text > DIV to 9 of #text > DIV toDOMRange:range from 9 of #text > DIV to 9 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > DIV to 9 of #text > DIV toDOMRange:range from 0 of #text > DIV to 9 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+This tests that moving the caret and selecting using Command+Left/Right arrows work correctly. If this text is successful, the text "SUCCESS" will be shown below.
+SUCCESS
+
diff --git a/LayoutTests/editing/selection/move-begin-end.html b/LayoutTests/editing/selection/move-begin-end.html
new file mode 100644 (file)
index 0000000..aa6c6cf
--- /dev/null
@@ -0,0 +1,58 @@
+<html>
+    <head>
+        <script>
+            function runTest() {
+                if (window.layoutTestController)
+                    layoutTestController.dumpAsText();
+                else {
+                    alert('This test must be run by DumpRenderTree!') 
+                    return;
+                }
+                
+                var area = document.getElementById('area');
+                area.focus();
+                
+                var sel = window.getSelection();
+                // Position the caret at the beginning of the string.
+                eventSender.keyDown(String.fromCharCode(0xf702));
+
+                // Now move to the end
+                eventSender.keyDown(String.fromCharCode(0xf703), ["metaKey"]);
+
+                if (sel.baseOffset != 9 || sel.extentOffset != 9)
+                    return;
+                
+                // Now move back to the beginning
+                eventSender.keyDown(String.fromCharCode(0xf702), ["metaKey"]);
+
+                if (sel.baseOffset != 0 || sel.extentOffset != 0)
+                    return;
+
+                // Now move to the end, selecting
+                eventSender.keyDown(String.fromCharCode(0xf703), ["metaKey", "shiftKey"]);
+
+                if (sel.baseOffset != 0 || sel.extentOffset != 9)
+                    return;
+
+                // Deselect but position the caret at the end                
+                eventSender.keyDown(String.fromCharCode(0xf703));
+                
+                if (sel.baseOffset != 9 || sel.extentOffset != 9)
+                    return;
+                
+                // Now move to the beginning, selecting
+                eventSender.keyDown(String.fromCharCode(0xf702), ["metaKey", "shiftKey"]);
+                
+                if (sel.baseOffset != 9 || sel.extentOffset != 0)
+                    return;
+                
+                document.getElementById('result').innerHTML = 'SUCCESS'
+            }
+        </script>
+    </head>
+    <body onload="runTest();">
+        <textarea id="area">Some text</textarea>
+        <div>This tests that moving the caret and selecting using Command+Left/Right arrows work correctly. If this text is successful, the text "SUCCESS" will be shown below.</div>
+        <div id="result">FAILURE</div>
+    </body>
+</html>
index 7dc3c0a..e24d823 100644 (file)
@@ -1,3 +1,19 @@
+2006-07-18  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Darin.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=9695
+        <rdar://problem/4614085> 
+        TOT REGRESSION: NativeTextArea: Text area does not respond to Cmd-UpArrow/Cmd-DownArrow (9695)
+        
+        * editing/SelectionController.cpp:
+        (WebCore::SelectionController::modifyExtendingRightForward):
+        (WebCore::SelectionController::modifyMovingRightForward):
+        (WebCore::SelectionController::modifyExtendingLeftBackward):
+        (WebCore::SelectionController::modifyMovingLeftBackward):
+        If the caret is inside an editable region, the beginning/end of the document should actually be the
+        beginning/end of the editable region.
+
 2006-07-17  Tim Omernick  <timo@apple.com>
 
         Reviewed by Maciej.
index 620be5f..6a306a9 100644 (file)
@@ -281,7 +281,11 @@ VisiblePosition SelectionController::modifyExtendingRightForward(TextGranularity
             pos = endOfParagraph(VisiblePosition(m_sel.end(), m_sel.affinity()));
             break;
         case DocumentBoundary:
-            pos = endOfDocument(pos);
+            pos = VisiblePosition(m_sel.end(), m_sel.affinity());
+            if (pos.deepEquivalent().node()->isContentEditable())
+                pos = endOfEditableContent(pos);
+            else
+                pos = endOfDocument(pos);
             break;
     }
     
@@ -326,8 +330,13 @@ VisiblePosition SelectionController::modifyMovingRightForward(TextGranularity gr
             pos = endOfParagraph(VisiblePosition(m_sel.end(), m_sel.affinity()));
             break;
         case DocumentBoundary:
-            pos = endOfDocument(VisiblePosition(m_sel.end(), m_sel.affinity()));
+            pos = VisiblePosition(m_sel.end(), m_sel.affinity());
+            if (pos.deepEquivalent().node()->isContentEditable())
+                pos = endOfEditableContent(pos);
+            else
+                pos = endOfDocument(pos);
             break;
+            
     }
     return pos;
 }
@@ -372,7 +381,11 @@ VisiblePosition SelectionController::modifyExtendingLeftBackward(TextGranularity
             pos = startOfParagraph(VisiblePosition(m_sel.start(), m_sel.affinity()));
             break;
         case DocumentBoundary:
-            pos = startOfDocument(pos);
+            pos = VisiblePosition(m_sel.start(), m_sel.affinity());
+            if (pos.deepEquivalent().node()->isContentEditable())
+                pos = startOfEditableContent(pos);
+            else 
+                pos = startOfDocument(VisiblePosition(m_sel.start(), m_sel.affinity()));
             break;
     }
     return pos;
@@ -411,7 +424,11 @@ VisiblePosition SelectionController::modifyMovingLeftBackward(TextGranularity gr
             pos = startOfParagraph(VisiblePosition(m_sel.start(), m_sel.affinity()));
             break;
         case DocumentBoundary:
-            pos = startOfDocument(VisiblePosition(m_sel.start(), m_sel.affinity()));
+            pos = VisiblePosition(m_sel.start(), m_sel.affinity());
+            if (pos.deepEquivalent().node()->isContentEditable())
+                pos = startOfEditableContent(pos);
+            else 
+                pos = startOfDocument(VisiblePosition(m_sel.start(), m_sel.affinity()));
             break;
     }
     return pos;