[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
mrobinson at webkit.org
mrobinson at webkit.org
Wed Dec 22 11:39:14 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 0e00da8a91273a21c9ed80fccb414ae0ef6e3843
Author: mrobinson at webkit.org <mrobinson at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Aug 2 21:55:02 2010 +0000
2010-08-02 Martin Robinson <mrobinson at igalia.com>
Reviewed by Xan Lopez.
[GTK] Create a frame-created signal
https://bugs.webkit.org/show_bug.cgi?id=43284
Add a frame-created signal, which will allow developers to track
the beginning of a frame lifecycle and attach signal handlers to
all new frames.
* WebCoreSupport/FrameLoaderClientGtk.cpp:
(WebKit::FrameLoaderClient::createFrame): Emit the frame-created signal.
* tests/testwebframe.c: Add a test which verifies that the correct number of
frame-created signals is fired when a page with iframes loads.
(createFrameSignalTestFrameCreatedCallback): Added.
(createFrameSignalTestTimeout): Added.
(test_webkit_web_frame_created_signal): Added.
(main): Add a reference to the new test.
* webkit/webkitprivate.h: De-normalize webkit_web_frame_init_with_web_view into
the one place that it is used, so that the frame-created signal may be fired there.
* webkit/webkitwebframe.cpp: Remove webkit_web_frame_init_with_web_view.
* webkit/webkitwebview.cpp:
(webkit_web_view_class_init): Add the frame-created signal declaration.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64496 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index 0918b4e..cf7e706 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,28 @@
+2010-08-02 Martin Robinson <mrobinson at igalia.com>
+
+ Reviewed by Xan Lopez.
+
+ [GTK] Create a frame-created signal
+ https://bugs.webkit.org/show_bug.cgi?id=43284
+
+ Add a frame-created signal, which will allow developers to track
+ the beginning of a frame lifecycle and attach signal handlers to
+ all new frames.
+
+ * WebCoreSupport/FrameLoaderClientGtk.cpp:
+ (WebKit::FrameLoaderClient::createFrame): Emit the frame-created signal.
+ * tests/testwebframe.c: Add a test which verifies that the correct number of
+ frame-created signals is fired when a page with iframes loads.
+ (createFrameSignalTestFrameCreatedCallback): Added.
+ (createFrameSignalTestTimeout): Added.
+ (test_webkit_web_frame_created_signal): Added.
+ (main): Add a reference to the new test.
+ * webkit/webkitprivate.h: De-normalize webkit_web_frame_init_with_web_view into
+ the one place that it is used, so that the frame-created signal may be fired there.
+ * webkit/webkitwebframe.cpp: Remove webkit_web_frame_init_with_web_view.
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_class_init): Add the frame-created signal declaration.
+
2010-08-02 Mario Sanchez Prada <msanchez at igalia.com>
Reviewed by Chris Fleizach.
diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
index 340b789..98ac4a1 100644
--- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
@@ -5,6 +5,7 @@
* Copyright (C) 2008, 2009 Collabora Ltd. All rights reserved.
* Copyright (C) 2009, 2010 Gustavo Noronha Silva <gns at gnome.org>
* Copyright (C) Research In Motion Limited 2009. All rights reserved.
+ * Copyright (C) 2010 Igalia S.L.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -472,14 +473,20 @@ PassRefPtr<Widget> FrameLoaderClient::createPlugin(const IntSize& pluginSize, HT
PassRefPtr<Frame> FrameLoaderClient::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight)
{
- Frame* coreFrame = core(m_frame);
-
- ASSERT(core(getViewFromFrame(m_frame)) == coreFrame->page());
+ ASSERT(m_frame);
+ Frame* parentFrame = core(m_frame);
+ WebKitWebView* webView = getViewFromFrame(m_frame);
+ WebCore::Page* page = core(webView);
+ ASSERT(page == parentFrame->page());
- RefPtr<Frame> childFrame = webkit_web_frame_init_with_web_view(getViewFromFrame(m_frame), ownerElement);
+ WebKitWebFrame* kitFrame = WEBKIT_WEB_FRAME(g_object_new(WEBKIT_TYPE_WEB_FRAME, NULL));
+ WebKitWebFramePrivate* framePrivate = kitFrame->priv;
+ framePrivate->webView = webView;
- coreFrame->tree()->appendChild(childFrame);
+ RefPtr<Frame> childFrame = Frame::create(page, ownerElement, new FrameLoaderClient(kitFrame));
+ framePrivate->coreFrame = childFrame.get();
+ parentFrame->tree()->appendChild(childFrame);
childFrame->tree()->setName(name);
childFrame->init();
@@ -493,6 +500,7 @@ PassRefPtr<Frame> FrameLoaderClient::createFrame(const KURL& url, const String&
if (!childFrame->tree()->parent())
return 0;
+ g_signal_emit_by_name(webView, "frame-created", kitFrame);
return childFrame.release();
}
diff --git a/WebKit/gtk/tests/testwebframe.c b/WebKit/gtk/tests/testwebframe.c
index 620c9c9..59c7c2b 100644
--- a/WebKit/gtk/tests/testwebframe.c
+++ b/WebKit/gtk/tests/testwebframe.c
@@ -27,6 +27,50 @@
#if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0)
+static int numberOfFramesCreated = 0;
+
+static void createFrameSignalTestFrameCreatedCallback(WebKitWebView* webView, WebKitWebFrame* frame, gpointer data)
+{
+ numberOfFramesCreated++;
+}
+
+static gboolean createFrameSignalTestTimeout(gpointer data)
+{
+ g_assert_cmpint(numberOfFramesCreated, ==, 2);
+ g_main_loop_quit((GMainLoop*) data);
+ return FALSE;
+}
+
+static void test_webkit_web_frame_created_signal(void)
+{
+ GtkWidget* webView;
+ GtkWidget* window;
+ GMainLoop* loop = g_main_loop_new(NULL, TRUE);
+
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+
+ webView = webkit_web_view_new();
+ g_signal_connect(webView, "frame-created", G_CALLBACK(createFrameSignalTestFrameCreatedCallback), loop);
+
+ // We want to ensure that exactly two create-frame signals are
+ // fired and no more, so we set a timeout here. There does not appear
+ // to be a simple way via the API to figure out when all frames have
+ // loaded.
+ g_timeout_add(500, createFrameSignalTestTimeout, loop);
+
+ gtk_container_add(GTK_CONTAINER(window), webView);
+ gtk_widget_show(window);
+ gtk_widget_show(webView);
+
+ webkit_web_view_load_string(WEBKIT_WEB_VIEW(webView),
+ "<html><body>Frames!"
+ "<iframe></iframe>"
+ "<iframe></iframe>"
+ "</body></html>",
+ "text/html", "utf-8", "file://");
+ g_main_loop_run(loop);
+}
+
static void test_webkit_web_frame_create_destroy(void)
{
GtkWidget *webView;
@@ -170,6 +214,7 @@ int main(int argc, char** argv)
g_test_bug_base("https://bugs.webkit.org/");
g_test_add_func("/webkit/webview/create_destroy", test_webkit_web_frame_create_destroy);
+ g_test_add_func("/webkit/webview/frame-created_signal", test_webkit_web_frame_created_signal);
g_test_add_func("/webkit/webframe/lifetime", test_webkit_web_frame_lifetime);
g_test_add_func("/webkit/webview/printing", test_webkit_web_frame_printing);
g_test_add_func("/webkit/webview/response", test_webkit_web_frame_response);
diff --git a/WebKit/gtk/webkit/webkitprivate.h b/WebKit/gtk/webkit/webkitprivate.h
index 73f9fcc..3ce77e6 100644
--- a/WebKit/gtk/webkit/webkitprivate.h
+++ b/WebKit/gtk/webkit/webkitprivate.h
@@ -196,9 +196,6 @@ extern "C" {
gboolean disposed;
};
- PassRefPtr<WebCore::Frame>
- webkit_web_frame_init_with_web_view(WebKitWebView*, WebCore::HTMLFrameOwnerElement*);
-
void
webkit_web_frame_core_frame_gone(WebKitWebFrame*);
diff --git a/WebKit/gtk/webkit/webkitwebframe.cpp b/WebKit/gtk/webkit/webkitwebframe.cpp
index 344f94e..5e82d57 100644
--- a/WebKit/gtk/webkit/webkitwebframe.cpp
+++ b/WebKit/gtk/webkit/webkitwebframe.cpp
@@ -408,21 +408,6 @@ WebKitWebFrame* webkit_web_frame_new(WebKitWebView* webView)
return frame;
}
-PassRefPtr<Frame> webkit_web_frame_init_with_web_view(WebKitWebView* webView, HTMLFrameOwnerElement* element)
-{
- WebKitWebFrame* frame = WEBKIT_WEB_FRAME(g_object_new(WEBKIT_TYPE_WEB_FRAME, NULL));
- WebKitWebFramePrivate* priv = frame->priv;
- WebKitWebViewPrivate* viewPriv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
-
- priv->webView = webView;
- WebKit::FrameLoaderClient* client = new WebKit::FrameLoaderClient(frame);
-
- RefPtr<Frame> coreFrame = Frame::create(viewPriv->corePage, element, client);
- priv->coreFrame = coreFrame.get();
-
- return coreFrame.release();
-}
-
/**
* webkit_web_frame_get_title:
* @frame: a #WebKitWebFrame
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index cde9148..8747d42 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -172,6 +172,7 @@ enum {
GEOLOCATION_POLICY_DECISION_REQUESTED,
GEOLOCATION_POLICY_DECISION_CANCELLED,
ONLOAD_EVENT,
+ FRAME_CREATED,
LAST_SIGNAL
};
@@ -2447,6 +2448,26 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
G_TYPE_NONE, 1,
WEBKIT_TYPE_WEB_FRAME);
+ /*
+ * WebKitWebView::frame-created
+ * @web_view: the object which received the signal
+ * @web_frame: the #WebKitWebFrame which was just created.
+ *
+ * Emitted when a WebKitWebView has created a new frame. This signal will
+ * be emitted for all sub-frames created during page load. It will not be
+ * emitted for the main frame, which originates in the WebKitWebView constructor
+ * and may be accessed at any time using webkit_web_view_get_main_frame.
+ *
+ * Since: 1.3.4
+ */
+ webkit_web_view_signals[FRAME_CREATED] = g_signal_new("frame-created",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ WEBKIT_TYPE_WEB_FRAME);
/*
* implementations of virtual methods
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list