Reviewed by Chris
authorkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Aug 2004 23:58:03 +0000 (23:58 +0000)
committerkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Aug 2004 23:58:03 +0000 (23:58 +0000)
        Fix for this bug:

        <rdar://problem/3761014> command-down-arrow takes you to start of document instead of end of document

        * khtml/xml/dom_selection.cpp:
        (DOM::Selection::modifyExtendingRightForward): Code used to assume, incorrectly, that index 1 of the
        document element was beyond the last node in the document. But this is not true, since the document
        element is the HTML element (generally). Instead, move to the index equal to the number of children
        of the document element. This puts us past everything.
        (DOM::Selection::modifyMovingRightForward): Ditto.

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

WebCore/ChangeLog-2005-08-23
WebCore/khtml/editing/SelectionController.cpp
WebCore/khtml/editing/selection.cpp
WebCore/khtml/xml/dom_selection.cpp

index 707b5d8a20eaec904f22cca45ecbb21d78dbae08..e03062e8577ac9b14ec8b07fa5589cbc447d9bac 100644 (file)
@@ -1,3 +1,18 @@
+2004-08-12  Ken Kocienda  <kocienda@apple.com>
+
+        Reviewed by Chris
+
+        Fix for this bug:
+        
+        <rdar://problem/3761014> command-down-arrow takes you to start of document instead of end of document
+
+        * khtml/xml/dom_selection.cpp:
+        (DOM::Selection::modifyExtendingRightForward): Code used to assume, incorrectly, that index 1 of the
+        document element was beyond the last node in the document. But this is not true, since the document
+        element is the HTML element (generally). Instead, move to the index equal to the number of children
+        of the document element. This puts us past everything.
+        (DOM::Selection::modifyMovingRightForward): Ditto.
+
 2004-08-12  Ken Kocienda  <kocienda@apple.com>
 
         Reviewed by Trey
index 72360928b655600c5315d8e6fa244a8c38d6f6d7..47d135a495f498c6c2cc5c3032295eb2a3d1a6f3 100644 (file)
@@ -214,9 +214,11 @@ Position Selection::modifyExtendingRightForward(ETextGranularity granularity)
         case PARAGRAPH:
             // not implemented
             break;
-        case DOCUMENT:
-            pos = Position(start().node()->getDocument()->documentElement(), 1);
+        case DOCUMENT: {
+            ElementImpl *elem = start().node()->getDocument()->documentElement();
+            pos = Position(elem, elem->childNodeCount());
             break;
+        }
         case LINE_BOUNDARY: {
             Selection selection;
             startAndEndLineNodesIncludingNode(end().node(), end().offset(), selection);
@@ -247,9 +249,11 @@ Position Selection::modifyMovingRightForward(ETextGranularity granularity)
         case PARAGRAPH:
             // not implemented
             break;
-        case DOCUMENT:
-            pos = Position(start().node()->getDocument()->documentElement(), 1);
+        case DOCUMENT: {
+            ElementImpl *elem = start().node()->getDocument()->documentElement();
+            pos = Position(elem, elem->childNodeCount());
             break;
+        }
         case LINE_BOUNDARY: {
             Selection selection;
             startAndEndLineNodesIncludingNode(end().node(), end().offset(), selection);
index 72360928b655600c5315d8e6fa244a8c38d6f6d7..47d135a495f498c6c2cc5c3032295eb2a3d1a6f3 100644 (file)
@@ -214,9 +214,11 @@ Position Selection::modifyExtendingRightForward(ETextGranularity granularity)
         case PARAGRAPH:
             // not implemented
             break;
-        case DOCUMENT:
-            pos = Position(start().node()->getDocument()->documentElement(), 1);
+        case DOCUMENT: {
+            ElementImpl *elem = start().node()->getDocument()->documentElement();
+            pos = Position(elem, elem->childNodeCount());
             break;
+        }
         case LINE_BOUNDARY: {
             Selection selection;
             startAndEndLineNodesIncludingNode(end().node(), end().offset(), selection);
@@ -247,9 +249,11 @@ Position Selection::modifyMovingRightForward(ETextGranularity granularity)
         case PARAGRAPH:
             // not implemented
             break;
-        case DOCUMENT:
-            pos = Position(start().node()->getDocument()->documentElement(), 1);
+        case DOCUMENT: {
+            ElementImpl *elem = start().node()->getDocument()->documentElement();
+            pos = Position(elem, elem->childNodeCount());
             break;
+        }
         case LINE_BOUNDARY: {
             Selection selection;
             startAndEndLineNodesIncludingNode(end().node(), end().offset(), selection);
index 72360928b655600c5315d8e6fa244a8c38d6f6d7..47d135a495f498c6c2cc5c3032295eb2a3d1a6f3 100644 (file)
@@ -214,9 +214,11 @@ Position Selection::modifyExtendingRightForward(ETextGranularity granularity)
         case PARAGRAPH:
             // not implemented
             break;
-        case DOCUMENT:
-            pos = Position(start().node()->getDocument()->documentElement(), 1);
+        case DOCUMENT: {
+            ElementImpl *elem = start().node()->getDocument()->documentElement();
+            pos = Position(elem, elem->childNodeCount());
             break;
+        }
         case LINE_BOUNDARY: {
             Selection selection;
             startAndEndLineNodesIncludingNode(end().node(), end().offset(), selection);
@@ -247,9 +249,11 @@ Position Selection::modifyMovingRightForward(ETextGranularity granularity)
         case PARAGRAPH:
             // not implemented
             break;
-        case DOCUMENT:
-            pos = Position(start().node()->getDocument()->documentElement(), 1);
+        case DOCUMENT: {
+            ElementImpl *elem = start().node()->getDocument()->documentElement();
+            pos = Position(elem, elem->childNodeCount());
             break;
+        }
         case LINE_BOUNDARY: {
             Selection selection;
             startAndEndLineNodesIncludingNode(end().node(), end().offset(), selection);