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

Unified Diff: Source/devtools/front_end/elements/ElementsTreeOutline.js

Issue 701153002: DevTools: [Elements] Highlight DOM updates (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Don't access |document| directly Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/devtools/front_end/elements/elementsTreeOutline.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/elements/ElementsTreeOutline.js
diff --git a/Source/devtools/front_end/elements/ElementsTreeOutline.js b/Source/devtools/front_end/elements/ElementsTreeOutline.js
index c5e2d6f8f3eff068f09bcb413942338cdb083757..530f4b8fa8f7f3c6c15127e8bb5faf77d26afbb7 100644
--- a/Source/devtools/front_end/elements/ElementsTreeOutline.js
+++ b/Source/devtools/front_end/elements/ElementsTreeOutline.js
@@ -490,10 +490,33 @@ WebInspector.ElementsTreeOutline.prototype = {
/**
* @param {!Array.<!WebInspector.DOMNode>} nodes
+ * @param {!Map.<!WebInspector.DOMNode, !Set.<string>>} modifiedAttributes
*/
- _fireElementsTreeUpdated: function(nodes)
+ _fireElementsTreeUpdated: function(nodes, modifiedAttributes)
{
this._eventSupport.dispatchEventToListeners(WebInspector.ElementsTreeOutline.Events.ElementsTreeUpdated, nodes);
+ for (var entry of modifiedAttributes.entries()) {
+ // FIXME: Remove this cast once Map.prototype.entries is properly supported by the Closure compiler.
+ var treeElement = this.findTreeElement(/** @type {!WebInspector.DOMNode} */ (entry[0]));
vsevik 2014/11/05 20:40:24 You could iterate over keys instead to workaround
apavlov 2014/11/06 10:47:03 Done.
+ if (!treeElement)
+ continue;
+ var element = treeElement.listItemElement;
+ // FIXME: Remove this cast once Map.prototype.entries is properly supported by the Closure compiler.
+ var names = /** @type {!Set.<string>} */ (entry[1]);
+ for (var name of names) {
+ var attrValue = treeElement.representedObject.getAttribute(name);
+ var xpath;
+ if (attrValue === undefined) {
+ xpath = ".//*[@class='webkit-html-tag-name']";
+ } else {
+ var elementClassName = !!attrValue ? "webkit-html-attribute-value" : "webkit-html-attribute-name";
+ xpath = ".//*[@class='webkit-html-tag']//*[@class='webkit-html-attribute'][.//*[@class='webkit-html-attribute-name'][text()='" + name + "']]/*[@class='" + elementClassName + "']";
vsevik 2014/11/05 20:40:24 Maybe store attribute elements on the treeElement
apavlov 2014/11/06 10:47:03 Discussed this approach offline
+ }
+ element = element.ownerDocument.evaluate(xpath, element, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
+ if (element)
+ WebInspector.runCSSAnimationOnce(element, "dom-update-highlight");
+ }
+ }
},
/**
@@ -2747,8 +2770,15 @@ WebInspector.ElementsTreeUpdater = function(domModel, treeOutline)
this._recentlyModifiedNodes = new Set();
/** @type {!Set.<!WebInspector.DOMNode>} */
this._recentlyModifiedParentNodes = new Set();
+ /** @type {!Map.<!WebInspector.DOMNode, !Set.<string>>} */
+ this._recentlyModifiedAttributes = new Map();
}
+/**
+ * @typedef {{node: !WebInspector.DOMNode, name: string}}
+ */
+WebInspector.ElementsTreeUpdater.AttributeUpdateEntry;
vsevik 2014/11/05 20:40:24 unused?
apavlov 2014/11/06 10:47:03 Done.
+
WebInspector.ElementsTreeUpdater.prototype = {
dispose: function()
{
@@ -2815,6 +2845,12 @@ WebInspector.ElementsTreeUpdater.prototype = {
{
var node = /** @type {!WebInspector.DOMNode} */ (event.data.node);
this._nodeModified(node);
+ var names = this._recentlyModifiedAttributes.get(node);
+ if (!names) {
+ names = new Set();
+ this._recentlyModifiedAttributes.set(node, names);
+ }
+ names.add(/** @type {string} */ (event.data.name));
},
/**
@@ -2905,7 +2941,8 @@ WebInspector.ElementsTreeUpdater.prototype = {
}
this._recentlyModifiedNodes.clear();
this._recentlyModifiedParentNodes.clear();
- this._treeOutline._fireElementsTreeUpdated(updatedNodes);
+ this._treeOutline._fireElementsTreeUpdated(updatedNodes, this._recentlyModifiedAttributes);
+ this._recentlyModifiedAttributes.clear();
},
_reset: function()
« no previous file with comments | « no previous file | Source/devtools/front_end/elements/elementsTreeOutline.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698