Title: [118813] branches/chromium/1132
- Revision
- 118813
- Author
- [email protected]
- Date
- 2012-05-29 11:42:23 -0700 (Tue, 29 May 2012)
Log Message
Merge 118449 - REGRESSION (r112399): insertHTML doesn't respect current selection range and inserts HTML to incorrect position
https://bugs.webkit.org/show_bug.cgi?id=87195
Reviewed by Darin Adler.
Source/WebCore:
The bug was caused by our passing insertionPos.anchorNode() to splitTreeToNode's start node even when
the position's type was an offset in a container. Fixed the bug by passing the node after the insert position
or the container node if the position is at the end of the container.
Test: editing/pasteboard/paste-at-end-of-node-followed-by-inline-element.html
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::doApply):
LayoutTests:
Add a regression test.
* editing/pasteboard/paste-at-end-of-node-followed-by-inline-element-expected.txt: Added.
* editing/pasteboard/paste-at-end-of-node-followed-by-inline-element.html: Added.
Modified Paths
Added Paths
Diff
Copied: branches/chromium/1132/LayoutTests/editing/pasteboard/paste-at-end-of-node-followed-by-inline-element-expected.txt (from rev 118449, trunk/LayoutTests/editing/pasteboard/paste-at-end-of-node-followed-by-inline-element-expected.txt) (0 => 118813)
--- branches/chromium/1132/LayoutTests/editing/pasteboard/paste-at-end-of-node-followed-by-inline-element-expected.txt (rev 0)
+++ branches/chromium/1132/LayoutTests/editing/pasteboard/paste-at-end-of-node-followed-by-inline-element-expected.txt 2012-05-29 18:42:23 UTC (rev 118813)
@@ -0,0 +1,9 @@
+This tests inserting a text in the middle of a text node. You should see "1 Two 3" below.
+| <b>
+| "1 "
+| "Two<#selection-caret>"
+| <b>
+| <i>
+| " 3"
+| "
+"
Copied: branches/chromium/1132/LayoutTests/editing/pasteboard/paste-at-end-of-node-followed-by-inline-element.html (from rev 118449, trunk/LayoutTests/editing/pasteboard/paste-at-end-of-node-followed-by-inline-element.html) (0 => 118813)
--- branches/chromium/1132/LayoutTests/editing/pasteboard/paste-at-end-of-node-followed-by-inline-element.html (rev 0)
+++ branches/chromium/1132/LayoutTests/editing/pasteboard/paste-at-end-of-node-followed-by-inline-element.html 2012-05-29 18:42:23 UTC (rev 118813)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests inserting a text in the middle of a text node. You should see "1 Two 3" below.</p>
+<pre id="test" contentEditable="true" style="border:1px solid black">
+<b>1 <i>2 3</i></b>
+</pre>
+<script src=""
+<script>
+getSelection().selectAllChildren(document.querySelector('i'));
+var text = document.querySelector('i').firstChild;
+getSelection().setBaseAndExtent(text, 0, text, 1);
+document.execCommand('InsertHtml', false, 'Two');
+
+Markup.description(document.getElementById('description').textContent);
+Markup.dump('test');
+
+</script>
+</body>
+</html>
Modified: branches/chromium/1132/Source/WebCore/editing/ReplaceSelectionCommand.cpp (118812 => 118813)
--- branches/chromium/1132/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2012-05-29 18:42:01 UTC (rev 118812)
+++ branches/chromium/1132/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2012-05-29 18:42:23 UTC (rev 118813)
@@ -936,7 +936,10 @@
if (RefPtr<Node> nodeToSplitTo = nodeToSplitToAvoidPastingIntoInlineNodesWithStyle(insertionPos)) {
if (insertionPos.containerNode() != nodeToSplitTo->parentNode()) {
- nodeToSplitTo = splitTreeToNode(insertionPos.anchorNode(), nodeToSplitTo->parentNode()).get();
+ Node* splitStart = insertionPos.computeNodeAfterPosition();
+ if (!splitStart)
+ splitStart = insertionPos.containerNode();
+ nodeToSplitTo = splitTreeToNode(splitStart, nodeToSplitTo->parentNode()).get();
insertionPos = positionInParentBeforeNode(nodeToSplitTo.get());
}
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes