Make the docked Web Inspector resizable.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Aug 2008 18:10:36 +0000 (18:10 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Aug 2008 18:10:36 +0000 (18:10 +0000)
WebCore:

2008-08-12  Timothy Hatcher  <timothy@apple.com>

        Make the docked Web Inspector resizable. This is the cross platform
        portion of the code. Each InspectorClient needs to implement the
        real resize code.

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

        Reviewed by Kevin McCullough.

        * loader/EmptyClients.h: Added an empty setAttachedWindowHeight.
        * page/InspectorClient.h: Added setAttachedWindowHeight.
        * page/InspectorController.cpp:
        (WebCore::setAttachedWindowHeight): Call setAttachedWindowHeight
        on the InspectorController.
        (WebCore::InspectorController::setAttachedWindowHeight): Call
        setAttachedWindowHeight on the client.
        (WebCore::InspectorController::windowScriptObjectAvailable):
        Added setAttachedWindowHeight to the script class.
        * page/InspectorController.h:
        * page/inspector/inspector.css: Make the cursor on the toolbar be
        row-resize when docked.
        * page/inspector/inspector.js:
        (WebInspector.loaded): Always add the toolbarDragStart event listener.
        (WebInspector.toolbarDragStart): Return early if we are not attached
        and not on Leopard. Call WebInspector.elementDragStart.
        (WebInspector.toolbarDragEnd): Call WebInspector.elementDragEnd.
        (WebInspector.toolbarDrag): When attached call setAttachedWindowHeight,
        otherwise call moveByUnrestricted.

WebKit/gtk:

2008-08-12  Timothy Hatcher  <timothy@apple.com>

        Add a stub for InspectorClient::setAttachedWindowHeight.

        * WebCoreSupport/InspectorClientGtk.cpp:
        (WebKit::InspectorClient::setAttachedWindowHeight):
        Call notImplemented().
        * WebCoreSupport/InspectorClientGtk.h:

WebKit/mac:

2008-08-12  Timothy Hatcher  <timothy@apple.com>

        Make the docked Web Inspector resizable.

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

        Reviewed by Kevin McCullough.

        * WebCoreSupport/WebInspectorClient.h:
        * WebCoreSupport/WebInspectorClient.mm:
        (WebInspectorClient::setAttachedWindowHeight): Call setAttachedWindowHeight:
        on the WebInspectorWindowController.
        (-[WebInspectorWindowController showWindow:]): Call setAttachedWindowHeight:.
        (-[WebInspectorWindowController setAttachedWindowHeight:]): Moved code
        from showWindow: and generalized to allow being called multiple times.
        Remembers the last height passed, which is used by showWindow: the next
        time the Inspector attaches.

WebKit/qt:

2008-08-12  Timothy Hatcher  <timothy@apple.com>

        Add a stub for InspectorClient::setAttachedWindowHeight.

        * WebCoreSupport/InspectorClientQt.cpp:
        (WebCore::InspectorClientQt::setAttachedWindowHeight):
        Call notImplemented().
        * WebCoreSupport/InspectorClientQt.h:

WebKit/win:

2008-08-12  Timothy Hatcher  <timothy@apple.com>

        Add a stub for InspectorClient::setAttachedWindowHeight.

        * WebCoreSupport/WebInspectorClient.cpp:
        (WebInspectorClient::setAttachedWindowHeight): Add a FIXME to implement this.
        * WebCoreSupport/WebInspectorClient.h:

WebKit/wx:

2008-08-12  Timothy Hatcher  <timothy@apple.com>

        Add a stub for InspectorClient::setAttachedWindowHeight.

        * WebKitSupport/InspectorClientWx.cpp:
        (WebCore::InspectorClientWx::setAttachedWindowHeight):
        Call notImplemented().
        * WebKitSupport/InspectorClientWx.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@35719 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/loader/EmptyClients.h
WebCore/page/InspectorClient.h
WebCore/page/InspectorController.cpp
WebCore/page/InspectorController.h
WebCore/page/inspector/inspector.css
WebCore/page/inspector/inspector.js
WebKit/gtk/ChangeLog
WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp
WebKit/gtk/WebCoreSupport/InspectorClientGtk.h
WebKit/mac/ChangeLog
WebKit/mac/WebCoreSupport/WebInspectorClient.h
WebKit/mac/WebCoreSupport/WebInspectorClient.mm
WebKit/qt/ChangeLog
WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
WebKit/qt/WebCoreSupport/InspectorClientQt.h
WebKit/win/ChangeLog
WebKit/win/WebCoreSupport/WebInspectorClient.cpp
WebKit/win/WebCoreSupport/WebInspectorClient.h
WebKit/wx/ChangeLog
WebKit/wx/WebKitSupport/InspectorClientWx.cpp
WebKit/wx/WebKitSupport/InspectorClientWx.h

index 08e7e80..a867193 100644 (file)
@@ -1,3 +1,33 @@
+2008-08-12  Timothy Hatcher  <timothy@apple.com>
+
+        Make the docked Web Inspector resizable. This is the cross platform
+        portion of the code. Each InspectorClient needs to implement the
+        real resize code.
+
+        https://bugs.webkit.org/show_bug.cgi?id=14282
+
+        Reviewed by Kevin McCullough.
+
+        * loader/EmptyClients.h: Added an empty setAttachedWindowHeight.
+        * page/InspectorClient.h: Added setAttachedWindowHeight.
+        * page/InspectorController.cpp:
+        (WebCore::setAttachedWindowHeight): Call setAttachedWindowHeight
+        on the InspectorController.
+        (WebCore::InspectorController::setAttachedWindowHeight): Call
+        setAttachedWindowHeight on the client.
+        (WebCore::InspectorController::windowScriptObjectAvailable):
+        Added setAttachedWindowHeight to the script class.
+        * page/InspectorController.h:
+        * page/inspector/inspector.css: Make the cursor on the toolbar be
+        row-resize when docked.
+        * page/inspector/inspector.js:
+        (WebInspector.loaded): Always add the toolbarDragStart event listener.
+        (WebInspector.toolbarDragStart): Return early if we are not attached
+        and not on Leopard. Call WebInspector.elementDragStart.
+        (WebInspector.toolbarDragEnd): Call WebInspector.elementDragEnd.
+        (WebInspector.toolbarDrag): When attached call setAttachedWindowHeight,
+        otherwise call moveByUnrestricted.
+
 2008-08-13  Simon Hausmann  <hausmann@webkit.org>
 
         Reviewed by Holger.
index 489fb0d..e9a1f41 100644 (file)
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
                        projectRoot = "";
-                       projectRoots = (
-                               "",
-                       );
                        targets = (
                                93F198A508245E59001E9ABC /* WebCore */,
                                DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
index fcd49a4..df3af1a 100644 (file)
@@ -395,6 +395,8 @@ public:
     virtual void attachWindow() {};
     virtual void detachWindow() {};
 
+    virtual void setAttachedWindowHeight(unsigned) {};
+
     virtual void highlight(Node*) {};
     virtual void hideHighlight() {};
     virtual void inspectedURLChanged(const String& newURL) {};
index ec1ee92..9ee4a26 100644 (file)
@@ -48,6 +48,8 @@ public:
     virtual void attachWindow() = 0;
     virtual void detachWindow() = 0;
 
+    virtual void setAttachedWindowHeight(unsigned height) = 0;
+
     virtual void highlight(Node*) = 0;
     virtual void hideHighlight() = 0;
 
index 01826a4..9cd07a9 100644 (file)
@@ -779,6 +779,24 @@ static JSValueRef moveByUnrestricted(JSContextRef ctx, JSObjectRef /*function*/,
     return JSValueMakeUndefined(ctx);
 }
 
+static JSValueRef setAttachedWindowHeight(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    InspectorController* controller = reinterpret_cast<InspectorController*>(JSObjectGetPrivate(thisObject));
+    if (!controller)
+        return JSValueMakeUndefined(ctx);
+
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(ctx);
+
+    unsigned height = static_cast<unsigned>(JSValueToNumber(ctx, arguments[0], exception));
+    if (exception && *exception)
+        return JSValueMakeUndefined(ctx);
+
+    controller->setAttachedWindowHeight(height);
+
+    return JSValueMakeUndefined(ctx);
+}
+
 static JSValueRef wrapCallback(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     InspectorController* controller = reinterpret_cast<InspectorController*>(JSObjectGetPrivate(thisObject));
@@ -1297,6 +1315,13 @@ void InspectorController::detachWindow()
     m_client->detachWindow();
 }
 
+void InspectorController::setAttachedWindowHeight(unsigned height)
+{
+    if (!enabled())
+        return;
+    m_client->setAttachedWindowHeight(height);
+}
+
 void InspectorController::inspectedWindowScriptObjectCleared(Frame* frame)
 {
     if (!enabled() || !m_scriptContext || !m_scriptObject)
@@ -1339,6 +1364,7 @@ void InspectorController::windowScriptObjectAvailable()
         { "localizedStringsURL", localizedStrings, kJSPropertyAttributeNone },
         { "platform", platform, kJSPropertyAttributeNone },
         { "moveByUnrestricted", moveByUnrestricted, kJSPropertyAttributeNone },
+        { "setAttachedWindowHeight", WebCore::setAttachedWindowHeight, kJSPropertyAttributeNone },
         { "wrapCallback", wrapCallback, kJSPropertyAttributeNone },
         { "startDebuggingAndReloadInspectedPage", WebCore::startDebuggingAndReloadInspectedPage, kJSPropertyAttributeNone },
         { "stopDebugging", WebCore::stopDebugging, kJSPropertyAttributeNone },
index 56974c9..171134c 100644 (file)
@@ -119,6 +119,8 @@ public:
     void attachWindow();
     void detachWindow();
 
+    void setAttachedWindowHeight(unsigned height);
+
     JSContextRef scriptContext() const { return m_scriptContext; };
     void setScriptContext(JSContextRef context) { m_scriptContext = context; };
 
index 24fc0db..3911118 100644 (file)
@@ -89,6 +89,7 @@ body.detached.platform-mac-leopard #toolbar {
 body.attached #toolbar {
     height: 34px;
     border-top: 1px solid rgb(100, 100, 100);
+    cursor: row-resize;
 }
 
 body.attached.inactive #toolbar {
index d2d5fb9..1c74012 100644 (file)
@@ -343,8 +343,7 @@ WebInspector.loaded = function()
     var searchField = document.getElementById("search");
     searchField.addEventListener("keyup", this.performSearch.bind(this), false);
 
-    if (platform === "mac-leopard")
-        document.getElementById("toolbar").addEventListener("mousedown", this.toolbarDragStart, true);
+    document.getElementById("toolbar").addEventListener("mousedown", this.toolbarDragStart, true);
 
     InspectorController.loaded();
 }
@@ -583,7 +582,7 @@ WebInspector.toggleAttach = function()
 
 WebInspector.toolbarDragStart = function(event)
 {
-    if (WebInspector.attached)
+    if (!WebInspector.attached && InspectorController.platform() !== "mac-leopard")
         return;
 
     var target = event.target;
@@ -597,40 +596,39 @@ WebInspector.toolbarDragStart = function(event)
     toolbar.lastScreenX = event.screenX;
     toolbar.lastScreenY = event.screenY;
 
-    document.addEventListener("mousemove", WebInspector.toolbarDrag, true);
-    document.addEventListener("mouseup", WebInspector.toolbarDragEnd, true);
-    document.body.style.cursor = "default";
-
-    event.preventDefault();
+    WebInspector.elementDragStart(toolbar, WebInspector.toolbarDrag, WebInspector.toolbarDragEnd, event, (WebInspector.attached ? "row-resize" : "default"));
 }
 
 WebInspector.toolbarDragEnd = function(event)
 {
     var toolbar = document.getElementById("toolbar");
-    delete toolbar.lastScreenX;
-    delete toolbar.lastScreenY;
 
-    document.removeEventListener("mousemove", WebInspector.toolbarDrag, true);
-    document.removeEventListener("mouseup", WebInspector.toolbarDragEnd, true);
-    document.body.style.removeProperty("cursor");
+    WebInspector.elementDragEnd(event);
 
-    event.preventDefault();
+    delete toolbar.lastScreenX;
+    delete toolbar.lastScreenY;
 }
 
 WebInspector.toolbarDrag = function(event)
 {
     var toolbar = document.getElementById("toolbar");
 
-    var x = event.screenX - toolbar.lastScreenX;
-    var y = event.screenY - toolbar.lastScreenY;
+    if (WebInspector.attached) {
+        var height = window.innerHeight - (event.screenY - toolbar.lastScreenY);
+
+        InspectorController.setAttachedWindowHeight(height);
+    } else {
+        var x = event.screenX - toolbar.lastScreenX;
+        var y = event.screenY - toolbar.lastScreenY;
+
+        // We cannot call window.moveBy here because it restricts the movement
+        // of the window at the edges.
+        InspectorController.moveByUnrestricted(x, y);
+    }
 
     toolbar.lastScreenX = event.screenX;
     toolbar.lastScreenY = event.screenY;
 
-    // We cannot call window.moveBy here because it restricts the movement of the window
-    // at the edges.
-    InspectorController.moveByUnrestricted(x, y);
-
     event.preventDefault();
 }
 
index 595a14f..4bacae5 100644 (file)
@@ -1,3 +1,12 @@
+2008-08-12  Timothy Hatcher  <timothy@apple.com>
+
+        Add a stub for InspectorClient::setAttachedWindowHeight.
+
+        * WebCoreSupport/InspectorClientGtk.cpp:
+        (WebKit::InspectorClient::setAttachedWindowHeight):
+        Call notImplemented().
+        * WebCoreSupport/InspectorClientGtk.h:
+
 2008-08-10  Alp Toker  <alp@nuanti.com>
 
         Remove leftover qmake/GTK+ build files.
index a54b6a0..1a72261 100644 (file)
@@ -61,6 +61,11 @@ void InspectorClient::detachWindow()
     notImplemented();
 }
 
+void InspectorClient::setAttachedWindowHeight(unsigned height)
+{
+    notImplemented();
+}
+
 void InspectorClient::highlight(Node* node)
 {
     notImplemented();
index 9afd42b..ff60fab 100644 (file)
@@ -53,6 +53,8 @@ namespace WebKit {
         virtual void attachWindow();
         virtual void detachWindow();
 
+        virtual void setAttachedWindowHeight(unsigned height);
+
         virtual void highlight(WebCore::Node*);
         virtual void hideHighlight();
         virtual void inspectedURLChanged(const WebCore::String& newURL);
index f28a2fb..ccf406b 100644 (file)
@@ -1,5 +1,23 @@
 2008-08-12  Timothy Hatcher  <timothy@apple.com>
 
+        Make the docked Web Inspector resizable.
+
+        https://bugs.webkit.org/show_bug.cgi?id=14282
+
+        Reviewed by Kevin McCullough.
+
+        * WebCoreSupport/WebInspectorClient.h:
+        * WebCoreSupport/WebInspectorClient.mm:
+        (WebInspectorClient::setAttachedWindowHeight): Call setAttachedWindowHeight:
+        on the WebInspectorWindowController.
+        (-[WebInspectorWindowController showWindow:]): Call setAttachedWindowHeight:.
+        (-[WebInspectorWindowController setAttachedWindowHeight:]): Moved code
+        from showWindow: and generalized to allow being called multiple times.
+        Remembers the last height passed, which is used by showWindow: the next
+        time the Inspector attaches.
+
+2008-08-12  Timothy Hatcher  <timothy@apple.com>
+
         Remove unneeded header imports from some Web Inspector files.
 
         Reviewed by Adam Roben.
index 45cd1f9..5554c07 100644 (file)
@@ -49,6 +49,8 @@ public:
     virtual void attachWindow();
     virtual void detachWindow();
 
+    virtual void setAttachedWindowHeight(unsigned height);
+
     virtual void highlight(WebCore::Node*);
     virtual void hideHighlight();
     virtual void inspectedURLChanged(const WebCore::String& newURL);
index d6f7d83..127c805 100644 (file)
@@ -57,6 +57,7 @@ using namespace WebCore;
 - (WebView *)webView;
 - (void)attach;
 - (void)detach;
+- (void)setAttachedWindowHeight:(unsigned)height;
 - (void)highlightAndScrollToNode:(DOMNode *)node;
 - (void)highlightNode:(DOMNode *)node;
 - (void)hideHighlight;
@@ -112,6 +113,11 @@ void WebInspectorClient::detachWindow()
     [m_windowController.get() detach];
 }
 
+void WebInspectorClient::setAttachedWindowHeight(unsigned height)
+{
+    [m_windowController.get() setAttachedWindowHeight:height];
+}
+
 void WebInspectorClient::highlight(Node* node)
 {
     [m_windowController.get() highlightAndScrollToNode:kit(node)];
@@ -289,21 +295,15 @@ void WebInspectorClient::updateWindowTitle() const
     if (_shouldAttach) {
         WebFrameView *frameView = [[_inspectedWebView mainFrame] frameView];
 
-        NSRect frameViewRect = [frameView frame];
-        float attachedHeight = [[NSUserDefaults standardUserDefaults] integerForKey:WebKitInspectorAttachedViewHeightKey];
-        attachedHeight = MAX(300.0, MIN(attachedHeight, (NSHeight(frameViewRect) * 0.6)));
-        frameViewRect = NSMakeRect(0, attachedHeight, NSWidth(frameViewRect), NSHeight(frameViewRect) - attachedHeight);
-
         [_webView removeFromSuperview];
-        [_inspectedWebView addSubview:_webView positioned:NSWindowBelow relativeTo:(NSView*)frameView];
+        [_inspectedWebView addSubview:_webView positioned:NSWindowBelow relativeTo:(NSView *)frameView];
 
         [_webView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable | NSViewMaxYMargin)];
-        [_webView setFrame:NSMakeRect(0, 0, NSWidth(frameViewRect), attachedHeight)];
-
         [frameView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable | NSViewMinYMargin)];
-        [frameView setFrame:frameViewRect];
 
         _attachedToInspectedWebView = YES;
+
+        [self setAttachedWindowHeight:[[NSUserDefaults standardUserDefaults] integerForKey:WebKitInspectorAttachedViewHeightKey]];
     } else {
         _attachedToInspectedWebView = NO;
 
@@ -349,6 +349,23 @@ void WebInspectorClient::updateWindowTitle() const
     _movingWindows = NO;
 }
 
+- (void)setAttachedWindowHeight:(unsigned)height
+{
+    [[NSUserDefaults standardUserDefaults] setInteger:height forKey:WebKitInspectorAttachedViewHeightKey];
+
+    if (!_attachedToInspectedWebView)
+        return;
+
+    WebFrameView *frameView = [[_inspectedWebView mainFrame] frameView];
+    NSRect frameViewRect = [frameView frame];
+
+    CGFloat attachedHeight = round(MAX(250.0, MIN(height, (NSHeight([_inspectedWebView frame]) * 0.75))));
+    frameViewRect = NSMakeRect(0.0, attachedHeight, NSWidth(frameViewRect), NSHeight([_inspectedWebView frame]) - attachedHeight);
+
+    [_webView setFrame:NSMakeRect(0.0, 0.0, NSWidth(frameViewRect), attachedHeight)];
+    [frameView setFrame:frameViewRect];
+}
+
 #pragma mark -
 
 - (void)highlightAndScrollToNode:(DOMNode *)node
index 51b106f..a1c9f72 100644 (file)
@@ -1,3 +1,12 @@
+2008-08-12  Timothy Hatcher  <timothy@apple.com>
+
+        Add a stub for InspectorClient::setAttachedWindowHeight.
+
+        * WebCoreSupport/InspectorClientQt.cpp:
+        (WebCore::InspectorClientQt::setAttachedWindowHeight):
+        Call notImplemented().
+        * WebCoreSupport/InspectorClientQt.h:
+
 2008-08-13  Ariya Hidayat  <ariya.hidayat@trolltech.com>
 
         Reviewed by Simon.
index 8e7422a..6854de4 100644 (file)
@@ -154,6 +154,11 @@ void InspectorClientQt::detachWindow()
     notImplemented();
 }
 
+void InspectorClientQt::setAttachedWindowHeight(unsigned height)
+{
+    notImplemented();
+}
+
 void InspectorClientQt::highlight(Node* node)
 {
     notImplemented();
index bc0fccd..0f30b91 100644 (file)
@@ -58,6 +58,8 @@ namespace WebCore {
         virtual void attachWindow();
         virtual void detachWindow();
 
+        virtual void setAttachedWindowHeight(unsigned height);
+
         virtual void highlight(Node*);
         virtual void hideHighlight();
         virtual void inspectedURLChanged(const String& newURL);
index 443e960..1297dd4 100644 (file)
@@ -1,3 +1,11 @@
+2008-08-12  Timothy Hatcher  <timothy@apple.com>
+
+        Add a stub for InspectorClient::setAttachedWindowHeight.
+
+        * WebCoreSupport/WebInspectorClient.cpp:
+        (WebInspectorClient::setAttachedWindowHeight): Add a FIXME to implement this.
+        * WebCoreSupport/WebInspectorClient.h:
+
 2008-08-12  Adam Roben  <aroben@apple.com>
 
         Export WTFLog in Debug builds
index fce9b0c..242a52f 100644 (file)
@@ -267,6 +267,11 @@ void WebInspectorClient::detachWindow()
         m_highlight->update();
 }
 
+void WebInspectorClient::setAttachedWindowHeight(unsigned height)
+{
+    // FIXME: implement this.
+}
+
 void WebInspectorClient::highlight(Node*)
 {
     bool creatingHighlight = !m_highlight;
index 4759284..902f3fb 100644 (file)
@@ -57,6 +57,8 @@ public:
     virtual void attachWindow();
     virtual void detachWindow();
 
+    virtual void setAttachedWindowHeight(unsigned height);
+
     virtual void highlight(WebCore::Node*);
     virtual void hideHighlight();
 
index d9b1935..2ef2086 100644 (file)
@@ -1,3 +1,12 @@
+2008-08-12  Timothy Hatcher  <timothy@apple.com>
+
+        Add a stub for InspectorClient::setAttachedWindowHeight.
+
+        * WebKitSupport/InspectorClientWx.cpp:
+        (WebCore::InspectorClientWx::setAttachedWindowHeight):
+        Call notImplemented().
+        * WebKitSupport/InspectorClientWx.h:
+
 2008-08-06  Kevin Watters  <kevinwatters@gmail.com>
 
         Reviewed by Kevin Ollivier.
index e77a068..d5f236b 100644 (file)
@@ -79,6 +79,11 @@ void InspectorClientWx::detachWindow()
     notImplemented();
 }
 
+void InspectorClientWx::setAttachedWindowHeight(unsigned height)
+{
+    notImplemented();
+}
+
 void InspectorClientWx::highlight(Node*)
 {
     notImplemented();
index 5616278..9ea3aed 100644 (file)
@@ -51,6 +51,8 @@ public:
     virtual void attachWindow();
     virtual void detachWindow();
 
+    virtual void setAttachedWindowHeight(unsigned height);
+
     virtual void highlight(Node*);
     virtual void hideHighlight();