Diff
Modified: trunk/LayoutTests/ChangeLog (183935 => 183936)
--- trunk/LayoutTests/ChangeLog 2015-05-07 18:01:46 UTC (rev 183935)
+++ trunk/LayoutTests/ChangeLog 2015-05-07 18:24:31 UTC (rev 183936)
@@ -1,3 +1,13 @@
+2015-05-07 Martin Robinson <[email protected]>
+
+ [GTK] All spell checking layout tests fail
+ https://bugs.webkit.org/show_bug.cgi?id=144648
+
+ Reviewed by Carlos Garcia Campos.
+
+ * platform/gtk/TestExpectations: Unskip and reclassify previously failing tests.
+ * platform/gtk/editing/spelling/spellcheck-paste-expected.txt: Removed.
+
2015-05-07 Joanmarie Diggs <[email protected]>
AX: [ATK] The pre element should be mapped to ATK_ROLE_SECTION; not ATK_ROLE_PANEL
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (183935 => 183936)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2015-05-07 18:01:46 UTC (rev 183935)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2015-05-07 18:24:31 UTC (rev 183936)
@@ -627,11 +627,6 @@
Bug(GTK) editing/spelling/inline-spelling-markers-hidpi.html [ Skip ]
Bug(GTK) editing/spelling/markers.html [ Skip ]
-# Missing asynchronous spellchecking implementation.
-Bug(GTK) editing/spelling/design-mode-spellcheck-off.html [ Skip ]
-Bug(GTK) editing/spelling/spelling-insert-html.html [ Skip ]
-Bug(GTK) editing/spelling/spelling-hasspellingmarker.html [ Skip ]
-
# Requires ENABLE(MEDIA_CAPTURE)
webkit.org/b/85958 fast/forms/file/file-input-capture.html [ Failure ]
@@ -1283,11 +1278,6 @@
webkit.org/b/122571 inspector-protocol/page/setEmulatedMedia.html [ Timeout Pass ]
webkit.org/b/122571 inspector-protocol/css/getSupportedCSSProperties.html [ Timeout Pass ]
-webkit.org/b/130411 editing/spelling/spellcheck-paste.html [ Timeout ]
-webkit.org/b/130411 editing/spelling/spelling-changed-text.html [ Timeout ]
-webkit.org/b/130411 editing/spelling/spellcheck-paste-disabled.html [ Timeout ]
-webkit.org/b/130411 editing/spelling/spellcheck-paste-continuous-disabled.html [ Timeout ]
-
Bug(GTK) plugins/reloadplugins-and-pages.html [ Timeout ]
Bug(GTK) fast/forms/select/menulist-popup-crash.html [ Timeout ]
@@ -1479,26 +1469,6 @@
webkit.org/b/42194 fast/events/5056619.html [ Failure ]
webkit.org/b/42194 http/tests/security/drag-drop-same-unique-origin.html [ Failure ]
-# Missing TextChecker::requestCheckingOfString() implementation for Gtk.
-webkit.org/b/73003 editing/spelling/delete-into-misspelled-word.html [ Skip ]
-webkit.org/b/73003 editing/spelling/editing-multiple-words-with-markers.html [ Skip ]
-webkit.org/b/73003 editing/spelling/editing-word-with-marker-2.html [ Skip ]
-webkit.org/b/73003 editing/spelling/move-cursor-around-misspelled-word.html [ Skip ]
-webkit.org/b/73003 editing/spelling/spellcheck-async-mutation.html [ Skip ]
-webkit.org/b/73003 editing/spelling/spellcheck-async-remove-frame.html [ Skip ]
-webkit.org/b/73003 editing/spelling/spellcheck-async.html [ Skip ]
-webkit.org/b/73003 editing/spelling/spellcheck-queue.html [ Skip ]
-webkit.org/b/73003 editing/spelling/spellcheck-sequencenum.html [ Skip ]
-webkit.org/b/73003 editing/spelling/spelling-backward.html [ Skip ]
-webkit.org/b/73003 editing/spelling/spelling-marker-description.html [ Skip ]
-
-# Spellcheck tests don't seem to work.
-Bug(GTK) editing/spelling/spelling-backspace-between-lines.html [ Skip ]
-Bug(GTK) editing/spelling/spellcheck-attribute.html [ Skip ]
-Bug(GTK) editing/spelling/spelling-attribute-at-child.html [ Skip ]
-Bug(GTK) editing/spelling/spelling-attribute-change.html [ Skip ]
-Bug(GTK) editing/spelling/spelling-linebreak.html [ Skip ]
-
# Context menu problems.
webkit.org/b/120401 fast/events [ Skip ]
webkit.org/b/120401 editing/selection [ Skip ]
@@ -1581,9 +1551,6 @@
Bug(GTK) editing/selection/context-menu-text-selection.html [ Failure Pass ]
Bug(GTK) editing/selection/context-menu-text-selection-lookup.html [ Failure Pass ]
-# An oncontextmenu attribute is not called.
-Bug(GTK) editing/spelling/spellcheck-input-search-crash.html [ Failure ]
-
Bug(GTK) http/tests/misc/iframe-beforeunload-dialog-matching-ancestor-securityorigin.html [ Failure ]
Bug(GTK) http/tests/misc/will-send-request-returns-null-on-redirect.html [ Failure ]
@@ -1718,9 +1685,6 @@
# Need to add functionality to DumpRenderTree to handle scrollbar policy changes
Bug(GTK) fast/overflow/scrollbar-restored-and-then-locked.html [ Failure ]
-# DRT doesn't dispatch an event for the second call eventSender.contextClick().
-webkit.org/b/39102 editing/spelling/context-menu-suggestions.html [ Failure ]
-
# Some input type=range tests fail because of the size
# of the slider thumb in GTK+ themes.
Bug(GTK) fast/forms/range/slider-mouse-events.html [ Failure ]
@@ -1800,8 +1764,6 @@
# Does not render the rectangle as it should, even though the multiple parts seem to work
webkit.org/b/54251 http/tests/multipart/invalid-image-data.html [ Failure ]
-webkit.org/b/72248 editing/spelling/spelling-unified-emulation.html [ Failure ]
-
webkit.org/b/62204 svg/custom/relative-sized-use-without-attributes-on-symbol.xhtml [ Failure ]
webkit.org/b/62204 svg/custom/use-on-symbol-inside-pattern.svg [ Failure ]
webkit.org/b/62204 svg/W3C-SVG-1.1/animate-elem-04-t.svg [ Failure ]
@@ -1909,14 +1871,6 @@
webkit.org/b/103927 http/tests/w3c/webperf/submission/Google/resource-timing/html/test_resource_initiator_types.html [ Failure ]
webkit.org/b/103927 http/tests/w3c/webperf/submission/Google/resource-timing/html/test_resource_redirects.html [ Failure ]
-# Spellchecker behavior tests.
-webkit.org/b/108370 editing/spelling/context-menu-suggestions-multiword-selection.html [ Skip ]
-webkit.org/b/108370 editing/spelling/context-menu-suggestions-subword-selection.html [ Skip ]
-webkit.org/b/108370 editing/spelling/spelling-double-clicked-word.html [ Skip ]
-webkit.org/b/108370 editing/spelling/spelling-exactly-selected-word.html [ Skip ]
-webkit.org/b/108370 editing/spelling/spelling-with-punctuation-selection.html [ Skip ]
-webkit.org/b/108370 editing/spelling/spelling-with-whitespace-selection.html [ Skip ]
-
webkit.org/b/107118 fast/canvas/canvas-quadratic-same-endpoint.html [ Failure ]
webkit.org/b/108973 fast/css/negative-text-indent-in-inline-block.html [ ImageOnlyFailure ]
@@ -2371,6 +2325,14 @@
webkit.org/b/144673 fast/forms/button-line-height.html [ ImageOnlyFailure ]
+webkit.org/b/144690 editing/spelling/context-menu-suggestions-multiword-selection.html [ Timeout ]
+webkit.org/b/144690 editing/spelling/context-menu-suggestions-subword-selection.html [ Timeout ]
+webkit.org/b/144690 editing/spelling/spelling-exactly-selected-word.html [ Timeout ]
+webkit.org/b/144690 editing/spelling/spelling-with-punctuation-selection.html [ Timeout ]
+webkit.org/b/144690 editing/spelling/context-menu-suggestions.html [ Failure ]
+webkit.org/b/144690 editing/spelling/spelling-double-clicked-word.html [ Failure ]
+webkit.org/b/144690 editing/spelling/delete-into-misspelled-word.html [ Timeout Pass ]
+
#////////////////////////////////////////////////////////////////////////////////////////
# End of Tests failing
#////////////////////////////////////////////////////////////////////////////////////////
Deleted: trunk/LayoutTests/platform/gtk/editing/spelling/spellcheck-paste-expected.txt (183935 => 183936)
--- trunk/LayoutTests/platform/gtk/editing/spelling/spellcheck-paste-expected.txt 2015-05-07 18:01:46 UTC (rev 183935)
+++ trunk/LayoutTests/platform/gtk/editing/spelling/spellcheck-paste-expected.txt 2015-05-07 18:24:31 UTC (rev 183936)
@@ -1,18 +0,0 @@
-For Bug 40092: Spell checking for pasted text.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-FAIL INPUT should have a marker on 'zz apple'
-FAIL INPUT should have a marker on 'z<b>z appl</b>e'
-FAIL INPUT should have a marker on 'zz zz zz'
-FAIL TEXTAREA should have a marker on 'zz apple'
-FAIL TEXTAREA should have a marker on 'z<b>z appl</b>e'
-FAIL TEXTAREA should have a marker on 'zz zz zz'
-FAIL DIV should have a marker on 'zz apple'
-FAIL DIV should have a marker on 'z<b>z appl</b>e'
-FAIL DIV should have a marker on 'zz zz zz'
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
Modified: trunk/Source/WTF/ChangeLog (183935 => 183936)
--- trunk/Source/WTF/ChangeLog 2015-05-07 18:01:46 UTC (rev 183935)
+++ trunk/Source/WTF/ChangeLog 2015-05-07 18:24:31 UTC (rev 183936)
@@ -1,3 +1,12 @@
+2015-05-07 Martin Robinson <[email protected]>
+
+ [GTK] All spell checking layout tests fail
+ https://bugs.webkit.org/show_bug.cgi?id=144648
+
+ Reviewed by Carlos Garcia Campos.
+
+ * wtf/Platform.h: Activate UNIFIED_TEXT_CHECKING for GTK+.
+
2015-05-07 Dan Bernstein <[email protected]>
<rdar://problem/19317140> [Xcode] Remove usage of AspenFamily.xcconfig in Source/
Modified: trunk/Source/WTF/wtf/Platform.h (183935 => 183936)
--- trunk/Source/WTF/wtf/Platform.h 2015-05-07 18:01:46 UTC (rev 183935)
+++ trunk/Source/WTF/wtf/Platform.h 2015-05-07 18:24:31 UTC (rev 183936)
@@ -1052,7 +1052,7 @@
#define USE_GRAMMAR_CHECKING 1
-#if PLATFORM(COCOA) || PLATFORM(EFL)
+#if PLATFORM(COCOA) || PLATFORM(EFL) || PLATFORM(GTK)
#define USE_UNIFIED_TEXT_CHECKING 1
#endif
#if PLATFORM(MAC)
Modified: trunk/Source/WebKit2/ChangeLog (183935 => 183936)
--- trunk/Source/WebKit2/ChangeLog 2015-05-07 18:01:46 UTC (rev 183935)
+++ trunk/Source/WebKit2/ChangeLog 2015-05-07 18:24:31 UTC (rev 183936)
@@ -1,3 +1,32 @@
+2015-05-07 Martin Robinson <[email protected]>
+
+ [GTK] All spell checking layout tests fail
+ https://bugs.webkit.org/show_bug.cgi?id=144648
+
+ Reviewed by Carlos Garcia Campos.
+
+ Simplify and complete the GTK+ spell-checking implementation. Instead of using
+ the EFL/GTK+ only WKTextChecker interface, directly implement Enchant spell-checking
+ in TextCheckerGtk. The per-context spell checking API is an illusion, since all
+ WKTextChecker implementations will adjust the same singleton. This can be a first step
+ toward removing it entirely.
+
+ Also complete the implementation of the TextChecker interface by duplicating the EFL code,
+ which reuses other methods in the same class. Eventually this duplication will collapse,
+ once GTK+ and EFL can share an Enchant implementation.
+
+ * PlatformGTK.cmake:
+ * UIProcess/API/gtk/WebKitPrivate.h:
+ * UIProcess/API/gtk/WebKitTextChecker.cpp: Removed.
+ * UIProcess/API/gtk/WebKitTextChecker.h: Removed.
+ * UIProcess/API/gtk/WebKitWebContext.cpp: Remove WebTextChecker usage and
+ replace it with calls directly to the TextChecker singleton via static methods.
+ * UIProcess/TextChecker.h:
+ * UIProcess/gtk/TextCheckerGtk.cpp: Move the WebTextChecker enchant implementation
+ here and reuse the EFL version of WebKit::TextChecker::requestCheckingOfString.
+ Also initialize languages properly when building for developer builds. This
+ allows WebKitTestRunner to work even when it doesn't explicitly set the languages.
+
2015-05-07 Ada Chan <[email protected]>
Fix a couple of cases where the backForwardListState's currentIndex is not set correctly in WebBackForwardList::backForwardListState().
Modified: trunk/Source/WebKit2/PlatformGTK.cmake (183935 => 183936)
--- trunk/Source/WebKit2/PlatformGTK.cmake 2015-05-07 18:01:46 UTC (rev 183935)
+++ trunk/Source/WebKit2/PlatformGTK.cmake 2015-05-07 18:24:31 UTC (rev 183936)
@@ -214,8 +214,6 @@
UIProcess/API/gtk/WebKitSettings.cpp
UIProcess/API/gtk/WebKitSettings.h
UIProcess/API/gtk/WebKitSettingsPrivate.h
- UIProcess/API/gtk/WebKitTextChecker.cpp
- UIProcess/API/gtk/WebKitTextChecker.h
UIProcess/API/gtk/WebKitUIClient.cpp
UIProcess/API/gtk/WebKitUIClient.h
UIProcess/API/gtk/WebKitURIRequest.cpp
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h (183935 => 183936)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h 2015-05-07 18:01:46 UTC (rev 183935)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h 2015-05-07 18:24:31 UTC (rev 183936)
@@ -41,7 +41,6 @@
#include <WebKit/WKSerializedScriptValue.h>
#include <WebKit/WKSoupCustomProtocolRequestManager.h>
#include <WebKit/WKString.h>
-#include <WebKit/WKTextChecker.h>
#include <WebKit/WKUserMediaPermissionRequest.h>
#include <WebKit/WebKit2_C.h>
#include <glib.h>
Deleted: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp (183935 => 183936)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp 2015-05-07 18:01:46 UTC (rev 183935)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp 2015-05-07 18:24:31 UTC (rev 183936)
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2012 Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "WebKitTextChecker.h"
-
-#if ENABLE(SPELLCHECK)
-
-#include "WebKitPrivate.h"
-
-using namespace WebKit;
-
-static inline WebKitTextChecker* toTextChecker(const void* clientInfo)
-{
- return static_cast<WebKitTextChecker*>(const_cast<void*>(clientInfo));
-}
-
-static bool continuousSpellCheckingEnabledCallback(const void* clientInfo)
-{
- return toTextChecker(clientInfo)->isSpellCheckingEnabled();
-}
-
-static void setContinuousSpellCheckingEnabledCallback(bool enabled, const void* clientInfo)
-{
- toTextChecker(clientInfo)->setSpellCheckingEnabled(enabled);
-}
-
-static void checkSpellingOfStringCallback(uint64_t /* tag */, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void* clientInfo)
-{
- toTextChecker(clientInfo)->checkSpellingOfString(toImpl(text)->string(), *misspellingLocation, *misspellingLength);
-}
-
-static WKArrayRef guessesForWordCallback(uint64_t /* tag */, WKStringRef word, const void* clientInfo)
-{
- Vector<String> guesses = toTextChecker(clientInfo)->getGuessesForWord(toImpl(word)->string());
- if (guesses.isEmpty())
- return 0;
-
- WKMutableArrayRef wkSuggestions = WKMutableArrayCreate();
- for (Vector<String>::const_iterator iter = guesses.begin(); iter != guesses.end(); ++iter) {
- WKRetainPtr<WKStringRef> wkSuggestion(AdoptWK, WKStringCreateWithUTF8CString(iter->utf8().data()));
- WKArrayAppendItem(wkSuggestions, wkSuggestion.get());
- }
-
- return wkSuggestions;
-}
-
-static void learnWordCallback(uint64_t /* tag */, WKStringRef word, const void* clientInfo)
-{
- toTextChecker(clientInfo)->learnWord(toImpl(word)->string());
-}
-
-static void ignoreWordCallback(uint64_t /* tag */, WKStringRef word, const void* clientInfo)
-{
- toTextChecker(clientInfo)->ignoreWord(toImpl(word)->string());
-}
-
-WebKitTextChecker::~WebKitTextChecker()
-{
-}
-
-WebKitTextChecker::WebKitTextChecker()
- : m_textChecker(std::make_unique<WebCore::TextCheckerEnchant>())
- , m_spellCheckingEnabled(false)
-{
- WKTextCheckerClientV0 wkTextCheckerClient = {
- {
- 0, // version
- this, // clientInfo
- },
- 0, // continuousSpellCheckingAllowed
- continuousSpellCheckingEnabledCallback,
- setContinuousSpellCheckingEnabledCallback,
- 0, // grammarCheckingEnabled
- 0, // setGrammarCheckingEnabled
- 0, // uniqueSpellDocumentTag
- 0, // closeSpellDocumentWithTag
- checkSpellingOfStringCallback,
- 0, // checkGrammarOfString
- 0, // spellingUIIsShowing
- 0, // toggleSpellingUIIsShowing
- 0, // updateSpellingUIWithMisspelledWord
- 0, // updateSpellingUIWithGrammarString
- guessesForWordCallback,
- learnWordCallback,
- ignoreWordCallback,
- };
- WKTextCheckerSetClient(&wkTextCheckerClient.base);
-}
-
-void WebKitTextChecker::checkSpellingOfString(const String& string, int& misspellingLocation, int& misspellingLength)
-{
- m_textChecker->checkSpellingOfString(string, misspellingLocation, misspellingLength);
-}
-
-Vector<String> WebKitTextChecker::getGuessesForWord(const String& word)
-{
- return m_textChecker->getGuessesForWord(word);
-}
-
-void WebKitTextChecker::learnWord(const String& word)
-{
- m_textChecker->learnWord(word);
-}
-
-void WebKitTextChecker::ignoreWord(const String& word)
-{
- m_textChecker->ignoreWord(word);
-}
-
-void WebKitTextChecker::setSpellCheckingEnabled(bool enabled)
-{
- if (m_spellCheckingEnabled == enabled)
- return;
- m_spellCheckingEnabled = enabled;
-
- // We need to notify the Web process that this has changed.
- WKTextCheckerContinuousSpellCheckingEnabledStateChanged(enabled);
-}
-
-const char* const* WebKitTextChecker::getSpellCheckingLanguages()
-{
- Vector<String> spellCheckingLanguages = m_textChecker->loadedSpellCheckingLanguages();
- if (spellCheckingLanguages.isEmpty())
- return 0;
-
- m_spellCheckingLanguages = adoptGRef(g_ptr_array_new_with_free_func(g_free));
- for (size_t i = 0; i < spellCheckingLanguages.size(); ++i)
- g_ptr_array_add(m_spellCheckingLanguages.get(), g_strdup(spellCheckingLanguages[i].utf8().data()));
- g_ptr_array_add(m_spellCheckingLanguages.get(), 0);
-
- return reinterpret_cast<char**>(m_spellCheckingLanguages->pdata);
-}
-
-void WebKitTextChecker::setSpellCheckingLanguages(const char* const* languages)
-{
- Vector<String> spellCheckingLanguages;
- for (size_t i = 0; languages[i]; ++i)
- spellCheckingLanguages.append(String::fromUTF8(languages[i]));
- m_textChecker->updateSpellCheckingLanguages(spellCheckingLanguages);
-}
-#endif // ENABLE(SPELLCHECK)
Deleted: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h (183935 => 183936)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h 2015-05-07 18:01:46 UTC (rev 183935)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h 2015-05-07 18:24:31 UTC (rev 183936)
@@ -1,58 +0,0 @@
-/*
- * 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 library 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 library; 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 WebKitTextChecker_h
-#define WebKitTextChecker_h
-
-#if ENABLE(SPELLCHECK)
-
-#include <WebCore/TextCheckerEnchant.h>
-#include <wtf/FastMalloc.h>
-#include <wtf/Vector.h>
-#include <wtf/gobject/GRefPtr.h>
-#include <wtf/text/CString.h>
-
-class WebKitTextChecker {
- WTF_MAKE_FAST_ALLOCATED;
-
-public:
- WebKitTextChecker();
- ~WebKitTextChecker();
-
- // For implementing TextCheckerClient.
- bool isSpellCheckingEnabled() { return m_spellCheckingEnabled; }
- void setSpellCheckingEnabled(bool enabled);
- void checkSpellingOfString(const String& string, int& misspellingLocation, int& misspellingLength);
- Vector<String> getGuessesForWord(const String& word);
- void learnWord(const String& word);
- void ignoreWord(const String& word);
-
- // To be called from WebKitWebContext only.
- const char* const* getSpellCheckingLanguages();
- void setSpellCheckingLanguages(const char* const* spellCheckingLanguages);
-
-private:
- std::unique_ptr<WebCore::TextCheckerEnchant> m_textChecker;
- GRefPtr<GPtrArray> m_spellCheckingLanguages;
- bool m_spellCheckingEnabled;
-};
-
-#endif // ENABLE(SPELLCHECK)
-
-#endif // WebKitTextChecker_h
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (183935 => 183936)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp 2015-05-07 18:01:46 UTC (rev 183935)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp 2015-05-07 18:24:31 UTC (rev 183936)
@@ -23,6 +23,8 @@
#include "APIDownloadClient.h"
#include "APIProcessPoolConfiguration.h"
#include "APIString.h"
+#include "TextChecker.h"
+#include "TextCheckerState.h"
#include "WebBatteryManagerProxy.h"
#include "WebCertificateInfo.h"
#include "WebCookieManagerProxy.h"
@@ -40,7 +42,6 @@
#include "WebKitRequestManagerClient.h"
#include "WebKitSecurityManagerPrivate.h"
#include "WebKitSettingsPrivate.h"
-#include "WebKitTextChecker.h"
#include "WebKitURISchemeRequestPrivate.h"
#include "WebKitUserContentManagerPrivate.h"
#include "WebKitWebContextPrivate.h"
@@ -172,9 +173,6 @@
#if ENABLE(NOTIFICATIONS)
RefPtr<WebKitNotificationProvider> notificationProvider;
#endif
-#if ENABLE(SPELLCHECK)
- std::unique_ptr<WebKitTextChecker> textChecker;
-#endif
CString faviconDatabaseDirectory;
WebKitTLSErrorsPolicy tlsErrorsPolicy;
@@ -290,9 +288,6 @@
#if ENABLE(NOTIFICATIONS)
priv->notificationProvider = WebKitNotificationProvider::create(priv->context->supplement<WebNotificationManagerProxy>());
#endif
-#if ENABLE(SPELLCHECK)
- priv->textChecker = std::make_unique<WebKitTextChecker>();
-#endif
}
static void webkitWebContextDispose(GObject* object)
@@ -802,7 +797,7 @@
g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), FALSE);
#if ENABLE(SPELLCHECK)
- return context->priv->textChecker->isSpellCheckingEnabled();
+ return TextChecker::state().isContinuousSpellCheckingEnabled;
#else
return false;
#endif
@@ -820,7 +815,7 @@
g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
#if ENABLE(SPELLCHECK)
- context->priv->textChecker->setSpellCheckingEnabled(enabled);
+ TextChecker::setContinuousSpellCheckingEnabled(enabled);
#endif
}
@@ -839,10 +834,20 @@
*/
const gchar* const* webkit_web_context_get_spell_checking_languages(WebKitWebContext* context)
{
- g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0);
+ g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), nullptr);
#if ENABLE(SPELLCHECK)
- return context->priv->textChecker->getSpellCheckingLanguages();
+ Vector<String> spellCheckingLanguages = TextChecker::loadedSpellCheckingLanguages();
+ if (spellCheckingLanguages.isEmpty())
+ return nullptr;
+
+ static GRefPtr<GPtrArray> languagesToReturn;
+ languagesToReturn = adoptGRef(g_ptr_array_new_with_free_func(g_free));
+ for (const auto& language : spellCheckingLanguages)
+ g_ptr_array_add(languagesToReturn.get(), g_strdup(language.utf8().data()));
+ g_ptr_array_add(languagesToReturn.get(), nullptr);
+
+ return reinterpret_cast<char**>(languagesToReturn->pdata);
#else
return 0;
#endif
@@ -871,7 +876,10 @@
g_return_if_fail(languages);
#if ENABLE(SPELLCHECK)
- context->priv->textChecker->setSpellCheckingLanguages(languages);
+ Vector<String> spellCheckingLanguages;
+ for (size_t i = 0; languages[i]; ++i)
+ spellCheckingLanguages.append(String::fromUTF8(languages[i]));
+ TextChecker::setSpellCheckingLanguages(spellCheckingLanguages);
#endif
}
Modified: trunk/Source/WebKit2/UIProcess/TextChecker.h (183935 => 183936)
--- trunk/Source/WebKit2/UIProcess/TextChecker.h 2015-05-07 18:01:46 UTC (rev 183935)
+++ trunk/Source/WebKit2/UIProcess/TextChecker.h 2015-05-07 18:24:31 UTC (rev 183936)
@@ -62,6 +62,11 @@
static void toggleSubstitutionsPanelIsShowing();
#endif
+#if PLATFORM(GTK)
+ static void setSpellCheckingLanguages(const Vector<String>&);
+ static Vector<String> loadedSpellCheckingLanguages();
+#endif
+
static void continuousSpellCheckingEnabledStateChanged(bool);
static void grammarCheckingEnabledStateChanged(bool);
static int64_t uniqueSpellDocumentTag(WebPageProxy*);
Modified: trunk/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp (183935 => 183936)
--- trunk/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp 2015-05-07 18:01:46 UTC (rev 183935)
+++ trunk/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp 2015-05-07 18:24:31 UTC (rev 183936)
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
* Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
+ * Copyright (C) 2011-2013 Samsung Electronics
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,120 +28,227 @@
#include "config.h"
#include "TextChecker.h"
+#include "TextBreakIterator.h"
#include "TextCheckerState.h"
+#include "WebProcessPool.h"
#include "WebTextChecker.h"
#include <WebCore/NotImplemented.h>
+#include <WebCore/TextCheckerEnchant.h>
+#include <wtf/NeverDestroyed.h>
using namespace WebCore;
-
+
namespace WebKit {
-static TextCheckerState textCheckerState;
-
-const TextCheckerState& TextChecker::state()
+static WebCore::TextCheckerEnchant& enchantTextChecker()
{
- static bool didInitializeState = false;
- if (didInitializeState)
- return textCheckerState;
+ static NeverDestroyed<WebCore::TextCheckerEnchant> checker;
- WebTextCheckerClient& client = WebTextChecker::singleton()->client();
- textCheckerState.isContinuousSpellCheckingEnabled = client.continuousSpellCheckingEnabled();
- textCheckerState.isGrammarCheckingEnabled = client.grammarCheckingEnabled();
+#if defined(DEVELOPMENT_BUILD)
+ // This is a bit of a hack, but ensures that for testing purposes,
+ // spell checking is properly initialized in WebKitTestRunner while
+ // running layout tests. We should consider replacing this with some
+ // more accessible C API at some point.
+ static std::once_flag onceFlag;
+ std::call_once(onceFlag, [] {
+ checker.get().updateSpellCheckingLanguages(Vector<String> { "en_US" });
+ });
+#endif
- didInitializeState = true;
+ return checker;
+}
+TextCheckerState& checkerState()
+{
+ static TextCheckerState textCheckerState;
+ static std::once_flag onceFlag;
+ std::call_once(onceFlag, [] {
+ textCheckerState.isContinuousSpellCheckingEnabled = false;;
+ textCheckerState.isGrammarCheckingEnabled = false;;
+ });
+
return textCheckerState;
}
-
+
+const TextCheckerState& TextChecker::state()
+{
+ return checkerState();
+}
+
+static void updateStateForAllContexts()
+{
+ const Vector<WebProcessPool*>& contexts = WebProcessPool::allProcessPools();
+ for (size_t i = 0; i < contexts.size(); ++i)
+ contexts[i]->textCheckerStateChanged();
+}
+
bool TextChecker::isContinuousSpellCheckingAllowed()
{
- return WebTextChecker::singleton()->client().continuousSpellCheckingAllowed();
+ return true;
}
void TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled)
{
- if (state().isContinuousSpellCheckingEnabled == isContinuousSpellCheckingEnabled)
+ if (checkerState().isContinuousSpellCheckingEnabled == isContinuousSpellCheckingEnabled)
return;
- textCheckerState.isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled;
- WebTextChecker::singleton()->client().setContinuousSpellCheckingEnabled(isContinuousSpellCheckingEnabled);
+ checkerState().isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled;
+ updateStateForAllContexts();
}
void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled)
{
- if (state().isGrammarCheckingEnabled == isGrammarCheckingEnabled)
+ if (checkerState().isGrammarCheckingEnabled == isGrammarCheckingEnabled)
return;
- textCheckerState.isGrammarCheckingEnabled = isGrammarCheckingEnabled;
- WebTextChecker::singleton()->client().setGrammarCheckingEnabled(isGrammarCheckingEnabled);
+ checkerState().isGrammarCheckingEnabled = isGrammarCheckingEnabled;
+ updateStateForAllContexts();
}
void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled)
{
- textCheckerState.isContinuousSpellCheckingEnabled = enabled;
+ checkerState().isContinuousSpellCheckingEnabled = enabled;
}
void TextChecker::grammarCheckingEnabledStateChanged(bool enabled)
{
- textCheckerState.isGrammarCheckingEnabled = enabled;
+ checkerState().isGrammarCheckingEnabled = enabled;
}
-int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy* page)
+int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*)
{
- return WebTextChecker::singleton()->client().uniqueSpellDocumentTag(page);
+ return 0;
}
-void TextChecker::closeSpellDocumentWithTag(int64_t tag)
+void TextChecker::closeSpellDocumentWithTag(int64_t /* tag */)
{
- WebTextChecker::singleton()->client().closeSpellDocumentWithTag(tag);
}
-void TextChecker::checkSpellingOfString(int64_t spellDocumentTag, StringView text, int32_t& misspellingLocation, int32_t& misspellingLength)
+void TextChecker::checkSpellingOfString(int64_t /* spellDocumentTag */, StringView text, int32_t& misspellingLocation, int32_t& misspellingLength)
{
- WebTextChecker::singleton()->client().checkSpellingOfString(spellDocumentTag, text.toStringWithoutCopying(), misspellingLocation, misspellingLength);
+ misspellingLocation = -1;
+ misspellingLength = 0;
+ enchantTextChecker().checkSpellingOfString(text.toStringWithoutCopying(), misspellingLocation, misspellingLength);
}
-void TextChecker::checkGrammarOfString(int64_t spellDocumentTag, StringView text, Vector<WebCore::GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
+void TextChecker::checkGrammarOfString(int64_t /* spellDocumentTag */, StringView /* text */, Vector<WebCore::GrammarDetail>& /* grammarDetails */, int32_t& /* badGrammarLocation */, int32_t& /* badGrammarLength */)
{
- WebTextChecker::singleton()->client().checkGrammarOfString(spellDocumentTag, text.toStringWithoutCopying(), grammarDetails, badGrammarLocation, badGrammarLength);
}
bool TextChecker::spellingUIIsShowing()
{
- return WebTextChecker::singleton()->client().spellingUIIsShowing();
+ return false;
}
void TextChecker::toggleSpellingUIIsShowing()
{
- WebTextChecker::singleton()->client().toggleSpellingUIIsShowing();
}
-void TextChecker::updateSpellingUIWithMisspelledWord(int64_t spellDocumentTag, const String& misspelledWord)
+void TextChecker::updateSpellingUIWithMisspelledWord(int64_t /* spellDocumentTag */, const String& /* misspelledWord */)
{
- WebTextChecker::singleton()->client().updateSpellingUIWithMisspelledWord(spellDocumentTag, misspelledWord);
}
-void TextChecker::updateSpellingUIWithGrammarString(int64_t spellDocumentTag, const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
+void TextChecker::updateSpellingUIWithGrammarString(int64_t /* spellDocumentTag */, const String& /* badGrammarPhrase */, const GrammarDetail& /* grammarDetail */)
{
- WebTextChecker::singleton()->client().updateSpellingUIWithGrammarString(spellDocumentTag, badGrammarPhrase, grammarDetail);
}
-void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& /* context */, Vector<String>& guesses)
+void TextChecker::getGuessesForWord(int64_t /* spellDocumentTag */, const String& word, const String& /* context */, Vector<String>& guesses)
{
- WebTextChecker::singleton()->client().guessesForWord(spellDocumentTag, word, guesses);
+ guesses = enchantTextChecker().getGuessesForWord(word);
}
-void TextChecker::learnWord(int64_t spellDocumentTag, const String& word)
+void TextChecker::learnWord(int64_t /* spellDocumentTag */, const String& word)
{
- WebTextChecker::singleton()->client().learnWord(spellDocumentTag, word);
+ enchantTextChecker().learnWord(word);
}
void TextChecker::ignoreWord(int64_t spellDocumentTag, const String& word)
{
- WebTextChecker::singleton()->client().ignoreWord(spellDocumentTag, word);
+ enchantTextChecker().ignoreWord(word);
}
-void TextChecker::requestCheckingOfString(PassRefPtr<TextCheckerCompletion>)
+void TextChecker::requestCheckingOfString(PassRefPtr<TextCheckerCompletion> completion)
{
- notImplemented();
+ if (!completion)
+ return;
+
+ TextCheckingRequestData request = completion->textCheckingRequestData();
+ ASSERT(request.sequence() != unrequestedTextCheckingSequence);
+ ASSERT(request.mask() != TextCheckingTypeNone);
+
+ completion->didFinishCheckingText(checkTextOfParagraph(completion->spellDocumentTag(), request.text(), request.mask()));
}
+#if USE(UNIFIED_TEXT_CHECKING)
+static unsigned nextWordOffset(StringView text, unsigned currentOffset)
+{
+ // FIXME: avoid creating textIterator object here, it could be passed as a parameter.
+ // isTextBreak() leaves the iterator pointing to the first boundary position at
+ // or after "offset" (ubrk_isBoundary side effect).
+ // For many word separators, the method doesn't properly determine the boundaries
+ // without resetting the iterator.
+ TextBreakIterator* textIterator = wordBreakIterator(text);
+ if (!textIterator)
+ return currentOffset;
+
+ unsigned wordOffset = currentOffset;
+ while (wordOffset < text.length() && isTextBreak(textIterator, wordOffset))
+ ++wordOffset;
+
+ // Do not treat the word's boundary as a separator.
+ if (!currentOffset && wordOffset == 1)
+ return currentOffset;
+
+ // Omit multiple separators.
+ if ((wordOffset - currentOffset) > 1)
+ --wordOffset;
+
+ return wordOffset;
+}
+
+Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, uint64_t checkingTypes)
+{
+ if (!(checkingTypes & TextCheckingTypeSpelling))
+ return Vector<TextCheckingResult>();
+
+ TextBreakIterator* textIterator = wordBreakIterator(text);
+ if (!textIterator)
+ return Vector<TextCheckingResult>();
+
+ // Omit the word separators at the beginning/end of the text to don't unnecessarily
+ // involve the client to check spelling for them.
+ unsigned offset = nextWordOffset(text, 0);
+ unsigned lengthStrip = text.length();
+ while (lengthStrip > 0 && isTextBreak(textIterator, lengthStrip - 1))
+ --lengthStrip;
+
+ Vector<TextCheckingResult> paragraphCheckingResult;
+ while (offset < lengthStrip) {
+ int32_t misspellingLocation = -1;
+ int32_t misspellingLength = 0;
+ checkSpellingOfString(spellDocumentTag, text.substring(offset, lengthStrip - offset), misspellingLocation, misspellingLength);
+ if (!misspellingLength)
+ break;
+
+ TextCheckingResult misspellingResult;
+ misspellingResult.type = TextCheckingTypeSpelling;
+ misspellingResult.location = offset + misspellingLocation;
+ misspellingResult.length = misspellingLength;
+ paragraphCheckingResult.append(misspellingResult);
+ offset += misspellingLocation + misspellingLength;
+ // Generally, we end up checking at the word separator, move to the adjacent word.
+ offset = nextWordOffset(text.substring(0, lengthStrip), offset);
+ }
+ return paragraphCheckingResult;
+}
+#endif
+
+void TextChecker::setSpellCheckingLanguages(const Vector<String>& languages)
+{
+ enchantTextChecker().updateSpellCheckingLanguages(languages);
+}
+
+Vector<String> TextChecker::loadedSpellCheckingLanguages()
+{
+ return enchantTextChecker().loadedSpellCheckingLanguages();
+}
+
} // namespace WebKit