Commit a74353d4 authored by jam@chromium.org's avatar jam@chromium.org

2011-03-24 John Abd-El-Malek <jam@chromium.org>

        Reviewed by Dimitri Glazkov.

        [chromium] Add setters for various client interfaces, and add WebSpellCheckClient
        https://bugs.webkit.org/show_bug.cgi?id=57070

        * public/WebSpellCheckClient.h: Added.
        (WebKit::WebSpellCheckClient::spellCheck):
        (WebKit::WebSpellCheckClient::requestCheckingOfText):
        (WebKit::WebSpellCheckClient::autoCorrectWord):
        (WebKit::WebSpellCheckClient::showSpellingUI):
        (WebKit::WebSpellCheckClient::isShowingSpellingUI):
        (WebKit::WebSpellCheckClient::updateSpellingUIWithMisspelledWord):
        (WebKit::WebSpellCheckClient::~WebSpellCheckClient):
        * public/WebView.h:
        * public/WebViewClient.h:
        * src/EditorClientImpl.cpp:
        (WebKit::EditorClientImpl::checkSpellingOfString):
        (WebKit::EditorClientImpl::requestCheckingOfString):
        (WebKit::EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord):
        (WebKit::EditorClientImpl::updateSpellingUIWithMisspelledWord):
        (WebKit::EditorClientImpl::showSpellingUI):
        (WebKit::EditorClientImpl::spellingUIIsShowing):
        * src/WebViewImpl.cpp:
        (WebKit::WebViewImpl::setWebDevToolsAgentClient):
        (WebKit::WebViewImpl::setWebAutoFillClient):
        (WebKit::WebViewImpl::setWebSpellCheckClient):
        (WebKit::WebViewImpl::WebViewImpl):
        * src/WebViewImpl.h:
        (WebKit::WebViewImpl::spellCheckClient):


git-svn-id: svn://svn.chromium.org/blink/trunk@81987 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent bdb5d14c
2011-03-24 John Abd-El-Malek <jam@chromium.org>
Reviewed by Dimitri Glazkov.
[chromium] Add setters for various client interfaces, and add WebSpellCheckClient
https://bugs.webkit.org/show_bug.cgi?id=57070
* public/WebSpellCheckClient.h: Added.
(WebKit::WebSpellCheckClient::spellCheck):
(WebKit::WebSpellCheckClient::requestCheckingOfText):
(WebKit::WebSpellCheckClient::autoCorrectWord):
(WebKit::WebSpellCheckClient::showSpellingUI):
(WebKit::WebSpellCheckClient::isShowingSpellingUI):
(WebKit::WebSpellCheckClient::updateSpellingUIWithMisspelledWord):
(WebKit::WebSpellCheckClient::~WebSpellCheckClient):
* public/WebView.h:
* public/WebViewClient.h:
* src/EditorClientImpl.cpp:
(WebKit::EditorClientImpl::checkSpellingOfString):
(WebKit::EditorClientImpl::requestCheckingOfString):
(WebKit::EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord):
(WebKit::EditorClientImpl::updateSpellingUIWithMisspelledWord):
(WebKit::EditorClientImpl::showSpellingUI):
(WebKit::EditorClientImpl::spellingUIIsShowing):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::setWebDevToolsAgentClient):
(WebKit::WebViewImpl::setWebAutoFillClient):
(WebKit::WebViewImpl::setWebSpellCheckClient):
(WebKit::WebViewImpl::WebViewImpl):
* src/WebViewImpl.h:
(WebKit::WebViewImpl::spellCheckClient):
2011-03-25 Cary Clark <caryclark@google.com> 2011-03-25 Cary Clark <caryclark@google.com>
Reviewed by Dimitri Glazkov. Reviewed by Dimitri Glazkov.
......
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WebSpellCheckClient_h
#define WebSpellCheckClient_h
namespace WebKit {
class WebString;
class WebTextCheckingCompletion;
class WebSpellCheckClient {
public:
// The client should perform spell-checking on the given text. If the
// text contains a misspelled word, then upon return misspelledOffset
// will point to the start of the misspelled word, and misspelledLength
// will indicates its length. Otherwise, if there was not a spelling
// error, then upon return misspelledLength is 0.
virtual void spellCheck(
const WebString& text, int& misspelledOffset, int& misspelledLength) { }
// Requests asynchronous spelling and grammar checking, whose result should be
// returned by passed completion object.
virtual void requestCheckingOfText(const WebString&, WebTextCheckingCompletion*) { }
// Computes an auto-corrected replacement for a misspelled word. If no
// replacement is found, then an empty string is returned.
virtual WebString autoCorrectWord(const WebString& misspelledWord) { return WebString(); }
// Show or hide the spelling UI.
virtual void showSpellingUI(bool show) { }
// Returns true if the spelling UI is showing.
virtual bool isShowingSpellingUI() { return false; }
// Update the spelling UI with the given word.
virtual void updateSpellingUIWithMisspelledWord(const WebString& word) { }
protected:
~WebSpellCheckClient() { }
};
} // namespace WebKit
#endif
...@@ -36,9 +36,6 @@ ...@@ -36,9 +36,6 @@
#include "WebVector.h" #include "WebVector.h"
#include "WebWidget.h" #include "WebWidget.h"
// FIXME(jam): take out once Chromium rolls past this revision
#define WEBKIT_HAS_WEB_AUTO_FILL_CLIENT
namespace WebKit { namespace WebKit {
class WebAccessibilityObject; class WebAccessibilityObject;
...@@ -51,6 +48,7 @@ class WebFrameClient; ...@@ -51,6 +48,7 @@ class WebFrameClient;
class WebGraphicsContext3D; class WebGraphicsContext3D;
class WebNode; class WebNode;
class WebSettings; class WebSettings;
class WebSpellCheckClient;
class WebString; class WebString;
class WebViewClient; class WebViewClient;
struct WebMediaPlayerAction; struct WebMediaPlayerAction;
...@@ -86,9 +84,10 @@ public: ...@@ -86,9 +84,10 @@ public:
// Creates a WebView that is NOT yet initialized. You will need to // Creates a WebView that is NOT yet initialized. You will need to
// call initializeMainFrame to finish the initialization. It is valid // call initializeMainFrame to finish the initialization. It is valid
// to pass null client pointers. // to pass null client pointers.
// FIXME(jam): take out default parameters once chromium stops passing them.
WEBKIT_API static WebView* create(WebViewClient*, WEBKIT_API static WebView* create(WebViewClient*,
WebDevToolsAgentClient*, WebDevToolsAgentClient* = 0,
WebAutoFillClient*); WebAutoFillClient* = 0);
// After creating a WebView, you should immediately call this method. // After creating a WebView, you should immediately call this method.
// You can optionally modify the settings before calling this method. // You can optionally modify the settings before calling this method.
...@@ -96,6 +95,11 @@ public: ...@@ -96,6 +95,11 @@ public:
// child frames. It is valid to pass a null WebFrameClient pointer. // child frames. It is valid to pass a null WebFrameClient pointer.
virtual void initializeMainFrame(WebFrameClient*) = 0; virtual void initializeMainFrame(WebFrameClient*) = 0;
// Initializes the various client interfaces.
virtual void setDevToolsAgentClient(WebDevToolsAgentClient*) = 0;
virtual void setAutoFillClient(WebAutoFillClient*) = 0;
virtual void setSpellCheckClient(WebSpellCheckClient*) = 0;
// Options ------------------------------------------------------------- // Options -------------------------------------------------------------
......
...@@ -171,6 +171,7 @@ public: ...@@ -171,6 +171,7 @@ public:
// Spellchecker -------------------------------------------------------- // Spellchecker --------------------------------------------------------
// FIXME(jam): remove once chromium is updated to use WebSpellCheckClient
// The client should perform spell-checking on the given text. If the // The client should perform spell-checking on the given text. If the
// text contains a misspelled word, then upon return misspelledOffset // text contains a misspelled word, then upon return misspelledOffset
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include "WebNode.h" #include "WebNode.h"
#include "WebPasswordAutocompleteListener.h" #include "WebPasswordAutocompleteListener.h"
#include "WebRange.h" #include "WebRange.h"
#include "WebSpellCheckClient.h"
#include "WebTextAffinity.h" #include "WebTextAffinity.h"
#include "WebTextCheckingCompletionImpl.h" #include "WebTextCheckingCompletionImpl.h"
#include "WebViewClient.h" #include "WebViewClient.h"
...@@ -856,6 +857,9 @@ void EditorClientImpl::checkSpellingOfString(const UChar* text, int length, ...@@ -856,6 +857,9 @@ void EditorClientImpl::checkSpellingOfString(const UChar* text, int length,
int spellLength = 0; int spellLength = 0;
// Check to see if the provided text is spelled correctly. // Check to see if the provided text is spelled correctly.
// FIXME(jam): remove once chrome is updated.
if (isContinuousSpellCheckingEnabled() && m_webView->spellCheckClient())
m_webView->spellCheckClient()->spellCheck(WebString(text, length), spellLocation, spellLength);
if (isContinuousSpellCheckingEnabled() && m_webView->client()) if (isContinuousSpellCheckingEnabled() && m_webView->client())
m_webView->client()->spellCheck(WebString(text, length), spellLocation, spellLength); m_webView->client()->spellCheck(WebString(text, length), spellLocation, spellLength);
else { else {
...@@ -873,7 +877,11 @@ void EditorClientImpl::checkSpellingOfString(const UChar* text, int length, ...@@ -873,7 +877,11 @@ void EditorClientImpl::checkSpellingOfString(const UChar* text, int length,
void EditorClientImpl::requestCheckingOfString(SpellChecker* sender, int identifier, const String& text) void EditorClientImpl::requestCheckingOfString(SpellChecker* sender, int identifier, const String& text)
{ {
m_webView->client()->requestCheckingOfText(text, new WebTextCheckingCompletionImpl(identifier, sender)); // FIXME(jam): remove once chrome is updated.
if (m_webView->spellCheckClient())
m_webView->spellCheckClient()->requestCheckingOfText(text, new WebTextCheckingCompletionImpl(identifier, sender));
else
m_webView->client()->requestCheckingOfText(text, new WebTextCheckingCompletionImpl(identifier, sender));
} }
String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord) String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord)
...@@ -888,6 +896,9 @@ String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(const String& ...@@ -888,6 +896,9 @@ String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(const String&
return String(); return String();
} }
// FIXME(jam): remove once chrome is updated.
if (m_webView->spellCheckClient())
return m_webView->spellCheckClient()->autoCorrectWord(WebString(misspelledWord));
return m_webView->client()->autoCorrectWord(WebString(misspelledWord)); return m_webView->client()->autoCorrectWord(WebString(misspelledWord));
} }
...@@ -911,18 +922,27 @@ void EditorClientImpl::updateSpellingUIWithGrammarString(const String&, ...@@ -911,18 +922,27 @@ void EditorClientImpl::updateSpellingUIWithGrammarString(const String&,
void EditorClientImpl::updateSpellingUIWithMisspelledWord(const String& misspelledWord) void EditorClientImpl::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
{ {
if (m_webView->client()) // FIXME(jam): remove once chrome is updated.
if (m_webView->spellCheckClient())
m_webView->spellCheckClient()->updateSpellingUIWithMisspelledWord(WebString(misspelledWord));
else if (m_webView->client())
m_webView->client()->updateSpellingUIWithMisspelledWord(WebString(misspelledWord)); m_webView->client()->updateSpellingUIWithMisspelledWord(WebString(misspelledWord));
} }
void EditorClientImpl::showSpellingUI(bool show) void EditorClientImpl::showSpellingUI(bool show)
{ {
if (m_webView->client()) // FIXME(jam): remove once chrome is updated.
if (m_webView->spellCheckClient())
m_webView->spellCheckClient()->showSpellingUI(show);
else if (m_webView->client())
m_webView->client()->showSpellingUI(show); m_webView->client()->showSpellingUI(show);
} }
bool EditorClientImpl::spellingUIIsShowing() bool EditorClientImpl::spellingUIIsShowing()
{ {
// FIXME(jam): remove once chrome is updated.
if (m_webView->spellCheckClient())
return m_webView->spellCheckClient()->isShowingSpellingUI();
if (m_webView->client()) if (m_webView->client())
return m_webView->client()->isShowingSpellingUI(); return m_webView->client()->isShowingSpellingUI();
return false; return false;
......
...@@ -270,9 +270,28 @@ void WebViewImpl::initializeMainFrame(WebFrameClient* frameClient) ...@@ -270,9 +270,28 @@ void WebViewImpl::initializeMainFrame(WebFrameClient* frameClient)
SecurityOrigin::setLocalLoadPolicy(SecurityOrigin::AllowLocalLoadsForLocalOnly); SecurityOrigin::setLocalLoadPolicy(SecurityOrigin::AllowLocalLoadsForLocalOnly);
} }
void WebViewImpl::setDevToolsAgentClient(WebDevToolsAgentClient* devToolsClient)
{
if (devToolsClient)
m_devToolsAgent = new WebDevToolsAgentImpl(this, devToolsClient);
else
m_devToolsAgent.clear();
}
void WebViewImpl::setAutoFillClient(WebAutoFillClient* autoFillClient)
{
m_autoFillClient = autoFillClient;
}
void WebViewImpl::setSpellCheckClient(WebSpellCheckClient* spellCheckClient)
{
m_spellCheckClient = spellCheckClient;
}
WebViewImpl::WebViewImpl(WebViewClient* client, WebDevToolsAgentClient* devToolsClient, WebAutoFillClient* autoFillClient) WebViewImpl::WebViewImpl(WebViewClient* client, WebDevToolsAgentClient* devToolsClient, WebAutoFillClient* autoFillClient)
: m_client(client) : m_client(client)
, m_autoFillClient(autoFillClient) , m_autoFillClient(autoFillClient)
, m_spellCheckClient(0)
, m_chromeClientImpl(this) , m_chromeClientImpl(this)
, m_contextMenuClientImpl(this) , m_contextMenuClientImpl(this)
, m_dragClientImpl(this) , m_dragClientImpl(this)
...@@ -320,8 +339,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client, WebDevToolsAgentClient* devTools ...@@ -320,8 +339,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client, WebDevToolsAgentClient* devTools
// set to impossible point so we always get the first mouse pos // set to impossible point so we always get the first mouse pos
m_lastMousePosition = WebPoint(-1, -1); m_lastMousePosition = WebPoint(-1, -1);
if (devToolsClient) setDevToolsAgentClient(devToolsClient);
m_devToolsAgent = new WebDevToolsAgentImpl(this, devToolsClient);
Page::PageClients pageClients; Page::PageClients pageClients;
pageClients.chromeClient = &m_chromeClientImpl; pageClients.chromeClient = &m_chromeClientImpl;
......
...@@ -114,6 +114,9 @@ public: ...@@ -114,6 +114,9 @@ public:
// WebView methods: // WebView methods:
virtual void initializeMainFrame(WebFrameClient*); virtual void initializeMainFrame(WebFrameClient*);
virtual void setDevToolsAgentClient(WebDevToolsAgentClient*);
virtual void setAutoFillClient(WebAutoFillClient*);
virtual void setSpellCheckClient(WebSpellCheckClient*);
virtual WebSettings* settings(); virtual WebSettings* settings();
virtual WebString pageEncoding() const; virtual WebString pageEncoding() const;
virtual void setPageEncoding(const WebString& encoding); virtual void setPageEncoding(const WebString& encoding);
...@@ -224,6 +227,11 @@ public: ...@@ -224,6 +227,11 @@ public:
return m_autoFillClient; return m_autoFillClient;
} }
WebSpellCheckClient* spellCheckClient()
{
return m_spellCheckClient;
}
// Returns the page object associated with this view. This may be null when // Returns the page object associated with this view. This may be null when
// the page is shutting down, but will be valid at all other times. // the page is shutting down, but will be valid at all other times.
WebCore::Page* page() const WebCore::Page* page() const
...@@ -408,6 +416,7 @@ private: ...@@ -408,6 +416,7 @@ private:
WebViewClient* m_client; WebViewClient* m_client;
WebAutoFillClient* m_autoFillClient; WebAutoFillClient* m_autoFillClient;
WebSpellCheckClient* m_spellCheckClient;
ChromeClientImpl m_chromeClientImpl; ChromeClientImpl m_chromeClientImpl;
ContextMenuClientImpl m_contextMenuClientImpl; ContextMenuClientImpl m_contextMenuClientImpl;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment