Title: [120274] trunk/Source/WebKit/chromium
Revision
120274
Author
[email protected]
Date
2012-06-13 21:08:17 -0700 (Wed, 13 Jun 2012)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (120273 => 120274)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-06-14 03:57:52 UTC (rev 120273)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-06-14 04:08:17 UTC (rev 120274)
@@ -1,3 +1,22 @@
+2012-06-13  Hironori Bono  <[email protected]>
+
+        [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):
+
 2012-06-13  Xianzhu Wang  <[email protected]>
 
         [Chromium] Let Android and Linux share WebFontRendering decl/impl.

Modified: trunk/Source/WebKit/chromium/public/WebFrame.h (120273 => 120274)


--- trunk/Source/WebKit/chromium/public/WebFrame.h	2012-06-14 03:57:52 UTC (rev 120273)
+++ trunk/Source/WebKit/chromium/public/WebFrame.h	2012-06-14 04:08:17 UTC (rev 120274)
@@ -434,6 +434,7 @@
     virtual void enableContinuousSpellChecking(bool) = 0;
     virtual bool isContinuousSpellCheckingEnabled() const = 0;
     virtual void requestTextChecking(const WebElement&) = 0;
+    virtual void replaceMisspelledRange(const WebString&) = 0;
 
     // Selection -----------------------------------------------------------
 

Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp (120273 => 120274)


--- trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2012-06-14 03:57:52 UTC (rev 120273)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2012-06-14 04:08:17 UTC (rev 120274)
@@ -1344,6 +1344,24 @@
     frame()->editor()->spellChecker()->requestCheckingFor(SpellCheckRequest::create(TextCheckingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToCheck, rangeToCheck));
 }
 
+void WebFrameImpl::replaceMisspelledRange(const WebString& text)
+{
+    // 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.
+    if (pluginContainerFromFrame(frame()))
+        return;
+    RefPtr<Range> caretRange = frame()->selection()->toNormalizedRange();
+    if (!caretRange)
+        return;
+    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()))
+        return;
+    frame()->selection()->setSelection(markerRange.get(), CharacterGranularity);
+    frame()->editor()->replaceSelectionWithText(text, false, true);
+}
+
 bool WebFrameImpl::hasSelection() const
 {
     WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());

Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.h (120273 => 120274)


--- trunk/Source/WebKit/chromium/src/WebFrameImpl.h	2012-06-14 03:57:52 UTC (rev 120273)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.h	2012-06-14 04:08:17 UTC (rev 120274)
@@ -171,6 +171,7 @@
     virtual void enableContinuousSpellChecking(bool);
     virtual bool isContinuousSpellCheckingEnabled() const;
     virtual void requestTextChecking(const WebElement&);
+    virtual void replaceMisspelledRange(const WebString&);
     virtual bool hasSelection() const;
     virtual WebRange selectionRange() const;
     virtual WebString selectionAsText() const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to