[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

tkent at chromium.org tkent at chromium.org
Thu Apr 8 02:16:59 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 12335729a60a5f3674420fa4e2c7048181a24bde
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Mar 9 06:39:34 2010 +0000

    2010-03-08  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Dimitri Glazkov.
    
            [DRT/Chromium] Add PlainTextController and TextInputController
            https://bugs.webkit.org/show_bug.cgi?id=35852
    
            Add PlainTextController and TextInputController classes, which are going
            to be used by DumpRenderTree Chromium port. These files are based on:
            - src/webkit/tools/test_shell/plain_text_controller.{cc,h} and
            - src/webkit/tools/test_shell/text_input_controller.{cc,h}
            of Chromium rev.40492.
    
            * DumpRenderTree/chromium/PlainTextController.cpp: Added.
            * DumpRenderTree/chromium/PlainTextController.h: Added.
            * DumpRenderTree/chromium/TextInputController.cpp: Added.
            * DumpRenderTree/chromium/TextInputController.h: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55712 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index de583e9..3ac4094 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,21 @@
+2010-03-08  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        [DRT/Chromium] Add PlainTextController and TextInputController
+        https://bugs.webkit.org/show_bug.cgi?id=35852
+
+        Add PlainTextController and TextInputController classes, which are going
+        to be used by DumpRenderTree Chromium port. These files are based on:
+        - src/webkit/tools/test_shell/plain_text_controller.{cc,h} and
+        - src/webkit/tools/test_shell/text_input_controller.{cc,h}
+        of Chromium rev.40492.
+
+        * DumpRenderTree/chromium/PlainTextController.cpp: Added.
+        * DumpRenderTree/chromium/PlainTextController.h: Added.
+        * DumpRenderTree/chromium/TextInputController.cpp: Added.
+        * DumpRenderTree/chromium/TextInputController.h: Added.
+
 2010-03-08  Dumitru Daniliuc  <dumi at chromium.org>
 
         Unreviewed, Chromium build fix.
diff --git a/WebKitTools/DumpRenderTree/chromium/PlainTextController.cpp b/WebKitTools/DumpRenderTree/chromium/PlainTextController.cpp
new file mode 100644
index 0000000..6e6cf11
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/chromium/PlainTextController.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2009 Pawel Hajdan (phajdan.jr at chromium.org)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 "PlainTextController.h"
+
+#include "TestShell.h"
+#include "public/WebBindings.h"
+#include "public/WebRange.h"
+#include "public/WebString.h"
+
+using namespace WebKit;
+
+PlainTextController::PlainTextController()
+{
+    // Initialize the map that associates methods of this class with the names
+    // they will use when called by JavaScript. The actual binding of those
+    // names to their methods will be done by calling bindToJavaScript() (defined
+    // by CppBoundClass, the parent to PlainTextController).
+    bindMethod("plainText", &PlainTextController::plainText);
+
+    // The fallback method is called when an unknown method is invoked.
+    bindFallbackMethod(&PlainTextController::fallbackMethod);
+}
+
+void PlainTextController::plainText(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+
+    if (arguments.size() < 1 || !arguments[0].isObject())
+        return;
+
+    // Check that passed-in object is, in fact, a range.
+    NPObject* npobject = NPVARIANT_TO_OBJECT(arguments[0]);
+    if (!npobject)
+        return;
+    WebRange range;
+    if (!WebBindings::getRange(npobject, &range))
+        return;
+
+    // Extract the text using the Range's text() method
+    WebString text = range.toPlainText();
+    result->set(text.utf8());
+}
+
+void PlainTextController::fallbackMethod(const CppArgumentList&, CppVariant* result)
+{
+    printf("CONSOLE MESSAGE: JavaScript ERROR: unknown method called on PlainTextController\n");
+    result->setNull();
+}
+
diff --git a/WebKitTools/DumpRenderTree/chromium/PlainTextController.h b/WebKitTools/DumpRenderTree/chromium/PlainTextController.h
new file mode 100644
index 0000000..3d3a04c
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/chromium/PlainTextController.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 PlainTextController_h
+#define PlainTextController_h
+
+#include "CppBoundClass.h"
+
+class TestShell;
+
+class PlainTextController : public CppBoundClass {
+public:
+    // Builds the property and method lists needed to bind this class to a JS
+    // object.
+    explicit PlainTextController();
+
+    // JS callback methods.
+    void plainText(const CppArgumentList&, CppVariant*);
+
+    // Fall-back method: called if an unknown method is invoked.
+    void fallbackMethod(const CppArgumentList&, CppVariant*);
+};
+
+#endif // PlainTextController_h
+
diff --git a/WebKitTools/DumpRenderTree/chromium/TextInputController.cpp b/WebKitTools/DumpRenderTree/chromium/TextInputController.cpp
new file mode 100644
index 0000000..f2186ca
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/chromium/TextInputController.cpp
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 "TestShell.h"
+#include "base/string_util.h"
+#include "public/WebFrame.h"
+#include "public/WebRange.h"
+#include "public/WebString.h"
+#include "public/WebView.h"
+
+using namespace WebKit;
+
+TestShell* TextInputController::testShell = 0;
+
+TextInputController::TextInputController(TestShell* shell)
+{
+    // Set static testShell variable. Be careful not to assign testShell to new
+    // windows which are temporary.
+    if (!testShell)
+        testShell = shell;
+
+    bindMethod("insertText", &TextInputController::insertText);
+    bindMethod("doCommand", &TextInputController::doCommand);
+    bindMethod("setMarkedText", &TextInputController::setMarkedText);
+    bindMethod("unmarkText", &TextInputController::unmarkText);
+    bindMethod("hasMarkedText", &TextInputController::hasMarkedText);
+    bindMethod("conversationIdentifier", &TextInputController::conversationIdentifier);
+    bindMethod("substringFromRange", &TextInputController::substringFromRange);
+    bindMethod("attributedSubstringFromRange", &TextInputController::attributedSubstringFromRange);
+    bindMethod("markedRange", &TextInputController::markedRange);
+    bindMethod("selectedRange", &TextInputController::selectedRange);
+    bindMethod("firstRectForCharacterRange", &TextInputController::firstRectForCharacterRange);
+    bindMethod("characterIndexForPoint", &TextInputController::characterIndexForPoint);
+    bindMethod("validAttributesForMarkedText", &TextInputController::validAttributesForMarkedText);
+    bindMethod("makeAttributedString", &TextInputController::makeAttributedString);
+}
+
+WebFrame* TextInputController::getMainFrame()
+{
+    return testShell->webView()->mainFrame();
+}
+
+void TextInputController::insertText(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+
+    WebFrame* mainFrame = getMainFrame();
+    if (!mainFrame)
+        return;
+    if (arguments.size() < 1 || !arguments[0].isString())
+        return;
+
+    if (mainFrame->hasMarkedText()) {
+        mainFrame->unmarkText();
+        mainFrame->replaceSelection(WebString());
+    }
+    mainFrame->insertText(WebString::fromUTF8(arguments[0].toString()));
+}
+
+void TextInputController::doCommand(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+
+    WebFrame* mainFrame = getMainFrame();
+    if (!mainFrame)
+        return;
+
+    if (arguments.size() >= 1 && arguments[0].isString())
+        mainFrame->executeCommand(WebString::fromUTF8(arguments[0].toString()));
+}
+
+void TextInputController::setMarkedText(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+
+    WebFrame* mainFrame = getMainFrame();
+    if (!mainFrame)
+        return;
+
+    if (arguments.size() >= 3 && arguments[0].isString()
+        && arguments[1].isNumber() && arguments[2].isNumber()) {
+        mainFrame->setMarkedText(WebString::fromUTF8(arguments[0].toString()),
+                                 arguments[1].toInt32(),
+                                 arguments[2].toInt32());
+    }
+}
+
+void TextInputController::unmarkText(const CppArgumentList&, CppVariant* result)
+{
+    result->setNull();
+
+    WebFrame* mainFrame = getMainFrame();
+    if (!mainFrame)
+        return;
+
+    mainFrame->unmarkText();
+}
+
+void TextInputController::hasMarkedText(const CppArgumentList&, CppVariant* result)
+{
+    result->setNull();
+
+    WebFrame* mainFrame = getMainFrame();
+    if (!mainFrame)
+        return;
+
+    result->set(mainFrame->hasMarkedText());
+}
+
+void TextInputController::conversationIdentifier(const CppArgumentList&, CppVariant* result)
+{
+    // FIXME: Implement this.
+    result->setNull();
+}
+
+void TextInputController::substringFromRange(const CppArgumentList&, CppVariant* result)
+{
+    // FIXME: Implement this.
+    result->setNull();
+}
+
+void TextInputController::attributedSubstringFromRange(const CppArgumentList&, CppVariant* result)
+{
+    // FIXME: Implement this.
+    result->setNull();
+}
+
+void TextInputController::markedRange(const CppArgumentList&, CppVariant* result)
+{
+    result->setNull();
+
+    WebFrame* mainFrame = getMainFrame();
+    if (!mainFrame)
+        return;
+
+    WebRange range = mainFrame->markedRange();
+    result->set(StringPrintf("%d,%d", range.startOffset(), range.endOffset()));
+}
+
+void TextInputController::selectedRange(const CppArgumentList&, CppVariant* result)
+{
+    result->setNull();
+
+    WebFrame* mainFrame = getMainFrame();
+    if (!mainFrame)
+        return;
+
+    WebRange range = mainFrame->selectionRange();
+    result->set(StringPrintf("%d,%d", range.startOffset(), range.endOffset()));
+}
+
+void TextInputController::firstRectForCharacterRange(const CppArgumentList&, CppVariant* result)
+{
+    // FIXME: Implement this.
+    result->setNull();
+}
+
+void TextInputController::characterIndexForPoint(const CppArgumentList&, CppVariant* result)
+{
+    // FIXME: Implement this.
+    result->setNull();
+}
+
+void TextInputController::validAttributesForMarkedText(const CppArgumentList&, CppVariant* result)
+{
+    result->setNull();
+
+    WebFrame* mainFrame = getMainFrame();
+    if (!mainFrame)
+        return;
+
+    result->set("NSUnderline,NSUnderlineColor,NSMarkedClauseSegment,"
+                "NSTextInputReplacementRangeAttributeName");
+}
+
+void TextInputController::makeAttributedString(const CppArgumentList&, CppVariant* result)
+{
+    // FIXME: Implement this.
+    result->setNull();
+}
diff --git a/WebKitTools/DumpRenderTree/chromium/TextInputController.h b/WebKitTools/DumpRenderTree/chromium/TextInputController.h
new file mode 100644
index 0000000..9896be5
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/chromium/TextInputController.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+// TextInputController is bound to window.textInputController in Javascript
+// when DRT is running. Layout tests use it to exercise various corners of
+// text input.
+
+#ifndef TextInputController_h
+#define TextInputController_h
+
+#include "CppBoundClass.h"
+
+class TestShell;
+
+namespace WebKit {
+class WebFrame;
+}
+
+class TextInputController : public CppBoundClass {
+public:
+    TextInputController(TestShell*);
+
+    void insertText(const CppArgumentList&, CppVariant*);
+    void doCommand(const CppArgumentList&, CppVariant*);
+    void setMarkedText(const CppArgumentList&, CppVariant*);
+    void unmarkText(const CppArgumentList&, CppVariant*);
+    void hasMarkedText(const CppArgumentList&, CppVariant*);
+    void conversationIdentifier(const CppArgumentList&, CppVariant*);
+    void substringFromRange(const CppArgumentList&, CppVariant*);
+    void attributedSubstringFromRange(const CppArgumentList&, CppVariant*);
+    void markedRange(const CppArgumentList&, CppVariant*);
+    void selectedRange(const CppArgumentList&, CppVariant*);
+    void firstRectForCharacterRange(const CppArgumentList&, CppVariant*);
+    void characterIndexForPoint(const CppArgumentList&, CppVariant*);
+    void validAttributesForMarkedText(const CppArgumentList&, CppVariant*);
+    void makeAttributedString(const CppArgumentList&, CppVariant*);
+
+private:
+    // Returns the test shell's main WebFrame.
+    static WebKit::WebFrame* getMainFrame();
+
+    // Non-owning pointer. The TextInputController is owned by the TestShell.
+    static TestShell* testShell;
+};
+
+#endif // TextInputController_h

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list