| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 return new WebInspector.CSSStyleModel.MatchedStyleResult(matchedRule
s, inherited, pseudoElements); | 162 return new WebInspector.CSSStyleModel.MatchedStyleResult(matchedRule
s, inherited, pseudoElements); |
| 163 } | 163 } |
| 164 | 164 |
| 165 return this._agent.getMatchedStylesForNode(nodeId, excludePseudo, exclud
eInherited, callback.bind(this)); | 165 return this._agent.getMatchedStylesForNode(nodeId, excludePseudo, exclud
eInherited, callback.bind(this)); |
| 166 }, | 166 }, |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * @param {!DOMAgent.NodeId} nodeId | 169 * @param {!DOMAgent.NodeId} nodeId |
| 170 * @return {!Promise.<?WebInspector.CSSStyleDeclaration>} | 170 * @return {!Promise.<?Map.<string, string>>} |
| 171 */ | 171 */ |
| 172 computedStylePromise: function(nodeId) | 172 computedStylePromise: function(nodeId) |
| 173 { | 173 { |
| 174 return this._styleLoader.computedStylePromise(nodeId); | 174 return this._styleLoader.computedStylePromise(nodeId); |
| 175 }, | 175 }, |
| 176 | 176 |
| 177 /** | 177 /** |
| 178 * @param {number} nodeId | 178 * @param {number} nodeId |
| 179 * @return {!Promise.<?Array.<!CSSAgent.PlatformFontUsage>>} | 179 * @return {!Promise.<?Array.<!CSSAgent.PlatformFontUsage>>} |
| 180 */ | 180 */ |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 /** | 709 /** |
| 710 * @param {!WebInspector.CSSStyleModel} cssModel | 710 * @param {!WebInspector.CSSStyleModel} cssModel |
| 711 * @param {!CSSAgent.CSSStyle} payload | 711 * @param {!CSSAgent.CSSStyle} payload |
| 712 * @return {!WebInspector.CSSStyleDeclaration} | 712 * @return {!WebInspector.CSSStyleDeclaration} |
| 713 */ | 713 */ |
| 714 WebInspector.CSSStyleDeclaration.parsePayload = function(cssModel, payload) | 714 WebInspector.CSSStyleDeclaration.parsePayload = function(cssModel, payload) |
| 715 { | 715 { |
| 716 return new WebInspector.CSSStyleDeclaration(cssModel, payload); | 716 return new WebInspector.CSSStyleDeclaration(cssModel, payload); |
| 717 } | 717 } |
| 718 | 718 |
| 719 /** | |
| 720 * @param {!WebInspector.CSSStyleModel} cssModel | |
| 721 * @param {!Array.<!CSSAgent.CSSComputedStyleProperty>} payload | |
| 722 * @return {!WebInspector.CSSStyleDeclaration} | |
| 723 */ | |
| 724 WebInspector.CSSStyleDeclaration.parseComputedStylePayload = function(cssModel,
payload) | |
| 725 { | |
| 726 var newPayload = /** @type {!CSSAgent.CSSStyle} */ ({ cssProperties: [], sho
rthandEntries: [], width: "", height: "" }); | |
| 727 if (payload) | |
| 728 newPayload.cssProperties = /** @type {!Array.<!CSSAgent.CSSProperty>} */
(payload); | |
| 729 | |
| 730 return new WebInspector.CSSStyleDeclaration(cssModel, newPayload); | |
| 731 } | |
| 732 | |
| 733 WebInspector.CSSStyleDeclaration.prototype = { | 719 WebInspector.CSSStyleDeclaration.prototype = { |
| 734 /** | 720 /** |
| 735 * @return {!WebInspector.Target} | 721 * @return {!WebInspector.Target} |
| 736 */ | 722 */ |
| 737 target: function() | 723 target: function() |
| 738 { | 724 { |
| 739 return this._cssModel.target(); | 725 return this._cssModel.target(); |
| 740 }, | 726 }, |
| 741 | 727 |
| 742 /** | 728 /** |
| (...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1884 WebInspector.CSSStyleModel.ComputedStyleLoader = function(cssModel) | 1870 WebInspector.CSSStyleModel.ComputedStyleLoader = function(cssModel) |
| 1885 { | 1871 { |
| 1886 this._cssModel = cssModel; | 1872 this._cssModel = cssModel; |
| 1887 /** @type {!Map.<!DOMAgent.NodeId, !Promise.<?WebInspector.CSSStyleDeclarati
on>>} */ | 1873 /** @type {!Map.<!DOMAgent.NodeId, !Promise.<?WebInspector.CSSStyleDeclarati
on>>} */ |
| 1888 this._nodeIdToPromise = new Map(); | 1874 this._nodeIdToPromise = new Map(); |
| 1889 } | 1875 } |
| 1890 | 1876 |
| 1891 WebInspector.CSSStyleModel.ComputedStyleLoader.prototype = { | 1877 WebInspector.CSSStyleModel.ComputedStyleLoader.prototype = { |
| 1892 /** | 1878 /** |
| 1893 * @param {!DOMAgent.NodeId} nodeId | 1879 * @param {!DOMAgent.NodeId} nodeId |
| 1894 * @return {!Promise.<?WebInspector.CSSStyleDeclaration>} | 1880 * @return {!Promise.<?Map.<string, string>>} |
| 1895 */ | 1881 */ |
| 1896 computedStylePromise: function(nodeId) | 1882 computedStylePromise: function(nodeId) |
| 1897 { | 1883 { |
| 1898 if (!this._nodeIdToPromise[nodeId]) | 1884 if (!this._nodeIdToPromise[nodeId]) |
| 1899 this._nodeIdToPromise[nodeId] = this._cssModel._agent.getComputedSty
leForNode(nodeId, parsePayload.bind(this)).then(cleanUp.bind(this)); | 1885 this._nodeIdToPromise[nodeId] = this._cssModel._agent.getComputedSty
leForNode(nodeId, parsePayload).then(cleanUp.bind(this)); |
| 1900 | 1886 |
| 1901 return this._nodeIdToPromise[nodeId]; | 1887 return this._nodeIdToPromise[nodeId]; |
| 1902 | 1888 |
| 1903 /** | 1889 /** |
| 1904 * @param {?Protocol.Error} error | 1890 * @param {?Protocol.Error} error |
| 1905 * @param {!Array.<!CSSAgent.CSSComputedStyleProperty>} computedPayload | 1891 * @param {!Array.<!CSSAgent.CSSComputedStyleProperty>} computedPayload |
| 1906 * @return {?WebInspector.CSSStyleDeclaration} | 1892 * @return {?Map.<string, string>} |
| 1907 * @this {WebInspector.CSSStyleModel.ComputedStyleLoader} | |
| 1908 */ | 1893 */ |
| 1909 function parsePayload(error, computedPayload) | 1894 function parsePayload(error, computedPayload) |
| 1910 { | 1895 { |
| 1911 return !error && computedPayload ? WebInspector.CSSStyleDeclaration.
parseComputedStylePayload(this._cssModel, computedPayload) : null; | 1896 if (error || !computedPayload) |
| 1897 return null; |
| 1898 var result = new Map(); |
| 1899 for (var property of computedPayload) |
| 1900 result.set(property.name, property.value); |
| 1901 return result; |
| 1912 } | 1902 } |
| 1913 | 1903 |
| 1914 /** | 1904 /** |
| 1915 * @param {?WebInspector.CSSStyleDeclaration} computedStyle | 1905 * @param {?Map.<string, string>} computedStyle |
| 1916 * @return {?WebInspector.CSSStyleDeclaration} | 1906 * @return {?Map.<string, string>} |
| 1917 * @this {WebInspector.CSSStyleModel.ComputedStyleLoader} | 1907 * @this {WebInspector.CSSStyleModel.ComputedStyleLoader} |
| 1918 */ | 1908 */ |
| 1919 function cleanUp(computedStyle) | 1909 function cleanUp(computedStyle) |
| 1920 { | 1910 { |
| 1921 delete this._nodeIdToPromise[nodeId]; | 1911 delete this._nodeIdToPromise[nodeId]; |
| 1922 return computedStyle; | 1912 return computedStyle; |
| 1923 } | 1913 } |
| 1924 } | 1914 } |
| 1925 } | 1915 } |
| 1926 | 1916 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1983 * @constructor | 1973 * @constructor |
| 1984 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle | 1974 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle |
| 1985 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle | 1975 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle |
| 1986 */ | 1976 */ |
| 1987 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS
tyle) | 1977 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS
tyle) |
| 1988 { | 1978 { |
| 1989 this.inlineStyle = inlineStyle; | 1979 this.inlineStyle = inlineStyle; |
| 1990 this.attributesStyle = attributesStyle; | 1980 this.attributesStyle = attributesStyle; |
| 1991 } | 1981 } |
| 1992 | 1982 |
| OLD | NEW |