Changeset 120810 in webkit


Ignore:
Timestamp:
Jun 20, 2012 12:00:34 AM (12 years ago)
Author:
hbono@chromium.org
Message:

[chromium] Select the marker range when right-clicking on a marker.
https://bugs.webkit.org/show_bug.cgi?id=89331

Reviewed by Hajime Morita.

Chromium always selects only one word when right-clicking on a spelling marker.
This prevents selecting whole region specified by a marker if the marker
consists of two or more words. This change retrieves a range coverted by a
marker and select the range. This emulates the behavior of Mac Chromium and it
does not need any workarounds for Mac.

  • src/ContextMenuClientImpl.cpp:

(WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):

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

Legend:

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

    r120775 r120810  
     12012-06-20  Hironori Bono  <hbono@chromium.org>
     2
     3        [chromium] Select the marker range when right-clicking on a marker.
     4        https://bugs.webkit.org/show_bug.cgi?id=89331
     5
     6        Reviewed by Hajime Morita.
     7
     8        Chromium always selects only one word when right-clicking on a spelling marker.
     9        This prevents selecting whole region specified by a marker if the marker
     10        consists of two or more words. This change retrieves a range coverted by a
     11        marker and select the range. This emulates the behavior of Mac Chromium and it
     12        does not need any workarounds for Mac.
     13
     14        * src/ContextMenuClientImpl.cpp:
     15        (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
     16
    1172012-06-19  Kenneth Russell  <kbr@google.com>
    218
  • trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp

    r120689 r120810  
    279279        // a mouse on a word, Chrome just needs to find a spelling marker on the word instread of spellchecking it.
    280280        if (selectedFrame->settings() && selectedFrame->settings()->asynchronousSpellCheckingEnabled()) {
    281             RefPtr<Range> range = selectedFrame->selection()->toNormalizedRange();
    282             if (range.get()) {
     281            VisibleSelection selection = selectedFrame->selection()->selection();
     282            if (selection.isCaretOrRange()) {
     283                if (selection.isCaret())
     284                    selection.expandUsingGranularity(WordGranularity);
     285                RefPtr<Range> range = selection.toNormalizedRange();
    283286                Vector<DocumentMarker*> markers = selectedFrame->document()->markers()->markersInRange(range.get(), DocumentMarker::Spelling | DocumentMarker::Grammar);
    284                 if (!markers.isEmpty()) {
    285                     Vector<String> suggestions;
    286                     for (size_t i = 0; i < markers.size(); ++i) {
    287                         if (!markers[i]->description().isEmpty()) {
    288                             Vector<String> descriptions;
    289                             markers[i]->description().split('\n', descriptions);
    290                             suggestions.append(descriptions);
    291                         }
    292                     }
    293                     data.misspelledWord = selectMisspelledWord(defaultMenu, selectedFrame);
    294                     if (!suggestions.isEmpty())
     287                if (markers.size() == 1) {
     288                    range->setStart(range->startContainer(), markers[0]->startOffset());
     289                    range->setEnd(range->endContainer(), markers[0]->endOffset());
     290                    data.misspelledWord = range->text();
     291                    if (markers[0]->description().length()) {
     292                        Vector<String> suggestions;
     293                        markers[0]->description().split('\n', suggestions);
    295294                        data.dictionarySuggestions = suggestions;
    296                     else if (m_webView->spellCheckClient()) {
     295                    } else if (m_webView->spellCheckClient()) {
    297296                        int misspelledOffset, misspelledLength;
    298297                        m_webView->spellCheckClient()->spellCheck(data.misspelledWord, misspelledOffset, misspelledLength, &data.dictionarySuggestions);
    299298                    }
     299                    selection = VisibleSelection(range.get());
     300                    if (selectedFrame->selection()->shouldChangeSelection(selection))
     301                        selectedFrame->selection()->setSelection(selection, WordGranularity);
    300302                }
    301303            }
Note: See TracChangeset for help on using the changeset viewer.