| 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.createElementWithClass("div", "sidebar-separat
or"); |
| 44 var cssFontPrefix = cssFontSection.createChild("span", "webkit-css-property"
); | 44 this.element.insertBefore(this._sectionTitle, this.bodyElement); |
| 45 cssFontPrefix.textContent = "font-family"; | 45 this._sectionTitle.textContent = WebInspector.UIString("Rendered Fonts"); |
| 46 cssFontSection.createTextChild(":"); | 46 this._fontStatsSection = this.bodyElement.createChild("div", "stats-section"
); |
| 47 this._cssFontValue = cssFontSection.createChild("span", "css-font-value"); | |
| 48 | |
| 49 this._fontStatsSection = this.element.createChild("div", "stats-section"); | |
| 50 } | 47 } |
| 51 | 48 |
| 52 WebInspector.PlatformFontsSidebarPane.prototype = { | 49 WebInspector.PlatformFontsSidebarPane.prototype = { |
| 53 _onNodeChange: function() | 50 _onNodeChange: function() |
| 54 { | 51 { |
| 55 if (this._innerUpdateTimeout) | 52 if (this._innerUpdateTimeout) |
| 56 return; | 53 return; |
| 57 this._innerUpdateTimeout = setTimeout(this._innerUpdate.bind(this), 100)
; | 54 this._innerUpdateTimeout = setTimeout(this._innerUpdate.bind(this), 100)
; |
| 58 }, | 55 }, |
| 59 | 56 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 82 }, | 79 }, |
| 83 | 80 |
| 84 /** | 81 /** |
| 85 * @param {String} cssFamilyName | 82 * @param {String} cssFamilyName |
| 86 * @param {WebInspector.DOMNode} node | 83 * @param {WebInspector.DOMNode} node |
| 87 */ | 84 */ |
| 88 _refreshUI: function(node, cssFamilyName, platformFonts) | 85 _refreshUI: function(node, cssFamilyName, platformFonts) |
| 89 { | 86 { |
| 90 if (this._node !== node) | 87 if (this._node !== node) |
| 91 return; | 88 return; |
| 92 this._cssFontValue.textContent = cssFamilyName + ";"; | 89 |
| 93 this._fontStatsSection.removeChildren(); | 90 this._fontStatsSection.removeChildren(); |
| 94 | 91 |
| 95 if (!platformFonts || !platformFonts.length) | 92 var isEmptySection = !platformFonts || !platformFonts.length; |
| 93 this._sectionTitle.enableStyleClass("hidden", isEmptySection); |
| 94 if (isEmptySection) |
| 96 return; | 95 return; |
| 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 }, | 112 }, |
| 114 | 113 |
| 115 __proto__: WebInspector.SidebarPane.prototype | 114 __proto__: WebInspector.SidebarPane.prototype |
| 116 } | 115 } |
| OLD | NEW |