Title: [114718] trunk
- Revision
- 114718
- Author
- [email protected]
- Date
- 2012-04-19 23:18:46 -0700 (Thu, 19 Apr 2012)
Log Message
Inserting empty html moves caret.
https://bugs.webkit.org/show_bug.cgi?id=71771
Patch by Antaryami Pandia <[email protected]> on 2012-04-19
Reviewed by Ryosuke Niwa.
Source/WebCore:
When we place the cursor in the middle of a text node and try to insert some text
between, then we split text node. But in this case we have nothing to insert since
the string to be inserted is empty. So the check for fragments should precedes the
call to code block containing splitTextNode.
Test: editing/inserting/insert-empty-html.html
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::doApply):
LayoutTests:
Test inserting empty html.
* editing/inserting/insert-empty-html-expected.txt: Added.
* editing/inserting/insert-empty-html.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (114717 => 114718)
--- trunk/LayoutTests/ChangeLog 2012-04-20 05:35:07 UTC (rev 114717)
+++ trunk/LayoutTests/ChangeLog 2012-04-20 06:18:46 UTC (rev 114718)
@@ -1,3 +1,15 @@
+2012-04-19 Antaryami Pandia <[email protected]>
+
+ Inserting empty html moves caret.
+ https://bugs.webkit.org/show_bug.cgi?id=71771
+
+ Reviewed by Ryosuke Niwa.
+
+ Test inserting empty html.
+
+ * editing/inserting/insert-empty-html-expected.txt: Added.
+ * editing/inserting/insert-empty-html.html: Added.
+
2012-04-19 Dmitry Titov <[email protected]>
Not reviewed, re-update baselines for new tests
Added: trunk/LayoutTests/editing/inserting/insert-empty-html-expected.txt (0 => 114718)
--- trunk/LayoutTests/editing/inserting/insert-empty-html-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/inserting/insert-empty-html-expected.txt 2012-04-20 06:18:46 UTC (rev 114718)
@@ -0,0 +1,7 @@
+This test ensures inserting empty string does not move the caret.
+
+The caret is placed at 5th pos and the empty html is added. The test passes if the caret is positioned at the same position after the execution insertion command.
+
+abcdefghijklmnopqrstuvwxyz
+PASS window.getSelection().baseOffset is 5
+
Added: trunk/LayoutTests/editing/inserting/insert-empty-html.html (0 => 114718)
--- trunk/LayoutTests/editing/inserting/insert-empty-html.html (rev 0)
+++ trunk/LayoutTests/editing/inserting/insert-empty-html.html 2012-04-20 06:18:46 UTC (rev 114718)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+
+<body>
+<p>This test ensures inserting empty string does not move the caret.</p>
+<p>The caret is placed at 5th pos and the empty html is added. The test passes if the caret is positioned at the same position after the execution insertion command.</p>
+
+<div id="content" contenteditable="true">abcdefghijklmnopqrstuvwxyz</div>
+<div id="console"></div>
+
+<script src=""
+<script>
+
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+
+ var selection = window.getSelection();
+ var div = document.getElementById("content");
+ var text = div.firstChild;
+
+ selection.setPosition(text, 5);
+ document.execCommand('InsertHTML', false, "");
+
+ shouldBe("window.getSelection().baseOffset", "5");
+}
+
+</script>
+
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (114717 => 114718)
--- trunk/Source/WebCore/ChangeLog 2012-04-20 05:35:07 UTC (rev 114717)
+++ trunk/Source/WebCore/ChangeLog 2012-04-20 06:18:46 UTC (rev 114718)
@@ -1,3 +1,20 @@
+2012-04-19 Antaryami Pandia <[email protected]>
+
+ Inserting empty html moves caret.
+ https://bugs.webkit.org/show_bug.cgi?id=71771
+
+ Reviewed by Ryosuke Niwa.
+
+ When we place the cursor in the middle of a text node and try to insert some text
+ between, then we split text node. But in this case we have nothing to insert since
+ the string to be inserted is empty. So the check for fragments should precedes the
+ call to code block containing splitTextNode.
+
+ Test: editing/inserting/insert-empty-html.html
+
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::doApply):
+
2012-04-19 Tay Grigg <[email protected]>
[BlackBerry] Update HTTP connection per host limit in ResourceRequestBlackBerry
Modified: trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp (114717 => 114718)
--- trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2012-04-20 05:35:07 UTC (rev 114717)
+++ trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2012-04-20 06:18:46 UTC (rev 114718)
@@ -918,6 +918,10 @@
bool handledStyleSpans = handleStyleSpansBeforeInsertion(fragment, insertionPos);
+ // We're finished if there is nothing to add.
+ if (fragment.isEmpty() || !fragment.firstChild())
+ return;
+
// If we are not trying to match the destination style we prefer a position
// that is outside inline elements that provide style.
// This way we can produce a less verbose markup.
@@ -940,11 +944,7 @@
// FIXME: When pasting rich content we're often prevented from heading down the fast path by style spans. Try
// again here if they've been removed.
-
- // We're finished if there is nothing to add.
- if (fragment.isEmpty() || !fragment.firstChild())
- return;
-
+
// 1) Insert the content.
// 2) Remove redundant styles and style tags, this inner <b> for example: <b>foo <b>bar</b> baz</b>.
// 3) Merge the start of the added content with the content before the position being pasted into.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes