Title: [149322] trunk
- Revision
- 149322
- Author
- [email protected]
- Date
- 2013-04-29 15:25:11 -0700 (Mon, 29 Apr 2013)
Log Message
HTML Editing: Insertion point jumps when using link detection
https://bugs.webkit.org/show_bug.cgi?id=82198
Source/WebCore:
Patch by Yi Shen <[email protected]> on 2013-04-29
Reviewed by Ryosuke Niwa.
Add links should be done only when typing a word separator (e.g. space or dot) which
breaks the text into two parts - the link and the rest of the text. Reflected in
code, we should only add link when the caret position is at the right end location of
TextChecking result. Otherwise, the text on the right of a word separator could be
highlighted as a link and the insertion point jumps unexpectedly.
Tests: update editing/inserting/typing-space-to-trigger-smart-link.html
* editing/Editor.cpp:
(WebCore::Editor::markAndReplaceFor):
LayoutTests:
Patch by Yi Shen <[email protected]> on 2013-04-29
Reviewed by Ryosuke Niwa.
Update typing-space-to-trigger-smart-link.html to verify link detection behavior
when typing a link before existing text.
* editing/inserting/typing-space-to-trigger-smart-link-expected.txt:
* editing/inserting/typing-space-to-trigger-smart-link.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (149321 => 149322)
--- trunk/LayoutTests/ChangeLog 2013-04-29 22:19:08 UTC (rev 149321)
+++ trunk/LayoutTests/ChangeLog 2013-04-29 22:25:11 UTC (rev 149322)
@@ -1,3 +1,16 @@
+2013-04-29 Yi Shen <[email protected]>
+
+ HTML Editing: Insertion point jumps when using link detection
+ https://bugs.webkit.org/show_bug.cgi?id=82198
+
+ Reviewed by Ryosuke Niwa.
+
+ Update typing-space-to-trigger-smart-link.html to verify link detection behavior
+ when typing a link before existing text.
+
+ * editing/inserting/typing-space-to-trigger-smart-link-expected.txt:
+ * editing/inserting/typing-space-to-trigger-smart-link.html:
+
2013-04-29 Roger Fong <[email protected]>
Unreviewed. Tests mistakenly added to general TestExpectations file moved to mac TestExpectations file.
Modified: trunk/LayoutTests/editing/inserting/typing-space-to-trigger-smart-link-expected.txt (149321 => 149322)
--- trunk/LayoutTests/editing/inserting/typing-space-to-trigger-smart-link-expected.txt 2013-04-29 22:19:08 UTC (rev 149321)
+++ trunk/LayoutTests/editing/inserting/typing-space-to-trigger-smart-link-expected.txt 2013-04-29 22:25:11 UTC (rev 149322)
@@ -1,2 +1,4 @@
The www.foo.com should be underlined and there is an anchor node created for it.
+The www.bar.com should be underlined and there is an anchor node created for it.
PASS: the anchor for 'www.foo.com' has been created.
+PASS: the anchor for 'www.bar.com' has been created.
Modified: trunk/LayoutTests/editing/inserting/typing-space-to-trigger-smart-link.html (149321 => 149322)
--- trunk/LayoutTests/editing/inserting/typing-space-to-trigger-smart-link.html 2013-04-29 22:19:08 UTC (rev 149321)
+++ trunk/LayoutTests/editing/inserting/typing-space-to-trigger-smart-link.html 2013-04-29 22:25:11 UTC (rev 149322)
@@ -9,16 +9,36 @@
testRunner.setAutomaticLinkDetectionEnabled(true);
}
- var targetDiv = document.getElementById('test');
- var targetText = targetDiv.firstChild;
+ var testTypeSpaceDiv = document.getElementById('testTypeSpace');
+ var targetText = testTypeSpaceDiv.firstChild;
window.getSelection().setPosition(targetText, 15);
pressKey(" ");
- document.getElementById('log').textContent = targetDiv.innerHTML;
var expectedContents = "The <a href="" should be underlined and there is an anchor node created for it.";
- if (expectedContents == targetDiv.innerHTML)
- document.getElementById('log').textContent = "PASS: the anchor for 'www.foo.com' has been created."
+ if (expectedContents == testTypeSpaceDiv.innerHTML)
+ document.getElementById('log').textContent = "PASS: the anchor for 'www.foo.com' has been created.\n"
else
- document.getElementById('log').textContent = "Failed: the expected content was '" + expectedContents + "', but the actual result was '" + targetDiv.innerHTML + "'."
+ document.getElementById('log').textContent = "Failed: the expected content was '" + expectedContents + "', but the actual result was '" + testTypeSpaceDiv.innerHTML + "'.\n"
+
+ var testTypeLinkDiv = document.getElementById('testTypeLink');
+ targetText = testTypeLinkDiv.firstChild;
+ window.getSelection().setPosition(targetText, 4);
+ pressKey("w");
+ pressKey("w");
+ pressKey("w");
+ pressKey(".");
+ pressKey("b");
+ pressKey("a");
+ pressKey("r");
+ pressKey(".");
+ pressKey("c");
+ pressKey("o");
+ pressKey("m");
+ pressKey(" ");
+ expectedContents = "The <a href="" should be underlined and there is an anchor node created for it.";
+ if (expectedContents == testTypeLinkDiv.innerHTML)
+ document.getElementById('log').textContent += "PASS: the anchor for 'www.bar.com' has been created."
+ else
+ document.getElementById('log').textContent += "Failed: the expected content was '" + expectedContents + "', but the actual result was '" + testTypeLinkDiv.innerHTML + "'."
if (window.testRunner)
testRunner.setAutomaticLinkDetectionEnabled(false);
@@ -39,7 +59,8 @@
</script>
</head>
<body>
-<div id="test" contenteditable>The www.foo.comshould be underlined and there is an anchor node created for it.</div>
+<div id="testTypeSpace" contenteditable>The www.foo.comshould be underlined and there is an anchor node created for it.</div>
+<div id="testTypeLink" contenteditable>The should be underlined and there is an anchor node created for it.</div>
<pre id="log"></pre>
</body>
<script>
Modified: trunk/Source/WebCore/ChangeLog (149321 => 149322)
--- trunk/Source/WebCore/ChangeLog 2013-04-29 22:19:08 UTC (rev 149321)
+++ trunk/Source/WebCore/ChangeLog 2013-04-29 22:25:11 UTC (rev 149322)
@@ -1,3 +1,21 @@
+2013-04-29 Yi Shen <[email protected]>
+
+ HTML Editing: Insertion point jumps when using link detection
+ https://bugs.webkit.org/show_bug.cgi?id=82198
+
+ Reviewed by Ryosuke Niwa.
+
+ Add links should be done only when typing a word separator (e.g. space or dot) which
+ breaks the text into two parts - the link and the rest of the text. Reflected in
+ code, we should only add link when the caret position is at the right end location of
+ TextChecking result. Otherwise, the text on the right of a word separator could be
+ highlighted as a link and the insertion point jumps unexpectedly.
+
+ Tests: update editing/inserting/typing-space-to-trigger-smart-link.html
+
+ * editing/Editor.cpp:
+ (WebCore::Editor::markAndReplaceFor):
+
2013-04-29 Beth Dakin <[email protected]>
Need a LayoutMilestone to fire when we have done our first paint after suppressing
Modified: trunk/Source/WebCore/editing/Editor.cpp (149321 => 149322)
--- trunk/Source/WebCore/editing/Editor.cpp 2013-04-29 22:19:08 UTC (rev 149321)
+++ trunk/Source/WebCore/editing/Editor.cpp 2013-04-29 22:25:11 UTC (rev 149322)
@@ -2257,7 +2257,7 @@
RefPtr<Range> rangeToReplace = paragraph.subrange(resultLocation, resultLength);
// adding links should be done only immediately after they are typed
- if (resultType == TextCheckingTypeLink && (selectionOffset > resultEndLocation + 1 || selectionOffset <= resultLocation))
+ if (resultType == TextCheckingTypeLink && selectionOffset != resultEndLocation + 1)
continue;
if (!(shouldPerformReplacement || shouldCheckForCorrection || shouldMarkLink) || !doReplacement)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes