Title: [113405] trunk
Revision
113405
Author
[email protected]
Date
2012-04-05 19:48:37 -0700 (Thu, 05 Apr 2012)

Log Message

[Chromium] moving a cursor on a misspelled word should not remove a misspelled underline
https://bugs.webkit.org/show_bug.cgi?id=83214

Reviewed by Ryosuke Niwa.

When Chrome enables asynchronous spellchecking, it adds Spelling markers in the
background. For this case, moving a cursor should not remove these markers
because it requires Chrome to spellcheck text again. This change prevents
removing Spelling markers added by spellcheckers asynchronously.

Source/WebCore:

Test: platform/chromium/editing/spelling/move-cursor-to-misspelled-word.html

* editing/Editor.cpp:
(WebCore::Editor::respondToChangedSelection):

Source/WebKit/chromium:

* src/ContextMenuClientImpl.cpp:
(WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): use marker descriptions instead of spellchecking text when Chrome enables asynchronous spellchecking.

LayoutTests:

* platform/chromium/editing/spelling/move-cursor-to-misspelled-word-expected.txt: Added.
* platform/chromium/editing/spelling/move-cursor-to-misspelled-word.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (113404 => 113405)


--- trunk/LayoutTests/ChangeLog	2012-04-06 02:27:31 UTC (rev 113404)
+++ trunk/LayoutTests/ChangeLog	2012-04-06 02:48:37 UTC (rev 113405)
@@ -1,3 +1,18 @@
+2012-04-05  Hironori Bono  <[email protected]>
+
+        [Chromium] moving a cursor on a misspelled word should not remove a misspelled underline
+        https://bugs.webkit.org/show_bug.cgi?id=83214
+
+        Reviewed by Ryosuke Niwa.
+
+        When Chrome enables asynchronous spellchecking, it adds Spelling markers in the
+        background. For this case, moving a cursor should not remove these markers
+        because it requires Chrome to spellcheck text again. This change prevents
+        removing Spelling markers added by spellcheckers asynchronously.
+
+        * platform/chromium/editing/spelling/move-cursor-to-misspelled-word-expected.txt: Added.
+        * platform/chromium/editing/spelling/move-cursor-to-misspelled-word.html: Added.
+
 2012-04-05  Martin Robinson  <[email protected]>
 
         Unskip a test that should now be passing after r113004

Added: trunk/LayoutTests/platform/chromium/editing/spelling/move-cursor-to-misspelled-word-expected.txt (0 => 113405)


--- trunk/LayoutTests/platform/chromium/editing/spelling/move-cursor-to-misspelled-word-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/editing/spelling/move-cursor-to-misspelled-word-expected.txt	2012-04-06 02:48:37 UTC (rev 113405)
@@ -0,0 +1,12 @@
+Test if Chrome WebKit does not remove a misspelled marker when moving a cursor on a misspelled word.To test manually, type a misspelled word "zz " and type a left-arrow key to move the cursor on it.This test succeeds when "zz" is marked as misspelled.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS internals.hasSpellingMarker(document, 0, 2) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+zz 
+
+

Added: trunk/LayoutTests/platform/chromium/editing/spelling/move-cursor-to-misspelled-word.html (0 => 113405)


--- trunk/LayoutTests/platform/chromium/editing/spelling/move-cursor-to-misspelled-word.html	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/editing/spelling/move-cursor-to-misspelled-word.html	2012-04-06 02:48:37 UTC (rev 113405)
@@ -0,0 +1,25 @@
+<html>
+<head>
+<script src="" language="_javascript_" type="text/_javascript_"></script>
+<title>Testing moving cursor to a misspelled word</title> 
+</head> 
+<body>
+<div id="src" contenteditable="true" spellcheck="true"></div><br/>
+<script language="_javascript_">
+description('Test if Chrome WebKit does not remove a misspelled marker when moving a cursor on a misspelled word.' +
+            'To test manually, type a misspelled word "zz " and type a left-arrow key to move the cursor on it.' +
+            'This test succeeds when "zz" is marked as misspelled.');
+
+layoutTestController.setAsynchronousSpellCheckingEnabled(true);
+var node = document.getElementById('src');
+node.focus();
+document.execCommand("InsertText", false, 'z');
+document.execCommand("InsertText", false, 'z');
+document.execCommand("InsertText", false, ' ');
+window.getSelection().modify('move', 'backward', 'character');
+shouldBeTrue('internals.hasSpellingMarker(document, 0, 2)');
+layoutTestController.setAsynchronousSpellCheckingEnabled(false);
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (113404 => 113405)


--- trunk/Source/WebCore/ChangeLog	2012-04-06 02:27:31 UTC (rev 113404)
+++ trunk/Source/WebCore/ChangeLog	2012-04-06 02:48:37 UTC (rev 113405)
@@ -1,3 +1,20 @@
+2012-04-05  Hironori Bono  <[email protected]>
+
+        [Chromium] moving a cursor on a misspelled word should not remove a misspelled underline
+        https://bugs.webkit.org/show_bug.cgi?id=83214
+
+        Reviewed by Ryosuke Niwa.
+
+        When Chrome enables asynchronous spellchecking, it adds Spelling markers in the
+        background. For this case, moving a cursor should not remove these markers
+        because it requires Chrome to spellcheck text again. This change prevents
+        removing Spelling markers added by spellcheckers asynchronously.
+
+        Test: platform/chromium/editing/spelling/move-cursor-to-misspelled-word.html
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::respondToChangedSelection):
+
 2012-04-05  Hans Muller  <[email protected]>
 
         CSS Exclusions polygon shape arguments should be comma separated

Modified: trunk/Source/WebCore/editing/Editor.cpp (113404 => 113405)


--- trunk/Source/WebCore/editing/Editor.cpp	2012-04-06 02:27:31 UTC (rev 113404)
+++ trunk/Source/WebCore/editing/Editor.cpp	2012-04-06 02:48:37 UTC (rev 113405)
@@ -2923,11 +2923,18 @@
         }
 
 #if !PLATFORM(MAC) || (PLATFORM(MAC) && (defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)))
+#if PLATFORM(CHROMIUM)
+        if (!m_frame->settings() || !m_frame->settings()->asynchronousSpellCheckingEnabled()) {
+            if (RefPtr<Range> wordRange = newAdjacentWords.toNormalizedRange())
+                m_frame->document()->markers()->removeMarkers(wordRange.get(), DocumentMarker::Spelling);
+        }
+#else
         // This only erases markers that are in the first unit (word or sentence) of the selection.
         // Perhaps peculiar, but it matches AppKit on these Mac OS X versions.
         if (RefPtr<Range> wordRange = newAdjacentWords.toNormalizedRange())
             m_frame->document()->markers()->removeMarkers(wordRange.get(), DocumentMarker::Spelling);
 #endif
+#endif
         if (RefPtr<Range> sentenceRange = newSelectedSentence.toNormalizedRange())
             m_frame->document()->markers()->removeMarkers(sentenceRange.get(), DocumentMarker::Grammar);
     }

Modified: trunk/Source/WebKit/chromium/ChangeLog (113404 => 113405)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-04-06 02:27:31 UTC (rev 113404)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-04-06 02:48:37 UTC (rev 113405)
@@ -1,3 +1,18 @@
+2012-04-05  Hironori Bono  <[email protected]>
+
+        [Chromium] moving a cursor on a misspelled word should not remove a misspelled underline
+        https://bugs.webkit.org/show_bug.cgi?id=83214
+
+        Reviewed by Ryosuke Niwa.
+
+        When Chrome enables asynchronous spellchecking, it adds Spelling markers in the
+        background. For this case, moving a cursor should not remove these markers
+        because it requires Chrome to spellcheck text again. This change prevents
+        removing Spelling markers added by spellcheckers asynchronously.
+
+        * src/ContextMenuClientImpl.cpp:
+        (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): use marker descriptions instead of spellchecking text when Chrome enables asynchronous spellchecking.
+
 2012-04-05  Dana Jansens  <[email protected]>
 
         [chromium] Record the number of tiles paint-culled instead of the incorrect number of pixels

Modified: trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp (113404 => 113405)


--- trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp	2012-04-06 02:27:31 UTC (rev 113404)
+++ trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp	2012-04-06 02:48:37 UTC (rev 113405)
@@ -37,6 +37,7 @@
 #include "ContextMenuController.h"
 #include "Document.h"
 #include "DocumentLoader.h"
+#include "DocumentMarkerController.h"
 #include "Editor.h"
 #include "EventHandler.h"
 #include "FrameLoader.h"
@@ -54,6 +55,7 @@
 #include "Page.h"
 #include "PlatformString.h"
 #include "RenderWidget.h"
+#include "Settings.h"
 #include "TextBreakIterator.h"
 #include "Widget.h"
 
@@ -272,7 +274,25 @@
                 static_cast<HTMLInputElement*>(r.innerNonSharedNode())->isSpeechEnabled();
         }  
 #endif
-        if (m_webView->focusedWebCoreFrame()->editor()->isContinuousSpellCheckingEnabled()) {
+        // 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.
+        if (selectedFrame->settings() && selectedFrame->settings()->asynchronousSpellCheckingEnabled()) {
+            RefPtr<Range> range = selectedFrame->selection()->toNormalizedRange();
+            Vector<DocumentMarker*> markers = selectedFrame->document()->markers()->markersInRange(range.get(), DocumentMarker::Spelling);
+            if (!markers.isEmpty()) {
+                Vector<String> suggestions;
+                for (size_t i = 0; i < markers.size(); ++i) {
+                    if (!markers[i]->description().isEmpty()) {
+                        Vector<String> descriptions;
+                        markers[i]->description().split('\n', descriptions);
+                        suggestions.append(descriptions);
+                    }
+                }
+                data.dictionarySuggestions = suggestions;
+                data.misspelledWord = range->text();
+            }
+        } else if (m_webView->focusedWebCoreFrame()->editor()->isContinuousSpellCheckingEnabled()) {
             data.isSpellCheckingEnabled = true;
             // Spellchecking might be enabled for the field, but could be disabled on the node.
             if (m_webView->focusedWebCoreFrame()->editor()->isSpellCheckingEnabledInFocusedNode()) {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to