Adds a debugger toggle button to the scripts status bar that will start
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Apr 2008 16:54:16 +0000 (16:54 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Apr 2008 16:54:16 +0000 (16:54 +0000)
and stop debugging of the inspected page.

Reviewed by Adam Roben.

* English.lproj/InspectorLocalizedStrings.js: Adds the two new tooltip strings.
* page/InspectorController.cpp:
(WebCore::debuggerAttached): Call InspectorController::debuggerAttached.
(WebCore::InspectorController::InspectorController): Initialize
m_debuggerAttached to false.
(WebCore::InspectorController::windowScriptObjectAvailable): Add the debuggerAttached
property to the InspectorController class.
(WebCore::InspectorController::startDebuggingAndReloadInspectedPage):
Set m_debuggerAttached to true.
(WebCore::InspectorController::stopDebugging): Set m_debuggerAttached to false.
* page/InspectorController.h:
* page/inspector/Images/debuggingButtons.png: Added.
* page/inspector/ScriptsPanel.js:
(WebInspector.ScriptsPanel): Disable the pause button. Create the debugging
button and setup the id, className and event listener. Call reset.
(WebInspector.ScriptsPanel.prototype.get statusBarItems): Return an array
(WebInspector.ScriptsPanel.prototype.reset): Call _updateDebuggerButtons.
(WebInspector.ScriptsPanel.prototype._updateDebuggerButtons): Adjust the title of
the debugging button to match what will happen when clicked. Change the style class,
and toggle the disabled state of the pause button.
(WebInspector.ScriptsPanel.prototype._toggleDebugging): Start or stop debugging
depending on InspectorController.debuggerAttached().
* page/inspector/inspector.css: Added style rules for the debugger button.

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

WebCore/ChangeLog
WebCore/English.lproj/InspectorLocalizedStrings.js
WebCore/page/InspectorController.cpp
WebCore/page/InspectorController.h
WebCore/page/inspector/Images/debuggingButtons.png [new file with mode: 0644]
WebCore/page/inspector/ScriptsPanel.js
WebCore/page/inspector/inspector.css

index 3092506..175ce69 100644 (file)
@@ -1,3 +1,34 @@
+2008-04-22  Timothy Hatcher  <timothy@apple.com>
+
+        Adds a debugger toggle button to the scripts status bar that will start
+        and stop debugging of the inspected page.
+
+        Reviewed by Adam Roben.
+
+        * English.lproj/InspectorLocalizedStrings.js: Adds the two new tooltip strings.
+        * page/InspectorController.cpp:
+        (WebCore::debuggerAttached): Call InspectorController::debuggerAttached.
+        (WebCore::InspectorController::InspectorController): Initialize
+        m_debuggerAttached to false.
+        (WebCore::InspectorController::windowScriptObjectAvailable): Add the debuggerAttached
+        property to the InspectorController class.
+        (WebCore::InspectorController::startDebuggingAndReloadInspectedPage):
+        Set m_debuggerAttached to true.
+        (WebCore::InspectorController::stopDebugging): Set m_debuggerAttached to false.
+        * page/InspectorController.h:
+        * page/inspector/Images/debuggingButtons.png: Added.
+        * page/inspector/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel): Disable the pause button. Create the debugging
+        button and setup the id, className and event listener. Call reset.
+        (WebInspector.ScriptsPanel.prototype.get statusBarItems): Return an array
+        (WebInspector.ScriptsPanel.prototype.reset): Call _updateDebuggerButtons.
+        (WebInspector.ScriptsPanel.prototype._updateDebuggerButtons): Adjust the title of
+        the debugging button to match what will happen when clicked. Change the style class,
+        and toggle the disabled state of the pause button.
+        (WebInspector.ScriptsPanel.prototype._toggleDebugging): Start or stop debugging
+        depending on InspectorController.debuggerAttached().
+        * page/inspector/inspector.css: Added style rules for the debugger button.
+
 2008-04-21  Adam Roben  <aroben@apple.com>
 
         Change PlatformWheelEvent to use GET_WHEEL_DELTA_WPARAM
index 4d88e0a..0644744 100644 (file)
Binary files a/WebCore/English.lproj/InspectorLocalizedStrings.js and b/WebCore/English.lproj/InspectorLocalizedStrings.js differ
index 41de049..38ef25f 100644 (file)
@@ -755,6 +755,14 @@ static JSValueRef stopDebugging(JSContextRef ctx, JSObjectRef /*function*/, JSOb
     return JSValueMakeUndefined(ctx);
 }
 
+static JSValueRef debuggerAttached(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);
+    return JSValueMakeBoolean(ctx, controller->debuggerAttached());
+}
+
 #pragma mark -
 #pragma mark InspectorController Class
 
@@ -766,6 +774,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* client)
     , m_controllerScriptObject(0)
     , m_scriptContext(0)
     , m_windowVisible(false)
+    , m_debuggerAttached(false)
     , m_showAfterVisible(FocusedNodeDocumentPanel)
     , m_nextIdentifier(-2)
 {
@@ -998,6 +1007,7 @@ void InspectorController::windowScriptObjectAvailable()
         { "wrapCallback", wrapCallback, kJSPropertyAttributeNone },
         { "startDebuggingAndReloadInspectedPage", WebCore::startDebuggingAndReloadInspectedPage, kJSPropertyAttributeNone },
         { "stopDebugging", WebCore::stopDebugging, kJSPropertyAttributeNone },
+        { "debuggerAttached", WebCore::debuggerAttached, kJSPropertyAttributeNone },
         { 0, 0, 0 }
     };
 
@@ -1912,12 +1922,14 @@ void InspectorController::moveWindowBy(float x, float y) const
 void InspectorController::startDebuggingAndReloadInspectedPage()
 {
     JavaScriptDebugServer::shared().addListener(this, m_inspectedPage);
+    m_debuggerAttached = true;
     m_inspectedPage->mainFrame()->loader()->reload();
 }
 
 void InspectorController::stopDebugging()
 {
     JavaScriptDebugServer::shared().removeListener(this, m_inspectedPage);
+    m_debuggerAttached = false;
 }
 
 static void drawOutlinedRect(GraphicsContext& context, const IntRect& rect, const Color& fillColor)
index a33a86f..0c56a1a 100644 (file)
@@ -132,6 +132,7 @@ public:
 
     void startDebuggingAndReloadInspectedPage();
     void stopDebugging();
+    bool debuggerAttached() const { return m_debuggerAttached; }
 
     void drawNodeHighlight(GraphicsContext&) const;
 
@@ -191,6 +192,7 @@ private:
     JSObjectRef m_controllerScriptObject;
     JSContextRef m_scriptContext;
     bool m_windowVisible;
+    bool m_debuggerAttached;
     SpecialPanels m_showAfterVisible;
     long long m_nextIdentifier;
     RefPtr<Node> m_highlightedNode;
diff --git a/WebCore/page/inspector/Images/debuggingButtons.png b/WebCore/page/inspector/Images/debuggingButtons.png
new file mode 100644 (file)
index 0000000..c9cc618
Binary files /dev/null and b/WebCore/page/inspector/Images/debuggingButtons.png differ
index 0d9c6dd..dbc0e4c 100644 (file)
@@ -68,6 +68,7 @@ WebInspector.ScriptsPanel = function()
     this.pauseButton.className = "status-bar-item";
     this.pauseButton.id = "scripts-pause";
     this.pauseButton.title = WebInspector.UIString("Pause script execution.");
+    this.pauseButton.disabled = true;
     this.pauseButton.appendChild(document.createElement("img"));
     this.sidebarButtonsElement.appendChild(this.pauseButton);
 
@@ -124,6 +125,13 @@ WebInspector.ScriptsPanel = function()
     this.element.appendChild(this.scriptResourceViews);
     this.element.appendChild(this.sidebarElement);
     this.element.appendChild(this.sidebarResizeElement);
+
+    this.debuggingButton = document.createElement("button");
+    this.debuggingButton.id = "scripts-debugging-status-bar-item";
+    this.debuggingButton.className = "status-bar-item";
+    this.debuggingButton.addEventListener("click", this._toggleDebugging.bind(this), false);
+
+    this.reset();
 }
 
 WebInspector.ScriptsPanel.prototype = {
@@ -136,7 +144,7 @@ WebInspector.ScriptsPanel.prototype = {
 
     get statusBarItems()
     {
-        return [];
+        return [this.debuggingButton];
     },
 
     show: function()
@@ -145,6 +153,11 @@ WebInspector.ScriptsPanel.prototype = {
         this.sidebarResizeElement.style.right = (this.sidebarElement.offsetWidth - 3) + "px";
     },
 
+    reset: function()
+    {
+        this._updateDebuggerButtons();
+    },
+
     _startSidebarResizeDrag: function(event)
     {
         WebInspector.elementDragStart(this.sidebarElement, this._sidebarResizeDrag.bind(this), this._endSidebarResizeDrag.bind(this), event, "col-resize");
@@ -175,6 +188,28 @@ WebInspector.ScriptsPanel.prototype = {
 
         event.preventDefault();
     },
+
+    _updateDebuggerButtons: function()
+    {
+        if (InspectorController.debuggerAttached()) {
+            this.debuggingButton.title = WebInspector.UIString("Stop debugging.");
+            this.debuggingButton.addStyleClass("toggled-on");
+            this.pauseButton.disabled = false;
+        } else {
+            this.debuggingButton.title = WebInspector.UIString("Start debugging and reload inspected page.");
+            this.debuggingButton.removeStyleClass("toggled-on");
+            this.pauseButton.disabled = true;
+        }
+    },
+
+    _toggleDebugging: function()
+    {
+        if (InspectorController.debuggerAttached())
+            InspectorController.stopDebugging();
+        else
+            InspectorController.startDebuggingAndReloadInspectedPage();
+        this._updateDebuggerButtons();
+    },
 }
 
 WebInspector.ScriptsPanel.prototype.__proto__ = WebInspector.Panel.prototype;
index 06d1e7e..41292cc 100644 (file)
@@ -1340,6 +1340,22 @@ body.inactive .sidebar {
     background-image: url(Images/errorIcon.png);
 }
 
+#scripts-debugging-status-bar-item {
+    background-image: url(Images/debuggingButtons.png);
+}
+
+#scripts-debugging-status-bar-item:active {
+    background-position: 32px 0;
+}
+
+#scripts-debugging-status-bar-item.toggled-on {
+    background-position: 0 24px;
+}
+
+#scripts-debugging-status-bar-item.toggled-on:active {
+    background-position: 32px 24px;
+}
+
 #scripts-status-bar {
     position: absolute;
     top: -1px;