| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * @constructor | 31 * @constructor |
| 32 * @param {!WebInspector.StylesSidebarPane} stylesSidebarPane | 32 * @param {!WebInspector.StylesSidebarPane} stylesSidebarPane |
| 33 * @param {!WebInspector.SharedSidebarModel} sharedModel | 33 * @param {!WebInspector.SharedSidebarModel} sharedModel |
| 34 * @param {!Element} filterContainer | |
| 35 * @extends {WebInspector.ThrottledWidget} | 34 * @extends {WebInspector.ThrottledWidget} |
| 36 */ | 35 */ |
| 37 WebInspector.ComputedStyleWidget = function(stylesSidebarPane, sharedModel, filt
erContainer) | 36 WebInspector.ComputedStyleWidget = function(stylesSidebarPane, sharedModel) |
| 38 { | 37 { |
| 39 WebInspector.ThrottledWidget.call(this); | 38 WebInspector.ThrottledWidget.call(this); |
| 39 this.element.classList.add("computed-style-sidebar-pane"); |
| 40 |
| 40 this.registerRequiredCSS("elements/computedStyleSidebarPane.css"); | 41 this.registerRequiredCSS("elements/computedStyleSidebarPane.css"); |
| 41 this._alwaysShowComputedProperties = { "display": true, "height": true, "wid
th": true }; | 42 this._alwaysShowComputedProperties = { "display": true, "height": true, "wid
th": true }; |
| 42 | 43 |
| 43 this._sharedModel = sharedModel; | 44 this._sharedModel = sharedModel; |
| 44 this._sharedModel.addEventListener(WebInspector.SharedSidebarModel.Events.Co
mputedStyleChanged, this.update, this); | 45 this._sharedModel.addEventListener(WebInspector.SharedSidebarModel.Events.Co
mputedStyleChanged, this.update, this); |
| 45 | 46 |
| 46 this._showInheritedComputedStylePropertiesSetting = WebInspector.settings.cr
eateSetting("showInheritedComputedStyleProperties", false); | 47 this._showInheritedComputedStylePropertiesSetting = WebInspector.settings.cr
eateSetting("showInheritedComputedStyleProperties", false); |
| 48 this._showInheritedComputedStylePropertiesSetting.addChangeListener(this._sh
owInheritedComputedStyleChanged.bind(this)); |
| 47 | 49 |
| 48 var inheritedCheckBox = WebInspector.SettingsUI.createSettingCheckbox(WebIns
pector.UIString("Show inherited properties"), this._showInheritedComputedStylePr
opertiesSetting, true); | 50 var hbox = this.element.createChild("div", "hbox styles-sidebar-pane-toolbar
"); |
| 49 inheritedCheckBox.classList.add("checkbox-with-label"); | 51 var filterContainerElement = hbox.createChild("div", "styles-sidebar-pane-fi
lter-box"); |
| 50 this.element.appendChild(inheritedCheckBox); | 52 var filterInput = WebInspector.StylesSidebarPane.createPropertyFilterElement
(WebInspector.UIString("Filter"), hbox, filterCallback.bind(this)); |
| 51 this.element.classList.add("computed-style-sidebar-pane"); | 53 filterContainerElement.appendChild(filterInput); |
| 52 this._showInheritedComputedStylePropertiesSetting.addChangeListener(this._sh
owInheritedComputedStyleChanged.bind(this)); | 54 |
| 55 var toolbar = new WebInspector.Toolbar(hbox); |
| 56 toolbar.element.classList.add("styles-pane-toolbar"); |
| 57 toolbar.appendToolbarItem(new WebInspector.ToolbarCheckbox(WebInspector.UISt
ring("Show inherited"), |
| 58 WebInspector.UISt
ring("Show inherited properties"), |
| 59 this._showInherit
edComputedStylePropertiesSetting)); |
| 53 | 60 |
| 54 this._propertiesContainer = this.element.createChild("div", "monospace"); | 61 this._propertiesContainer = this.element.createChild("div", "monospace"); |
| 55 this._propertiesContainer.classList.add("computed-properties"); | 62 this._propertiesContainer.classList.add("computed-properties"); |
| 56 this._onTracePropertyBound = this._onTraceProperty.bind(this); | 63 this._onTracePropertyBound = this._onTraceProperty.bind(this); |
| 57 | 64 |
| 58 this._stylesSidebarPane = stylesSidebarPane; | 65 this._stylesSidebarPane = stylesSidebarPane; |
| 59 this._installFilter(filterContainer); | 66 |
| 67 /** |
| 68 * @param {?RegExp} regex |
| 69 * @this {WebInspector.ComputedStyleWidget} |
| 70 */ |
| 71 function filterCallback(regex) |
| 72 { |
| 73 this._filterRegex = regex; |
| 74 this._updateFilter(regex); |
| 75 } |
| 60 } | 76 } |
| 61 | 77 |
| 62 /** | 78 /** |
| 63 * @param {!WebInspector.StylesSidebarPane} stylesSidebarPane | 79 * @param {!WebInspector.StylesSidebarPane} stylesSidebarPane |
| 64 * @param {!WebInspector.SharedSidebarModel} sharedModel | 80 * @param {!WebInspector.SharedSidebarModel} sharedModel |
| 65 * @param {!Element} filterContainer | |
| 66 * @return {!WebInspector.ElementsSidebarViewWrapperPane} | 81 * @return {!WebInspector.ElementsSidebarViewWrapperPane} |
| 67 */ | 82 */ |
| 68 WebInspector.ComputedStyleWidget.createSidebarWrapper = function(stylesSidebarPa
ne, sharedModel, filterContainer) | 83 WebInspector.ComputedStyleWidget.createSidebarWrapper = function(stylesSidebarPa
ne, sharedModel) |
| 69 { | 84 { |
| 70 var widget = new WebInspector.ComputedStyleWidget(stylesSidebarPane, sharedM
odel, filterContainer); | 85 var widget = new WebInspector.ComputedStyleWidget(stylesSidebarPane, sharedM
odel); |
| 71 return new WebInspector.ElementsSidebarViewWrapperPane(WebInspector.UIString
("Computed Style"), widget) | 86 return new WebInspector.ElementsSidebarViewWrapperPane(WebInspector.UIString
("Computed Style"), widget) |
| 72 } | 87 } |
| 73 | 88 |
| 74 WebInspector.ComputedStyleWidget._propertySymbol = Symbol("property"); | 89 WebInspector.ComputedStyleWidget._propertySymbol = Symbol("property"); |
| 75 | 90 |
| 76 WebInspector.ComputedStyleWidget.prototype = { | 91 WebInspector.ComputedStyleWidget.prototype = { |
| 77 /** | 92 /** |
| 78 * @param {!Event} event | 93 * @param {!Event} event |
| 79 */ | 94 */ |
| 80 _onTraceProperty: function(event) | 95 _onTraceProperty: function(event) |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 _updateFilter: function(regex) | 204 _updateFilter: function(regex) |
| 190 { | 205 { |
| 191 for (var i = 0; i < this._propertiesContainer.children.length; ++i) { | 206 for (var i = 0; i < this._propertiesContainer.children.length; ++i) { |
| 192 var item = this._propertiesContainer.children[i]; | 207 var item = this._propertiesContainer.children[i]; |
| 193 var property = item[WebInspector.ComputedStyleWidget._propertySymbol
]; | 208 var property = item[WebInspector.ComputedStyleWidget._propertySymbol
]; |
| 194 var matched = !regex || regex.test(property.name) || regex.test(prop
erty.value); | 209 var matched = !regex || regex.test(property.name) || regex.test(prop
erty.value); |
| 195 item.classList.toggle("hidden", !matched); | 210 item.classList.toggle("hidden", !matched); |
| 196 } | 211 } |
| 197 }, | 212 }, |
| 198 | 213 |
| 199 /** | |
| 200 * @param {!Element} container | |
| 201 */ | |
| 202 _installFilter: function(container) | |
| 203 { | |
| 204 container.appendChild(WebInspector.StylesSidebarPane.createPropertyFilte
rElement(WebInspector.UIString("Filter"), filterCallback.bind(this))); | |
| 205 | |
| 206 /** | |
| 207 * @param {?RegExp} regex | |
| 208 * @this {WebInspector.ComputedStyleWidget} | |
| 209 */ | |
| 210 function filterCallback(regex) | |
| 211 { | |
| 212 this._filterRegex = regex; | |
| 213 this._updateFilter(regex); | |
| 214 } | |
| 215 }, | |
| 216 | |
| 217 __proto__: WebInspector.ThrottledWidget.prototype | 214 __proto__: WebInspector.ThrottledWidget.prototype |
| 218 } | 215 } |
| OLD | NEW |