| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 * @protected | 64 * @protected |
| 65 */ | 65 */ |
| 66 doUpdate: function(finishedCallback) | 66 doUpdate: function(finishedCallback) |
| 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 finishedCallback(); |
| 72 return; | 72 return; |
| 73 } | 73 } |
| 74 cssModel.getPlatformFontsForNode(node.id, this._refreshUI.bind(this, nod
e, finishedCallback)); | 74 cssModel.platformFontsPromise(node.id) |
| 75 .then(this._refreshUI.bind(this, node)) |
| 76 .then(finishedCallback) |
| 77 .catch(/** @type {function()} */(finishedCallback)); |
| 75 }, | 78 }, |
| 76 | 79 |
| 77 /** | 80 /** |
| 78 * @param {!WebInspector.DOMNode} node | 81 * @param {!WebInspector.DOMNode} node |
| 79 * @param {!WebInspector.Throttler.FinishCallback} finishedCallback | |
| 80 * @param {?Array.<!CSSAgent.PlatformFontUsage>} platformFonts | 82 * @param {?Array.<!CSSAgent.PlatformFontUsage>} platformFonts |
| 81 */ | 83 */ |
| 82 _refreshUI: function(node, finishedCallback, platformFonts) | 84 _refreshUI: function(node, platformFonts) |
| 83 { | 85 { |
| 84 if (this._sharedModel.node() !== node) { | 86 if (this._sharedModel.node() !== node) |
| 85 finishedCallback(); | |
| 86 return; | 87 return; |
| 87 } | |
| 88 | 88 |
| 89 this._fontStatsSection.removeChildren(); | 89 this._fontStatsSection.removeChildren(); |
| 90 | 90 |
| 91 var isEmptySection = !platformFonts || !platformFonts.length; | 91 var isEmptySection = !platformFonts || !platformFonts.length; |
| 92 this._sectionTitle.classList.toggle("hidden", isEmptySection); | 92 this._sectionTitle.classList.toggle("hidden", isEmptySection); |
| 93 if (isEmptySection) { | 93 if (isEmptySection) |
| 94 finishedCallback(); | |
| 95 return; | 94 return; |
| 96 } | 95 |
| 97 platformFonts.sort(function (a, b) { | 96 platformFonts.sort(function (a, b) { |
| 98 return b.glyphCount - a.glyphCount; | 97 return b.glyphCount - a.glyphCount; |
| 99 }); | 98 }); |
| 100 for (var i = 0; i < platformFonts.length; ++i) { | 99 for (var i = 0; i < platformFonts.length; ++i) { |
| 101 var fontStatElement = this._fontStatsSection.createChild("div", "fon
t-stats-item"); | 100 var fontStatElement = this._fontStatsSection.createChild("div", "fon
t-stats-item"); |
| 102 | 101 |
| 103 var fontNameElement = fontStatElement.createChild("span", "font-name
"); | 102 var fontNameElement = fontStatElement.createChild("span", "font-name
"); |
| 104 fontNameElement.textContent = platformFonts[i].familyName; | 103 fontNameElement.textContent = platformFonts[i].familyName; |
| 105 | 104 |
| 106 var fontDelimeterElement = fontStatElement.createChild("span", "deli
meter"); | 105 var fontDelimeterElement = fontStatElement.createChild("span", "deli
meter"); |
| 107 fontDelimeterElement.textContent = "\u2014"; | 106 fontDelimeterElement.textContent = "\u2014"; |
| 108 | 107 |
| 109 var fontUsageElement = fontStatElement.createChild("span", "font-usa
ge"); | 108 var fontUsageElement = fontStatElement.createChild("span", "font-usa
ge"); |
| 110 var usage = platformFonts[i].glyphCount; | 109 var usage = platformFonts[i].glyphCount; |
| 111 fontUsageElement.textContent = usage === 1 ? WebInspector.UIString("
%d glyph", usage) : WebInspector.UIString("%d glyphs", usage); | 110 fontUsageElement.textContent = usage === 1 ? WebInspector.UIString("
%d glyph", usage) : WebInspector.UIString("%d glyphs", usage); |
| 112 } | 111 } |
| 113 finishedCallback(); | |
| 114 }, | 112 }, |
| 115 | 113 |
| 116 __proto__: WebInspector.ThrottledWidget.prototype | 114 __proto__: WebInspector.ThrottledWidget.prototype |
| 117 } | 115 } |
| OLD | NEW |