WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Proposed patch
chromium-spelling.patch (text/plain), 58.04 KB, created by
Rouslan Solomakhin
on 2013-01-23 12:12:13 PST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Rouslan Solomakhin
Created:
2013-01-23 12:12:13 PST
Size:
58.04 KB
patch
obsolete
> ><!-- saved from url=(0065)https://codereview.chromium.org/download/issue11976003_20025.diff --> ><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Index: LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word-expected.txt >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word-expected.txt b/LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..3e01edf0a5ec77ebbd656f14d77ca50efbb994f0 >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word-expected.txt >@@ -0,0 +1,15 @@ >+Spelling should work for double-clicked misspellings. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "" >+PASS window.getSelection().toString() is "wellcome" >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "wellcome" >+PASS contextMenuElements[contextMenuElements.length - 1] is "welcome" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+wellcome home. >Index: LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word-with-underscores-expected.txt >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word-with-underscores-expected.txt b/LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word-with-underscores-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..e634e8a95cde8c76e4ee8f938750e86947157266 >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word-with-underscores-expected.txt >@@ -0,0 +1,15 @@ >+Spelling should work for double-clicked misspelled words with underscores. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "" >+PASS window.getSelection().toString() is "wellcome_" >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "wellcome_" >+PASS contextMenuElements[contextMenuElements.length - 1] is "welcome" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+wellcome_ home. >Index: LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word-with-underscores.html >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word-with-underscores.html b/LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word-with-underscores.html >new file mode 100644 >index 0000000000000000000000000000000000000000..cb95f9d81e7279bade3a966a2b3c2bdc1ce5e23a >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word-with-underscores.html >@@ -0,0 +1,81 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../../fast/js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<div id="container"> >+ <div id="destination" contentEditable></div> >+</div> >+ >+<script> >+ >+function done() >+{ >+ testRunner.setAsynchronousSpellCheckingEnabled(false); >+ internals.settings.setUnifiedTextCheckerEnabled(false); >+ finishJSTest() >+} >+ >+function verify(nretry) >+{ >+ if (!nretry) { >+ done(); >+ return; >+ } >+ >+ if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) { >+ window.setTimeout(function() { verify(nretry - 1); }, 0); >+ return; >+ } >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", ""); >+ >+ // Double-click the misspelled word. >+ var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40; >+ var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ eventSender.mouseDown(); >+ eventSender.mouseUp(); >+ eventSender.mouseDown(); >+ eventSender.mouseUp(); >+ >+ shouldBeEqualToString("window.getSelection().toString()", "wellcome_"); >+ >+ // Context click on "wellcome" to show the context menu. >+ x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40; >+ y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ contextMenuElements = eventSender.contextClick(); >+ // Esc key to hide the context menu. >+ eventSender.keyDown(String.fromCharCode(0x001B), null); >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", "wellcome_"); >+ shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome"); >+ >+ done(); >+} >+ >+function test() >+{ >+ jsTestIsAsync = true; >+ internals.settings.setUnifiedTextCheckerEnabled(true); >+ testRunner.setAsynchronousSpellCheckingEnabled(true); >+ var destination = document.getElementById("destination"); >+ destination.focus(); >+ document.execCommand("InsertText", false, "wellcome_ home."); >+ window.setTimeout(function() { verify(10); }, 0); >+} >+ >+description("Spelling should work for double-clicked misspelled words with underscores."); >+if (window.internals) >+ test(); >+ >+</script> >+<script src="../../../../fast/js/resources/js-test-post.js"></script> >+</body> >+</html> >Index: LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word.html >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word.html b/LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word.html >new file mode 100644 >index 0000000000000000000000000000000000000000..33e5a81cdc9577803627f2b82eaf1da3d2150668 >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-double-clicked-word.html >@@ -0,0 +1,81 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../../fast/js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<div id="container"> >+ <div id="destination" contentEditable></div> >+</div> >+ >+<script> >+ >+function done() >+{ >+ testRunner.setAsynchronousSpellCheckingEnabled(false); >+ internals.settings.setUnifiedTextCheckerEnabled(false); >+ finishJSTest() >+} >+ >+function verify(nretry) >+{ >+ if (!nretry) { >+ done(); >+ return; >+ } >+ >+ if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) { >+ window.setTimeout(function() { verify(nretry - 1); }, 0); >+ return; >+ } >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", ""); >+ >+ // Double-click the misspelled word. >+ var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40; >+ var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ eventSender.mouseDown(); >+ eventSender.mouseUp(); >+ eventSender.mouseDown(); >+ eventSender.mouseUp(); >+ >+ shouldBeEqualToString("window.getSelection().toString()", "wellcome"); >+ >+ // Context click on "wellcome" to show the context menu. >+ x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40; >+ y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ contextMenuElements = eventSender.contextClick(); >+ // Esc key to hide the context menu. >+ eventSender.keyDown(String.fromCharCode(0x001B), null); >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", "wellcome"); >+ shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome"); >+ >+ done(); >+} >+ >+function test() >+{ >+ jsTestIsAsync = true; >+ internals.settings.setUnifiedTextCheckerEnabled(true); >+ testRunner.setAsynchronousSpellCheckingEnabled(true); >+ var destination = document.getElementById("destination"); >+ destination.focus(); >+ document.execCommand("InsertText", false, "wellcome home."); >+ window.setTimeout(function() { verify(10); }, 0); >+} >+ >+description("Spelling should work for double-clicked misspellings."); >+if (window.internals) >+ test(); >+ >+</script> >+<script src="../../../../fast/js/resources/js-test-post.js"></script> >+</body> >+</html> >Index: LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-multiple-words-expected.txt >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-multiple-words-expected.txt b/LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-multiple-words-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..a7512ddc73b0381984145c9e79d4ffdaaaccbf66 >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-multiple-words-expected.txt >@@ -0,0 +1,14 @@ >+Spelling should work when the user selects a multi-word misspelling exactly. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS spellingMarkerRange.toString() is "upper case" >+PASS window.getSelection().toString() is "" >+PASS window.getSelection().toString() is "upper case" >+PASS spellingMarkerRange.toString() is "upper case" >+PASS window.getSelection().toString() is "upper case" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+It should be upper case. >Index: LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-multiple-words.html >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-multiple-words.html b/LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-multiple-words.html >new file mode 100644 >index 0000000000000000000000000000000000000000..9f3571c2c79e83266c5ea0ec82af863dae780957 >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-multiple-words.html >@@ -0,0 +1,65 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../../fast/js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<div id="container"> >+ <div id="destination" contentEditable></div> >+</div> >+<script> >+ >+function test() >+{ >+ jsTestIsAsync = true; >+ internals.settings.setUnifiedTextCheckerEnabled(true); >+ testRunner.setAsynchronousSpellCheckingEnabled(true); >+ >+ var destination = document.getElementById("destination"); >+ destination.focus(); >+ document.execCommand("InsertText", false, "It should be upper case."); >+ >+ // Inject a multi-word misspelling. >+ var range = document.createRange(); >+ range.setStart(destination.childNodes[0], 13); >+ range.setEnd(destination.childNodes[0], 23); >+ window.internals.addSpellingMarker(range); >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "upper case"); >+ shouldBeEqualToString("window.getSelection().toString()", ""); >+ >+ // Select the multi-word misspelling without surrounding whitespace or punctuation. >+ window.getSelection().removeAllRanges(); >+ var wordRange = document.createRange(); >+ wordRange.setStart(destination.childNodes[0], 13); >+ wordRange.setEnd(destination.childNodes[0], 23); >+ window.getSelection().addRange(wordRange); >+ >+ shouldBeEqualToString("window.getSelection().toString()", "upper case"); >+ >+ // Context click on "upper case" to show the context menu. >+ var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 100; >+ var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ contextMenuElements = eventSender.contextClick(); >+ // Esc key to hide the context menu. >+ eventSender.keyDown(String.fromCharCode(0x001B), null); >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "upper case"); >+ shouldBeEqualToString("window.getSelection().toString()", "upper case"); >+ >+ testRunner.setAsynchronousSpellCheckingEnabled(false); >+ internals.settings.setUnifiedTextCheckerEnabled(false); >+ finishJSTest() >+} >+ >+description("Spelling should work when the user selects a multi-word misspelling exactly."); >+if (window.internals) >+ test(); >+ >+</script> >+<script src="../../../../fast/js/resources/js-test-post.js"></script> >+</body> >+</html> >Index: LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-word-expected.txt >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-word-expected.txt b/LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-word-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..eb65bb4a4b5d5d034c5b6df1d17f0077b4a5334c >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-word-expected.txt >@@ -0,0 +1,17 @@ >+Spelling should work when the user selects the misspelled word exactly. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "wellcome" >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "wellcome" >+PASS contextMenuElements[contextMenuElements.length - 1] is "welcome" >+PASS window.getSelection().toString() is "home" >+PASS window.getSelection().toString() is "home" >+PASS contextMenuElements[contextMenuElements.length - 1] is "<separator>" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+wellcome home. >Index: LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-word.html >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-word.html b/LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-word.html >new file mode 100644 >index 0000000000000000000000000000000000000000..6ae48147017081ccbb0d9f8aa6f765f883e5ab76 >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-exactly-selected-word.html >@@ -0,0 +1,94 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../../fast/js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<div id="container"> >+ <div id="destination" contentEditable></div> >+</div> >+ >+<script> >+ >+function done() >+{ >+ testRunner.setAsynchronousSpellCheckingEnabled(false); >+ internals.settings.setUnifiedTextCheckerEnabled(false); >+ finishJSTest() >+} >+ >+function verify(nretry) >+{ >+ if (!nretry) { >+ done(); >+ return; >+ } >+ >+ if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) { >+ window.setTimeout(function() { verify(nretry - 1); }, 0); >+ return; >+ } >+ >+ // Select the misspelled word without surrounding whitespace or punctuation. >+ window.getSelection().removeAllRanges(); >+ var wordRange = document.createRange(); >+ wordRange.setStart(destination.childNodes[0], 0); >+ wordRange.setEnd(destination.childNodes[0], 8); >+ window.getSelection().addRange(wordRange); >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", "wellcome"); >+ >+ // Context click on "wellcome" to show the context menu. >+ var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40; >+ var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ contextMenuElements = eventSender.contextClick(); >+ // Esc key to hide the context menu. >+ eventSender.keyDown(String.fromCharCode(0x001B), null); >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", "wellcome"); >+ shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome"); >+ >+ window.getSelection().removeAllRanges(); >+ wordRange.setStart(destination.childNodes[0], 9); >+ wordRange.setEnd(destination.childNodes[0], 13); >+ window.getSelection().addRange(wordRange); >+ shouldBeEqualToString("window.getSelection().toString()", "home"); >+ >+ // Context click on "home" to show the context menu. >+ var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 80; >+ var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ contextMenuElements = eventSender.contextClick(); >+ // Esc key to hide the context menu. >+ eventSender.keyDown(String.fromCharCode(0x001B), null); >+ >+ shouldBeEqualToString("window.getSelection().toString()", "home"); >+ shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "<separator>"); >+ >+ done(); >+} >+ >+function test() >+{ >+ jsTestIsAsync = true; >+ internals.settings.setUnifiedTextCheckerEnabled(true); >+ testRunner.setAsynchronousSpellCheckingEnabled(true); >+ var destination = document.getElementById("destination"); >+ destination.focus(); >+ document.execCommand("InsertText", false, "wellcome home."); >+ window.setTimeout(function() { verify(10); }, 0); >+} >+ >+description("Spelling should work when the user selects the misspelled word exactly."); >+if (window.internals) >+ test(); >+ >+</script> >+<script src="../../../../fast/js/resources/js-test-post.js"></script> >+</body> >+</html> >Index: LayoutTests/platform/chromium/editing/spelling/spelling-multiword-selection-expected.txt >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-multiword-selection-expected.txt b/LayoutTests/platform/chromium/editing/spelling/spelling-multiword-selection-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..1b5aec7317a67522aa244cc7cc390798670bbfe0 >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-multiword-selection-expected.txt >@@ -0,0 +1,15 @@ >+Spelling should be disabled when user selects multiple words that are not a single misspelling. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "" >+PASS window.getSelection().toString() is "wellcome home" >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "wellcome home" >+PASS contextMenuElements[contextMenuElements.length - 1] is "<separator>" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+wellcome home. >Index: LayoutTests/platform/chromium/editing/spelling/spelling-multiword-selection.html >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-multiword-selection.html b/LayoutTests/platform/chromium/editing/spelling/spelling-multiword-selection.html >new file mode 100644 >index 0000000000000000000000000000000000000000..714bc0cdc96d28c6801bda7614439350aca3fd9e >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-multiword-selection.html >@@ -0,0 +1,78 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../../fast/js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<div id="container"> >+ <div id="destination" contentEditable></div> >+</div> >+ >+<script> >+ >+function done() >+{ >+ testRunner.setAsynchronousSpellCheckingEnabled(false); >+ internals.settings.setUnifiedTextCheckerEnabled(false); >+ finishJSTest() >+} >+ >+function verify(nretry) >+{ >+ if (!nretry) { >+ done(); >+ return; >+ } >+ >+ if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) { >+ window.setTimeout(function() { verify(nretry - 1); }, 0); >+ return; >+ } >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", ""); >+ >+ window.getSelection().removeAllRanges(); >+ var multiWordRange = document.createRange(); >+ multiWordRange.setStart(destination.childNodes[0], 0); >+ multiWordRange.setEnd(destination.childNodes[0], 13); >+ window.getSelection().addRange(multiWordRange); >+ >+ shouldBeEqualToString("window.getSelection().toString()", "wellcome home"); >+ >+ // Context click to show the context menu. >+ var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40; >+ var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ contextMenuElements = eventSender.contextClick(); >+ // Esc key to hide the context menu. >+ eventSender.keyDown(String.fromCharCode(0x001B), null); >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", "wellcome home"); >+ shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "<separator>"); >+ >+ done(); >+} >+ >+function test() >+{ >+ jsTestIsAsync = true; >+ internals.settings.setUnifiedTextCheckerEnabled(true); >+ testRunner.setAsynchronousSpellCheckingEnabled(true); >+ var destination = document.getElementById("destination"); >+ destination.focus(); >+ document.execCommand("InsertText", false, "wellcome home."); >+ window.setTimeout(function() { verify(10); }, 0); >+} >+ >+description("Spelling should be disabled when user selects multiple words that are not a single misspelling."); >+if (window.internals) >+ test(); >+ >+</script> >+<script src="../../../../fast/js/resources/js-test-post.js"></script> >+</body> >+</html> >Index: LayoutTests/platform/chromium/editing/spelling/spelling-should-select-multiple-words-expected.txt >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-should-select-multiple-words-expected.txt b/LayoutTests/platform/chromium/editing/spelling/spelling-should-select-multiple-words-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..17798efb8dd52e3b9dae85ffea43c8de3a1c308c >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-should-select-multiple-words-expected.txt >@@ -0,0 +1,13 @@ >+Chrome should select multi-word misspellings on context click. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS spellingMarkerRange.toString() is "upper case" >+PASS window.getSelection().toString() is "" >+PASS spellingMarkerRange.toString() is "upper case" >+PASS window.getSelection().toString() is "upper case" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+It should be upper case. >Index: LayoutTests/platform/chromium/editing/spelling/spelling-should-select-multiple-words.html >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-should-select-multiple-words.html b/LayoutTests/platform/chromium/editing/spelling/spelling-should-select-multiple-words.html >new file mode 100644 >index 0000000000000000000000000000000000000000..b0076f90009f5ec689f2ce044149d7d6eb8a6d5a >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-should-select-multiple-words.html >@@ -0,0 +1,56 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../../fast/js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<div id="container"> >+ <div id="destination" contentEditable></div> >+</div> >+<script> >+ >+function test() >+{ >+ jsTestIsAsync = true; >+ internals.settings.setUnifiedTextCheckerEnabled(true); >+ testRunner.setAsynchronousSpellCheckingEnabled(true); >+ >+ var destination = document.getElementById("destination"); >+ destination.focus(); >+ document.execCommand("InsertText", false, "It should be upper case."); >+ >+ // Inject a multi-word misspelling. >+ var range = document.createRange(); >+ range.setStart(destination.childNodes[0], 13); >+ range.setEnd(destination.childNodes[0], 23); >+ window.internals.addSpellingMarker(range); >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "upper case"); >+ shouldBeEqualToString("window.getSelection().toString()", ""); >+ >+ // Context click on "upper case" to show the context menu. >+ var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 100; >+ var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ contextMenuElements = eventSender.contextClick(); >+ // Esc key to hide the context menu. >+ eventSender.keyDown(String.fromCharCode(0x001B), null); >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "upper case"); >+ shouldBeEqualToString("window.getSelection().toString()", "upper case"); >+ >+ testRunner.setAsynchronousSpellCheckingEnabled(false); >+ internals.settings.setUnifiedTextCheckerEnabled(false); >+ finishJSTest() >+} >+ >+description("Chrome should select multi-word misspellings on context click."); >+if (window.internals) >+ test(); >+ >+</script> >+<script src="../../../../fast/js/resources/js-test-post.js"></script> >+</body> >+</html> >Index: LayoutTests/platform/chromium/editing/spelling/spelling-should-select-single-word-expected.txt >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-should-select-single-word-expected.txt b/LayoutTests/platform/chromium/editing/spelling/spelling-should-select-single-word-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..a12b41d1a46b00cde6f8eb702ae92f0db7642e65 >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-should-select-single-word-expected.txt >@@ -0,0 +1,17 @@ >+Chrome selects the misspelled word on context click. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "" >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "wellcome" >+PASS contextMenuElements[contextMenuElements.length - 1] is "welcome" >+PASS window.getSelection().toString() is "" >+PASS window.getSelection().toString() is "" >+PASS contextMenuElements[contextMenuElements.length - 1] is "<separator>" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+wellcome home. >Index: LayoutTests/platform/chromium/editing/spelling/spelling-should-select-single-word.html >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-should-select-single-word.html b/LayoutTests/platform/chromium/editing/spelling/spelling-should-select-single-word.html >new file mode 100644 >index 0000000000000000000000000000000000000000..f6b67811c91ab4dd41684947c2321da939e51d24 >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-should-select-single-word.html >@@ -0,0 +1,84 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../../fast/js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<div id="container"> >+ <div id="destination" contentEditable></div> >+</div> >+ >+<script> >+ >+function done() >+{ >+ testRunner.setAsynchronousSpellCheckingEnabled(false); >+ internals.settings.setUnifiedTextCheckerEnabled(false); >+ finishJSTest() >+} >+ >+function verify(nretry) >+{ >+ if (!nretry) { >+ done(); >+ return; >+ } >+ >+ if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) { >+ window.setTimeout(function() { verify(nretry - 1); }, 0); >+ return; >+ } >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", ""); >+ >+ // Context click on "wellcome" to show the context menu. >+ var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40; >+ var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ contextMenuElements = eventSender.contextClick(); >+ // Esc key to hide the context menu. >+ eventSender.keyDown(String.fromCharCode(0x001B), null); >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", "wellcome"); >+ shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome"); >+ >+ window.getSelection().removeAllRanges(); >+ shouldBeEqualToString("window.getSelection().toString()", ""); >+ >+ // Context click on "home" to show the context menu. >+ var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 80; >+ var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ contextMenuElements = eventSender.contextClick(); >+ // Esc key to hide the context menu. >+ eventSender.keyDown(String.fromCharCode(0x001B), null); >+ >+ shouldBeEqualToString("window.getSelection().toString()", ""); >+ shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "<separator>"); >+ >+ done(); >+} >+ >+function test() >+{ >+ jsTestIsAsync = true; >+ internals.settings.setUnifiedTextCheckerEnabled(true); >+ testRunner.setAsynchronousSpellCheckingEnabled(true); >+ var destination = document.getElementById("destination"); >+ destination.focus(); >+ document.execCommand("InsertText", false, "wellcome home."); >+ window.setTimeout(function() { verify(10); }, 0); >+} >+ >+description("Chrome selects the misspelled word on context click."); >+if (window.internals) >+ test(); >+ >+</script> >+<script src="../../../../fast/js/resources/js-test-post.js"></script> >+</body> >+</html> >Index: LayoutTests/platform/chromium/editing/spelling/spelling-subword-selection-expected.txt >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-subword-selection-expected.txt b/LayoutTests/platform/chromium/editing/spelling/spelling-subword-selection-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..197fc1f1ac9464277343d5bd43701bebb80afa77 >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-subword-selection-expected.txt >@@ -0,0 +1,15 @@ >+Spelling should be disabled when user selects a part of misspelling. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "" >+PASS window.getSelection().toString() is "llco" >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "llco" >+PASS contextMenuElements[contextMenuElements.length - 1] is "<separator>" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+wellcome home. >Index: LayoutTests/platform/chromium/editing/spelling/spelling-subword-selection.html >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-subword-selection.html b/LayoutTests/platform/chromium/editing/spelling/spelling-subword-selection.html >new file mode 100644 >index 0000000000000000000000000000000000000000..0571a8d427e1d66313ddf0721fb184a6962a55ec >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-subword-selection.html >@@ -0,0 +1,77 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../../fast/js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<div id="container"> >+ <div id="destination" contentEditable></div> >+</div> >+ >+<script> >+ >+function done() >+{ >+ testRunner.setAsynchronousSpellCheckingEnabled(false); >+ internals.settings.setUnifiedTextCheckerEnabled(false); >+ finishJSTest() >+} >+ >+function verify(nretry) >+{ >+ if (!nretry) { >+ done(); >+ return; >+ } >+ >+ if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) { >+ window.setTimeout(function() { verify(nretry - 1); }, 0); >+ return; >+ } >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", ""); >+ >+ window.getSelection().removeAllRanges(); >+ var subWordRange = document.createRange(); >+ subWordRange.setStart(destination.childNodes[0], 2); >+ subWordRange.setEnd(destination.childNodes[0], 6); >+ window.getSelection().addRange(subWordRange); >+ shouldBeEqualToString("window.getSelection().toString()", "llco"); >+ >+ // Context click to show the context menu. >+ var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40; >+ var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ contextMenuElements = eventSender.contextClick(); >+ // Esc key to hide the context menu. >+ eventSender.keyDown(String.fromCharCode(0x001B), null); >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", "llco"); >+ shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "<separator>"); >+ >+ done(); >+} >+ >+function test() >+{ >+ jsTestIsAsync = true; >+ internals.settings.setUnifiedTextCheckerEnabled(true); >+ testRunner.setAsynchronousSpellCheckingEnabled(true); >+ var destination = document.getElementById("destination"); >+ destination.focus(); >+ document.execCommand("InsertText", false, "wellcome home."); >+ window.setTimeout(function() { verify(10); }, 0); >+} >+ >+description("Spelling should be disabled when user selects a part of misspelling."); >+if (window.internals) >+ test(); >+ >+</script> >+<script src="../../../../fast/js/resources/js-test-post.js"></script> >+</body> >+</html> >Index: LayoutTests/platform/chromium/editing/spelling/spelling-with-punctuation-selection-expected.txt >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-with-punctuation-selection-expected.txt b/LayoutTests/platform/chromium/editing/spelling/spelling-with-punctuation-selection-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..3698902ef59e3b68c4ab88a06e1818e573f10b9b >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-with-punctuation-selection-expected.txt >@@ -0,0 +1,15 @@ >+Punctuation marks should be treated as whitespace: spelling should ignore them. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "" >+PASS window.getSelection().toString() is "wellcome!" >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "wellcome!" >+PASS contextMenuElements[contextMenuElements.length - 1] is "welcome" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+wellcome! >Index: LayoutTests/platform/chromium/editing/spelling/spelling-with-punctuation-selection.html >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-with-punctuation-selection.html b/LayoutTests/platform/chromium/editing/spelling/spelling-with-punctuation-selection.html >new file mode 100644 >index 0000000000000000000000000000000000000000..fd0aa4605fb2160bbec94c35c64fb1220ca0a288 >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-with-punctuation-selection.html >@@ -0,0 +1,76 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../../fast/js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<div id="container"> >+ <div id="destination" contentEditable></div> >+</div> >+ >+<script> >+ >+function done() >+{ >+ testRunner.setAsynchronousSpellCheckingEnabled(false); >+ internals.settings.setUnifiedTextCheckerEnabled(false); >+ finishJSTest() >+} >+ >+function verify(nretry) >+{ >+ if (!nretry) { >+ done(); >+ return; >+ } >+ >+ if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) { >+ window.setTimeout(function() { verify(nretry - 1); }, 0); >+ return; >+ } >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", ""); >+ >+ var range = document.createRange(); >+ range.setStart(destination.childNodes[0], 0); >+ range.setEnd(destination.childNodes[0], 9); >+ window.getSelection().addRange(range); >+ shouldBeEqualToString("window.getSelection().toString()", "wellcome!"); >+ >+ // Context click to show the context menu. >+ var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40; >+ var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ contextMenuElements = eventSender.contextClick(); >+ // Esc key to hide the context menu. >+ eventSender.keyDown(String.fromCharCode(0x001B), null); >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", "wellcome!"); >+ shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome"); >+ >+ done(); >+} >+ >+function test() >+{ >+ jsTestIsAsync = true; >+ internals.settings.setUnifiedTextCheckerEnabled(true); >+ testRunner.setAsynchronousSpellCheckingEnabled(true); >+ var destination = document.getElementById("destination"); >+ destination.focus(); >+ document.execCommand("InsertText", false, "wellcome!"); >+ window.setTimeout(function() { verify(10); }, 0); >+} >+ >+description("Punctuation marks should be treated as whitespace: spelling should ignore them."); >+if (window.internals) >+ test(); >+ >+</script> >+<script src="../../../../fast/js/resources/js-test-post.js"></script> >+</body> >+</html> >Index: LayoutTests/platform/chromium/editing/spelling/spelling-with-underscore-selection-expected.txt >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-with-underscore-selection-expected.txt b/LayoutTests/platform/chromium/editing/spelling/spelling-with-underscore-selection-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..3ce9a3535207328a8bd864d760be95d4a763df09 >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-with-underscore-selection-expected.txt >@@ -0,0 +1,15 @@ >+Underscores should be treated as whitespace: spelling should ignore them. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "" >+PASS window.getSelection().toString() is "_wellcome_" >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is "_wellcome_" >+PASS contextMenuElements[contextMenuElements.length - 1] is "welcome" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+Hi, _wellcome_ home. >Index: LayoutTests/platform/chromium/editing/spelling/spelling-with-underscore-selection.html >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-with-underscore-selection.html b/LayoutTests/platform/chromium/editing/spelling/spelling-with-underscore-selection.html >new file mode 100644 >index 0000000000000000000000000000000000000000..4fa7d27991e8d2bd9b50dfc3bbdcf5e7a33f4b44 >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-with-underscore-selection.html >@@ -0,0 +1,78 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../../fast/js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<div id="container"> >+ <div id="destination" contentEditable></div> >+</div> >+ >+<script> >+ >+function done() >+{ >+ testRunner.setAsynchronousSpellCheckingEnabled(false); >+ internals.settings.setUnifiedTextCheckerEnabled(false); >+ finishJSTest() >+} >+ >+function verify(nretry) >+{ >+ if (!nretry) { >+ done(); >+ return; >+ } >+ >+ if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) { >+ window.setTimeout(function() { verify(nretry - 1); }, 0); >+ return; >+ } >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", ""); >+ >+ // Select the text "_wellcome_". >+ window.getSelection().removeAllRanges(); >+ var rangeWithUnderscores = document.createRange(); >+ rangeWithUnderscores.setStart(destination.childNodes[0], 4); >+ rangeWithUnderscores.setEnd(destination.childNodes[0], 14); >+ window.getSelection().addRange(rangeWithUnderscores); >+ shouldBeEqualToString("window.getSelection().toString()", "_wellcome_"); >+ >+ // Context click on "_wellcome_" to show the context menu. >+ var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 80; >+ var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ contextMenuElements = eventSender.contextClick(); >+ // Esc key to hide the context menu. >+ eventSender.keyDown(String.fromCharCode(0x001B), null); >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", "_wellcome_"); >+ shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome"); >+ >+ done(); >+} >+ >+function test() >+{ >+ jsTestIsAsync = true; >+ internals.settings.setUnifiedTextCheckerEnabled(true); >+ testRunner.setAsynchronousSpellCheckingEnabled(true); >+ var destination = document.getElementById("destination"); >+ destination.focus(); >+ document.execCommand("InsertText", false, "Hi, _wellcome_ home."); >+ window.setTimeout(function() { verify(10); }, 0); >+} >+ >+description("Underscores should be treated as whitespace: spelling should ignore them."); >+if (window.internals) >+ test(); >+ >+</script> >+<script src="../../../../fast/js/resources/js-test-post.js"></script> >+</body> >+</html> >Index: LayoutTests/platform/chromium/editing/spelling/spelling-with-whitespace-selection-expected.txt >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-with-whitespace-selection-expected.txt b/LayoutTests/platform/chromium/editing/spelling/spelling-with-whitespace-selection-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..44381901e9dc8bdb80e909fbcff29e23a327785a >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-with-whitespace-selection-expected.txt >@@ -0,0 +1,14 @@ >+Spelling should ignore whitespace. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is " wellcome " >+PASS spellingMarkerRange.toString() is "wellcome" >+PASS window.getSelection().toString() is " wellcome " >+PASS contextMenuElements[contextMenuElements.length - 1] is "welcome" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+hello, wellcome home. >Index: LayoutTests/platform/chromium/editing/spelling/spelling-with-whitespace-selection.html >diff --git a/LayoutTests/platform/chromium/editing/spelling/spelling-with-whitespace-selection.html b/LayoutTests/platform/chromium/editing/spelling/spelling-with-whitespace-selection.html >new file mode 100644 >index 0000000000000000000000000000000000000000..66f5bd49a287b8754d5a52b328397293545c6ae1 >--- /dev/null >+++ b/LayoutTests/platform/chromium/editing/spelling/spelling-with-whitespace-selection.html >@@ -0,0 +1,75 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../../fast/js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<div id="container"> >+ <div id="destination" contentEditable></div> >+</div> >+ >+<script> >+ >+function done() >+{ >+ testRunner.setAsynchronousSpellCheckingEnabled(false); >+ internals.settings.setUnifiedTextCheckerEnabled(false); >+ finishJSTest() >+} >+ >+function verify(nretry) >+{ >+ if (!nretry) { >+ done(); >+ return; >+ } >+ >+ if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) { >+ window.setTimeout(function() { verify(nretry - 1); }, 0); >+ return; >+ } >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ >+ window.getSelection().removeAllRanges(); >+ var rangeWithWhitespace = document.createRange(); >+ rangeWithWhitespace.setStart(destination.childNodes[0], 6); >+ rangeWithWhitespace.setEnd(destination.childNodes[0], 16); >+ window.getSelection().addRange(rangeWithWhitespace); >+ shouldBeEqualToString("window.getSelection().toString()", " wellcome "); >+ >+ var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 80; >+ var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2; >+ eventSender.mouseMoveTo(x, y); >+ contextMenuElements = eventSender.contextClick(); >+ // esc key to kill the context menu >+ eventSender.keyDown(String.fromCharCode(0x001B), null); >+ >+ spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0); >+ shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome"); >+ shouldBeEqualToString("window.getSelection().toString()", " wellcome "); >+ shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome"); >+ >+ done(); >+} >+ >+function test() >+{ >+ jsTestIsAsync = true; >+ internals.settings.setUnifiedTextCheckerEnabled(true); >+ testRunner.setAsynchronousSpellCheckingEnabled(true); >+ var destination = document.getElementById("destination"); >+ destination.focus(); >+ document.execCommand("InsertText", false, "hello, wellcome home."); >+ window.setTimeout(function() { verify(10); }, 0); >+} >+ >+description("Spelling should ignore whitespace."); >+if (window.internals) >+ test(); >+ >+</script> >+<script src="../../../../fast/js/resources/js-test-post.js"></script> >+</body> >+</html> >Index: Source/WebCore/testing/Internals.cpp >diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp >index bee82043aa8066336019fda4b94decfd34da4b1f..002fe2d43b07e7d1025cc2f5685e0625debf4379 100644 >--- a/Source/WebCore/testing/Internals.cpp >+++ b/Source/WebCore/testing/Internals.cpp >@@ -898,6 +898,11 @@ void Internals::addTextMatchMarker(const Range* range, bool isActive) > range->ownerDocument()->markers()->addTextMatchMarker(range, isActive); > } > >+void Internals::addSpellingMarker(Range* range) >+{ >+ range->ownerDocument()->markers()->addMarker(range, DocumentMarker::Spelling); >+} >+ > void Internals::setScrollViewPosition(Document* document, long x, long y, ExceptionCode& ec) > { > if (!document || !document->view()) { >Index: Source/WebCore/testing/Internals.h >diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h >index 4ffd706c0be304f7a1b6284304b571139e31f87d..5dc0ff8dcac03cd170cccd3bb449f5ee39e3ad13 100644 >--- a/Source/WebCore/testing/Internals.h >+++ b/Source/WebCore/testing/Internals.h >@@ -139,6 +139,7 @@ public: > PassRefPtr<Range> markerRangeForNode(Node*, const String& markerType, unsigned index, ExceptionCode&); > String markerDescriptionForNode(Node*, const String& markerType, unsigned index, ExceptionCode&); > void addTextMatchMarker(const Range*, bool isActive); >+ void addSpellingMarker(Range*); > > void setScrollViewPosition(Document*, long x, long y, ExceptionCode&); > void setPagination(Document* document, const String& mode, int gap, ExceptionCode& ec) { setPagination(document, mode, gap, 0, ec); } >Index: Source/WebCore/testing/Internals.idl >diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl >index da1e403d987d92a521a326ea4119c2300ba86ff9..cd59f09bcf66cf0c63f5a3923e01012197c63ae0 100644 >--- a/Source/WebCore/testing/Internals.idl >+++ b/Source/WebCore/testing/Internals.idl >@@ -99,6 +99,7 @@ > Range markerRangeForNode(in Node node, in DOMString markerType, in unsigned long index) raises(DOMException); > DOMString markerDescriptionForNode(in Node node, in DOMString markerType, in unsigned long index) raises(DOMException); > void addTextMatchMarker(in Range range, in boolean isActive); >+ void addSpellingMarker(in Range range); > > void setScrollViewPosition(in Document document, in long x, in long y) raises(DOMException); > >Index: Source/WebKit/chromium/src/ContextMenuClientImpl.cpp >diff --git a/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp b/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp >index 33956bca784e019459b2f93d4b4601c56ef50327..d210f3a644f30107ad00a3ca41d9cde3e057d061 100644 >--- a/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp >+++ b/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp >@@ -78,6 +78,10 @@ using namespace WebCore; > > namespace WebKit { > >+static bool IsWhiteSpaceOrPunctuation(UChar c) { >+ return WTF::Unicode::isSeparatorSpace(c) || WTF::Unicode::isPunct(c); >+} >+ > // Figure out the URL of a page or subframe. Returns |page_type| as the type, > // which indicates page or subframe, or ContextNodeType::NONE if the URL could not > // be determined for some reason. >@@ -102,8 +106,8 @@ static bool isASingleWord(const String& text) > } > > // Helper function to get misspelled word on which context menu >-// is to be evolked. This function also sets the word on which context menu >-// has been evoked to be the selected word, as required. This function changes >+// is to be invoked. This function also sets the word on which context menu >+// has been invoked to be the selected word, as required. This function changes > // the selection only when there were no selected characters on OS X. > static String selectMisspelledWord(const ContextMenu* defaultMenu, Frame* selectedFrame) > { >@@ -274,36 +278,35 @@ PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems( > #endif > // When Chrome enables asynchronous spellchecking, its spellchecker adds spelling markers to misspelled > // words and attaches suggestions to these markers in the background. Therefore, when a user right-clicks >- // a mouse on a word, Chrome just needs to find a spelling marker on the word instread of spellchecking it. >+ // a mouse on a word, Chrome just needs to find a spelling marker on the word instead of spellchecking it. > if (selectedFrame->settings() && selectedFrame->settings()->asynchronousSpellCheckingEnabled()) { > VisibleSelection selection = selectedFrame->selection()->selection(); >- bool shouldUpdateSelection = false; > if (selection.isCaretOrRange()) { >- if (selection.isCaret()) { >- selection.expandUsingGranularity(WordGranularity); >- shouldUpdateSelection = true; >- } >- RefPtr<Range> range = selection.toNormalizedRange(); >- Vector<DocumentMarker*> markers = selectedFrame->document()->markers()->markersInRange(range.get(), DocumentMarker::Spelling | DocumentMarker::Grammar); >- if (markers.size() == 1) { >- if (markers[0]->startOffset() != static_cast<unsigned>(range->startOffset()) || markers[0]->endOffset() != static_cast<unsigned>(range->endOffset())) >- markers.clear(); >- } >- if (markers.size() == 1) { >- range->setStart(range->startContainer(), markers[0]->startOffset()); >- range->setEnd(range->endContainer(), markers[0]->endOffset()); >- data.misspelledWord = range->text(); >- if (markers[0]->description().length()) { >- Vector<String> suggestions; >- markers[0]->description().split('\n', suggestions); >- data.dictionarySuggestions = suggestions; >- } else if (m_webView->spellCheckClient()) { >- int misspelledOffset, misspelledLength; >- m_webView->spellCheckClient()->spellCheck(data.misspelledWord, misspelledOffset, misspelledLength, &data.dictionarySuggestions); >- } >- selection = VisibleSelection(range.get()); >- if (shouldUpdateSelection && selectedFrame->selection()->shouldChangeSelection(selection)) >+ RefPtr<Range> selectionRange = selection.toNormalizedRange(); >+ ExceptionCode exceptionCode; >+ RefPtr<Range> markerRange = selectionRange->cloneRange(exceptionCode); >+ Vector<DocumentMarker*> markers = selectedFrame->document()->markers()->markersInRange(selectionRange.get(), DocumentMarker::Spelling | DocumentMarker::Grammar); >+ if (!exceptionCode && markers.size() == 1) { >+ markerRange->setStart(markerRange->startContainer(), markers[0]->startOffset()); >+ markerRange->setEnd(markerRange->endContainer(), markers[0]->endOffset()); >+ // If there is no selection, then select the misspelling. >+ if (selection.isCaret()) { >+ selection = VisibleSelection(markerRange.get()); > selectedFrame->selection()->setSelection(selection, WordGranularity); >+ selectionRange.clear(); >+ selectionRange = selection.toNormalizedRange(); >+ } >+ if (selectionRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation) == markerRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation)) { >+ data.misspelledWord = markerRange->text(); >+ if (markers[0]->description().length()) { >+ Vector<String> suggestions; >+ markers[0]->description().split('\n', suggestions); >+ data.dictionarySuggestions = suggestions; >+ } else if (m_webView->spellCheckClient()) { >+ int misspelledOffset, misspelledLength; >+ m_webView->spellCheckClient()->spellCheck(data.misspelledWord, misspelledOffset, misspelledLength, &data.dictionarySuggestions); >+ } >+ } > } > } > } else { >Index: Source/WebKit/chromium/src/WebFrameImpl.cpp >diff --git a/Source/WebKit/chromium/src/WebFrameImpl.cpp b/Source/WebKit/chromium/src/WebFrameImpl.cpp >index 347fa20388d73a3a0ab093bb799a8e641abe585c..73b3e22a9d8f5394cf0334cb5e5e02d8e3c526d9 100644 >--- a/Source/WebKit/chromium/src/WebFrameImpl.cpp >+++ b/Source/WebKit/chromium/src/WebFrameImpl.cpp >@@ -1299,11 +1299,16 @@ void WebFrameImpl::replaceMisspelledRange(const WebString& text) > Vector<DocumentMarker*> markers = frame()->document()->markers()->markersInRange(caretRange.get(), DocumentMarker::Spelling | DocumentMarker::Grammar); > if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset()) > return; >- RefPtr<Range> markerRange = TextIterator::rangeFromLocationAndLength(frame()->selection()->rootEditableElementOrDocumentElement(), markers[0]->startOffset(), markers[0]->endOffset() - markers[0]->startOffset()); >- if (!markerRange.get() || !frame()->selection()->shouldChangeSelection(markerRange.get())) >+ ExceptionCode exceptionCode; >+ RefPtr<Range> markerRange = caretRange->cloneRange(exceptionCode); >+ if (!exceptionCode) >+ return; >+ markerRange->setStart(markerRange->startContainer(), markers[0]->startOffset()); >+ markerRange->setEnd(markerRange->endContainer(), markers[0]->endOffset()); >+ if (!frame()->selection()->shouldChangeSelection(markerRange.get())) > return; > frame()->selection()->setSelection(markerRange.get(), CharacterGranularity); >- frame()->editor()->replaceSelectionWithText(text, false, true); >+ frame()->editor()->replaceSelectionWithText(text, false, false); > } > > bool WebFrameImpl::hasSelection() const ></pre></body></html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 106815
:
184278
|
184581
|
184588
|
184808
|
184825
|
185091
|
185121
|
185303
|
185537
|
185547
|
185594
|
185625