Split the words before sending it to spellCheck

This commit is contained in:
Cheng Zhao 2014-12-19 20:42:19 -08:00
parent b801a93dc5
commit c6a18b1b59
7 changed files with 720 additions and 19 deletions

View file

@ -5,6 +5,10 @@
#ifndef ATOM_RENDERER_API_ATOM_API_SPELL_CHECK_CLIENT_H_
#define ATOM_RENDERER_API_ATOM_API_SPELL_CHECK_CLIENT_H_
#include <string>
#include "base/callback.h"
#include "chrome/renderer/spellchecker/spellcheck_worditerator.h"
#include "native_mate/scoped_persistent.h"
#include "third_party/WebKit/public/web/WebSpellCheckClient.h"
@ -14,7 +18,9 @@ namespace api {
class SpellCheckClient : public blink::WebSpellCheckClient {
public:
SpellCheckClient(v8::Isolate* isolate, v8::Handle<v8::Object> provider);
SpellCheckClient(v8::Isolate* isolate,
const std::string& language,
v8::Handle<v8::Object> provider);
virtual ~SpellCheckClient();
private:
@ -44,8 +50,28 @@ class SpellCheckClient : public blink::WebSpellCheckClient {
bool CallProviderMethod(const char* method, const blink::WebString& text,
T* result);
// Call JavaScript to check spelling.
bool CheckSpelling(const base::string16& word_to_check);
// Returns whether or not the given word is a contraction of valid words
// (e.g. "word:word").
bool IsValidContraction(const base::string16& word);
// Represents character attributes used for filtering out characters which
// are not supported by this SpellCheck object.
SpellcheckCharAttribute character_attributes_;
// Represents word iterators used in this spellchecker. The |text_iterator_|
// splits text provided by WebKit into words, contractions, or concatenated
// words. The |contraction_iterator_| splits a concatenated word extracted by
// |text_iterator_| into word components so we can treat a concatenated word
// consisting only of correct words as a correct word.
SpellcheckWordIterator text_iterator_;
SpellcheckWordIterator contraction_iterator_;
v8::Isolate* isolate_;
mate::ScopedPersistent<v8::Object> provider_;
mate::ScopedPersistent<v8::Function> spell_check_;
DISALLOW_COPY_AND_ASSIGN(SpellCheckClient);
};