[WK2] Support setMarkedText/hasMarkedText/unmarkText/insertText for WTR TextInputCont...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Oct 2011 19:46:39 +0000 (19:46 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Oct 2011 19:46:39 +0000 (19:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68924

Source/WebKit2:

Implemented WKBundlePage private APIs to support the above functions.

Patch by Chang Shu <cshu@webkit.org> on 2011-10-05
Reviewed by Darin Adler.

* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageSetComposition):
(WKBundlePageHasComposition):
(WKBundlePageConfirmComposition):
(WKBundlePageConfirmCompositionWithText):
* WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setCompositionForTesting):
(WebKit::WebPage::hasCompositionForTesting):
(WebKit::WebPage::confirmCompositionForTesting):
* WebProcess/WebPage/WebPage.h:

Tools:

Added TextInputController files and JS interfaces for the above functions.

Patch by Chang Shu <cshu@webkit.org> on 2011-10-05
Reviewed by Darin Adler.

* WebKitTestRunner/DerivedSources.make:
* WebKitTestRunner/DerivedSources.pro:
* WebKitTestRunner/GNUmakefile.am:
* WebKitTestRunner/InjectedBundle/Bindings/TextInputController.idl: Added.
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::beginTesting):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
(WTR::InjectedBundle::textInputController):
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::didClearWindowForFrame):
* WebKitTestRunner/InjectedBundle/TextInputController.cpp: Added.
(WTR::TextInputController::create):
(WTR::TextInputController::TextInputController):
(WTR::TextInputController::~TextInputController):
(WTR::TextInputController::wrapperClass):
(WTR::TextInputController::makeWindowObject):
(WTR::TextInputController::setMarkedText):
(WTR::TextInputController::hasMarkedText):
(WTR::TextInputController::unmarkText):
(WTR::TextInputController::insertText):
* WebKitTestRunner/InjectedBundle/TextInputController.h: Added.
* WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro:
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
* WebKitTestRunner/win/InjectedBundle.vcproj:

LayoutTests:

Unskip passed tests.

Patch by Chang Shu <cshu@webkit.org> on 2011-10-05
Reviewed by Darin Adler.

* platform/wk2/Skipped:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@96740 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/wk2/Skipped
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Tools/ChangeLog
Tools/WebKitTestRunner/DerivedSources.make
Tools/WebKitTestRunner/DerivedSources.pro
Tools/WebKitTestRunner/GNUmakefile.am
Tools/WebKitTestRunner/InjectedBundle/Bindings/TextInputController.idl [new file with mode: 0644]
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
Tools/WebKitTestRunner/InjectedBundle/TextInputController.cpp [new file with mode: 0644]
Tools/WebKitTestRunner/InjectedBundle/TextInputController.h [new file with mode: 0644]
Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro
Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
Tools/WebKitTestRunner/win/InjectedBundle.vcproj

index 818f152021c9d44d582a772d786aa339b50c12fb..afa916e33cfcf7337bb0fd21e82addd999076905 100644 (file)
@@ -1,3 +1,14 @@
+2011-10-05  Chang Shu  <cshu@webkit.org>
+
+        [WK2] Support setMarkedText/hasMarkedText/unmarkText/insertText for WTR TextInputController
+        https://bugs.webkit.org/show_bug.cgi?id=68924
+
+        Unskip passed tests.
+
+        Reviewed by Darin Adler.
+
+        * platform/wk2/Skipped:
+
 2011-10-05  Chang Shu  <cshu@webkit.org>
 
         [WK2] WebKitTestRunner needs LayoutTestController.dumpConfigurationForViewport
index d9a653b237e767c0f6e9303d409f1e73e4eca9ec..443c9a04424292ad581b6ac0c5e99b2bb2c59161 100644 (file)
@@ -436,16 +436,12 @@ http/tests/loading/state-object-security-exception.html
 # WebKitTestRunner needs textInputController
 # <https://bugs.webkit.org/show_bug.cgi?id=42337>
 editing/input/setting-input-value-cancel-ime-composition.html
-editing/inserting/insert-composition-whitespace.html
 svg/text/caret-in-svg-text.xhtml
-editing/input/ime-composition-clearpreedit.html
 editing/spelling/spelling-backspace-between-lines.html
 editing/selection/5825350-1.html
 editing/selection/5825350-2.html
 editing/selection/move-left-right.html
 fast/events/ime-composition-events-001.html
-fast/forms/input-maxlength-ime-completed.html
-fast/forms/input-maxlength-ime-preedit.html
 fast/text/international/thai-cursor-position.html
 platform/mac/editing/input/5576619.html
 platform/mac/editing/input/bold-node.html
@@ -455,13 +451,9 @@ platform/mac/editing/input/firstrectforcharacterrange-styled.html
 platform/mac/editing/input/hangul-enter-confirms-and-sends-keypress.html
 platform/mac/editing/input/insert-delete-smp-symbol.html
 platform/mac/editing/input/kotoeri-enter-to-confirm-and-newline.html
-platform/mac/editing/input/maxlength.html
-platform/mac/editing/input/NSBackgroundColor-transparent.html
 platform/mac/editing/input/range-for-empty-document.html
 platform/mac/editing/input/replace-invalid-range.html
 platform/mac/editing/input/secure-input.html
-platform/mac/editing/input/selection-change-closes-typing.html
-platform/mac/editing/input/text-control-ime-input.html
 platform/mac/editing/input/text-input-controller.html
 platform/mac/editing/input/wrapped-line-char-rect.html
 platform/mac/editing/pasteboard/paste-and-match-style-selector-event.html
index 5ba41212dff15c48a5a8ec0fa6b7755e77d45302..89bbdf60bc60297457d2aa5a341335d7baa26c7b 100644 (file)
@@ -1,3 +1,24 @@
+2011-10-05  Chang Shu  <cshu@webkit.org>
+
+        [WK2] Support setMarkedText/hasMarkedText/unmarkText/insertText for WTR TextInputController
+        https://bugs.webkit.org/show_bug.cgi?id=68924
+
+        Implemented WKBundlePage private APIs to support the above functions.
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+        (WKBundlePageSetComposition):
+        (WKBundlePageHasComposition):
+        (WKBundlePageConfirmComposition):
+        (WKBundlePageConfirmCompositionWithText):
+        * WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setCompositionForTesting):
+        (WebKit::WebPage::hasCompositionForTesting):
+        (WebKit::WebPage::confirmCompositionForTesting):
+        * WebProcess/WebPage/WebPage.h:
+
 2011-10-05  Alexey Proskuryakov  <ap@apple.com>
 
         [Mac] Make built-in PDF description localizable
index 921dac1902f13be1f10f6cde61158f736d23761b..98b8224c3a879b793182e5d7285bac1e404528e8 100644 (file)
@@ -295,3 +295,23 @@ WKStringRef WKBundlePageViewportConfigurationAsText(WKBundlePageRef pageRef, int
 {
     return toCopiedAPI(toImpl(pageRef)->viewportConfigurationAsText(deviceDPI, deviceWidth, deviceHeight, availableWidth, availableHeight));
 }
+
+void WKBundlePageSetComposition(WKBundlePageRef pageRef, WKStringRef text, int from, int length)
+{
+    toImpl(pageRef)->setCompositionForTesting(toImpl(text)->string(), from, length);
+}
+
+bool WKBundlePageHasComposition(WKBundlePageRef pageRef)
+{
+    return toImpl(pageRef)->hasCompositionForTesting();
+}
+
+void WKBundlePageConfirmComposition(WKBundlePageRef pageRef)
+{
+    toImpl(pageRef)->confirmCompositionForTesting(String());
+}
+
+void WKBundlePageConfirmCompositionWithText(WKBundlePageRef pageRef, WKStringRef text)
+{
+    toImpl(pageRef)->confirmCompositionForTesting(toImpl(text)->string());
+}
index e9bab0330c552f80402f94abd083eafa8eb6f8a5..e6dc96f3b6a8a74b13287590e17120eafb4b8b2f 100644 (file)
@@ -62,6 +62,11 @@ WK_EXPORT WKArrayRef WKBundlePageCopyTrackedRepaintRects(WKBundlePageRef page);
 
 WK_EXPORT WKStringRef WKBundlePageViewportConfigurationAsText(WKBundlePageRef, int deviceDPI, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight);
 
+WK_EXPORT void WKBundlePageSetComposition(WKBundlePageRef page, WKStringRef text, int from, int length);
+WK_EXPORT bool WKBundlePageHasComposition(WKBundlePageRef page);
+WK_EXPORT void WKBundlePageConfirmComposition(WKBundlePageRef page);
+WK_EXPORT void WKBundlePageConfirmCompositionWithText(WKBundlePageRef page, WKStringRef text);
+
 #ifdef __cplusplus
 }
 #endif
index 05de806262238ed0e80ff1c914214aaa51510aa7..091789b8b425377811b8bbe3ce119d81f7aef2e4 100644 (file)
@@ -2547,6 +2547,34 @@ String WebPage::viewportConfigurationAsText(int deviceDPI, int deviceWidth, int
     return String::format("viewport size %dx%d scale %f with limits [%f, %f] and userScalable %f\n", attrs.layoutSize.width(), attrs.layoutSize.height(), attrs.initialScale, attrs.minimumScale, attrs.maximumScale, attrs.userScalable);
 }
 
+void WebPage::setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length)
+{
+    Frame* frame = m_page->focusController()->focusedOrMainFrame();
+    if (!frame || !frame->editor()->canEdit())
+        return;
+
+    Vector<CompositionUnderline> underlines;
+    underlines.append(CompositionUnderline(0, compositionString.length(), Color(Color::black), false));
+    frame->editor()->setComposition(compositionString, underlines, from, from + length);
+}
+
+bool WebPage::hasCompositionForTesting()
+{
+    Frame* frame = m_page->focusController()->focusedOrMainFrame();
+    return frame && frame->editor()->hasComposition();
+}
+
+void WebPage::confirmCompositionForTesting(const String& compositionString)
+{
+    Frame* frame = m_page->focusController()->focusedOrMainFrame();
+    if (!frame || !frame->editor()->canEdit())
+        return;
+
+    if (compositionString.isNull())
+        frame->editor()->confirmComposition();
+    frame->editor()->confirmComposition(compositionString);
+}
+
 Frame* WebPage::mainFrame() const
 {
     return m_page ? m_page->mainFrame() : 0;
index 96b107585b3c63dde1463c0916b2fcf60b6eac09..b3d87aca764ea5908985f7daa9d09ac6edd7e76b 100644 (file)
@@ -374,6 +374,10 @@ public:
     void gestureDidEnd();
 #endif
 
+    void setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length);
+    bool hasCompositionForTesting();
+    void confirmCompositionForTesting(const String& compositionString);
+
     // FIXME: This a dummy message, to avoid breaking the build for platforms that don't require
     // any synchronous messages, and should be removed when <rdar://problem/8775115> is fixed.
     void dummy(bool&);
index 05521b618e741ddd0d752b61088e257a83bf2c83..4d7f9c17157577eb19e01dca4b94c0924456eeb6 100644 (file)
@@ -1,3 +1,37 @@
+2011-10-05  Chang Shu  <cshu@webkit.org>
+
+        [WK2] Support setMarkedText/hasMarkedText/unmarkText/insertText for WTR TextInputController
+        https://bugs.webkit.org/show_bug.cgi?id=68924
+
+        Added TextInputController files and JS interfaces for the above functions.
+
+        Reviewed by Darin Adler.
+
+        * WebKitTestRunner/DerivedSources.make:
+        * WebKitTestRunner/DerivedSources.pro:
+        * WebKitTestRunner/GNUmakefile.am:
+        * WebKitTestRunner/InjectedBundle/Bindings/TextInputController.idl: Added.
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::beginTesting):
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+        (WTR::InjectedBundle::textInputController):
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::didClearWindowForFrame):
+        * WebKitTestRunner/InjectedBundle/TextInputController.cpp: Added.
+        (WTR::TextInputController::create):
+        (WTR::TextInputController::TextInputController):
+        (WTR::TextInputController::~TextInputController):
+        (WTR::TextInputController::wrapperClass):
+        (WTR::TextInputController::makeWindowObject):
+        (WTR::TextInputController::setMarkedText):
+        (WTR::TextInputController::hasMarkedText):
+        (WTR::TextInputController::unmarkText):
+        (WTR::TextInputController::insertText):
+        * WebKitTestRunner/InjectedBundle/TextInputController.h: Added.
+        * WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro:
+        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+        * WebKitTestRunner/win/InjectedBundle.vcproj:
+
 2011-10-04  Oliver Hunt  <oliver@apple.com>
 
         Add rudimentary filtering to write barriers
index c308a8a105b8a2c359453fef726ad5c57bb485ed..ed1531bc2863e0ba37421073b08bb09112fc35be 100644 (file)
@@ -29,6 +29,7 @@ INTERFACES = \
     EventSendingController \
     GCController \
     LayoutTestController \
+    TextInputController \
 #
 
 SCRIPTS = \
index ce7ac6310a24a75f43a5d0d9987ee89fec04b0ee..eda239e8ec145d9bc46f32a11d2db4ae24ba102f 100644 (file)
@@ -13,6 +13,7 @@ IDL_BINDINGS += \
     InjectedBundle/Bindings/EventSendingController.idl \
     InjectedBundle/Bindings/GCController.idl \
     InjectedBundle/Bindings/LayoutTestController.idl \
+    InjectedBundle/Bindings/TextInputController.idl \
 
 defineTest(addExtraCompiler) {
     eval($${1}.CONFIG = target_predeps no_link)
index eb6b95086f9095a59e1562a7d5aa534cb56d509e..42d4f4c62849e3cb5b402c5b47bf2f84a8700f21 100644 (file)
@@ -59,7 +59,8 @@ noinst_LTLIBRARIES += Libraries/libTestRunnerInjectedBundle.la
 webkittestrunner_built_sources += \
        DerivedSources/InjectedBundle/JSEventSendingController.cpp \
        DerivedSources/InjectedBundle/JSGCController.cpp \
-       DerivedSources/InjectedBundle/JSLayoutTestController.cpp
+       DerivedSources/InjectedBundle/JSLayoutTestController.cpp \
+       DerivedSources/InjectedBundle/JSTextInputController.cpp
 nodist_Libraries_libTestRunnerInjectedBundle_la_SOURCES = $(webkittestrunner_built_sources)
 BUILT_SOURCES += $(webkittestrunner_built_sources)
 
@@ -81,7 +82,8 @@ Libraries_libTestRunnerInjectedBundle_la_SOURCES = \
        Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp \
        Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h \
        Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp \
-       Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
+       Tools/WebKitTestRunner/InjectedBundle/TextInputController.cpp \
+       Tools/WebKitTestRunner/InjectedBundle/TextInputController.h
 
 Libraries_libTestRunnerInjectedBundle_la_LIBADD = \
        libWebCoreInternals.la
diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TextInputController.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TextInputController.idl
new file mode 100644 (file)
index 0000000..ceb3a00
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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.
+ */
+
+module WTR {
+
+    interface TextInputController {
+        void setMarkedText(in DOMString string, in long from, in long length);
+        boolean hasMarkedText();
+        void unmarkText();
+        void insertText(in DOMString string);
+    };
+
+}
+
index 568916e60c593c59e7b4fb2fb6e030938cc695f7..2c9f00846dd63c94cb8c0a44daff579d9c80a42a 100644 (file)
@@ -187,6 +187,7 @@ void InjectedBundle::beginTesting()
     m_layoutTestController = LayoutTestController::create();
     m_gcController = GCController::create();
     m_eventSendingController = EventSendingController::create();
+    m_textInputController = TextInputController::create();
 
     WKBundleSetShouldTrackVisitedLinks(m_bundle, false);
     WKBundleRemoveAllVisitedLinks(m_bundle);
index 62cd0c0338f74a97edc544c80bba2ff750125ca7..f1912896aa6aa847c68db18ed78fed2642611d2c 100644 (file)
@@ -29,6 +29,7 @@
 #include "EventSendingController.h"
 #include "GCController.h"
 #include "LayoutTestController.h"
+#include "TextInputController.h"
 #include <WebKit2/WKBase.h>
 #include <WebKit2/WKRetainPtr.h>
 #include <wtf/OwnPtr.h>
@@ -54,6 +55,7 @@ public:
     LayoutTestController* layoutTestController() { return m_layoutTestController.get(); }
     GCController* gcController() { return m_gcController.get(); }
     EventSendingController* eventSendingController() { return m_eventSendingController.get(); }
+    TextInputController* textInputController() { return m_textInputController.get(); }
 
     InjectedBundlePage* page() const;
     size_t pageCount() const { return m_pages.size(); }
@@ -104,6 +106,7 @@ private:
     RefPtr<LayoutTestController> m_layoutTestController;
     RefPtr<GCController> m_gcController;
     RefPtr<EventSendingController> m_eventSendingController;
+    RefPtr<TextInputController> m_textInputController;
 
     WKBundleFrameRef m_topLoadingFrame;
 
index d515733e237d564bf1c121d629a4eb428f0d063c..b668a40a0a8d4aa29784b086cddcae7f36058810 100644 (file)
@@ -644,6 +644,7 @@ void InjectedBundlePage::didClearWindowForFrame(WKBundleFrameRef frame, WKBundle
     InjectedBundle::shared().layoutTestController()->makeWindowObject(context, window, &exception);
     InjectedBundle::shared().gcController()->makeWindowObject(context, window, &exception);
     InjectedBundle::shared().eventSendingController()->makeWindowObject(context, window, &exception);
+    InjectedBundle::shared().textInputController()->makeWindowObject(context, window, &exception);
     WebCoreTestSupport::injectInternalsObject(context);
 }
 
diff --git a/Tools/WebKitTestRunner/InjectedBundle/TextInputController.cpp b/Tools/WebKitTestRunner/InjectedBundle/TextInputController.cpp
new file mode 100644 (file)
index 0000000..0087aa3
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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 "TextInputController.h"
+
+#include "InjectedBundle.h"
+#include "InjectedBundlePage.h"
+#include "JSTextInputController.h"
+#include "StringFunctions.h"
+#include <WebKit2/WKBundlePagePrivate.h>
+
+namespace WTR {
+
+PassRefPtr<TextInputController> TextInputController::create()
+{
+    return adoptRef(new TextInputController);
+}
+
+TextInputController::TextInputController()
+{
+}
+
+TextInputController::~TextInputController()
+{
+}
+
+JSClassRef TextInputController::wrapperClass()
+{
+    return JSTextInputController::textInputControllerClass();
+}
+
+void TextInputController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
+{
+    setProperty(context, windowObject, "textInputController", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
+}
+
+void TextInputController::setMarkedText(JSStringRef text, int from, int length)
+{
+    WKBundlePageSetComposition(InjectedBundle::shared().page()->page(), toWK(text).get(), from, length);
+}
+
+bool TextInputController::hasMarkedText()
+{
+    return WKBundlePageHasComposition(InjectedBundle::shared().page()->page());
+}
+
+void TextInputController::unmarkText()
+{
+    WKBundlePageConfirmComposition(InjectedBundle::shared().page()->page());
+}
+
+void TextInputController::insertText(JSStringRef text)
+{
+    WKBundlePageConfirmCompositionWithText(InjectedBundle::shared().page()->page(), toWK(text).get());
+}
+
+} // namespace WTR
diff --git a/Tools/WebKitTestRunner/InjectedBundle/TextInputController.h b/Tools/WebKitTestRunner/InjectedBundle/TextInputController.h
new file mode 100644 (file)
index 0000000..71a0437
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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.
+ */
+
+#ifndef TextInputController_h
+#define TextInputController_h
+
+#include "JSWrappable.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WTR {
+
+class TextInputController : public JSWrappable {
+public:
+    static PassRefPtr<TextInputController> create();
+    virtual ~TextInputController();
+
+    // JSWrappable
+    virtual JSClassRef wrapperClass();
+
+    void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception);
+
+    void setMarkedText(JSStringRef text, int from, int length);
+    bool hasMarkedText();
+    void unmarkText();
+    void insertText(JSStringRef text);
+
+private:
+    TextInputController();
+};
+
+} // namespace WTR
+
+#endif // TextInputController_h
index 34c5a7a65758bba837f32cd992102acf3ffee402..1d018a7e1d332d987ff9132c0226d3512d79f528 100644 (file)
@@ -24,6 +24,8 @@ SOURCES += \
     ../GCController.h \
     ../LayoutTestController.cpp \
     ../LayoutTestController.h \
+    ../TextInputController.cpp \
+    ../TextInputController.h \
     ../Bindings/JSWrapper.cpp \
     ActivateFontsQt.cpp \
     InjectedBundleQt.cpp \
@@ -31,6 +33,7 @@ SOURCES += \
     $$GENERATED_SOURCES_DIR/JSEventSendingController.cpp \
     $$GENERATED_SOURCES_DIR/JSGCController.cpp \
     $$GENERATED_SOURCES_DIR/JSLayoutTestController.cpp \
+    $$GENERATED_SOURCES_DIR/JSTextInputController.cpp \
 
 HEADERS += \
     ../ActivateFonts.h \
@@ -39,6 +42,7 @@ HEADERS += \
     ../InjectedBundle.h \
     ../InjectedBundlePage.h \
     ../LayoutTestController.h \
+    ../TextInputController.h \
 
 !CONFIG(release, debug|release) {
     OBJECTS_DIR = obj/debug
index 7c6e2271722193b9e1f732e3ae6347e40dd32f51..786acbc11c699daa99fdc6e5c933991aad97aadc 100644 (file)
@@ -23,6 +23,8 @@
 /* Begin PBXBuildFile section */
                5322FB4313FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5322FB4113FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp */; };
                5322FB4613FDA0EA0041ABCC /* PixelDumpSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5322FB4413FDA0EA0041ABCC /* PixelDumpSupport.cpp */; };
+               5641E2D014335E95008307E5 /* JSTextInputController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5641E2CE14335E95008307E5 /* JSTextInputController.cpp */; };
+               5664A49A14326384008881BE /* TextInputController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5664A49814326384008881BE /* TextInputController.cpp */; };
                5670B8281386FCA5002EB355 /* EventSenderProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5670B8271386FCA5002EB355 /* EventSenderProxy.mm */; };
                6510A78211EC643800410867 /* AHEM____.TTF in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77711EC643800410867 /* AHEM____.TTF */; };
                6510A78311EC643800410867 /* ColorBits.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77811EC643800410867 /* ColorBits.ttf */; };
                5322FB4213FDA0CD0041ABCC /* CyclicRedundancyCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CyclicRedundancyCheck.h; sourceTree = "<group>"; };
                5322FB4413FDA0EA0041ABCC /* PixelDumpSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PixelDumpSupport.cpp; sourceTree = "<group>"; };
                5322FB4513FDA0EA0041ABCC /* PixelDumpSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PixelDumpSupport.h; sourceTree = "<group>"; };
+               5641E2CE14335E95008307E5 /* JSTextInputController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSTextInputController.cpp; path = DerivedSources/WebKitTestRunner/JSTextInputController.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
+               5641E2CF14335E95008307E5 /* JSTextInputController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSTextInputController.h; path = DerivedSources/WebKitTestRunner/JSTextInputController.h; sourceTree = BUILT_PRODUCTS_DIR; };
+               5664A49614326377008881BE /* TextInputController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TextInputController.idl; sourceTree = "<group>"; };
+               5664A49814326384008881BE /* TextInputController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextInputController.cpp; sourceTree = "<group>"; };
+               5664A49914326384008881BE /* TextInputController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputController.h; sourceTree = "<group>"; };
                5670B8261386FC13002EB355 /* EventSenderProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSenderProxy.h; sourceTree = "<group>"; };
                5670B8271386FCA5002EB355 /* EventSenderProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EventSenderProxy.mm; sourceTree = "<group>"; };
                6510A77711EC643800410867 /* AHEM____.TTF */ = {isa = PBXFileReference; lastKnownFileType = file; name = "AHEM____.TTF"; path = "fonts/AHEM____.TTF"; sourceTree = "<group>"; };
                                BCC9981711D3F51E0017BCA2 /* LayoutTestController.cpp */,
                                BCC9981611D3F51E0017BCA2 /* LayoutTestController.h */,
                                C0CE720A1247C93300BC0EC4 /* LayoutTestControllerMac.mm */,
+                               5664A49814326384008881BE /* TextInputController.cpp */,
+                               5664A49914326384008881BE /* TextInputController.h */,
                        );
                        name = Controllers;
                        sourceTree = "<group>";
                                BC8FD8CB120E52B000F3E71A /* EventSendingController.idl */,
                                BC14E4E1120E032000826C0C /* GCController.idl */,
                                BC952ED211F3C29F003398B4 /* LayoutTestController.idl */,
+                               5664A49614326377008881BE /* TextInputController.idl */,
                        );
                        path = Bindings;
                        sourceTree = "<group>";
                                BC14E4E9120E03D800826C0C /* JSGCController.h */,
                                BC952F1D11F3C652003398B4 /* JSLayoutTestController.cpp */,
                                BC952F1E11F3C652003398B4 /* JSLayoutTestController.h */,
+                               5641E2CE14335E95008307E5 /* JSTextInputController.cpp */,
+                               5641E2CF14335E95008307E5 /* JSTextInputController.h */,
                        );
                        name = "Derived Sources";
                        sourceTree = "<group>";
                                BC8FD8CA120E527F00F3E71A /* EventSendingController.cpp in Sources */,
                                BC8FD8D2120E545B00F3E71A /* JSEventSendingController.cpp in Sources */,
                                C0CE720B1247C93300BC0EC4 /* LayoutTestControllerMac.mm in Sources */,
+                               5664A49A14326384008881BE /* TextInputController.cpp in Sources */,
+                               5641E2D014335E95008307E5 /* JSTextInputController.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index bc48534530598369b45043cf2d58ecfffc53765a..f728d63a80f0de9cc9e127dae1e837f18d8ee7a5 100644 (file)
                                        />
                                </FileConfiguration>
                        </File>
+                       <File
+                               RelativePath="..\InjectedBundle\Bindings\TextInputController.idl"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCMIDLTool"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCMIDLTool"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug_All|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCMIDLTool"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug_Cairo_CFLite|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCMIDLTool"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release_Cairo_CFLite|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCMIDLTool"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Production|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCMIDLTool"
+                                       />
+                               </FileConfiguration>
+                       </File>
                </Filter>
                <Filter
                        Name="Derived Sources"
                                RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSLayoutTestController.h"
                                >
                        </File>
+                       <File
+                               RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSTextInputController.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSTextInputController.h"
+                               >
+                       </File>
                </Filter>
                <File
                        RelativePath="..\InjectedBundle\win\ActivateFonts.cpp"
                        RelativePath="..\InjectedBundle\win\LayoutTestControllerWin.cpp"
                        >
                </File>
+               <File
+                       RelativePath="..\InjectedBundle\TextInputController.cpp"
+                       >
+               </File>
+               <File
+                       RelativePath="..\InjectedBundle\TextInputController.h"
+                       >
+               </File>
        </Files>
        <Globals>
        </Globals>