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

Side by Side Diff: Source/devtools/front_end/components/ObjectPropertiesSection.js

Issue 826713005: DevTools: Highlight changed scope variables as they change (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: addressing feedback. v good points. simplified Created 5 years, 11 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
« no previous file with comments | « no previous file | Source/devtools/front_end/main/Main.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 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 16 matching lines...) Expand all
27 /** 27 /**
28 * @constructor 28 * @constructor
29 * @extends {WebInspector.PropertiesSection} 29 * @extends {WebInspector.PropertiesSection}
30 * @param {!WebInspector.RemoteObject} object 30 * @param {!WebInspector.RemoteObject} object
31 * @param {?string|!Element=} title 31 * @param {?string|!Element=} title
32 * @param {string=} subtitle 32 * @param {string=} subtitle
33 * @param {?string=} emptyPlaceholder 33 * @param {?string=} emptyPlaceholder
34 * @param {boolean=} ignoreHasOwnProperty 34 * @param {boolean=} ignoreHasOwnProperty
35 * @param {!Array.<!WebInspector.RemoteObjectProperty>=} extraProperties 35 * @param {!Array.<!WebInspector.RemoteObjectProperty>=} extraProperties
36 * @param {function(new:TreeElement, !WebInspector.RemoteObjectProperty)=} treeE lementConstructor 36 * @param {function(new:TreeElement, !WebInspector.RemoteObjectProperty)=} treeE lementConstructor
37 * @param {?WebInspector.ObjectPropertiesMemento=} memento
37 */ 38 */
38 WebInspector.ObjectPropertiesSection = function(object, title, subtitle, emptyPl aceholder, ignoreHasOwnProperty, extraProperties, treeElementConstructor) 39 WebInspector.ObjectPropertiesSection = function(object, title, subtitle, emptyPl aceholder, ignoreHasOwnProperty, extraProperties, treeElementConstructor, mement o)
39 { 40 {
40 this._emptyPlaceholder = emptyPlaceholder; 41 this._emptyPlaceholder = emptyPlaceholder;
41 this.object = object; 42 this.object = object;
42 this.ignoreHasOwnProperty = ignoreHasOwnProperty; 43 this.ignoreHasOwnProperty = ignoreHasOwnProperty;
43 this.extraProperties = extraProperties; 44 this.extraProperties = extraProperties;
44 this.treeElementConstructor = treeElementConstructor || WebInspector.ObjectP ropertyTreeElement; 45 this.treeElementConstructor = treeElementConstructor || WebInspector.ObjectP ropertyTreeElement;
45 this.editable = true; 46 this.editable = true;
46 this.skipProto = false; 47 this.skipProto = false;
48 /**
49 * @private
50 */
51 this.memento = memento;
47 52
48 WebInspector.PropertiesSection.call(this, title || "", subtitle); 53 WebInspector.PropertiesSection.call(this, title || "", subtitle);
49 } 54 }
50 55
51 /** @const */ 56 /** @const */
52 WebInspector.ObjectPropertiesSection._arrayLoadThreshold = 100; 57 WebInspector.ObjectPropertiesSection._arrayLoadThreshold = 100;
53 58
54 WebInspector.ObjectPropertiesSection.prototype = { 59 WebInspector.ObjectPropertiesSection.prototype = {
55 enableContextMenu: function() 60 enableContextMenu: function()
56 { 61 {
(...skipping 30 matching lines...) Expand all
87 if (!properties) 92 if (!properties)
88 return; 93 return;
89 this.updateProperties(properties, internalProperties); 94 this.updateProperties(properties, internalProperties);
90 } 95 }
91 96
92 WebInspector.RemoteObject.loadFromObject(this.object, !!this.ignoreHasOw nProperty, callback.bind(this)); 97 WebInspector.RemoteObject.loadFromObject(this.object, !!this.ignoreHasOw nProperty, callback.bind(this));
93 }, 98 },
94 99
95 updateProperties: function(properties, internalProperties, rootTreeElementCo nstructor, rootPropertyComparer) 100 updateProperties: function(properties, internalProperties, rootTreeElementCo nstructor, rootPropertyComparer)
96 { 101 {
102 if (this.memento)
103 this.memento.forgetProperties();
104
97 if (!rootTreeElementConstructor) 105 if (!rootTreeElementConstructor)
98 rootTreeElementConstructor = this.treeElementConstructor; 106 rootTreeElementConstructor = this.treeElementConstructor;
99 107
100 if (!rootPropertyComparer) 108 if (!rootPropertyComparer)
101 rootPropertyComparer = WebInspector.ObjectPropertiesSection.CompareP roperties; 109 rootPropertyComparer = WebInspector.ObjectPropertiesSection.CompareP roperties;
102 110
103 if (this.extraProperties) { 111 if (this.extraProperties) {
104 for (var i = 0; i < this.extraProperties.length; ++i) 112 for (var i = 0; i < this.extraProperties.length; ++i)
105 properties.push(this.extraProperties[i]); 113 properties.push(this.extraProperties[i]);
106 } 114 }
(...skipping 26 matching lines...) Expand all
133 return -1; 141 return -1;
134 if (propertyA.symbol && !propertyB.symbol) 142 if (propertyA.symbol && !propertyB.symbol)
135 return 1; 143 return 1;
136 if (propertyB.symbol && !propertyA.symbol) 144 if (propertyB.symbol && !propertyA.symbol)
137 return -1; 145 return -1;
138 return String.naturalOrderComparator(a, b); 146 return String.naturalOrderComparator(a, b);
139 } 147 }
140 148
141 /** 149 /**
142 * @constructor 150 * @constructor
151 */
152 WebInspector.ObjectPropertiesMemento = function()
153 {
154 this._expandedProperties = new Set();
155 this._lastDescriptions = {};
156 this._propertyIdentifiers = {};
157 }
158
159 WebInspector.ObjectPropertiesMemento.prototype = {
160 /**
161 * @return {boolean}
162 */
163 isPropertyPathExpanded: function(propertyPath)
164 {
165 return this._expandedProperties.has(propertyPath);
166 },
167 addExpandedPropertyPath: function(propertyPath)
168 {
169 this._expandedProperties.add(propertyPath);
170 },
171 deleteExpandedPropertyPath: function(propertyPath)
172 {
173 this._expandedProperties['delete'](propertyPath);
174 },
175 forgetProperties: function()
176 {
177 for (var pi in this._lastDescriptions)
178 {
179 if (!(pi in this._propertyIdentifiers))
180 delete this._lastDescriptions[pi];
181 }
182 this._propertyIdentifiers = {};
183 },
184 /**
185 * @param {!WebInspector.ObjectPropertyTreeElement} objectPropertyTreeElemen t
186 */
187 recordAndDecorate: function(objectPropertyTreeElement)
188 {
189 var propertyPath = objectPropertyTreeElement.propertyPath();
190 if (Runtime.experiments.isEnabled("highlightChangedProperties") && prope rtyPath) {
191 this._propertyIdentifiers[propertyPath] = 1;
192 var lastDesription = this._lastDescriptions[propertyPath];
193 var hadProperty = (lastDesription != undefined);
194 var description = (objectPropertyTreeElement.property.value.type + " :" +
195 (objectPropertyTreeElement.property.value.subtype? objectPro pertyTreeElement.property.value.subtype : "") + ":" +
196 /* (objectPropertyTreeElement.property.value.objectId ? obje ctPropertyTreeElement.property.value.objectId : "") + ":" + */
197 objectPropertyTreeElement.property.value.description);
198 var descriptionChanged = (!hadProperty) || (description != lastDesri ption);
199 this._lastDescriptions[propertyPath] = description;
200
201 if (descriptionChanged)
202 objectPropertyTreeElement.valueElement.classList.add("highlighte d-search-result");
203 if (!hadProperty)
204 objectPropertyTreeElement.nameElement.classList.add("highlighted -search-result");
205 }
206 }
207 }
208
209 /**
210 * @constructor
143 * @extends {TreeElement} 211 * @extends {TreeElement}
144 * @param {!WebInspector.RemoteObjectProperty} property 212 * @param {!WebInspector.RemoteObjectProperty} property
145 */ 213 */
146 WebInspector.ObjectPropertyTreeElement = function(property) 214 WebInspector.ObjectPropertyTreeElement = function(property)
147 { 215 {
148 this.property = property; 216 this.property = property;
149 217
150 // Pass an empty title, the title gets made later in onattach. 218 // Pass an empty title, the title gets made later in onattach.
151 TreeElement.call(this, "", null, false); 219 TreeElement.call(this, "", null, false);
152 this.toggleOnClick = true; 220 this.toggleOnClick = true;
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 * @param {?Array.<!WebInspector.RemoteObjectProperty>} internalProperties 601 * @param {?Array.<!WebInspector.RemoteObjectProperty>} internalProperties
534 * @param {function(new:TreeElement, !WebInspector.RemoteObjectProperty)} treeEl ementConstructor 602 * @param {function(new:TreeElement, !WebInspector.RemoteObjectProperty)} treeEl ementConstructor
535 * @param {function(!WebInspector.RemoteObjectProperty, !WebInspector.RemoteObje ctProperty): number} comparator 603 * @param {function(!WebInspector.RemoteObjectProperty, !WebInspector.RemoteObje ctProperty): number} comparator
536 * @param {boolean} skipProto 604 * @param {boolean} skipProto
537 * @param {?WebInspector.RemoteObject} value 605 * @param {?WebInspector.RemoteObject} value
538 * @param {?string=} emptyPlaceholder 606 * @param {?string=} emptyPlaceholder
539 */ 607 */
540 WebInspector.ObjectPropertyTreeElement.populateWithProperties = function(treeNod e, properties, internalProperties, treeElementConstructor, comparator, skipProto , value, emptyPlaceholder) { 608 WebInspector.ObjectPropertyTreeElement.populateWithProperties = function(treeNod e, properties, internalProperties, treeElementConstructor, comparator, skipProto , value, emptyPlaceholder) {
541 properties.sort(comparator); 609 properties.sort(comparator);
542 610
611 function appendChild(treeElement) {
612 treeNode.appendChild(treeElement);
613 if (treeElement instanceof WebInspector.ObjectPropertyTreeElement) {
614 var treeElementPropertyPath = treeElement.propertyPath();
615 if (Runtime.experiments.isEnabled("highlightChangedProperties") &&
616 treeElementPropertyPath &&
617 treeNode.treeOutline.section.memento)
618 treeNode.treeOutline.section.memento.recordAndDecorate(treeEleme nt);
619 }
620 }
621
543 for (var i = 0; i < properties.length; ++i) { 622 for (var i = 0; i < properties.length; ++i) {
544 var property = properties[i]; 623 var property = properties[i];
545 if (skipProto && property.name === "__proto__") 624 if (skipProto && property.name === "__proto__")
546 continue; 625 continue;
547 if (property.isAccessorProperty()) { 626 if (property.isAccessorProperty()) {
548 if (property.name !== "__proto__" && property.getter) { 627 if (property.name !== "__proto__" && property.getter) {
549 property.parentObject = value; 628 property.parentObject = value;
550 treeNode.appendChild(new treeElementConstructor(property)); 629 appendChild(new treeElementConstructor(property));
551 } 630 }
552 if (property.isOwn) { 631 if (property.isOwn) {
553 if (property.getter) { 632 if (property.getter) {
554 var getterProperty = new WebInspector.RemoteObjectProperty(" get " + property.name, property.getter); 633 var getterProperty = new WebInspector.RemoteObjectProperty(" get " + property.name, property.getter);
555 getterProperty.parentObject = value; 634 getterProperty.parentObject = value;
556 treeNode.appendChild(new treeElementConstructor(getterProper ty)); 635 appendChild(new treeElementConstructor(getterProperty));
557 } 636 }
558 if (property.setter) { 637 if (property.setter) {
559 var setterProperty = new WebInspector.RemoteObjectProperty(" set " + property.name, property.setter); 638 var setterProperty = new WebInspector.RemoteObjectProperty(" set " + property.name, property.setter);
560 setterProperty.parentObject = value; 639 setterProperty.parentObject = value;
561 treeNode.appendChild(new treeElementConstructor(setterProper ty)); 640 appendChild(new treeElementConstructor(setterProperty));
562 } 641 }
563 } 642 }
564 } else { 643 } else {
565 property.parentObject = value; 644 property.parentObject = value;
566 treeNode.appendChild(new treeElementConstructor(property)); 645 appendChild(new treeElementConstructor(property));
567 } 646 }
568 } 647 }
569 if (internalProperties) { 648 if (internalProperties) {
570 for (var i = 0; i < internalProperties.length; i++) { 649 for (var i = 0; i < internalProperties.length; i++) {
571 internalProperties[i].parentObject = value; 650 internalProperties[i].parentObject = value;
572 treeNode.appendChild(new treeElementConstructor(internalProperties[i ])); 651 appendChild(new treeElementConstructor(internalProperties[i]));
573 } 652 }
574 } 653 }
575 if (value && value.type === "function") { 654 if (value && value.type === "function") {
576 // Whether function has TargetFunction internal property. 655 // Whether function has TargetFunction internal property.
577 // This is a simple way to tell that the function is actually a bound fu nction (we are not told). 656 // This is a simple way to tell that the function is actually a bound fu nction (we are not told).
578 // Bound function never has inner scope and doesn't need corresponding U I node. 657 // Bound function never has inner scope and doesn't need corresponding U I node.
579 var hasTargetFunction = false; 658 var hasTargetFunction = false;
580 659
581 if (internalProperties) { 660 if (internalProperties) {
582 for (var i = 0; i < internalProperties.length; i++) { 661 for (var i = 0; i < internalProperties.length; i++) {
583 if (internalProperties[i].name == "[[TargetFunction]]") { 662 if (internalProperties[i].name == "[[TargetFunction]]") {
584 hasTargetFunction = true; 663 hasTargetFunction = true;
585 break; 664 break;
586 } 665 }
587 } 666 }
588 } 667 }
589 if (!hasTargetFunction) 668 if (!hasTargetFunction)
590 treeNode.appendChild(new WebInspector.FunctionScopeMainTreeElement(v alue)); 669 appendChild(new WebInspector.FunctionScopeMainTreeElement(value));
591 } 670 }
592 if (value && value.type === "object" && (value.subtype === "map" || value.su btype === "set" || value.subtype === "iterator")) 671 if (value && value.type === "object" && (value.subtype === "map" || value.su btype === "set" || value.subtype === "iterator"))
593 treeNode.appendChild(new WebInspector.CollectionEntriesMainTreeElement(v alue)); 672 appendChild(new WebInspector.CollectionEntriesMainTreeElement(value));
594 673
595 WebInspector.ObjectPropertyTreeElement._appendEmptyPlaceholderIfNeeded(treeN ode, emptyPlaceholder); 674 WebInspector.ObjectPropertyTreeElement._appendEmptyPlaceholderIfNeeded(treeN ode, emptyPlaceholder);
596 } 675 }
597 676
598 /** 677 /**
599 * @param {!TreeContainerNode} treeNode 678 * @param {!TreeContainerNode} treeNode
600 * @param {?string=} emptyPlaceholder 679 * @param {?string=} emptyPlaceholder
601 */ 680 */
602 WebInspector.ObjectPropertyTreeElement._appendEmptyPlaceholderIfNeeded = functio n(treeNode, emptyPlaceholder) 681 WebInspector.ObjectPropertyTreeElement._appendEmptyPlaceholderIfNeeded = functio n(treeNode, emptyPlaceholder)
603 { 682 {
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 { 1199 {
1121 WebInspector.TextPrompt.call(this, WebInspector.ExecutionContextSelector.com pletionsForTextPromptInCurrentContext); 1200 WebInspector.TextPrompt.call(this, WebInspector.ExecutionContextSelector.com pletionsForTextPromptInCurrentContext);
1122 this.setSuggestBoxEnabled(true); 1201 this.setSuggestBoxEnabled(true);
1123 if (renderAsBlock) 1202 if (renderAsBlock)
1124 this.renderAsBlock(); 1203 this.renderAsBlock();
1125 } 1204 }
1126 1205
1127 WebInspector.ObjectPropertyPrompt.prototype = { 1206 WebInspector.ObjectPropertyPrompt.prototype = {
1128 __proto__: WebInspector.TextPrompt.prototype 1207 __proto__: WebInspector.TextPrompt.prototype
1129 } 1208 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/main/Main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698