LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jul 2007 19:26:56 +0000 (19:26 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jul 2007 19:26:56 +0000 (19:26 +0000)
        Reviewed by Harrison.

        <rdar://problem/5300379> Mail hung on option-delete

        * editing/deleting/5300379-expected.checksum: Added.
        * editing/deleting/5300379-expected.png: Added.
        * editing/deleting/5300379-expected.txt: Added.
        * editing/deleting/5300379.html: Added.

WebCore:

        Reviewed by Harrison.

        <rdar://problem/5300379> Mail hung on option-delete

        We were starting backward iteration at [container, 0] and
        emitting for container over and over.

        * editing/TextIterator.cpp:
        (WebCore::SimplifiedBackwardsTextIterator::advance): Don't
        emit characters for a node if we're starting iteration at
        [container, 0].  Don't emit characters for exiting containers
        if we've already done so.

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

LayoutTests/ChangeLog
LayoutTests/editing/deleting/5300379-expected.checksum [new file with mode: 0644]
LayoutTests/editing/deleting/5300379-expected.png [new file with mode: 0644]
LayoutTests/editing/deleting/5300379-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/5300379.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/TextIterator.cpp

index 17670007555c57c78ff4b7f340998ff4ed1e91e1..d509a1373d7cbe58ddc8b951f1379e8519feb16d 100644 (file)
@@ -1,3 +1,14 @@
+2007-07-12  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by Harrison.
+        
+        <rdar://problem/5300379> Mail hung on option-delete
+
+        * editing/deleting/5300379-expected.checksum: Added.
+        * editing/deleting/5300379-expected.png: Added.
+        * editing/deleting/5300379-expected.txt: Added.
+        * editing/deleting/5300379.html: Added.
+
 2007-07-11  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Maciej.
diff --git a/LayoutTests/editing/deleting/5300379-expected.checksum b/LayoutTests/editing/deleting/5300379-expected.checksum
new file mode 100644 (file)
index 0000000..4c7e26d
--- /dev/null
@@ -0,0 +1 @@
+eb961bc0a6372808fbd351e18cea694a
\ No newline at end of file
diff --git a/LayoutTests/editing/deleting/5300379-expected.png b/LayoutTests/editing/deleting/5300379-expected.png
new file mode 100644 (file)
index 0000000..394f193
Binary files /dev/null and b/LayoutTests/editing/deleting/5300379-expected.png differ
diff --git a/LayoutTests/editing/deleting/5300379-expected.txt b/LayoutTests/editing/deleting/5300379-expected.txt
new file mode 100644 (file)
index 0000000..3a91e3c
--- /dev/null
@@ -0,0 +1,11 @@
+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 {DIV} at (0,0) size 784x0
+      RenderBlock {DIV} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 50x18
+          text run at (0,0) width 50: "Success"
+      RenderBlock {DIV} at (0,18) size 784x0
+caret: position 7 of child 0 {#text} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/deleting/5300379.html b/LayoutTests/editing/deleting/5300379.html
new file mode 100644 (file)
index 0000000..ea2b344
--- /dev/null
@@ -0,0 +1,19 @@
+<div></div>
+<div contenteditable="true" id="div"></div>
+<div></div>
+
+<script>
+div = document.getElementById("div");
+sel = window.getSelection();
+sel.setPosition(div, 0);
+if (window.layoutTestController) {
+    // Test to see if deleteWordBackward: hangs.
+    textInputController.doCommand("deleteWordBackward:");
+    document.execCommand("InsertText", false, "Success FAIL");
+    // Delete 'FAIL' with deleteWordBackward: to verify that it's not a no-op.
+    textInputController.doCommand("deleteWordBackward:");
+    textInputController.doCommand("deleteBackward:");
+} else {
+    document.execCommand("InsertText", false, "To run this test manually.  Delete all this text and then option-delete.  Safari shouldn't hang.");
+}
+</script>
index 57fc98aa79dd410be3064c92a74f257ee378e2c0..267dafb695f2bfa22fd44a275c3410880fbc2151 100644 (file)
@@ -1,3 +1,18 @@
+2007-07-11  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by Harrison.
+        
+        <rdar://problem/5300379> Mail hung on option-delete
+        
+        We were starting backward iteration at [container, 0] and
+        emitting for container over and over.
+
+        * editing/TextIterator.cpp:
+        (WebCore::SimplifiedBackwardsTextIterator::advance): Don't 
+        emit characters for a node if we're starting iteration at 
+        [container, 0].  Don't emit characters for exiting containers
+        if we've already done so.
+
 2007-07-12  Kevin Decker  <kdecker@apple.com>
 
         Reviewed by Mark Rowe.
index 6b88f28c41e949914e4d87d8c1717103a282380d..c9c8209bce25074b2ce36ab8a5c2d266aa254c09 100644 (file)
@@ -728,7 +728,8 @@ void SimplifiedBackwardsTextIterator::advance()
     m_textLength = 0;
 
     while (m_node && m_node != m_pastStartNode) {
-        if (!m_handledNode) {
+        // Don't handle node if we start iterating at [node, 0].
+        if (!m_handledNode && !(m_node == m_endNode && m_endOffset == 0)) {
             RenderObject *renderer = m_node->renderer();
             if (renderer && renderer->isText() && m_node->nodeType() == Node::TEXT_NODE) {
                 // FIXME: What about CDATA_SECTION_NODE?
@@ -747,7 +748,10 @@ void SimplifiedBackwardsTextIterator::advance()
         if (!next) {
             // Exit empty containers as we pass over them or containers
             // where [container, 0] is where we started iterating.
-            if (canHaveChildrenForEditing(m_node) && m_node->parentNode() && (!m_node->lastChild() || m_node == m_endNode && m_endOffset == 0)) {
+            if (!m_handledNode &&
+                canHaveChildrenForEditing(m_node) && 
+                m_node->parentNode() && 
+                (!m_node->lastChild() || m_node == m_endNode && m_endOffset == 0)) {
                 exitNode();
                 if (m_positionNode) {
                     m_handledNode = true;
@@ -755,6 +759,7 @@ void SimplifiedBackwardsTextIterator::advance()
                     return;
                 }            
             }
+            // Exit all other containers.
             next = m_node->previousSibling();
             while (!next) {
                 if (!m_node->parentNode())