Reviewed by Darin
authorkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Aug 2004 17:26:02 +0000 (17:26 +0000)
committerkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Aug 2004 17:26:02 +0000 (17:26 +0000)
        Fix for this bug:

        <rdar://problem/3778059> Odd behaviour when editing between blockquote elements

        * khtml/editing/htmlediting_impl.cpp:
        (khtml::CompositeEditCommandImpl::deleteUnrenderedText): This function should not move
        the selection out of the current block, ever. This is exactly what the bug reported.
        What was I thinking? Now, the code looks at the passed-in position and then the equivalent
        upstream and downstream positions to see if the selection can be placed there after the
        delete, and settles on the block containing the passed-in position as a fallback.
        * layout-tests/editing/inserting/insert-3778059-fix-expected.txt: Added.
        * layout-tests/editing/inserting/insert-3778059-fix.html: Added.

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

WebCore/ChangeLog-2005-08-23
WebCore/khtml/editing/htmlediting_impl.cpp

index 7b5a3bda618f5d2ede98ff1f04f94ed2e18ac99d..ab691ccafab98a460ff60f338f0051ee145df69c 100644 (file)
@@ -1,3 +1,20 @@
+2004-08-27  Ken Kocienda  <kocienda@apple.com>
+
+        Reviewed by Darin
+
+        Fix for this bug:
+        
+        <rdar://problem/3778059> Odd behaviour when editing between blockquote elements
+
+        * khtml/editing/htmlediting_impl.cpp:
+        (khtml::CompositeEditCommandImpl::deleteUnrenderedText): This function should not move
+        the selection out of the current block, ever. This is exactly what the bug reported.
+        What was I thinking? Now, the code looks at the passed-in position and then the equivalent
+        upstream and downstream positions to see if the selection can be placed there after the
+        delete, and settles on the block containing the passed-in position as a fallback.
+        * layout-tests/editing/inserting/insert-3778059-fix-expected.txt: Added.
+        * layout-tests/editing/inserting/insert-3778059-fix.html: Added.
+
 2004-08-26  Richard Williamson   <rjw@apple.com>
 
         Boiler plate for canvas gradients and patterns.
index 2e4bb38fd3e697a0c6ddb4f516c42fa4555a6cd5..fa7a7021d2f391b28fa6d4517a0c3239239458eb 100644 (file)
@@ -584,9 +584,9 @@ ElementImpl *CompositeEditCommandImpl::applyTypingStyle(NodeImpl *child) const
 
 void CompositeEditCommandImpl::deleteUnrenderedText(const Position &pos)
 {
-    Position ending = pos.upstream();
     Position upstream = pos.upstream(StayInBlock);
     Position downstream = pos.downstream(StayInBlock);
+    Position block = Position(pos.node()->enclosingBlockFlowElement(), 0);
     
     NodeImpl *node = upstream.node();
     while (node != downstream.node()) {
@@ -611,7 +611,15 @@ void CompositeEditCommandImpl::deleteUnrenderedText(const Position &pos)
                 deleteText(text, 0, text->caretMinOffset());
         }
     }
-    setEndingSelection(ending);
+    
+    if (pos.node()->inDocument())
+        setEndingSelection(pos);
+    else if (upstream.node()->inDocument())
+        setEndingSelection(upstream);
+    else if (downstream.node()->inDocument())
+        setEndingSelection(downstream);
+    else
+        setEndingSelection(block);
 }