summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-06-20 13:01:08 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-06-20 13:01:08 +0200
commit49233e234e5c787396cadb2cea33b31ae0cd65c1 (patch)
tree5410cb9a8fd53168bb60d62c54b654d86f03c38d /Source/WebKit/chromium/src/ContextMenuClientImpl.cpp
parentb211c645d8ab690f713515dfdc84d80b11c27d2c (diff)
downloadqtwebkit-49233e234e5c787396cadb2cea33b31ae0cd65c1.tar.gz
Imported WebKit commit 3a8c29f35d00659d2ce7a0ccdfa8304f14e82327 (http://svn.webkit.org/repository/webkit/trunk@120813)
New snapshot with Windows build fixes
Diffstat (limited to 'Source/WebKit/chromium/src/ContextMenuClientImpl.cpp')
-rw-r--r--Source/WebKit/chromium/src/ContextMenuClientImpl.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp b/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp
index d400e7c2b..a32a182a4 100644
--- a/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp
+++ b/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp
@@ -278,25 +278,27 @@ PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems(
// 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();
- if (range.get()) {
+ VisibleSelection selection = selectedFrame->selection()->selection();
+ if (selection.isCaretOrRange()) {
+ if (selection.isCaret())
+ selection.expandUsingGranularity(WordGranularity);
+ RefPtr<Range> range = selection.toNormalizedRange();
Vector<DocumentMarker*> markers = selectedFrame->document()->markers()->markersInRange(range.get(), DocumentMarker::Spelling | DocumentMarker::Grammar);
- 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.misspelledWord = selectMisspelledWord(defaultMenu, selectedFrame);
- if (!suggestions.isEmpty())
+ 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()) {
+ } else if (m_webView->spellCheckClient()) {
int misspelledOffset, misspelledLength;
m_webView->spellCheckClient()->spellCheck(data.misspelledWord, misspelledOffset, misspelledLength, &data.dictionarySuggestions);
}
+ selection = VisibleSelection(range.get());
+ if (selectedFrame->selection()->shouldChangeSelection(selection))
+ selectedFrame->selection()->setSelection(selection, WordGranularity);
}
}
} else if (m_webView->focusedWebCoreFrame()->editor()->isContinuousSpellCheckingEnabled()) {