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

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

Issue 2838263002: [DevTools] Throttle node decorations update in UI (Closed)
Patch Set: null check Created 3 years, 7 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 | no next file » | 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) 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 var gutterMenuIcon = UI.Icon.create('largeicon-menu', 'gutter-menu-icon'); 46 var gutterMenuIcon = UI.Icon.create('largeicon-menu', 'gutter-menu-icon');
47 this._gutterContainer.appendChild(gutterMenuIcon); 47 this._gutterContainer.appendChild(gutterMenuIcon);
48 this._decorationsElement = this._gutterContainer.createChild('div', 'hidden' ); 48 this._decorationsElement = this._gutterContainer.createChild('div', 'hidden' );
49 49
50 this._elementCloseTag = elementCloseTag; 50 this._elementCloseTag = elementCloseTag;
51 51
52 if (this._node.nodeType() === Node.ELEMENT_NODE && !elementCloseTag) 52 if (this._node.nodeType() === Node.ELEMENT_NODE && !elementCloseTag)
53 this._canAddAttributes = true; 53 this._canAddAttributes = true;
54 this._searchQuery = null; 54 this._searchQuery = null;
55 this._expandedChildrenLimit = Elements.ElementsTreeElement.InitialChildrenLi mit; 55 this._expandedChildrenLimit = Elements.ElementsTreeElement.InitialChildrenLi mit;
56 this._decorationsThrottler = new Common.Throttler(100);
56 } 57 }
57 58
58 /** 59 /**
59 * @param {!Elements.ElementsTreeElement} treeElement 60 * @param {!Elements.ElementsTreeElement} treeElement
60 */ 61 */
61 static animateOnDOMUpdate(treeElement) { 62 static animateOnDOMUpdate(treeElement) {
62 var tagName = treeElement.listItemElement.querySelector('.webkit-html-tag-na me'); 63 var tagName = treeElement.listItemElement.querySelector('.webkit-html-tag-na me');
63 UI.runCSSAnimationOnce(tagName || treeElement.listItemElement, 'dom-update-h ighlight'); 64 UI.runCSSAnimationOnce(tagName || treeElement.listItemElement, 'dom-update-h ighlight');
64 } 65 }
65 66
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 /** Keep it in sync with elementsTreeOutline.css **/ 1080 /** Keep it in sync with elementsTreeOutline.css **/
1080 return 12 * (depth - 2) + (this.isExpandable() ? 1 : 12); 1081 return 12 * (depth - 2) + (this.isExpandable() ? 1 : 12);
1081 } 1082 }
1082 1083
1083 updateDecorations() { 1084 updateDecorations() {
1084 this._gutterContainer.style.left = (-this._computeLeftIndent()) + 'px'; 1085 this._gutterContainer.style.left = (-this._computeLeftIndent()) + 'px';
1085 1086
1086 if (this.isClosingTag()) 1087 if (this.isClosingTag())
1087 return; 1088 return;
1088 1089
1090 if (this._node.nodeType() !== Node.ELEMENT_NODE)
1091 return;
1092
1093 this._decorationsThrottler.schedule(this._updateDecorationsInternal.bind(thi s));
1094 }
1095
1096 /**
1097 * @return {!Promise}
1098 */
1099 _updateDecorationsInternal() {
1100 if (!this.treeOutline)
1101 return Promise.resolve();
1102
1089 var node = this._node; 1103 var node = this._node;
1090 if (node.nodeType() !== Node.ELEMENT_NODE)
1091 return;
1092 1104
1093 if (!this.treeOutline._decoratorExtensions) 1105 if (!this.treeOutline._decoratorExtensions)
1094 /** @type {!Array.<!Runtime.Extension>} */ 1106 /** @type {!Array.<!Runtime.Extension>} */
1095 this.treeOutline._decoratorExtensions = runtime.extensions(Components.DOMP resentationUtils.MarkerDecorator); 1107 this.treeOutline._decoratorExtensions = runtime.extensions(Components.DOMP resentationUtils.MarkerDecorator);
1096 1108
1097 var markerToExtension = new Map(); 1109 var markerToExtension = new Map();
1098 for (var i = 0; i < this.treeOutline._decoratorExtensions.length; ++i) { 1110 for (var i = 0; i < this.treeOutline._decoratorExtensions.length; ++i) {
1099 markerToExtension.set( 1111 markerToExtension.set(
1100 this.treeOutline._decoratorExtensions[i].descriptor()['marker'], this. treeOutline._decoratorExtensions[i]); 1112 this.treeOutline._decoratorExtensions[i].descriptor()['marker'], this. treeOutline._decoratorExtensions[i]);
1101 } 1113 }
(...skipping 18 matching lines...) Expand all
1120 * @param {!SDK.DOMNode} n 1132 * @param {!SDK.DOMNode} n
1121 * @param {!Components.DOMPresentationUtils.MarkerDecorator} decorator 1133 * @param {!Components.DOMPresentationUtils.MarkerDecorator} decorator
1122 */ 1134 */
1123 function collectDecoration(n, decorator) { 1135 function collectDecoration(n, decorator) {
1124 var decoration = decorator.decorate(n); 1136 var decoration = decorator.decorate(n);
1125 if (!decoration) 1137 if (!decoration)
1126 return; 1138 return;
1127 (n === node ? decorations : descendantDecorations).push(decoration); 1139 (n === node ? decorations : descendantDecorations).push(decoration);
1128 } 1140 }
1129 1141
1130 Promise.all(promises).then(updateDecorationsUI.bind(this)); 1142 return Promise.all(promises).then(updateDecorationsUI.bind(this));
1131 1143
1132 /** 1144 /**
1133 * @this {Elements.ElementsTreeElement} 1145 * @this {Elements.ElementsTreeElement}
1134 */ 1146 */
1135 function updateDecorationsUI() { 1147 function updateDecorationsUI() {
1136 this._decorationsElement.removeChildren(); 1148 this._decorationsElement.removeChildren();
1137 this._decorationsElement.classList.add('hidden'); 1149 this._decorationsElement.classList.add('hidden');
1138 this._gutterContainer.classList.toggle('has-decorations', decorations.leng th || descendantDecorations.length); 1150 this._gutterContainer.classList.toggle('has-decorations', decorations.leng th || descendantDecorations.length);
1139 1151
1140 if (!decorations.length && !descendantDecorations.length) 1152 if (!decorations.length && !descendantDecorations.length)
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 Elements.ElementsTreeElement.ForbiddenClosingTagElements = new Set([ 1630 Elements.ElementsTreeElement.ForbiddenClosingTagElements = new Set([
1619 'area', 'base', 'basefont', 'br', 'canvas', 'col', 'command', 'embed', 'frame', 'hr', 1631 'area', 'base', 'basefont', 'br', 'canvas', 'col', 'command', 'embed', 'frame', 'hr',
1620 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr' 1632 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'
1621 ]); 1633 ]);
1622 1634
1623 // These tags we do not allow editing their tag name. 1635 // These tags we do not allow editing their tag name.
1624 Elements.ElementsTreeElement.EditTagBlacklist = new Set(['html', 'head', 'body'] ); 1636 Elements.ElementsTreeElement.EditTagBlacklist = new Set(['html', 'head', 'body'] );
1625 1637
1626 /** @typedef {{cancel: function(), commit: function(), resize: function(), edito r:!UI.TextEditor}} */ 1638 /** @typedef {{cancel: function(), commit: function(), resize: function(), edito r:!UI.TextEditor}} */
1627 Elements.MultilineEditorController; 1639 Elements.MultilineEditorController;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698