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

Unified Diff: Source/devtools/front_end/sdk/CSSStyleModel.js

Issue 1310883002: DevTools: represent ComputedStyle with simple Map (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix test 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 side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/sdk/CSSStyleModel.js
diff --git a/Source/devtools/front_end/sdk/CSSStyleModel.js b/Source/devtools/front_end/sdk/CSSStyleModel.js
index cb0f0ca51da378addb4ca139db0ce001a5101703..f1f2b2b6e12747003ff22e2932335026d82d57a6 100644
--- a/Source/devtools/front_end/sdk/CSSStyleModel.js
+++ b/Source/devtools/front_end/sdk/CSSStyleModel.js
@@ -167,7 +167,7 @@ WebInspector.CSSStyleModel.prototype = {
/**
* @param {!DOMAgent.NodeId} nodeId
- * @return {!Promise.<?WebInspector.CSSStyleDeclaration>}
+ * @return {!Promise.<?Map.<string, string>>}
*/
computedStylePromise: function(nodeId)
{
@@ -716,20 +716,6 @@ WebInspector.CSSStyleDeclaration.parsePayload = function(cssModel, payload)
return new WebInspector.CSSStyleDeclaration(cssModel, payload);
}
-/**
- * @param {!WebInspector.CSSStyleModel} cssModel
- * @param {!Array.<!CSSAgent.CSSComputedStyleProperty>} payload
- * @return {!WebInspector.CSSStyleDeclaration}
- */
-WebInspector.CSSStyleDeclaration.parseComputedStylePayload = function(cssModel, payload)
-{
- var newPayload = /** @type {!CSSAgent.CSSStyle} */ ({ cssProperties: [], shorthandEntries: [], width: "", height: "" });
- if (payload)
- newPayload.cssProperties = /** @type {!Array.<!CSSAgent.CSSProperty>} */ (payload);
-
- return new WebInspector.CSSStyleDeclaration(cssModel, newPayload);
-}
-
WebInspector.CSSStyleDeclaration.prototype = {
/**
* @return {!WebInspector.Target}
@@ -1891,29 +1877,33 @@ WebInspector.CSSStyleModel.ComputedStyleLoader = function(cssModel)
WebInspector.CSSStyleModel.ComputedStyleLoader.prototype = {
/**
* @param {!DOMAgent.NodeId} nodeId
- * @return {!Promise.<?WebInspector.CSSStyleDeclaration>}
+ * @return {!Promise.<?Map.<string, string>>}
*/
computedStylePromise: function(nodeId)
{
if (!this._nodeIdToPromise[nodeId])
- this._nodeIdToPromise[nodeId] = this._cssModel._agent.getComputedStyleForNode(nodeId, parsePayload.bind(this)).then(cleanUp.bind(this));
+ this._nodeIdToPromise[nodeId] = this._cssModel._agent.getComputedStyleForNode(nodeId, parsePayload).then(cleanUp.bind(this));
return this._nodeIdToPromise[nodeId];
/**
* @param {?Protocol.Error} error
* @param {!Array.<!CSSAgent.CSSComputedStyleProperty>} computedPayload
- * @return {?WebInspector.CSSStyleDeclaration}
- * @this {WebInspector.CSSStyleModel.ComputedStyleLoader}
+ * @return {?Map.<string, string>}
*/
function parsePayload(error, computedPayload)
{
- return !error && computedPayload ? WebInspector.CSSStyleDeclaration.parseComputedStylePayload(this._cssModel, computedPayload) : null;
+ if (error || !computedPayload)
+ return null;
+ var result = new Map();
+ for (var property of computedPayload)
+ result.set(property.name, property.value);
+ return result;
}
/**
- * @param {?WebInspector.CSSStyleDeclaration} computedStyle
- * @return {?WebInspector.CSSStyleDeclaration}
+ * @param {?Map.<string, string>} computedStyle
+ * @return {?Map.<string, string>}
* @this {WebInspector.CSSStyleModel.ComputedStyleLoader}
*/
function cleanUp(computedStyle)

Powered by Google App Engine
This is Rietveld 408576698