Title: [120586] trunk/Source/WebKit/chromium
- Revision
- 120586
- Author
- hb...@chromium.org
- Date
- 2012-06-18 04:09:33 -0700 (Mon, 18 Jun 2012)
Log Message
[chromium] Spellchecker should show suggestions only when right-clicking a misspelled word.
https://bugs.webkit.org/show_bug.cgi?id=89331
Reviewed by Hajime Morita.
When a selection includes two or more misspelled words, it is not so easy to
select one word from them and to show its suggestions. To avoid this problem,
this change shows suggestions only when the selection is collapsed. For this
case, we can use Range::setStart and setEnd to convert a DocumentMarker to a
Range.
* src/ContextMenuClientImpl.cpp:
(WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): Added a check that the selection is collapsed.
* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::replaceMisspelledRange): Added a check that the selection is collapsed. Also, use Range::setStart() and Range::setEnd() to get the marker range to emulate the behavior of DocumentMarker::markersInRange().
Modified Paths
Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (120585 => 120586)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-06-18 10:56:34 UTC (rev 120585)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-06-18 11:09:33 UTC (rev 120586)
@@ -1,3 +1,21 @@
+2012-06-18 Hironori Bono <hb...@chromium.org>
+
+ [chromium] Spellchecker should show suggestions only when right-clicking a misspelled word.
+ https://bugs.webkit.org/show_bug.cgi?id=89331
+
+ Reviewed by Hajime Morita.
+
+ When a selection includes two or more misspelled words, it is not so easy to
+ select one word from them and to show its suggestions. To avoid this problem,
+ this change shows suggestions only when the selection is collapsed. For this
+ case, we can use Range::setStart and setEnd to convert a DocumentMarker to a
+ Range.
+
+ * src/ContextMenuClientImpl.cpp:
+ (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): Added a check that the selection is collapsed.
+ * src/WebFrameImpl.cpp:
+ (WebKit::WebFrameImpl::replaceMisspelledRange): Added a check that the selection is collapsed. Also, use Range::setStart() and Range::setEnd() to get the marker range to emulate the behavior of DocumentMarker::markersInRange().
+
2012-06-14 Kinuko Yasuda <kin...@chromium.org>
[chromium] Cleanup: remove PlatformSupport::createAsyncFileSystem as it's no longer used
Modified: trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp (120585 => 120586)
--- trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp 2012-06-18 10:56:34 UTC (rev 120585)
+++ trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp 2012-06-18 11:09:33 UTC (rev 120586)
@@ -279,7 +279,7 @@
// 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()) {
+ if (range.get() && range->collapsed()) {
Vector<DocumentMarker*> markers = selectedFrame->document()->markers()->markersInRange(range.get(), DocumentMarker::Spelling | DocumentMarker::Grammar);
if (!markers.isEmpty()) {
Vector<String> suggestions;
Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp (120585 => 120586)
--- trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp 2012-06-18 10:56:34 UTC (rev 120585)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp 2012-06-18 11:09:33 UTC (rev 120586)
@@ -1355,10 +1355,11 @@
Vector<DocumentMarker*> markers = frame()->document()->markers()->markersInRange(caretRange.get(), DocumentMarker::Spelling | DocumentMarker::Grammar);
if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset())
return;
- RefPtr<Range> markerRange = TextIterator::rangeFromLocationAndLength(frame()->selection()->rootEditableElementOrDocumentElement(), markers[0]->startOffset(), markers[0]->endOffset() - markers[0]->startOffset());
- if (!markerRange.get() || !frame()->selection()->shouldChangeSelection(markerRange.get()))
+ caretRange->setStart(caretRange->firstNode(), markers[0]->startOffset());
+ caretRange->setEnd(caretRange->firstNode(), markers[0]->endOffset());
+ if (!frame()->selection()->shouldChangeSelection(caretRange.get()))
return;
- frame()->selection()->setSelection(markerRange.get(), CharacterGranularity);
+ frame()->selection()->setSelection(caretRange.get(), CharacterGranularity);
frame()->editor()->replaceSelectionWithText(text, false, true);
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes