LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2006 19:43:03 +0000 (19:43 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2006 19:43:03 +0000 (19:43 +0000)
        Reviewed by harrison

        Added:
        * editing/selection/skip-non-editable-1-expected.txt: Added.
        * editing/selection/skip-non-editable-1.html: Added.
        * editing/selection/skip-non-editable-2-expected.txt: Added.
        * editing/selection/skip-non-editable-2.html: Added.

        Equivalent render tree:
        * editing/execCommand/format-block-with-braces-expected.txt:

        Fixes:
        * editing/selection/iframe-expected.checksum:
        * editing/selection/iframe-expected.png:
        * editing/selection/iframe-expected.txt:
        * editing/selection/inline-table-expected.checksum:
        * editing/selection/inline-table-expected.png:
        * editing/selection/inline-table-expected.txt:
        * editing/selection/move-between-blocks-no-001-expected.checksum:
        * editing/selection/move-between-blocks-no-001-expected.png:
        * editing/selection/move-between-blocks-no-001-expected.txt:
        * editing/selection/select-box-expected.checksum:
        * editing/selection/select-box-expected.png:
        * editing/selection/select-box-expected.txt:

WebCore:

        Reviewed by harrison

        <rdar://problem/4598309
        Caret gets stuck when it hits non editable content within an editable body
        <http://bugzilla.opendarwin.org/show_bug.cgi?id=9510>
        Caret will jump out of an editable region

        * dom/Position.cpp:
        (WebCore::Position::upstream): Don't move into a new editable region so that
        candidates that that straddle an editable/non-editable boundary will
        correspond to different VisiblePositions.
        (WebCore::Position::downstream): Ditto.
        * editing/SelectionController.cpp:
        (WebCore::SelectionController::modifyMovingRightForward): Use VisiblePosition::next(true)
        (WebCore::SelectionController::modifyMovingLeftBackward): Use VisiblePosition::previous(true)
        * editing/VisiblePosition.cpp:
        (WebCore::VisiblePosition::next): Added code to jump to the next editable region as long
        as it has the same highest editable root.
        (WebCore::VisiblePosition::previous): Ditto.
        * editing/VisiblePosition.h:
        * editing/htmlediting.cpp:
        (WebCore::highestEditableRoot): Added, returns the highest editable root of a node if that
        node is in editable content, otherwise 0.
        * editing/htmlediting.h:

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

26 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/execCommand/format-block-with-braces-expected.txt
LayoutTests/editing/selection/iframe-expected.checksum
LayoutTests/editing/selection/iframe-expected.png
LayoutTests/editing/selection/iframe-expected.txt
LayoutTests/editing/selection/inline-table-expected.checksum
LayoutTests/editing/selection/inline-table-expected.png
LayoutTests/editing/selection/inline-table-expected.txt
LayoutTests/editing/selection/move-between-blocks-no-001-expected.checksum
LayoutTests/editing/selection/move-between-blocks-no-001-expected.png
LayoutTests/editing/selection/move-between-blocks-no-001-expected.txt
LayoutTests/editing/selection/select-box-expected.checksum
LayoutTests/editing/selection/select-box-expected.png
LayoutTests/editing/selection/select-box-expected.txt
LayoutTests/editing/selection/skip-non-editable-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/skip-non-editable-1.html [new file with mode: 0644]
LayoutTests/editing/selection/skip-non-editable-2-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/skip-non-editable-2.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/dom/Position.cpp
WebCore/editing/SelectionController.cpp
WebCore/editing/VisiblePosition.cpp
WebCore/editing/VisiblePosition.h
WebCore/editing/htmlediting.cpp
WebCore/editing/htmlediting.h

index e843d71c6c977d6156109b11e40ab30492d37b09..9a11cdd58b92b6ba8db419a9d48da12e6d814ff8 100644 (file)
@@ -1,3 +1,30 @@
+2006-06-30  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by harrison
+        
+        Added:
+        * editing/selection/skip-non-editable-1-expected.txt: Added.
+        * editing/selection/skip-non-editable-1.html: Added.
+        * editing/selection/skip-non-editable-2-expected.txt: Added.
+        * editing/selection/skip-non-editable-2.html: Added.
+
+        Equivalent render tree:
+        * editing/execCommand/format-block-with-braces-expected.txt:
+        
+        Fixes:
+        * editing/selection/iframe-expected.checksum:
+        * editing/selection/iframe-expected.png:
+        * editing/selection/iframe-expected.txt:
+        * editing/selection/inline-table-expected.checksum:
+        * editing/selection/inline-table-expected.png:
+        * editing/selection/inline-table-expected.txt:
+        * editing/selection/move-between-blocks-no-001-expected.checksum:
+        * editing/selection/move-between-blocks-no-001-expected.png:
+        * editing/selection/move-between-blocks-no-001-expected.txt:
+        * editing/selection/select-box-expected.checksum:
+        * editing/selection/select-box-expected.png:
+        * editing/selection/select-box-expected.txt:
+
 2006-06-30  David Kilzer  <ddkilzer@kilzer.net>
 
         Reviewed by Darin.
index d99caa7b301ed67caa6e462615dd5586af7d28f4..06f5aec5cfa7a6251d373ebe59100fa992cbbf87 100644 (file)
@@ -22,4 +22,5 @@ layer at (0,0) size 800x600
               text run at (0,0) width 156: "Format Me"
       RenderBlock (anonymous) at (0,115) size 784x0
         RenderInline {DIV} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
 caret: position 0 of child 0 {#text} of child 0 {DIV} of child 0 {H1} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
index 0fe4fc42a2646bcbb87e4edf18dc5d0da9c0902f..3ff054a490821c763869201d336c8c8801176c23 100644 (file)
@@ -1 +1 @@
-869fa4c8c0258388b1acb0f5ec1e356a
\ No newline at end of file
+6950bf936f869b9c32342977c0ef82ee
\ No newline at end of file
index f0b248b2a682b484dc5247f82760a45c2f860b95..7261feafa82a50c8e8652a59e8f39cd656528fb6 100644 (file)
Binary files a/LayoutTests/editing/selection/iframe-expected.png and b/LayoutTests/editing/selection/iframe-expected.png differ
index df7ec3165b136f0a712bc9a16c5687198a1c0591..983d43b65cd4232829c546607d23ae23c84c6300 100644 (file)
@@ -182,36 +182,6 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 800x600
@@ -281,4 +251,4 @@ layer at (0,0) size 800x600
                         text run at (212,62) width 67: "The End..."
           RenderText {#text} at (450,188) size 66x18
             text run at (450,188) width 66: " the end ..."
-caret: position 127 of child 0 {#text} of child 1 {P} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 1 of child 0 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index 8590a0331444aad401dbd3eaf20b73dde7e8e74e..f81d22cce11aaae4fcca3a9f233ee790eee3c80e 100644 (file)
@@ -1 +1 @@
-ef501de743d6e9546b6bf6b2fa0de46f
\ No newline at end of file
+864af36d8ec3cff54652542133dcb86d
\ No newline at end of file
index 97b27e22d2f9f3e18288b8cb69196bb05c29eb94..a02289e02ec2fb90bb3e46d6162ac70c9ad7b13f 100644 (file)
Binary files a/LayoutTests/editing/selection/inline-table-expected.png and b/LayoutTests/editing/selection/inline-table-expected.png differ
index a28c78758486ee2004365cb0482a23ed2d234b53..eb8fe588b3c6c5d674f46b3938534d08e49d1880 100644 (file)
@@ -139,7 +139,6 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 800x600
@@ -190,4 +189,4 @@ layer at (0,0) size 800x600
                     text run at (2,2) width 31: "Nine"
           RenderText {#text} at (212,62) size 67x18
             text run at (212,62) width 67: "The End..."
-caret: position 266 of child 0 {#text} of child 1 {P} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 1 of child 0 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index 6556cda195e04fc49545fe5d2e390c5ab5f70bed..8160453d3f0dcaf6ed531e36a2c302ed4555f8e9 100644 (file)
@@ -1 +1 @@
-493bb88b937eeb7a0ae543fc0bc47552
\ No newline at end of file
+b6d919f37e95762718c1cdc6fabd99f8
\ No newline at end of file
index 8f047ff2bb6a81cf29b492c191e213c874b67f26..290ad4185f64e9bcf93d98f022aac172350f284b 100644 (file)
Binary files a/LayoutTests/editing/selection/move-between-blocks-no-001-expected.png and b/LayoutTests/editing/selection/move-between-blocks-no-001-expected.png differ
index b9cbf6ede80365777e13ccf0546ff5ebcfa4c8da..2d122787f114f3c7e1f8ea823ae18f63b59a7936 100644 (file)
@@ -41,58 +41,50 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldEndEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
-EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
-EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 10 of #text > DIV > BODY > HTML > #document to 10 of #text > DIV > BODY > HTML > #document toDOMRange:range from 9 of #text > DIV > BODY > HTML > #document to 9 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 39 of #text > SPAN > DIV > BODY > HTML > #document to 39 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 39 of #text > SPAN > DIV > BODY > HTML > #document to 39 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > DIV > BODY > HTML > #document to 9 of #text > DIV > BODY > HTML > #document toDOMRange:range from 8 of #text > DIV > BODY > HTML > #document to 8 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 38 of #text > SPAN > DIV > BODY > HTML > #document to 38 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 38 of #text > SPAN > DIV > BODY > HTML > #document to 38 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > DIV > BODY > HTML > #document to 8 of #text > DIV > BODY > HTML > #document toDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 7 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 37 of #text > SPAN > DIV > BODY > HTML > #document to 37 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 37 of #text > SPAN > DIV > BODY > HTML > #document to 37 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 7 of #text > DIV > BODY > HTML > #document toDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 36 of #text > SPAN > DIV > BODY > HTML > #document to 36 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 36 of #text > SPAN > DIV > BODY > HTML > #document to 36 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document toDOMRange:range from 5 of #text > DIV > BODY > HTML > #document to 5 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 35 of #text > SPAN > DIV > BODY > HTML > #document to 35 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 35 of #text > SPAN > DIV > BODY > HTML > #document to 35 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text > DIV > BODY > HTML > #document to 5 of #text > DIV > BODY > HTML > #document toDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 34 of #text > SPAN > DIV > BODY > HTML > #document to 34 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 34 of #text > SPAN > DIV > BODY > HTML > #document to 34 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document toDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 33 of #text > SPAN > DIV > BODY > HTML > #document to 33 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 33 of #text > SPAN > DIV > BODY > HTML > #document to 33 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document toDOMRange:range from 2 of #text > DIV > BODY > HTML > #document to 2 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 32 of #text > SPAN > DIV > BODY > HTML > #document to 32 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 32 of #text > SPAN > DIV > BODY > HTML > #document to 32 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of #text > DIV > BODY > HTML > #document to 2 of #text > DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 31 of #text > SPAN > DIV > BODY > HTML > #document to 31 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 31 of #text > SPAN > DIV > BODY > HTML > #document to 31 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 30 of #text > SPAN > DIV > BODY > HTML > #document to 30 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 30 of #text > SPAN > DIV > BODY > HTML > #document to 30 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 29 of #text > SPAN > DIV > BODY > HTML > #document to 29 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 29 of #text > SPAN > DIV > BODY > HTML > #document to 29 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 28 of #text > SPAN > DIV > BODY > HTML > #document to 28 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 28 of #text > SPAN > DIV > BODY > HTML > #document to 28 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 27 of #text > SPAN > DIV > BODY > HTML > #document to 27 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 27 of #text > SPAN > DIV > BODY > HTML > #document to 27 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 26 of #text > SPAN > DIV > BODY > HTML > #document to 26 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 26 of #text > SPAN > DIV > BODY > HTML > #document to 26 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 25 of #text > SPAN > DIV > BODY > HTML > #document to 25 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 25 of #text > SPAN > DIV > BODY > HTML > #document to 25 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
@@ -100,11 +92,10 @@ layer at (0,0) size 800x600
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
       RenderBlock {DIV} at (0,0) size 784x56 [border: (2px solid #FF0000)]
-        RenderInline {SPAN} at (0,0) size 381x28
-          RenderText {#text} at (14,14) size 381x28
-            text run at (14,14) width 381: "We hold these truths to be self-evident,"
-        RenderText {#text} at (0,0) size 0x0
+        RenderInline {SPAN} at (0,0) size 243x28
+          RenderText {#text} at (14,14) size 243x28
+            text run at (14,14) width 243: "We hold these truths to b"
       RenderBlock {DIV} at (0,56) size 784x56 [border: (2px solid #FF0000)]
-        RenderText {#text} at (14,14) size 244x28
-          text run at (14,14) width 244: "men are created equal, ..."
-caret: position 0 of child 0 {#text} of child 4 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+        RenderText {#text} at (14,14) size 318x28
+          text run at (14,14) width 318: "that all men are created equal, ..."
+caret: position 25 of child 0 {#text} of child 1 {SPAN} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index 9048dfe06dd747bdb84079139e8e4e5feacf8227..3006171f169cae09063ccb0c1063194e38eab684 100644 (file)
@@ -1 +1 @@
-30983dba6d07c9f20fdfed0cd8bf72da
\ No newline at end of file
+ac836d92967ca91f8ae6bbb795d2d658
\ No newline at end of file
index 77bd96397464e663a6d5859292fcf7708c1bb807..de121a69ada4e75d63865a6cc5ad3397bffe4eda 100644 (file)
Binary files a/LayoutTests/editing/selection/select-box-expected.png and b/LayoutTests/editing/selection/select-box-expected.png differ
index 67c421acf205c9a61f23a5dec9a7e1be9b285d58..feedeea03cd66a5f85fec15b5c9f72b429cd6285 100644 (file)
@@ -51,31 +51,6 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 800x600
@@ -92,4 +67,4 @@ layer at (0,0) size 800x600
           DeprecatedRenderSelect {SELECT} at (73,2) size 38x18
           RenderText {#text} at (113,1) size 66x18
             text run at (113,1) width 66: " the end ..."
-caret: position 89 of child 0 {#text} of child 1 {P} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 1 of child 0 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/selection/skip-non-editable-1-expected.txt b/LayoutTests/editing/selection/skip-non-editable-1-expected.txt
new file mode 100644 (file)
index 0000000..9087b1b
--- /dev/null
@@ -0,0 +1,38 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 13 of BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldEndEditingInDOMRange:range from 0 of BODY > HTML > #document to 13 of BODY > HTML > #document
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of TD > TR > TBODY > TABLE > BODY > HTML > #document to 1 of TD > TR > TBODY > TABLE > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldEndEditingInDOMRange:range from 0 of TD > TR > TBODY > TABLE > BODY > HTML > #document to 1 of TD > TR > TBODY > TABLE > BODY > HTML > #document
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 13 of BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldEndEditingInDOMRange:range from 0 of BODY > HTML > #document to 13 of BODY > HTML > #document
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of TD > TR > TBODY > TABLE > BODY > HTML > #document to 1 of TD > TR > TBODY > TABLE > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldEndEditingInDOMRange:range from 0 of TD > TR > TBODY > TABLE > BODY > HTML > #document to 1 of TD > TR > TBODY > TABLE > BODY > HTML > #document
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 13 of BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldEndEditingInDOMRange:range from 0 of BODY > HTML > #document to 13 of BODY > HTML > #document
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of TD > TR > TBODY > TABLE > BODY > HTML > #document to 1 of TD > TR > TBODY > TABLE > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+This tests moving the caret in content of mixed editability. The caret should jump to the next editable region that shares a common editable ancestor when it reaches non-editable content.
+
+editable content
+non-editable content   non-editable content    editable content
+editable content
+Success
+Success
+Success
+Success
+
diff --git a/LayoutTests/editing/selection/skip-non-editable-1.html b/LayoutTests/editing/selection/skip-non-editable-1.html
new file mode 100644 (file)
index 0000000..dd0cb1c
--- /dev/null
@@ -0,0 +1,61 @@
+<head>
+<style>
+table, td {
+    border: 1px solid #aaa;
+}
+</style>
+
+<script>
+function log(str) {
+    var li = document.createElement("li");
+    li.appendChild(document.createTextNode(str));
+    var console = document.getElementById("console");
+    console.appendChild(li);
+}
+
+function assert(bool) {
+    if (!bool)
+        log("Failure");
+    else
+        log("Success");
+}
+</script>
+</head>
+
+<body contentEditable="true">
+<p>This tests moving the caret in content of mixed editability.  The caret should jump to the next editable region that shares a common editable ancestor when it reaches non-editable content.</p>
+<div id="e1">editable content</div>
+<table cellpadding="5" contentEditable="false">
+<tr>
+<td>non-editable content</td>
+<td>non-editable content</td>
+<td id="e2" contentEditable="true">editable content</td>
+</table>
+<div id="e3">editable content</div>
+
+<ul id="console"></ul>
+</body>
+
+<script>
+if (window.layoutTestController)
+    window.layoutTestController.dumpAsText();
+    
+var s = window.getSelection();
+var e1 = document.getElementById("e1");
+var e2 = document.getElementById("e2");
+var e3 = document.getElementById("e3");
+
+s.setPosition(e1.firstChild, e1.firstChild.length);
+s.modify("move", "forward", "character");
+assert(s.anchorNode == e2.firstChild && s.anchorOffset == 0);
+
+s.modify("move", "backward", "character");
+assert(s.anchorNode == e1.firstChild && s.anchorOffset == e1.firstChild.length);
+    
+s.setPosition(e2.firstChild, e2.firstChild.length);
+s.modify("move", "forward", "character");
+assert(s.anchorNode == e3.firstChild && s.anchorOffset == 0);
+
+s.modify("move", "backward", "character");
+assert(s.anchorNode == e2.firstChild && s.anchorOffset == e2.firstChild.length)
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/selection/skip-non-editable-2-expected.txt b/LayoutTests/editing/selection/skip-non-editable-2-expected.txt
new file mode 100644 (file)
index 0000000..071d309
--- /dev/null
@@ -0,0 +1,11 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 11 of BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+This tests moving the caret in content of mixed editability. The caret should jump to the next editable region that shares a common editable ancestor when it reaches non-editable content.
+
+editablenoneditableeditable
+Success
+Success
+
diff --git a/LayoutTests/editing/selection/skip-non-editable-2.html b/LayoutTests/editing/selection/skip-non-editable-2.html
new file mode 100644 (file)
index 0000000..5ca13b7
--- /dev/null
@@ -0,0 +1,42 @@
+<head>
+<script>
+function log(str) {
+    var li = document.createElement("li");
+    li.appendChild(document.createTextNode(str));
+    var console = document.getElementById("console");
+    console.appendChild(li);
+}
+
+function assert(bool) {
+    if (!bool)
+        log("Failure");
+    else
+        log("Success");
+}
+</script>
+</head>
+
+<body contentEditable="true">
+<p>This tests moving the caret in content of mixed editability.  The caret should jump to the next editable region that shares a common editable ancestor when it reaches non-editable content.</p>
+<span id="e1">editable</span><span id="e2" contentEditable="false" style="font-weight:bold">noneditable</span><span id="e3">editable</span>
+
+
+<ul id="console"></ul>
+</body>
+
+<script>
+if (window.layoutTestController)
+    window.layoutTestController.dumpAsText();
+    
+var s = window.getSelection();
+var e1 = document.getElementById("e1");
+var e2 = document.getElementById("e2");
+var e3 = document.getElementById("e3");
+
+s.setPosition(e1.firstChild, e1.firstChild.length);
+s.modify("move", "forward", "character");
+assert(s.anchorNode == e3.firstChild && s.anchorOffset == 0);
+
+s.modify("move", "backward", "character");
+assert(s.anchorNode == e1.firstChild && s.anchorOffset == e1.firstChild.length);
+</script>
index acd772f0ff7f56f5c94239665d50d31a41aed3b7..abcd7f28ddee309b214f2cd91c62330ce279fac5 100644 (file)
@@ -1,3 +1,30 @@
+2006-06-30  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by harrison
+        
+        <rdar://problem/4598309
+        Caret gets stuck when it hits non editable content within an editable body
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=9510>
+        Caret will jump out of an editable region
+        
+        * dom/Position.cpp:
+        (WebCore::Position::upstream): Don't move into a new editable region so that 
+        candidates that that straddle an editable/non-editable boundary will 
+        correspond to different VisiblePositions.
+        (WebCore::Position::downstream): Ditto.
+        * editing/SelectionController.cpp:
+        (WebCore::SelectionController::modifyMovingRightForward): Use VisiblePosition::next(true)
+        (WebCore::SelectionController::modifyMovingLeftBackward): Use VisiblePosition::previous(true)
+        * editing/VisiblePosition.cpp:
+        (WebCore::VisiblePosition::next): Added code to jump to the next editable region as long
+        as it has the same highest editable root.
+        (WebCore::VisiblePosition::previous): Ditto.
+        * editing/VisiblePosition.h:
+        * editing/htmlediting.cpp:
+        (WebCore::highestEditableRoot): Added, returns the highest editable root of a node if that
+        node is in editable content, otherwise 0.
+        * editing/htmlediting.h:
+
 2006-06-30  David Kilzer  <ddkilzer@kilzer.net>
 
         Reviewed by Darin.
index dd9c353ab6f5a1a89949b30b5afa265602468dfc..c5ea558917bba7feafc0792dd0072bedd9a082d4 100644 (file)
                FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
 /* End PBXBuildFile section */
 
+/* Begin PBXBuildStyle section */
+               D06749E30A54CE6D00DA0E29 /* Development */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = NO;
+                       };
+                       name = Development;
+               };
+               D06749E40A54CE6D00DA0E29 /* Deployment */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = YES;
+                       };
+                       name = Deployment;
+               };
+/* End PBXBuildStyle section */
+
 /* Begin PBXContainerItemProxy section */
                DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
+                       buildSettings = {
+                       };
+                       buildStyles = (
+                               D06749E30A54CE6D00DA0E29 /* Development */,
+                               D06749E40A54CE6D00DA0E29 /* Deployment */,
+                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index 568d072d1d679b806bafa6d87db67c8b44aa32bc..f604777e2134790194aa43d2b151c64dd582f74e 100644 (file)
@@ -287,9 +287,13 @@ Position Position::upstream() const
     Node *block = startNode->enclosingBlockFlowOrTableElement();
     Position lastVisible = *this;
     Position currentPos = start;
+    Node* originalRoot = node()->rootEditableElement();
     for (; !currentPos.atStart(); currentPos = currentPos.previous(UsingComposedCharacters)) {
         Node *currentNode = currentPos.node();
         int currentOffset = currentPos.offset();
+        
+        if (currentNode->rootEditableElement() != originalRoot)
+            break;
 
         // Don't enter a new enclosing block flow or table element.  There is code below that
         // terminates early if we're about to leave an enclosing block flow or table element.
@@ -361,9 +365,13 @@ Position Position::downstream() const
     Node *block = startNode->enclosingBlockFlowOrTableElement();
     Position lastVisible = *this;
     Position currentPos = start;
+    Node* originalRoot = node()->rootEditableElement();
     for (; !currentPos.atEnd(); currentPos = currentPos.next(UsingComposedCharacters)) {   
         Node *currentNode = currentPos.node();
         int currentOffset = currentPos.offset();
+        
+        if (currentNode->rootEditableElement() != originalRoot)
+            break;
 
         // stop before going above the body, up into the head
         // return the last visible streamer position
index c82b282e2b58e834d1474c8223c209914c73b9e4..4b0bcf45df99d288bd8e76534304cada5218b570 100644 (file)
@@ -282,12 +282,13 @@ VisiblePosition SelectionController::modifyExtendingRightForward(TextGranularity
 VisiblePosition SelectionController::modifyMovingRightForward(TextGranularity granularity)
 {
     VisiblePosition pos;
+    // FIXME: Stay in editable content for the less common granularities.
     switch (granularity) {
         case CharacterGranularity:
             if (isRange()) 
                 pos = VisiblePosition(m_sel.end(), m_sel.affinity());
             else
-                pos = VisiblePosition(m_sel.extent(), m_sel.affinity()).next();
+                pos = VisiblePosition(m_sel.extent(), m_sel.affinity()).next(true);
             break;
         case WordGranularity:
             pos = nextWordPosition(VisiblePosition(m_sel.extent(), m_sel.affinity()));
@@ -371,12 +372,13 @@ VisiblePosition SelectionController::modifyExtendingLeftBackward(TextGranularity
 VisiblePosition SelectionController::modifyMovingLeftBackward(TextGranularity granularity)
 {
     VisiblePosition pos;
+    // FIXME: Stay in editable content for the less common granularities.
     switch (granularity) {
         case CharacterGranularity:
             if (isRange()) 
                 pos = VisiblePosition(m_sel.start(), m_sel.affinity());
             else
-                pos = VisiblePosition(m_sel.extent(), m_sel.affinity()).previous();
+                pos = VisiblePosition(m_sel.extent(), m_sel.affinity()).previous(true);
             break;
         case WordGranularity:
             pos = previousWordPosition(VisiblePosition(m_sel.extent(), m_sel.affinity()));
index 2b066c09694a4e4e41f425f9c953ae34b81f576a..4acd7b6631c7588f09afe4cb948b8967458ad6c3 100644 (file)
@@ -60,14 +60,36 @@ void VisiblePosition::init(const Position& position, EAffinity affinity)
         m_affinity = DOWNSTREAM;
 }
 
-VisiblePosition VisiblePosition::next(bool stayInCurrentEditableRegion) const
+VisiblePosition VisiblePosition::next(bool stayInEditableContent) const
 {
     VisiblePosition next(nextVisiblePosition(m_deepPosition), m_affinity);
-    Element* currentRoot = rootEditableElement();
-    return !stayInCurrentEditableRegion || next.rootEditableElement() == currentRoot ? next : VisiblePosition();
+    
+    if (!stayInEditableContent || next.isNull())
+        return next;
+    
+    Node* highestRoot = highestEditableRoot(deepEquivalent().node());
+    
+    if (!next.deepEquivalent().node()->isAncestor(highestRoot))
+        return VisiblePosition();
+
+    if (highestEditableRoot(next.deepEquivalent().node()) == highestRoot)
+        return next;
+
+    Position p = next.deepEquivalent();
+    Node* node = p.node();
+    Node* child = node->childNode(p.offset());
+    node = child ? child : node->traverseNextSibling(highestRoot);
+
+    while (node && !node->isContentEditable())
+        node = node->traverseNextNode(highestRoot);
+    
+    if (!node)
+        return VisiblePosition();
+
+    return VisiblePosition(Position(node, 0));
 }
 
-VisiblePosition VisiblePosition::previous(bool stayInCurrentEditableRegion) const
+VisiblePosition VisiblePosition::previous(bool stayInEditableContent) const
 {
     // find first previous DOM position that is visible
     Position pos = previousVisiblePosition(m_deepPosition);
@@ -76,20 +98,42 @@ VisiblePosition VisiblePosition::previous(bool stayInCurrentEditableRegion) cons
     if (pos.atStart())
         return VisiblePosition();
         
-    VisiblePosition result = VisiblePosition(pos, DOWNSTREAM);
-    ASSERT(result != *this);
+    VisiblePosition prev = VisiblePosition(pos, DOWNSTREAM);
+    ASSERT(prev != *this);
     
 #ifndef NDEBUG
     // we should always be able to make the affinity DOWNSTREAM, because going previous from an
     // UPSTREAM position can never yield another UPSTREAM position (unless line wrap length is 0!).
-    if (result.isNotNull() && m_affinity == UPSTREAM) {
-        VisiblePosition temp = result;
+    if (prev.isNotNull() && m_affinity == UPSTREAM) {
+        VisiblePosition temp = prev;
         temp.setAffinity(UPSTREAM);
-        ASSERT(inSameLine(temp, result));
+        ASSERT(inSameLine(temp, prev));
     }
 #endif
-    Element* currentRoot = rootEditableElement();
-    return !stayInCurrentEditableRegion || result.rootEditableElement() == currentRoot ? result : VisiblePosition();
+
+    if (!stayInEditableContent || prev.isNull())
+        return prev;
+    
+    Node* highestRoot = highestEditableRoot(deepEquivalent().node());
+    
+    if (!prev.deepEquivalent().node()->isAncestor(highestRoot))
+        return VisiblePosition();
+        
+    if (highestEditableRoot(prev.deepEquivalent().node()) == highestRoot)
+        return prev;
+
+    Position p = prev.deepEquivalent();
+    Node* node = p.node();
+    Node* child = node->firstChild() && p.offset() > 1 ? node->childNode(p.offset() - 1) : 0;
+    node = child ? child : node->traversePreviousNode(highestRoot);
+
+    while (node && !node->isContentEditable())
+        node = node->traversePreviousNodePostOrder(highestRoot);
+    
+    if (!node)
+        return VisiblePosition();
+
+    return VisiblePosition(Position(node, maxDeepOffset(node)));
 }
 
 Position VisiblePosition::previousVisiblePosition(const Position& pos)
index 70efcaa3fefe19b26a7104e84dc81871fb86764a..15f3feb58426f159095922530a7dda1cf445f3ea 100644 (file)
@@ -61,8 +61,8 @@ public:
     void setAffinity(EAffinity affinity) { m_affinity = affinity; }
 
     // next() and previous() will increment/decrement by a character cluster.
-    VisiblePosition next(bool stayInCurrentEditableRegion = false) const;
-    VisiblePosition previous(bool stayInCurrentEditableRegion = false) const;
+    VisiblePosition next(bool stayInEditableContent = false) const;
+    VisiblePosition previous(bool stayInEditableContent = false) const;
 
     bool isLastInBlock() const;
 
index 62014e6cd42d36431c077b8f674295f03c97dd95..6f517a0431973616f2f4dca4ea2f35229eaaa2f7 100644 (file)
@@ -86,6 +86,27 @@ bool canHaveChildrenForEditing(const Node* node)
            !node->isTextNode();
 }
 
+Node* highestEditableRoot(Node* node)
+{
+    if (!node)
+        return 0;
+        
+    Node* highestRoot = node->rootEditableElement();
+    if (!highestRoot)
+        return 0;
+    
+    node = highestRoot;
+    while (node) {
+        if (node->isContentEditable())
+            highestRoot = node;
+        if (node->hasTagName(bodyTag))
+            break;
+        node = node->parentNode();
+    }
+    
+    return highestRoot;
+}
+
 // antidote for maxDeepOffset()
 Position rangeCompliantEquivalent(const Position& pos)
 {
index 339d171636cd606080a0c9c121c1f335c4a5b147..19fd97a14cc386e3e1166d016ad7fb51c7f2224b 100644 (file)
@@ -46,6 +46,7 @@ int maxDeepOffset(const Node*);
 bool isAtomicNode(const Node*);
 bool editingIgnoresContent(const Node*);
 bool canHaveChildrenForEditing(const Node*);
+Node* highestEditableRoot(Node*);
 
 void rebalanceWhitespaceInTextNode(Node*, unsigned start, unsigned length);
 const String& nonBreakingSpaceString();