diff options
Diffstat (limited to 'Source/WebKit/chromium/src/ContextMenuClientImpl.cpp')
-rw-r--r-- | Source/WebKit/chromium/src/ContextMenuClientImpl.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp b/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp index 4712eff7d..4491ea1ca 100644 --- a/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp +++ b/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp @@ -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 @@ PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems( 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 = selectMisspelledWord(defaultMenu, selectedFrame); + } + } 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()) { |