LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Jun 2006 00:45:02 +0000 (00:45 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Jun 2006 00:45:02 +0000 (00:45 +0000)
        Reviewed by levi

        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8637>
        REGRESSION (11-16-05): Selection gaps left behind after delete

        * fast/repaint/selection-after-delete-expected.checksum: Added.
        * fast/repaint/selection-after-delete-expected.png: Added.
        * fast/repaint/selection-after-delete-expected.txt: Added.
        * fast/repaint/selection-after-delete.html: Added.
        * fast/repaint/selection-after-remove-expected.checksum: Added.
        * fast/repaint/selection-after-remove-expected.png: Added.
        * fast/repaint/selection-after-remove-expected.txt: Added.
        * fast/repaint/selection-after-remove.html: Added.

WebCore:

        Reviewed by levi

        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8637>
        REGRESSION (11-16-05): Selection gaps left behind after delete

        * editing/SelectionController.cpp:
        (WebCore::SelectionController::nodeWillBeRemoved): Invalidate the selection so that
        selection gaps are invalidated.

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

LayoutTests/ChangeLog
LayoutTests/fast/repaint/selection-after-delete-expected.checksum [new file with mode: 0644]
LayoutTests/fast/repaint/selection-after-delete-expected.png [new file with mode: 0644]
LayoutTests/fast/repaint/selection-after-delete-expected.txt [new file with mode: 0644]
LayoutTests/fast/repaint/selection-after-delete.html [new file with mode: 0644]
LayoutTests/fast/repaint/selection-after-remove-expected.checksum [new file with mode: 0644]
LayoutTests/fast/repaint/selection-after-remove-expected.png [new file with mode: 0644]
LayoutTests/fast/repaint/selection-after-remove-expected.txt [new file with mode: 0644]
LayoutTests/fast/repaint/selection-after-remove.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/SelectionController.cpp

index 93e734c2bcafb43b2b5ef1465ab723acd90c6149..f8c8f4969afa51295f7f520562b41d357be06ca6 100644 (file)
@@ -1,3 +1,19 @@
+2006-06-15  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8637>
+        REGRESSION (11-16-05): Selection gaps left behind after delete
+
+        * fast/repaint/selection-after-delete-expected.checksum: Added.
+        * fast/repaint/selection-after-delete-expected.png: Added.
+        * fast/repaint/selection-after-delete-expected.txt: Added.
+        * fast/repaint/selection-after-delete.html: Added.
+        * fast/repaint/selection-after-remove-expected.checksum: Added.
+        * fast/repaint/selection-after-remove-expected.png: Added.
+        * fast/repaint/selection-after-remove-expected.txt: Added.
+        * fast/repaint/selection-after-remove.html: Added.
+
 2006-06-15  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by harrison
diff --git a/LayoutTests/fast/repaint/selection-after-delete-expected.checksum b/LayoutTests/fast/repaint/selection-after-delete-expected.checksum
new file mode 100644 (file)
index 0000000..0825e12
--- /dev/null
@@ -0,0 +1 @@
+3e74ad507354bcb554af6dee64ddf282
\ No newline at end of file
diff --git a/LayoutTests/fast/repaint/selection-after-delete-expected.png b/LayoutTests/fast/repaint/selection-after-delete-expected.png
new file mode 100644 (file)
index 0000000..d5d2b8c
Binary files /dev/null and b/LayoutTests/fast/repaint/selection-after-delete-expected.png differ
diff --git a/LayoutTests/fast/repaint/selection-after-delete-expected.txt b/LayoutTests/fast/repaint/selection-after-delete-expected.txt
new file mode 100644 (file)
index 0000000..fbe5c96
--- /dev/null
@@ -0,0 +1,20 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 6 of BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of 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
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x562
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 750x36
+          text run at (0,0) width 478: "This tests to see if selection gaps are removed when the selection is deleted. "
+          text run at (478,0) width 222: "Nothing should be selected below. "
+          text run at (700,0) width 50: "A caret "
+          text run at (0,18) width 177: "should be inside the red div."
+      RenderBlock {DIV} at (30,66) size 152x20 [border: (1px solid #FF0000)]
+        RenderBR {BR} at (1,1) size 0x18
+caret: position 0 of child 0 {BR} of child 3 {DIV} of child 2 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/fast/repaint/selection-after-delete.html b/LayoutTests/fast/repaint/selection-after-delete.html
new file mode 100644 (file)
index 0000000..b6580b2
--- /dev/null
@@ -0,0 +1,15 @@
+<script src="repaint.js" type="text/javascript"></script>
+<script type="text/javascript">
+function repaintTest() {
+    document.execCommand("Delete");
+}
+</script>
+<body onload="runRepaintTest();" contenteditable="true">
+<p>This tests to see if selection gaps are removed when the selection is deleted.  Nothing should be selected below.  A caret should be inside the red div.</p>
+<div id="test" style="width: 150px; border: 1px solid red; margin: 30px;">hello world hello world hello world hello world hello world hello world hello world hello world hello<br></div>
+<script>
+var s = window.getSelection();
+var e = document.getElementById("test");
+s.setBaseAndExtent(e, 0, e, e.childNodes.length);
+</script>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/repaint/selection-after-remove-expected.checksum b/LayoutTests/fast/repaint/selection-after-remove-expected.checksum
new file mode 100644 (file)
index 0000000..f6160a7
--- /dev/null
@@ -0,0 +1 @@
+67b479e4e9c9636aeaae6077b248f6f8
\ No newline at end of file
diff --git a/LayoutTests/fast/repaint/selection-after-remove-expected.png b/LayoutTests/fast/repaint/selection-after-remove-expected.png
new file mode 100644 (file)
index 0000000..ccabdfd
Binary files /dev/null and b/LayoutTests/fast/repaint/selection-after-remove-expected.png differ
diff --git a/LayoutTests/fast/repaint/selection-after-remove-expected.txt b/LayoutTests/fast/repaint/selection-after-remove-expected.txt
new file mode 100644 (file)
index 0000000..6247378
--- /dev/null
@@ -0,0 +1,21 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 6 of BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+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 784x562
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 768x36
+          text run at (0,0) width 650: "This tests to see if selection gaps are invalidated properly when content inside the selection is removed. "
+          text run at (650,0) width 118: "Only 'hello world' "
+          text run at (0,18) width 229: "should have a selecton tint behind it."
+      RenderBlock {DIV} at (30,66) size 152x20 [border: (1px solid #FF0000)]
+        RenderText {#text} at (1,1) size 35x18
+          text run at (1,1) width 35: "hello "
+        RenderText {#text} at (36,1) size 37x18
+          text run at (36,1) width 37: "world"
+        RenderBR {BR} at (73,15) size 0x0
+selection start: position 0 of child 0 {#text} of child 3 {DIV} of child 2 {BODY} of child 0 {HTML} of document
+selection end:   position 6 of child 1 {#text} of child 3 {DIV} of child 2 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/fast/repaint/selection-after-remove.html b/LayoutTests/fast/repaint/selection-after-remove.html
new file mode 100644 (file)
index 0000000..2826c91
--- /dev/null
@@ -0,0 +1,16 @@
+<script src="repaint.js" type="text/javascript"></script>
+<script type="text/javascript">
+function repaintTest() {
+    var e = document.getElementById("removeme");
+    e.parentNode.removeChild(e);
+}
+</script>
+<body onload="runRepaintTest();" contenteditable="true">
+<p>This tests to see if selection gaps are invalidated properly when content inside the selection is removed.  Only 'hello world' should have a selecton tint behind it.</p>
+<div id="test" style="width: 150px; border: 1px solid red; margin: 30px;">hello <span id="removeme"> world hello world hello world hello world hello world hello world hello world hello world hello</span> world<br></div>
+<script>
+var s = window.getSelection();
+var e = document.getElementById("test");
+s.setBaseAndExtent(e, 0, e, e.childNodes.length);
+</script>
+</body>
\ No newline at end of file
index a49390b5a9ed65623d067e07cf81a3dfb44f0062..821f174ee0e6e5cddb4b92bc3ce4699bdd757ca3 100644 (file)
@@ -1,3 +1,14 @@
+2006-06-15  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8637>
+        REGRESSION (11-16-05): Selection gaps left behind after delete
+
+        * editing/SelectionController.cpp:
+        (WebCore::SelectionController::nodeWillBeRemoved): Invalidate the selection so that 
+        selection gaps are invalidated.
+
 2006-06-15  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Geoff and Darin.
index e8fa1591b9f01329bba4b1aa5f0f25ec4694ad81..bc5c3e364a93af732d014c39dd3e356aece7386a 100644 (file)
@@ -188,11 +188,8 @@ void SelectionController::nodeWillBeRemoved(Node *node)
         // FIXME (6498): This doesn't notify the editing delegate of a selection change.
 
         // FIXME: When endpoints are removed, we should just alter the selection, instead of blowing it away.
-
-        // FIXME: The SelectionController should be responsible for scheduling a repaint, 
-        // but it can't do a proper job of it until it handles the other types of DOM mutations.
-        // For now, we'll continue to let RenderObjects handle it when they are destroyed.
-
+        
+        static_cast<RenderView*>(start->document()->renderer())->clearSelection();
         setSelection(Selection());
         
     } else if (baseRemoved || extentRemoved) {
@@ -203,6 +200,14 @@ void SelectionController::nodeWillBeRemoved(Node *node)
             m_sel.setBase(m_sel.start());
             m_sel.setExtent(m_sel.end());
         }
+    // FIXME: This could be more efficient if we had an isNodeInRange function on Ranges.
+    } else if (Range::compareBoundaryPoints(m_sel.start(), Position(node, 0)) == -1 &&
+               Range::compareBoundaryPoints(m_sel.end(), Position(node, 0)) == 1) {
+        // If we did nothing here, when this node's renderer was destroyed, the rect that it 
+        // occupied would be invalidated, but, selection gaps that change as a result of 
+        // the removal wouldn't be invalidated.
+        // FIXME: Don't do so much unnecessary invalidation.
+        static_cast<RenderView*>(start->document()->renderer())->clearSelection();
     }
 }