Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: webkit/glue/devtools/js/devtools.js

Issue 149341: DevTools: show property type names in Elements panel and Console (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | webkit/glue/devtools/js/inject.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Tools is a main class that wires all components of the 6 * @fileoverview Tools is a main class that wires all components of the
7 * DevTools frontend together. It is also responsible for overriding existing 7 * DevTools frontend together. It is also responsible for overriding existing
8 * WebInspector functionality while it is getting upstreamed into WebCore. 8 * WebInspector functionality while it is getting upstreamed into WebCore.
9 */ 9 */
10 goog.provide('devtools.Tools'); 10 goog.provide('devtools.Tools');
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 555
556 delete this._frameNeedsSetup; 556 delete this._frameNeedsSetup;
557 557
558 this.sourceFrame.addEventListener( 558 this.sourceFrame.addEventListener(
559 "syntax highlighting complete", this._syntaxHighlightingComplete, this); 559 "syntax highlighting complete", this._syntaxHighlightingComplete, this);
560 this.sourceFrame.syntaxHighlightJavascript(); 560 this.sourceFrame.syntaxHighlightJavascript();
561 }; 561 };
562 562
563 563
564 /** 564 /**
565 * Dummy object used during properties inspection.
566 * @see WebInspector.didGetNodePropertiesAsync_
567 */
568 WebInspector.dummyObject_ = { 'foo' : 'bar' };
569
570
571 /**
572 * Dummy function used during properties inspection.
573 * @see WebInspector.didGetNodePropertiesAsync_
574 */
575 WebInspector.dummyFunction_ = function() {};
576
577
578 /**
579 * Callback function used with the getNodeProperties. 565 * Callback function used with the getNodeProperties.
580 */ 566 */
581 WebInspector.didGetNodePropertiesAsync_ = function(treeOutline, constructor, 567 WebInspector.didGetNodePropertiesAsync_ = function(treeOutline, constructor,
582 nodeId, path, json) { 568 nodeId, path, json) {
583 var props = JSON.parse(json); 569 var props = JSON.parse(json);
584 var properties = []; 570 var properties = [];
585 var obj = {}; 571 var obj = {};
586 obj.devtools$$nodeId_ = nodeId; 572 obj.devtools$$nodeId_ = nodeId;
587 obj.devtools$$path_ = path; 573 obj.devtools$$path_ = path;
588 for (var i = 0; i < props.length; i += 3) { 574 for (var i = 0; i < props.length; i += 4) {
589 var type = props[i]; 575 var type = props[i];
590 var name = props[i + 1]; 576 var name = props[i + 1];
591 var value = props[i + 2]; 577 var value = props[i + 2];
578 var className = props[i + 3];
592 properties.push(name); 579 properties.push(name);
593 if (type == 'object') { 580 if (type == 'object' || type == 'function') {
594 // fake object is going to be replaced on expand. 581 // fake object is going to be replaced on expand.
595 obj[name] = WebInspector.dummyObject_; 582 obj[name] = new WebInspector.UnresolvedPropertyValue(type, className);
596 } else if (type == 'function') {
597 // fake function is going to be replaced on expand.
598 obj[name] = WebInspector.dummyFunction_;
599 } else { 583 } else {
600 obj[name] = value; 584 obj[name] = value;
601 } 585 }
602 } 586 }
603 properties.sort(); 587 properties.sort();
604
605 treeOutline.removeChildren(); 588 treeOutline.removeChildren();
606 589
607 for (var i = 0; i < properties.length; ++i) { 590 for (var i = 0; i < properties.length; ++i) {
608 var propertyName = properties[i]; 591 var propertyName = properties[i];
609 treeOutline.appendChild(new constructor(obj, propertyName)); 592 treeOutline.appendChild(new constructor(obj, propertyName));
610 } 593 }
611 }; 594 };
612 595
613 596
614 /** 597 /**
598 * @param {string} type Type of the the property value('object' or 'function').
599 * @param {string} className Class name of the property value.
600 * @constructor
601 */
602 WebInspector.UnresolvedPropertyValue = function(type, className) {
603 this.type = type;
604 this.className = className;
605 };
606
607
608 /**
615 * Replace WebKit method with our own implementation to use our call stack 609 * Replace WebKit method with our own implementation to use our call stack
616 * representation. Original method uses Object.prototype.toString.call to 610 * representation. Original method uses Object.prototype.toString.call to
617 * learn if scope object is a JSActivation which doesn't work in Chrome. 611 * learn if scope object is a JSActivation which doesn't work in Chrome.
618 */ 612 */
619 WebInspector.ScopeChainSidebarPane.prototype.update = function(callFrame) { 613 WebInspector.ScopeChainSidebarPane.prototype.update = function(callFrame) {
620 this.bodyElement.removeChildren(); 614 this.bodyElement.removeChildren();
621 615
622 this.sections = []; 616 this.sections = [];
623 this.callFrame = callFrame; 617 this.callFrame = callFrame;
624 618
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 document.title = 'Developer Tools - ' + resource.url; 974 document.title = 'Developer Tools - ' + resource.url;
981 } 975 }
982 }; 976 };
983 })(); 977 })();
984 978
985 979
986 // There is no clear way of rendering class name for scope variables yet. 980 // There is no clear way of rendering class name for scope variables yet.
987 (function OverrideObjectDescribe() { 981 (function OverrideObjectDescribe() {
988 var oldDescribe = Object.describe; 982 var oldDescribe = Object.describe;
989 Object.describe = function(obj, abbreviated) { 983 Object.describe = function(obj, abbreviated) {
984 if (obj instanceof WebInspector.UnresolvedPropertyValue) {
985 return obj.className;
986 }
987
990 var result = oldDescribe.call(Object, obj, abbreviated); 988 var result = oldDescribe.call(Object, obj, abbreviated);
991 if (result == 'Object' && obj.className) { 989 if (result == 'Object' && obj.className) {
992 return obj.className; 990 return obj.className;
993 } 991 }
994 return result; 992 return result;
995 }; 993 };
996 994
997 // This is needed to evaluate 'instanceof' against win.Node, etc. 995 // This is needed to evaluate 'instanceof' against win.Node, etc.
998 // Need a real window, not just InspectorController.inspectedWindow wrapper. 996 // Need a real window, not just InspectorController.inspectedWindow wrapper.
999 var oldType = Object.type; 997 var oldType = Object.type;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 } 1042 }
1045 }; 1043 };
1046 } else { 1044 } else {
1047 var wrapper = {}; 1045 var wrapper = {};
1048 wrapper.id_ = object.___devtools_id; 1046 wrapper.id_ = object.___devtools_id;
1049 wrapper.protoDepth_ = -1; 1047 wrapper.protoDepth_ = -1;
1050 section = new WebInspector.SidebarObjectPropertiesSection(wrapper, null); 1048 section = new WebInspector.SidebarObjectPropertiesSection(wrapper, null);
1051 } 1049 }
1052 elem.appendChild(section.element); 1050 elem.appendChild(section.element);
1053 }; 1051 };
OLDNEW
« no previous file with comments | « no previous file | webkit/glue/devtools/js/inject.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698