Title: [141618] trunk
- Revision
- 141618
- Author
- [email protected]
- Date
- 2013-02-01 11:44:37 -0800 (Fri, 01 Feb 2013)
Log Message
Smart link can erroneously move caret after an URL when typing immediately before it
https://bugs.webkit.org/show_bug.cgi?id=92812
Reviewed by Enrica Casucci.
Source/WebCore:
The bug was caused by smart link being triggered even when a user finished typing a word
immediately before an URL. We already had a logic to avoid smart-linking an URL when the caret
was after the URL but we were missing a check for when the caret is before the URL.
Fixed the bug by adding this check.
Test: editing/inserting/smart-link-when-caret-is-moved-before-URL.html
* editing/Editor.cpp:
(WebCore::Editor::markAndReplaceFor):
LayoutTests:
Add a regression for typing immediately before an URL while smart link is enabled.
WebKit should not be moving the caret erroneously.
* editing/inserting/smart-link-when-caret-is-moved-before-URL-expected.txt: Added.
* editing/inserting/smart-link-when-caret-is-moved-before-URL.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (141617 => 141618)
--- trunk/LayoutTests/ChangeLog 2013-02-01 19:40:32 UTC (rev 141617)
+++ trunk/LayoutTests/ChangeLog 2013-02-01 19:44:37 UTC (rev 141618)
@@ -1,3 +1,16 @@
+2013-02-01 Ryosuke Niwa <[email protected]>
+
+ Smart link can erroneously move caret after an URL when typing immediately before it
+ https://bugs.webkit.org/show_bug.cgi?id=92812
+
+ Reviewed by Enrica Casucci.
+
+ Add a regression for typing immediately before an URL while smart link is enabled.
+ WebKit should not be moving the caret erroneously.
+
+ * editing/inserting/smart-link-when-caret-is-moved-before-URL-expected.txt: Added.
+ * editing/inserting/smart-link-when-caret-is-moved-before-URL.html: Added.
+
2013-02-01 Julien Chaffraix <[email protected]>
[CSS Grid Layout] computePreferredLogicalWidths doesn't handle minmax tracks
Added: trunk/LayoutTests/editing/inserting/smart-link-when-caret-is-moved-before-URL-expected.txt (0 => 141618)
--- trunk/LayoutTests/editing/inserting/smart-link-when-caret-is-moved-before-URL-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/inserting/smart-link-when-caret-is-moved-before-URL-expected.txt 2013-02-01 19:44:37 UTC (rev 141618)
@@ -0,0 +1,10 @@
+This test demonstrates that smart link doesn't erroneously trigger when the user moves the caret immediately before an URL.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+To manually run this test, disable "Check Spelling While Typing" and enable "Smart Link". The caret should be shown immediately after "zz" below:
+
+PASS editor.selectionStart is 3
+PASS editor.selectionEnd is 3
+
Added: trunk/LayoutTests/editing/inserting/smart-link-when-caret-is-moved-before-URL.html (0 => 141618)
--- trunk/LayoutTests/editing/inserting/smart-link-when-caret-is-moved-before-URL.html (rev 0)
+++ trunk/LayoutTests/editing/inserting/smart-link-when-caret-is-moved-before-URL.html 2013-02-01 19:44:37 UTC (rev 141618)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<body>
+<textarea id="editor" cols="50" rows="5">
+</textarea>
+<script src=""
+<script>
+
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.setAutomaticLinkDetectionEnabled(true);
+}
+
+description('This test demonstrates that smart link doesn\'t erroneously trigger when the user moves the caret immediately before an URL.');
+
+debug('To manually run this test, disable "Check Spelling While Typing" and enable "Smart Link". The caret should be shown immediately after "zz" below:');
+debug('');
+
+var editor = document.getElementById('editor');
+editor.focus();
+document.execCommand('InsertText', false, 'http://webkit.org/');
+getSelection().modify('move', 'backward', 'lineBoundary');
+document.execCommand('InsertText', false, 'zz');
+document.execCommand('InsertText', false, ' ');
+
+shouldBe('editor.selectionStart', '3');
+shouldBe('editor.selectionEnd', '3');
+
+editor.style.display = 'none';
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (141617 => 141618)
--- trunk/Source/WebCore/ChangeLog 2013-02-01 19:40:32 UTC (rev 141617)
+++ trunk/Source/WebCore/ChangeLog 2013-02-01 19:44:37 UTC (rev 141618)
@@ -1,3 +1,21 @@
+2013-02-01 Ryosuke Niwa <[email protected]>
+
+ Smart link can erroneously move caret after an URL when typing immediately before it
+ https://bugs.webkit.org/show_bug.cgi?id=92812
+
+ Reviewed by Enrica Casucci.
+
+ The bug was caused by smart link being triggered even when a user finished typing a word
+ immediately before an URL. We already had a logic to avoid smart-linking an URL when the caret
+ was after the URL but we were missing a check for when the caret is before the URL.
+
+ Fixed the bug by adding this check.
+
+ Test: editing/inserting/smart-link-when-caret-is-moved-before-URL.html
+
+ * editing/Editor.cpp:
+ (WebCore::Editor::markAndReplaceFor):
+
2013-02-01 Roger Fong <[email protected]>
Unreviewed. Windows build fix. FloatSize.cpp was not included in the project.
Modified: trunk/Source/WebCore/editing/Editor.cpp (141617 => 141618)
--- trunk/Source/WebCore/editing/Editor.cpp 2013-02-01 19:40:32 UTC (rev 141617)
+++ trunk/Source/WebCore/editing/Editor.cpp 2013-02-01 19:44:37 UTC (rev 141618)
@@ -2137,7 +2137,9 @@
VisibleSelection selectionToReplace(rangeToReplace.get(), DOWNSTREAM);
// adding links should be done only immediately after they are typed
- if (result->type == TextCheckingTypeLink && selectionOffset > resultLocation + resultLength + 1)
+ int resultEnd = resultLocation + resultLength;
+ if (result->type == TextCheckingTypeLink
+ && (selectionOffset > resultEnd + 1 || selectionOffset <= resultLocation))
continue;
if (!(shouldPerformReplacement || shouldCheckForCorrection || shouldMarkLink) || !doReplacement)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes