1/* 2 * Copyright (C) 2012 Igalia S.L. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20#ifndef WebKitTextChecker_h 21#define WebKitTextChecker_h 22 23#if ENABLE(SPELLCHECK) 24 25#include <WebCore/TextCheckerEnchant.h> 26#include <wtf/FastMalloc.h> 27#include <wtf/OwnPtr.h> 28#include <wtf/Vector.h> 29#include <wtf/gobject/GRefPtr.h> 30#include <wtf/text/CString.h> 31 32class WebKitTextChecker { 33 WTF_MAKE_FAST_ALLOCATED; 34 35public: 36 static std::unique_ptr<WebKitTextChecker> create() 37 { 38 return std::unique_ptr<WebKitTextChecker>(new WebKitTextChecker); 39 } 40 ~WebKitTextChecker(); 41 42 // For implementing TextCheckerClient. 43 bool isSpellCheckingEnabled() { return m_spellCheckingEnabled; } 44 void setSpellCheckingEnabled(bool enabled); 45 void checkSpellingOfString(const String& string, int& misspellingLocation, int& misspellingLength); 46 Vector<String> getGuessesForWord(const String& word); 47 void learnWord(const String& word); 48 void ignoreWord(const String& word); 49 50 // To be called from WebKitWebContext only. 51 const char* const* getSpellCheckingLanguages(); 52 void setSpellCheckingLanguages(const char* const* spellCheckingLanguages); 53 54private: 55 WebKitTextChecker(); 56 57 OwnPtr<WebCore::TextCheckerEnchant> m_textChecker; 58 GRefPtr<GPtrArray> m_spellCheckingLanguages; 59 bool m_spellCheckingEnabled; 60}; 61 62#endif // ENABLE(SPELLCHECK) 63 64#endif // WebKitTextChecker_h 65