Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[GTK] Inspector should set a default attached height before being att…
…ached

https://bugs.webkit.org/show_bug.cgi?id=90767

Reviewed by Xan Lopez.

We are currently using the minimum attached height in
WebKitWebViewBase as the default height for the inspector when
attached. It would be easier for WebKitWebViewBase and embedders
implementing attach() if the inspector already had an attached
height set when it's being attached.

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseContainerAdd): Don't initialize
inspectorViewHeight.
(webkitWebViewBaseSetInspectorViewHeight): Allow to set the
inspector view height before having an inpector view, but only
queue a resize when the view already has an inspector view.
* UIProcess/API/gtk/tests/TestInspector.cpp:
(testInspectorDefault):
(testInspectorManualAttachDetach):
* UIProcess/gtk/WebInspectorProxyGtk.cpp:
(WebKit::WebInspectorProxy::platformAttach): Set the default
attached height before attach the inspector view.

Canonical link: https://commits.webkit.org/110850@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@124479 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carlosgcampos committed Aug 2, 2012
1 parent 24946c9 commit ef2e26f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
26 changes: 26 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,29 @@
2012-08-02 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] Inspector should set a default attached height before being attached
https://bugs.webkit.org/show_bug.cgi?id=90767

Reviewed by Xan Lopez.

We are currently using the minimum attached height in
WebKitWebViewBase as the default height for the inspector when
attached. It would be easier for WebKitWebViewBase and embedders
implementing attach() if the inspector already had an attached
height set when it's being attached.

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseContainerAdd): Don't initialize
inspectorViewHeight.
(webkitWebViewBaseSetInspectorViewHeight): Allow to set the
inspector view height before having an inpector view, but only
queue a resize when the view already has an inspector view.
* UIProcess/API/gtk/tests/TestInspector.cpp:
(testInspectorDefault):
(testInspectorManualAttachDetach):
* UIProcess/gtk/WebInspectorProxyGtk.cpp:
(WebKit::WebInspectorProxy::platformAttach): Set the default
attached height before attach the inspector view.

2012-08-02 Dinu Jacob <dinu.jacob@nokia.com>

WebKitTestRunner needs layoutTestController.setUserStyleSheetEnabled
Expand Down
9 changes: 2 additions & 7 deletions Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
Expand Up @@ -101,9 +101,6 @@ struct _WebKitWebViewBasePrivate {

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;
Expand Down Expand Up @@ -190,7 +187,6 @@ static void webkitWebViewBaseContainerAdd(GtkContainer* container, GtkWidget* wi
&& 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);
Expand Down Expand Up @@ -773,12 +769,11 @@ void webkitWebViewBaseInitializeFullScreenClient(WebKitWebViewBase* webkitWebVie

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));
if (webkitWebViewBase->priv->inspectorView)
gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase));
}

void webkitWebViewBaseSetActiveContextMenuProxy(WebKitWebViewBase* webkitWebViewBase, WebContextMenuProxyGtk* contextMenuProxy)
Expand Down
5 changes: 3 additions & 2 deletions Source/WebKit2/UIProcess/API/gtk/tests/TestInspector.cpp
Expand Up @@ -22,8 +22,6 @@
#include "WebViewTest.h"
#include <wtf/gobject/GRefPtr.h>

static const unsigned gMinimumAttachedInspectorHeight = 250;

class InspectorTest: public WebViewTest {
public:
MAKE_GLIB_TEST_FIXTURE(InspectorTest);
Expand Down Expand Up @@ -181,6 +179,7 @@ static void testInspectorDefault(InspectorTest* test, gconstpointer)

test->resizeViewAndAttach();
g_assert(webkit_web_inspector_is_attached(test->m_inspector));
g_assert_cmpuint(webkit_web_inspector_get_attached_height(test->m_inspector), >=, InspectorTest::gMinimumAttachedInspectorHeight);
events = test->m_events;
g_assert_cmpint(events.size(), ==, 1);
g_assert_cmpint(events[0], ==, InspectorTest::Attach);
Expand Down Expand Up @@ -258,6 +257,7 @@ class CustomInspectorTest: public InspectorTest {
gtk_widget_show_all(pane);
} else
pane = gtk_bin_get_child(GTK_BIN(m_parentWindow));
gtk_paned_set_position(GTK_PANED(pane), webkit_web_inspector_get_attached_height(m_inspector));
gtk_paned_add2(GTK_PANED(pane), GTK_WIDGET(inspectorView.get()));

return InspectorTest::attach();
Expand Down Expand Up @@ -301,6 +301,7 @@ static void testInspectorManualAttachDetach(CustomInspectorTest* test, gconstpoi

test->resizeViewAndAttach();
g_assert(webkit_web_inspector_is_attached(test->m_inspector));
g_assert_cmpuint(webkit_web_inspector_get_attached_height(test->m_inspector), >=, InspectorTest::gMinimumAttachedInspectorHeight);
events = test->m_events;
g_assert_cmpint(events.size(), ==, 1);
g_assert_cmpint(events[0], ==, InspectorTest::Attach);
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp
Expand Up @@ -182,6 +182,11 @@ void WebInspectorProxy::platformAttach()
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)));

if (m_client.attach(this))
return;

Expand Down

0 comments on commit ef2e26f

Please sign in to comment.