| 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 11 matching lines...) Expand all Loading... |
| 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 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 * @extends {WebInspector.ThrottledWidget} |
| 32 * @param {!WebInspector.StylesSidebarPane} stylesSidebarPane | 33 * @param {!WebInspector.StylesSidebarPane} stylesSidebarPane |
| 33 * @param {!WebInspector.SharedSidebarModel} sharedModel | 34 * @param {!WebInspector.SharedSidebarModel} sharedModel |
| 34 * @extends {WebInspector.ThrottledWidget} | 35 * @param {function(!WebInspector.CSSProperty)} revealCallback |
| 35 */ | 36 */ |
| 36 WebInspector.ComputedStyleWidget = function(stylesSidebarPane, sharedModel) | 37 WebInspector.ComputedStyleWidget = function(stylesSidebarPane, sharedModel, reve
alCallback) |
| 37 { | 38 { |
| 38 WebInspector.ThrottledWidget.call(this); | 39 WebInspector.ThrottledWidget.call(this); |
| 39 this.element.classList.add("computed-style-sidebar-pane"); | 40 this.element.classList.add("computed-style-sidebar-pane"); |
| 40 | 41 |
| 41 this.registerRequiredCSS("elements/computedStyleSidebarPane.css"); | 42 this.registerRequiredCSS("elements/computedStyleSidebarPane.css"); |
| 42 this._alwaysShowComputedProperties = { "display": true, "height": true, "wid
th": true }; | 43 this._alwaysShowComputedProperties = { "display": true, "height": true, "wid
th": true }; |
| 43 | 44 |
| 44 this._sharedModel = sharedModel; | 45 this._sharedModel = sharedModel; |
| 45 this._sharedModel.addEventListener(WebInspector.SharedSidebarModel.Events.Co
mputedStyleChanged, this.update, this); | 46 this._sharedModel.addEventListener(WebInspector.SharedSidebarModel.Events.Co
mputedStyleChanged, this.update, this); |
| 46 | 47 |
| 47 this._showInheritedComputedStylePropertiesSetting = WebInspector.settings.cr
eateSetting("showInheritedComputedStyleProperties", false); | 48 this._showInheritedComputedStylePropertiesSetting = WebInspector.settings.cr
eateSetting("showInheritedComputedStyleProperties", false); |
| 48 this._showInheritedComputedStylePropertiesSetting.addChangeListener(this._sh
owInheritedComputedStyleChanged.bind(this)); | 49 this._showInheritedComputedStylePropertiesSetting.addChangeListener(this._sh
owInheritedComputedStyleChanged.bind(this)); |
| 49 | 50 |
| 50 var hbox = this.element.createChild("div", "hbox styles-sidebar-pane-toolbar
"); | 51 var hbox = this.element.createChild("div", "hbox styles-sidebar-pane-toolbar
"); |
| 51 var filterContainerElement = hbox.createChild("div", "styles-sidebar-pane-fi
lter-box"); | 52 var filterContainerElement = hbox.createChild("div", "styles-sidebar-pane-fi
lter-box"); |
| 52 var filterInput = WebInspector.StylesSidebarPane.createPropertyFilterElement
(WebInspector.UIString("Filter"), hbox, filterCallback.bind(this)); | 53 var filterInput = WebInspector.StylesSidebarPane.createPropertyFilterElement
(WebInspector.UIString("Filter"), hbox, filterCallback.bind(this)); |
| 53 filterContainerElement.appendChild(filterInput); | 54 filterContainerElement.appendChild(filterInput); |
| 54 | 55 |
| 55 var toolbar = new WebInspector.Toolbar("styles-pane-toolbar", hbox); | 56 var toolbar = new WebInspector.Toolbar("styles-pane-toolbar", hbox); |
| 56 toolbar.appendToolbarItem(new WebInspector.ToolbarCheckbox(WebInspector.UISt
ring("Show all"), undefined, this._showInheritedComputedStylePropertiesSetting))
; | 57 toolbar.appendToolbarItem(new WebInspector.ToolbarCheckbox(WebInspector.UISt
ring("Show all"), undefined, this._showInheritedComputedStylePropertiesSetting))
; |
| 57 | 58 |
| 58 this._propertiesOutline = new TreeOutlineInShadow(); | 59 this._propertiesOutline = new TreeOutlineInShadow(); |
| 59 this._propertiesOutline.hideOverflow(); | 60 this._propertiesOutline.hideOverflow(); |
| 60 this._propertiesOutline.registerRequiredCSS("elements/computedStyleSidebarPa
ne.css"); | 61 this._propertiesOutline.registerRequiredCSS("elements/computedStyleSidebarPa
ne.css"); |
| 61 this._propertiesOutline.element.classList.add("monospace", "computed-propert
ies"); | 62 this._propertiesOutline.element.classList.add("monospace", "computed-propert
ies"); |
| 62 this.element.appendChild(this._propertiesOutline.element); | 63 this.element.appendChild(this._propertiesOutline.element); |
| 63 | 64 |
| 64 this._stylesSidebarPane = stylesSidebarPane; | 65 this._stylesSidebarPane = stylesSidebarPane; |
| 65 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa
ultCSSFormatter()); | 66 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa
ultCSSFormatter()); |
| 67 this._revealCallback = revealCallback; |
| 66 | 68 |
| 67 /** | 69 /** |
| 68 * @param {?RegExp} regex | 70 * @param {?RegExp} regex |
| 69 * @this {WebInspector.ComputedStyleWidget} | 71 * @this {WebInspector.ComputedStyleWidget} |
| 70 */ | 72 */ |
| 71 function filterCallback(regex) | 73 function filterCallback(regex) |
| 72 { | 74 { |
| 73 this._filterRegex = regex; | 75 this._filterRegex = regex; |
| 74 this._updateFilter(regex); | 76 this._updateFilter(regex); |
| 75 } | 77 } |
| 76 } | 78 } |
| 77 | 79 |
| 78 /** | 80 /** |
| 79 * @param {!WebInspector.StylesSidebarPane} stylesSidebarPane | 81 * @param {!WebInspector.StylesSidebarPane} stylesSidebarPane |
| 80 * @param {!WebInspector.SharedSidebarModel} sharedModel | 82 * @param {!WebInspector.SharedSidebarModel} sharedModel |
| 83 * @param {function(!WebInspector.CSSProperty)} revealCallback |
| 81 * @return {!WebInspector.ElementsSidebarViewWrapperPane} | 84 * @return {!WebInspector.ElementsSidebarViewWrapperPane} |
| 82 */ | 85 */ |
| 83 WebInspector.ComputedStyleWidget.createSidebarWrapper = function(stylesSidebarPa
ne, sharedModel) | 86 WebInspector.ComputedStyleWidget.createSidebarWrapper = function(stylesSidebarPa
ne, sharedModel, revealCallback) |
| 84 { | 87 { |
| 85 var widget = new WebInspector.ComputedStyleWidget(stylesSidebarPane, sharedM
odel); | 88 var widget = new WebInspector.ComputedStyleWidget(stylesSidebarPane, sharedM
odel, revealCallback); |
| 86 return new WebInspector.ElementsSidebarViewWrapperPane(WebInspector.UIString
("Computed Style"), widget) | 89 return new WebInspector.ElementsSidebarViewWrapperPane(WebInspector.UIString
("Computed Style"), widget) |
| 87 } | 90 } |
| 88 | 91 |
| 89 WebInspector.ComputedStyleWidget._propertySymbol = Symbol("property"); | 92 WebInspector.ComputedStyleWidget._propertySymbol = Symbol("property"); |
| 90 | 93 |
| 91 WebInspector.ComputedStyleWidget.prototype = { | 94 WebInspector.ComputedStyleWidget.prototype = { |
| 92 _showInheritedComputedStyleChanged: function() | 95 _showInheritedComputedStyleChanged: function() |
| 93 { | 96 { |
| 94 this.update(); | 97 this.update(); |
| 95 }, | 98 }, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 treeElement[WebInspector.ComputedStyleWidget._propertySymbol] = { | 181 treeElement[WebInspector.ComputedStyleWidget._propertySymbol] = { |
| 179 name: propertyName, | 182 name: propertyName, |
| 180 value: propertyValue | 183 value: propertyValue |
| 181 }; | 184 }; |
| 182 var isOdd = this._propertiesOutline.rootElement().children().length
% 2 === 0; | 185 var isOdd = this._propertiesOutline.rootElement().children().length
% 2 === 0; |
| 183 treeElement.listItemElement.classList.toggle("odd-row", isOdd); | 186 treeElement.listItemElement.classList.toggle("odd-row", isOdd); |
| 184 this._propertiesOutline.appendChild(treeElement); | 187 this._propertiesOutline.appendChild(treeElement); |
| 185 | 188 |
| 186 var trace = propertyTraces.get(propertyName); | 189 var trace = propertyTraces.get(propertyName); |
| 187 if (trace) { | 190 if (trace) { |
| 188 this._renderPropertyTrace(cssModel, matchedStyles, nodeStyle.nod
e, treeElement, trace); | 191 var activeProperty = this._renderPropertyTrace(cssModel, matched
Styles, nodeStyle.node, treeElement, trace); |
| 189 treeElement.listItemElement.addEventListener("mousedown", consum
eEvent, false); | 192 treeElement.listItemElement.addEventListener("mousedown", consum
eEvent, false); |
| 190 treeElement.listItemElement.addEventListener("dblclick", consume
Event, false); | 193 treeElement.listItemElement.addEventListener("dblclick", consume
Event, false); |
| 191 treeElement.listItemElement.addEventListener("click", handleClic
k.bind(null, treeElement), false); | 194 treeElement.listItemElement.addEventListener("click", handleClic
k.bind(null, treeElement), false); |
| 195 var gotoSourceElement = propertyValueElement.createChild("div",
"goto-source-icon"); |
| 196 gotoSourceElement.addEventListener("click", this._navigateToSour
ce.bind(this, activeProperty)); |
| 192 } | 197 } |
| 193 } | 198 } |
| 194 | 199 |
| 195 this._updateFilter(this._filterRegex); | 200 this._updateFilter(this._filterRegex); |
| 196 | 201 |
| 197 /** | 202 /** |
| 198 * @param {string} a | 203 * @param {string} a |
| 199 * @param {string} b | 204 * @param {string} b |
| 200 * @return {number} | 205 * @return {number} |
| 201 */ | 206 */ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 215 { | 220 { |
| 216 if (!treeElement.expanded) | 221 if (!treeElement.expanded) |
| 217 treeElement.expand(); | 222 treeElement.expand(); |
| 218 else | 223 else |
| 219 treeElement.collapse(); | 224 treeElement.collapse(); |
| 220 consumeEvent(event); | 225 consumeEvent(event); |
| 221 } | 226 } |
| 222 }, | 227 }, |
| 223 | 228 |
| 224 /** | 229 /** |
| 230 * @param {!WebInspector.CSSProperty} cssProperty |
| 231 * @param {!Event} event |
| 232 */ |
| 233 _navigateToSource: function(cssProperty, event) |
| 234 { |
| 235 if (this._revealCallback) |
| 236 this._revealCallback.call(null, cssProperty); |
| 237 event.consume(true); |
| 238 }, |
| 239 |
| 240 /** |
| 225 * @param {!WebInspector.CSSStyleModel} cssModel | 241 * @param {!WebInspector.CSSStyleModel} cssModel |
| 226 * @param {!WebInspector.CSSStyleModel.MatchedStyleResult} matchedStyles | 242 * @param {!WebInspector.CSSStyleModel.MatchedStyleResult} matchedStyles |
| 227 * @param {!WebInspector.DOMNode} node | 243 * @param {!WebInspector.DOMNode} node |
| 228 * @param {!TreeElement} rootTreeElement | 244 * @param {!TreeElement} rootTreeElement |
| 229 * @param {!Array<!WebInspector.CSSProperty>} tracedProperties | 245 * @param {!Array<!WebInspector.CSSProperty>} tracedProperties |
| 246 * @return {!WebInspector.CSSProperty} |
| 230 */ | 247 */ |
| 231 _renderPropertyTrace: function(cssModel, matchedStyles, node, rootTreeElemen
t, tracedProperties) | 248 _renderPropertyTrace: function(cssModel, matchedStyles, node, rootTreeElemen
t, tracedProperties) |
| 232 { | 249 { |
| 250 var activeProperty = null; |
| 233 for (var property of tracedProperties) { | 251 for (var property of tracedProperties) { |
| 234 var trace = createElement("div"); | 252 var trace = createElement("div"); |
| 235 trace.classList.add("property-trace"); | 253 trace.classList.add("property-trace"); |
| 236 if (matchedStyles.propertyState(property) === WebInspector.CSSStyleM
odel.MatchedStyleResult.PropertyState.Overloaded) | 254 if (matchedStyles.propertyState(property) === WebInspector.CSSStyleM
odel.MatchedStyleResult.PropertyState.Overloaded) |
| 237 trace.classList.add("property-trace-inactive"); | 255 trace.classList.add("property-trace-inactive"); |
| 256 else |
| 257 activeProperty = property; |
| 238 | 258 |
| 239 var renderer = new WebInspector.StylesSidebarPropertyRenderer(null,
node, property.name, /** @type {string} */(property.value)); | 259 var renderer = new WebInspector.StylesSidebarPropertyRenderer(null,
node, property.name, /** @type {string} */(property.value)); |
| 240 renderer.setColorHandler(this._processColor.bind(this)); | 260 renderer.setColorHandler(this._processColor.bind(this)); |
| 241 var valueElement = renderer.renderValue(); | 261 var valueElement = renderer.renderValue(); |
| 242 valueElement.classList.add("property-trace-value"); | 262 valueElement.classList.add("property-trace-value"); |
| 263 valueElement.addEventListener("click", this._navigateToSource.bind(t
his, property), false); |
| 264 var gotoSourceElement = createElement("div"); |
| 265 gotoSourceElement.classList.add("goto-source-icon"); |
| 266 gotoSourceElement.addEventListener("click", this._navigateToSource.b
ind(this, property)); |
| 267 valueElement.insertBefore(gotoSourceElement, valueElement.firstChild
); |
| 268 |
| 243 trace.appendChild(valueElement); | 269 trace.appendChild(valueElement); |
| 244 | 270 |
| 245 var rule = property.ownerStyle.parentRule; | 271 var rule = property.ownerStyle.parentRule; |
| 246 if (rule) { | 272 if (rule) { |
| 247 var linkSpan = trace.createChild("span", "trace-link"); | 273 var linkSpan = trace.createChild("span", "trace-link"); |
| 248 linkSpan.appendChild(WebInspector.StylePropertiesSection.createR
uleOriginNode(cssModel, this._linkifier, rule)); | 274 linkSpan.appendChild(WebInspector.StylePropertiesSection.createR
uleOriginNode(cssModel, this._linkifier, rule)); |
| 249 } | 275 } |
| 250 | 276 |
| 251 var selectorElement = trace.createChild("span", "property-trace-sele
ctor"); | 277 var selectorElement = trace.createChild("span", "property-trace-sele
ctor"); |
| 252 selectorElement.textContent = rule ? rule.selectorText() : "element.
style"; | 278 selectorElement.textContent = rule ? rule.selectorText() : "element.
style"; |
| 253 selectorElement.title = selectorElement.textContent; | 279 selectorElement.title = selectorElement.textContent; |
| 254 | 280 |
| 255 var traceTreeElement = new TreeElement(); | 281 var traceTreeElement = new TreeElement(); |
| 256 traceTreeElement.title = trace; | 282 traceTreeElement.title = trace; |
| 257 traceTreeElement.selectable = false; | 283 traceTreeElement.selectable = false; |
| 258 rootTreeElement.appendChild(traceTreeElement); | 284 rootTreeElement.appendChild(traceTreeElement); |
| 259 } | 285 } |
| 286 return /** @type {!WebInspector.CSSProperty} */(activeProperty); |
| 260 }, | 287 }, |
| 261 | 288 |
| 262 /** | 289 /** |
| 263 * @param {!WebInspector.CSSStyleModel.MatchedStyleResult} matchedStyles | 290 * @param {!WebInspector.CSSStyleModel.MatchedStyleResult} matchedStyles |
| 264 * @return {!Map<string, !Array<!WebInspector.CSSProperty>>} | 291 * @return {!Map<string, !Array<!WebInspector.CSSProperty>>} |
| 265 */ | 292 */ |
| 266 _computePropertyTraces: function(matchedStyles) | 293 _computePropertyTraces: function(matchedStyles) |
| 267 { | 294 { |
| 268 var result = new Map(); | 295 var result = new Map(); |
| 269 for (var style of matchedStyles.nodeStyles()) { | 296 for (var style of matchedStyles.nodeStyles()) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 var children = this._propertiesOutline.rootElement().children(); | 331 var children = this._propertiesOutline.rootElement().children(); |
| 305 for (var child of children) { | 332 for (var child of children) { |
| 306 var property = child[WebInspector.ComputedStyleWidget._propertySymbo
l]; | 333 var property = child[WebInspector.ComputedStyleWidget._propertySymbo
l]; |
| 307 var matched = !regex || regex.test(property.name) || regex.test(prop
erty.value); | 334 var matched = !regex || regex.test(property.name) || regex.test(prop
erty.value); |
| 308 child.hidden = !matched; | 335 child.hidden = !matched; |
| 309 } | 336 } |
| 310 }, | 337 }, |
| 311 | 338 |
| 312 __proto__: WebInspector.ThrottledWidget.prototype | 339 __proto__: WebInspector.ThrottledWidget.prototype |
| 313 } | 340 } |
| OLD | NEW |