Chromium Code Reviews| 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 = new WebInspector.HBox(); |
|
dgozman
2015/06/11 08:39:31
Just create a div with "hbox" class.
pfeldman
2015/06/11 09:56:02
Done.
| |
| 49 inheritedCheckBox.classList.add("checkbox-with-label"); | 51 hbox.element.classList.add("styles-sidebarpane-toolbar"); |
|
dgozman
2015/06/11 08:39:31
nit: sidebar-pane (with a dash) for consistency
pfeldman
2015/06/11 09:56:02
Done.
| |
| 50 this.element.appendChild(inheritedCheckBox); | 52 hbox.show(this.element); |
| 51 this.element.classList.add("computed-style-sidebar-pane"); | 53 var filterContainerElement = hbox.element.createChild("div", "styles-sidebar -pane-filter-box"); |
| 52 this._showInheritedComputedStylePropertiesSetting.addChangeListener(this._sh owInheritedComputedStyleChanged.bind(this)); | 54 var filterInput = WebInspector.StylesSidebarPane.createPropertyFilterElement (WebInspector.UIString("Filter"), hbox.element, filterCallback.bind(this)); |
| 55 filterContainerElement.appendChild(filterInput); | |
| 56 | |
| 57 var toolbar = new WebInspector.Toolbar(hbox.element); | |
| 58 toolbar.element.classList.add("styles-pane-toolbar"); | |
|
dgozman
2015/06/11 08:39:31
nit: pane -> sidebar-pane
pfeldman
2015/06/11 09:56:02
Not changing it - it has been there for tests.
| |
| 59 toolbar.appendToolbarItem(new WebInspector.ToolbarCheckbox(WebInspector.UISt ring("Show inherited"), | |
| 60 WebInspector.UISt ring("Show inherited properties"), | |
| 61 this._showInherit edComputedStylePropertiesSetting)); | |
| 53 | 62 |
| 54 this._propertiesContainer = this.element.createChild("div", "monospace"); | 63 this._propertiesContainer = this.element.createChild("div", "monospace"); |
| 55 this._propertiesContainer.classList.add("computed-properties"); | 64 this._propertiesContainer.classList.add("computed-properties"); |
| 56 this._onTracePropertyBound = this._onTraceProperty.bind(this); | 65 this._onTracePropertyBound = this._onTraceProperty.bind(this); |
| 57 | 66 |
| 58 this._stylesSidebarPane = stylesSidebarPane; | 67 this._stylesSidebarPane = stylesSidebarPane; |
| 59 this._installFilter(filterContainer); | 68 |
| 69 /** | |
| 70 * @param {?RegExp} regex | |
| 71 * @this {WebInspector.ComputedStyleWidget} | |
| 72 */ | |
| 73 function filterCallback(regex) | |
| 74 { | |
| 75 this._filterRegex = regex; | |
| 76 this._updateFilter(regex); | |
| 77 } | |
| 60 } | 78 } |
| 61 | 79 |
| 62 /** | 80 /** |
| 63 * @param {!WebInspector.StylesSidebarPane} stylesSidebarPane | 81 * @param {!WebInspector.StylesSidebarPane} stylesSidebarPane |
| 64 * @param {!WebInspector.SharedSidebarModel} sharedModel | 82 * @param {!WebInspector.SharedSidebarModel} sharedModel |
| 65 * @param {!Element} filterContainer | |
| 66 * @return {!WebInspector.ElementsSidebarViewWrapperPane} | 83 * @return {!WebInspector.ElementsSidebarViewWrapperPane} |
| 67 */ | 84 */ |
| 68 WebInspector.ComputedStyleWidget.createSidebarWrapper = function(stylesSidebarPa ne, sharedModel, filterContainer) | 85 WebInspector.ComputedStyleWidget.createSidebarWrapper = function(stylesSidebarPa ne, sharedModel) |
| 69 { | 86 { |
| 70 var widget = new WebInspector.ComputedStyleWidget(stylesSidebarPane, sharedM odel, filterContainer); | 87 var widget = new WebInspector.ComputedStyleWidget(stylesSidebarPane, sharedM odel); |
| 71 return new WebInspector.ElementsSidebarViewWrapperPane(WebInspector.UIString ("Computed Style"), widget) | 88 return new WebInspector.ElementsSidebarViewWrapperPane(WebInspector.UIString ("Computed Style"), widget) |
| 72 } | 89 } |
| 73 | 90 |
| 74 WebInspector.ComputedStyleWidget._propertySymbol = Symbol("property"); | 91 WebInspector.ComputedStyleWidget._propertySymbol = Symbol("property"); |
| 75 | 92 |
| 76 WebInspector.ComputedStyleWidget.prototype = { | 93 WebInspector.ComputedStyleWidget.prototype = { |
| 77 /** | 94 /** |
| 78 * @param {!Event} event | 95 * @param {!Event} event |
| 79 */ | 96 */ |
| 80 _onTraceProperty: function(event) | 97 _onTraceProperty: function(event) |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 _updateFilter: function(regex) | 206 _updateFilter: function(regex) |
| 190 { | 207 { |
| 191 for (var i = 0; i < this._propertiesContainer.children.length; ++i) { | 208 for (var i = 0; i < this._propertiesContainer.children.length; ++i) { |
| 192 var item = this._propertiesContainer.children[i]; | 209 var item = this._propertiesContainer.children[i]; |
| 193 var property = item[WebInspector.ComputedStyleWidget._propertySymbol ]; | 210 var property = item[WebInspector.ComputedStyleWidget._propertySymbol ]; |
| 194 var matched = !regex || regex.test(property.name) || regex.test(prop erty.value); | 211 var matched = !regex || regex.test(property.name) || regex.test(prop erty.value); |
| 195 item.classList.toggle("hidden", !matched); | 212 item.classList.toggle("hidden", !matched); |
| 196 } | 213 } |
| 197 }, | 214 }, |
| 198 | 215 |
| 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 | 216 __proto__: WebInspector.ThrottledWidget.prototype |
| 218 } | 217 } |
| OLD | NEW |