Reviewed by Darin.
<rdar://problem/
5483567>
REGRESSION (Tiger only, workaround in AppKit on Leopard): Pasting words copied from TextEdit in Mail adds extra newline
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::removeUnrenderedNodes): Added.
(WebCore::ReplaceSelectionCommand::doApply): Call removeUnrenderedNodes
to prevent unrendered spaces from interfering with paragraph merging.
* editing/ReplaceSelectionCommand.h:
LayoutTests:
Reviewed by Darin.
<rdar://problem/
5483567>
REGRESSION (Tiger only, workaround in AppKit on Leopard): Pasting words copied from TextEdit in Mail adds extra newline
Demonstrate fix:
* editing/pasteboard/
5483567.html: Added.
* platform/mac/editing/pasteboard/
5483567-expected.checksum: Added.
* platform/mac/editing/pasteboard/
5483567-expected.png: Added.
* platform/mac/editing/pasteboard/
5483567-expected.txt: Added.
Unrendered nodes removed:
* editing/pasteboard/nested-blocks-with-text-area-expected.txt:
* editing/pasteboard/nested-blocks-with-text-field-expected.txt:
* editing/pasteboard/paste-RTFD-expected.txt:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25721
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-09-25 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by Darin.
+
+ <rdar://problem/5483567>
+ REGRESSION (Tiger only, workaround in AppKit on Leopard): Pasting words copied from TextEdit in Mail adds extra newline
+
+ Demonstrate fix:
+ * editing/pasteboard/5483567.html: Added.
+ * platform/mac/editing/pasteboard/5483567-expected.checksum: Added.
+ * platform/mac/editing/pasteboard/5483567-expected.png: Added.
+ * platform/mac/editing/pasteboard/5483567-expected.txt: Added.
+
+ Unrendered nodes removed:
+ * editing/pasteboard/nested-blocks-with-text-area-expected.txt:
+ * editing/pasteboard/nested-blocks-with-text-field-expected.txt:
+ * editing/pasteboard/paste-RTFD-expected.txt:
+
2007-09-24 Sam Weinig <sam@webkit.org>
Reviewed by Adam Roben.
--- /dev/null
+<div id="div" contenteditable="true">xx</div>
+
+<script>
+text = document.getElementById("div").firstChild;
+window.getSelection().setPosition(text, 1);
+document.execCommand("InsertHTML", false, " <div>foo</div> ");
+</script>
\ No newline at end of file
RenderBlock (anonymous) at (0,90) size 784x0
layer at (313,65) size 161x26
RenderBlock {DIV} at (1,1) size 161x26
- RenderText {#text} at (3,0) size 3x13
- text run at (3,0) width 3: " "
-caret: position 1 of child 0 {#text} of child 3 {SPAN} of child 1 {DIV} of child 4 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 1 of child 0 {#text} of child 2 {SPAN} of child 0 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
RenderBlock (anonymous) at (0,77) size 784x0
layer at (323,67) size 142x13
RenderBlock {DIV} at (3,3) size 142x13
-caret: position 1 of child 0 {#text} of child 3 {SPAN} of child 1 {DIV} of child 4 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 1 of child 0 {#text} of child 2 {SPAN} of child 0 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
RenderBR {BR} at (0,0) size 0x14
RenderBlock (anonymous) at (0,204) size 756x0
RenderBlock {DIV} at (0,260) size 784x0
-caret: position 0 of child 0 {BR} of child 12 {P} of child 4 {DIV} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 0 of child 0 {BR} of child 6 {P} of child 4 {DIV} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
--- /dev/null
+24f895b0fdb8bbe61988189f6e6fe10b
\ No newline at end of file
--- /dev/null
+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 784x18
+ RenderText {#text} at (0,0) size 8x18
+ text run at (0,0) width 8: "x"
+ RenderText {#text} at (8,0) size 21x18
+ text run at (8,0) width 21: "foo"
+ RenderText {#text} at (29,0) size 8x18
+ text run at (29,0) width 8: "x"
+caret: position 3 of child 1 {#text} of child 0 {DIV} of child 0 {BODY} of child 0 {HTML} of document
+2007-09-25 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by Darin.
+
+ <rdar://problem/5483567>
+ REGRESSION (Tiger only, workaround in AppKit on Leopard): Pasting words copied from TextEdit in Mail adds extra newline
+
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::removeUnrenderedNodes): Added.
+ (WebCore::ReplaceSelectionCommand::doApply): Call removeUnrenderedNodes
+ to prevent unrendered spaces from interfering with paragraph merging.
+ * editing/ReplaceSelectionCommand.h:
+
2007-09-24 Steve Falkenburg <sfalken@apple.com>
Reviewed by Darin.
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
- compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
knownRegions = (
English,
}
}
+// Removes unrendered nodes after insertion but before paragraph merging. Fixed <rdar://problem/5483567>,
+// where unrendered whitespace before and after the incoming fragment would prevent paragraph merging.
+void ReplaceSelectionCommand::removeUnrenderedNodes()
+{
+ RefPtr<Node> next;
+ for (RefPtr<Node> node = m_firstNodeInserted; node; node = next) {
+
+ next = node->traverseNextNode();
+
+ if (node == m_lastLeafInserted)
+ next = 0;
+
+ if (node->hasTagName(selectTag))
+ next = node->traverseNextSibling();
+
+ if (node->renderer())
+ continue;
+
+ RefPtr<Node> afterFirst = m_firstNodeInserted ? m_firstNodeInserted->traverseNextSibling() : 0;
+ RefPtr<Node> beforeLast = m_lastLeafInserted ? m_lastLeafInserted->traversePreviousNode() : 0;
+
+ removeNode(node.get());
+
+ if (m_lastLeafInserted && !m_lastLeafInserted->inDocument())
+ m_lastLeafInserted = beforeLast;
+ if (m_firstNodeInserted && !m_firstNodeInserted->inDocument())
+ m_firstNodeInserted = m_lastLeafInserted && m_lastLeafInserted->inDocument() ? afterFirst : 0;
+ }
+}
+
void ReplaceSelectionCommand::handlePasteAsQuotationNode()
{
Node* node = m_firstNodeInserted.get();
removeRedundantStyles(mailBlockquoteEnclosingSelectionStart);
+ removeUnrenderedNodes();
+
if (!m_firstNodeInserted)
return;
void negateStyleRulesThatAffectAppearance();
void removeRedundantStyles(Node*);
+ void removeUnrenderedNodes();
void handlePasteAsQuotationNode();