Title: [160435] trunk/Source/WebKit2
Revision
160435
Author
g...@gnome.org
Date
2013-12-11 08:40:43 -0800 (Wed, 11 Dec 2013)

Log Message

[GTK] Support right-side attachment of the inspector
https://bugs.webkit.org/show_bug.cgi?id=124126

Reviewed by Carlos Garcia Campos.

* UIProcess/API/C/gtk/WKInspectorClientGtk.h: add changed attached width callback.
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseAddWebInspector): take attachment side parameter into account when adding the
inspector view.
(webkitWebViewBaseContainerRemove): renamed inspectorViewHeight to inspectorViewSize.
(resizeWebKitWebViewBaseFromAllocation): take attachment side into account when allocating the
sizes for the inspector view and the inspected view.
(webkitWebViewBaseSetInspectorViewSize): renamed from webkitWebViewBaseSetInspectorViewHeight.
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
* UIProcess/gtk/WebInspectorClientGtk.cpp:
(WebKit::WebInspectorClientGtk::didChangeAttachedWidth): notify client that view width has changed.
* UIProcess/gtk/WebInspectorClientGtk.h:
* UIProcess/gtk/WebInspectorProxyGtk.cpp:
(WebKit::WebInspectorProxy::platformAttach): use attachment side for setting the default size
for the inspector view.
(WebKit::WebInspectorProxy::platformSetAttachedWindowHeight): use the new generic SetInspectorViewSize.
(WebKit::WebInspectorProxy::platformSetAttachedWindowWidth): allow setting the inspector view width.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (160434 => 160435)


--- trunk/Source/WebKit2/ChangeLog	2013-12-11 16:28:27 UTC (rev 160434)
+++ trunk/Source/WebKit2/ChangeLog	2013-12-11 16:40:43 UTC (rev 160435)
@@ -1,3 +1,28 @@
+2013-12-11  Gustavo Noronha Silva  <g...@gnome.org>
+
+        [GTK] Support right-side attachment of the inspector
+        https://bugs.webkit.org/show_bug.cgi?id=124126
+
+        Reviewed by Carlos Garcia Campos.
+
+        * UIProcess/API/C/gtk/WKInspectorClientGtk.h: add changed attached width callback.
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseAddWebInspector): take attachment side parameter into account when adding the
+        inspector view.
+        (webkitWebViewBaseContainerRemove): renamed inspectorViewHeight to inspectorViewSize.
+        (resizeWebKitWebViewBaseFromAllocation): take attachment side into account when allocating the
+        sizes for the inspector view and the inspected view.
+        (webkitWebViewBaseSetInspectorViewSize): renamed from webkitWebViewBaseSetInspectorViewHeight.
+        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
+        * UIProcess/gtk/WebInspectorClientGtk.cpp:
+        (WebKit::WebInspectorClientGtk::didChangeAttachedWidth): notify client that view width has changed.
+        * UIProcess/gtk/WebInspectorClientGtk.h:
+        * UIProcess/gtk/WebInspectorProxyGtk.cpp:
+        (WebKit::WebInspectorProxy::platformAttach): use attachment side for setting the default size
+        for the inspector view.
+        (WebKit::WebInspectorProxy::platformSetAttachedWindowHeight): use the new generic SetInspectorViewSize.
+        (WebKit::WebInspectorProxy::platformSetAttachedWindowWidth): allow setting the inspector view width.
+
 2013-12-11  Brendan Long  <b.l...@cablelabs.com>
 
         [GTK] Add "enable-mediasource" property to WebKitWebSettings

Modified: trunk/Source/WebKit2/UIProcess/API/C/gtk/WKInspectorClientGtk.h (160434 => 160435)


--- trunk/Source/WebKit2/UIProcess/API/C/gtk/WKInspectorClientGtk.h	2013-12-11 16:28:27 UTC (rev 160434)
+++ trunk/Source/WebKit2/UIProcess/API/C/gtk/WKInspectorClientGtk.h	2013-12-11 16:40:43 UTC (rev 160435)
@@ -36,6 +36,7 @@
 typedef void (*WKInspectorClientGtkInspectorDidCloseCallback)(WKInspectorRef inspector, const void* clientInfo);
 typedef void (*WKInspectorClientGtkInspectedURLChangedCallback)(WKInspectorRef inspector, WKStringRef url, const void* clientInfo);
 typedef void (*WKInspectorClientGtkDidChangeAttachedHeightCallback)(WKInspectorRef inspector, unsigned height, const void* clientInfo);
+typedef void (*WKInspectorClientGtkDidChangeAttachedWidthCallback)(WKInspectorRef inspector, unsigned width, const void* clientInfo);
 
 typedef struct WKInspectorClientGtkBase {
     int                                                 version;
@@ -52,6 +53,7 @@
     WKInspectorClientGtkInspectorCallback               attach;
     WKInspectorClientGtkInspectorCallback               detach;
     WKInspectorClientGtkDidChangeAttachedHeightCallback didChangeAttachedHeight;
+    WKInspectorClientGtkDidChangeAttachedWidthCallback  didChangeAttachedWidth;
 } WKInspectorClientGtkV0;
 
 WK_EXPORT void WKInspectorSetInspectorClientGtk(WKInspectorRef inspectorRef, const WKInspectorClientGtkBase* client);

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (160434 => 160435)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp	2013-12-11 16:28:27 UTC (rev 160434)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp	2013-12-11 16:40:43 UTC (rev 160435)
@@ -2,6 +2,7 @@
  * Copyright (C) 2010 Apple Inc. All rights reserved.
  * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
  * Copyright (C) 2011 Igalia S.L.
+ * Copyright (C) 2013 Gustavo Noronha Silva <g...@gnome.org>.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -105,7 +106,8 @@
     bool needsResizeOnMap;
     GtkWidget* authenticationDialog;
     GtkWidget* inspectorView;
-    unsigned inspectorViewHeight;
+    AttachmentSide inspectorAttachmentSide;
+    unsigned inspectorViewSize;
     GOwnPtr<GdkEvent> contextMenuEvent;
     WebContextMenuProxyGtk* activeContextMenuProxy;
     WebViewBaseInputMethodFilter inputMethodFilter;
@@ -320,8 +322,18 @@
     gtk_widget_queue_draw(GTK_WIDGET(webViewBase));
 }
 
-void webkitWebViewBaseAddWebInspector(WebKitWebViewBase* webViewBase, GtkWidget* inspector)
+void webkitWebViewBaseAddWebInspector(WebKitWebViewBase* webViewBase, GtkWidget* inspector, AttachmentSide attachmentSide)
 {
+    if (webViewBase->priv->inspectorView == inspector && webViewBase->priv->inspectorAttachmentSide == attachmentSide)
+        return;
+
+    webViewBase->priv->inspectorAttachmentSide = attachmentSide;
+
+    if (webViewBase->priv->inspectorView == inspector) {
+        gtk_widget_queue_resize(GTK_WIDGET(webViewBase));
+        return;
+    }
+
     webViewBase->priv->inspectorView = inspector;
     gtk_container_add(GTK_CONTAINER(webViewBase), inspector);
 }
@@ -337,7 +349,7 @@
 
     if (priv->inspectorView == widget) {
         priv->inspectorView = 0;
-        priv->inspectorViewHeight = 0;
+        priv->inspectorViewSize = 0;
     } else if (priv->authenticationDialog == widget) {
         priv->authenticationDialog = 0;
     } else {
@@ -480,13 +492,23 @@
     IntRect viewRect(allocation->x, allocation->y, allocation->width, allocation->height);
     WebKitWebViewBasePrivate* priv = webViewBase->priv;
     if (priv->inspectorView) {
-        int inspectorViewHeight = std::min(static_cast<int>(priv->inspectorViewHeight), allocation->height);
         GtkAllocation childAllocation = viewRect;
-        childAllocation.y = allocation->height - inspectorViewHeight;
-        childAllocation.height = inspectorViewHeight;
+
+        if (priv->inspectorAttachmentSide == AttachmentSideBottom) {
+            int inspectorViewHeight = std::min(static_cast<int>(priv->inspectorViewSize), allocation->height);
+            childAllocation.x = 0;
+            childAllocation.y = allocation->height - inspectorViewHeight;
+            childAllocation.height = inspectorViewHeight;
+            viewRect.setHeight(std::max(allocation->height - inspectorViewHeight, 1));
+        } else {
+            int inspectorViewWidth = std::min(static_cast<int>(priv->inspectorViewSize), allocation->width);
+            childAllocation.y = 0;
+            childAllocation.x = allocation->width - inspectorViewWidth;
+            childAllocation.width = inspectorViewWidth;
+            viewRect.setWidth(std::max(allocation->width - inspectorViewWidth, 1));
+        }
+
         gtk_widget_size_allocate(priv->inspectorView, &childAllocation);
-
-        viewRect.setHeight(std::max(allocation->height - inspectorViewHeight, 1));
     }
 
     // The authentication dialog is centered in the view rect, which means that it
@@ -1046,11 +1068,11 @@
     webkitWebViewBase->priv->fullScreenClient.initialize(wkClient);
 }
 
-void webkitWebViewBaseSetInspectorViewHeight(WebKitWebViewBase* webkitWebViewBase, unsigned height)
+void webkitWebViewBaseSetInspectorViewSize(WebKitWebViewBase* webkitWebViewBase, unsigned size)
 {
-    if (webkitWebViewBase->priv->inspectorViewHeight == height)
+    if (webkitWebViewBase->priv->inspectorViewSize == size)
         return;
-    webkitWebViewBase->priv->inspectorViewHeight = height;
+    webkitWebViewBase->priv->inspectorViewSize = size;
     if (webkitWebViewBase->priv->inspectorView)
         gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase));
 }

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h (160434 => 160435)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h	2013-12-11 16:28:27 UTC (rev 160434)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h	2013-12-11 16:40:43 UTC (rev 160435)
@@ -29,6 +29,7 @@
 #define WebKitWebViewBasePrivate_h
 
 #include "WebContextMenuProxyGtk.h"
+#include "WebInspectorProxy.h"
 #include "WebKitPrivate.h"
 #include "WebKitWebViewBase.h"
 #include "WebPageProxy.h"
@@ -45,7 +46,7 @@
 void webkitWebViewBaseEnterFullScreen(WebKitWebViewBase*);
 void webkitWebViewBaseExitFullScreen(WebKitWebViewBase*);
 void webkitWebViewBaseInitializeFullScreenClient(WebKitWebViewBase*, const WKFullScreenClientGtkBase*);
-void webkitWebViewBaseSetInspectorViewHeight(WebKitWebViewBase*, unsigned height);
+void webkitWebViewBaseSetInspectorViewSize(WebKitWebViewBase*, unsigned size);
 void webkitWebViewBaseSetActiveContextMenuProxy(WebKitWebViewBase*, WebKit::WebContextMenuProxyGtk*);
 WebKit::WebContextMenuProxyGtk* webkitWebViewBaseGetActiveContextMenuProxy(WebKitWebViewBase*);
 GdkEvent* webkitWebViewBaseTakeContextMenuEvent(WebKitWebViewBase*);
@@ -70,6 +71,6 @@
 
 void webkitWebViewBaseAddAuthenticationDialog(WebKitWebViewBase*, GtkWidget* authDialog);
 void webkitWebViewBaseCancelAuthenticationDialog(WebKitWebViewBase*);
-void webkitWebViewBaseAddWebInspector(WebKitWebViewBase*, GtkWidget* inspector);
+void webkitWebViewBaseAddWebInspector(WebKitWebViewBase*, GtkWidget* inspector, WebKit::AttachmentSide);
 
 #endif // WebKitWebViewBasePrivate_h

Modified: trunk/Source/WebKit2/UIProcess/gtk/WebInspectorClientGtk.cpp (160434 => 160435)


--- trunk/Source/WebKit2/UIProcess/gtk/WebInspectorClientGtk.cpp	2013-12-11 16:28:27 UTC (rev 160434)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebInspectorClientGtk.cpp	2013-12-11 16:40:43 UTC (rev 160435)
@@ -81,4 +81,11 @@
     m_client.didChangeAttachedHeight(toAPI(inspector), height, m_client.base.clientInfo);
 }
 
+void WebInspectorClientGtk::didChangeAttachedWidth(WebInspectorProxy* inspector, unsigned width)
+{
+    if (!m_client.didChangeAttachedWidth)
+        return;
+    m_client.didChangeAttachedWidth(toAPI(inspector), width, m_client.base.clientInfo);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/gtk/WebInspectorClientGtk.h (160434 => 160435)


--- trunk/Source/WebKit2/UIProcess/gtk/WebInspectorClientGtk.h	2013-12-11 16:28:27 UTC (rev 160434)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebInspectorClientGtk.h	2013-12-11 16:40:43 UTC (rev 160435)
@@ -52,6 +52,7 @@
     bool attach(WebInspectorProxy*);
     bool detach(WebInspectorProxy*);
     void didChangeAttachedHeight(WebInspectorProxy*, unsigned height);
+    void didChangeAttachedWidth(WebInspectorProxy*, unsigned width);
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp (160434 => 160435)


--- trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp	2013-12-11 16:28:27 UTC (rev 160434)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp	2013-12-11 16:40:43 UTC (rev 160435)
@@ -2,6 +2,7 @@
  * Copyright (C) 2010 Apple Inc. All rights reserved.
  * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
  * Copyright (C) 2012 Igalia S.L.
+ * Copyright (C) 2013 Gustavo Noronha Silva <g...@gnome.org>.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -176,15 +177,20 @@
         m_inspectorWindow = 0;
     }
 
-    // Set a default attached height based on InspectorFrontendClientLocal.
-    static const unsigned defaultAttachedHeight = 300;
-    unsigned maximumAttachedHeight = platformInspectedWindowHeight() * 3 / 4;
-    platformSetAttachedWindowHeight(std::max(minimumAttachedHeight, std::min(defaultAttachedHeight, maximumAttachedHeight)));
+    // Set a default attached size based on InspectorFrontendClientLocal.
+    static const unsigned defaultAttachedSize = 300;
+    if (m_attachmentSide == AttachmentSideBottom) {
+        unsigned maximumAttachedHeight = platformInspectedWindowHeight() * 3 / 4;
+        platformSetAttachedWindowHeight(std::max(minimumAttachedHeight, std::min(defaultAttachedSize, maximumAttachedHeight)));
+    } else {
+        unsigned maximumAttachedWidth = platformInspectedWindowWidth() * 3 / 4;
+        platformSetAttachedWindowWidth(std::max(minimumAttachedWidth, std::min(defaultAttachedSize, maximumAttachedWidth)));
+    }
 
     if (m_client.attach(this))
         return;
 
-    webkitWebViewBaseAddWebInspector(WEBKIT_WEB_VIEW_BASE(m_page->viewWidget()), m_inspectorView);
+    webkitWebViewBaseAddWebInspector(WEBKIT_WEB_VIEW_BASE(m_page->viewWidget()), m_inspectorView, m_attachmentSide);
     gtk_widget_show(m_inspectorView);
 }
 
@@ -212,12 +218,16 @@
         return;
 
     m_client.didChangeAttachedHeight(this, height);
-    webkitWebViewBaseSetInspectorViewHeight(WEBKIT_WEB_VIEW_BASE(m_page->viewWidget()), height);
+    webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE(m_page->viewWidget()), height);
 }
 
-void WebInspectorProxy::platformSetAttachedWindowWidth(unsigned)
+void WebInspectorProxy::platformSetAttachedWindowWidth(unsigned width)
 {
-    notImplemented();
+    if (!m_isAttached)
+        return;
+
+    m_client.didChangeAttachedWidth(this, width);
+    webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE(m_page->viewWidget()), width);
 }
 
 void WebInspectorProxy::platformSetToolbarHeight(unsigned)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to