Remember the docked state of the Web Inspector, so it can be reopened docked if it...
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Aug 2008 18:11:01 +0000 (18:11 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Aug 2008 18:11:01 +0000 (18:11 +0000)
WebCore:

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

        Changed the InspectorController so it can be notified when the
        attached state of the Inspector changes in WebKit.

        Reviewed by Kevin McCullough.

        * WebCore.base.exp: Updated the symbol for setWindowVisible.
        * page/InspectorController.cpp:
        (WebCore::InspectorController::setWindowVisible): Added an attached argument,
        that defaults to false.Call setAttachedWindow with the attached argument.
        (WebCore::InspectorController::setAttachedWindow): Call the script version
        of setAttachedWindow.
        * page/InspectorController.h:
        * page/inspector/inspector.js:
        (WebInspector.setAttachedWindow): Set the attached property.

WebKit/mac:

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

        Remember the docked state of the Web Inspector, so it can be
        reopened docked if it was last docked.

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

        Reviewed by Kevin McCullough.

        * WebCoreSupport/WebInspectorClient.mm:
        (-[WebInspectorWindowController init]): Initialize _shouldAttach
        to the value stored in the user defaults. If there has never
        been a value stored, default to being attached.
        (-[WebInspectorWindowController showWindow:]): Pass the attached
        state to InspectorController::setWindowVisible.

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

WebCore/ChangeLog
WebCore/WebCore.base.exp
WebCore/page/InspectorController.cpp
WebCore/page/InspectorController.h
WebCore/page/inspector/inspector.js
WebKit/mac/ChangeLog
WebKit/mac/WebCoreSupport/WebInspectorClient.mm

index a927e41..e3b3a5b 100644 (file)
@@ -1,3 +1,20 @@
+2008-08-13  Timothy Hatcher  <timothy@apple.com>
+
+        Changed the InspectorController so it can be notified when the
+        attached state of the Inspector changes in WebKit.
+
+        Reviewed by Kevin McCullough.
+
+        * WebCore.base.exp: Updated the symbol for setWindowVisible.
+        * page/InspectorController.cpp:
+        (WebCore::InspectorController::setWindowVisible): Added an attached argument,
+        that defaults to false.Call setAttachedWindow with the attached argument.
+        (WebCore::InspectorController::setAttachedWindow): Call the script version
+        of setAttachedWindow.
+        * page/InspectorController.h:
+        * page/inspector/inspector.js:
+        (WebInspector.setAttachedWindow): Set the attached property.
+
 2008-08-12  Timothy Hatcher  <timothy@apple.com>
 
         Added a close button to the Inspector's toolbar when docked.
index 47a52ae..61a3087 100644 (file)
@@ -376,7 +376,7 @@ __ZN7WebCore19CSSStyleDeclaration11setPropertyERKNS_6StringES3_Ri
 __ZN7WebCore19InspectorController12attachWindowEv
 __ZN7WebCore19InspectorController12detachWindowEv
 __ZN7WebCore19InspectorController13stopDebuggingEv
-__ZN7WebCore19InspectorController16setWindowVisibleEb
+__ZN7WebCore19InspectorController16setWindowVisibleEbb
 __ZN7WebCore19InspectorController26stopUserInitiatedProfilingEv
 __ZN7WebCore19InspectorController27startUserInitiatedProfilingEv
 __ZN7WebCore19InspectorController36startDebuggingAndReloadInspectedPageEv
index af17de7..021bb55 100644 (file)
@@ -1210,7 +1210,7 @@ bool InspectorController::windowVisible()
     return m_windowVisible;
 }
 
-void InspectorController::setWindowVisible(bool visible)
+void InspectorController::setWindowVisible(bool visible, bool attached)
 {
     if (visible == m_windowVisible)
         return;
@@ -1221,6 +1221,7 @@ void InspectorController::setWindowVisible(bool visible)
         return;
 
     if (m_windowVisible) {
+        setAttachedWindow(attached);
         populateScriptObjects();
         if (m_nodeToFocus)
             focusNode();
@@ -1326,6 +1327,17 @@ void InspectorController::detachWindow()
     m_client->detachWindow();
 }
 
+void InspectorController::setAttachedWindow(bool attached)
+{
+    if (!enabled() || !m_scriptContext || !m_scriptObject)
+        return;
+
+    JSValueRef attachedValue = JSValueMakeBoolean(m_scriptContext, attached);
+
+    JSValueRef exception = 0;
+    callFunction(m_scriptContext, m_scriptObject, "setAttachedWindow", 1, &attachedValue, exception);
+}
+
 void InspectorController::setAttachedWindowHeight(unsigned height)
 {
     if (!enabled())
index e17093d..afc6f54 100644 (file)
@@ -105,7 +105,7 @@ public:
     void finishedProfiling(PassRefPtr<KJS::Profile>);
 
     bool windowVisible();
-    void setWindowVisible(bool visible = true);
+    void setWindowVisible(bool visible = true, bool attached = false);
 
     void addMessageToConsole(MessageSource, MessageLevel, KJS::ExecState*, const KJS::ArgList& arguments, unsigned lineNumber, const String& sourceID);
     void addMessageToConsole(MessageSource, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID);
@@ -119,6 +119,7 @@ public:
     void attachWindow();
     void detachWindow();
 
+    void setAttachedWindow(bool);
     void setAttachedWindowHeight(unsigned height);
 
     JSContextRef scriptContext() const { return m_scriptContext; };
index dfbd4cb..2025d30 100644 (file)
@@ -397,6 +397,11 @@ WebInspector.focusChanged = function(event)
     this.currentFocusElement = event.target;
 }
 
+WebInspector.setAttachedWindow = function(attached)
+{
+    this.attached = attached;
+}
+
 WebInspector.close = function(event)
 {
     InspectorController.closeWindow();
index 3d733ee..ef866ea 100644 (file)
@@ -1,3 +1,19 @@
+2008-08-13  Timothy Hatcher  <timothy@apple.com>
+
+        Remember the docked state of the Web Inspector, so it can be
+        reopened docked if it was last docked.
+
+        https://bugs.webkit.org/show_bug.cgi?id=14271
+
+        Reviewed by Kevin McCullough.
+
+        * WebCoreSupport/WebInspectorClient.mm:
+        (-[WebInspectorWindowController init]): Initialize _shouldAttach
+        to the value stored in the user defaults. If there has never
+        been a value stored, default to being attached.
+        (-[WebInspectorWindowController showWindow:]): Pass the attached
+        state to InspectorController::setWindowVisible.
+
 2008-08-12  Timothy Hatcher  <timothy@apple.com>
 
         Remove the Inspector's WebView for the view hierarchy when closed
index 889fd1f..73acdd6 100644 (file)
@@ -142,6 +142,7 @@ void WebInspectorClient::updateWindowTitle() const
 
 #pragma mark -
 
+#define WebKitInspectorAttachedKey @"WebKitInspectorAttached"
 #define WebKitInspectorAttachedViewHeightKey @"WebKitInspectorAttachedViewHeight"
 
 @implementation WebInspectorWindowController
@@ -175,6 +176,10 @@ void WebInspectorClient::updateWindowTitle() const
 
     [preferences release];
 
+    NSNumber *attached = [[NSUserDefaults standardUserDefaults] objectForKey:WebKitInspectorAttachedKey];
+    ASSERT(!attached || [attached isKindOfClass:[NSNumber class]]);
+    _shouldAttach = attached ? [attached boolValue] : YES;
+
     NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"inspector" ofType:@"html" inDirectory:@"inspector"];
     NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL fileURLWithPath:path]];
     [[_webView mainFrame] loadRequest:request];
@@ -318,7 +323,7 @@ void WebInspectorClient::updateWindowTitle() const
         [super showWindow:nil];
     }
 
-    [_inspectedWebView page]->inspectorController()->setWindowVisible(true);
+    [_inspectedWebView page]->inspectorController()->setWindowVisible(true, _shouldAttach);
 }
 
 #pragma mark -