OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 28 matching lines...) Expand all Loading... |
39 this.registerRequiredCSS("elements/platformFontsWidget.css"); | 39 this.registerRequiredCSS("elements/platformFontsWidget.css"); |
40 | 40 |
41 this._sharedModel = sharedModel; | 41 this._sharedModel = sharedModel; |
42 this._sharedModel.addEventListener(WebInspector.ComputedStyleModel.Events.Co
mputedStyleChanged, this.update, this); | 42 this._sharedModel.addEventListener(WebInspector.ComputedStyleModel.Events.Co
mputedStyleChanged, this.update, this); |
43 | 43 |
44 this._sectionTitle = createElementWithClass("div", "title"); | 44 this._sectionTitle = createElementWithClass("div", "title"); |
45 this.contentElement.classList.add("platform-fonts"); | 45 this.contentElement.classList.add("platform-fonts"); |
46 this.contentElement.appendChild(this._sectionTitle); | 46 this.contentElement.appendChild(this._sectionTitle); |
47 this._sectionTitle.textContent = WebInspector.UIString("Rendered Fonts"); | 47 this._sectionTitle.textContent = WebInspector.UIString("Rendered Fonts"); |
48 this._fontStatsSection = this.contentElement.createChild("div", "stats-secti
on"); | 48 this._fontStatsSection = this.contentElement.createChild("div", "stats-secti
on"); |
49 } | 49 }; |
50 | 50 |
51 WebInspector.PlatformFontsWidget.prototype = { | 51 WebInspector.PlatformFontsWidget.prototype = { |
52 /** | 52 /** |
53 * @override | 53 * @override |
54 * @protected | 54 * @protected |
55 * @return {!Promise.<?>} | 55 * @return {!Promise.<?>} |
56 */ | 56 */ |
57 doUpdate: function() | 57 doUpdate: function() |
58 { | 58 { |
59 var cssModel = this._sharedModel.cssModel(); | 59 var cssModel = this._sharedModel.cssModel(); |
60 var node = this._sharedModel.node(); | 60 var node = this._sharedModel.node(); |
61 if (!node || !cssModel) | 61 if (!node || !cssModel) |
62 return Promise.resolve(); | 62 return Promise.resolve(); |
63 | 63 |
64 return cssModel.platformFontsPromise(node.id) | 64 return cssModel.platformFontsPromise(node.id) |
65 .then(this._refreshUI.bind(this, node)) | 65 .then(this._refreshUI.bind(this, node)); |
66 }, | 66 }, |
67 | 67 |
68 /** | 68 /** |
69 * @param {!WebInspector.DOMNode} node | 69 * @param {!WebInspector.DOMNode} node |
70 * @param {?Array.<!CSSAgent.PlatformFontUsage>} platformFonts | 70 * @param {?Array.<!CSSAgent.PlatformFontUsage>} platformFonts |
71 */ | 71 */ |
72 _refreshUI: function(node, platformFonts) | 72 _refreshUI: function(node, platformFonts) |
73 { | 73 { |
74 if (this._sharedModel.node() !== node) | 74 if (this._sharedModel.node() !== node) |
75 return; | 75 return; |
(...skipping 20 matching lines...) Expand all Loading... |
96 var fontOrigin = fontStatElement.createChild("span"); | 96 var fontOrigin = fontStatElement.createChild("span"); |
97 fontOrigin.textContent = platformFonts[i].isCustomFont ? WebInspecto
r.UIString("Network resource") : WebInspector.UIString("Local file"); | 97 fontOrigin.textContent = platformFonts[i].isCustomFont ? WebInspecto
r.UIString("Network resource") : WebInspector.UIString("Local file"); |
98 | 98 |
99 var fontUsageElement = fontStatElement.createChild("span", "font-usa
ge"); | 99 var fontUsageElement = fontStatElement.createChild("span", "font-usa
ge"); |
100 var usage = platformFonts[i].glyphCount; | 100 var usage = platformFonts[i].glyphCount; |
101 fontUsageElement.textContent = usage === 1 ? WebInspector.UIString("
(%d glyph)", usage) : WebInspector.UIString("(%d glyphs)", usage); | 101 fontUsageElement.textContent = usage === 1 ? WebInspector.UIString("
(%d glyph)", usage) : WebInspector.UIString("(%d glyphs)", usage); |
102 } | 102 } |
103 }, | 103 }, |
104 | 104 |
105 __proto__: WebInspector.ThrottledWidget.prototype | 105 __proto__: WebInspector.ThrottledWidget.prototype |
106 } | 106 }; |
OLD | NEW |