Diff
Modified: trunk/Source/WebKit2/ChangeLog (117594 => 117595)
--- trunk/Source/WebKit2/ChangeLog 2012-05-18 15:19:16 UTC (rev 117594)
+++ trunk/Source/WebKit2/ChangeLog 2012-05-18 15:21:24 UTC (rev 117595)
@@ -1,5 +1,70 @@
2012-05-18 Carlos Garcia Campos <[email protected]>
+ [GTK] Allow to attach/detach the inspector in WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=86823
+
+ Reviewed by Gustavo Noronha Silva.
+
+ Also rename WebInspectorGtk.cpp as WebInspectorProxyGtk.cpp since
+ it implements the platform specific methods of WebInspectorProxy.
+
+ * GNUmakefile.list.am: Add new files to compilation.
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (webkitWebViewBaseContainerAdd): Allow to add a WebView containing
+ the inspector as an internal child.
+ (webkitWebViewBaseContainerRemove): Check whether the widget
+ removed is the inspector web view.
+ (webkitWebViewBaseContainerForall): When includeInternals is True,
+ add also the inspector web view if it's present.
+ (resizeWebKitWebViewBaseFromAllocation): Allocate space for the
+ inspector web view if it's present.
+ (webkitWebViewBaseSetInspectorViewHeight): Private function used
+ by the inspector proxy to set the height of the inspector web
+ view.
+ * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
+ * UIProcess/WebInspectorProxy.h:
+ (WebInspectorProxy): Remove unneeded method windowDestroyed.
+ * UIProcess/gtk/WebInspectorProxyGtk.cpp: Renamed from Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp.
+ (WebKit::inspectorFilesBasePath):
+ (WebKit::inspectorWindowClosed): Renamed as inspectorWindowClosed
+ instead of inspectorWindowDestroyed, since this is called when the
+ window manager requests to close the window, and not when the
+ widget is destroyed. Also remove the call to windowDestroyed that
+ has been removed.
+ (WebKit::WebInspectorProxy::platformCreateInspectorPage):
+ (WebKit::WebInspectorProxy::createInspectorWindow): Helper
+ function to create the inspector window and add the inspector
+ view. Also set the inspector window as transient for the
+ inspected view toplevel window. And use a weak pointer to make
+ sure inspector window pointer is NULL when it's destroyed, not
+ only when the window is closed.
+ (WebKit::WebInspectorProxy::platformOpen): Call platformAttach if
+ the inspector is opened attached, or createInspectorWindow
+ otherwise.
+ (WebKit::WebInspectorProxy::platformDidClose): Always set the view
+ inspector pointer to NULL.
+ (WebKit::WebInspectorProxy::platformBringToFront): Implement it by
+ showing the toplevel window where the inspector view is contained.
+ (WebKit::WebInspectorProxy::platformIsFront): Implement it by
+ checking whether the toplevel window where the inspector view is
+ contained is active or not.
+ (WebKit::WebInspectorProxy::platformInspectedURLChanged): Return
+ early if there's no inspector window.
+ (WebKit::WebInspectorProxy::inspectorPageURL):
+ (WebKit::WebInspectorProxy::inspectorBaseURL):
+ (WebKit::WebInspectorProxy::platformInspectedWindowHeight): Return
+ the height of the inpected view.
+ (WebKit::WebInspectorProxy::platformAttach): Remove the view from
+ the current window if there's one, and insert the inspector view
+ into the inspected view.
+ (WebKit::WebInspectorProxy::platformDetach): Remove the inspector
+ view from the inspected view and create a new window for it if
+ it's visible.
+ (WebKit::WebInspectorProxy::platformSetAttachedWindowHeight): Call
+ webkitWebViewBaseSetInspectorViewHeight().
+
+2012-05-18 Carlos Garcia Campos <[email protected]>
+
Return TRUE for events handled to avoid their propagation.
Reviewed by Gustavo Noronha Silva.
Modified: trunk/Source/WebKit2/GNUmakefile.list.am (117594 => 117595)
--- trunk/Source/WebKit2/GNUmakefile.list.am 2012-05-18 15:19:16 UTC (rev 117594)
+++ trunk/Source/WebKit2/GNUmakefile.list.am 2012-05-18 15:21:24 UTC (rev 117595)
@@ -675,7 +675,7 @@
Source/WebKit2/UIProcess/gtk/WebFullScreenClientGtk.cpp \
Source/WebKit2/UIProcess/gtk/WebFullScreenClientGtk.h \
Source/WebKit2/UIProcess/gtk/WebFullScreenManagerProxyGtk.cpp \
- Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp \
+ Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp \
Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp \
Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp \
Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.h \
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (117594 => 117595)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2012-05-18 15:19:16 UTC (rev 117594)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2012-05-18 15:21:24 UTC (rev 117595)
@@ -36,6 +36,7 @@
#include "WebContext.h"
#include "WebEventFactory.h"
#include "WebFullScreenClientGtk.h"
+#include "WebInspectorProxy.h"
#include "WebKitPrivate.h"
#include "WebKitWebViewBaseAccessible.h"
#include "WebKitWebViewBasePrivate.h"
@@ -87,10 +88,15 @@
bool fullScreenModeActive;
WebFullScreenClientGtk fullScreenClient;
#endif
+ GtkWidget* inspectorView;
+ unsigned inspectorViewHeight;
};
G_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_CONTAINER)
+// Keep this in sync with the value minimumAttachedHeight in WebInspectorProxy.
+static const unsigned gMinimumAttachedInspectorHeight = 250;
+
static void webkitWebViewBaseNotifyResizerSizeForWindow(WebKitWebViewBase* webViewBase, GtkWindow* window)
{
gboolean resizerVisible;
@@ -170,9 +176,16 @@
WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(container);
WebKitWebViewBasePrivate* priv = webView->priv;
- GtkAllocation childAllocation;
- gtk_widget_get_allocation(widget, &childAllocation);
- priv->children.set(widget, childAllocation);
+ if (WEBKIT_IS_WEB_VIEW_BASE(widget)
+ && WebInspectorProxy::isInspectorPage(WEBKIT_WEB_VIEW_BASE(widget)->priv->pageProxy.get())) {
+ ASSERT(priv->inspectorView);
+ priv->inspectorView = widget;
+ priv->inspectorViewHeight = gMinimumAttachedInspectorHeight;
+ } else {
+ GtkAllocation childAllocation;
+ gtk_widget_get_allocation(widget, &childAllocation);
+ priv->children.set(widget, childAllocation);
+ }
gtk_widget_set_parent(widget, GTK_WIDGET(container));
}
@@ -183,11 +196,16 @@
WebKitWebViewBasePrivate* priv = webView->priv;
GtkWidget* widgetContainer = GTK_WIDGET(container);
- ASSERT(priv->children.contains(widget));
gboolean wasVisible = gtk_widget_get_visible(widget);
gtk_widget_unparent(widget);
- priv->children.remove(widget);
+ if (priv->inspectorView == widget) {
+ priv->inspectorView = 0;
+ priv->inspectorViewHeight = 0;
+ } else {
+ ASSERT(priv->children.contains(widget));
+ priv->children.remove(widget);
+ }
if (wasVisible && gtk_widget_get_visible(widgetContainer))
gtk_widget_queue_resize(widgetContainer);
}
@@ -201,6 +219,9 @@
WebKitWebViewChildrenMap::const_iterator end = children.end();
for (WebKitWebViewChildrenMap::const_iterator current = children.begin(); current != end; ++current)
(*callback)(current->first, callbackData);
+
+ if (includeInternals && priv->inspectorView)
+ (*callback)(priv->inspectorView, callbackData);
}
void webkitWebViewBaseChildMoveResize(WebKitWebViewBase* webView, GtkWidget* child, const IntRect& childRect)
@@ -282,9 +303,19 @@
{
gtk_container_foreach(GTK_CONTAINER(webViewBase), webkitWebViewBaseChildAllocate, webViewBase);
+ IntRect viewRect(allocation->x, allocation->y, allocation->width, allocation->height);
WebKitWebViewBasePrivate* priv = webViewBase->priv;
+ if (priv->inspectorView) {
+ GtkAllocation childAllocation = viewRect;
+ childAllocation.y = allocation->height - priv->inspectorViewHeight;
+ childAllocation.height = priv->inspectorViewHeight;
+ gtk_widget_size_allocate(priv->inspectorView, &childAllocation);
+
+ viewRect.setHeight(allocation->height - priv->inspectorViewHeight);
+ }
+
if (priv->pageProxy->drawingArea())
- priv->pageProxy->drawingArea()->setSize(IntSize(allocation->width, allocation->height), IntSize());
+ priv->pageProxy->drawingArea()->setSize(viewRect.size(), IntSize());
GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(webViewBase));
if (widgetIsOnscreenToplevelWindow(toplevel))
@@ -718,3 +749,13 @@
{
webkitWebViewBase->priv->fullScreenClient.initialize(wkClient);
}
+
+void webkitWebViewBaseSetInspectorViewHeight(WebKitWebViewBase* webkitWebViewBase, unsigned height)
+{
+ if (!webkitWebViewBase->priv->inspectorView)
+ return;
+ if (webkitWebViewBase->priv->inspectorViewHeight == height)
+ return;
+ webkitWebViewBase->priv->inspectorViewHeight = height;
+ gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase));
+}
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h (117594 => 117595)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h 2012-05-18 15:19:16 UTC (rev 117594)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h 2012-05-18 15:21:24 UTC (rev 117595)
@@ -45,5 +45,6 @@
void webkitWebViewBaseEnterFullScreen(WebKitWebViewBase*);
void webkitWebViewBaseExitFullScreen(WebKitWebViewBase*);
void webkitWebViewBaseInitializeFullScreenClient(WebKitWebViewBase*, const WKFullScreenClientGtk*);
+void webkitWebViewBaseSetInspectorViewHeight(WebKitWebViewBase*, unsigned height);
#endif // WebKitWebViewBasePrivate_h
Modified: trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h (117594 => 117595)
--- trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h 2012-05-18 15:19:16 UTC (rev 117594)
+++ trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h 2012-05-18 15:21:24 UTC (rev 117595)
@@ -89,8 +89,6 @@
void createInspectorWindow();
void updateInspectorWindowTitle() const;
void inspectedViewFrameDidChange();
-#elif PLATFORM(GTK)
- void windowDestroyed();
#endif
void showConsole();
@@ -176,6 +174,10 @@
virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM);
#endif
+#if PLATFORM(GTK)
+ void createInspectorWindow();
+#endif
+
static const unsigned minimumWindowWidth = 500;
static const unsigned minimumWindowHeight = 400;
Deleted: trunk/Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp (117594 => 117595)
--- trunk/Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp 2012-05-18 15:19:16 UTC (rev 117594)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp 2012-05-18 15:21:24 UTC (rev 117595)
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- * Portions Copyright (c) 2010 Motorola Mobility, 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:
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "WebInspectorProxy.h"
-
-#if ENABLE(INSPECTOR)
-
-#include "WebKitWebViewBasePrivate.h"
-#include "WebProcessProxy.h"
-
-#include <WebCore/FileSystem.h>
-#include <WebCore/NotImplemented.h>
-#include <glib/gi18n-lib.h>
-#include <gtk/gtk.h>
-#include <wtf/gobject/GOwnPtr.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebKit {
-
-static const char* inspectorFilesBasePath()
-{
- const gchar* environmentPath = g_getenv("WEBKIT_INSPECTOR_PATH");
- if (environmentPath && g_file_test(environmentPath, G_FILE_TEST_IS_DIR))
- return environmentPath;
-
- static const char* inspectorFilesPath = DATA_DIR""G_DIR_SEPARATOR_S
- "webkitgtk-"WEBKITGTK_API_VERSION_STRING""G_DIR_SEPARATOR_S
- "webinspector"G_DIR_SEPARATOR_S;
- return inspectorFilesPath;
-}
-
-static gboolean inspectorWindowDestroyed(GtkWidget* window, GdkEvent*, gpointer userData)
-{
- WebInspectorProxy* inspectorProxy = static_cast<WebInspectorProxy*>(userData);
-
- // Inform WebProcess about webinspector closure. Not doing so,
- // results in failure of subsequent invocation of webinspector.
- inspectorProxy->close();
- inspectorProxy->windowDestroyed();
-
- return FALSE;
-}
-
-void WebInspectorProxy::windowDestroyed()
-{
- ASSERT(m_inspectorView);
- ASSERT(m_inspectorWindow);
- m_inspectorView = 0;
- m_inspectorWindow = 0;
-}
-
-WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
-{
- ASSERT(m_page);
- ASSERT(!m_inspectorView);
- m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(page()->process()->context(), inspectorPageGroup()));
- return webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_inspectorView));
-}
-
-void WebInspectorProxy::platformOpen()
-{
- ASSERT(!m_inspectorWindow);
- m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-
- gtk_window_set_title(GTK_WINDOW(m_inspectorWindow), _("Web Inspector"));
- gtk_window_set_default_size(GTK_WINDOW(m_inspectorWindow), initialWindowWidth, initialWindowHeight);
- g_signal_connect(m_inspectorWindow, "delete-event", G_CALLBACK(inspectorWindowDestroyed), this);
-
- gtk_container_add(GTK_CONTAINER(m_inspectorWindow), m_inspectorView);
- gtk_widget_show(m_inspectorView);
- gtk_widget_show(m_inspectorWindow);
-}
-
-void WebInspectorProxy::platformDidClose()
-{
- if (m_inspectorWindow) {
- gtk_widget_destroy(m_inspectorWindow);
- m_inspectorWindow = 0;
- m_inspectorView = 0;
- }
-}
-
-void WebInspectorProxy::platformBringToFront()
-{
- notImplemented();
-}
-
-bool WebInspectorProxy::platformIsFront()
-{
- notImplemented();
- return false;
-}
-
-void WebInspectorProxy::platformInspectedURLChanged(const String& url)
-{
- GOwnPtr<gchar> title(g_strdup_printf("%s - %s", _("Web Inspector"), url.utf8().data()));
- gtk_window_set_title(GTK_WINDOW(m_inspectorWindow), title.get());
-}
-
-String WebInspectorProxy::inspectorPageURL() const
-{
- GOwnPtr<gchar> filePath(g_build_filename(inspectorFilesBasePath(), "inspector.html", NULL));
- GOwnPtr<gchar> fileURI(g_filename_to_uri(filePath.get(), 0, 0));
- return WebCore::filenameToString(fileURI.get());
-}
-
-String WebInspectorProxy::inspectorBaseURL() const
-{
- GOwnPtr<gchar> fileURI(g_filename_to_uri(inspectorFilesBasePath(), 0, 0));
- return WebCore::filenameToString(fileURI.get());
-}
-
-unsigned WebInspectorProxy::platformInspectedWindowHeight()
-{
- notImplemented();
- return 0;
-}
-
-void WebInspectorProxy::platformAttach()
-{
- notImplemented();
-}
-
-void WebInspectorProxy::platformDetach()
-{
- notImplemented();
-}
-
-void WebInspectorProxy::platformSetAttachedWindowHeight(unsigned)
-{
- notImplemented();
-}
-
-} // namespace WebKit
-
-#endif // ENABLE(INSPECTOR)
Copied: trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp (from rev 117594, trunk/Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp) (0 => 117595)
--- trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp 2012-05-18 15:21:24 UTC (rev 117595)
@@ -0,0 +1,194 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
+ * Copyright (C) 2012 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "WebInspectorProxy.h"
+
+#if ENABLE(INSPECTOR)
+
+#include "WebKitWebViewBasePrivate.h"
+#include "WebProcessProxy.h"
+#include <WebCore/FileSystem.h>
+#include <WebCore/GtkUtilities.h>
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+static const char* inspectorFilesBasePath()
+{
+ const gchar* environmentPath = g_getenv("WEBKIT_INSPECTOR_PATH");
+ if (environmentPath && g_file_test(environmentPath, G_FILE_TEST_IS_DIR))
+ return environmentPath;
+
+ static const char* inspectorFilesPath = DATA_DIR""G_DIR_SEPARATOR_S
+ "webkitgtk-"WEBKITGTK_API_VERSION_STRING""G_DIR_SEPARATOR_S
+ "webinspector"G_DIR_SEPARATOR_S;
+ return inspectorFilesPath;
+}
+
+static gboolean inspectorWindowClosed(GtkWidget* window, GdkEvent*, gpointer userData)
+{
+ WebInspectorProxy* inspectorProxy = static_cast<WebInspectorProxy*>(userData);
+
+ // Inform WebProcess about webinspector closure. Not doing so,
+ // results in failure of subsequent invocation of webinspector.
+ inspectorProxy->close();
+
+ return FALSE;
+}
+
+WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
+{
+ ASSERT(m_page);
+ ASSERT(!m_inspectorView);
+ m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(page()->process()->context(), inspectorPageGroup()));
+ return webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_inspectorView));
+}
+
+void WebInspectorProxy::createInspectorWindow()
+{
+ ASSERT(!m_inspectorWindow);
+ m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+
+ GtkWidget* inspectedViewParent = gtk_widget_get_toplevel(m_page->viewWidget());
+ if (WebCore::widgetIsOnscreenToplevelWindow(inspectedViewParent))
+ gtk_window_set_transient_for(GTK_WINDOW(m_inspectorWindow), GTK_WINDOW(inspectedViewParent));
+
+ gtk_window_set_title(GTK_WINDOW(m_inspectorWindow), _("Web Inspector"));
+ gtk_window_set_default_size(GTK_WINDOW(m_inspectorWindow), initialWindowWidth, initialWindowHeight);
+ g_signal_connect(m_inspectorWindow, "delete-event", G_CALLBACK(inspectorWindowClosed), this);
+
+ gtk_container_add(GTK_CONTAINER(m_inspectorWindow), m_inspectorView);
+ gtk_widget_show(m_inspectorView);
+
+ g_object_add_weak_pointer(G_OBJECT(m_inspectorWindow), reinterpret_cast<void**>(&m_inspectorWindow));
+ gtk_window_present(GTK_WINDOW(m_inspectorWindow));
+}
+
+void WebInspectorProxy::platformOpen()
+{
+ ASSERT(!m_inspectorWindow);
+ ASSERT(m_inspectorView);
+
+ if (m_isAttached)
+ platformAttach();
+ else
+ createInspectorWindow();
+}
+
+void WebInspectorProxy::platformDidClose()
+{
+ if (m_inspectorWindow) {
+ gtk_widget_destroy(m_inspectorWindow);
+ m_inspectorWindow = 0;
+ }
+ m_inspectorView = 0;
+}
+
+void WebInspectorProxy::platformBringToFront()
+{
+ GtkWidget* parent = gtk_widget_get_toplevel(m_inspectorView);
+ if (WebCore::widgetIsOnscreenToplevelWindow(parent))
+ gtk_window_present(GTK_WINDOW(parent));
+}
+
+bool WebInspectorProxy::platformIsFront()
+{
+ GtkWidget* parent = gtk_widget_get_toplevel(m_inspectorView);
+ if (WebCore::widgetIsOnscreenToplevelWindow(parent))
+ return m_isVisible && gtk_window_is_active(GTK_WINDOW(parent));
+ return false;
+}
+
+void WebInspectorProxy::platformInspectedURLChanged(const String& url)
+{
+ if (!m_inspectorWindow)
+ return;
+ GOwnPtr<gchar> title(g_strdup_printf("%s - %s", _("Web Inspector"), url.utf8().data()));
+ gtk_window_set_title(GTK_WINDOW(m_inspectorWindow), title.get());
+}
+
+String WebInspectorProxy::inspectorPageURL() const
+{
+ GOwnPtr<gchar> filePath(g_build_filename(inspectorFilesBasePath(), "inspector.html", NULL));
+ GOwnPtr<gchar> fileURI(g_filename_to_uri(filePath.get(), 0, 0));
+ return WebCore::filenameToString(fileURI.get());
+}
+
+String WebInspectorProxy::inspectorBaseURL() const
+{
+ GOwnPtr<gchar> fileURI(g_filename_to_uri(inspectorFilesBasePath(), 0, 0));
+ return WebCore::filenameToString(fileURI.get());
+}
+
+unsigned WebInspectorProxy::platformInspectedWindowHeight()
+{
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(m_page->viewWidget(), &allocation);
+ return allocation.height;
+}
+
+void WebInspectorProxy::platformAttach()
+{
+ GRefPtr<GtkWidget> inspectorView = m_inspectorView;
+ if (m_inspectorWindow) {
+ gtk_container_remove(GTK_CONTAINER(m_inspectorWindow), m_inspectorView);
+ gtk_widget_destroy(m_inspectorWindow);
+ m_inspectorWindow = 0;
+ }
+
+ gtk_container_add(GTK_CONTAINER(m_page->viewWidget()), m_inspectorView);
+ gtk_widget_show(m_inspectorView);
+}
+
+void WebInspectorProxy::platformDetach()
+{
+ if (!m_page->isValid())
+ return;
+
+ GRefPtr<GtkWidget> inspectorView = m_inspectorView;
+ gtk_container_remove(GTK_CONTAINER(m_page->viewWidget()), m_inspectorView);
+ if (!m_isVisible)
+ return;
+
+ createInspectorWindow();
+}
+
+void WebInspectorProxy::platformSetAttachedWindowHeight(unsigned height)
+{
+ if (!m_isAttached)
+ return;
+ webkitWebViewBaseSetInspectorViewHeight(WEBKIT_WEB_VIEW_BASE(m_page->viewWidget()), height);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INSPECTOR)