Changeset 96383 in webkit


Ignore:
Timestamp:
Sep 29, 2011 7:30:15 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

Initial implementation of WebInspector for WebKit2 GTK port.
https://bugs.webkit.org/show_bug.cgi?id=68235

Patch by Ravi Phaneendra Kasibhatla <ravi.kasibhatla@motorola.com> on 2011-09-29
Reviewed by Martin Robinson.

  • UIProcess/WebInspectorProxy.cpp:

(WebKit::WebInspectorProxy::WebInspectorProxy): Initialize the native window handles of GTK.

  • UIProcess/WebInspectorProxy.h: Add native window handle for inspector window.
  • UIProcess/gtk/WebInspectorGtk.cpp:

(WebKit::inspectorFilesBasePath): Base folder for inspector resources.
(WebKit::inspectorWindowDestroyed): Invoked when inspector window is closed by user.
(WebKit::WebInspectorProxy::windowDestroyed): Resets the native handles to 0 when user closes the window.
(WebKit::WebInspectorProxy::platformCreateInspectorPage): Create the WebView for inspector.
(WebKit::WebInspectorProxy::platformOpen): Create the window for inspector.
(WebKit::WebInspectorProxy::platformDidClose): Close both WebView & window of inspector.
(WebKit::WebInspectorProxy::platformInspectedURLChanged): Update the title of inspector window.
(WebKit::WebInspectorProxy::inspectorPageURL): Return the absolute URL of inspector.html.
(WebKit::WebInspectorProxy::inspectorBaseURL): Return the location where inspector resources are present.
WebProcess is given read access to this folder only for loading file URLs by sandboxed extension.

Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r96345 r96383  
     12011-09-29  Ravi Phaneendra Kasibhatla  <ravi.kasibhatla@motorola.com>
     2
     3        Initial implementation of WebInspector for WebKit2 GTK port.
     4        https://bugs.webkit.org/show_bug.cgi?id=68235
     5
     6        Reviewed by Martin Robinson.
     7
     8        * UIProcess/WebInspectorProxy.cpp:
     9        (WebKit::WebInspectorProxy::WebInspectorProxy): Initialize the native window handles of GTK.
     10        * UIProcess/WebInspectorProxy.h: Add native window handle for inspector window.
     11        * UIProcess/gtk/WebInspectorGtk.cpp:
     12        (WebKit::inspectorFilesBasePath): Base folder for inspector resources.
     13        (WebKit::inspectorWindowDestroyed): Invoked when inspector window is closed by user.
     14        (WebKit::WebInspectorProxy::windowDestroyed): Resets the native handles to 0 when user closes the window.
     15        (WebKit::WebInspectorProxy::platformCreateInspectorPage): Create the WebView for inspector.
     16        (WebKit::WebInspectorProxy::platformOpen): Create the window for inspector.
     17        (WebKit::WebInspectorProxy::platformDidClose): Close both WebView & window of inspector.
     18        (WebKit::WebInspectorProxy::platformInspectedURLChanged): Update the title of inspector window.
     19        (WebKit::WebInspectorProxy::inspectorPageURL): Return the absolute URL of inspector.html.
     20        (WebKit::WebInspectorProxy::inspectorBaseURL): Return the location where inspector resources are present.
     21        WebProcess is given read access to this folder only for loading file URLs by sandboxed extension.
     22
    1232011-09-23  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
    224
  • trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp

    r96014 r96383  
    11/*
    22 * Copyright (C) 2010 Apple Inc. All rights reserved.
     3 * Portions Copyright (c) 2011 Motorola Mobility, Inc.  All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    3031
    3132#include "WebInspectorMessages.h"
     33#include "WebPageCreationParameters.h"
     34#include "WebPageGroup.h"
    3235#include "WebPageProxy.h"
    33 #include "WebPageCreationParameters.h"
    3436#include "WebPreferences.h"
    3537#include "WebProcessProxy.h"
    36 #include "WebPageGroup.h"
    3738
    3839#if PLATFORM(WIN)
    3940#include "WebView.h"
    4041#endif
    41 
    42 #include <WebCore/NotImplemented.h>
    4342
    4443using namespace WebCore;
     
    7372#if PLATFORM(WIN)
    7473    , m_inspectorWindow(0)
     74#elif PLATFORM(GTK)
     75    , m_inspectorView(0)
     76    , m_inspectorWindow(0)
    7577#endif
    7678{
  • trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h

    r96014 r96383  
    11/*
    22 * Copyright (C) 2010 Apple Inc. All rights reserved.
     3 * Portions Copyright (c) 2011 Motorola Mobility, Inc.  All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    8384#if PLATFORM(MAC)
    8485    void inspectedViewFrameDidChange();
     86#elif PLATFORM(GTK)
     87    void windowDestroyed();
    8588#endif
    8689
     
    176179    HWND m_inspectorWindow;
    177180    RefPtr<WebView> m_inspectorView;
     181#elif PLATFORM(GTK)
     182    GtkWidget* m_inspectorView;
     183    GtkWidget* m_inspectorWindow;
    178184#endif
    179185};
  • trunk/Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp

    r96014 r96383  
    3030#if ENABLE(INSPECTOR)
    3131
     32#include "WebKitWebViewBasePrivate.h"
     33#include "WebProcessProxy.h"
     34
     35#include <WebCore/FileSystem.h>
    3236#include <WebCore/NotImplemented.h>
     37#include <glib/gi18n-lib.h>
     38#include <gtk/gtk.h>
     39#include <wtf/gobject/GOwnPtr.h>
     40#include <wtf/text/CString.h>
    3341#include <wtf/text/WTFString.h>
    3442
    3543namespace WebKit {
    3644
     45static const char* inspectorFilesBasePath()
     46{
     47    const gchar* environmentPath = g_getenv("WEBKIT_INSPECTOR_PATH");
     48    if (environmentPath && g_file_test(environmentPath, G_FILE_TEST_IS_DIR))
     49        return environmentPath;
     50
     51    static const char* inspectorFilesPath = DATA_DIR""G_DIR_SEPARATOR_S
     52                                            "webkitgtk-"WEBKITGTK_API_VERSION_STRING""G_DIR_SEPARATOR_S
     53                                            "webinspector"G_DIR_SEPARATOR_S;
     54    return inspectorFilesPath;
     55}
     56
     57static gboolean inspectorWindowDestroyed(GtkWidget* window, GdkEvent*, gpointer userData)
     58{
     59    WebInspectorProxy* inspectorProxy = static_cast<WebInspectorProxy*>(userData);
     60
     61    // Inform WebProcess about webinspector closure. Not doing so,
     62    // results in failure of subsequent invocation of webinspector.
     63    inspectorProxy->close();
     64    inspectorProxy->windowDestroyed();
     65
     66    return FALSE;
     67}
     68
     69void WebInspectorProxy::windowDestroyed()
     70{
     71    ASSERT(m_inspectorView);
     72    ASSERT(m_inspectorWindow);
     73    m_inspectorView = 0;
     74    m_inspectorWindow = 0;
     75}
     76
    3777WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
    3878{
    39     notImplemented();
    40     return 0;
     79    ASSERT(m_page);
     80    ASSERT(!m_inspectorView);
     81    m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(page()->process()->context(), inspectorPageGroup()));
     82    return webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_inspectorView));
    4183}
    4284
    4385void WebInspectorProxy::platformOpen()
    4486{
    45     notImplemented();
     87    ASSERT(!m_inspectorWindow);
     88    m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     89
     90    gtk_window_set_title(GTK_WINDOW(m_inspectorWindow), _("Web Inspector"));
     91    gtk_window_set_default_size(GTK_WINDOW(m_inspectorWindow), initialWindowWidth, initialWindowHeight);
     92    g_signal_connect(m_inspectorWindow, "delete-event", G_CALLBACK(inspectorWindowDestroyed), this);
     93
     94    gtk_container_add(GTK_CONTAINER(m_inspectorWindow), m_inspectorView);
     95    gtk_widget_show(m_inspectorView);
     96    gtk_widget_show(m_inspectorWindow);
    4697}
    4798
    4899void WebInspectorProxy::platformDidClose()
    49100{
    50     notImplemented();
     101    if (m_inspectorWindow) {
     102        gtk_widget_destroy(m_inspectorWindow);
     103        m_inspectorWindow = 0;
     104        m_inspectorView = 0;
     105    }
    51106}
    52107
     
    56111}
    57112
    58 void WebInspectorProxy::platformInspectedURLChanged(const String&)
     113void WebInspectorProxy::platformInspectedURLChanged(const String& url)
    59114{
    60     notImplemented();
     115    GOwnPtr<gchar> title(g_strdup_printf("%s - %s", _("Web Inspector"), url.utf8().data()));
     116    gtk_window_set_title(GTK_WINDOW(m_inspectorWindow), title.get());
    61117}
    62118
    63119String WebInspectorProxy::inspectorPageURL() const
    64120{
    65     notImplemented();
    66     return String();
     121    GOwnPtr<gchar> filePath(g_build_filename(inspectorFilesBasePath(), "inspector.html", NULL));
     122    GOwnPtr<gchar> fileURI(g_filename_to_uri(filePath.get(), 0, 0));
     123    return WebCore::filenameToString(fileURI.get());
    67124}
    68125
    69126String WebInspectorProxy::inspectorBaseURL() const
    70127{
    71     notImplemented();
    72     return String();
     128    GOwnPtr<gchar> fileURI(g_filename_to_uri(inspectorFilesBasePath(), 0, 0));
     129    return WebCore::filenameToString(fileURI.get());
    73130}
    74131
Note: See TracChangeset for help on using the changeset viewer.