Reviewed by Ken Kocienda.
authorharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Jan 2005 18:54:59 +0000 (18:54 +0000)
committerharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Jan 2005 18:54:59 +0000 (18:54 +0000)
        <rdar://problem/3905066> REGRESSION (Mail): Hitting return key with caret in front of space causes space to become lost (resize fixes)

        Problem was that InsertParagraphSeparatorCommand::doApply() was not collapsing
        whitespace to a single non-breaking space when splitting a text node.

        * khtml/editing/htmlediting.cpp:
        (khtml::InsertParagraphSeparatorCommand::doApply):

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

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

index 56d1fa073a172f47c65bb25e990277239cdd5845..d79001da66555f1e83b89cb61bd16c98ba26a3ac 100644 (file)
@@ -1,3 +1,16 @@
+2005-01-09  David Harrison  <harrison@apple.com>
+
+        Reviewed by Ken Kocienda.
+
+        <rdar://problem/3905066> REGRESSION (Mail): Hitting return key with caret in front of space causes space to become lost (resize fixes)
+
+
+        Problem was that InsertParagraphSeparatorCommand::doApply() was not collapsing
+        whitespace to a single non-breaking space when splitting a text node.
+
+        * khtml/editing/htmlediting.cpp:
+        (khtml::InsertParagraphSeparatorCommand::doApply):
+
 2005-01-08  Kevin Decker  <kdecker@apple.com>
 
         Reviewed by Ken.
index f8a0d779b6e2dd52942b094795c2f281f3e80752..c7d1858c868701bc47427892f48286bdba672da0 100644 (file)
@@ -2266,6 +2266,7 @@ void InsertParagraphSeparatorCommand::calculateAndSetTypingStyleAfterInsertion()
 
 void InsertParagraphSeparatorCommand::doApply()
 {
+    bool splitText = false;
     Selection selection = endingSelection();
     if (selection.isNone())
         return;
@@ -2391,6 +2392,7 @@ void InsertParagraphSeparatorCommand::doApply()
             applyCommandToComposite(cmd);
             startNode = splitCommand->node();
             pos = Position(startNode, 0);
+            splitText = true;
         }
     }
 
@@ -2440,6 +2442,18 @@ void InsertParagraphSeparatorCommand::doApply()
         leftParent = leftParent->parentNode();
     }
 
+    // Handle whitespace that occurs after the split
+    if (splitText) {
+        document()->updateLayout();
+        pos = Position(blockToInsert, 0);
+        if (!pos.isRenderedCharacter()) {
+            // Clear out all whitespace and insert one non-breaking space
+            ASSERT(startNode && startNode->isTextNode());
+            deleteInsignificantTextDownstream(pos);
+            insertTextIntoNode(static_cast<TextImpl *>(startNode), 0, nonBreakingSpaceString());
+        }
+    }
+
     setEndingSelection(Position(blockToInsert, 0));
     rebalanceWhitespace();
     calculateAndSetTypingStyleAfterInsertion();