summaryrefslogtreecommitdiffstats
path: root/Tools/DumpRenderTree/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/DumpRenderTree/gtk')
-rw-r--r--Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp76
-rw-r--r--Tools/DumpRenderTree/gtk/DumpRenderTree.cpp33
-rw-r--r--Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp7
-rw-r--r--Tools/DumpRenderTree/gtk/PixelDumpSupportGtk.cpp14
-rw-r--r--Tools/DumpRenderTree/gtk/PlainTextController.cpp65
-rw-r--r--Tools/DumpRenderTree/gtk/PlainTextController.h37
-rw-r--r--Tools/DumpRenderTree/gtk/TextInputController.cpp1
7 files changed, 205 insertions, 28 deletions
diff --git a/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp b/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp
index ff76e4b..8a4a490 100644
--- a/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp
+++ b/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp
@@ -26,15 +26,14 @@
#include "config.h"
#include "AccessibilityUIElement.h"
+
#include "GOwnPtr.h"
#include "GRefPtr.h"
-
+#include "WebCoreSupport/DumpRenderTreeSupportGtk.h"
#include <JavaScriptCore/JSStringRef.h>
-#include <wtf/Assertions.h>
-
#include <atk/atk.h>
#include <gtk/gtk.h>
-
+#include <wtf/Assertions.h>
AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element)
: m_element(element)
@@ -488,16 +487,56 @@ int AccessibilityUIElement::indexInTable()
return 0;
}
+static JSStringRef indexRangeInTable(PlatformUIElement element, bool isRowRange)
+{
+ GOwnPtr<gchar> rangeString(g_strdup("{0, 0}"));
+
+ if (!element)
+ return JSStringCreateWithUTF8CString(rangeString.get());
+
+ ASSERT(ATK_IS_OBJECT(element));
+
+ AtkObject* axTable = atk_object_get_parent(ATK_OBJECT(element));
+ if (!axTable || !ATK_IS_TABLE(axTable))
+ return JSStringCreateWithUTF8CString(rangeString.get());
+
+ // Look for the cell in the table.
+ gint indexInParent = atk_object_get_index_in_parent(ATK_OBJECT(element));
+ if (indexInParent == -1)
+ return JSStringCreateWithUTF8CString(rangeString.get());
+
+ int row = -1;
+ int column = -1;
+ row = atk_table_get_row_at_index(ATK_TABLE(axTable), indexInParent);
+ column = atk_table_get_column_at_index(ATK_TABLE(axTable), indexInParent);
+
+ // Get the actual values, if row and columns are valid values.
+ if (row != -1 && column != -1) {
+ int base = 0;
+ int length = 0;
+ if (isRowRange) {
+ base = row;
+ length = atk_table_get_row_extent_at(ATK_TABLE(axTable), row, column);
+ } else {
+ base = column;
+ length = atk_table_get_column_extent_at(ATK_TABLE(axTable), row, column);
+ }
+ rangeString.set(g_strdup_printf("{%d, %d}", base, length));
+ }
+
+ return JSStringCreateWithUTF8CString(rangeString.get());
+}
+
JSStringRef AccessibilityUIElement::rowIndexRange()
{
- // FIXME: implement
- return JSStringCreateWithCharacters(0, 0);
+ // Range in table for rows.
+ return indexRangeInTable(m_element, true);
}
JSStringRef AccessibilityUIElement::columnIndexRange()
{
- // FIXME: implement
- return JSStringCreateWithCharacters(0, 0);
+ // Range in table for columns.
+ return indexRangeInTable(m_element, false);
}
int AccessibilityUIElement::lineForIndex(int)
@@ -532,8 +571,13 @@ bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned location
AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned column, unsigned row)
{
- // FIXME: implement
- return 0;
+ if (!m_element)
+ return 0;
+
+ ASSERT(ATK_IS_TABLE(m_element));
+
+ AtkObject* foundCell = atk_table_ref_at(ATK_TABLE(m_element), row, column);
+ return foundCell ? AccessibilityUIElement(foundCell) : 0;
}
JSStringRef AccessibilityUIElement::selectedTextRange()
@@ -572,12 +616,20 @@ bool AccessibilityUIElement::isAttributeSupported(JSStringRef attribute)
void AccessibilityUIElement::increment()
{
- // FIXME: implement
+ if (!m_element)
+ return;
+
+ ASSERT(ATK_IS_OBJECT(m_element));
+ DumpRenderTreeSupportGtk::incrementAccessibilityValue(ATK_OBJECT(m_element));
}
void AccessibilityUIElement::decrement()
{
- // FIXME: implement
+ if (!m_element)
+ return;
+
+ ASSERT(ATK_IS_OBJECT(m_element));
+ DumpRenderTreeSupportGtk::decrementAccessibilityValue(ATK_OBJECT(m_element));
}
void AccessibilityUIElement::press()
diff --git a/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp b/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp
index f768b43..a281e48 100644
--- a/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp
+++ b/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp
@@ -39,6 +39,7 @@
#include "GOwnPtr.h"
#include "LayoutTestController.h"
#include "PixelDumpSupport.h"
+#include "PlainTextController.h"
#include "TextInputController.h"
#include "WebCoreSupport/DumpRenderTreeSupportGtk.h"
#include "WorkQueue.h"
@@ -814,6 +815,13 @@ static void webViewOnloadEvent(WebKitWebView* view, WebKitWebFrame* frame, void*
}
}
+static void addControllerToWindow(JSContextRef context, JSObjectRef windowObject, const char* controllerName, JSValueRef controller)
+{
+ JSStringRef controllerNameStr = JSStringCreateWithUTF8CString(controllerName);
+ JSObjectSetProperty(context, windowObject, controllerNameStr, controller, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, 0);
+ JSStringRelease(controllerNameStr);
+}
+
static void webViewWindowObjectCleared(WebKitWebView* view, WebKitWebFrame* frame, JSGlobalContextRef context, JSObjectRef windowObject, gpointer data)
{
JSValueRef exception = 0;
@@ -828,15 +836,9 @@ static void webViewWindowObjectCleared(WebKitWebView* view, WebKitWebFrame* fram
axController->makeWindowObject(context, windowObject, &exception);
ASSERT(!exception);
- JSStringRef eventSenderStr = JSStringCreateWithUTF8CString("eventSender");
- JSValueRef eventSender = makeEventSender(context, !webkit_web_frame_get_parent(frame));
- JSObjectSetProperty(context, windowObject, eventSenderStr, eventSender, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, 0);
- JSStringRelease(eventSenderStr);
-
- JSStringRef textInputControllerStr = JSStringCreateWithUTF8CString("textInputController");
- JSValueRef textInputController = makeTextInputController(context);
- JSObjectSetProperty(context, windowObject, textInputControllerStr, textInputController, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, 0);
- JSStringRelease(textInputControllerStr);
+ addControllerToWindow(context, windowObject, "eventSender", makeEventSender(context, !webkit_web_frame_get_parent(frame)));
+ addControllerToWindow(context, windowObject, "plainText", makePlainTextController(context));
+ addControllerToWindow(context, windowObject, "textInputController", makeTextInputController(context));
}
static gboolean webViewConsoleMessage(WebKitWebView* view, const gchar* message, unsigned int line, const gchar* sourceId, gpointer data)
@@ -941,10 +943,8 @@ static void webViewStatusBarTextChanged(WebKitWebView* view, const gchar* messag
{
// Are we doing anything wrong? One test that does not call
// dumpStatusCallbacks gets true here
- if (gLayoutTestController->dumpStatusCallbacks()) {
- if (message && strcmp(message, ""))
- printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", message);
- }
+ if (gLayoutTestController->dumpStatusCallbacks())
+ printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", message);
}
static gboolean webViewClose(WebKitWebView* view)
@@ -1048,6 +1048,9 @@ static void frameCreatedCallback(WebKitWebView* webView, WebKitWebFrame* webFram
static void willSendRequestCallback(WebKitWebView* webView, WebKitWebFrame*, WebKitWebResource*, WebKitNetworkRequest* request, WebKitNetworkResponse*)
{
+ if (!done && gLayoutTestController->willSendRequestReturnsNull())
+ return;
+
SoupMessage* soupMessage = webkit_network_request_get_message(request);
SoupURI* uri = soup_uri_new(webkit_network_request_get_uri(request));
@@ -1058,8 +1061,8 @@ static void willSendRequestCallback(WebKitWebView* webView, WebKitWebFrame*, Web
soup_uri_free(uri);
return;
}
- soup_uri_free(uri);
-
+ if (uri)
+ soup_uri_free(uri);
if (soupMessage) {
const set<string>& clearHeaders = gLayoutTestController->willSendRequestClearHeaders();
diff --git a/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
index c26e2db..29742be 100644
--- a/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
+++ b/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
@@ -778,6 +778,8 @@ void LayoutTestController::overridePreference(JSStringRef key, JSStringRef value
propertyName = "enable-plugins";
else if (g_str_equal(originalName.get(), "WebKitHyperlinkAuditingEnabled"))
propertyName = "enable-hyperlink-auditing";
+ else if (g_str_equal(originalName.get(), "WebKitWebGLEnabled"))
+ propertyName = "enable-webgl";
else if (g_str_equal(originalName.get(), "WebKitTabToLinksPreferenceKey")) {
DumpRenderTreeSupportGtk::setLinksIncludedInFocusChain(!g_ascii_strcasecmp(valueAsString.get(), "true") || !g_ascii_strcasecmp(valueAsString.get(), "1"));
return;
@@ -917,6 +919,11 @@ void LayoutTestController::setEditingBehavior(const char* editingBehavior)
g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_UNIX, NULL);
}
+JSValueRef LayoutTestController::shadowRoot(JSContextRef context, JSValueRef element)
+{
+ return DumpRenderTreeSupportGtk::shadowRoot(context, element);
+}
+
void LayoutTestController::abortModal()
{
}
diff --git a/Tools/DumpRenderTree/gtk/PixelDumpSupportGtk.cpp b/Tools/DumpRenderTree/gtk/PixelDumpSupportGtk.cpp
index 1e591bb..2bd8fe2 100644
--- a/Tools/DumpRenderTree/gtk/PixelDumpSupportGtk.cpp
+++ b/Tools/DumpRenderTree/gtk/PixelDumpSupportGtk.cpp
@@ -32,9 +32,10 @@
#include "DumpRenderTree.h"
#include "GtkVersioning.h"
#include "PixelDumpSupportCairo.h"
+#include "WebCoreSupport/DumpRenderTreeSupportGtk.h"
#include <webkit/webkit.h>
-PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool, bool, bool, bool)
+PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool, bool, bool, bool drawSelectionRect)
{
WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
GtkWidget* viewContainer = gtk_widget_get_parent(GTK_WIDGET(view));
@@ -49,6 +50,7 @@ PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool, bool, bool, bool)
cairo_surface_t* imageSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t* context = cairo_create(imageSurface);
+
#ifdef GTK_API_VERSION_2
gdk_cairo_set_source_pixmap(context, pixmap, 0, 0);
cairo_paint(context);
@@ -57,5 +59,15 @@ PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool, bool, bool, bool)
gtk_widget_draw(viewContainer, context);
#endif
+ if (drawSelectionRect) {
+ GdkRectangle rectangle;
+ DumpRenderTreeSupportGtk::rectangleForSelection(mainFrame, &rectangle);
+
+ cairo_set_line_width(context, 1.0);
+ cairo_rectangle(context, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
+ cairo_set_source_rgba(context, 1.0, 0.0, 0.0, 1.0);
+ cairo_stroke(context);
+ }
+
return BitmapContext::createByAdoptingBitmapAndContext(0, context);
}
diff --git a/Tools/DumpRenderTree/gtk/PlainTextController.cpp b/Tools/DumpRenderTree/gtk/PlainTextController.cpp
new file mode 100644
index 0000000..25e251a
--- /dev/null
+++ b/Tools/DumpRenderTree/gtk/PlainTextController.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2011 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.
+ * 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 "config.h"
+#include "PlainTextController.h"
+
+#include "DumpRenderTree.h"
+#include "WebCoreSupport/DumpRenderTreeSupportGtk.h"
+#include <GOwnPtrGtk.h>
+#include <JavaScriptCore/JSObjectRef.h>
+#include <JavaScriptCore/JSRetainPtr.h>
+#include <JavaScriptCore/JSStringRef.h>
+#include <webkit/webkit.h>
+
+static JSValueRef plainTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ g_return_val_if_fail(argumentCount == 1, JSValueMakeUndefined(context));
+ WebKitDOMRange* kitRange = DumpRenderTreeSupportGtk::jsValueToDOMRange(context, arguments[0]);
+ g_return_val_if_fail(kitRange, JSValueMakeUndefined(context));
+
+ GOwnPtr<gchar> text(webkit_dom_range_get_text(kitRange));
+ JSRetainPtr<JSStringRef> jsText(Adopt, JSStringCreateWithUTF8CString(text.get()));
+ return JSValueMakeString(context, jsText.get());
+}
+
+JSObjectRef makePlainTextController(JSContextRef context)
+{
+ static JSStaticFunction staticFunctions[] = {
+ { "plainText", plainTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { 0, 0, 0 }
+ };
+
+ static JSClassRef plainTextControllerClass = 0;
+ if (!plainTextControllerClass) {
+ JSClassDefinition classDefinition = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ classDefinition.staticFunctions = staticFunctions;
+ plainTextControllerClass = JSClassCreate(&classDefinition);
+ }
+ return JSObjectMake(context, plainTextControllerClass, 0);
+}
diff --git a/Tools/DumpRenderTree/gtk/PlainTextController.h b/Tools/DumpRenderTree/gtk/PlainTextController.h
new file mode 100644
index 0000000..dadfc13
--- /dev/null
+++ b/Tools/DumpRenderTree/gtk/PlainTextController.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2011 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.
+ * 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 PlainTextController_h
+#define PlainTextController_h
+
+typedef const struct OpaqueJSContext* JSContextRef;
+typedef struct OpaqueJSValue* JSObjectRef;
+
+JSObjectRef makePlainTextController(JSContextRef);
+
+#endif
diff --git a/Tools/DumpRenderTree/gtk/TextInputController.cpp b/Tools/DumpRenderTree/gtk/TextInputController.cpp
index 7243fdc..d1aa33d 100644
--- a/Tools/DumpRenderTree/gtk/TextInputController.cpp
+++ b/Tools/DumpRenderTree/gtk/TextInputController.cpp
@@ -36,6 +36,7 @@
#include <JavaScriptCore/JSRetainPtr.h>
#include <JavaScriptCore/JSStringRef.h>
#include <cstring>
+#include <webkit/webkit.h>
static JSValueRef setMarkedTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{