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 22 matching lines...) Expand all Loading... | |
33 * @extends {WebInspector.SidebarPane} | 33 * @extends {WebInspector.SidebarPane} |
34 */ | 34 */ |
35 WebInspector.PlatformFontsSidebarPane = function() | 35 WebInspector.PlatformFontsSidebarPane = function() |
36 { | 36 { |
37 WebInspector.SidebarPane.call(this, WebInspector.UIString("Fonts")); | 37 WebInspector.SidebarPane.call(this, WebInspector.UIString("Fonts")); |
38 this.element.addStyleClass("platform-fonts"); | 38 this.element.addStyleClass("platform-fonts"); |
39 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrModi fied, this._onNodeChange.bind(this)); | 39 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrModi fied, this._onNodeChange.bind(this)); |
40 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrRemo ved, this._onNodeChange.bind(this)); | 40 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrRemo ved, this._onNodeChange.bind(this)); |
41 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.Characte rDataModified, this._onNodeChange.bind(this)); | 41 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.Characte rDataModified, this._onNodeChange.bind(this)); |
42 | 42 |
43 var cssFontSection = this.element.createChild("div", "stats-section monospac e"); | 43 this._sectionTitle = document.createElement("div"); |
vsevik
2013/11/05 17:30:18
consider document.createElementwithClass
| |
44 var cssFontPrefix = cssFontSection.createChild("span", "webkit-css-property" ); | 44 this._sectionTitle.className = "sidebar-separator"; |
45 cssFontPrefix.textContent = "font-family"; | 45 this.element.insertBefore(this._sectionTitle, this.bodyElement); |
46 cssFontSection.createTextChild(":"); | 46 this._sectionTitle.textContent = WebInspector.UIString("Rendered Fonts"); |
47 this._cssFontValue = cssFontSection.createChild("span", "css-font-value"); | 47 this._fontStatsSection = this.bodyElement.createChild("div", "stats-section" ); |
48 | |
49 this._fontStatsSection = this.element.createChild("div", "stats-section"); | |
50 } | 48 } |
51 | 49 |
52 WebInspector.PlatformFontsSidebarPane.prototype = { | 50 WebInspector.PlatformFontsSidebarPane.prototype = { |
53 _onNodeChange: function() | 51 _onNodeChange: function() |
54 { | 52 { |
55 if (this._innerUpdateTimeout) | 53 if (this._innerUpdateTimeout) |
56 return; | 54 return; |
57 this._innerUpdateTimeout = setTimeout(this._innerUpdate.bind(this), 100) ; | 55 this._innerUpdateTimeout = setTimeout(this._innerUpdate.bind(this), 100) ; |
58 }, | 56 }, |
59 | 57 |
(...skipping 22 matching lines...) Expand all Loading... | |
82 }, | 80 }, |
83 | 81 |
84 /** | 82 /** |
85 * @param {String} cssFamilyName | 83 * @param {String} cssFamilyName |
86 * @param {WebInspector.DOMNode} node | 84 * @param {WebInspector.DOMNode} node |
87 */ | 85 */ |
88 _refreshUI: function(node, cssFamilyName, platformFonts) | 86 _refreshUI: function(node, cssFamilyName, platformFonts) |
89 { | 87 { |
90 if (this._node !== node) | 88 if (this._node !== node) |
91 return; | 89 return; |
92 this._cssFontValue.textContent = cssFamilyName + ";"; | 90 |
93 this._fontStatsSection.removeChildren(); | 91 this._fontStatsSection.removeChildren(); |
94 | 92 |
95 if (!platformFonts || !platformFonts.length) | 93 var isEmptySection = !platformFonts || !platformFonts.length; |
94 this._sectionTitle.enableStyleClass("hidden", isEmptySection); | |
95 if (isEmptySection) | |
96 return; | 96 return; |
97 platformFonts.sort(function (a, b) { | 97 platformFonts.sort(function (a, b) { |
98 return b.glyphCount - a.glyphCount; | 98 return b.glyphCount - a.glyphCount; |
99 }); | 99 }); |
100 for (var i = 0; i < platformFonts.length; ++i) { | 100 for (var i = 0; i < platformFonts.length; ++i) { |
101 var fontStatElement = this._fontStatsSection.createChild("div", "fon t-stats-item"); | 101 var fontStatElement = this._fontStatsSection.createChild("div", "fon t-stats-item"); |
102 | 102 |
103 var fontNameElement = fontStatElement.createChild("span", "font-name "); | 103 var fontNameElement = fontStatElement.createChild("span", "font-name "); |
104 fontNameElement.textContent = platformFonts[i].familyName; | 104 fontNameElement.textContent = platformFonts[i].familyName; |
105 | 105 |
106 var fontDelimeterElement = fontStatElement.createChild("span", "deli meter"); | 106 var fontDelimeterElement = fontStatElement.createChild("span", "deli meter"); |
107 fontDelimeterElement.textContent = "\u2014"; | 107 fontDelimeterElement.textContent = "\u2014"; |
108 | 108 |
109 var fontUsageElement = fontStatElement.createChild("span", "font-usa ge"); | 109 var fontUsageElement = fontStatElement.createChild("span", "font-usa ge"); |
110 var usage = platformFonts[i].glyphCount; | 110 var usage = platformFonts[i].glyphCount; |
111 fontUsageElement.textContent = usage === 1 ? WebInspector.UIString(" %d glyph", usage) : WebInspector.UIString("%d glyphs", usage); | 111 fontUsageElement.textContent = usage === 1 ? WebInspector.UIString(" %d glyph", usage) : WebInspector.UIString("%d glyphs", usage); |
112 } | 112 } |
113 }, | 113 }, |
114 | 114 |
115 __proto__: WebInspector.SidebarPane.prototype | 115 __proto__: WebInspector.SidebarPane.prototype |
116 } | 116 } |
OLD | NEW |