WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-105034-20130122111632.patch (text/plain), 29.65 KB, created by
José Dapena Paz
on 2013-01-22 02:19:38 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
José Dapena Paz
Created:
2013-01-22 02:19:38 PST
Size:
29.65 KB
patch
obsolete
>Subversion Revision: 140340 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 4d9633b6daf9b4b8a726faf71c22f261f7cbb0db..f2312282b432b4d015d4fd29d4732ab4a14c421a 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,15 @@ >+2013-01-22 José Dapena Paz <jdapena@igalia.com> >+ >+ [Qt][WK2] Add spell checking support >+ https://bugs.webkit.org/show_bug.cgi?id=105034 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add support for building TextCheckerEnchant for Qt WebKit. >+ >+ * Target.pri: >+ * WebCore.pri: >+ > 2013-01-21 Joanmarie Diggs <jdiggs@igalia.com> > > Crash in AccessibilityTableCell::parentTable() >diff --git a/Source/WebKit/qt/ChangeLog b/Source/WebKit/qt/ChangeLog >index 647dbab84916ad5f9a22a716a19a0bba58fb818a..4a444c5830b7f14d74a4dada2212959e7186b400 100644 >--- a/Source/WebKit/qt/ChangeLog >+++ b/Source/WebKit/qt/ChangeLog >@@ -1,3 +1,16 @@ >+2013-01-22 José Dapena Paz <jdapena@igalia.com> >+ >+ [Qt][WK2] Add spell checking support >+ https://bugs.webkit.org/show_bug.cgi?id=105034 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Expose QWebGlobal on QML plugin. >+ >+ * declarative/experimental/plugin.cpp: >+ * declarative/plugin.cpp: >+ * declarative/public.pri: >+ > 2013-01-21 Allan Sandfeld Jensen <allan.jensen@digia.com> > > [Qt][WK1] Permission request callbacks for non-legacy notifications >diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog >index 110d485ed24b0e1de51d51361545f537a9cb46b0..d546d955a9e1599e65ca2fc958e7ea092eff46aa 100644 >--- a/Source/WebKit2/ChangeLog >+++ b/Source/WebKit2/ChangeLog >@@ -1,3 +1,52 @@ >+2013-01-22 José Dapena Paz <jdapena@igalia.com> >+ >+ [Qt][WK2] Add spell checking support >+ https://bugs.webkit.org/show_bug.cgi?id=105034 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Spellcheck support for Qt WebKit2. >+ >+ QtTextChecker object implements the WKTextCheckerClient interface >+ using TextCheckerEnchant in WebCore. >+ >+ Added webkit property, for accessing the objects shared among >+ all web views. This is for exposing and allowing to change >+ the current text checker status. This is a global as WebKit holds >+ internally a global for enabled text checker too. >+ >+ * Target.pri: >+ * UIProcess/API/qt/qwebglobal.cpp: Added. >+ (QWebGlobal::QWebGlobal): >+ (QWebGlobal::instance): >+ (QWebGlobal::textCheckerEnabled): >+ (QWebGlobal::setTextCheckerEnabled): >+ (QWebGlobal::setTextCheckerLanguages): >+ * UIProcess/API/qt/qwebglobal_p.h: Added. >+ * UIProcess/API/qt/qwebtextchecker.cpp: Added. >+ * UIProcess/API/qt/qwebtextchecker_p.h: Added. >+ * UIProcess/API/qt/qwebtextcheckerenchant.cpp: Added. >+ * UIProcess/API/qt/qwebtextcheckerenchant_p.h: Added. >+ * UIProcess/API/qt/qwebtextcheckerenchant_p_p.h: Added. >+ * UIProcess/qt/TextCheckerQt.cpp: >+ (WebKit::TextChecker::state): >+ (WebKit::TextChecker::isContinuousSpellCheckingAllowed): >+ (WebKit::TextChecker::setContinuousSpellCheckingEnabled): >+ (WebKit::TextChecker::setGrammarCheckingEnabled): >+ (WebKit::TextChecker::continuousSpellCheckingEnabledStateChanged): >+ (WebKit::TextChecker::grammarCheckingEnabledStateChanged): >+ (WebKit::TextChecker::uniqueSpellDocumentTag): >+ (WebKit::TextChecker::closeSpellDocumentWithTag): >+ (WebKit::TextChecker::checkSpellingOfString): >+ (WebKit::TextChecker::checkGrammarOfString): >+ (WebKit::TextChecker::spellingUIIsShowing): >+ (WebKit::TextChecker::toggleSpellingUIIsShowing): >+ (WebKit::TextChecker::updateSpellingUIWithMisspelledWord): >+ (WebKit::TextChecker::updateSpellingUIWithGrammarString): >+ (WebKit::TextChecker::getGuessesForWord): >+ (WebKit::TextChecker::learnWord): >+ (WebKit::TextChecker::ignoreWord): >+ > 2013-01-21 Gustavo Noronha Silva <gns@gnome.org> > > REGRESSION (r140285): GTK uses WKPageResourceLoadClient which was removed >diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri >index 09cca80ba62422424adfab00bbeabf619f41b818..b16115a802f255fd512c4b6f7fa30066d32b4577 100644 >--- a/Source/WebCore/Target.pri >+++ b/Source/WebCore/Target.pri >@@ -4116,6 +4116,11 @@ use?(WEBP) { > SOURCES += platform/image-decoders/webp/WEBPImageDecoder.cpp > } > >+use?(LIBENCHANT) { >+ HEADERS += platform/text/enchant/TextCheckerEnchant.h >+ SOURCES += platform/text/enchant/TextCheckerEnchant.cpp >+} >+ > !have?(sqlite3):exists($${SQLITE3SRCDIR}/sqlite3.c) { > # Build sqlite3 into WebCore from source > # somewhat copied from $$QT_SOURCE_TREE/src/plugins/sqldrivers/sqlite/sqlite.pro >diff --git a/Source/WebCore/WebCore.pri b/Source/WebCore/WebCore.pri >index 6e15568fb856dbef1c9214e10c2e5b039a9146f5..486255da63eb0adff2056eb474b3f8bad25d4793 100644 >--- a/Source/WebCore/WebCore.pri >+++ b/Source/WebCore/WebCore.pri >@@ -254,6 +254,11 @@ have?(sqlite3) { > LIBS += -lsqlite3 > } > } >+enable?(SPELLCHECK) { >+ use?(LIBENCHANT) { >+ PKGCONFIG += enchant >+ } >+} > > use?(libjpeg): LIBS += -ljpeg > use?(libpng): LIBS += -lpng >diff --git a/Source/WebKit/qt/declarative/experimental/plugin.cpp b/Source/WebKit/qt/declarative/experimental/plugin.cpp >index e6ffeda6eb0a50ba42f2ff4e069902e4baba5560..cbcf3f1c5966ce41bd0a8d1b30376897b817ede0 100644 >--- a/Source/WebKit/qt/declarative/experimental/plugin.cpp >+++ b/Source/WebKit/qt/declarative/experimental/plugin.cpp >@@ -25,12 +25,15 @@ > #include "private/qquickwebview_p.h" > #include "private/qtwebsecurityorigin_p.h" > #include "private/qwebdownloaditem_p.h" >+#include "private/qwebglobal_p.h" > #include "private/qwebkittest_p.h" > #include "private/qwebnavigationhistory_p.h" > #include "private/qwebpermissionrequest_p.h" > #include "private/qwebpreferences_p.h" > > #include <QtQml/qqml.h> >+#include <QtQml/qqmlcontext.h> >+#include <QtQml/qqmlengine.h> > #include <QtQml/qqmlextensionplugin.h> > > QT_BEGIN_NAMESPACE >@@ -47,6 +50,15 @@ class WebKitQmlExperimentalExtensionPlugin: public QQmlExtensionPlugin { > Q_OBJECT > Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "plugin.json") > public: >+ >+#if defined(HAVE_WEBKIT2) >+ virtual void initializeEngine(QQmlEngine* engine, const char* uri) >+ { >+ Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebKit.experimental")); >+ engine->rootContext()->setContextProperty(QLatin1String("webkit"), QWebGlobal::instance()); >+ } >+#endif >+ > virtual void registerTypes(const char* uri) > { > qWarning("\nWARNING: This project is using the experimental QML API extensions for QtWebKit and is therefore tied to a specific QtWebKit release.\n" >diff --git a/Source/WebKit/qt/declarative/public.pri b/Source/WebKit/qt/declarative/public.pri >index 5fc5985ebda5bc136b21a96ea3f39baaf0628143..7aacd040e104a1c2977b3bdbfce6023e92ad59b4 100644 >--- a/Source/WebKit/qt/declarative/public.pri >+++ b/Source/WebKit/qt/declarative/public.pri >@@ -38,6 +38,12 @@ SOURCES += plugin.cpp > build?(webkit2): { > DEFINES += HAVE_WEBKIT2 > QT += network >+ >+ contains(DEFINES, ENABLE_SPELLCHECK=1) { >+ config_libenchant { >+ DEFINES += WTF_USE_LIBENCHANT=1 >+ } >+ } > } > > # The fallback to QT_INSTALL_IMPORTS can be removed once we >diff --git a/Source/WebKit2/Target.pri b/Source/WebKit2/Target.pri >index 6c408a7037bc398f2b6e59728989889342bab2a6..c9a8b0bebbf915adb3892136896d593feca8fc56 100644 >--- a/Source/WebKit2/Target.pri >+++ b/Source/WebKit2/Target.pri >@@ -814,6 +814,7 @@ have?(QTQUICK) { > UIProcess/API/qt/qquicknetworkrequest_p.h \ > UIProcess/API/qt/qquickurlschemedelegate_p.h \ > UIProcess/API/qt/qwebkittest_p.h \ >+ UIProcess/API/qt/qwebglobal_p.h \ > UIProcess/qt/PageViewportControllerClientQt.h \ > UIProcess/qt/QtWebContext.h \ > UIProcess/qt/QtWebPageEventHandler.h \ >@@ -849,6 +850,7 @@ have?(QTQUICK) { > UIProcess/API/qt/qquicknetworkrequest.cpp \ > UIProcess/API/qt/qquickurlschemedelegate.cpp \ > UIProcess/API/qt/qwebpreferences.cpp \ >+ UIProcess/API/qt/qwebglobal.cpp \ > UIProcess/API/qt/qwebkittest.cpp \ > UIProcess/qt/PageViewportControllerClientQt.cpp \ > UIProcess/qt/QtDialogRunner.cpp \ >@@ -877,6 +879,14 @@ have?(QTQUICK) { > SOURCES += \ > UIProcess/qt/WebColorChooserProxyQt.cpp > } >+ >+ enable?(SPELLCHECK) { >+ HEADERS += \ >+ UIProcess/qt/QtTextChecker.h >+ SOURCES += \ >+ UIProcess/qt/QtTextChecker.cpp >+ PKGCONFIG += enchant >+ } > } > > mac: { >diff --git a/Source/WebKit2/UIProcess/API/qt/qwebglobal.cpp b/Source/WebKit2/UIProcess/API/qt/qwebglobal.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..e230ce9e5079a7ee0f3e14c1e364c2188335d7bb >--- /dev/null >+++ b/Source/WebKit2/UIProcess/API/qt/qwebglobal.cpp >@@ -0,0 +1,81 @@ >+/* >+ * Copyright (C) 2012 Igalia, S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This program is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this program; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ */ >+ >+#include "config.h" >+ >+#include "qwebglobal_p.h" >+ >+#include "QtTextChecker.h" >+ >+QWebGlobal::QWebGlobal() >+{ >+} >+ >+QWebGlobal* QWebGlobal::instance() >+{ >+ static QWebGlobal* s_instance = 0; >+ if (!s_instance) >+ s_instance = new QWebGlobal(); >+ >+ return s_instance; >+} >+ >+bool QWebGlobal::textCheckerEnabled() const >+{ >+#if ENABLE(SPELLCHECK) >+ return QtTextChecker::instance()->enabled(); >+#else >+ return false; >+#endif >+} >+ >+void QWebGlobal::setTextCheckerEnabled(bool enabled) >+{ >+#if ENABLE(SPELLCHECK) >+ QtTextChecker::instance()->setEnabled(enabled); >+ emit textCheckerEnabledChanged(); >+#endif >+} >+ >+void QWebGlobal::setTextCheckerLanguages(const QList<QString> &languages) >+{ >+#if ENABLE(SPELLCHECK) >+ QtTextChecker::instance()->setLanguages(languages); >+ emit textCheckerLanguagesChanged(); >+#endif >+} >+ >+QList<QString> QWebGlobal::textCheckerLanguages() const >+{ >+#if ENABLE(SPELLCHECK) >+ return QtTextChecker::instance()->languages(); >+#else >+ return QList<QString>(); >+#endif >+} >+ >+QList<QString> QWebGlobal::textCheckerAvailableLanguages() const >+{ >+#if ENABLE(SPELLCHECK) >+ return QtTextChecker::instance()->availableLanguages(); >+#else >+ return QList<QString>(); >+#endif >+} >diff --git a/Source/WebKit2/UIProcess/API/qt/qwebglobal_p.h b/Source/WebKit2/UIProcess/API/qt/qwebglobal_p.h >new file mode 100644 >index 0000000000000000000000000000000000000000..af54ce177388f73cac69dee84a98a1cd083d9ca8 >--- /dev/null >+++ b/Source/WebKit2/UIProcess/API/qt/qwebglobal_p.h >@@ -0,0 +1,50 @@ >+/* >+ * Copyright (C) 2012 Igalia, S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This program is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this program; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ */ >+ >+#ifndef qwebglobal_p_h >+#define qwebglobal_p_h >+ >+#include "qwebkitglobal.h" >+ >+#include <QtCore/QObject> >+ >+class QWEBKIT_EXPORT QWebGlobal : public QObject { >+ Q_OBJECT >+ Q_PROPERTY(bool textCheckerEnabled READ textCheckerEnabled WRITE setTextCheckerEnabled NOTIFY textCheckerEnabledChanged) >+ Q_PROPERTY(QList<QString> textCheckerLanguages READ textCheckerLanguages WRITE setTextCheckerLanguages); >+ Q_PROPERTY(QList<QString> textCheckerAvailableLanguages READ textCheckerAvailableLanguages); >+ >+public: >+ static QWebGlobal* instance(); >+ bool textCheckerEnabled() const; >+ void setTextCheckerEnabled(bool enabled); >+ virtual void setTextCheckerLanguages(const QList<QString>& languages); >+ virtual QList<QString> textCheckerLanguages() const; >+ virtual QList<QString> textCheckerAvailableLanguages() const; >+ >+Q_SIGNALS: >+ void textCheckerEnabledChanged(); >+ void textCheckerLanguagesChanged(); >+ >+private: >+ explicit QWebGlobal(); >+}; >+ >+#endif // qwebglobal_p_h >diff --git a/Source/WebKit2/UIProcess/qt/QtTextChecker.cpp b/Source/WebKit2/UIProcess/qt/QtTextChecker.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..83b6213db38cca19338edf1f567af2f7b159506e >--- /dev/null >+++ b/Source/WebKit2/UIProcess/qt/QtTextChecker.cpp >@@ -0,0 +1,188 @@ >+/* >+ * Copyright (C) 2012 Igalia, S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This program is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this program; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ */ >+ >+#include "config.h" >+ >+#include "QtTextChecker.h" >+ >+#include "WKAPICast.h" >+#include "WKArray.h" >+#include "WKMutableArray.h" >+#include "WKRetainPtr.h" >+#include "WKStringQt.h" >+#include "WKTextChecker.h" >+#include <wtf/Vector.h> >+#include <wtf/text/WTFString.h> >+ >+QtTextChecker* QtTextChecker::instance() >+{ >+ static QtTextChecker* s_instance = 0; >+ if (!s_instance) >+ s_instance = new QtTextChecker(); >+ >+ return s_instance; >+} >+ >+QtTextChecker::QtTextChecker() >+ : m_enabled(true) >+ , m_textChecker(WebCore::TextCheckerEnchant::create()) >+{ >+ m_textChecker->updateSpellCheckingLanguages(Vector<String>()); >+ setWK(); >+} >+ >+bool QtTextChecker::enabled() const >+{ >+ return m_enabled; >+} >+ >+void QtTextChecker::setEnabled(bool enable) >+{ >+ if (m_enabled == enable) >+ return; >+ >+ m_enabled = enable; >+ WKTextCheckerContinuousSpellCheckingEnabledStateChanged(enable); >+} >+ >+void QtTextChecker::checkSpellingOfString(const QString& string, int& misspellingLocation, int& misspellingLength) >+{ >+ m_textChecker->checkSpellingOfString(string, misspellingLocation, misspellingLength); >+} >+ >+QVector<QString> QtTextChecker::getGuessesForWord(const QString& word) >+{ >+ Vector<String> guesses = m_textChecker->getGuessesForWord(word); >+ QVector<QString> result; >+ if (!guesses.isEmpty()) { >+ for (size_t i = 0; i < guesses.size(); i++) >+ result.append(guesses[i]); >+ } >+ return result; >+} >+ >+void QtTextChecker::learnWord(const QString& word) >+{ >+ m_textChecker->learnWord(word); >+} >+ >+void QtTextChecker::ignoreWord(const QString& word) >+{ >+ m_textChecker->ignoreWord(word); >+} >+ >+void QtTextChecker::setLanguages(const QList<QString>& languages) >+{ >+ Vector<String> languagesVector; >+ foreach (const QString& spellCheckingLanguage, languages) >+ languagesVector.append(spellCheckingLanguage); >+ >+ m_textChecker->updateSpellCheckingLanguages(languagesVector); >+} >+ >+QList<QString> QtTextChecker::languages() const >+{ >+ Vector<String> languages = m_textChecker->loadedSpellCheckingLanguages(); >+ QList<QString> result; >+ if (!languages.isEmpty()) { >+ for (size_t i = 0; i < languages.size(); i++) >+ result.append(languages[i]); >+ } >+ return result; >+} >+ >+QList<QString> QtTextChecker::availableLanguages() const >+{ >+ Vector<String> languages = m_textChecker->availableSpellCheckingLanguages(); >+ QList<QString> result; >+ if (!languages.isEmpty()) { >+ for (size_t i = 0; i < languages.size(); i++) >+ result.append(languages[i]); >+ } >+ return result; >+} >+ >+static inline QtTextChecker* toTextChecker(const void* clientInfo) >+{ >+ return static_cast<QtTextChecker*>(const_cast<void*>(clientInfo)); >+} >+ >+static bool continuousSpellCheckingEnabledCallback(const void* clientInfo) >+{ >+ return toTextChecker(clientInfo)->enabled(); >+} >+ >+static bool continuousSpellCheckingAllowedCallback(const void* clientInfo) >+{ >+ return true; >+} >+ >+static void setContinuousSpellCheckingEnabledCallback(bool enabled, const void* clientInfo) >+{ >+ toTextChecker(clientInfo)->setEnabled(enabled); >+} >+ >+static void checkSpellingOfStringCallback(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void* clientInfo) >+{ >+ toTextChecker(clientInfo)->checkSpellingOfString(WebKit::toImpl(text)->string(), *misspellingLocation, *misspellingLength); >+} >+ >+static WKArrayRef guessesForWordCallback(uint64_t tag, WKStringRef word, const void* clientInfo) >+{ >+ QVector<QString> guesses = toTextChecker(clientInfo)->getGuessesForWord(WebKit::toImpl(word)->string()); >+ if (guesses.isEmpty()) >+ return 0; >+ >+ WKMutableArrayRef wkSuggestions = WKMutableArrayCreate(); >+ foreach (const QString& guess, guesses) { >+ WKRetainPtr<WKStringRef> wkSuggestion(AdoptWK, WKStringCreateWithQString(guess)); >+ WKArrayAppendItem(wkSuggestions, wkSuggestion.get()); >+ } >+ >+ return wkSuggestions; >+} >+ >+static void learnWordCallback(uint64_t tag, WKStringRef word, const void* clientInfo) >+{ >+ toTextChecker(clientInfo)->learnWord(WebKit::toImpl(word)->string()); >+} >+ >+static void ignoreWordCallback(uint64_t tag, WKStringRef word, const void* clientInfo) >+{ >+ toTextChecker(clientInfo)->ignoreWord(WebKit::toImpl(word)->string()); >+} >+ >+ >+void QtTextChecker::setWK() >+{ >+ WKTextCheckerClient textCheckerClient; >+ memset(&textCheckerClient, 0, sizeof(WKTextCheckerClient)); >+ textCheckerClient.version = kWKTextCheckerClientCurrentVersion; >+ textCheckerClient.clientInfo = this; >+ textCheckerClient.continuousSpellCheckingAllowed = continuousSpellCheckingAllowedCallback; >+ textCheckerClient.continuousSpellCheckingEnabled = continuousSpellCheckingEnabledCallback; >+ textCheckerClient.setContinuousSpellCheckingEnabled = setContinuousSpellCheckingEnabledCallback; >+ textCheckerClient.checkSpellingOfString = checkSpellingOfStringCallback; >+ textCheckerClient.guessesForWord = guessesForWordCallback; >+ textCheckerClient.learnWord = learnWordCallback; >+ textCheckerClient.ignoreWord = ignoreWordCallback; >+ >+ WKTextCheckerSetClient(&textCheckerClient); >+} >diff --git a/Source/WebKit2/UIProcess/qt/QtTextChecker.h b/Source/WebKit2/UIProcess/qt/QtTextChecker.h >new file mode 100644 >index 0000000000000000000000000000000000000000..ac7e86b6e899804c1e4e70cec19181fd82a72712 >--- /dev/null >+++ b/Source/WebKit2/UIProcess/qt/QtTextChecker.h >@@ -0,0 +1,34 @@ >+#ifndef QtTextChecker_h >+#define QtTextChecker_h >+ >+#include <QtCore/QObject> >+#include <QtCore/QSet> >+#include <QtCore/QString> >+#include <QtCore/QVector> >+#include <WebCore/TextCheckerEnchant.h> >+#include <wtf/OwnPtr.h> >+ >+class QtTextChecker { >+public: >+ static QtTextChecker* instance(); >+ >+ virtual void checkSpellingOfString(const QString&, int& misspellingLocation, int& misspellingLength); >+ virtual QVector<QString> getGuessesForWord(const QString& word); >+ virtual void learnWord(const QString& word); >+ virtual void ignoreWord(const QString& word); >+ >+ virtual bool enabled() const; >+ virtual void setEnabled(bool); >+ virtual void setLanguages(const QList<QString>&); >+ virtual QList<QString> languages() const; >+ virtual QList<QString> availableLanguages() const; >+ >+private: >+ QtTextChecker(); >+ void setWK(); >+ >+ bool m_enabled; >+ OwnPtr<WebCore::TextCheckerEnchant> m_textChecker; >+}; >+ >+#endif // QtTextChecker_h >diff --git a/Source/WebKit2/UIProcess/qt/QtWebContext.cpp b/Source/WebKit2/UIProcess/qt/QtWebContext.cpp >index faaca91b2fe86aa533ccaf26cbc05c861c95dd21..7521eeacf61baa0037550d47bb663c162cdd1823 100644 >--- a/Source/WebKit2/UIProcess/qt/QtWebContext.cpp >+++ b/Source/WebKit2/UIProcess/qt/QtWebContext.cpp >@@ -22,6 +22,9 @@ > #include "QtWebContext.h" > > #include "QtDownloadManager.h" >+#if ENABLE(SPELLCHECK) >+#include "QtTextChecker.h" >+#endif > #include "QtWebIconDatabaseClient.h" > #include "WKAPICast.h" > #include "WebContext.h" >@@ -71,6 +74,13 @@ static void initInspectorServer() > #endif > } > >+static void initTextChecker() >+{ >+#if ENABLE(SPELLCHECK) >+ QtTextChecker::instance()->setEnabled(true); >+#endif >+} >+ > static void globalInitialization() > { > static bool initialized = false; >@@ -78,6 +88,7 @@ static void globalInitialization() > return; > > initInspectorServer(); >+ initTextChecker(); > initialized = true; > } > >diff --git a/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp b/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp >index 4a3318405ad5ec8ce636334f7d80e508aae68a92..3f36583bf4400f3d60634d4d581f867c819ead3e 100644 >--- a/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp >+++ b/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp >@@ -27,7 +27,7 @@ > #include "TextChecker.h" > > #include "TextCheckerState.h" >-#include <WebCore/NotImplemented.h> >+#include "WebTextChecker.h" > > using namespace WebCore; > >@@ -37,93 +37,103 @@ static TextCheckerState textCheckerState; > > const TextCheckerState& TextChecker::state() > { >- notImplemented(); >- >+ static bool didInitializeState = false; >+ if (didInitializeState) >+ return textCheckerState; >+ >+ WebTextCheckerClient& client = WebTextChecker::shared()->client(); >+ textCheckerState.isContinuousSpellCheckingEnabled = client.continuousSpellCheckingEnabled(); >+ textCheckerState.isGrammarCheckingEnabled = client.grammarCheckingEnabled(); >+ >+ didInitializeState = true; >+ > return textCheckerState; > } > > bool TextChecker::isContinuousSpellCheckingAllowed() > { >- notImplemented(); >- >- return false; >+ return WebTextChecker::shared()->client().continuousSpellCheckingAllowed(); > } > > void TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled) > { >- notImplemented(); >+ if (state().isContinuousSpellCheckingEnabled == isContinuousSpellCheckingEnabled) >+ return; >+ textCheckerState.isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled; >+ WebTextChecker::shared()->client().setContinuousSpellCheckingEnabled(isContinuousSpellCheckingEnabled); > } > > void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled) > { >- notImplemented(); >+ if (state().isGrammarCheckingEnabled == isGrammarCheckingEnabled) >+ return; >+ textCheckerState.isGrammarCheckingEnabled = isGrammarCheckingEnabled; >+ WebTextChecker::shared()->client().setGrammarCheckingEnabled(isGrammarCheckingEnabled); > } > > void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled) > { >- notImplemented(); >+ textCheckerState.isContinuousSpellCheckingEnabled = enabled; > } > > void TextChecker::grammarCheckingEnabledStateChanged(bool enabled) > { >- notImplemented(); >+ textCheckerState.isGrammarCheckingEnabled = enabled; > } > >-int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*) >+int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy* page) > { >- notImplemented(); >- return 0; >+ return WebTextChecker::shared()->client().uniqueSpellDocumentTag(page); > } > >-void TextChecker::closeSpellDocumentWithTag(int64_t) >+void TextChecker::closeSpellDocumentWithTag(int64_t tag) > { >- notImplemented(); >+ WebTextChecker::shared()->client().closeSpellDocumentWithTag(tag); > } > >-void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&) >+void TextChecker::checkSpellingOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, int32_t& misspellingLocation, int32_t& misspellingLength) > { >- notImplemented(); >+ WebTextChecker::shared()->client().checkSpellingOfString(spellDocumentTag, String(text, length), misspellingLocation, misspellingLength); > } > >-void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&) >+void TextChecker::checkGrammarOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, Vector<WebCore::GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength) > { >- notImplemented(); >+ WebTextChecker::shared()->client().checkGrammarOfString(spellDocumentTag, String(text, length), grammarDetails, badGrammarLocation, badGrammarLength); > } > > bool TextChecker::spellingUIIsShowing() > { >- notImplemented(); >- return false; >+ return WebTextChecker::shared()->client().spellingUIIsShowing(); > } > > void TextChecker::toggleSpellingUIIsShowing() > { >- notImplemented(); >+ WebTextChecker::shared()->client().toggleSpellingUIIsShowing(); > } > >-void TextChecker::updateSpellingUIWithMisspelledWord(int64_t, const String&) >+void TextChecker::updateSpellingUIWithMisspelledWord(int64_t spellDocumentTag, const String& misspelledWord) > { >- notImplemented(); >+ WebTextChecker::shared()->client().updateSpellingUIWithMisspelledWord(spellDocumentTag, misspelledWord); > } > >-void TextChecker::updateSpellingUIWithGrammarString(int64_t, const String&, const GrammarDetail&) >+void TextChecker::updateSpellingUIWithGrammarString(int64_t spellDocumentTag, const String& badGrammarPhrase, const GrammarDetail& grammarDetail) > { >- notImplemented(); >+ WebTextChecker::shared()->client().updateSpellingUIWithGrammarString(spellDocumentTag, badGrammarPhrase, grammarDetail); > } > > void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses) > { >- notImplemented(); >+ WebTextChecker::shared()->client().guessesForWord(spellDocumentTag, word, guesses); > } > >-void TextChecker::learnWord(int64_t, const String&) >+void TextChecker::learnWord(int64_t spellDocumentTag, const String& word) > { >- notImplemented(); >+ WebTextChecker::shared()->client().learnWord(spellDocumentTag, word); > } > > void TextChecker::ignoreWord(int64_t spellDocumentTag, const String& word) > { >- notImplemented(); >+ WebTextChecker::shared()->client().ignoreWord(spellDocumentTag, word); > } > > } // namespace WebKit >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index f1f31c0f195e4558dc3feacee8d9d8c0876a804c..29ad4fbcc14c5783f050f0349fe2120c3cb5823e 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,19 @@ >+2013-01-22 José Dapena Paz <jdapena@igalia.com> >+ >+ [Qt][WK2] Add spell checking support >+ https://bugs.webkit.org/show_bug.cgi?id=105034 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Enable spellcheck by default, and build Enchant default backend >+ if Enchant is available. Also added a config test for libenchant. >+ >+ * qmake/config.tests/libenchant/libenchant.cpp: Added. >+ (main): >+ * qmake/config.tests/libenchant/libenchant.pro: Added. >+ * qmake/mkspecs/features/features.prf: >+ * qmake/mkspecs/features/features.pri: >+ > 2013-01-21 Gustavo Noronha Silva <gns@gnome.org> > > REGRESSION (r140285): GTK uses WKPageResourceLoadClient which was removed >diff --git a/Tools/qmake/config.tests/libenchant/libenchant.cpp b/Tools/qmake/config.tests/libenchant/libenchant.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..7e1c2e4e9b23e5019bd40f58517bf47e208673b7 >--- /dev/null >+++ b/Tools/qmake/config.tests/libenchant/libenchant.cpp >@@ -0,0 +1,9 @@ >+#include <enchant.h> >+#include <stdio.h> >+ >+int main(int, char**) >+{ >+ enchant_get_version(); >+ >+ return 0; >+} >diff --git a/Tools/qmake/config.tests/libenchant/libenchant.pro b/Tools/qmake/config.tests/libenchant/libenchant.pro >new file mode 100644 >index 0000000000000000000000000000000000000000..d588b1a46533caddc88c42aebbffa4583c524948 >--- /dev/null >+++ b/Tools/qmake/config.tests/libenchant/libenchant.pro >@@ -0,0 +1,4 @@ >+CONFIG -= qt >+SOURCES = libenchant.cpp >+CONFIG += link_pkgconfig >+PKGCONFIG += enchant >diff --git a/Tools/qmake/mkspecs/features/features.prf b/Tools/qmake/mkspecs/features/features.prf >index cc9072dd9ba3a1207b196e3b0733b9b46187e9cf..565d6918f2b04d525a40f43217589179547fc873 100644 >--- a/Tools/qmake/mkspecs/features/features.prf >+++ b/Tools/qmake/mkspecs/features/features.prf >@@ -50,6 +50,10 @@ defineTest(detectFeatures) { > contains(QT_CONFIG, system-png): WEBKIT_CONFIG += use_libpng > else: CONFIGURE_WARNINGS += "PNG library not found, QImageDecoder will decode PNG images" > >+ enable?(spellcheck) { >+ config_libenchant: WEBKIT_CONFIG += use_libenchant >+ } >+ > linux-* { > config_libXcomposite: WEBKIT_CONFIG += have_xcomposite > config_libXrender: WEBKIT_CONFIG += have_xrender >diff --git a/Tools/qmake/mkspecs/features/features.pri b/Tools/qmake/mkspecs/features/features.pri >index e3e408bedabe9aa5ae5d43ab82d9bc7ba8d1ab70..99bffd50fddbf61d4ca52f2e0fb62848323e6192 100644 >--- a/Tools/qmake/mkspecs/features/features.pri >+++ b/Tools/qmake/mkspecs/features/features.pri >@@ -97,6 +97,7 @@ FEATURE_DEFAULTS = \ > ENABLE_SHADOW_DOM=0 \ > ENABLE_SHARED_WORKERS=1 \ > ENABLE_SMOOTH_SCROLLING=1 \ >+ ENABLE_SPELLCHECK=1 \ > ENABLE_SQL_DATABASE=1 \ > ENABLE_STYLE_SCOPED=0 \ > ENABLE_SVG=1 \
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 105034
:
179990
|
180127
|
182561
|
183938
|
183950
|
183983