| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 }, | 799 }, |
| 800 } | 800 } |
| 801 | 801 |
| 802 /** | 802 /** |
| 803 * @constructor | 803 * @constructor |
| 804 * @param {!WebInspector.CSSStyleModel} cssModel | 804 * @param {!WebInspector.CSSStyleModel} cssModel |
| 805 */ | 805 */ |
| 806 WebInspector.CSSStyleModel.ComputedStyleLoader = function(cssModel) | 806 WebInspector.CSSStyleModel.ComputedStyleLoader = function(cssModel) |
| 807 { | 807 { |
| 808 this._cssModel = cssModel; | 808 this._cssModel = cssModel; |
| 809 /** @type {!Map.<!DOMAgent.NodeId, !Promise.<?WebInspector.CSSStyleDeclarati
on>>} */ | 809 /** @type {!Map<!DOMAgent.NodeId, !Promise<?Map<string, string>>>} */ |
| 810 this._nodeIdToPromise = new Map(); | 810 this._nodeIdToPromise = new Map(); |
| 811 } | 811 } |
| 812 | 812 |
| 813 WebInspector.CSSStyleModel.ComputedStyleLoader.prototype = { | 813 WebInspector.CSSStyleModel.ComputedStyleLoader.prototype = { |
| 814 /** | 814 /** |
| 815 * @param {!DOMAgent.NodeId} nodeId | 815 * @param {!DOMAgent.NodeId} nodeId |
| 816 * @return {!Promise.<?Map.<string, string>>} | 816 * @return {!Promise<?Map<string, string>>} |
| 817 */ | 817 */ |
| 818 computedStylePromise: function(nodeId) | 818 computedStylePromise: function(nodeId) |
| 819 { | 819 { |
| 820 if (!this._nodeIdToPromise[nodeId]) | 820 if (!this._nodeIdToPromise.has(nodeId)) |
| 821 this._nodeIdToPromise[nodeId] = this._cssModel._agent.getComputedSty
leForNode(nodeId, parsePayload).then(cleanUp.bind(this)); | 821 this._nodeIdToPromise.set(nodeId, this._cssModel._agent.getComputedS
tyleForNode(nodeId, parsePayload).then(cleanUp.bind(this))); |
| 822 | 822 |
| 823 return this._nodeIdToPromise[nodeId]; | 823 return /** @type {!Promise.<?Map.<string, string>>} */(this._nodeIdToPro
mise.get(nodeId)); |
| 824 | 824 |
| 825 /** | 825 /** |
| 826 * @param {?Protocol.Error} error | 826 * @param {?Protocol.Error} error |
| 827 * @param {!Array.<!CSSAgent.CSSComputedStyleProperty>} computedPayload | 827 * @param {!Array.<!CSSAgent.CSSComputedStyleProperty>} computedPayload |
| 828 * @return {?Map.<string, string>} | 828 * @return {?Map.<string, string>} |
| 829 */ | 829 */ |
| 830 function parsePayload(error, computedPayload) | 830 function parsePayload(error, computedPayload) |
| 831 { | 831 { |
| 832 if (error || !computedPayload || !computedPayload.length) | 832 if (error || !computedPayload || !computedPayload.length) |
| 833 return null; | 833 return null; |
| 834 var result = new Map(); | 834 var result = new Map(); |
| 835 for (var property of computedPayload) | 835 for (var property of computedPayload) |
| 836 result.set(property.name, property.value); | 836 result.set(property.name, property.value); |
| 837 return result; | 837 return result; |
| 838 } | 838 } |
| 839 | 839 |
| 840 /** | 840 /** |
| 841 * @param {?Map.<string, string>} computedStyle | 841 * @param {?Map.<string, string>} computedStyle |
| 842 * @return {?Map.<string, string>} | 842 * @return {?Map.<string, string>} |
| 843 * @this {WebInspector.CSSStyleModel.ComputedStyleLoader} | 843 * @this {WebInspector.CSSStyleModel.ComputedStyleLoader} |
| 844 */ | 844 */ |
| 845 function cleanUp(computedStyle) | 845 function cleanUp(computedStyle) |
| 846 { | 846 { |
| 847 delete this._nodeIdToPromise[nodeId]; | 847 this._nodeIdToPromise.delete(nodeId); |
| 848 return computedStyle; | 848 return computedStyle; |
| 849 } | 849 } |
| 850 } | 850 } |
| 851 } | 851 } |
| 852 | 852 |
| 853 /** | 853 /** |
| 854 * @param {!WebInspector.Target} target | 854 * @param {!WebInspector.Target} target |
| 855 * @return {?WebInspector.CSSStyleModel} | 855 * @return {?WebInspector.CSSStyleModel} |
| 856 */ | 856 */ |
| 857 WebInspector.CSSStyleModel.fromTarget = function(target) | 857 WebInspector.CSSStyleModel.fromTarget = function(target) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 873 /** | 873 /** |
| 874 * @constructor | 874 * @constructor |
| 875 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle | 875 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle |
| 876 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle | 876 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle |
| 877 */ | 877 */ |
| 878 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS
tyle) | 878 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS
tyle) |
| 879 { | 879 { |
| 880 this.inlineStyle = inlineStyle; | 880 this.inlineStyle = inlineStyle; |
| 881 this.attributesStyle = attributesStyle; | 881 this.attributesStyle = attributesStyle; |
| 882 } | 882 } |
| OLD | NEW |