Diff
Modified: trunk/LayoutTests/ChangeLog (113126 => 113127)
--- trunk/LayoutTests/ChangeLog 2012-04-04 02:12:40 UTC (rev 113126)
+++ trunk/LayoutTests/ChangeLog 2012-04-04 02:18:49 UTC (rev 113127)
@@ -1,3 +1,25 @@
+2012-04-03 Hironori Bono <[email protected]>
+
+ Prevent spellchecking text pasted to an element having spellchecking disabled
+ https://bugs.webkit.org/show_bug.cgi?id=81323
+
+ Reviewed by Hajime Morita.
+
+ This change prevent calling SpellChecker::requestCheckingFor when pasting text
+ to an element whose spellcheck attribute is false or a password input.
+
+ * editing/spelling/spellcheck-paste-disabled-expected.txt: Added.
+ * editing/spelling/spellcheck-paste-disabled.html: Added.
+ * platform/efl/Skipped: Skipped due to the lack of requestCheckingOfString().
+ * platform/gtk/Skipped: ditto.
+ * platform/mac-leopard/Skipped: ditto.
+ * platform/mac-lion/Skipped: ditto.
+ * platform/mac-wk2/Skipped: ditto.
+ * platform/qt/Skipped: ditto.
+ * platform/win-wk2/Skipped: ditto.
+ * platform/win/Skipped: ditto.
+ * platform/wincairo/Skipped: ditto.
+
2012-04-03 Ami Fischman <[email protected]>
Layout Test media/video-source-error.html is flaky on cr-win
Added: trunk/LayoutTests/editing/spelling/spellcheck-paste-disabled-expected.txt (0 => 113127)
--- trunk/LayoutTests/editing/spelling/spellcheck-paste-disabled-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/spelling/spellcheck-paste-disabled-expected.txt 2012-04-04 02:18:49 UTC (rev 113127)
@@ -0,0 +1,13 @@
+Test if WebKit does not spellcheck text when pasting text to an element having spellchecking disabled. To test manually, copy the text "zz apple" and paste it to the textarea. When "zz" is not marked as misspelled, this test succeeds.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS internals.hasSpellingMarker(document, 0, 2) is true
+PASS The destination node does not have any markers.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+zz apple
+
+zz apple
Added: trunk/LayoutTests/editing/spelling/spellcheck-paste-disabled.html (0 => 113127)
--- trunk/LayoutTests/editing/spelling/spellcheck-paste-disabled.html (rev 0)
+++ trunk/LayoutTests/editing/spelling/spellcheck-paste-disabled.html 2012-04-04 02:18:49 UTC (rev 113127)
@@ -0,0 +1,61 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<div>
+<div id="src" contenteditable="true" spellcheck="true"></div><br/>
+<div id="dst" contenteditable="true" spellcheck="false"></div>
+</div>
+<script language="_javascript_">
+description('Test if WebKit does not spellcheck text when pasting text to an element having spellchecking disabled. ' +
+ 'To test manually, copy the text "zz apple" and paste it to the textarea. ' +
+ 'When "zz" is not marked as misspelled, this test succeeds.');
+
+jsTestIsAsync = true;
+
+// Insert a misspelled word to initialize a spellchecker.
+var srcNode = document.getElementById('src');
+srcNode.focus();
+document.execCommand("InsertText", false, 'z');
+document.execCommand("InsertText", false, 'z');
+document.execCommand("InsertText", false, ' ');
+document.execCommand("InsertText", false, 'a');
+document.execCommand("InsertText", false, 'p');
+document.execCommand("InsertText", false, 'p');
+document.execCommand("InsertText", false, 'l');
+document.execCommand("InsertText", false, 'e');
+shouldBeTrue('internals.hasSpellingMarker(document, 0, 2)');
+window.getSelection().selectAllChildren(srcNode);
+document.execCommand('Copy');
+
+layoutTestController.setAsynchronousSpellCheckingEnabled(true);
+
+var dstNode = document.getElementById('dst');
+dstNode.focus();
+document.execCommand('Paste');
+
+var retryCount = 10;
+var sleepPeriod = 1;
+function verifyMarker() {
+ dstNode.focus();
+ var hasMarker = internals.hasSpellingMarker(document, 0, 2);
+ if (!hasMarker && --retryCount > 0) {
+ sleepPeriod *= 2;
+ window.setTimeout(verifyMarker, sleepPeriod);
+ return;
+ }
+ if (hasMarker)
+ testFailed('The destination node should not have a marker.');
+ else
+ testPassed('The destination node does not have any markers.');
+ layoutTestController.setAsynchronousSpellCheckingEnabled(false);
+ finishJSTest();
+}
+window.setTimeout(verifyMarker, sleepPeriod);
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/platform/efl/Skipped (113126 => 113127)
--- trunk/LayoutTests/platform/efl/Skipped 2012-04-04 02:12:40 UTC (rev 113126)
+++ trunk/LayoutTests/platform/efl/Skipped 2012-04-04 02:18:49 UTC (rev 113127)
@@ -643,6 +643,7 @@
# EFL's LayoutTestController does not implement setAsynchronousSpellCheckingEnabled
editing/spelling/spellcheck-paste.html
+editing/spelling/spellcheck-paste-disabled.html
# EFL's LayoutTestController does not implement evaluateScriptInIsolatedWorld
http/tests/security/isolatedWorld
Modified: trunk/LayoutTests/platform/gtk/Skipped (113126 => 113127)
--- trunk/LayoutTests/platform/gtk/Skipped 2012-04-04 02:12:40 UTC (rev 113126)
+++ trunk/LayoutTests/platform/gtk/Skipped 2012-04-04 02:18:49 UTC (rev 113127)
@@ -1191,6 +1191,7 @@
# https://bugs.webkit.org/show_bug.cgi?id=50740
editing/spelling/spelling-backspace-between-lines.html
editing/spelling/spellcheck-paste.html
+editing/spelling/spellcheck-paste-disabled.html
editing/spelling/spellcheck-queue.html
editing/spelling/spellcheck-sequencenum.html
editing/spelling/spellcheck-async-mutation.html
Modified: trunk/LayoutTests/platform/mac-leopard/Skipped (113126 => 113127)
--- trunk/LayoutTests/platform/mac-leopard/Skipped 2012-04-04 02:12:40 UTC (rev 113126)
+++ trunk/LayoutTests/platform/mac-leopard/Skipped 2012-04-04 02:18:49 UTC (rev 113127)
@@ -97,6 +97,7 @@
# Available 10.6 or later
editing/spelling/spellcheck-paste.html
+editing/spelling/spellcheck-paste-disabled.html
editing/spelling/spellcheck-async-mutation.html
editing/spelling/grammar-paste.html
fast/html/set-text-direction.html
Modified: trunk/LayoutTests/platform/mac-lion/Skipped (113126 => 113127)
--- trunk/LayoutTests/platform/mac-lion/Skipped 2012-04-04 02:12:40 UTC (rev 113126)
+++ trunk/LayoutTests/platform/mac-lion/Skipped 2012-04-04 02:18:49 UTC (rev 113127)
@@ -126,6 +126,7 @@
# Unknown failures.
editing/spelling/spellcheck-paste.html
+editing/spelling/spellcheck-paste-disabled.html
http/tests/media/video-play-stall-seek.html
http/tests/media/video-play-stall.html
http/tests/multipart/invalid-image-data-standalone.html
Modified: trunk/LayoutTests/platform/mac-wk2/Skipped (113126 => 113127)
--- trunk/LayoutTests/platform/mac-wk2/Skipped 2012-04-04 02:12:40 UTC (rev 113126)
+++ trunk/LayoutTests/platform/mac-wk2/Skipped 2012-04-04 02:18:49 UTC (rev 113127)
@@ -107,6 +107,7 @@
editing/selection/word-granularity.html
editing/spelling/context-menu-suggestions.html
editing/spelling/spellcheck-paste.html
+editing/spelling/spellcheck-paste-disabled.html
editing/undo/undo-smart-delete-reversed-selection.html
fast/block/positioning/hittest-on-relative-positioned-children.html
fast/css/user-drag-none.html
Modified: trunk/LayoutTests/platform/qt/Skipped (113126 => 113127)
--- trunk/LayoutTests/platform/qt/Skipped 2012-04-04 02:12:40 UTC (rev 113126)
+++ trunk/LayoutTests/platform/qt/Skipped 2012-04-04 02:18:49 UTC (rev 113127)
@@ -816,6 +816,7 @@
# EditorClient::requestCheckingOfString() is not implemented
editing/spelling/spellcheck-paste.html
+editing/spelling/spellcheck-paste-disabled.html
editing/spelling/spellcheck-queue.html
editing/spelling/spellcheck-sequencenum.html
editing/spelling/spellcheck-async-mutation.html
Modified: trunk/LayoutTests/platform/win/Skipped (113126 => 113127)
--- trunk/LayoutTests/platform/win/Skipped 2012-04-04 02:12:40 UTC (rev 113126)
+++ trunk/LayoutTests/platform/win/Skipped 2012-04-04 02:18:49 UTC (rev 113127)
@@ -1072,6 +1072,8 @@
# EditorClient::requestCheckingOfString() is not implemented
editing/spelling/spellcheck-paste.html
+editing/spelling/spellcheck-paste-disabled.html
+
# Replacement text for misspelling is not given.
# https://bugs.webkit.org/show_bug.cgi?id=77934
editing/spelling/spelling-marker-description.html
Modified: trunk/LayoutTests/platform/win-wk2/Skipped (113126 => 113127)
--- trunk/LayoutTests/platform/win-wk2/Skipped 2012-04-04 02:12:40 UTC (rev 113126)
+++ trunk/LayoutTests/platform/win-wk2/Skipped 2012-04-04 02:18:49 UTC (rev 113127)
@@ -155,6 +155,7 @@
editing/selection/word-granularity.html
editing/spelling/context-menu-suggestions.html
editing/spelling/spellcheck-paste.html
+editing/spelling/spellcheck-paste-disabled.html
editing/undo/undo-deleteWord.html
editing/undo/undo-smart-delete-reversed-selection.html
editing/undo/undo-smart-delete-word.html
Modified: trunk/LayoutTests/platform/wincairo/Skipped (113126 => 113127)
--- trunk/LayoutTests/platform/wincairo/Skipped 2012-04-04 02:12:40 UTC (rev 113126)
+++ trunk/LayoutTests/platform/wincairo/Skipped 2012-04-04 02:18:49 UTC (rev 113127)
@@ -1592,6 +1592,7 @@
# EditorClient::requestCheckingOfString() is not implemented
editing/spelling/spellcheck-paste.html
+editing/spelling/spellcheck-paste-disabled.html
# IndexedDB is not yet enabled.
storage/indexeddb
Modified: trunk/Source/WebCore/ChangeLog (113126 => 113127)
--- trunk/Source/WebCore/ChangeLog 2012-04-04 02:12:40 UTC (rev 113126)
+++ trunk/Source/WebCore/ChangeLog 2012-04-04 02:18:49 UTC (rev 113127)
@@ -1,3 +1,20 @@
+2012-04-03 Hironori Bono <[email protected]>
+
+ Prevent spellchecking text pasted to an element having spellchecking disabled
+ https://bugs.webkit.org/show_bug.cgi?id=81323
+
+ Reviewed by Hajime Morita.
+
+ This change prevent calling SpellChecker::requestCheckingFor when pasting text
+ to an element whose spellcheck attribute is false or a password input.
+
+ Test: editing/spelling/spellcheck-paste-disabled.html
+
+ * editing/Editor.cpp:
+ (WebCore::Editor::replaceSelectionWithFragment): Disabled spellchecking on password inputs.
+ * editing/SpellChecker.cpp:
+ (WebCore::SpellChecker::isCheckable): Return false when spellchecking is disabled.
+
2012-04-03 Hayato Ito <[email protected]>
Make FocusController use a ComposedShadowTreeWalker, instead of ReifiedTreeTraversal APIs.
Modified: trunk/Source/WebCore/editing/Editor.cpp (113126 => 113127)
--- trunk/Source/WebCore/editing/Editor.cpp 2012-04-04 02:12:40 UTC (rev 113126)
+++ trunk/Source/WebCore/editing/Editor.cpp 2012-04-04 02:18:49 UTC (rev 113127)
@@ -413,6 +413,8 @@
applyCommand(ReplaceSelectionCommand::create(m_frame->document(), fragment, options, EditActionPaste));
revealSelectionAfterEditingOperation();
+ if (m_frame->selection()->isInPasswordField())
+ return;
Node* nodeToCheck = m_frame->selection()->rootEditableElement();
if (!nodeToCheck)
return;
Modified: trunk/Source/WebCore/editing/SpellChecker.cpp (113126 => 113127)
--- trunk/Source/WebCore/editing/SpellChecker.cpp 2012-04-04 02:12:40 UTC (rev 113126)
+++ trunk/Source/WebCore/editing/SpellChecker.cpp 2012-04-04 02:18:49 UTC (rev 113127)
@@ -118,7 +118,12 @@
bool SpellChecker::isCheckable(Range* range) const
{
- return range && range->firstNode() && range->firstNode()->renderer();
+ if (!range || !range->firstNode() || !range->firstNode()->renderer())
+ return false;
+ const Node* node = range->startContainer();
+ if (node && node->isElementNode() && !toElement(node)->isSpellCheckingEnabled())
+ return false;
+ return true;
}
void SpellChecker::requestCheckingFor(PassRefPtr<SpellCheckRequest> request)