Changeset 73324 in webkit


Ignore:
Timestamp:
Dec 3, 2010 7:19:24 PM (13 years ago)
Author:
timothy@apple.com
Message:

Make the Web Inspector window show and be usable on Mac.

https://webkit.org/b/50490

Reviewed by Sam Weinig.

  • UIProcess/WebInspectorProxy.cpp:

(WebKit::WebInspectorProxy::invalidate): Call platformClose.
(WebKit::WebInspectorProxy::didLoadInspectorPage): Call platformOpen.
(WebKit::WebInspectorProxy::didClose): Call platformClose.

  • UIProcess/WebInspectorProxy.h:
  • UIProcess/WebInspectorProxy.messages.in: Added DidClose.
  • UIProcess/mac/WebInspectorProxyMac.mm:

(-[WebInspectorProxyObjCAdapter initWithWebInspectorProxy:]): Added.
(-[WebInspectorProxyObjCAdapter windowWillClose:]): Added. Call WebInspectorProxy::close.
(WebKit::WebInspectorProxy::platformOpen): Added.
(WebKit::WebInspectorProxy::platformClose): Added.

  • UIProcess/qt/WebInspectorProxyQt.cpp:

(WebKit::WebInspectorProxy::platformOpen): Added stub.
(WebKit::WebInspectorProxy::platformClose): Added stub.

  • UIProcess/win/WebInspectorProxyWin.cpp:

(WebKit::WebInspectorProxy::platformOpen): Added stub.
(WebKit::WebInspectorProxy::platformClose): Added stub.

  • WebProcess/WebCoreSupport/WebInspectorClient.cpp:

(WebKit::WebInspectorClient::sendMessageToFrontend): Added more null checks to avoid a crash.

  • WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp:

(WebKit::WebInspectorFrontendClient::closeWindow): Call WebInspector::didClose.
(WebKit::WebInspectorFrontendClient::disconnectFromBackend): Ditto.
(WebKit::WebInspectorFrontendClient::sendMessageToBackend): Removed. This does not need to be
implemented by our subclass since we are in a single process.

  • WebProcess/WebCoreSupport/WebInspectorFrontendClient.h: Removed sendMessageToBackend.
  • WebProcess/WebPage/WebInspector.cpp:

(WebKit::WebInspector::didClose): Added. Send a DidClose message to the UI process.

  • WebProcess/WebPage/WebInspector.h:
Location:
trunk/WebKit2
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r73318 r73324  
     12010-12-03  Timothy Hatcher  <timothy@apple.com>
     2
     3        Make the Web Inspector window show and be usable on Mac.
     4
     5        https://webkit.org/b/50490
     6
     7        Reviewed by Sam Weinig.
     8
     9        * UIProcess/WebInspectorProxy.cpp:
     10        (WebKit::WebInspectorProxy::invalidate): Call platformClose.
     11        (WebKit::WebInspectorProxy::didLoadInspectorPage): Call platformOpen.
     12        (WebKit::WebInspectorProxy::didClose): Call platformClose.
     13        * UIProcess/WebInspectorProxy.h:
     14        * UIProcess/WebInspectorProxy.messages.in: Added DidClose.
     15        * UIProcess/mac/WebInspectorProxyMac.mm:
     16        (-[WebInspectorProxyObjCAdapter initWithWebInspectorProxy:]): Added.
     17        (-[WebInspectorProxyObjCAdapter windowWillClose:]): Added. Call WebInspectorProxy::close.
     18        (WebKit::WebInspectorProxy::platformOpen): Added.
     19        (WebKit::WebInspectorProxy::platformClose): Added.
     20        * UIProcess/qt/WebInspectorProxyQt.cpp:
     21        (WebKit::WebInspectorProxy::platformOpen): Added stub.
     22        (WebKit::WebInspectorProxy::platformClose): Added stub.
     23        * UIProcess/win/WebInspectorProxyWin.cpp:
     24        (WebKit::WebInspectorProxy::platformOpen): Added stub.
     25        (WebKit::WebInspectorProxy::platformClose): Added stub.
     26        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
     27        (WebKit::WebInspectorClient::sendMessageToFrontend): Added more null checks to avoid a crash.
     28        * WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp:
     29        (WebKit::WebInspectorFrontendClient::closeWindow): Call WebInspector::didClose.
     30        (WebKit::WebInspectorFrontendClient::disconnectFromBackend): Ditto.
     31        (WebKit::WebInspectorFrontendClient::sendMessageToBackend): Removed. This does not need to be
     32        implemented by our subclass since we are in a single process.
     33        * WebProcess/WebCoreSupport/WebInspectorFrontendClient.h: Removed sendMessageToBackend.
     34        * WebProcess/WebPage/WebInspector.cpp:
     35        (WebKit::WebInspector::didClose): Added. Send a DidClose message to the UI process.
     36        * WebProcess/WebPage/WebInspector.h:
     37
    1382010-12-03  Anders Carlsson  <andersca@apple.com>
    239
  • trunk/WebKit2/UIProcess/WebInspectorProxy.cpp

    r73066 r73324  
    6363void WebInspectorProxy::invalidate()
    6464{
     65    platformClose();
     66
    6567    m_page = 0;
     68
     69    m_isVisible = false;
    6670    m_isDebuggingJavaScript = false;
    6771    m_isProfilingJavaScript = false;
     
    167171void WebInspectorProxy::didLoadInspectorPage()
    168172{
    169     // FIXME: show the window or attach the inspector here.
     173    m_isVisible = true;
     174
     175    platformOpen();
     176}
     177
     178void WebInspectorProxy::didClose()
     179{
     180    platformClose();
     181
     182    m_isVisible = false;
    170183}
    171184
  • trunk/WebKit2/UIProcess/WebInspectorProxy.h

    r73066 r73324  
    3737#include <wtf/RetainPtr.h>
    3838#ifdef __OBJC__
     39@class NSWindow;
    3940@class WKView;
     41@class WebInspectorProxyObjCAdapter;
    4042#else
     43class NSWindow;
    4144class WKView;
     45class WebInspectorProxyObjCAdapter;
    4246#endif
    4347#endif
     
    96100
    97101    WebPageProxy* platformCreateInspectorPage();
     102    void platformOpen();
     103    void platformClose();
    98104
    99105    // Implemented the platform WebInspectorProxy file
     
    103109    void createInspectorPage(uint64_t& inspectorPageID, WebPageCreationParameters&);
    104110    void didLoadInspectorPage();
     111    void didClose();
    105112
    106113    static WebPageGroup* inspectorPageGroup();
     114
     115    static const unsigned minimumWindowWidth = 500;
     116    static const unsigned minimumWindowHeight = 400;
     117
     118    static const unsigned initialWindowWidth = 750;
     119    static const unsigned initialWindowHeight = 650;
    107120
    108121    WebPageProxy* m_page;
     
    116129#if PLATFORM(MAC)
    117130    RetainPtr<WKView> m_inspectorView;
     131    RetainPtr<NSWindow> m_inspectorWindow;
     132    RetainPtr<WebInspectorProxyObjCAdapter> m_inspectorProxyObjCAdapter;
    118133#endif
    119134};
  • trunk/WebKit2/UIProcess/WebInspectorProxy.messages.in

    r72666 r73324  
    2626    CreateInspectorPage() -> (uint64_t inspectorPageID, WebKit::WebPageCreationParameters inspectorPageParameters)
    2727    DidLoadInspectorPage()
     28    DidClose()
    2829}
    2930
  • trunk/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm

    r73066 r73324  
    3131#import "WKView.h"
    3232#import "WebPageProxy.h"
     33#import <WebKitSystemInterface.h>
    3334#import <wtf/text/WTFString.h>
    3435
    3536using namespace WebCore;
     37using namespace WebKit;
     38
     39// The height needed to match a typical NSToolbar.
     40static const CGFloat windowContentBorderThickness = 55;
     41
     42// WebInspectorProxyObjCAdapter is a helper ObjC object used as a delegate or notification observer
     43// for the sole purpose of getting back into the C++ code from an ObjC caller.
     44
     45@interface WebInspectorProxyObjCAdapter : NSObject <NSWindowDelegate> {
     46    WebInspectorProxy* _inspectorProxy; // Not retained to prevent cycles
     47}
     48
     49- (id)initWithWebInspectorProxy:(WebInspectorProxy*)inspectorProxy;
     50
     51@end
     52
     53@implementation WebInspectorProxyObjCAdapter
     54
     55- (id)initWithWebInspectorProxy:(WebInspectorProxy*)inspectorProxy
     56{
     57    ASSERT_ARG(inspectorProxy, inspectorProxy);
     58
     59    if (!(self = [super init]))
     60        return nil;
     61
     62    _inspectorProxy = inspectorProxy; // Not retained to prevent cycles
     63
     64    return self;
     65}
     66
     67- (void)windowWillClose:(NSNotification *)notification;
     68{
     69    _inspectorProxy->close();
     70}
     71
     72@end
    3673
    3774namespace WebKit {
     
    4885}
    4986
     87void WebInspectorProxy::platformOpen()
     88{
     89    ASSERT(!m_inspectorWindow);
     90
     91    m_inspectorProxyObjCAdapter.adoptNS([[WebInspectorProxyObjCAdapter alloc] initWithWebInspectorProxy:this]);
     92
     93    // FIXME: support opening in docked mode here.
     94
     95    NSUInteger styleMask = (NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask | NSTexturedBackgroundWindowMask);
     96    NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight) styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
     97    [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge];
     98    [window setContentBorderThickness:windowContentBorderThickness forEdge:NSMaxYEdge];
     99    [window setDelegate:m_inspectorProxyObjCAdapter.get()];
     100    [window setMinSize:NSMakeSize(minimumWindowWidth, minimumWindowHeight)];
     101    [window setReleasedWhenClosed:NO];
     102
     103    // Center the window initially before setting the frame autosave name so that the window will be in a good
     104    // position if there is no saved frame yet.
     105    [window center];
     106    [window setFrameAutosaveName:@"Web Inspector 2"];
     107
     108    WKNSWindowMakeBottomCornersSquare(window);
     109
     110    NSView *contentView = [window contentView];
     111    [m_inspectorView.get() setFrame:[contentView bounds]];
     112    [m_inspectorView.get() setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
     113    [contentView addSubview:m_inspectorView.get()];
     114
     115    [window makeKeyAndOrderFront:nil];
     116
     117    m_inspectorWindow.adoptNS(window);
     118}
     119
     120void WebInspectorProxy::platformClose()
     121{
     122    // FIXME: support closing in docked mode here.
     123
     124    [m_inspectorWindow.get() setDelegate:nil];
     125    [m_inspectorWindow.get() orderOut:nil];
     126
     127    m_inspectorWindow = 0;
     128    m_inspectorView = 0;
     129    m_inspectorProxyObjCAdapter = 0;
     130}
     131
    50132String WebInspectorProxy::inspectorPageURL() const
    51133{
  • trunk/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp

    r72666 r73324  
    4141}
    4242
     43void WebInspectorProxy::platformOpen()
     44{
     45    notImplemented();
     46}
     47
     48void WebInspectorProxy::platformClose()
     49{
     50    notImplemented();
     51}
     52
    4353String WebInspectorProxy::inspectorPageURL() const
    4454{
  • trunk/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp

    r72666 r73324  
    4141}
    4242
     43void WebInspectorProxy::platformOpen()
     44{
     45    notImplemented();
     46}
     47
     48void WebInspectorProxy::platformClose()
     49{
     50    notImplemented();
     51}
     52
    4353String WebInspectorProxy::inspectorPageURL() const
    4454{
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp

    r72666 r73324  
    7777bool WebInspectorClient::sendMessageToFrontend(const String& message)
    7878{
    79     if (WebPage* inspectorPage = m_page->inspector()->inspectorPage())
    80         return doDispatchMessageOnFrontendPage(inspectorPage->corePage(), message);
    81     return false;
     79    WebInspector* inspector = m_page->inspector();
     80    if (!inspector)
     81        return false;
     82    WebPage* inspectorPage = inspector->inspectorPage();
     83    if (!inspectorPage)
     84        return false;
     85    return doDispatchMessageOnFrontendPage(inspectorPage->corePage(), message);
    8286}
    8387
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp

    r72666 r73324  
    7171void WebInspectorFrontendClient::closeWindow()
    7272{
    73     notImplemented();
     73    m_page->inspector()->didClose();
    7474}
    7575
    7676void WebInspectorFrontendClient::disconnectFromBackend()
    7777{
    78     notImplemented();
     78    m_page->inspector()->didClose();
    7979}
    8080
     
    9999}
    100100
    101 void WebInspectorFrontendClient::sendMessageToBackend(const String&)
    102 {
    103     notImplemented();
    104 }
    105 
    106101} // namespace WebKit
    107102
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.h

    r72666 r73324  
    5555    virtual void inspectedURLChanged(const String&);
    5656
    57     virtual void sendMessageToBackend(const String&);
    58 
    5957    WebPage* m_page;
    6058};
  • trunk/WebKit2/WebProcess/WebPage/WebInspector.cpp

    r72666 r73324  
    7676}
    7777
     78void WebInspector::didClose()
     79{
     80    WebProcess::shared().connection()->send(Messages::WebInspectorProxy::DidClose(), m_page->pageID());
     81}
     82
    7883// Called by WebInspector messages
    7984void WebInspector::show()
  • trunk/WebKit2/WebProcess/WebPage/WebInspector.h

    r72666 r73324  
    5959    // Called from WebInspectorFrontendClient
    6060    void didLoadInspectorPage();
     61    void didClose();
    6162
    6263    // Implemented in platform WebInspector file
Note: See TracChangeset for help on using the changeset viewer.