[chromium] WebFrame should have an interface to invoke spellchecking in arbitrarily.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2012 08:42:30 +0000 (08:42 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2012 08:42:30 +0000 (08:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=73971

Patch by Shinya Kawanaka <shinyak@google.com> on 2012-01-20
Reviewed by Darin Fisher.

This interface is necessary to recheck spelling of an arbitrary element.

* public/WebFrame.h:
* public/WebNode.h:
* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::requestTextChecking):
  Requests spellchecking for the element having current selection.
* src/WebFrameImpl.h:
* src/WebNode.cpp:
(WebKit::WebNode::rootEditableElement):
  Takes a root editable element from Node.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105489 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebFrame.h
Source/WebKit/chromium/public/WebNode.h
Source/WebKit/chromium/src/WebFrameImpl.cpp
Source/WebKit/chromium/src/WebFrameImpl.h
Source/WebKit/chromium/src/WebNode.cpp

index f321a27..f9f055b 100644 (file)
@@ -1,3 +1,22 @@
+2012-01-20  Shinya Kawanaka  <shinyak@google.com>
+
+        [chromium] WebFrame should have an interface to invoke spellchecking in arbitrarily.
+        https://bugs.webkit.org/show_bug.cgi?id=73971
+
+        Reviewed by Darin Fisher.
+
+        This interface is necessary to recheck spelling of an arbitrary element.
+
+        * public/WebFrame.h:
+        * public/WebNode.h:
+        * src/WebFrameImpl.cpp:
+        (WebKit::WebFrameImpl::requestTextChecking):
+          Requests spellchecking for the element having current selection.
+        * src/WebFrameImpl.h:
+        * src/WebNode.cpp:
+        (WebKit::WebNode::rootEditableElement):
+          Takes a root editable element from Node.
+
 2012-01-19  Kinuko Yasuda  <kinuko@chromium.org>
 
         Cleanup: make constant variable names in fileapi/ conform to WebKit's coding guideline
index 85bbda1..9574c49 100644 (file)
@@ -418,7 +418,7 @@ public:
     // Spell-checking support.
     virtual void enableContinuousSpellChecking(bool) = 0;
     virtual bool isContinuousSpellCheckingEnabled() const = 0;
-
+    virtual void requestTextChecking(const WebElement&) = 0;
 
     // Selection -----------------------------------------------------------
 
index 38be3b6..d4ee874 100644 (file)
@@ -42,6 +42,7 @@ class WebDOMEvent;
 class WebDOMEventListener;
 class WebDOMEventListenerPrivate;
 class WebDocument;
+class WebElement;
 class WebFrame;
 class WebNodeList;
 
@@ -109,6 +110,7 @@ public:
     WEBKIT_EXPORT bool dispatchEvent(const WebDOMEvent&);
     WEBKIT_EXPORT void simulateClick();
     WEBKIT_EXPORT WebNodeList getElementsByTagName(const WebString&) const;
+    WEBKIT_EXPORT WebElement rootEditableElement() const;
 
     // Returns true if the node has a non-empty bounding box in layout.
     // This does not 100% guarantee the user can see it, but is pretty close.
index 3c9015f..9d0e0c3 100644 (file)
 #include "IconURL.h"
 #include "InspectorController.h"
 #include "KURL.h"
+#include "Node.h"
 #include "Page.h"
 #include "PageOverlay.h"
 #include "painting/GraphicsContextBuilder.h"
 #include "SecurityPolicy.h"
 #include "Settings.h"
 #include "SkiaUtils.h"
+#include "SpellChecker.h"
 #include "SubstituteData.h"
 #include "TextAffinity.h"
 #include "TextIterator.h"
@@ -1294,6 +1296,16 @@ bool WebFrameImpl::isContinuousSpellCheckingEnabled() const
     return frame()->editor()->isContinuousSpellCheckingEnabled();
 }
 
+void WebFrameImpl::requestTextChecking(const WebElement& webElem)
+{
+    if (webElem.isNull())
+        return;
+
+    RefPtr<Range> rangeToCheck = rangeOfContents(const_cast<Element*>(webElem.constUnwrap<Element>()));
+
+    frame()->editor()->spellChecker()->requestCheckingFor(SpellCheckRequest::create(TextCheckingTypeSpelling | TextCheckingTypeGrammar, rangeToCheck, rangeToCheck));
+}
+
 bool WebFrameImpl::hasSelection() const
 {
     WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
index 23e60d9..de38d0d 100644 (file)
@@ -158,6 +158,7 @@ public:
     virtual bool isCommandEnabled(const WebString&) const;
     virtual void enableContinuousSpellChecking(bool);
     virtual bool isContinuousSpellCheckingEnabled() const;
+    virtual void requestTextChecking(const WebElement&);
     virtual bool hasSelection() const;
     virtual WebRange selectionRange() const;
     virtual WebString selectionAsText() const;
index a4a26f2..69908c9 100644 (file)
@@ -42,6 +42,7 @@
 #include "WebDOMEvent.h"
 #include "WebDOMEventListener.h"
 #include "WebDocument.h"
+#include "WebElement.h"
 #include "WebFrameImpl.h"
 #include "WebNodeList.h"
 #include "platform/WebString.h"
@@ -207,6 +208,11 @@ WebNodeList WebNode::getElementsByTagName(const WebString& tag) const
     return WebNodeList(m_private->getElementsByTagName(tag));
 }
 
+WebElement WebNode::rootEditableElement() const
+{
+    return WebElement(m_private->rootEditableElement());
+}
+
 bool WebNode::hasNonEmptyBoundingBox() const
 {
     return m_private->hasNonEmptyBoundingBox();