Changeset 120586 in webkit


Ignore:
Timestamp:
Jun 18, 2012 4:09:33 AM (12 years ago)
Author:
hbono@chromium.org
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().

Location:
trunk/Source/WebKit/chromium
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/chromium/ChangeLog

    r120585 r120586  
     12012-06-18  Hironori Bono  <hbono@chromium.org>
     2
     3        [chromium] Spellchecker should show suggestions only when right-clicking a misspelled word.
     4        https://bugs.webkit.org/show_bug.cgi?id=89331
     5
     6        Reviewed by Hajime Morita.
     7
     8        When a selection includes two or more misspelled words, it is not so easy to
     9        select one word from them and to show its suggestions. To avoid this problem,
     10        this change shows suggestions only when the selection is collapsed. For this
     11        case, we can use Range::setStart and setEnd to convert a DocumentMarker to a
     12        Range.
     13
     14        * src/ContextMenuClientImpl.cpp:
     15        (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): Added a check that the selection is collapsed.
     16        * src/WebFrameImpl.cpp:
     17        (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().
     18
    1192012-06-14  Kinuko Yasuda  <kinuko@chromium.org>
    220
  • trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp

    r118740 r120586  
    280280        if (selectedFrame->settings() && selectedFrame->settings()->asynchronousSpellCheckingEnabled()) {
    281281            RefPtr<Range> range = selectedFrame->selection()->toNormalizedRange();
    282             if (range.get()) {
     282            if (range.get() && range->collapsed()) {
    283283                Vector<DocumentMarker*> markers = selectedFrame->document()->markers()->markersInRange(range.get(), DocumentMarker::Spelling | DocumentMarker::Grammar);
    284284                if (!markers.isEmpty()) {
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp

    r120408 r120586  
    13561356    if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset())
    13571357        return;
    1358     RefPtr<Range> markerRange = TextIterator::rangeFromLocationAndLength(frame()->selection()->rootEditableElementOrDocumentElement(), markers[0]->startOffset(), markers[0]->endOffset() - markers[0]->startOffset());
    1359     if (!markerRange.get() || !frame()->selection()->shouldChangeSelection(markerRange.get()))
     1358    caretRange->setStart(caretRange->firstNode(), markers[0]->startOffset());
     1359    caretRange->setEnd(caretRange->firstNode(), markers[0]->endOffset());
     1360    if (!frame()->selection()->shouldChangeSelection(caretRange.get()))
    13601361        return;
    1361     frame()->selection()->setSelection(markerRange.get(), CharacterGranularity);
     1362    frame()->selection()->setSelection(caretRange.get(), CharacterGranularity);
    13621363    frame()->editor()->replaceSelectionWithText(text, false, true);
    13631364}
Note: See TracChangeset for help on using the changeset viewer.