Commit d4f3e77a authored by morrita@google.com's avatar morrita@google.com

2011-02-03 MORITA Hajime <morrita@google.com>

        Reviewed by Darin Fisher.

        [Chromium] Should implement EditorClientImpl::requestCheckingOfString()
        https://bugs.webkit.org/show_bug.cgi?id=51013

        Unskipped passed test.

        * platform/chromium/test_expectations.txt:
2011-02-03  MORITA Hajime  <morrita@google.com>

        Reviewed by Darin Fisher.

        [Chromium] Should implement EditorClientImpl::requestCheckingOfString()
        https://bugs.webkit.org/show_bug.cgi?id=51013

        - Added WebTextCheckingCompletion to receive the checked result asynchronously.
        - Added WebViewClient::requestCheckingOfText() and related classes.
        - Implemented EditorClientImpl::requestCheckingOfString().

        * WebKit.gyp:
        * public/WebSettings.h:
        * public/WebTextCheckingCompletion.h: Added.
        (WebKit::WebTextCheckingCompletion::~WebTextCheckingCompletion):
        * public/WebTextCheckingResult.h: Added.
        (WebKit::WebTextCheckingResult::error):
        (WebKit::WebTextCheckingResult::position):
        (WebKit::WebTextCheckingResult::length):
        (WebKit::WebTextCheckingResult::WebTextCheckingResult):
        * public/WebViewClient.h:
        (WebKit::WebViewClient::requestCheckingOfText): Gave an implementation
        * src/AssertMatchingEnums.cpp:
        * src/EditorClientImpl.cpp:
        (WebKit::EditorClientImpl::requestCheckingOfString):
        * src/EditorClientImpl.h:
        * src/WebSettingsImpl.cpp:
        (WebKit::WebSettingsImpl::setAsynchronousSpellCheckingEnabled):
        * src/WebSettingsImpl.h:
        * src/WebTextCheckingCompletionImpl.cpp: Added.
        (WebKit::toCoreResults):
        (WebKit::WebTextCheckingCompletionImpl::didFinishCheckingText):
        * src/WebTextCheckingCompletionImpl.h: Added.
        (WebKit::WebTextCheckingCompletionImpl::WebTextCheckingCompletionImpl):
2011-02-03  MORITA Hajime  <morrita@google.com>

        Reviewed by Darin Fisher.

        [Chromium] Should implement EditorClientImpl::requestCheckingOfString()
        https://bugs.webkit.org/show_bug.cgi?id=51013

        Gave DRT implementation for requestTextCheck().

        * DumpRenderTree/chromium/LayoutTestController.cpp:
        (LayoutTestController::setAsynchronousSpellCheckingEnabled): Implemented.
        * DumpRenderTree/chromium/WebViewHost.cpp:
        (invokeFinishLastTextCheck): Added.
        (WebViewHost::requestTextCheck): Added.
        (WebViewHost::finishLastTextCheck): Added.
        * DumpRenderTree/chromium/WebViewHost.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77875 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a9e1c59b
2011-02-03 MORITA Hajime <morrita@google.com>
Reviewed by Darin Fisher.
[Chromium] Should implement EditorClientImpl::requestCheckingOfString()
https://bugs.webkit.org/show_bug.cgi?id=51013
Unskipped passed test.
* platform/chromium/test_expectations.txt:
2011-02-07 Martin Robinson <mrobinson@igalia.com>
Classify tests failing in the fast directory on GTK+. Add results for
......@@ -2180,10 +2180,6 @@ BUGWK41311 WIN LINUX : fast/borders/borderRadiusDouble07.html = IMAGE
BUGWK41311 WIN LINUX : fast/borders/borderRadiusDouble08.html = IMAGE
BUGWK41311 WIN LINUX : fast/borders/borderRadiusDouble09.html = IMAGE
// Need to implement EditorClient::requestCheckingOfString()
// Overriden with 66682
// BUGWK41423 WIN LINUX : editing/spelling/spellcheck-paste.html = TEXT
// Flaky tests.
BUGCR44345 LINUX : svg/zoom/text/zoom-hixie-mixed-009.xml = IMAGE PASS
BUGCR44346 LINUX : svg/zoom/page/zoom-hixie-mixed-009.xml = IMAGE PASS
......@@ -2873,7 +2869,6 @@ BUGCR66466 MAC WIN DEBUG SLOW : perf/array-nested-loop.html = PASS TEXT
BUGCR66554 WIN DEBUG : fast/js/kde/encode_decode_uri.html = CRASH PASS
BUGCR66683 WIN LINUX : fast/canvas/canvas-draw-canvas-on-canvas-shadow.html = TEXT
BUGCR66682 WIN LINUX MAC : editing/spelling/spellcheck-paste.html = TEXT TIMEOUT
BUGCR66686 : fast/loader/user-stylesheet-fast-path.html = TEXT
BUGCR66751 : http/tests/local/link-stylesheet-load-order-preload.html = TEXT TIMEOUT PASS
......
2011-02-03 MORITA Hajime <morrita@google.com>
Reviewed by Darin Fisher.
[Chromium] Should implement EditorClientImpl::requestCheckingOfString()
https://bugs.webkit.org/show_bug.cgi?id=51013
- Added WebTextCheckingCompletion to receive the checked result asynchronously.
- Added WebViewClient::requestCheckingOfText() and related classes.
- Implemented EditorClientImpl::requestCheckingOfString().
* WebKit.gyp:
* public/WebSettings.h:
* public/WebTextCheckingCompletion.h: Added.
(WebKit::WebTextCheckingCompletion::~WebTextCheckingCompletion):
* public/WebTextCheckingResult.h: Added.
(WebKit::WebTextCheckingResult::error):
(WebKit::WebTextCheckingResult::position):
(WebKit::WebTextCheckingResult::length):
(WebKit::WebTextCheckingResult::WebTextCheckingResult):
* public/WebViewClient.h:
(WebKit::WebViewClient::requestCheckingOfText): Gave an implementation
* src/AssertMatchingEnums.cpp:
* src/EditorClientImpl.cpp:
(WebKit::EditorClientImpl::requestCheckingOfString):
* src/EditorClientImpl.h:
* src/WebSettingsImpl.cpp:
(WebKit::WebSettingsImpl::setAsynchronousSpellCheckingEnabled):
* src/WebSettingsImpl.h:
* src/WebTextCheckingCompletionImpl.cpp: Added.
(WebKit::toCoreResults):
(WebKit::WebTextCheckingCompletionImpl::didFinishCheckingText):
* src/WebTextCheckingCompletionImpl.h: Added.
(WebKit::WebTextCheckingCompletionImpl::WebTextCheckingCompletionImpl):
2011-02-07 Enrica Casucci <enrica@apple.com>
Reviewed Adam Roben and Darin Adler.
......@@ -273,6 +273,8 @@
'public/WebString.h',
'public/WebTextAffinity.h',
'public/WebTextCaseSensitivity.h',
'public/WebTextCheckingResult.h',
'public/WebTextCheckingCompletion.h',
'public/WebTextDirection.h',
'public/WebTextInputType.h',
'public/WebTextRun.h',
......@@ -401,6 +403,8 @@
'src/StorageNamespaceProxy.cpp',
'src/StorageNamespaceProxy.h',
'src/TemporaryGlue.h',
'src/WebTextCheckingCompletionImpl.h',
'src/WebTextCheckingCompletionImpl.cpp',
'src/VideoFrameChromiumImpl.cpp',
'src/VideoFrameChromiumImpl.h',
'src/WebAccessibilityCache.cpp',
......
......@@ -104,6 +104,7 @@ public:
virtual void setAccelerated2dCanvasEnabled(bool) = 0;
virtual void setMemoryInfoEnabled(bool) = 0;
virtual void setHyperlinkAuditingEnabled(bool) = 0;
virtual void setAsynchronousSpellCheckingEnabled(bool) = 0;
virtual void setCaretBrowsingEnabled(bool) = 0;
virtual void setInteractiveFormValidationEnabled(bool) = 0;
......
/*
* 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 WebTextCheckingCompletion_h
#define WebTextCheckingCompletion_h
#include "WebCommon.h"
namespace WebKit {
class WebTextCheckingResult;
template <typename T> class WebVector;
// Gets called back when WebViewClient finished an asynchronous spell checking.
class WebTextCheckingCompletion {
public:
virtual void didFinishCheckingText(const WebVector<WebTextCheckingResult>&) = 0;
protected:
~WebTextCheckingCompletion() { }
};
} // namespace WebKit
#endif
/*
* 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 WebTextCheckingResult_h
#define WebTextCheckingResult_h
#include "WebCommon.h"
namespace WebKit {
// A checked entry of text checking.
class WebTextCheckingResult {
public:
enum Error {
ErrorSpelling = 1 << 0,
ErrorGrammar = 1 << 1
};
Error error() const { return m_error; }
int position() const { return m_position; }
int length() const { return m_length; }
WebTextCheckingResult(Error error, int position, int length)
: m_error(error)
, m_position(position)
, m_length(length)
{
}
private:
Error m_error;
int m_position;
int m_length;
};
} // namespace WebKit
#endif
......@@ -64,6 +64,7 @@ class WebRange;
class WebSpeechInputController;
class WebSpeechInputListener;
class WebStorageNamespace;
class WebTextCheckingCompletion;
class WebURL;
class WebURLRequest;
class WebView;
......@@ -178,7 +179,9 @@ public:
// 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(); }
......
......@@ -36,6 +36,7 @@
#include "AccessibilityObject.h"
#include "ApplicationCacheHost.h"
#include "AsyncFileSystem.h"
#include "DocumentMarker.h"
#include "EditorInsertAction.h"
#include "FileError.h"
#include "FileMetadata.h"
......@@ -74,6 +75,7 @@
#include "WebSettings.h"
#include "WebTextAffinity.h"
#include "WebTextCaseSensitivity.h"
#include "WebTextCheckingResult.h"
#include "WebVideoFrame.h"
#include "WebView.h"
#include <wtf/Assertions.h>
......@@ -397,6 +399,9 @@ COMPILE_ASSERT_MATCHING_ENUM(WebFileErrorPathExists, FileError::PATH_EXISTS_ERR)
COMPILE_ASSERT_MATCHING_ENUM(WebGeolocationError::ErrorPermissionDenied, GeolocationError::PermissionDenied);
COMPILE_ASSERT_MATCHING_ENUM(WebGeolocationError::ErrorPositionUnavailable, GeolocationError::PositionUnavailable);
COMPILE_ASSERT_MATCHING_ENUM(WebTextCheckingResult::ErrorSpelling, DocumentMarker::Spelling);
COMPILE_ASSERT_MATCHING_ENUM(WebTextCheckingResult::ErrorGrammar, DocumentMarker::Grammar);
#if OS(DARWIN)
COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::StateDisabled, PlatformBridge::StateDisabled);
COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::StateInactive, PlatformBridge::StateInactive);
......
......@@ -40,6 +40,7 @@
#include "PlatformKeyboardEvent.h"
#include "PlatformString.h"
#include "RenderObject.h"
#include "SpellChecker.h"
#include "DOMUtilitiesPrivate.h"
#include "WebAutoFillClient.h"
......@@ -54,6 +55,7 @@
#include "WebPasswordAutocompleteListener.h"
#include "WebRange.h"
#include "WebTextAffinity.h"
#include "WebTextCheckingCompletionImpl.h"
#include "WebViewClient.h"
#include "WebViewImpl.h"
......@@ -876,6 +878,11 @@ void EditorClientImpl::checkSpellingOfString(const UChar* text, int length,
*misspellingLength = spellLength;
}
void EditorClientImpl::requestCheckingOfString(SpellChecker* sender, int identifier, const String& text)
{
m_webView->client()->requestCheckingOfText(text, new WebTextCheckingCompletionImpl(identifier, sender));
}
String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord)
{
if (!(isContinuousSpellCheckingEnabled() && m_webView->client()))
......
......@@ -37,6 +37,7 @@
namespace WebCore {
class HTMLInputElement;
class SpellChecker;
}
namespace WebKit {
......@@ -111,7 +112,7 @@ public:
WTF::Vector<WTF::String>& guesses);
virtual void willSetInputMethodState();
virtual void setInputMethodState(bool enabled);
virtual void requestCheckingOfString(WebCore::SpellChecker*, int, const WTF::String&) {}
virtual void requestCheckingOfString(WebCore::SpellChecker*, int, const WTF::String&);
// Shows the form autofill popup for |node| if it is an HTMLInputElement and
// it is empty. This is called when you press the up or down arrow in a
......
......@@ -329,6 +329,11 @@ void WebSettingsImpl::setHyperlinkAuditingEnabled(bool enabled)
m_settings->setHyperlinkAuditingEnabled(enabled);
}
void WebSettingsImpl::setAsynchronousSpellCheckingEnabled(bool enabled)
{
m_settings->setAsynchronousSpellCheckingEnabled(enabled);
}
void WebSettingsImpl::setCaretBrowsingEnabled(bool enabled)
{
m_settings->setCaretBrowsingEnabled(enabled);
......
......@@ -97,6 +97,7 @@ public:
virtual void setAccelerated2dCanvasEnabled(bool);
virtual void setMemoryInfoEnabled(bool);
virtual void setHyperlinkAuditingEnabled(bool);
virtual void setAsynchronousSpellCheckingEnabled(bool);
virtual void setCaretBrowsingEnabled(bool);
virtual void setInteractiveFormValidationEnabled(bool);
......
/*
* Copyright (C) 2009 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.
*/
#include "config.h"
#include "WebTextCheckingCompletionImpl.h"
#include "SpellChecker.h"
#include "WebTextCheckingResult.h"
#include "WebVector.h"
using namespace WebCore;
namespace WebKit {
static Vector<SpellCheckingResult> toCoreResults(const WebVector<WebTextCheckingResult>& results)
{
Vector<SpellCheckingResult> coreResults;
for (size_t i = 0; i < results.size(); ++i)
coreResults.append(SpellCheckingResult(static_cast<DocumentMarker::MarkerType>(results[i].error()), results[i].position(), results[i].length()));
return coreResults;
}
void WebTextCheckingCompletionImpl::didFinishCheckingText(const WebVector<WebTextCheckingResult>& results)
{
m_spellChecker->didCheck(m_identifier, toCoreResults(results));
delete this;
}
} // namespace WebKit
/*
* 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 WebTextCheckingCompletionImpl_h
#define WebTextCheckingCompletionImpl_h
#include "WebTextCheckingCompletion.h"
namespace WebCore {
class SpellChecker;
}
namespace WebKit {
class WebTextCheckingCompletionImpl : public WebTextCheckingCompletion {
public:
WebTextCheckingCompletionImpl(int identifier, WebCore::SpellChecker* spellchecker)
: m_identifier(identifier), m_spellChecker(spellchecker)
{
}
virtual void didFinishCheckingText(const WebVector<WebTextCheckingResult>&);
private:
int m_identifier;
WebCore::SpellChecker* m_spellChecker;
};
} // namespace WebKit
#endif
2011-02-03 MORITA Hajime <morrita@google.com>
Reviewed by Darin Fisher.
[Chromium] Should implement EditorClientImpl::requestCheckingOfString()
https://bugs.webkit.org/show_bug.cgi?id=51013
Gave DRT implementation for requestTextCheck().
* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::setAsynchronousSpellCheckingEnabled): Implemented.
* DumpRenderTree/chromium/WebViewHost.cpp:
(invokeFinishLastTextCheck): Added.
(WebViewHost::requestTextCheck): Added.
(WebViewHost::finishLastTextCheck): Added.
* DumpRenderTree/chromium/WebViewHost.h:
2011-02-07 Joone Hur <joone.hur@collabora.co.uk>
Reviewed by Martin Robinson.
......@@ -627,9 +627,11 @@ void LayoutTestController::setAlwaysAcceptCookies(const CppArgumentList& argumen
result->setNull();
}
void LayoutTestController::setAsynchronousSpellCheckingEnabled(const CppArgumentList&, CppVariant*)
void LayoutTestController::setAsynchronousSpellCheckingEnabled(const CppArgumentList& arguments, CppVariant* result)
{
// FIXME: Implement this.
if (arguments.size() > 0 && arguments[0].isBool())
m_shell->webView()->settings()->setAsynchronousSpellCheckingEnabled(cppVariantToBool(arguments[0]));
result->setNull();
}
void LayoutTestController::showWebInspector(const CppArgumentList&, CppVariant* result)
......
......@@ -52,6 +52,8 @@
#include "WebSize.h"
#include "WebSpeechInputControllerMock.h"
#include "WebStorageNamespace.h"
#include "WebTextCheckingCompletion.h"
#include "WebTextCheckingResult.h"
#include "WebURLRequest.h"
#include "WebURLResponse.h"
#include "WebView.h"
......@@ -60,6 +62,7 @@
#include "webkit/support/webkit_support.h"
#include <wtf/Assertions.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
using namespace WebCore;
using namespace WebKit;
......@@ -225,6 +228,12 @@ static string textAffinityDescription(WebTextAffinity affinity)
return "(UNKNOWN AFFINITY)";
}
static void invokeFinishLastTextCheck(void* context)
{
WebViewHost* wvh = static_cast<WebViewHost*>(context);
wvh->finishLastTextCheck();
}
// WebViewClient -------------------------------------------------------------
WebView* WebViewHost::createView(WebFrame*, const WebURLRequest&, const WebWindowFeatures&, const WebString&)
......@@ -409,6 +418,35 @@ void WebViewHost::spellCheck(const WebString& text, int& misspelledOffset, int&
m_spellcheck.spellCheckWord(text, &misspelledOffset, &misspelledLength);
}
void WebViewHost::requestCheckingOfText(const WebString& text, WebTextCheckingCompletion* completion)
{
m_lastRequestedTextCheckingCompletion = completion;
m_lastRequestedTextCheckString = text;
webkit_support::PostDelayedTask(invokeFinishLastTextCheck, static_cast<void*>(this), 0);
}
void WebViewHost::finishLastTextCheck()
{
Vector<WebTextCheckingResult> results;
// FIXME: Do the grammar check.
int offset = 0;
String text(m_lastRequestedTextCheckString.data(), m_lastRequestedTextCheckString.length());
while (text.length()) {
int misspelledPosition = 0;
int misspelledLength = 0;
m_spellcheck.spellCheckWord(WebString(text.characters(), text.length()), &misspelledPosition, &misspelledLength);
if (!misspelledLength)
break;
results.append(WebTextCheckingResult(WebTextCheckingResult::ErrorSpelling, offset + misspelledPosition, misspelledLength));
text = text.substring(misspelledPosition + misspelledLength);
offset += misspelledPosition;
}
m_lastRequestedTextCheckingCompletion->didFinishCheckingText(results);
m_lastRequestedTextCheckingCompletion = 0;
}
WebString WebViewHost::autoCorrectWord(const WebString&)
{
// Returns an empty string as Mac WebKit ('WebKitSupport/WebEditorClient.mm')
......@@ -1115,6 +1153,7 @@ void WebViewHost::openFileSystem(WebFrame* frame, WebFileSystem::Type type, long
WebViewHost::WebViewHost(TestShell* shell)
: m_shell(shell)
, m_webWidget(0)
, m_lastRequestedTextCheckingCompletion(0)
{
reset();
}
......
......@@ -126,6 +126,7 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
virtual void didEndEditing();
virtual bool handleCurrentKeyboardEvent();
virtual void spellCheck(const WebKit::WebString&, int& offset, int& length);
virtual void requestCheckingOfText(const WebKit::WebString&, WebKit::WebTextCheckingCompletion*);
virtual WebKit::WebString autoCorrectWord(const WebKit::WebString&);
virtual void runModalAlertDialog(WebKit::WebFrame*, const WebKit::WebString&);
virtual bool runModalConfirmDialog(WebKit::WebFrame*, const WebKit::WebString&);
......@@ -207,7 +208,10 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
virtual void openFileSystem(WebKit::WebFrame*, WebKit::WebFileSystem::Type, long long size, bool create, WebKit::WebFileSystemCallbacks*);
WebKit::WebDeviceOrientationClientMock* deviceOrientationClientMock();
// Spellcheck related helper APIs
MockSpellCheck* mockSpellCheck();
void finishLastTextCheck();
// Geolocation client mocks for LayoutTestController
WebKit::WebGeolocationClientMock* geolocationClientMock();
......@@ -320,6 +324,9 @@ private:
OwnPtr<WebKit::WebSpeechInputControllerMock> m_speechInputControllerMock;
OwnPtr<TestNavigationController*> m_navigationController;
WebKit::WebString m_lastRequestedTextCheckString;
WebKit::WebTextCheckingCompletion* m_lastRequestedTextCheckingCompletion;
};
#endif // WebViewHost_h
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