Changeset 73877 in webkit


Ignore:
Timestamp:
Dec 12, 2010 12:15:51 PM (13 years ago)
Author:
bweinstein@apple.com
Message:

Web Inspector: Make inspector on Windows show and be usable in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=50877

Reviewed by Sam Weinig.

Hook up the unimplemented methods in WebInspectorProxyWin to get the web inspector
showing and usable in WebKit2 on Windows.

  • UIProcess/WebInspectorProxy.cpp:

(WebKit::WebInspectorProxy::WebInspectorProxy): Initialize Windows-specific variables to 0.

  • UIProcess/WebInspectorProxy.h:
  • UIProcess/win/WebInspectorProxyWin.cpp:

(WebKit::WebInspectorProxy::registerInspectorViewWindowClass): Sets up the inspector view class.
(WebKit::WebInspectorProxy::InspectorViewWndProc): Calls through to the WebInspectorProxy's non-static

WndProc.

(WebKit::WebInspectorProxy::wndProc): Handles WM_SIZE, WM_CLOSE, and WM_GETMINMAXINFO, the rest go to

::DefWindowProc.

(WebKit::WebInspectorProxy::onSizeEvent): Resize the WKView that has the inspector page to match the

outer window that was just resized.

(WebKit::WebInspectorProxy::onMinMaxInfoEvent): Set the minimum size the window can be resized to.
(WebKit::WebInspectorProxy::onCloseEvent): Hide the window, and call WebInspectorProxy::close.
(WebKit::WebInspectorProxy::platformCreateInspectorPage): Create a WKView and return its page.
(WebKit::WebInspectorProxy::platformOpen): Create an HWND for the inspector, put the inspector's WKView

inside of it, and show the window.

(WebKit::WebInspectorProxy::platformClose): Destroy the inspector's window (which destroys the child WKView),

and 0 out instance variables.

(WebKit::WebInspectorProxy::inspectorPageURL): Finds inspector/inspector.html in the WebKit bundle.

Location:
trunk/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r73876 r73877  
     12010-12-11  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Web Inspector: Make inspector on Windows show and be usable in WebKit2
     6        https://bugs.webkit.org/show_bug.cgi?id=50877
     7       
     8        Hook up the unimplemented methods in WebInspectorProxyWin to get the web inspector
     9        showing and usable in WebKit2 on Windows.
     10
     11        * UIProcess/WebInspectorProxy.cpp:
     12        (WebKit::WebInspectorProxy::WebInspectorProxy): Initialize Windows-specific variables to 0.
     13        * UIProcess/WebInspectorProxy.h:
     14        * UIProcess/win/WebInspectorProxyWin.cpp:
     15        (WebKit::WebInspectorProxy::registerInspectorViewWindowClass): Sets up the inspector view class.
     16        (WebKit::WebInspectorProxy::InspectorViewWndProc): Calls through to the WebInspectorProxy's non-static
     17            WndProc.
     18        (WebKit::WebInspectorProxy::wndProc): Handles WM_SIZE, WM_CLOSE, and WM_GETMINMAXINFO, the rest go to
     19            ::DefWindowProc.
     20        (WebKit::WebInspectorProxy::onSizeEvent): Resize the WKView that has the inspector page to match the
     21            outer window that was just resized.
     22        (WebKit::WebInspectorProxy::onMinMaxInfoEvent): Set the minimum size the window can be resized to.
     23        (WebKit::WebInspectorProxy::onCloseEvent): Hide the window, and call WebInspectorProxy::close.
     24        (WebKit::WebInspectorProxy::platformCreateInspectorPage): Create a WKView and return its page.
     25        (WebKit::WebInspectorProxy::platformOpen): Create an HWND for the inspector, put the inspector's WKView
     26            inside of it, and show the window.
     27        (WebKit::WebInspectorProxy::platformClose): Destroy the inspector's window (which destroys the child WKView),
     28            and 0 out instance variables.
     29        (WebKit::WebInspectorProxy::inspectorPageURL): Finds inspector/inspector.html in the WebKit bundle.
     30
    1312010-12-12  Balazs Kelemen  <kbalazs@webkit.org>
    232
  • trunk/WebKit2/UIProcess/WebInspectorProxy.cpp

    r73324 r73877  
    5454    , m_isProfilingJavaScript(false)
    5555    , m_isProfilingPage(false)
     56#if PLATFORM(WIN)
     57    , m_inspectorWindow(0)
     58    , m_inspectorView(0)
     59#endif
    5660{
    5761}
  • trunk/WebKit2/UIProcess/WebInspectorProxy.h

    r73324 r73877  
    5252class WebPageProxy;
    5353struct WebPageCreationParameters;
     54
     55#if PLATFORM(WIN)
     56class WebView;
     57#endif
    5458
    5559class WebInspectorProxy : public APIObject {
     
    113117    static WebPageGroup* inspectorPageGroup();
    114118
     119#if PLATFORM(WIN)
     120    static bool registerInspectorViewWindowClass();
     121    static LRESULT CALLBACK InspectorViewWndProc(HWND, UINT, WPARAM, LPARAM);
     122    LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
     123
     124    LRESULT onSizeEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
     125    LRESULT onMinMaxInfoEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
     126    LRESULT onCloseEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
     127#endif
     128
    115129    static const unsigned minimumWindowWidth = 500;
    116130    static const unsigned minimumWindowHeight = 400;
     
    131145    RetainPtr<NSWindow> m_inspectorWindow;
    132146    RetainPtr<WebInspectorProxyObjCAdapter> m_inspectorProxyObjCAdapter;
     147#elif PLATFORM(WIN)
     148    HWND m_inspectorWindow;
     149    WebView* m_inspectorView;
    133150#endif
    134151};
  • trunk/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp

    r73324 r73877  
    2828#if ENABLE(INSPECTOR)
    2929
     30#include "WebPageProxy.h"
     31#include "WebView.h"
     32#include <WebCore/WebCoreInstanceHandle.h>
     33#include <wtf/PassRefPtr.h>
    3034#include <wtf/text/WTFString.h>
    3135
    32 #define DISABLE_NOT_IMPLEMENTED_WARNINGS 1
    33 #include "NotImplemented.h"
     36using namespace WebCore;
    3437
    3538namespace WebKit {
    3639
     40static const LPCWSTR kWebKit2InspectorWindowClassName = L"WebKit2InspectorWindowClass";
     41
     42bool WebInspectorProxy::registerInspectorViewWindowClass()
     43{
     44    static bool haveRegisteredWindowClass = false;
     45    if (haveRegisteredWindowClass)
     46        return true;
     47    haveRegisteredWindowClass = true;
     48
     49    WNDCLASSEX wcex;
     50
     51    wcex.cbSize = sizeof(WNDCLASSEX);
     52    wcex.style          = CS_DBLCLKS;
     53    wcex.lpfnWndProc    = WebInspectorProxy::InspectorViewWndProc;
     54    wcex.cbClsExtra     = 0;
     55    wcex.cbWndExtra     = sizeof(WebInspectorProxy*);
     56    wcex.hInstance      = instanceHandle();
     57    wcex.hIcon          = 0;
     58    wcex.hCursor        = ::LoadCursor(0, IDC_ARROW);
     59    wcex.hbrBackground  = 0;
     60    wcex.lpszMenuName   = 0;
     61    wcex.lpszClassName  = kWebKit2InspectorWindowClassName;
     62    wcex.hIconSm        = 0;
     63
     64    return !!::RegisterClassEx(&wcex);
     65}
     66
     67LRESULT CALLBACK WebInspectorProxy::InspectorViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
     68{
     69    LONG_PTR longPtr = ::GetWindowLongPtr(hWnd, 0);
     70   
     71    if (WebInspectorProxy* inspectorView = reinterpret_cast<WebInspectorProxy*>(longPtr))
     72        return inspectorView->wndProc(hWnd, message, wParam, lParam);
     73
     74    if (message == WM_CREATE) {
     75        LPCREATESTRUCT createStruct = reinterpret_cast<LPCREATESTRUCT>(lParam);
     76
     77        // Associate the WebInspectorProxy with the window.
     78        ::SetWindowLongPtr(hWnd, 0, (LONG_PTR)createStruct->lpCreateParams);
     79        return 0;
     80    }
     81
     82    return ::DefWindowProc(hWnd, message, wParam, lParam);
     83}
     84
     85LRESULT WebInspectorProxy::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
     86{
     87    LRESULT lResult = 0;
     88    bool handled = true;
     89
     90    switch (message) {
     91    case WM_SIZE:
     92        lResult = onSizeEvent(hWnd, message, wParam, lParam, handled);
     93        break;
     94    case WM_GETMINMAXINFO:
     95        lResult = onMinMaxInfoEvent(hWnd, message, wParam, lParam, handled);
     96        break;
     97    case WM_CLOSE:
     98        lResult = onCloseEvent(hWnd, message, wParam, lParam, handled);
     99        break;
     100    default:
     101        handled = false;
     102        break;
     103    }
     104
     105    if (!handled)
     106        lResult = ::DefWindowProc(hWnd, message, wParam, lParam);
     107
     108    return lResult;
     109}
     110
     111LRESULT WebInspectorProxy::onSizeEvent(HWND, UINT, WPARAM, LPARAM, bool&)
     112{
     113    RECT rect;
     114    ::GetClientRect(m_inspectorWindow, &rect);
     115
     116    ::SetWindowPos(m_inspectorView->window(), 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER);
     117
     118    return 0;
     119}
     120
     121LRESULT WebInspectorProxy::onMinMaxInfoEvent(HWND, UINT, WPARAM, LPARAM lParam, bool&)
     122{
     123    MINMAXINFO* info = reinterpret_cast<MINMAXINFO*>(lParam);
     124    POINT size = {minimumWindowWidth, minimumWindowHeight};
     125    info->ptMinTrackSize = size;
     126
     127    return 0;
     128}
     129
     130LRESULT WebInspectorProxy::onCloseEvent(HWND, UINT, WPARAM, LPARAM, bool&)
     131{
     132    ::ShowWindow(m_inspectorWindow, SW_HIDE);
     133    close();
     134
     135    return 0;
     136}
     137
    37138WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
    38139{
    39     notImplemented();
    40     return 0;
     140    ASSERT(!m_inspectorView);
     141    ASSERT(!m_inspectorWindow);
     142
     143    RECT emptyRect = {0};
     144    m_inspectorView = WebView::create(emptyRect, m_page->pageNamespace(), inspectorPageGroup(), 0).leakRef();
     145   
     146    return m_inspectorView->page();
    41147}
    42148
    43149void WebInspectorProxy::platformOpen()
    44150{
    45     notImplemented();
     151    registerInspectorViewWindowClass();
     152
     153    m_inspectorWindow = ::CreateWindowEx(0, kWebKit2InspectorWindowClassName, 0, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
     154        0, 0, initialWindowWidth, initialWindowHeight, 0, 0, instanceHandle(), this);
     155    ASSERT(::IsWindow(m_inspectorWindow));
     156
     157    m_inspectorView->setParentWindow(m_inspectorWindow);
     158    ::ShowWindow(m_inspectorWindow, SW_SHOW);
    46159}
    47160
    48161void WebInspectorProxy::platformClose()
    49162{
    50     notImplemented();
     163    ASSERT(m_inspectorWindow);
     164    ASSERT(m_inspectorView);
     165
     166    ::DestroyWindow(m_inspectorWindow);
     167
     168    m_inspectorWindow = 0;
     169    m_inspectorView = 0;
    51170}
    52171
    53172String WebInspectorProxy::inspectorPageURL() const
    54173{
    55     notImplemented();
    56     return String();
     174    RetainPtr<CFURLRef> htmlURLRef(AdoptCF, CFBundleCopyResourceURL(CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit")), CFSTR("inspector"), CFSTR("html"), CFSTR("inspector")));
     175    if (!htmlURLRef)
     176        return String();
     177
     178    return String(CFURLGetString(htmlURLRef.get()));
    57179}
    58180
Note: See TracChangeset for help on using the changeset viewer.