2007-12-04 Xan Lopez <xan@gnome.org>
authoralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Dec 2007 12:16:38 +0000 (12:16 +0000)
committeralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Dec 2007 12:16:38 +0000 (12:16 +0000)
        Reviewed by Alp Toker.

        http://bugs.webkit.org/show_bug.cgi?id=15561
        GTK port needs DumpRenderTree implementation

        Start work on the GTK+ DRT.

        This does not work yet, and there are a few lingering style issues
        (nothing major) but this patch has been stuck in the bug tracker for
        too long already.

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

13 files changed:
ChangeLog
WebKit.pro
WebKit/gtk/ChangeLog
WebKit/gtk/WebView/webkitprivate.h
WebKit/gtk/WebView/webkitwebframe.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/DumpRenderTree.h
WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp [new file with mode: 0644]
WebKitTools/DumpRenderTree/gtk/DumpRenderTree.pro [new file with mode: 0644]
WebKitTools/DumpRenderTree/gtk/DumpRenderTreeGtk.h [new file with mode: 0644]
WebKitTools/DumpRenderTree/gtk/GCControllerGtk.cpp [new file with mode: 0644]
WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp [new file with mode: 0644]
WebKitTools/DumpRenderTree/gtk/WorkQueueItemGtk.cpp [new file with mode: 0644]

index 4655cba..77bc004 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-12-04  Xan Lopez  <xan@gnome.org>
+
+        Reviewed by Alp Toker.
+
+        http://bugs.webkit.org/show_bug.cgi?id=15561
+        GTK port needs DumpRenderTree implementation
+
+        Start work on the GTK+ DRT.
+
+        * WebKit.pro:
+
 2007-11-30  Alp Toker  <alp@atoker.com>
 
         Reviewed by Adam Roben.
index c036e25..882ee77 100644 (file)
@@ -14,4 +14,5 @@ qt-port {
 }
 
 gtk-port:SUBDIRS += \
-        WebKitTools/GtkLauncher
+        WebKitTools/GtkLauncher \
+        WebKitTools/DumpRenderTree/gtk/DumpRenderTree.pro
index 6e7d83b..21819d5 100644 (file)
@@ -1,3 +1,18 @@
+2007-12-04  Xan Lopez  <xan@gnome.org>
+
+        Reviewed by Alp Toker.
+
+        http://bugs.webkit.org/show_bug.cgi?id=15561
+        GTK port needs DumpRenderTree implementation
+
+        Start work on the GTK+ DRT.
+
+        Add a couple of proposed new API entry points. They are currently for
+        internal use only by DRT and not in the public headers.
+
+        * WebView/webkitprivate.h:
+        * WebView/webkitwebframe.cpp:
+
 2007-12-03  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Dave Hyatt.
index 7293930..58a4fe1 100644 (file)
@@ -35,6 +35,7 @@
  * They are using WebCore which musn't be exposed to the outer world.
  */
 
+#include "webkitdefines.h"
 #include "webkitsettings.h"
 #include "webkitwebview.h"
 #include "webkitwebframe.h"
@@ -91,6 +92,16 @@ extern "C" {
     };
 
     WebKitWebFrame* webkit_web_frame_init_with_web_view(WebKitWebView*, WebCore::HTMLFrameOwnerElement*);
+
+
+    // TODO: Move these to webkitwebframe.h once these functions are fully
+    // implemented and their API has been discussed.
+
+    WEBKIT_API GSList*
+    webkit_web_frame_get_children (WebKitWebFrame* frame);
+
+    WEBKIT_API gchar*
+    webkit_web_frame_get_inner_text (WebKitWebFrame* frame);
 }
 
 #endif
index 3ef7635..ada5d4f 100644 (file)
@@ -385,4 +385,48 @@ JSGlobalContextRef webkit_web_frame_get_global_context(WebKitWebFrame* frame)
     return toGlobalRef(coreFrame->scriptProxy()->globalObject()->globalExec());
 }
 
+/**
+ * webkit_web_frame_get_children:
+ * @frame: a #WebKitWebFrame
+ *
+ * Return value: child frames of @frame
+ */
+GSList* webkit_web_frame_get_children(WebKitWebFrame* frame)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL);
+
+    GSList* children = NULL;
+    Frame* coreFrame = core(frame);
+
+    for (Frame* child = coreFrame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
+        FrameLoader* loader = child->loader();
+        WebKit::FrameLoaderClient* client = static_cast<WebKit::FrameLoaderClient*>(loader->client());
+        if (client)
+          children = g_slist_append(children, client->webFrame());
+    }
+
+    return children;
+}
+
+/**
+ * webkit_web_frame_get_inner_text:
+ * @frame: a #WebKitWebFrame
+ *
+ * Return value: inner text of @frame
+ */
+gchar* webkit_web_frame_get_inner_text(WebKitWebFrame* frame)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL);
+
+    Frame* coreFrame = core(frame);
+    FrameView* view = coreFrame->view();
+
+    if (view->layoutPending())
+        view->layout();
+
+    Element* documentElement = coreFrame->document()->documentElement();
+    String string =  documentElement->innerText();
+    return g_strdup(string.utf8().data());
+}
+
 }
index 92133a8..f0e221c 100644 (file)
@@ -1,3 +1,68 @@
+2007-12-04  Xan Lopez  <xan@gnome.org>
+
+        Reviewed by Alp Toker.
+
+        http://bugs.webkit.org/show_bug.cgi?id=15561
+        GTK port needs DumpRenderTree implementation
+
+        Start work on the GTK+ DRT.
+
+        This does not work yet, and there are a few lingering style issues
+        (nothing major) but this patch has been stuck in the bug tracker for
+        too long already.
+
+        * DumpRenderTree/DumpRenderTree.h:
+        * DumpRenderTree/gtk: Added.
+        * DumpRenderTree/gtk/DumpRenderTree.cpp: Added.
+        (autocorrectURL):
+        (shouldLogFrameLoadDelegates):
+        (dumpFrameScrollPosition):
+        (displayWebView):
+        (appendString):
+        (dumpFramesAsText):
+        (dumpRenderTreeAsText):
+        (dump):
+        (runTest):
+        (main):
+        * DumpRenderTree/gtk/DumpRenderTree.pro: Added.
+        * DumpRenderTree/gtk/DumpRenderTreeGtk.h: Added.
+        * DumpRenderTree/gtk/GCControllerGtk.cpp: Added.
+        (GCController::collect):
+        (GCController::collectOnAlternateThread):
+        (GCController::getJSObjectCount):
+        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp: Added.
+        (LayoutTestController::~LayoutTestController):
+        (LayoutTestController::addDisallowedURL):
+        (LayoutTestController::clearBackForwardList):
+        (LayoutTestController::copyDecodedHostName):
+        (LayoutTestController::copyEncodedHostName):
+        (LayoutTestController::display):
+        (LayoutTestController::keepWebHistory):
+        (LayoutTestController::notifyDone):
+        (LayoutTestController::queueBackNavigation):
+        (LayoutTestController::queueForwardNavigation):
+        (LayoutTestController::queueLoad):
+        (LayoutTestController::queueReload):
+        (LayoutTestController::queueScript):
+        (LayoutTestController::setAcceptsEditing):
+        (LayoutTestController::setCustomPolicyDelegate):
+        (LayoutTestController::setMainFrameIsFirstResponder):
+        (LayoutTestController::setTabKeyCyclesThroughElements):
+        (LayoutTestController::setUseDashboardCompatibilityMode):
+        (LayoutTestController::setUserStyleSheetEnabled):
+        (LayoutTestController::setUserStyleSheetLocation):
+        (LayoutTestController::setWindowIsKey):
+        (LayoutTestController::setWaitToDump):
+        (LayoutTestController::windowCount):
+        (LayoutTestController::setPrivateBrowsingEnabled):
+        (LayoutTestController::setAuthorAndUserStylesEnabled):
+        * DumpRenderTree/gtk/WorkQueueItemGtk.cpp: Added.
+        (JSStringCopyUTF8CString):
+        (LoadItem::invoke):
+        (ReloadItem::invoke):
+        (ScriptItem::invoke):
+        (BackForwardItem::invoke):
+
 2007-12-03  Sam Weinig  <sam@webkit.org>
 
         Move JavaScriptCore thread testing code to pthread specific directory
index 6968398..174da27 100644 (file)
 
 #if PLATFORM(MAC)
 #include "DumpRenderTreeMac.h"
-#else if PLATFORM(WIN)
+#elif PLATFORM(WIN)
 #include "DumpRenderTreeWin.h"
+#elif PLATFORM(GTK)
+#include "DumpRenderTreeGtk.h"
 #endif
 
+#if PLATFORM(CF)
 #include <CoreFoundation/CoreFoundation.h>
+extern CFRunLoopTimerRef waitToDumpWatchdog;
+#endif
 
 class LayoutTestController;
 
 extern volatile bool done;
 
-extern CFRunLoopTimerRef waitToDumpWatchdog;
-
 // FIXME: This is a bad abstraction.  We should insted pass this to other controller objects which need access to it.
 extern LayoutTestController* layoutTestController;
 
diff --git a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp
new file mode 100644 (file)
index 0000000..71e89c2
--- /dev/null
@@ -0,0 +1,265 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT falseT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN false EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT falseT 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 "webkitwebframe.h"
+#include "webkitwebview.h"
+
+#include <gtk/gtk.h>
+
+#include <string.h>
+
+#include <JavaScriptCore/JSBase.h>
+#include <JavaScriptCore/JSContextRef.h>
+#include <JavaScriptCore/JSStringRef.h>
+#include <JavaScriptCore/JSObjectRef.h>
+#include <JavaScriptCore/JSValueRef.h>
+
+#include "LayoutTestController.h"
+#include "WorkQueue.h"
+#include "WorkQueueItem.h"
+
+#include <getopt.h>
+#include <stdlib.h>
+
+extern "C" {
+// This API is not yet public.
+extern GSList* webkit_web_frame_get_children(WebKitWebFrame* frame);
+extern gchar* webkit_web_frame_get_inner_text(WebKitWebFrame* frame);
+}
+
+volatile bool done;
+static bool printSeparators;
+static int testRepaintDefault;
+static int repaintSweepHorizontallyDefault;
+static int dumpPixels;
+static int dumpTree;
+static gchar* currentTest;
+
+LayoutTestController* layoutTestController = 0;
+static WebKitWebView* view;
+WebKitWebFrame* mainFrame = 0;
+
+const unsigned maxViewHeight = 600;
+const unsigned maxViewWidth = 800;
+
+static gchar* autocorrectURL(const gchar* url)
+{
+    if (strncmp("http://", url, 7) != 0 && strncmp("https://", url, 8) != 0) {
+        GString* string = g_string_new("file://");
+        g_string_append(string, url);
+        return g_string_free(string, FALSE);
+    }
+
+    return g_strdup(url);
+}
+
+static bool shouldLogFrameLoadDelegates(const char* pathOrURL)
+{
+    return strstr(pathOrURL, "loading/");
+}
+
+void dumpFrameScrollPosition(WebKitWebFrame* frame)
+{
+
+}
+
+void displayWebView()
+{
+
+}
+
+static void appendString(gchar*& target, gchar* string)
+{
+    gchar* oldString = target;
+    target = g_strconcat(target, string, NULL);
+    g_free(oldString);
+}
+
+static gchar* dumpFramesAsText(WebKitWebFrame* frame)
+{
+    gchar* result = 0;
+
+    // Add header for all but the main frame.
+    bool isMainFrame = (webkit_web_view_get_main_frame(view) == frame);
+
+    if (isMainFrame) {
+        const gchar* frameName = webkit_web_frame_get_name(frame);
+        gchar* innerText = webkit_web_frame_get_inner_text(frame);
+
+        result = g_strdup_printf("\n--------\nFrame: '%s'\n--------\n%s", frameName, innerText);
+
+        g_free(innerText);
+    }
+
+    if (layoutTestController->dumpChildFramesAsText()) {
+        GSList* children = webkit_web_frame_get_children(frame);
+        for (;children; children = g_slist_next(children))
+           appendString(result, dumpFramesAsText((WebKitWebFrame*)children->data));
+    }
+
+    return result;
+}
+
+static gchar* dumpRenderTreeAsText(WebKitWebFrame* frame)
+{
+    // FIXME: this will require new WebKitGtk SPI
+    return strdup("foo");
+}
+
+void dump()
+{
+    if (dumpTree) {
+        char* result = 0;
+
+        bool dumpAsText = layoutTestController->dumpAsText();
+        // FIXME: Also dump text resuls as text.
+        layoutTestController->setDumpAsText(dumpAsText);
+        if (layoutTestController->dumpAsText())
+            result = dumpFramesAsText(mainFrame);
+        else {
+            bool isSVGW3CTest = (g_strrstr(currentTest, "svg/W3C-SVG-1.1"));
+            if (isSVGW3CTest)
+                gtk_widget_set_size_request(GTK_WIDGET(view), 480, 360);
+            else
+                gtk_widget_set_size_request(GTK_WIDGET(view), maxViewWidth, maxViewHeight);
+            result = dumpRenderTreeAsText(mainFrame);
+        }
+
+        if (!result) {
+            const char* errorMessage;
+            if (layoutTestController->dumpAsText())
+                errorMessage = "[documentElement innerText]";
+            else if (layoutTestController->dumpDOMAsWebArchive())
+                errorMessage = "[[mainFrame DOMDocument] webArchive]";
+            else if (layoutTestController->dumpSourceAsWebArchive())
+                errorMessage = "[[mainFrame dataSource] webArchive]";
+            else
+                errorMessage = "[mainFrame renderTreeAsExternalRepresentation]";
+            printf("ERROR: nil result from %s", errorMessage);
+        } else {
+            printf("%s", result);
+        g_free(result);
+            if (!layoutTestController->dumpAsText() && !layoutTestController->dumpDOMAsWebArchive() && !layoutTestController->dumpSourceAsWebArchive())
+                dumpFrameScrollPosition(mainFrame);
+        }
+
+        if (layoutTestController->dumpBackForwardList()) {
+            // FIXME: not implemented
+        }
+
+        if (printSeparators)
+            puts("#EOF");
+    }
+
+    if (dumpPixels) {
+        if (!layoutTestController->dumpAsText() && !layoutTestController->dumpDOMAsWebArchive() && !layoutTestController->dumpSourceAsWebArchive()) {
+            // FIXME: Add support for dumping pixels
+        }
+    }
+
+    fflush(stdout);
+
+    // FIXME: call displayWebView here when we support --paint
+
+    done = true;
+}
+
+static void runTest(const char* pathOrURL)
+{
+    gchar* url = autocorrectURL(pathOrURL);
+
+    layoutTestController = new LayoutTestController(testRepaintDefault, repaintSweepHorizontallyDefault);
+
+    done = false;
+
+    if (shouldLogFrameLoadDelegates(pathOrURL))
+        layoutTestController->setDumpFrameLoadCallbacks(true);
+
+    if (currentTest)
+        g_free(currentTest);
+    currentTest = url;
+
+    WorkQueue::shared()->clear();
+    WorkQueue::shared()->setFrozen(false);
+
+    webkit_web_view_open(view, url);
+
+    while (!done)
+        g_main_context_iteration(NULL, true);
+
+    WorkQueue::shared()->clear();
+
+    delete layoutTestController;
+    layoutTestController = 0;
+}
+
+int main(int argc, char* argv[])
+{
+
+    struct option options[] = {
+        {"horizontal-sweep", no_argument, &repaintSweepHorizontallyDefault, true},
+        {"notree", no_argument, &dumpTree, false},
+        {"pixel-tests", no_argument, &dumpPixels, true},
+        {"repaint", no_argument, &testRepaintDefault, true},
+        {"tree", no_argument, &dumpTree, true},
+        {NULL, 0, NULL, 0}
+    };
+
+    int option;
+    while ((option = getopt_long(argc, (char* const*)argv, "", options, NULL)) != -1)
+        switch (option) {
+            case '?':   // unknown or ambiguous option
+            case ':':   // missing argument
+                exit(1);
+                break;
+        }
+
+    view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+    mainFrame = webkit_web_view_get_main_frame(view);
+
+    if (argc == optind+1 && strcmp(argv[optind], "-") == 0) {
+        char filenameBuffer[2048];
+        printSeparators = true;
+        while (fgets(filenameBuffer, sizeof(filenameBuffer), stdin)) {
+            char* newLineCharacter = strchr(filenameBuffer, '\n');
+            if (newLineCharacter)
+                *newLineCharacter = '\0';
+
+            if (strlen(filenameBuffer) == 0)
+                continue;
+
+            runTest(filenameBuffer);
+        }
+    } else {
+        printSeparators = (optind < argc-1 || (dumpPixels && dumpTree));
+        for (int i = optind; i != argc; ++i)
+            runTest(argv[i]);
+    }
+
+    return 0;
+}
diff --git a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.pro b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.pro
new file mode 100644 (file)
index 0000000..51fdd65
--- /dev/null
@@ -0,0 +1,19 @@
+TEMPLATE = app
+SOURCES += DumpRenderTree.cpp \
+           ../LayoutTestController.cpp \
+           ../GCController.cpp \
+           ../WorkQueue.cpp \
+           GCControllerGtk.cpp \
+           LayoutTestControllerGtk.cpp \
+           WorkQueueItemGtk.cpp
+
+CONFIG -= app_bundle
+
+BASE_DIR = $$PWD/../../..
+
+include(../../../WebKit.pri)
+
+INCLUDEPATH += \
+    $$BASE_DIR/WebKitTools/DumpRenderTree
+
+QMAKE_RPATHDIR += $$OUTPUT_DIR/lib
diff --git a/WebKitTools/DumpRenderTree/gtk/DumpRenderTreeGtk.h b/WebKitTools/DumpRenderTree/gtk/DumpRenderTreeGtk.h
new file mode 100644 (file)
index 0000000..fb690e3
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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 DumpRenderTreeGtk_h
+#define DumpRenderTreeGtk_h
+
+#include "webkitdefines.h"
+
+extern WebKitWebFrame* mainFrame;
+
+#endif // DumpRenderTreeGtk_h 
diff --git a/WebKitTools/DumpRenderTree/gtk/GCControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/GCControllerGtk.cpp
new file mode 100644 (file)
index 0000000..07fc314
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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 "GCController.h"
+
+void GCController::collect() const
+{
+}
+
+void GCController::collectOnAlternateThread(bool waitUntilDone) const
+{
+}
+
+size_t GCController::getJSObjectCount() const
+{
+    return 0;
+}
diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
new file mode 100644 (file)
index 0000000..24636bf
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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 "LayoutTestController.h"
+
+#include "DumpRenderTree.h"
+#include "WorkQueue.h"
+#include "WorkQueueItem.h"
+#include <JavaScriptCore/JSRetainPtr.h>
+#include <JavaScriptCore/JSStringRef.h>
+
+LayoutTestController::~LayoutTestController()
+{
+    // FIXME: implement
+}
+
+void LayoutTestController::addDisallowedURL(JSStringRef url)
+{
+    // FIXME: implement
+}
+
+void LayoutTestController::clearBackForwardList()
+{
+    // FIXME: implement
+}
+
+JSStringRef LayoutTestController::copyDecodedHostName(JSStringRef name)
+{
+    // FIXME: implement
+    return 0;
+}
+
+JSStringRef LayoutTestController::copyEncodedHostName(JSStringRef name)
+{
+    // FIXME: implement
+    return 0;
+}
+
+void LayoutTestController::display()
+{
+    displayWebView();
+}
+
+void LayoutTestController::keepWebHistory()
+{
+    // FIXME: implement
+}
+
+void LayoutTestController::notifyDone()
+{
+    // FIXME: The frame might not be finished loading yet
+    if (m_waitToDump && !WorkQueue::shared()->count())
+        dump();
+    m_waitToDump = false;
+}
+
+void LayoutTestController::queueBackNavigation(int howFarBack)
+{
+    WorkQueue::shared()->queue(new BackItem(howFarBack));
+}
+
+void LayoutTestController::queueForwardNavigation(int howFarForward)
+{
+    WorkQueue::shared()->queue(new ForwardItem(howFarForward));
+}
+
+void LayoutTestController::queueLoad(JSStringRef url, JSStringRef target)
+{
+    // FIXME: We need to resolve relative URLs here
+    WorkQueue::shared()->queue(new LoadItem(url, target));
+}
+
+void LayoutTestController::queueReload()
+{
+    WorkQueue::shared()->queue(new ReloadItem);
+}
+
+void LayoutTestController::queueScript(JSStringRef script)
+{
+    WorkQueue::shared()->queue(new ScriptItem(script));
+}
+
+void LayoutTestController::setAcceptsEditing(bool newAcceptsEditing)
+{
+    // FIXME: implement
+}
+
+void LayoutTestController::setCustomPolicyDelegate(bool setDelegate)
+{
+    // FIXME: implement
+}
+
+void LayoutTestController::setMainFrameIsFirstResponder(bool flag)
+{
+    // FIXME: implement
+}
+
+void LayoutTestController::setTabKeyCyclesThroughElements(bool cycles)
+{
+    // FIXME: implement
+}
+
+void LayoutTestController::setUseDashboardCompatibilityMode(bool flag)
+{
+    // FIXME: implement
+}
+
+void LayoutTestController::setUserStyleSheetEnabled(bool flag)
+{
+    // FIXME: implement
+}
+
+void LayoutTestController::setUserStyleSheetLocation(JSStringRef path)
+{
+    // FIXME: implement
+}
+
+void LayoutTestController::setWindowIsKey(bool windowIsKey)
+{
+    // FIXME: implement
+}
+
+void LayoutTestController::setWaitToDump(bool waitUntilDone)
+{
+    m_waitToDump = waitUntilDone;
+    // FIXME: Should have some sort of watchdog timer here
+}
+
+int LayoutTestController::windowCount()
+{
+    // FIXME: implement
+    return 0;
+}
+
+void LayoutTestController::setPrivateBrowsingEnabled(bool privateBrowsingEnabled)
+{
+    // FIXME: implement
+}
+
+void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
+{
+    // FIXME: implement
+}
+
diff --git a/WebKitTools/DumpRenderTree/gtk/WorkQueueItemGtk.cpp b/WebKitTools/DumpRenderTree/gtk/WorkQueueItemGtk.cpp
new file mode 100644 (file)
index 0000000..e81b610
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ *
+ * 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.
+ */
+
+#include "WorkQueueItem.h"
+
+#include "webkitnetworkrequest.h"
+#include "webkitwebframe.h"
+#include "webkitwebview.h"
+
+#include "DumpRenderTree.h"
+#include <JavaScriptCore/JSStringRef.h>
+
+// Returns a newly allocated UTF-8 character buffer which must be freed with g_free()
+static gchar* JSStringCopyUTF8CString(JSStringRef jsString)
+{
+    size_t dataSize = JSStringGetMaximumUTF8CStringSize(jsString);
+    gchar* utf8 = (gchar*)g_malloc(dataSize);
+    JSStringGetUTF8CString(jsString, utf8, dataSize);
+
+    return utf8;
+}
+
+void LoadItem::invoke() const
+{
+    gchar* targetString = JSStringCopyUTF8CString(target());
+
+    WebKitWebFrame* targetFrame;
+    if (!strlen(targetString))
+        targetFrame = mainFrame;
+    else
+        targetFrame = webkit_web_frame_find_frame(mainFrame, targetString);
+    g_free(targetString);
+
+    gchar* urlString = JSStringCopyUTF8CString(url());
+    WebKitNetworkRequest* request = webkit_network_request_new(urlString);
+    g_free(urlString);
+    webkit_web_frame_load_request(targetFrame, request);
+    g_object_unref(request);
+}
+
+void ReloadItem::invoke() const
+{
+    // TODO: Why not just reload the frame?
+    WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
+    webkit_web_view_reload(webView);
+}
+
+void ScriptItem::invoke() const
+{
+    WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
+    gchar* scriptString = JSStringCopyUTF8CString(script());
+    // TODO: does this return something we need to free? If not, why not?
+    webkit_web_view_execute_script(webView, scriptString);
+    g_free(scriptString);
+}
+
+void BackForwardItem::invoke() const
+{
+    WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
+    if (m_howFar == 1)
+        webkit_web_view_go_forward(webView);
+    else if (m_howFar == -1)
+        webkit_web_view_go_backward(webView);
+    else {
+        g_warning("Can't go backward/forward\n");
+        //notImplemented();
+        // TODO: API doesn't yet support arbitrary back/forward
+    }
+}