Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/elements/PlatformFontsWidget.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.PlatformFontsWidget = class extends WebInspector.ThrottledWidget { 34 Elements.PlatformFontsWidget = class extends UI.ThrottledWidget {
35 /** 35 /**
36 * @param {!WebInspector.ComputedStyleModel} sharedModel 36 * @param {!Elements.ComputedStyleModel} sharedModel
37 */ 37 */
38 constructor(sharedModel) { 38 constructor(sharedModel) {
39 super(true); 39 super(true);
40 this.registerRequiredCSS('elements/platformFontsWidget.css'); 40 this.registerRequiredCSS('elements/platformFontsWidget.css');
41 41
42 this._sharedModel = sharedModel; 42 this._sharedModel = sharedModel;
43 this._sharedModel.addEventListener(WebInspector.ComputedStyleModel.Events.Co mputedStyleChanged, this.update, this); 43 this._sharedModel.addEventListener(Elements.ComputedStyleModel.Events.Comput edStyleChanged, this.update, this);
44 44
45 this._sectionTitle = createElementWithClass('div', 'title'); 45 this._sectionTitle = createElementWithClass('div', 'title');
46 this.contentElement.classList.add('platform-fonts'); 46 this.contentElement.classList.add('platform-fonts');
47 this.contentElement.appendChild(this._sectionTitle); 47 this.contentElement.appendChild(this._sectionTitle);
48 this._sectionTitle.textContent = WebInspector.UIString('Rendered Fonts'); 48 this._sectionTitle.textContent = Common.UIString('Rendered Fonts');
49 this._fontStatsSection = this.contentElement.createChild('div', 'stats-secti on'); 49 this._fontStatsSection = this.contentElement.createChild('div', 'stats-secti on');
50 } 50 }
51 51
52 /** 52 /**
53 * @override 53 * @override
54 * @protected 54 * @protected
55 * @return {!Promise.<?>} 55 * @return {!Promise.<?>}
56 */ 56 */
57 doUpdate() { 57 doUpdate() {
58 var cssModel = this._sharedModel.cssModel(); 58 var cssModel = this._sharedModel.cssModel();
59 var node = this._sharedModel.node(); 59 var node = this._sharedModel.node();
60 if (!node || !cssModel) 60 if (!node || !cssModel)
61 return Promise.resolve(); 61 return Promise.resolve();
62 62
63 return cssModel.platformFontsPromise(node.id).then(this._refreshUI.bind(this , node)); 63 return cssModel.platformFontsPromise(node.id).then(this._refreshUI.bind(this , node));
64 } 64 }
65 65
66 /** 66 /**
67 * @param {!WebInspector.DOMNode} node 67 * @param {!SDK.DOMNode} node
68 * @param {?Array.<!Protocol.CSS.PlatformFontUsage>} platformFonts 68 * @param {?Array.<!Protocol.CSS.PlatformFontUsage>} platformFonts
69 */ 69 */
70 _refreshUI(node, platformFonts) { 70 _refreshUI(node, platformFonts) {
71 if (this._sharedModel.node() !== node) 71 if (this._sharedModel.node() !== node)
72 return; 72 return;
73 73
74 this._fontStatsSection.removeChildren(); 74 this._fontStatsSection.removeChildren();
75 75
76 var isEmptySection = !platformFonts || !platformFonts.length; 76 var isEmptySection = !platformFonts || !platformFonts.length;
77 this._sectionTitle.classList.toggle('hidden', isEmptySection); 77 this._sectionTitle.classList.toggle('hidden', isEmptySection);
78 if (isEmptySection) 78 if (isEmptySection)
79 return; 79 return;
80 80
81 platformFonts.sort(function(a, b) { 81 platformFonts.sort(function(a, b) {
82 return b.glyphCount - a.glyphCount; 82 return b.glyphCount - a.glyphCount;
83 }); 83 });
84 for (var i = 0; i < platformFonts.length; ++i) { 84 for (var i = 0; i < platformFonts.length; ++i) {
85 var fontStatElement = this._fontStatsSection.createChild('div', 'font-stat s-item'); 85 var fontStatElement = this._fontStatsSection.createChild('div', 'font-stat s-item');
86 86
87 var fontNameElement = fontStatElement.createChild('span', 'font-name'); 87 var fontNameElement = fontStatElement.createChild('span', 'font-name');
88 fontNameElement.textContent = platformFonts[i].familyName; 88 fontNameElement.textContent = platformFonts[i].familyName;
89 89
90 var fontDelimeterElement = fontStatElement.createChild('span', 'font-delim eter'); 90 var fontDelimeterElement = fontStatElement.createChild('span', 'font-delim eter');
91 fontDelimeterElement.textContent = '\u2014'; 91 fontDelimeterElement.textContent = '\u2014';
92 92
93 var fontOrigin = fontStatElement.createChild('span'); 93 var fontOrigin = fontStatElement.createChild('span');
94 fontOrigin.textContent = platformFonts[i].isCustomFont ? WebInspector.UISt ring('Network resource') : 94 fontOrigin.textContent = platformFonts[i].isCustomFont ? Common.UIString(' Network resource') :
95 WebInspector.UISt ring('Local file'); 95 Common.UIString(' Local file');
96 96
97 var fontUsageElement = fontStatElement.createChild('span', 'font-usage'); 97 var fontUsageElement = fontStatElement.createChild('span', 'font-usage');
98 var usage = platformFonts[i].glyphCount; 98 var usage = platformFonts[i].glyphCount;
99 fontUsageElement.textContent = 99 fontUsageElement.textContent =
100 usage === 1 ? WebInspector.UIString('(%d glyph)', usage) : WebInspecto r.UIString('(%d glyphs)', usage); 100 usage === 1 ? Common.UIString('(%d glyph)', usage) : Common.UIString(' (%d glyphs)', usage);
101 } 101 }
102 } 102 }
103 }; 103 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698