2011-04-11 Pavel Feldman <pfeldman@chromium.org>
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Apr 2011 11:45:08 +0000 (11:45 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Apr 2011 11:45:08 +0000 (11:45 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: refactor / document call frames in debugger domain.
        https://bugs.webkit.org/show_bug.cgi?id=58187

        Note that we are not special casing with(element) and with(document) anymore
        and do not tell user that it is "Event target" and "Event document". Strictly speaking,
        we should not have done it for with(element) not necessarily being related to an event.

        * English.lproj/localizedStrings.js:
        * inspector/InjectedScriptSource.js:
        * inspector/Inspector.json:
        * inspector/front-end/ScopeChainSidebarPane.js:
        (WebInspector.ScopeChainSidebarPane.prototype.update):

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

Source/WebCore/ChangeLog
Source/WebCore/English.lproj/localizedStrings.js
Source/WebCore/inspector/InjectedScriptSource.js
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/InspectorDebuggerAgent.cpp
Source/WebCore/inspector/front-end/ScopeChainSidebarPane.js

index e2fca5c..c5d07fe 100644 (file)
@@ -1,3 +1,20 @@
+2011-04-11  Pavel Feldman  <pfeldman@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: refactor / document call frames in debugger domain.
+        https://bugs.webkit.org/show_bug.cgi?id=58187
+
+        Note that we are not special casing with(element) and with(document) anymore
+        and do not tell user that it is "Event target" and "Event document". Strictly speaking,
+        we should not have done it for with(element) not necessarily being related to an event.
+
+        * English.lproj/localizedStrings.js:
+        * inspector/InjectedScriptSource.js:
+        * inspector/Inspector.json:
+        * inspector/front-end/ScopeChainSidebarPane.js:
+        (WebInspector.ScopeChainSidebarPane.prototype.update):
+
 2011-04-10  ChangSeok Oh  <shivamidow@gmail.com>
 
         Reviewed by Eric Seidel.
index 15938d9..33eae88 100644 (file)
Binary files a/Source/WebCore/English.lproj/localizedStrings.js and b/Source/WebCore/English.lproj/localizedStrings.js differ
index 8231d78..ce43a42 100644 (file)
@@ -299,7 +299,6 @@ InjectedScript.prototype = {
         if (!callFrame)
             return false;
     
-        injectedScript.releaseObjectGroup("backtrace");
         var result = [];
         var depth = 0;
         do {
@@ -487,38 +486,28 @@ InjectedScript.CallFrameProxy.prototype = {
         const WITH_SCOPE = 2;
         const CLOSURE_SCOPE = 3;
         const CATCH_SCOPE = 4;
-    
+
+        var scopeTypeNames = {};
+        scopeTypeNames[GLOBAL_SCOPE] = "global";
+        scopeTypeNames[LOCAL_SCOPE] = "local";
+        scopeTypeNames[WITH_SCOPE] = "with";
+        scopeTypeNames[CLOSURE_SCOPE] = "closure";
+        scopeTypeNames[CATCH_SCOPE] = "catch";
+
         var scopeChain = callFrame.scopeChain;
         var scopeChainProxy = [];
         var foundLocalScope = false;
         for (var i = 0; i < scopeChain.length; i++) {
+            var scope = {};
+            scope.object = injectedScript._wrapObject(scopeChain[i], "backtrace");
+
             var scopeType = callFrame.scopeType(i);
-            var scopeObject = scopeChain[i];
-            var scopeObjectProxy = injectedScript._wrapObject(scopeObject, "backtrace");
-
-            switch(scopeType) {
-                case LOCAL_SCOPE: {
-                    foundLocalScope = true;
-                    scopeObjectProxy.isLocal = true;
-                    scopeObjectProxy.thisObject = injectedScript._wrapObject(callFrame.thisObject, "backtrace");
-                    break;
-                }
-                case CLOSURE_SCOPE: {
-                    scopeObjectProxy.isClosure = true;
-                    break;
-                }
-                case WITH_SCOPE:
-                case CATCH_SCOPE: {
-                    if (foundLocalScope && scopeObject instanceof inspectedWindow.Element)
-                        scopeObjectProxy.isElement = true;
-                    else if (foundLocalScope && scopeObject instanceof inspectedWindow.Document)
-                        scopeObjectProxy.isDocument = true;
-                    else
-                        scopeObjectProxy.isWithBlock = true;
-                    break;
-                }
-            }
-            scopeChainProxy.push(scopeObjectProxy);
+            scope.type = scopeTypeNames[scopeType];
+
+            if (scopeType === LOCAL_SCOPE)
+                scope.this = injectedScript._wrapObject(callFrame.thisObject, "backtrace");
+
+            scopeChainProxy.push(scope);
         }
         return scopeChainProxy;
     }
index f2e69b0..cd91b6d 100644 (file)
                 "id": "CallFrame",
                 "type": "object",
                 "properties": {
-                    "id": { "type": "string",  "description": "Call frame identifier" },
+                    "id": { "type": "string",  "description": "Call frame identifier." },
                     "functionName": { "type": "string", "description": "Name of the function called on this frame." },
                     "location": { "$ref": "Location", "description": "Location in the source code." },
-                    "scopeChain": { "type": "array", "items": { "type": "object" }, "description": "Scope chain for given call frame. // FIXME" }
+                    "scopeChain": { "type": "array", "items": { "$ref": "Scope" }, "description": "Scope chain for given call frame." }
+                },
+                "description": "Debugger call frame. Array of call frames form call stack."
+            },
+            {
+                "id": "Scope",
+                "type": "object",
+                "properties": {
+                    "type": { "type": "string",  "enum": ["global", "local", "with", "closure", "catch"], "description": "Scope type." },
+                    "object": { "$ref": "RemoteObject", "description": "Object representing the scope." },
+                    "this": { "$ref": "RemoteObject", "optional": true, "description": "<code>this</code> object for local scope." },
                 },
                 "description": "Debugger call frame. Array of call frames form call stack."
             }
index 5a3ab27..c8283a1 100644 (file)
@@ -314,6 +314,7 @@ void InspectorDebuggerAgent::pause(ErrorString*)
 
 void InspectorDebuggerAgent::resume(ErrorString*)
 {
+    m_injectedScriptManager->releaseObjectGroup("backtrace");
     scriptDebugServer().continueProgram();
 }
 
index bdbb0cf..b7f0dad 100644 (file)
@@ -59,40 +59,45 @@ WebInspector.ScopeChainSidebarPane.prototype = {
         var foundLocalScope = false;
         var scopeChain = callFrame.scopeChain;
         for (var i = 0; i < scopeChain.length; ++i) {
-            var scopeObjectProxy = scopeChain[i];
+            var scope = scopeChain[i];
             var title = null;
-            var subtitle = scopeObjectProxy.description;
+            var subtitle = scope.object.description;
             var emptyPlaceholder = null;
             var extraProperties = null;
 
-            if (scopeObjectProxy.isLocal) {
-                foundLocalScope = true;
-                title = WebInspector.UIString("Local");
-                emptyPlaceholder = WebInspector.UIString("No Variables");
-                subtitle = null;
-                if (scopeObjectProxy.thisObject)
-                    extraProperties = [ new WebInspector.RemoteObjectProperty("this", WebInspector.RemoteObject.fromPayload(scopeObjectProxy.thisObject)) ];
-            } else if (scopeObjectProxy.isClosure) {
-                title = WebInspector.UIString("Closure");
-                emptyPlaceholder = WebInspector.UIString("No Variables");
-                subtitle = null;
-            } else if (i === (scopeChain.length - 1))
-                title = WebInspector.UIString("Global");
-            else if (scopeObjectProxy.isElement)
-                title = WebInspector.UIString("Event Target");
-            else if (scopeObjectProxy.isDocument)
-                title = WebInspector.UIString("Event Document");
-            else if (scopeObjectProxy.isWithBlock)
-                title = WebInspector.UIString("With Block");
+            switch (scope.type) {
+                case "local":
+                    foundLocalScope = true;
+                    title = WebInspector.UIString("Local");
+                    emptyPlaceholder = WebInspector.UIString("No Variables");
+                    subtitle = null;
+                    if (scope.this)
+                        extraProperties = [ new WebInspector.RemoteObjectProperty("this", WebInspector.RemoteObject.fromPayload(scope.this)) ];
+                    break;
+                case "closure":
+                    title = WebInspector.UIString("Closure");
+                    emptyPlaceholder = WebInspector.UIString("No Variables");
+                    subtitle = null;
+                    break;
+                case "catch":
+                    title = WebInspector.UIString("Catch");
+                    break;
+                case "with":
+                    title = WebInspector.UIString("With Block");
+                    break;
+                case "global":
+                    title = WebInspector.UIString("Global");
+                    break;
+            }
 
             if (!title || title === subtitle)
                 subtitle = null;
 
-            var section = new WebInspector.ObjectPropertiesSection(WebInspector.RemoteObject.fromPayload(scopeObjectProxy), title, subtitle, emptyPlaceholder, true, extraProperties, WebInspector.ScopeVariableTreeElement);
+            var section = new WebInspector.ObjectPropertiesSection(WebInspector.RemoteObject.fromPayload(scope.object), title, subtitle, emptyPlaceholder, true, extraProperties, WebInspector.ScopeVariableTreeElement);
             section.editInSelectedCallFrameWhenPaused = true;
             section.pane = this;
 
-            if (!foundLocalScope || scopeObjectProxy.isLocal || title in this._expandedSections)
+            if (!foundLocalScope || scope.type === "local" || title in this._expandedSections)
                 section.expanded = true;
 
             this._sections.push(section);