summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree/win/EditingDelegate.cpp
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2010-11-04 12:00:17 -0700
committerJohn Reck <jreck@google.com>2010-11-09 11:35:04 -0800
commite14391e94c850b8bd03680c23b38978db68687a8 (patch)
tree3fed87e6620fecaf3edc7259ae58a11662bedcb2 /WebKitTools/DumpRenderTree/win/EditingDelegate.cpp
parent1bd705833a68f07850cf7e204b26f8d328d16951 (diff)
downloadexternal_webkit-e14391e94c850b8bd03680c23b38978db68687a8.zip
external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.tar.gz
external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.tar.bz2
Merge Webkit at r70949: Initial merge by git.
Change-Id: I77b8645c083b5d0da8dba73ed01d4014aab9848e
Diffstat (limited to 'WebKitTools/DumpRenderTree/win/EditingDelegate.cpp')
-rw-r--r--WebKitTools/DumpRenderTree/win/EditingDelegate.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/WebKitTools/DumpRenderTree/win/EditingDelegate.cpp b/WebKitTools/DumpRenderTree/win/EditingDelegate.cpp
index 32c02bd..71859cb 100644
--- a/WebKitTools/DumpRenderTree/win/EditingDelegate.cpp
+++ b/WebKitTools/DumpRenderTree/win/EditingDelegate.cpp
@@ -353,3 +353,72 @@ HRESULT STDMETHODCALLTYPE EditingDelegate::webViewDidChangeSelection(
}
return S_OK;
}
+
+static int indexOfFirstWordCharacter(const TCHAR* text)
+{
+ const TCHAR* cursor = text;
+ while (*cursor && !isalpha(*cursor))
+ ++cursor;
+ return *cursor ? (cursor - text) : -1;
+};
+
+static int wordLength(const TCHAR* text)
+{
+ const TCHAR* cursor = text;
+ while (*cursor && isalpha(*cursor))
+ ++cursor;
+ return cursor - text;
+};
+
+HRESULT STDMETHODCALLTYPE EditingDelegate::checkSpellingOfString(
+ /* [in] */ IWebView* view,
+ /* [in] */ LPCTSTR text,
+ /* [in] */ int length,
+ /* [out] */ int* misspellingLocation,
+ /* [out] */ int* misspellingLength)
+{
+ static const TCHAR* misspelledWords[] = {
+ // These words are known misspelled words in webkit tests.
+ // If there are other misspelled words in webkit tests, please add them in
+ // this array.
+ TEXT("foo"),
+ TEXT("Foo"),
+ TEXT("baz"),
+ TEXT("fo"),
+ TEXT("LibertyF"),
+ TEXT("chello"),
+ TEXT("xxxtestxxx"),
+ TEXT("XXxxx"),
+ TEXT("Textx"),
+ TEXT("blockquoted"),
+ TEXT("asd"),
+ TEXT("Lorem"),
+ TEXT("Nunc"),
+ TEXT("Curabitur"),
+ TEXT("eu"),
+ TEXT("adlj"),
+ TEXT("adaasj"),
+ TEXT("sdklj"),
+ TEXT("jlkds"),
+ TEXT("jsaada"),
+ TEXT("jlda"),
+ TEXT("zz"),
+ TEXT("contentEditable"),
+ 0,
+ };
+
+ wstring textString(text, length);
+ int wordStart = indexOfFirstWordCharacter(textString.c_str());
+ if (-1 == wordStart)
+ return S_OK;
+ wstring word = textString.substr(wordStart, wordLength(textString.c_str() + wordStart));
+ for (size_t i = 0; misspelledWords[i]; ++i) {
+ if (word == misspelledWords[i]) {
+ *misspellingLocation = wordStart;
+ *misspellingLength = word.size();
+ break;
+ }
+ }
+
+ return S_OK;
+}