summaryrefslogtreecommitdiffstats
path: root/Tools/DumpRenderTree/chromium/WebViewHost.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/DumpRenderTree/chromium/WebViewHost.cpp')
-rw-r--r--Tools/DumpRenderTree/chromium/WebViewHost.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.cpp b/Tools/DumpRenderTree/chromium/WebViewHost.cpp
index 18b107f..e1a2fcb 100644
--- a/Tools/DumpRenderTree/chromium/WebViewHost.cpp
+++ b/Tools/DumpRenderTree/chromium/WebViewHost.cpp
@@ -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')
@@ -1094,7 +1132,7 @@ void WebViewHost::didDisplayInsecureContent(WebFrame*)
fputs("didDisplayInsecureContent\n", stdout);
}
-void WebViewHost::didRunInsecureContent(WebFrame*, const WebSecurityOrigin& origin)
+void WebViewHost::didRunInsecureContent(WebFrame*, const WebSecurityOrigin& origin, const WebURL& insecureURL)
{
if (m_shell->shouldDumpFrameLoadCallbacks())
fputs("didRunInsecureContent\n", stdout);
@@ -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();
}