Diff
Modified: trunk/LayoutTests/ChangeLog (115627 => 115628)
--- trunk/LayoutTests/ChangeLog 2012-04-30 13:49:12 UTC (rev 115627)
+++ trunk/LayoutTests/ChangeLog 2012-04-30 13:51:18 UTC (rev 115628)
@@ -1,3 +1,21 @@
+2012-04-30 Yi Shen <[email protected]>
+
+ Inserting a paragraph between quoted lines in editing/deleting/delete-4038408-fix.html doesn't work
+ https://bugs.webkit.org/show_bug.cgi?id=78193
+
+ Reviewed by Ryosuke Niwa.
+
+ When pasting a copied portion of a blockquote with a newline at the end into an unquoted area,
+ the newline is inserted after the blockquote since we don't want it also to be quoted. However,
+ this behavior has also applied when we insert a paragraph between quoted lines, which is incorrect.
+ To figure out the right place to insert a paragraph, we need providing more information to the
+ InsertParagraphSeparatorCommand by introducing a boolean parameter "pasteBlockqutoeIntoUnquotedArea".
+
+ * editing/inserting/insert-paragraph-separator-in-blockquote-expected.txt: Added.
+ * editing/inserting/insert-paragraph-separator-in-blockquote.html: Added.
+ * editing/pasteboard/paste-wrapped-blockquote-into-nonblockquote-expected.txt: Added.
+ * editing/pasteboard/paste-wrapped-blockquote-into-nonblockquote.html: Added.
+
2012-04-30 Antti Koivisto <[email protected]>
Protect current element in HTMLLinkElement::setCSSStyleSheet
Added: trunk/LayoutTests/editing/inserting/insert-paragraph-separator-in-blockquote-expected.txt (0 => 115628)
--- trunk/LayoutTests/editing/inserting/insert-paragraph-separator-in-blockquote-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/inserting/insert-paragraph-separator-in-blockquote-expected.txt 2012-04-30 13:51:18 UTC (rev 115628)
@@ -0,0 +1,12 @@
+This test ensures the paragraph separator inserted between quoted lines inside the blockquote.
+You should see a <br> tag between 'First Line' and 'Second Line'.
+
+| <div>
+| id="testDiv"
+| "First Line"
+| <div>
+| id="testDiv"
+| <#selection-caret>
+| <br>
+| <div>
+| "Second Line"
Added: trunk/LayoutTests/editing/inserting/insert-paragraph-separator-in-blockquote.html (0 => 115628)
--- trunk/LayoutTests/editing/inserting/insert-paragraph-separator-in-blockquote.html (rev 0)
+++ trunk/LayoutTests/editing/inserting/insert-paragraph-separator-in-blockquote.html 2012-04-30 13:51:18 UTC (rev 115628)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+.editing {
+ border: 2px solid red;
+ padding: 12px;
+}
+blockquote {
+ border-left: 2px solid blue;
+ padding: 1em;
+ margin: 0;
+}
+</style>
+
+</head>
+<body>
+<div contenteditable id="topDiv" class="editing">
+<blockquote id="testBQ" style="color:blue;"><div id="testDiv">First Line</div><div>Second Line</div></blockquote>
+</div>
+<script src=""
+<script>
+function pressKey(key)
+{
+ if (window.KeyEvent) {
+ var kbEvent = document.createEvent("KeyboardEvent");
+ kbEvent.initKeyEvent("keypress", true, true, window, 0,0,0,0, 0, key.charCodeAt(0));
+ document.body.dispatchEvent(kbEvent);
+ } else {
+ var kbEvent = document.createEvent("TextEvent");
+ kbEvent.initTextEvent('textInput', true, true, null, key.charAt(0));
+ document.body.dispatchEvent(kbEvent);
+ }
+}
+
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+var topDiv = document.getElementById("topDiv");
+var nodesOfTopDiv = topDiv.childNodes.length;
+var blockquoteElement = document.getElementById("testBQ");
+var nodesOfBlockquote = blockquoteElement.childNodes.length;
+var insertionDiv = document.getElementById("testDiv").firstChild;
+var selection = window.getSelection();
+selection.setPosition(insertionDiv, insertionDiv.textContent.length);
+
+document.execCommand('InsertParagraph', false, null);
+
+Markup.description('This test ensures the paragraph separator inserted between quoted lines inside the blockquote.\n'
++ 'You should see a <br> tag between \'First Line\' and \'Second Line\'.\n');
+Markup.dump('testBQ');
+</script>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/editing/pasteboard/paste-wrapped-blockquote-into-nonblockquote-expected.txt (0 => 115628)
--- trunk/LayoutTests/editing/pasteboard/paste-wrapped-blockquote-into-nonblockquote-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/paste-wrapped-blockquote-into-nonblockquote-expected.txt 2012-04-30 13:51:18 UTC (rev 115628)
@@ -0,0 +1,14 @@
+This test ensures the copied the newline is NOT inside the blockquote -- a '<div><div><br></div></div>' should be appended as the next sibling of the blockquote.
+
+| <div>
+| id="copyDiv"
+| <blockquote>
+| type="cite"
+| <div>
+| "line 1"
+| <div>
+| "line 2"
+| <div>
+| <div>
+| <#selection-caret>
+| <br>
Added: trunk/LayoutTests/editing/pasteboard/paste-wrapped-blockquote-into-nonblockquote.html (0 => 115628)
--- trunk/LayoutTests/editing/pasteboard/paste-wrapped-blockquote-into-nonblockquote.html (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/paste-wrapped-blockquote-into-nonblockquote.html 2012-04-30 13:51:18 UTC (rev 115628)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+blockquote {
+ color: blue;
+ border-left: 2px solid blue;
+ margin: 0px;
+ padding: 0 0 0 20px;
+}
+</style>
+</head>
+<body>
+<div id="pasteDiv" contenteditable="true"></div>
+<div id="copyDiv"><blockquote type='cite'><div>line 1</div><div>line 2</div></blockquote></div>
+<div>line 3</div>
+</body>
+<script src=""
+<script>
+var range = document.createRange();
+var nodeToCopy = document.getElementById("copyDiv");
+range.setStartBefore(nodeToCopy);
+range.setEndAfter(nodeToCopy);
+var selection = window.getSelection();
+selection.addRange(range);
+document.execCommand("Copy");
+
+var pasteNode = document.getElementById("pasteDiv");
+selection.setPosition(pasteNode, 0);
+document.execCommand("Paste");
+Markup.description("This test ensures the copied the newline is NOT inside the blockquote -- a '<div><div><br></div></div>' should be appended as the next sibling of the blockquote. \n");
+Markup.dump('pasteDiv');
+</script>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (115627 => 115628)
--- trunk/Source/WebCore/ChangeLog 2012-04-30 13:49:12 UTC (rev 115627)
+++ trunk/Source/WebCore/ChangeLog 2012-04-30 13:51:18 UTC (rev 115628)
@@ -1,3 +1,32 @@
+2012-04-30 Yi Shen <[email protected]>
+
+ Inserting a paragraph between quoted lines in editing/deleting/delete-4038408-fix.html doesn't work
+ https://bugs.webkit.org/show_bug.cgi?id=78193
+
+ Reviewed by Ryosuke Niwa.
+
+ When pasting a copied portion of a blockquote with a newline at the end into an unquoted area,
+ the newline is inserted after the blockquote since we don't want it also to be quoted. However,
+ this behavior has also applied when we insert a paragraph between quoted lines, which is incorrect.
+ To figure out the right place to insert a paragraph, we need providing more information to the
+ InsertParagraphSeparatorCommand by introducing a boolean parameter "pasteBlockqutoeIntoUnquotedArea".
+
+ Tests: editing/inserting/insert-paragraph-separator-in-blockquote.html
+ editing/pasteboard/paste-wrapped-blockquote-into-nonblockquote.html
+
+ * editing/CompositeEditCommand.cpp:
+ (WebCore::CompositeEditCommand::insertParagraphSeparator):
+ * editing/CompositeEditCommand.h:
+ (CompositeEditCommand):
+ * editing/InsertParagraphSeparatorCommand.cpp:
+ (WebCore::InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand):
+ (WebCore::InsertParagraphSeparatorCommand::doApply):
+ * editing/InsertParagraphSeparatorCommand.h:
+ (WebCore::InsertParagraphSeparatorCommand::create):
+ (InsertParagraphSeparatorCommand):
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::doApply):
+
2012-04-30 Antti Koivisto <[email protected]>
Protect current element in HTMLLinkElement::setCSSStyleSheet
Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (115627 => 115628)
--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2012-04-30 13:49:12 UTC (rev 115627)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2012-04-30 13:51:18 UTC (rev 115628)
@@ -292,9 +292,9 @@
applyCommandToComposite(ApplyStyleCommand::create(element, true));
}
-void CompositeEditCommand::insertParagraphSeparator(bool useDefaultParagraphElement)
+void CompositeEditCommand::insertParagraphSeparator(bool useDefaultParagraphElement, bool pasteBlockqutoeIntoUnquotedArea)
{
- applyCommandToComposite(InsertParagraphSeparatorCommand::create(document(), useDefaultParagraphElement));
+ applyCommandToComposite(InsertParagraphSeparatorCommand::create(document(), useDefaultParagraphElement, pasteBlockqutoeIntoUnquotedArea));
}
void CompositeEditCommand::insertLineBreak()
Modified: trunk/Source/WebCore/editing/CompositeEditCommand.h (115627 => 115628)
--- trunk/Source/WebCore/editing/CompositeEditCommand.h 2012-04-30 13:49:12 UTC (rev 115627)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.h 2012-04-30 13:51:18 UTC (rev 115628)
@@ -109,7 +109,7 @@
void insertNodeAt(PassRefPtr<Node>, const Position&);
void insertNodeAtTabSpanPosition(PassRefPtr<Node>, const Position&);
void insertNodeBefore(PassRefPtr<Node>, PassRefPtr<Node> refChild);
- void insertParagraphSeparator(bool useDefaultParagraphElement = false);
+ void insertParagraphSeparator(bool useDefaultParagraphElement = false, bool pasteBlockqutoeIntoUnquotedArea = false);
void insertLineBreak();
void insertTextIntoNode(PassRefPtr<Text>, unsigned offset, const String& text);
void mergeIdenticalElements(PassRefPtr<Element>, PassRefPtr<Element>);
Modified: trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp (115627 => 115628)
--- trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp 2012-04-30 13:49:12 UTC (rev 115627)
+++ trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp 2012-04-30 13:51:18 UTC (rev 115628)
@@ -58,9 +58,10 @@
return curBlock;
}
-InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand(Document *document, bool mustUseDefaultParagraphElement)
+InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand(Document *document, bool mustUseDefaultParagraphElement, bool pasteBlockqutoeIntoUnquotedArea)
: CompositeEditCommand(document)
, m_mustUseDefaultParagraphElement(mustUseDefaultParagraphElement)
+ , m_pasteBlockqutoeIntoUnquotedArea(pasteBlockqutoeIntoUnquotedArea)
{
}
@@ -226,8 +227,10 @@
} else {
// We can get here if we pasted a copied portion of a blockquote with a newline at the end and are trying to paste it
// into an unquoted area. We then don't want the newline within the blockquote or else it will also be quoted.
- if (Node* highestBlockquote = highestEnclosingNodeOfType(canonicalPos, &isMailBlockquote))
- startBlock = static_cast<Element*>(highestBlockquote);
+ if (m_pasteBlockqutoeIntoUnquotedArea) {
+ if (Node* highestBlockquote = highestEnclosingNodeOfType(canonicalPos, &isMailBlockquote))
+ startBlock = static_cast<Element*>(highestBlockquote);
+ }
// Most of the time we want to stay at the nesting level of the startBlock (e.g., when nesting within lists). However,
// for div nodes, this can result in nested div tags that are hard to break out of.
Modified: trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.h (115627 => 115628)
--- trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.h 2012-04-30 13:49:12 UTC (rev 115627)
+++ trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.h 2012-04-30 13:51:18 UTC (rev 115628)
@@ -34,13 +34,13 @@
class InsertParagraphSeparatorCommand : public CompositeEditCommand {
public:
- static PassRefPtr<InsertParagraphSeparatorCommand> create(Document* document, bool useDefaultParagraphElement = false)
+ static PassRefPtr<InsertParagraphSeparatorCommand> create(Document* document, bool useDefaultParagraphElement = false, bool pasteBlockqutoeIntoUnquotedArea = false)
{
- return adoptRef(new InsertParagraphSeparatorCommand(document, useDefaultParagraphElement));
+ return adoptRef(new InsertParagraphSeparatorCommand(document, useDefaultParagraphElement, pasteBlockqutoeIntoUnquotedArea));
}
private:
- InsertParagraphSeparatorCommand(Document*, bool useDefaultParagraphElement);
+ InsertParagraphSeparatorCommand(Document*, bool useDefaultParagraphElement, bool pasteBlockqutoeIntoUnquotedArea);
virtual void doApply();
@@ -56,6 +56,7 @@
RefPtr<EditingStyle> m_style;
bool m_mustUseDefaultParagraphElement;
+ bool m_pasteBlockqutoeIntoUnquotedArea;
};
}
Modified: trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp (115627 => 115628)
--- trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2012-04-30 13:49:12 UTC (rev 115627)
+++ trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2012-04-30 13:51:18 UTC (rev 115628)
@@ -1077,10 +1077,12 @@
RefPtr<Node> newListItem = createListItemElement(document());
insertNodeAfter(newListItem, enclosingNode);
setEndingSelection(VisiblePosition(firstPositionInNode(newListItem.get())));
- } else
+ } else {
// Use a default paragraph element (a plain div) for the empty paragraph, using the last paragraph
// block's style seems to annoy users.
- insertParagraphSeparator(true);
+ insertParagraphSeparator(true, !startIsInsideMailBlockquote && highestEnclosingNodeOfType(endOfInsertedContent.deepEquivalent(),
+ isMailBlockquote, CannotCrossEditingBoundary, insertedNodes.firstNodeInserted()->parentNode()));
+ }
// Select up to the paragraph separator that was added.
lastPositionToSelect = endingSelection().visibleStart().deepEquivalent();