Title: [122017] releases/WebKitGTK/webkit-1.8
Revision
122017
Author
[email protected]
Date
2012-07-06 13:05:38 -0700 (Fri, 06 Jul 2012)

Log Message

Merge 113127 - Prevent spellchecking text pasted to an element having spellchecking disabled
https://bugs.webkit.org/show_bug.cgi?id=81323

Patch by Hironori Bono <[email protected]> on 2012-04-03
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.

Source/WebCore:

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.

LayoutTests:

* 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.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-1.8/LayoutTests/ChangeLog (122016 => 122017)


--- releases/WebKitGTK/webkit-1.8/LayoutTests/ChangeLog	2012-07-06 20:05:24 UTC (rev 122016)
+++ releases/WebKitGTK/webkit-1.8/LayoutTests/ChangeLog	2012-07-06 20:05:38 UTC (rev 122017)
@@ -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-05-18  MORITA Hajime  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=85515

Added: releases/WebKitGTK/webkit-1.8/LayoutTests/editing/spelling/spellcheck-paste-disabled-expected.txt (0 => 122017)


--- releases/WebKitGTK/webkit-1.8/LayoutTests/editing/spelling/spellcheck-paste-disabled-expected.txt	                        (rev 0)
+++ releases/WebKitGTK/webkit-1.8/LayoutTests/editing/spelling/spellcheck-paste-disabled-expected.txt	2012-07-06 20:05:38 UTC (rev 122017)
@@ -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
Property changes on: releases/WebKitGTK/webkit-1.8/LayoutTests/editing/spelling/spellcheck-paste-disabled-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: releases/WebKitGTK/webkit-1.8/LayoutTests/editing/spelling/spellcheck-paste-disabled.html (0 => 122017)


--- releases/WebKitGTK/webkit-1.8/LayoutTests/editing/spelling/spellcheck-paste-disabled.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-1.8/LayoutTests/editing/spelling/spellcheck-paste-disabled.html	2012-07-06 20:05:38 UTC (rev 122017)
@@ -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>
Property changes on: releases/WebKitGTK/webkit-1.8/LayoutTests/editing/spelling/spellcheck-paste-disabled.html
___________________________________________________________________

Added: svn:eol-style

Modified: releases/WebKitGTK/webkit-1.8/LayoutTests/platform/efl/Skipped (122016 => 122017)


--- releases/WebKitGTK/webkit-1.8/LayoutTests/platform/efl/Skipped	2012-07-06 20:05:24 UTC (rev 122016)
+++ releases/WebKitGTK/webkit-1.8/LayoutTests/platform/efl/Skipped	2012-07-06 20:05:38 UTC (rev 122017)
@@ -771,6 +771,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: releases/WebKitGTK/webkit-1.8/LayoutTests/platform/mac-leopard/Skipped (122016 => 122017)


--- releases/WebKitGTK/webkit-1.8/LayoutTests/platform/mac-leopard/Skipped	2012-07-06 20:05:24 UTC (rev 122016)
+++ releases/WebKitGTK/webkit-1.8/LayoutTests/platform/mac-leopard/Skipped	2012-07-06 20:05:38 UTC (rev 122017)
@@ -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: releases/WebKitGTK/webkit-1.8/LayoutTests/platform/mac-lion/Skipped (122016 => 122017)


--- releases/WebKitGTK/webkit-1.8/LayoutTests/platform/mac-lion/Skipped	2012-07-06 20:05:24 UTC (rev 122016)
+++ releases/WebKitGTK/webkit-1.8/LayoutTests/platform/mac-lion/Skipped	2012-07-06 20:05:38 UTC (rev 122017)
@@ -123,6 +123,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: releases/WebKitGTK/webkit-1.8/LayoutTests/platform/mac-wk2/Skipped (122016 => 122017)


--- releases/WebKitGTK/webkit-1.8/LayoutTests/platform/mac-wk2/Skipped	2012-07-06 20:05:24 UTC (rev 122016)
+++ releases/WebKitGTK/webkit-1.8/LayoutTests/platform/mac-wk2/Skipped	2012-07-06 20:05:38 UTC (rev 122017)
@@ -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: releases/WebKitGTK/webkit-1.8/LayoutTests/platform/qt/Skipped (122016 => 122017)


--- releases/WebKitGTK/webkit-1.8/LayoutTests/platform/qt/Skipped	2012-07-06 20:05:24 UTC (rev 122016)
+++ releases/WebKitGTK/webkit-1.8/LayoutTests/platform/qt/Skipped	2012-07-06 20:05:38 UTC (rev 122017)
@@ -747,6 +747,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: releases/WebKitGTK/webkit-1.8/LayoutTests/platform/win/Skipped (122016 => 122017)


--- releases/WebKitGTK/webkit-1.8/LayoutTests/platform/win/Skipped	2012-07-06 20:05:24 UTC (rev 122016)
+++ releases/WebKitGTK/webkit-1.8/LayoutTests/platform/win/Skipped	2012-07-06 20:05:38 UTC (rev 122017)
@@ -1066,6 +1066,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: releases/WebKitGTK/webkit-1.8/LayoutTests/platform/win-wk2/Skipped (122016 => 122017)


--- releases/WebKitGTK/webkit-1.8/LayoutTests/platform/win-wk2/Skipped	2012-07-06 20:05:24 UTC (rev 122016)
+++ releases/WebKitGTK/webkit-1.8/LayoutTests/platform/win-wk2/Skipped	2012-07-06 20:05:38 UTC (rev 122017)
@@ -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: releases/WebKitGTK/webkit-1.8/LayoutTests/platform/wincairo/Skipped (122016 => 122017)


--- releases/WebKitGTK/webkit-1.8/LayoutTests/platform/wincairo/Skipped	2012-07-06 20:05:24 UTC (rev 122016)
+++ releases/WebKitGTK/webkit-1.8/LayoutTests/platform/wincairo/Skipped	2012-07-06 20:05:38 UTC (rev 122017)
@@ -1584,6 +1584,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: releases/WebKitGTK/webkit-1.8/Source/WebCore/ChangeLog (122016 => 122017)


--- releases/WebKitGTK/webkit-1.8/Source/WebCore/ChangeLog	2012-07-06 20:05:24 UTC (rev 122016)
+++ releases/WebKitGTK/webkit-1.8/Source/WebCore/ChangeLog	2012-07-06 20:05:38 UTC (rev 122017)
@@ -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-02-24  Shinya Kawanaka  <[email protected]>
 
         SpellCheckRequest needs to know the context where the spellcheck happened.

Modified: releases/WebKitGTK/webkit-1.8/Source/WebCore/editing/Editor.cpp (122016 => 122017)


--- releases/WebKitGTK/webkit-1.8/Source/WebCore/editing/Editor.cpp	2012-07-06 20:05:24 UTC (rev 122016)
+++ releases/WebKitGTK/webkit-1.8/Source/WebCore/editing/Editor.cpp	2012-07-06 20:05:38 UTC (rev 122017)
@@ -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: releases/WebKitGTK/webkit-1.8/Source/WebCore/editing/SpellChecker.cpp (122016 => 122017)


--- releases/WebKitGTK/webkit-1.8/Source/WebCore/editing/SpellChecker.cpp	2012-07-06 20:05:24 UTC (rev 122016)
+++ releases/WebKitGTK/webkit-1.8/Source/WebCore/editing/SpellChecker.cpp	2012-07-06 20:05:38 UTC (rev 122017)
@@ -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)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to