Title: [138216] trunk/Source/WebKit/chromium
- Revision
- 138216
- Author
- commit-qu...@webkit.org
- Date
- 2012-12-19 21:25:15 -0800 (Wed, 19 Dec 2012)
Log Message
[Chromium] Spellchecker should provide suggestions for non-caret selection, too
https://bugs.webkit.org/show_bug.cgi?id=104841
Patch by Rachel Blum <gr...@chromium.org> on 2012-12-19
Reviewed by Anders Carlsson.
Allow spelling suggestions for a word if the word is already selected. No suggestion
if subset of a word or more than a word is selected.
* src/ContextMenuClientImpl.cpp:
(WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
Modified Paths
Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (138215 => 138216)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-12-20 05:23:07 UTC (rev 138215)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-12-20 05:25:15 UTC (rev 138216)
@@ -1,3 +1,16 @@
+2012-12-19 Rachel Blum <gr...@chromium.org>
+
+ [Chromium] Spellchecker should provide suggestions for non-caret selection, too
+ https://bugs.webkit.org/show_bug.cgi?id=104841
+
+ Reviewed by Anders Carlsson.
+
+ Allow spelling suggestions for a word if the word is already selected. No suggestion
+ if subset of a word or more than a word is selected.
+
+ * src/ContextMenuClientImpl.cpp:
+ (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
+
2012-12-19 Mark Pilgrim <pilg...@chromium.org>
[Chromium] Remove all references to sharedWorkerRepository()
Modified: trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp (138215 => 138216)
--- trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp 2012-12-20 05:23:07 UTC (rev 138215)
+++ trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp 2012-12-20 05:25:15 UTC (rev 138216)
@@ -277,11 +277,19 @@
// 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()) {
VisibleSelection selection = selectedFrame->selection()->selection();
- if (selection.isCaret()) {
- selection.expandUsingGranularity(WordGranularity);
+ bool shouldUpdateSelection = false;
+ if (selection.isCaretOrRange()) {
+ if (selection.isCaret()) {
+ selection.expandUsingGranularity(WordGranularity);
+ shouldUpdateSelection = true;
+ }
RefPtr<Range> range = selection.toNormalizedRange();
Vector<DocumentMarker*> markers = selectedFrame->document()->markers()->markersInRange(range.get(), DocumentMarker::Spelling | DocumentMarker::Grammar);
if (markers.size() == 1) {
+ if (markers[0]->startOffset() != static_cast<unsigned>(range->startOffset()) || markers[0]->endOffset() != static_cast<unsigned>(range->endOffset()))
+ markers.clear();
+ }
+ if (markers.size() == 1) {
range->setStart(range->startContainer(), markers[0]->startOffset());
range->setEnd(range->endContainer(), markers[0]->endOffset());
data.misspelledWord = range->text();
@@ -294,7 +302,7 @@
m_webView->spellCheckClient()->spellCheck(data.misspelledWord, misspelledOffset, misspelledLength, &data.dictionarySuggestions);
}
selection = VisibleSelection(range.get());
- if (selectedFrame->selection()->shouldChangeSelection(selection))
+ if (shouldUpdateSelection && selectedFrame->selection()->shouldChangeSelection(selection))
selectedFrame->selection()->setSelection(selection, WordGranularity);
}
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes