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

Side by Side Diff: Source/devtools/front_end/elements/ElementsTreeElement.js

Issue 1273313002: DevTools: introduce dom markers, decorate hidden, forced state and breakpoint elements using marker… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: for landing Created 5 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 22 matching lines...) Expand all
33 * @extends {TreeElement} 33 * @extends {TreeElement}
34 * @param {!WebInspector.DOMNode} node 34 * @param {!WebInspector.DOMNode} node
35 * @param {boolean=} elementCloseTag 35 * @param {boolean=} elementCloseTag
36 */ 36 */
37 WebInspector.ElementsTreeElement = function(node, elementCloseTag) 37 WebInspector.ElementsTreeElement = function(node, elementCloseTag)
38 { 38 {
39 // The title will be updated in onattach. 39 // The title will be updated in onattach.
40 TreeElement.call(this); 40 TreeElement.call(this);
41 this._node = node; 41 this._node = node;
42 42
43 this._decorationsElement = createElementWithClass("div");
44 this.listItemElement.appendChild(this._decorationsElement);
45
43 this._elementCloseTag = elementCloseTag; 46 this._elementCloseTag = elementCloseTag;
44 47
45 if (this._node.nodeType() == Node.ELEMENT_NODE && !elementCloseTag) 48 if (this._node.nodeType() == Node.ELEMENT_NODE && !elementCloseTag)
46 this._canAddAttributes = true; 49 this._canAddAttributes = true;
47 this._searchQuery = null; 50 this._searchQuery = null;
48 this._expandedChildrenLimit = WebInspector.ElementsTreeElement.InitialChildr enLimit; 51 this._expandedChildrenLimit = WebInspector.ElementsTreeElement.InitialChildr enLimit;
49 } 52 }
50 53
51 WebInspector.ElementsTreeElement.InitialChildrenLimit = 500; 54 WebInspector.ElementsTreeElement.InitialChildrenLimit = 500;
52 55
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return false; 113 return false;
111 } 114 }
112 115
113 /** 116 /**
114 * @param {!WebInspector.ContextSubMenuItem} subMenu 117 * @param {!WebInspector.ContextSubMenuItem} subMenu
115 * @param {!WebInspector.DOMNode} node 118 * @param {!WebInspector.DOMNode} node
116 */ 119 */
117 WebInspector.ElementsTreeElement.populateForcedPseudoStateItems = function(subMe nu, node) 120 WebInspector.ElementsTreeElement.populateForcedPseudoStateItems = function(subMe nu, node)
118 { 121 {
119 const pseudoClasses = ["active", "hover", "focus", "visited"]; 122 const pseudoClasses = ["active", "hover", "focus", "visited"];
120 var forcedPseudoState = node.getUserProperty(WebInspector.CSSStyleModel.Pseu doStatePropertyName) || []; 123 var forcedPseudoState = WebInspector.CSSStyleModel.fromNode(node).pseudoStat e(node);
121 for (var i = 0; i < pseudoClasses.length; ++i) { 124 for (var i = 0; i < pseudoClasses.length; ++i) {
122 var pseudoClassForced = forcedPseudoState.indexOf(pseudoClasses[i]) >= 0 ; 125 var pseudoClassForced = forcedPseudoState.indexOf(pseudoClasses[i]) >= 0 ;
123 subMenu.appendCheckboxItem(":" + pseudoClasses[i], setPseudoStateCallbac k.bind(null, pseudoClasses[i], !pseudoClassForced), pseudoClassForced, false); 126 subMenu.appendCheckboxItem(":" + pseudoClasses[i], setPseudoStateCallbac k.bind(null, pseudoClasses[i], !pseudoClassForced), pseudoClassForced, false);
124 } 127 }
125 128
126 /** 129 /**
127 * @param {string} pseudoState 130 * @param {string} pseudoState
128 * @param {boolean} enabled 131 * @param {boolean} enabled
129 */ 132 */
130 function setPseudoStateCallback(pseudoState, enabled) 133 function setPseudoStateCallback(pseudoState, enabled)
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 } 1057 }
1055 if (!depth) 1058 if (!depth)
1056 this.childrenListElement.classList.add("shadow-root-deep"); 1059 this.childrenListElement.classList.add("shadow-root-deep");
1057 else 1060 else
1058 this.childrenListElement.classList.add("shadow-root-depth-" + depth); 1061 this.childrenListElement.classList.add("shadow-root-depth-" + depth);
1059 } 1062 }
1060 var highlightElement = createElement("span"); 1063 var highlightElement = createElement("span");
1061 highlightElement.className = "highlight"; 1064 highlightElement.className = "highlight";
1062 highlightElement.appendChild(nodeInfo); 1065 highlightElement.appendChild(nodeInfo);
1063 this.title = highlightElement; 1066 this.title = highlightElement;
1064 this._updateDecorations(); 1067 this.updateDecorations();
1068 this.listItemElement.insertBefore(this._decorationsElement, this.lis tItemElement.firstChild);
1065 delete this._highlightResult; 1069 delete this._highlightResult;
1066 } 1070 }
1067 1071
1068 delete this.selectionElement; 1072 delete this.selectionElement;
1069 if (this.selected) 1073 if (this.selected)
1070 this.updateSelection(); 1074 this.updateSelection();
1071 this._preventFollowingLinksOnDoubleClick(); 1075 this._preventFollowingLinksOnDoubleClick();
1072 this._highlightSearchResults(); 1076 this._highlightSearchResults();
1073 }, 1077 },
1074 1078
1075 /** 1079 updateDecorations: function()
1076 * @return {?Element}
1077 */
1078 _createDecoratorElement: function()
1079 { 1080 {
1081 if (this.isClosingTag())
1082 return;
1080 var node = this._node; 1083 var node = this._node;
1081 var decoratorMessages = []; 1084 if (node.nodeType() !== Node.ELEMENT_NODE)
1082 var parentDecoratorMessages = []; 1085 return;
1083 var decorators = this.treeOutline.nodeDecorators();
1084 for (var i = 0; i < decorators.length; ++i) {
1085 var decorator = decorators[i];
1086 var message = decorator.decorate(node);
1087 if (message) {
1088 decoratorMessages.push(message);
1089 continue;
1090 }
1091 1086
1092 if (this.expanded || this._elementCloseTag) 1087 var extensions = runtime.extensions(WebInspector.DOMPresentationUtils.Ma rkerDecorator);
1093 continue; 1088 var markerToExtension = new Map();
1089 for (var extension of extensions)
1090 markerToExtension.set(extension.descriptor()["marker"], extension);
1094 1091
1095 message = decorator.decorateAncestor(node); 1092 var promises = [];
1096 if (message) 1093 var decorations = [];
1097 parentDecoratorMessages.push(message) 1094 var descendantDecorations = [];
1095 node.traverseMarkers(visitor);
1096
1097 /**
1098 * @param {!WebInspector.DOMNode} n
1099 * @param {string} marker
1100 */
1101 function visitor(n, marker)
1102 {
1103 var extension = markerToExtension.get(marker);
1104 if (!extension)
1105 return;
1106 promises.push(extension.instancePromise().then(collectDecoration.bin d(null, n)));
1098 } 1107 }
1099 if (!decoratorMessages.length && !parentDecoratorMessages.length)
1100 return null;
1101 1108
1102 var decoratorElement = createElement("div"); 1109 /**
1103 decoratorElement.classList.add("elements-gutter-decoration"); 1110 * @param {!WebInspector.DOMNode} n
1104 if (!decoratorMessages.length) 1111 * @param {!WebInspector.DOMPresentationUtils.MarkerDecorator} decorator
1105 decoratorElement.classList.add("elements-has-decorated-children"); 1112 */
1106 decoratorElement.title = decoratorMessages.concat(parentDecoratorMessage s).join("\n"); 1113 function collectDecoration(n, decorator)
1107 return decoratorElement; 1114 {
1108 }, 1115 var decoration = decorator.decorate(n);
1116 if (!decoration)
1117 return;
1118 (n === node ? decorations : descendantDecorations).push(decoration);
1119 }
1109 1120
1110 _updateDecorations: function() 1121 Promise.all(promises).then(setTitle.bind(this));
1111 { 1122
1112 if (this._decoratorElement) 1123 /**
1113 this._decoratorElement.remove(); 1124 * @this {WebInspector.ElementsTreeElement}
1114 this._decoratorElement = this._createDecoratorElement(); 1125 */
1115 if (this._decoratorElement && this.listItemElement) 1126 function setTitle()
1116 this.listItemElement.insertBefore(this._decoratorElement, this.listI temElement.firstChild); 1127 {
1128 this._decorationsElement.classList.toggle("elements-gutter-decoratio n", decorations.length || (descendantDecorations.length && !this.expanded));
1129 this._decorationsElement.classList.toggle("elements-has-decorated-ch ildren", descendantDecorations.length && !this.expanded);
1130 var title = decorations.join("\n");
1131 if (descendantDecorations.length)
1132 title += WebInspector.UIString("\nChildren:\n") + descendantDeco rations.join("\n");
1133 this._decorationsElement.title = title;
1134 }
1117 }, 1135 },
1118 1136
1119 /** 1137 /**
1120 * @param {!Node} parentElement 1138 * @param {!Node} parentElement
1121 * @param {string} name 1139 * @param {string} name
1122 * @param {string} value 1140 * @param {string} value
1123 * @param {?WebInspector.ElementsTreeOutline.UpdateRecord} updateRecord 1141 * @param {?WebInspector.ElementsTreeOutline.UpdateRecord} updateRecord
1124 * @param {boolean=} forceValue 1142 * @param {boolean=} forceValue
1125 * @param {!WebInspector.DOMNode=} node 1143 * @param {!WebInspector.DOMNode=} node
1126 */ 1144 */
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 1539
1522 if (object) 1540 if (object)
1523 object.callFunction(scrollIntoView); 1541 object.callFunction(scrollIntoView);
1524 } 1542 }
1525 1543
1526 this._node.resolveToObject("", scrollIntoViewCallback); 1544 this._node.resolveToObject("", scrollIntoViewCallback);
1527 }, 1545 },
1528 1546
1529 __proto__: TreeElement.prototype 1547 __proto__: TreeElement.prototype
1530 } 1548 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/elements/ElementsPanel.js ('k') | Source/devtools/front_end/elements/ElementsTreeOutline.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698