TextCheckerEnchant.h [plain text]
#pragma once
#if ENABLE(SPELLCHECK)
#include <enchant.h>
#include <wtf/Forward.h>
#include <wtf/Vector.h>
namespace WebCore {
class TextCheckerEnchant {
WTF_MAKE_NONCOPYABLE(TextCheckerEnchant); WTF_MAKE_FAST_ALLOCATED;
friend class WTF::NeverDestroyed<TextCheckerEnchant>;
public:
static TextCheckerEnchant& singleton();
void ignoreWord(const String&);
void learnWord(const String&);
void checkSpellingOfString(const String&, int& misspellingLocation, int& misspellingLength);
Vector<String> getGuessesForWord(const String&);
void updateSpellCheckingLanguages(const Vector<String>& languages);
Vector<String> loadedSpellCheckingLanguages() const;
bool hasDictionary() const { return !m_enchantDictionaries.isEmpty(); }
Vector<String> availableSpellCheckingLanguages() const;
private:
TextCheckerEnchant();
~TextCheckerEnchant() = delete;
void checkSpellingOfWord(const String&, int start, int end, int& misspellingLocation, int& misspellingLength);
struct EnchantDictDeleter {
void operator()(EnchantDict*) const;
};
using UniqueEnchantDict = std::unique_ptr<EnchantDict, EnchantDictDeleter>;
EnchantBroker* m_broker;
Vector<UniqueEnchantDict> m_enchantDictionaries;
};
}
#endif // ENABLE(SPELLCHECK)