Changeset 120274 in webkit


Ignore:
Timestamp:
Jun 13, 2012 9:08:17 PM (12 years ago)
Author:
hbono@chromium.org
Message:

[chromium] Add WebFrame::replaceMisspelledRange
https://bugs.webkit.org/show_bug.cgi?id=88618

Reviewed by Kent Tamura.

This change adds WebFrame::replaceMisspelledRange, which replaces the range of a
misspelled marker with text so Chromium can use it for replacing misspelled
words with suggetions.

  • public/WebFrame.h:

(WebFrame):

  • src/WebFrameImpl.cpp:

(WebKit::WebFrameImpl::replaceMisspelledRange):
(WebKit):

  • src/WebFrameImpl.h:

(WebFrameImpl):

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

Legend:

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

    r120270 r120274  
     12012-06-13  Hironori Bono  <hbono@chromium.org>
     2
     3        [chromium] Add WebFrame::replaceMisspelledRange
     4        https://bugs.webkit.org/show_bug.cgi?id=88618
     5
     6        Reviewed by Kent Tamura.
     7
     8        This change adds WebFrame::replaceMisspelledRange, which replaces the range of a
     9        misspelled marker with text so Chromium can use it for replacing misspelled
     10        words with suggetions.
     11
     12        * public/WebFrame.h:
     13        (WebFrame):
     14        * src/WebFrameImpl.cpp:
     15        (WebKit::WebFrameImpl::replaceMisspelledRange):
     16        (WebKit):
     17        * src/WebFrameImpl.h:
     18        (WebFrameImpl):
     19
    1202012-06-13  Xianzhu Wang  <wangxianzhu@chromium.org>
    221
  • trunk/Source/WebKit/chromium/public/WebFrame.h

    r119666 r120274  
    435435    virtual bool isContinuousSpellCheckingEnabled() const = 0;
    436436    virtual void requestTextChecking(const WebElement&) = 0;
     437    virtual void replaceMisspelledRange(const WebString&) = 0;
    437438
    438439    // Selection -----------------------------------------------------------
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp

    r120219 r120274  
    13451345}
    13461346
     1347void WebFrameImpl::replaceMisspelledRange(const WebString& text)
     1348{
     1349    // If this caret selection has two or more markers, this function replace the range covered by the first marker with the specified word as Microsoft Word does.
     1350    if (pluginContainerFromFrame(frame()))
     1351        return;
     1352    RefPtr<Range> caretRange = frame()->selection()->toNormalizedRange();
     1353    if (!caretRange)
     1354        return;
     1355    Vector<DocumentMarker*> markers = frame()->document()->markers()->markersInRange(caretRange.get(), DocumentMarker::Spelling | DocumentMarker::Grammar);
     1356    if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset())
     1357        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()))
     1360        return;
     1361    frame()->selection()->setSelection(markerRange.get(), CharacterGranularity);
     1362    frame()->editor()->replaceSelectionWithText(text, false, true);
     1363}
     1364
    13471365bool WebFrameImpl::hasSelection() const
    13481366{
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.h

    r119508 r120274  
    172172    virtual bool isContinuousSpellCheckingEnabled() const;
    173173    virtual void requestTextChecking(const WebElement&);
     174    virtual void replaceMisspelledRange(const WebString&);
    174175    virtual bool hasSelection() const;
    175176    virtual WebRange selectionRange() const;
Note: See TracChangeset for help on using the changeset viewer.