Title: [118449] trunk
- Revision
- 118449
- Author
- [email protected]
- Date
- 2012-05-24 17:28:53 -0700 (Thu, 24 May 2012)
Log Message
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
Modified: trunk/LayoutTests/ChangeLog (118448 => 118449)
--- trunk/LayoutTests/ChangeLog 2012-05-25 00:15:34 UTC (rev 118448)
+++ trunk/LayoutTests/ChangeLog 2012-05-25 00:28:53 UTC (rev 118449)
@@ -1,3 +1,15 @@
+2012-05-24 Ryosuke Niwa <[email protected]>
+
+ 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.
+
+ 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.
+
2012-05-24 Emil A Eklund <[email protected]>
REGRESSION (115573): Incorrect rounding of margins for floats
Added: trunk/LayoutTests/editing/pasteboard/paste-at-end-of-node-followed-by-inline-element-expected.txt (0 => 118449)
--- trunk/LayoutTests/editing/pasteboard/paste-at-end-of-node-followed-by-inline-element-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/paste-at-end-of-node-followed-by-inline-element-expected.txt 2012-05-25 00:28:53 UTC (rev 118449)
@@ -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"
+| "
+"
Added: trunk/LayoutTests/editing/pasteboard/paste-at-end-of-node-followed-by-inline-element.html (0 => 118449)
--- trunk/LayoutTests/editing/pasteboard/paste-at-end-of-node-followed-by-inline-element.html (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/paste-at-end-of-node-followed-by-inline-element.html 2012-05-25 00:28:53 UTC (rev 118449)
@@ -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: trunk/Source/WebCore/ChangeLog (118448 => 118449)
--- trunk/Source/WebCore/ChangeLog 2012-05-25 00:15:34 UTC (rev 118448)
+++ trunk/Source/WebCore/ChangeLog 2012-05-25 00:28:53 UTC (rev 118449)
@@ -1,3 +1,19 @@
+2012-05-24 Ryosuke Niwa <[email protected]>
+
+ 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.
+
+ 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):
+
2012-05-24 Emil A Eklund <[email protected]>
REGRESSION (115573): Incorrect rounding of margins for floats
Modified: trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp (118448 => 118449)
--- trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2012-05-25 00:15:34 UTC (rev 118448)
+++ trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2012-05-25 00:28:53 UTC (rev 118449)
@@ -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