| 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 29 matching lines...) Expand all Loading... |
| 40 WebInspector.moduleSetting("textEditorIndent").addChangeListener(this.update
.bind(this)); | 40 WebInspector.moduleSetting("textEditorIndent").addChangeListener(this.update
.bind(this)); |
| 41 | 41 |
| 42 this._sectionsContainer = this.element.createChild("div"); | 42 this._sectionsContainer = this.element.createChild("div"); |
| 43 this._stylesPopoverHelper = new WebInspector.StylesPopoverHelper(); | 43 this._stylesPopoverHelper = new WebInspector.StylesPopoverHelper(); |
| 44 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa
ultCSSFormatter()); | 44 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa
ultCSSFormatter()); |
| 45 | 45 |
| 46 this.element.classList.add("styles-pane"); | 46 this.element.classList.add("styles-pane"); |
| 47 this.element.addEventListener("mousemove", this._mouseMovedOverElement.bind(
this), false); | 47 this.element.addEventListener("mousemove", this._mouseMovedOverElement.bind(
this), false); |
| 48 this._keyDownBound = this._keyDown.bind(this); | 48 this._keyDownBound = this._keyDown.bind(this); |
| 49 this._keyUpBound = this._keyUp.bind(this); | 49 this._keyUpBound = this._keyUp.bind(this); |
| 50 new WebInspector.PropertyChangeHighlighter(this); | 50 |
| 51 WebInspector.targetManager.addModelListener(WebInspector.CSSStyleModel, WebI
nspector.CSSStyleModel.Events.LayoutEditorChange, this._onLayoutEditorChange, th
is); |
| 51 } | 52 } |
| 52 | 53 |
| 53 /** | 54 /** |
| 54 * @param {!WebInspector.CSSProperty} property | 55 * @param {!WebInspector.CSSProperty} property |
| 55 * @return {!Element} | 56 * @return {!Element} |
| 56 */ | 57 */ |
| 57 WebInspector.StylesSidebarPane.createExclamationMark = function(property) | 58 WebInspector.StylesSidebarPane.createExclamationMark = function(property) |
| 58 { | 59 { |
| 59 var exclamationElement = createElement("label", "dt-icon-label"); | 60 var exclamationElement = createElement("label", "dt-icon-label"); |
| 60 exclamationElement.className = "exclamation-mark"; | 61 exclamationElement.className = "exclamation-mark"; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // IE hack. | 99 // IE hack. |
| 99 if (value.endsWith("\9")) | 100 if (value.endsWith("\9")) |
| 100 return true; | 101 return true; |
| 101 if (hasUnknownVendorPrefix(value)) | 102 if (hasUnknownVendorPrefix(value)) |
| 102 return true; | 103 return true; |
| 103 | 104 |
| 104 return false; | 105 return false; |
| 105 } | 106 } |
| 106 | 107 |
| 107 WebInspector.StylesSidebarPane.prototype = { | 108 WebInspector.StylesSidebarPane.prototype = { |
| 109 /** |
| 110 * @param {!WebInspector.Event} event |
| 111 */ |
| 112 _onLayoutEditorChange: function(event) |
| 113 { |
| 114 var cssModel = /** @type {!WebInspector.CSSStyleModel} */(event.target); |
| 115 var styleSheetId = event.data["id"]; |
| 116 var sourceRange = /** @type {!CSSAgent.SourceRange} */(event.data["range
"]); |
| 117 var range = WebInspector.TextRange.fromObject(sourceRange); |
| 118 this._decorator = new WebInspector.PropertyChangeHighlighter(this, cssMo
del, styleSheetId, range); |
| 119 this.update(); |
| 120 }, |
| 121 |
| 122 /** |
| 123 * @param {!WebInspector.CSSProperty} cssProperty |
| 124 */ |
| 125 revealProperty: function(cssProperty) |
| 126 { |
| 127 this._decorator = new WebInspector.PropertyRevealHighlighter(this, cssPr
operty); |
| 128 this._decorator.perform(); |
| 129 this.update(); |
| 130 }, |
| 131 |
| 108 onUndoOrRedoHappened: function() | 132 onUndoOrRedoHappened: function() |
| 109 { | 133 { |
| 110 this.setNode(this.node()); | 134 this.setNode(this.node()); |
| 111 }, | 135 }, |
| 112 | 136 |
| 113 /** | 137 /** |
| 114 * @param {!Event} event | 138 * @param {!Event} event |
| 115 */ | 139 */ |
| 116 _onAddButtonLongClick: function(event) | 140 _onAddButtonLongClick: function(event) |
| 117 { | 141 { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 189 |
| 166 /** | 190 /** |
| 167 * @param {!WebInspector.CSSRule} editedRule | 191 * @param {!WebInspector.CSSRule} editedRule |
| 168 * @param {!WebInspector.TextRange} oldRange | 192 * @param {!WebInspector.TextRange} oldRange |
| 169 * @param {!WebInspector.TextRange} newRange | 193 * @param {!WebInspector.TextRange} newRange |
| 170 */ | 194 */ |
| 171 _styleSheetRuleEdited: function(editedRule, oldRange, newRange) | 195 _styleSheetRuleEdited: function(editedRule, oldRange, newRange) |
| 172 { | 196 { |
| 173 if (!editedRule.styleSheetId) | 197 if (!editedRule.styleSheetId) |
| 174 return; | 198 return; |
| 175 for (var block of this._sectionBlocks) { | 199 for (var section of this.allSections()) |
| 176 for (var section of block.sections) | 200 section._styleSheetRuleEdited(editedRule, oldRange, newRange); |
| 177 section._styleSheetRuleEdited(editedRule, oldRange, newRange); | |
| 178 } | |
| 179 }, | 201 }, |
| 180 | 202 |
| 181 /** | 203 /** |
| 182 * @param {!WebInspector.CSSMedia} oldMedia | 204 * @param {!WebInspector.CSSMedia} oldMedia |
| 183 * @param {!WebInspector.CSSMedia} newMedia | 205 * @param {!WebInspector.CSSMedia} newMedia |
| 184 */ | 206 */ |
| 185 _styleSheetMediaEdited: function(oldMedia, newMedia) | 207 _styleSheetMediaEdited: function(oldMedia, newMedia) |
| 186 { | 208 { |
| 187 if (!oldMedia.parentStyleSheetId) | 209 if (!oldMedia.parentStyleSheetId) |
| 188 return; | 210 return; |
| 189 for (var block of this._sectionBlocks) { | 211 for (var section of this.allSections()) |
| 190 for (var section of block.sections) | 212 section._styleSheetMediaEdited(oldMedia, newMedia); |
| 191 section._styleSheetMediaEdited(oldMedia, newMedia); | |
| 192 } | |
| 193 }, | 213 }, |
| 194 | 214 |
| 195 /** | 215 /** |
| 196 * @param {?RegExp} regex | 216 * @param {?RegExp} regex |
| 197 */ | 217 */ |
| 198 onFilterChanged: function(regex) | 218 onFilterChanged: function(regex) |
| 199 { | 219 { |
| 200 this._filterRegex = regex; | 220 this._filterRegex = regex; |
| 201 this._updateFilter(); | 221 this._updateFilter(); |
| 202 }, | 222 }, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 216 | 236 |
| 217 /** | 237 /** |
| 218 * @param {!WebInspector.StylePropertiesSection=} editedSection | 238 * @param {!WebInspector.StylePropertiesSection=} editedSection |
| 219 */ | 239 */ |
| 220 _refreshUpdate: function(editedSection) | 240 _refreshUpdate: function(editedSection) |
| 221 { | 241 { |
| 222 var node = this.node(); | 242 var node = this.node(); |
| 223 if (!node) | 243 if (!node) |
| 224 return; | 244 return; |
| 225 | 245 |
| 226 for (var block of this._sectionBlocks) { | 246 for (var section of this.allSections()) { |
| 227 for (var section of block.sections) { | 247 if (section.isBlank) |
| 228 if (section.isBlank) | 248 continue; |
| 229 continue; | 249 section.update(section === editedSection); |
| 230 section.update(section === editedSection); | |
| 231 } | |
| 232 } | 250 } |
| 233 | 251 |
| 234 if (this._filterRegex) | 252 if (this._filterRegex) |
| 235 this._updateFilter(); | 253 this._updateFilter(); |
| 236 this._nodeStylesUpdatedForTest(node, false); | 254 this._nodeStylesUpdatedForTest(node, false); |
| 237 }, | 255 }, |
| 238 | 256 |
| 239 /** | 257 /** |
| 240 * @override | 258 * @override |
| 241 * @return {!Promise.<?>} | 259 * @return {!Promise.<?>} |
| 242 */ | 260 */ |
| 243 doUpdate: function() | 261 doUpdate: function() |
| 244 { | 262 { |
| 245 this._discardElementUnderMouse(); | 263 this._discardElementUnderMouse(); |
| 246 | 264 |
| 247 return this.fetchMatchedCascade() | 265 return this.fetchMatchedCascade() |
| 248 .then(this._innerRebuildUpdate.bind(this)); | 266 .then(this._innerRebuildUpdate.bind(this)); |
| 249 }, | 267 }, |
| 250 | 268 |
| 251 /** | |
| 252 * @param {function()} callback | |
| 253 */ | |
| 254 runDecoratorAfterUpdate: function(callback) | |
| 255 { | |
| 256 this._decoratorCallback = callback; | |
| 257 }, | |
| 258 | |
| 259 _resetCache: function() | 269 _resetCache: function() |
| 260 { | 270 { |
| 261 delete this._matchedCascadePromise; | 271 delete this._matchedCascadePromise; |
| 262 }, | 272 }, |
| 263 | 273 |
| 264 /** | 274 /** |
| 265 * @return {!Promise.<?WebInspector.CSSStyleModel.MatchedStyleResult>} | 275 * @return {!Promise.<?WebInspector.CSSStyleModel.MatchedStyleResult>} |
| 266 */ | 276 */ |
| 267 fetchMatchedCascade: function() | 277 fetchMatchedCascade: function() |
| 268 { | 278 { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 if (titleElement) | 398 if (titleElement) |
| 389 this._sectionsContainer.appendChild(titleElement); | 399 this._sectionsContainer.appendChild(titleElement); |
| 390 for (var section of block.sections) | 400 for (var section of block.sections) |
| 391 this._sectionsContainer.appendChild(section.element); | 401 this._sectionsContainer.appendChild(section.element); |
| 392 } | 402 } |
| 393 | 403 |
| 394 if (this._filterRegex) | 404 if (this._filterRegex) |
| 395 this._updateFilter(); | 405 this._updateFilter(); |
| 396 | 406 |
| 397 this._nodeStylesUpdatedForTest(node, true); | 407 this._nodeStylesUpdatedForTest(node, true); |
| 398 if (this._decoratorCallback) { | 408 if (this._decorator) { |
| 399 this._decoratorCallback(); | 409 this._decorator.perform(); |
| 400 delete this._decoratorCallback; | 410 delete this._decorator; |
| 401 } | 411 } |
| 402 }, | 412 }, |
| 403 | 413 |
| 404 /** | 414 /** |
| 405 * @param {!WebInspector.DOMNode} node | 415 * @param {!WebInspector.DOMNode} node |
| 406 * @param {boolean} rebuild | 416 * @param {boolean} rebuild |
| 407 */ | 417 */ |
| 408 _nodeStylesUpdatedForTest: function(node, rebuild) | 418 _nodeStylesUpdatedForTest: function(node, rebuild) |
| 409 { | 419 { |
| 410 // For sniffing in tests. | 420 // For sniffing in tests. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 */ | 592 */ |
| 583 _keyUp: function(event) | 593 _keyUp: function(event) |
| 584 { | 594 { |
| 585 if ((!WebInspector.isMac() && event.keyCode === WebInspector.KeyboardSho
rtcut.Keys.Ctrl.code) || | 595 if ((!WebInspector.isMac() && event.keyCode === WebInspector.KeyboardSho
rtcut.Keys.Ctrl.code) || |
| 586 (WebInspector.isMac() && event.keyCode === WebInspector.KeyboardShor
tcut.Keys.Meta.code)) { | 596 (WebInspector.isMac() && event.keyCode === WebInspector.KeyboardShor
tcut.Keys.Meta.code)) { |
| 587 this._discardElementUnderMouse(); | 597 this._discardElementUnderMouse(); |
| 588 } | 598 } |
| 589 }, | 599 }, |
| 590 | 600 |
| 591 /** | 601 /** |
| 592 * @return {!Array<!WebInspector.SectionBlock>} | 602 * @return {!Array<!WebInspector.StylePropertiesSection>} |
| 593 */ | 603 */ |
| 594 sectionBlocks: function() | 604 allSections: function() |
| 595 { | 605 { |
| 596 return this._sectionBlocks || []; | 606 var sections = []; |
| 607 for (var block of this._sectionBlocks) |
| 608 sections = sections.concat(block.sections); |
| 609 return sections; |
| 597 }, | 610 }, |
| 598 | 611 |
| 599 __proto__: WebInspector.ElementsSidebarPane.prototype | 612 __proto__: WebInspector.ElementsSidebarPane.prototype |
| 600 } | 613 } |
| 601 | 614 |
| 602 /** | 615 /** |
| 603 * @param {string} placeholder | 616 * @param {string} placeholder |
| 604 * @param {!Element} container | 617 * @param {!Element} container |
| 605 * @param {function(?RegExp)} filterCallback | 618 * @param {function(?RegExp)} filterCallback |
| 606 * @return {!Element} | 619 * @return {!Element} |
| (...skipping 2345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2952 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, onNodeCha
nged); | 2965 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, onNodeCha
nged); |
| 2953 onNodeChanged(); | 2966 onNodeChanged(); |
| 2954 return button; | 2967 return button; |
| 2955 | 2968 |
| 2956 function onNodeChanged() | 2969 function onNodeChanged() |
| 2957 { | 2970 { |
| 2958 var node = WebInspector.context.flavor(WebInspector.DOMNode); | 2971 var node = WebInspector.context.flavor(WebInspector.DOMNode); |
| 2959 button.setEnabled(!!node); | 2972 button.setEnabled(!!node); |
| 2960 } | 2973 } |
| 2961 } | 2974 } |
| OLD | NEW |