Changeset 160435 in webkit


Ignore:
Timestamp:
Dec 11, 2013 8:40:43 AM (10 years ago)
Author:
Gustavo Noronha Silva
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.

Location:
trunk/Source/WebKit2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r160434 r160435  
     12013-12-11  Gustavo Noronha Silva  <gns@gnome.org>
     2
     3        [GTK] Support right-side attachment of the inspector
     4        https://bugs.webkit.org/show_bug.cgi?id=124126
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * UIProcess/API/C/gtk/WKInspectorClientGtk.h: add changed attached width callback.
     9        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
     10        (webkitWebViewBaseAddWebInspector): take attachment side parameter into account when adding the
     11        inspector view.
     12        (webkitWebViewBaseContainerRemove): renamed inspectorViewHeight to inspectorViewSize.
     13        (resizeWebKitWebViewBaseFromAllocation): take attachment side into account when allocating the
     14        sizes for the inspector view and the inspected view.
     15        (webkitWebViewBaseSetInspectorViewSize): renamed from webkitWebViewBaseSetInspectorViewHeight.
     16        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
     17        * UIProcess/gtk/WebInspectorClientGtk.cpp:
     18        (WebKit::WebInspectorClientGtk::didChangeAttachedWidth): notify client that view width has changed.
     19        * UIProcess/gtk/WebInspectorClientGtk.h:
     20        * UIProcess/gtk/WebInspectorProxyGtk.cpp:
     21        (WebKit::WebInspectorProxy::platformAttach): use attachment side for setting the default size
     22        for the inspector view.
     23        (WebKit::WebInspectorProxy::platformSetAttachedWindowHeight): use the new generic SetInspectorViewSize.
     24        (WebKit::WebInspectorProxy::platformSetAttachedWindowWidth): allow setting the inspector view width.
     25
    1262013-12-11  Brendan Long  <b.long@cablelabs.com>
    227
  • trunk/Source/WebKit2/UIProcess/API/C/gtk/WKInspectorClientGtk.h

    r160075 r160435  
    3737typedef void (*WKInspectorClientGtkInspectedURLChangedCallback)(WKInspectorRef inspector, WKStringRef url, const void* clientInfo);
    3838typedef void (*WKInspectorClientGtkDidChangeAttachedHeightCallback)(WKInspectorRef inspector, unsigned height, const void* clientInfo);
     39typedef void (*WKInspectorClientGtkDidChangeAttachedWidthCallback)(WKInspectorRef inspector, unsigned width, const void* clientInfo);
    3940
    4041typedef struct WKInspectorClientGtkBase {
     
    5354    WKInspectorClientGtkInspectorCallback               detach;
    5455    WKInspectorClientGtkDidChangeAttachedHeightCallback didChangeAttachedHeight;
     56    WKInspectorClientGtkDidChangeAttachedWidthCallback  didChangeAttachedWidth;
    5557} WKInspectorClientGtkV0;
    5658
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r160303 r160435  
    33 * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
    44 * Copyright (C) 2011 Igalia S.L.
     5 * Copyright (C) 2013 Gustavo Noronha Silva <gns@gnome.org>.
    56 *
    67 * Redistribution and use in source and binary forms, with or without
     
    106107    GtkWidget* authenticationDialog;
    107108    GtkWidget* inspectorView;
    108     unsigned inspectorViewHeight;
     109    AttachmentSide inspectorAttachmentSide;
     110    unsigned inspectorViewSize;
    109111    GOwnPtr<GdkEvent> contextMenuEvent;
    110112    WebContextMenuProxyGtk* activeContextMenuProxy;
     
    321323}
    322324
    323 void webkitWebViewBaseAddWebInspector(WebKitWebViewBase* webViewBase, GtkWidget* inspector)
    324 {
     325void webkitWebViewBaseAddWebInspector(WebKitWebViewBase* webViewBase, GtkWidget* inspector, AttachmentSide attachmentSide)
     326{
     327    if (webViewBase->priv->inspectorView == inspector && webViewBase->priv->inspectorAttachmentSide == attachmentSide)
     328        return;
     329
     330    webViewBase->priv->inspectorAttachmentSide = attachmentSide;
     331
     332    if (webViewBase->priv->inspectorView == inspector) {
     333        gtk_widget_queue_resize(GTK_WIDGET(webViewBase));
     334        return;
     335    }
     336
    325337    webViewBase->priv->inspectorView = inspector;
    326338    gtk_container_add(GTK_CONTAINER(webViewBase), inspector);
     
    338350    if (priv->inspectorView == widget) {
    339351        priv->inspectorView = 0;
    340         priv->inspectorViewHeight = 0;
     352        priv->inspectorViewSize = 0;
    341353    } else if (priv->authenticationDialog == widget) {
    342354        priv->authenticationDialog = 0;
     
    481493    WebKitWebViewBasePrivate* priv = webViewBase->priv;
    482494    if (priv->inspectorView) {
    483         int inspectorViewHeight = std::min(static_cast<int>(priv->inspectorViewHeight), allocation->height);
    484495        GtkAllocation childAllocation = viewRect;
    485         childAllocation.y = allocation->height - inspectorViewHeight;
    486         childAllocation.height = inspectorViewHeight;
     496
     497        if (priv->inspectorAttachmentSide == AttachmentSideBottom) {
     498            int inspectorViewHeight = std::min(static_cast<int>(priv->inspectorViewSize), allocation->height);
     499            childAllocation.x = 0;
     500            childAllocation.y = allocation->height - inspectorViewHeight;
     501            childAllocation.height = inspectorViewHeight;
     502            viewRect.setHeight(std::max(allocation->height - inspectorViewHeight, 1));
     503        } else {
     504            int inspectorViewWidth = std::min(static_cast<int>(priv->inspectorViewSize), allocation->width);
     505            childAllocation.y = 0;
     506            childAllocation.x = allocation->width - inspectorViewWidth;
     507            childAllocation.width = inspectorViewWidth;
     508            viewRect.setWidth(std::max(allocation->width - inspectorViewWidth, 1));
     509        }
     510
    487511        gtk_widget_size_allocate(priv->inspectorView, &childAllocation);
    488 
    489         viewRect.setHeight(std::max(allocation->height - inspectorViewHeight, 1));
    490512    }
    491513
     
    10471069}
    10481070
    1049 void webkitWebViewBaseSetInspectorViewHeight(WebKitWebViewBase* webkitWebViewBase, unsigned height)
    1050 {
    1051     if (webkitWebViewBase->priv->inspectorViewHeight == height)
    1052         return;
    1053     webkitWebViewBase->priv->inspectorViewHeight = height;
     1071void webkitWebViewBaseSetInspectorViewSize(WebKitWebViewBase* webkitWebViewBase, unsigned size)
     1072{
     1073    if (webkitWebViewBase->priv->inspectorViewSize == size)
     1074        return;
     1075    webkitWebViewBase->priv->inspectorViewSize = size;
    10541076    if (webkitWebViewBase->priv->inspectorView)
    10551077        gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase));
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h

    r160075 r160435  
    3030
    3131#include "WebContextMenuProxyGtk.h"
     32#include "WebInspectorProxy.h"
    3233#include "WebKitPrivate.h"
    3334#include "WebKitWebViewBase.h"
     
    4647void webkitWebViewBaseExitFullScreen(WebKitWebViewBase*);
    4748void webkitWebViewBaseInitializeFullScreenClient(WebKitWebViewBase*, const WKFullScreenClientGtkBase*);
    48 void webkitWebViewBaseSetInspectorViewHeight(WebKitWebViewBase*, unsigned height);
     49void webkitWebViewBaseSetInspectorViewSize(WebKitWebViewBase*, unsigned size);
    4950void webkitWebViewBaseSetActiveContextMenuProxy(WebKitWebViewBase*, WebKit::WebContextMenuProxyGtk*);
    5051WebKit::WebContextMenuProxyGtk* webkitWebViewBaseGetActiveContextMenuProxy(WebKitWebViewBase*);
     
    7172void webkitWebViewBaseAddAuthenticationDialog(WebKitWebViewBase*, GtkWidget* authDialog);
    7273void webkitWebViewBaseCancelAuthenticationDialog(WebKitWebViewBase*);
    73 void webkitWebViewBaseAddWebInspector(WebKitWebViewBase*, GtkWidget* inspector);
     74void webkitWebViewBaseAddWebInspector(WebKitWebViewBase*, GtkWidget* inspector, WebKit::AttachmentSide);
    7475
    7576#endif // WebKitWebViewBasePrivate_h
  • trunk/Source/WebKit2/UIProcess/gtk/WebInspectorClientGtk.cpp

    r160075 r160435  
    8282}
    8383
     84void WebInspectorClientGtk::didChangeAttachedWidth(WebInspectorProxy* inspector, unsigned width)
     85{
     86    if (!m_client.didChangeAttachedWidth)
     87        return;
     88    m_client.didChangeAttachedWidth(toAPI(inspector), width, m_client.base.clientInfo);
     89}
     90
    8491} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/gtk/WebInspectorClientGtk.h

    r160075 r160435  
    5353    bool detach(WebInspectorProxy*);
    5454    void didChangeAttachedHeight(WebInspectorProxy*, unsigned height);
     55    void didChangeAttachedWidth(WebInspectorProxy*, unsigned width);
    5556};
    5657
  • trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp

    r160075 r160435  
    33 * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
    44 * Copyright (C) 2012 Igalia S.L.
     5 * Copyright (C) 2013 Gustavo Noronha Silva <gns@gnome.org>.
    56 *
    67 * Redistribution and use in source and binary forms, with or without
     
    177178    }
    178179
    179     // Set a default attached height based on InspectorFrontendClientLocal.
    180     static const unsigned defaultAttachedHeight = 300;
    181     unsigned maximumAttachedHeight = platformInspectedWindowHeight() * 3 / 4;
    182     platformSetAttachedWindowHeight(std::max(minimumAttachedHeight, std::min(defaultAttachedHeight, maximumAttachedHeight)));
     180    // Set a default attached size based on InspectorFrontendClientLocal.
     181    static const unsigned defaultAttachedSize = 300;
     182    if (m_attachmentSide == AttachmentSideBottom) {
     183        unsigned maximumAttachedHeight = platformInspectedWindowHeight() * 3 / 4;
     184        platformSetAttachedWindowHeight(std::max(minimumAttachedHeight, std::min(defaultAttachedSize, maximumAttachedHeight)));
     185    } else {
     186        unsigned maximumAttachedWidth = platformInspectedWindowWidth() * 3 / 4;
     187        platformSetAttachedWindowWidth(std::max(minimumAttachedWidth, std::min(defaultAttachedSize, maximumAttachedWidth)));
     188    }
    183189
    184190    if (m_client.attach(this))
    185191        return;
    186192
    187     webkitWebViewBaseAddWebInspector(WEBKIT_WEB_VIEW_BASE(m_page->viewWidget()), m_inspectorView);
     193    webkitWebViewBaseAddWebInspector(WEBKIT_WEB_VIEW_BASE(m_page->viewWidget()), m_inspectorView, m_attachmentSide);
    188194    gtk_widget_show(m_inspectorView);
    189195}
     
    213219
    214220    m_client.didChangeAttachedHeight(this, height);
    215     webkitWebViewBaseSetInspectorViewHeight(WEBKIT_WEB_VIEW_BASE(m_page->viewWidget()), height);
    216 }
    217 
    218 void WebInspectorProxy::platformSetAttachedWindowWidth(unsigned)
    219 {
    220     notImplemented();
     221    webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE(m_page->viewWidget()), height);
     222}
     223
     224void WebInspectorProxy::platformSetAttachedWindowWidth(unsigned width)
     225{
     226    if (!m_isAttached)
     227        return;
     228
     229    m_client.didChangeAttachedWidth(this, width);
     230    webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE(m_page->viewWidget()), width);
    221231}
    222232
Note: See TracChangeset for help on using the changeset viewer.