LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Dec 2006 19:29:40 +0000 (19:29 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Dec 2006 19:29:40 +0000 (19:29 +0000)
        Reviewed by john

        <rdar://problem/4836287>
        Cannot expand selection out of editable element when containing element is non-editable.

        * editing/selection/mixed-editability-6-expected.checksum: Added.
        * editing/selection/mixed-editability-6-expected.png: Added.
        * editing/selection/mixed-editability-6-expected.txt: Added.
        * editing/selection/mixed-editability-6.html: Added.
        * editing/selection/mixed-editability-7-expected.checksum: Added.
        * editing/selection/mixed-editability-7-expected.png: Added.
        * editing/selection/mixed-editability-7-expected.txt: Added.
        * editing/selection/mixed-editability-7.html: Added.

WebCore:

        Reviewed by john

        <rdar://problem/4836287>
        Cannot expand selection out of editable element when containing element is non-editable.

        * editing/Selection.cpp:
        (WebCore::Selection::adjustForEditableContent): Restrict the selection endpoints
        to the same *highest* editable root.  This bug only happened when creating selections
        based in an editable region and extending into a higher editable root, so this change
        doesn't expose any new kinds of deletions, but we should start thinking about how
        those deletions should behave.
        * editing/SelectionController.cpp:
        (WebCore::SelectionController::selectAll): Ditto.

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/selection/mixed-editability-6-expected.checksum [new file with mode: 0644]
LayoutTests/editing/selection/mixed-editability-6-expected.png [new file with mode: 0644]
LayoutTests/editing/selection/mixed-editability-6-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/mixed-editability-6.html [new file with mode: 0644]
LayoutTests/editing/selection/mixed-editability-7-expected.checksum [new file with mode: 0644]
LayoutTests/editing/selection/mixed-editability-7-expected.png [new file with mode: 0644]
LayoutTests/editing/selection/mixed-editability-7-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/mixed-editability-7.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/Selection.cpp
WebCore/editing/SelectionController.cpp

index 4be505cbbec705132588e4f803d0f42e81556d25..b0a33a5d864a556e24fe4c431d3e23fde05a9a42 100644 (file)
@@ -1,3 +1,19 @@
+2006-12-08  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by john
+
+        <rdar://problem/4836287>
+        Cannot expand selection out of editable element when containing element is non-editable.
+
+        * editing/selection/mixed-editability-6-expected.checksum: Added.
+        * editing/selection/mixed-editability-6-expected.png: Added.
+        * editing/selection/mixed-editability-6-expected.txt: Added.
+        * editing/selection/mixed-editability-6.html: Added.
+        * editing/selection/mixed-editability-7-expected.checksum: Added.
+        * editing/selection/mixed-editability-7-expected.png: Added.
+        * editing/selection/mixed-editability-7-expected.txt: Added.
+        * editing/selection/mixed-editability-7.html: Added.
+
 2006-12-08  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Geoff.
diff --git a/LayoutTests/editing/selection/mixed-editability-6-expected.checksum b/LayoutTests/editing/selection/mixed-editability-6-expected.checksum
new file mode 100644 (file)
index 0000000..64456af
--- /dev/null
@@ -0,0 +1 @@
+5a1abb6a04c7f939d3d8442a193d512f
\ No newline at end of file
diff --git a/LayoutTests/editing/selection/mixed-editability-6-expected.png b/LayoutTests/editing/selection/mixed-editability-6-expected.png
new file mode 100644 (file)
index 0000000..c839383
Binary files /dev/null and b/LayoutTests/editing/selection/mixed-editability-6-expected.png differ
diff --git a/LayoutTests/editing/selection/mixed-editability-6-expected.txt b/LayoutTests/editing/selection/mixed-editability-6-expected.txt
new file mode 100644 (file)
index 0000000..f134390
--- /dev/null
@@ -0,0 +1,28 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 779x36
+          text run at (0,0) width 618: "This tests Select All when the caret is inside an editable region that is inside a non editable region. "
+          text run at (618,0) width 161: "Whenever the selection is"
+          text run at (0,18) width 537: "in an editable region, Select All should select the contents of the highest editable root."
+      RenderBlock {DIV} at (0,52) size 784x54
+        RenderBlock {DIV} at (0,0) size 784x18
+          RenderText {#text} at (0,0) size 27x18
+            text run at (0,0) width 27: "One"
+        RenderBlock {DIV} at (0,18) size 784x18
+          RenderInline {SPAN} at (0,0) size 30x18
+            RenderText {#text} at (0,0) size 30x18
+              text run at (0,0) width 30: "Two"
+          RenderText {#text} at (30,0) size 4x18
+            text run at (30,0) width 4: " "
+          RenderInline {SPAN} at (0,0) size 37x18
+            RenderText {#text} at (34,0) size 37x18
+              text run at (34,0) width 37: "Three"
+        RenderBlock {DIV} at (0,36) size 784x18
+          RenderText {#text} at (0,0) size 30x18
+            text run at (0,0) width 30: "Four"
+selection start: position 0 of child 0 {#text} of child 1 {DIV} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
+selection end:   position 4 of child 0 {#text} of child 5 {DIV} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/selection/mixed-editability-6.html b/LayoutTests/editing/selection/mixed-editability-6.html
new file mode 100644 (file)
index 0000000..8d03e2e
--- /dev/null
@@ -0,0 +1,14 @@
+<p>This tests Select All when the caret is inside an editable region that is inside a non editable region.  Whenever the selection is in an editable region, Select All should select the contents of the highest editable root.</p>
+<div contenteditable="true">
+<div>One</div>
+<div contenteditable="false"><span>Two</span> <span id="start" contenteditable="true">Three</span></div>
+<div>Four</div>
+</div>
+
+<script>
+var span = document.getElementById("start");
+var sel = window.getSelection();
+sel.setPosition(span, 0);
+
+document.execCommand("SelectAll");
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/selection/mixed-editability-7-expected.checksum b/LayoutTests/editing/selection/mixed-editability-7-expected.checksum
new file mode 100644 (file)
index 0000000..2087882
--- /dev/null
@@ -0,0 +1 @@
+267df7b9967007a4f5292e45b70c0892
\ No newline at end of file
diff --git a/LayoutTests/editing/selection/mixed-editability-7-expected.png b/LayoutTests/editing/selection/mixed-editability-7-expected.png
new file mode 100644 (file)
index 0000000..a92f938
Binary files /dev/null and b/LayoutTests/editing/selection/mixed-editability-7-expected.png differ
diff --git a/LayoutTests/editing/selection/mixed-editability-7-expected.txt b/LayoutTests/editing/selection/mixed-editability-7-expected.txt
new file mode 100644 (file)
index 0000000..9f0cb93
--- /dev/null
@@ -0,0 +1,28 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 779x36
+          text run at (0,0) width 779: "This tests creating a selection based inside a nested editable region that extends out to editable content that is inside the same"
+          text run at (0,18) width 135: "highest editable root. "
+          text run at (135,18) width 256: "'One' through 'Three' should be selected."
+      RenderBlock {DIV} at (0,52) size 784x54
+        RenderBlock {DIV} at (0,0) size 784x18
+          RenderText {#text} at (0,0) size 27x18
+            text run at (0,0) width 27: "One"
+        RenderBlock {DIV} at (0,18) size 784x18
+          RenderInline {SPAN} at (0,0) size 30x18
+            RenderText {#text} at (0,0) size 30x18
+              text run at (0,0) width 30: "Two"
+          RenderText {#text} at (30,0) size 4x18
+            text run at (30,0) width 4: " "
+          RenderInline {SPAN} at (0,0) size 37x18
+            RenderText {#text} at (34,0) size 37x18
+              text run at (34,0) width 37: "Three"
+        RenderBlock {DIV} at (0,36) size 784x18
+          RenderText {#text} at (0,0) size 30x18
+            text run at (0,0) width 30: "Four"
+selection start: position 0 of child 0 {#text} of child 1 {DIV} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
+selection end:   position 5 of child 0 {#text} of child 2 {SPAN} of child 3 {DIV} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/selection/mixed-editability-7.html b/LayoutTests/editing/selection/mixed-editability-7.html
new file mode 100644 (file)
index 0000000..05132e7
--- /dev/null
@@ -0,0 +1,14 @@
+<p>This tests creating a selection based inside a nested editable region that extends out to editable content that is inside the same highest editable root.  'One' through 'Three' should be selected.</p>
+<div contenteditable="true">
+<div id="extent">One</div>
+<div contenteditable="false"><span>Two</span> <span id="base" contenteditable="true">Three</span></div>
+<div>Four</div>
+</div>
+
+<script>
+var base = document.getElementById("base");
+var extent = document.getElementById("extent");
+
+var sel = window.getSelection();
+sel.setBaseAndExtent(base, 1, extent, 0);
+</script>
\ No newline at end of file
index 775745ba3c518a0b36a839f538f78d1dcfca166f..e8d21f6b669d06a65b297d61eca64695cdf60ede 100644 (file)
@@ -1,3 +1,19 @@
+2006-12-07  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by john
+
+        <rdar://problem/4836287>
+        Cannot expand selection out of editable element when containing element is non-editable.
+
+        * editing/Selection.cpp:
+        (WebCore::Selection::adjustForEditableContent): Restrict the selection endpoints
+        to the same *highest* editable root.  This bug only happened when creating selections
+        based in an editable region and extending into a higher editable root, so this change 
+        doesn't expose any new kinds of deletions, but we should start thinking about how
+        those deletions should behave.
+        * editing/SelectionController.cpp:
+        (WebCore::SelectionController::selectAll): Ditto.
+
 2006-12-08  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Maciej.
index c15ab5738d65cb5fb9d7c3ac6cc2483f31616f8d..5e9feb49208039386753bc55d2bb40e015f677d9 100644 (file)
@@ -338,9 +338,9 @@ void Selection::adjustForEditableContent()
     if (m_base.isNull() || m_start.isNull() || m_end.isNull())
         return;
 
-    Node* baseRoot = m_base.node()->rootEditableElement();
-    Node* startRoot = m_start.node()->rootEditableElement();
-    Node* endRoot = m_end.node()->rootEditableElement();
+    Node* baseRoot = highestEditableRoot(m_base);
+    Node* startRoot = highestEditableRoot(m_start);
+    Node* endRoot = highestEditableRoot(m_end);
     
     Node* baseEditableAncestor = lowestEditableAncestor(m_base.node());
     
index 9cd41f80971f7bb5c03df9ab1a4d822d08c8b6dd..154f0b0531155063615457137984e52addf527ab 100644 (file)
@@ -1044,7 +1044,7 @@ void SelectionController::selectAll()
     if (!document)
         return;
     
-    Node* root = isContentEditable() ? rootEditableElement() : document->documentElement();
+    Node* root = isContentEditable() ? highestEditableRoot(m_sel.start()) : document->documentElement();
     Selection newSelection(Selection::selectionFromContentsOfNode(root));
     if (m_frame->shouldChangeSelection(newSelection))
         setSelection(newSelection);