| 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 Elements.StylesSidebarPane = class extends Elements.ElementsSidebarPane { | 30 Elements.StylesSidebarPane = class extends Elements.ElementsSidebarPane { |
| 31 constructor() { | 31 constructor() { |
| 32 super(); | 32 super(); |
| 33 this.setMinimumSize(96, 26); | 33 this.setMinimumSize(96, 26); |
| 34 this.registerRequiredCSS('elements/stylesSidebarPane.css'); |
| 34 | 35 |
| 35 Common.moduleSetting('colorFormat').addChangeListener(this.update.bind(this)
); | 36 Common.moduleSetting('colorFormat').addChangeListener(this.update.bind(this)
); |
| 36 Common.moduleSetting('textEditorIndent').addChangeListener(this.update.bind(
this)); | 37 Common.moduleSetting('textEditorIndent').addChangeListener(this.update.bind(
this)); |
| 37 | 38 |
| 38 /** @type {?UI.Widget} */ | 39 /** @type {?UI.Widget} */ |
| 39 this._currentToolbarPane = null; | 40 this._currentToolbarPane = null; |
| 40 /** @type {?UI.Widget} */ | 41 /** @type {?UI.Widget} */ |
| 41 this._animatedToolbarPane = null; | 42 this._animatedToolbarPane = null; |
| 42 /** @type {?UI.Widget} */ | 43 /** @type {?UI.Widget} */ |
| 43 this._pendingWidget = null; | 44 this._pendingWidget = null; |
| 44 /** @type {?UI.ToolbarToggle} */ | 45 /** @type {?UI.ToolbarToggle} */ |
| 45 this._pendingWidgetToggle = null; | 46 this._pendingWidgetToggle = null; |
| 46 this._toolbarPaneElement = this._createStylesSidebarToolbar(); | 47 this._toolbarPaneElement = this._createStylesSidebarToolbar(); |
| 47 this._sectionsContainer = this.element.createChild('div'); | 48 this._sectionsContainer = this.contentElement.createChild('div'); |
| 48 this._swatchPopoverHelper = new InlineEditor.SwatchPopoverHelper(); | 49 this._swatchPopoverHelper = new InlineEditor.SwatchPopoverHelper(); |
| 49 this._linkifier = new Components.Linkifier(Elements.StylesSidebarPane._maxLi
nkLength, /* useLinkDecorator */ true); | 50 this._linkifier = new Components.Linkifier(Elements.StylesSidebarPane._maxLi
nkLength, /* useLinkDecorator */ true); |
| 50 /** @type {?Elements.StylePropertyHighlighter} */ | 51 /** @type {?Elements.StylePropertyHighlighter} */ |
| 51 this._decorator = null; | 52 this._decorator = null; |
| 52 this._userOperation = false; | 53 this._userOperation = false; |
| 53 this._isEditingStyle = false; | 54 this._isEditingStyle = false; |
| 54 /** @type {?RegExp} */ | 55 /** @type {?RegExp} */ |
| 55 this._filterRegex = null; | 56 this._filterRegex = null; |
| 56 | 57 |
| 57 /** @type {?Elements.StylePropertyTreeElement} */ | 58 /** @type {?Elements.StylePropertyTreeElement} */ |
| 58 this._mouseDownTreeElement = null; | 59 this._mouseDownTreeElement = null; |
| 59 this._mouseDownTreeElementIsName = false; | 60 this._mouseDownTreeElementIsName = false; |
| 60 this._mouseDownTreeElementIsValue = false; | 61 this._mouseDownTreeElementIsValue = false; |
| 61 | 62 |
| 62 this.element.classList.add('styles-pane'); | 63 this.contentElement.classList.add('styles-pane'); |
| 63 | 64 |
| 64 /** @type {!Array<!Elements.SectionBlock>} */ | 65 /** @type {!Array<!Elements.SectionBlock>} */ |
| 65 this._sectionBlocks = []; | 66 this._sectionBlocks = []; |
| 66 Elements.StylesSidebarPane._instance = this; | 67 Elements.StylesSidebarPane._instance = this; |
| 67 UI.context.addFlavorChangeListener(SDK.DOMNode, this.forceUpdate, this); | 68 UI.context.addFlavorChangeListener(SDK.DOMNode, this.forceUpdate, this); |
| 68 this.element.addEventListener('copy', this._clipboardCopy.bind(this)); | 69 this.contentElement.addEventListener('copy', this._clipboardCopy.bind(this))
; |
| 69 this._resizeThrottler = new Common.Throttler(100); | 70 this._resizeThrottler = new Common.Throttler(100); |
| 70 } | 71 } |
| 71 | 72 |
| 72 /** | 73 /** |
| 73 * @param {!SDK.CSSProperty} property | 74 * @param {!SDK.CSSProperty} property |
| 74 * @return {!Element} | 75 * @return {!Element} |
| 75 */ | 76 */ |
| 76 static createExclamationMark(property) { | 77 static createExclamationMark(property) { |
| 77 var exclamationElement = createElement('label', 'dt-icon-label'); | 78 var exclamationElement = createElement('label', 'dt-icon-label'); |
| 78 exclamationElement.className = 'exclamation-mark'; | 79 exclamationElement.className = 'exclamation-mark'; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 * @override | 270 * @override |
| 270 */ | 271 */ |
| 271 onResize() { | 272 onResize() { |
| 272 this._resizeThrottler.schedule(this._innerResize.bind(this)); | 273 this._resizeThrottler.schedule(this._innerResize.bind(this)); |
| 273 } | 274 } |
| 274 | 275 |
| 275 /** | 276 /** |
| 276 * @return {!Promise} | 277 * @return {!Promise} |
| 277 */ | 278 */ |
| 278 _innerResize() { | 279 _innerResize() { |
| 279 var width = this.element.getBoundingClientRect().width + 'px'; | 280 var width = this.contentElement.getBoundingClientRect().width + 'px'; |
| 280 this.allSections().forEach(section => section.propertiesTreeOutline.element.
style.width = width); | 281 this.allSections().forEach(section => section.propertiesTreeOutline.element.
style.width = width); |
| 281 return Promise.resolve(); | 282 return Promise.resolve(); |
| 282 } | 283 } |
| 283 | 284 |
| 284 _resetCache() { | 285 _resetCache() { |
| 285 if (this.cssModel()) | 286 if (this.cssModel()) |
| 286 this.cssModel().discardCachedMatchedCascade(); | 287 this.cssModel().discardCachedMatchedCascade(); |
| 287 } | 288 } |
| 288 | 289 |
| 289 /** | 290 /** |
| (...skipping 15 matching lines...) Expand all Loading... |
| 305 return matchedStyles && matchedStyles.node() === this.node() ? matchedStyl
es : null; | 306 return matchedStyles && matchedStyles.node() === this.node() ? matchedStyl
es : null; |
| 306 } | 307 } |
| 307 } | 308 } |
| 308 | 309 |
| 309 /** | 310 /** |
| 310 * @param {boolean} editing | 311 * @param {boolean} editing |
| 311 */ | 312 */ |
| 312 setEditingStyle(editing) { | 313 setEditingStyle(editing) { |
| 313 if (this._isEditingStyle === editing) | 314 if (this._isEditingStyle === editing) |
| 314 return; | 315 return; |
| 315 this.element.classList.toggle('is-editing-style', editing); | 316 this.contentElement.classList.toggle('is-editing-style', editing); |
| 316 this._isEditingStyle = editing; | 317 this._isEditingStyle = editing; |
| 317 } | 318 } |
| 318 | 319 |
| 319 /** | 320 /** |
| 320 * @override | 321 * @override |
| 321 * @param {!Common.Event=} event | 322 * @param {!Common.Event=} event |
| 322 */ | 323 */ |
| 323 onCSSModelChanged(event) { | 324 onCSSModelChanged(event) { |
| 324 var edit = event && event.data ? /** @type {?SDK.CSSModel.Edit} */ (event.da
ta.edit) : null; | 325 var edit = event && event.data ? /** @type {?SDK.CSSModel.Edit} */ (event.da
ta.edit) : null; |
| 325 if (edit) { | 326 if (edit) { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 * @param {!Event} event | 522 * @param {!Event} event |
| 522 */ | 523 */ |
| 523 _clipboardCopy(event) { | 524 _clipboardCopy(event) { |
| 524 Host.userMetrics.actionTaken(Host.UserMetrics.Action.StyleRuleCopied); | 525 Host.userMetrics.actionTaken(Host.UserMetrics.Action.StyleRuleCopied); |
| 525 } | 526 } |
| 526 | 527 |
| 527 /** | 528 /** |
| 528 * @return {!Element} | 529 * @return {!Element} |
| 529 */ | 530 */ |
| 530 _createStylesSidebarToolbar() { | 531 _createStylesSidebarToolbar() { |
| 531 var container = this.element.createChild('div', 'styles-sidebar-pane-toolbar
-container'); | 532 var container = this.contentElement.createChild('div', 'styles-sidebar-pane-
toolbar-container'); |
| 532 var hbox = container.createChild('div', 'hbox styles-sidebar-pane-toolbar'); | 533 var hbox = container.createChild('div', 'hbox styles-sidebar-pane-toolbar'); |
| 533 var filterContainerElement = hbox.createChild('div', 'styles-sidebar-pane-fi
lter-box'); | 534 var filterContainerElement = hbox.createChild('div', 'styles-sidebar-pane-fi
lter-box'); |
| 534 var filterInput = Elements.StylesSidebarPane.createPropertyFilterElement( | 535 var filterInput = Elements.StylesSidebarPane.createPropertyFilterElement( |
| 535 Common.UIString('Filter'), hbox, this._onFilterChanged.bind(this), 'styl
es-filter-engaged'); | 536 Common.UIString('Filter'), hbox, this._onFilterChanged.bind(this), 'styl
es-filter-engaged'); |
| 536 UI.ARIAUtils.setAccessibleName(filterInput, Common.UIString('Filter Styles')
); | 537 UI.ARIAUtils.setAccessibleName(filterInput, Common.UIString('Filter Styles')
); |
| 537 filterContainerElement.appendChild(filterInput); | 538 filterContainerElement.appendChild(filterInput); |
| 538 var toolbar = new UI.Toolbar('styles-pane-toolbar', hbox); | 539 var toolbar = new UI.Toolbar('styles-pane-toolbar', hbox); |
| 539 toolbar.makeToggledGray(); | 540 toolbar.makeToggledGray(); |
| 540 toolbar.appendLocationItems('styles-sidebarpane-toolbar'); | 541 toolbar.appendLocationItems('styles-sidebarpane-toolbar'); |
| 541 var toolbarPaneContainer = container.createChild('div', 'styles-sidebar-tool
bar-pane-container'); | 542 var toolbarPaneContainer = container.createChild('div', 'styles-sidebar-tool
bar-pane-container'); |
| (...skipping 2693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3235 } | 3236 } |
| 3236 | 3237 |
| 3237 /** | 3238 /** |
| 3238 * @override | 3239 * @override |
| 3239 * @return {!UI.ToolbarItem} | 3240 * @return {!UI.ToolbarItem} |
| 3240 */ | 3241 */ |
| 3241 item() { | 3242 item() { |
| 3242 return this._button; | 3243 return this._button; |
| 3243 } | 3244 } |
| 3244 }; | 3245 }; |
| OLD | NEW |