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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 */ | 53 */ |
54 WebInspector.PlatformFontsWidget.createSidebarWrapper = function(sharedModel) | 54 WebInspector.PlatformFontsWidget.createSidebarWrapper = function(sharedModel) |
55 { | 55 { |
56 var widget = new WebInspector.PlatformFontsWidget(sharedModel); | 56 var widget = new WebInspector.PlatformFontsWidget(sharedModel); |
57 return new WebInspector.ElementsSidebarViewWrapperPane(WebInspector.UIString
("Fonts"), widget) | 57 return new WebInspector.ElementsSidebarViewWrapperPane(WebInspector.UIString
("Fonts"), widget) |
58 } | 58 } |
59 | 59 |
60 WebInspector.PlatformFontsWidget.prototype = { | 60 WebInspector.PlatformFontsWidget.prototype = { |
61 /** | 61 /** |
62 * @override | 62 * @override |
63 * @param {!WebInspector.Throttler.FinishCallback} finishedCallback | |
64 * @protected | 63 * @protected |
| 64 * @return {!Promise.<?>} |
65 */ | 65 */ |
66 doUpdate: function(finishedCallback) | 66 doUpdate: function() |
67 { | 67 { |
68 var cssModel = this._sharedModel.cssModel(); | 68 var cssModel = this._sharedModel.cssModel(); |
69 var node = this._sharedModel.node(); | 69 var node = this._sharedModel.node(); |
70 if (!node || !cssModel) { | 70 if (!node || !cssModel) |
71 finishedCallback(); | 71 return Promise.resolve(); |
72 return; | 72 |
73 } | 73 return cssModel.platformFontsPromise(node.id) |
74 cssModel.platformFontsPromise(node.id) | |
75 .then(this._refreshUI.bind(this, node)) | 74 .then(this._refreshUI.bind(this, node)) |
76 .then(finishedCallback) | |
77 .catch(/** @type {function()} */(finishedCallback)); | |
78 }, | 75 }, |
79 | 76 |
80 /** | 77 /** |
81 * @param {!WebInspector.DOMNode} node | 78 * @param {!WebInspector.DOMNode} node |
82 * @param {?Array.<!CSSAgent.PlatformFontUsage>} platformFonts | 79 * @param {?Array.<!CSSAgent.PlatformFontUsage>} platformFonts |
83 */ | 80 */ |
84 _refreshUI: function(node, platformFonts) | 81 _refreshUI: function(node, platformFonts) |
85 { | 82 { |
86 if (this._sharedModel.node() !== node) | 83 if (this._sharedModel.node() !== node) |
87 return; | 84 return; |
(...skipping 18 matching lines...) Expand all Loading... |
106 fontDelimeterElement.textContent = "\u2014"; | 103 fontDelimeterElement.textContent = "\u2014"; |
107 | 104 |
108 var fontUsageElement = fontStatElement.createChild("span", "font-usa
ge"); | 105 var fontUsageElement = fontStatElement.createChild("span", "font-usa
ge"); |
109 var usage = platformFonts[i].glyphCount; | 106 var usage = platformFonts[i].glyphCount; |
110 fontUsageElement.textContent = usage === 1 ? WebInspector.UIString("
%d glyph", usage) : WebInspector.UIString("%d glyphs", usage); | 107 fontUsageElement.textContent = usage === 1 ? WebInspector.UIString("
%d glyph", usage) : WebInspector.UIString("%d glyphs", usage); |
111 } | 108 } |
112 }, | 109 }, |
113 | 110 |
114 __proto__: WebInspector.ThrottledWidget.prototype | 111 __proto__: WebInspector.ThrottledWidget.prototype |
115 } | 112 } |
OLD | NEW |