| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 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.classList.add("platform-fonts"); | 38 this.element.classList.add("platform-fonts"); |
| 39 WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.AttrModi
fied, this._onNodeChange.bind(this)); | |
| 40 WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.AttrRemo
ved, this._onNodeChange.bind(this)); | |
| 41 WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.Characte
rDataModified, this._onNodeChange.bind(this)); | |
| 42 | 39 |
| 43 this._sectionTitle = document.createElementWithClass("div", "sidebar-separat
or"); | 40 this._sectionTitle = document.createElementWithClass("div", "sidebar-separat
or"); |
| 44 this.element.insertBefore(this._sectionTitle, this.bodyElement); | 41 this.element.insertBefore(this._sectionTitle, this.bodyElement); |
| 45 this._sectionTitle.textContent = WebInspector.UIString("Rendered Fonts"); | 42 this._sectionTitle.textContent = WebInspector.UIString("Rendered Fonts"); |
| 46 this._fontStatsSection = this.bodyElement.createChild("div", "stats-section"
); | 43 this._fontStatsSection = this.bodyElement.createChild("div", "stats-section"
); |
| 47 } | 44 } |
| 48 | 45 |
| 49 WebInspector.PlatformFontsSidebarPane.prototype = { | 46 WebInspector.PlatformFontsSidebarPane.prototype = { |
| 50 _onNodeChange: function() | 47 _onNodeChange: function() |
| 51 { | 48 { |
| 52 if (this._innerUpdateTimeout) | 49 if (this._innerUpdateTimeout) |
| 53 return; | 50 return; |
| 54 this._innerUpdateTimeout = setTimeout(this._innerUpdate.bind(this), 100)
; | 51 this._innerUpdateTimeout = setTimeout(this._innerUpdate.bind(this), 100)
; |
| 55 }, | 52 }, |
| 56 | 53 |
| 57 /** | 54 /** |
| 58 * @param {?WebInspector.DOMNode} node | 55 * @param {?WebInspector.DOMNode} node |
| 59 */ | 56 */ |
| 60 update: function(node) | 57 update: function(node) |
| 61 { | 58 { |
| 62 if (!node) { | 59 if (!node) { |
| 63 delete this._node; | 60 delete this._node; |
| 64 return; | 61 return; |
| 65 } | 62 } |
| 66 this._node = node; | 63 this._node = node; |
| 64 this._updateTarget(node.target()); |
| 67 this._innerUpdate(); | 65 this._innerUpdate(); |
| 68 }, | 66 }, |
| 69 | 67 |
| 68 /** |
| 69 * @param {!WebInspector.Target} target |
| 70 */ |
| 71 _updateTarget: function(target) |
| 72 { |
| 73 if (this._target === target) |
| 74 return; |
| 75 if (this._target) { |
| 76 this._target.domModel.removeEventListener(WebInspector.DOMModel.Even
ts.AttrModified, this._onNodeChange, this); |
| 77 this._target.domModel.removeEventListener(WebInspector.DOMModel.Even
ts.AttrRemoved, this._onNodeChange, this); |
| 78 this._target.domModel.removeEventListener(WebInspector.DOMModel.Even
ts.CharacterDataModified, this._onNodeChange, this); |
| 79 } |
| 80 this._target = target; |
| 81 this._target.domModel.addEventListener(WebInspector.DOMModel.Events.Attr
Modified, this._onNodeChange, this); |
| 82 this._target.domModel.addEventListener(WebInspector.DOMModel.Events.Attr
Removed, this._onNodeChange, this); |
| 83 this._target.domModel.addEventListener(WebInspector.DOMModel.Events.Char
acterDataModified, this._onNodeChange, this); |
| 84 }, |
| 85 |
| 70 _innerUpdate: function() | 86 _innerUpdate: function() |
| 71 { | 87 { |
| 72 if (this._innerUpdateTimeout) { | 88 if (this._innerUpdateTimeout) { |
| 73 clearTimeout(this._innerUpdateTimeout); | 89 clearTimeout(this._innerUpdateTimeout); |
| 74 delete this._innerUpdateTimeout; | 90 delete this._innerUpdateTimeout; |
| 75 } | 91 } |
| 76 if (!this._node) | 92 if (!this._node) |
| 77 return; | 93 return; |
| 78 WebInspector.cssModel.getPlatformFontsForNode(this._node.id, this._refre
shUI.bind(this, this._node)); | 94 this._target.cssModel.getPlatformFontsForNode(this._node.id, this._refre
shUI.bind(this, this._node)); |
| 79 }, | 95 }, |
| 80 | 96 |
| 81 /** | 97 /** |
| 82 * @param {!WebInspector.DOMNode} node | 98 * @param {!WebInspector.DOMNode} node |
| 83 * @param {?string} cssFamilyName | 99 * @param {?string} cssFamilyName |
| 84 * @param {?Array.<!CSSAgent.PlatformFontUsage>} platformFonts | 100 * @param {?Array.<!CSSAgent.PlatformFontUsage>} platformFonts |
| 85 */ | 101 */ |
| 86 _refreshUI: function(node, cssFamilyName, platformFonts) | 102 _refreshUI: function(node, cssFamilyName, platformFonts) |
| 87 { | 103 { |
| 88 if (this._node !== node) | 104 if (this._node !== node) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 107 fontDelimeterElement.textContent = "\u2014"; | 123 fontDelimeterElement.textContent = "\u2014"; |
| 108 | 124 |
| 109 var fontUsageElement = fontStatElement.createChild("span", "font-usa
ge"); | 125 var fontUsageElement = fontStatElement.createChild("span", "font-usa
ge"); |
| 110 var usage = platformFonts[i].glyphCount; | 126 var usage = platformFonts[i].glyphCount; |
| 111 fontUsageElement.textContent = usage === 1 ? WebInspector.UIString("
%d glyph", usage) : WebInspector.UIString("%d glyphs", usage); | 127 fontUsageElement.textContent = usage === 1 ? WebInspector.UIString("
%d glyph", usage) : WebInspector.UIString("%d glyphs", usage); |
| 112 } | 128 } |
| 113 }, | 129 }, |
| 114 | 130 |
| 115 __proto__: WebInspector.SidebarPane.prototype | 131 __proto__: WebInspector.SidebarPane.prototype |
| 116 } | 132 } |
| OLD | NEW |