summaryrefslogtreecommitdiffstats
path: root/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-06 11:45:16 +0100
committerSteve Block <steveblock@google.com>2011-05-12 13:44:10 +0100
commitcad810f21b803229eb11403f9209855525a25d57 (patch)
tree29a6fd0279be608e0fe9ffe9841f722f0f4e4269 /WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
parent121b0cf4517156d0ac5111caf9830c51b69bae8f (diff)
downloadexternal_webkit-cad810f21b803229eb11403f9209855525a25d57.zip
external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.gz
external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.bz2
Merge WebKit at r75315: Initial merge by git.
Change-Id: I570314b346ce101c935ed22a626b48c2af266b84
Diffstat (limited to 'WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp')
-rw-r--r--WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp39
1 files changed, 29 insertions, 10 deletions
diff --git a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
index 12f4f14..7f39d37 100644
--- a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
@@ -48,13 +48,14 @@
#include "SecurityOrigin.h"
#include "WindowFeatures.h"
#include "webkitgeolocationpolicydecision.h"
+#include "webkitgeolocationpolicydecisionprivate.h"
#include "webkitnetworkrequest.h"
-#include "webkitprivate.h"
#include "webkitsecurityoriginprivate.h"
#include "webkitviewportattributesprivate.h"
#include "webkitwebframeprivate.h"
#include "webkitwebview.h"
#include "webkitwebviewprivate.h"
+#include "webkitwebwindowfeaturesprivate.h"
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
@@ -70,6 +71,7 @@ namespace WebKit {
ChromeClient::ChromeClient(WebKitWebView* webView)
: m_webView(webView)
+ , m_closeSoonTimer(0)
{
ASSERT(m_webView);
}
@@ -155,9 +157,8 @@ Page* ChromeClient::createWindow(Frame* frame, const FrameLoadRequest& frameLoad
if (!webView)
return 0;
- WebKitWebWindowFeatures* webWindowFeatures = webkit_web_window_features_new_from_core_features(coreFeatures);
- g_object_set(webView, "window-features", webWindowFeatures, NULL);
- g_object_unref(webWindowFeatures);
+ GRefPtr<WebKitWebWindowFeatures> webWindowFeatures(adoptGRef(kitNew(coreFeatures)));
+ g_object_set(webView, "window-features", webWindowFeatures.get(), NULL);
if (!frameLoadRequest.isEmpty())
webkit_web_view_open(webView, frameLoadRequest.resourceRequest().url().string().utf8().data());
@@ -249,19 +250,37 @@ void ChromeClient::setResizable(bool)
// Ignored for now
}
+static gboolean emitCloseWebViewSignalLater(WebKitWebView* view)
+{
+ gboolean isHandled;
+ g_signal_emit_by_name(view, "close-web-view", &isHandled);
+ return FALSE;
+}
+
void ChromeClient::closeWindowSoon()
{
// We may not have a WebView as create-web-view can return NULL.
if (!m_webView)
return;
+ if (m_closeSoonTimer) // Don't call close-web-view more than once.
+ return;
- webkit_web_view_stop_loading(m_webView);
+ // We need to remove the parent WebView from WebViewSets here, before it actually
+ // closes, to make sure that JavaScript code that executes before it closes
+ // can't find it. Otherwise, window.open will select a closed WebView instead of
+ // opening a new one <rdar://problem/3572585>.
+ m_webView->priv->corePage->setGroupName("");
- gboolean isHandled = false;
- g_signal_emit_by_name(m_webView, "close-web-view", &isHandled);
+ // We also need to stop the load to prevent further parsing or JavaScript execution
+ // after the window has torn down <rdar://problem/4161660>.
+ webkit_web_view_stop_loading(m_webView);
- if (isHandled)
- return;
+ // Clients commonly destroy the web view during the close-web-view signal, but our caller
+ // may need to send more signals to the web view. For instance, if this happened in the
+ // onload handler, it will need to call FrameLoaderClient::dispatchDidHandleOnloadEvents.
+ // Instead of firing the close-web-view signal now, fire it after the caller finishes.
+ // This seems to match the Mac/Windows port behavior.
+ m_closeSoonTimer = g_timeout_add(0, reinterpret_cast<GSourceFunc>(emitCloseWebViewSignalLater), m_webView);
}
bool ChromeClient::canTakeFocus(FocusDirection)
@@ -638,7 +657,7 @@ void ChromeClient::requestGeolocationPermissionForFrame(Frame* frame, Geolocatio
WebKitWebFrame* webFrame = kit(frame);
WebKitWebView* webView = getViewFromFrame(webFrame);
- PlatformRefPtr<WebKitGeolocationPolicyDecision> policyDecision(adoptPlatformRef(webkit_geolocation_policy_decision_new(webFrame, geolocation)));
+ GRefPtr<WebKitGeolocationPolicyDecision> policyDecision(adoptGRef(webkit_geolocation_policy_decision_new(webFrame, geolocation)));
gboolean isHandled = FALSE;
g_signal_emit_by_name(webView, "geolocation-policy-decision-requested", webFrame, policyDecision.get(), &isHandled);