Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js b/third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js |
| index a8b2810df358155ee8354743ff50d0302f20caa4..67c30b30ec5788ab24386620640b4b95155ecc09 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js |
| @@ -35,6 +35,15 @@ Elements.StylesSidebarPane = class extends Elements.ElementsSidebarPane { |
| Common.moduleSetting('colorFormat').addChangeListener(this.update.bind(this)); |
| Common.moduleSetting('textEditorIndent').addChangeListener(this.update.bind(this)); |
| + /** @type {?UI.Widget} */ |
| + this._currentToolbarPane = null; |
| + /** @type {?UI.Widget} */ |
| + this._animatedToolbarPane = null; |
| + /** @type {?UI.Widget} */ |
| + this._pendingWidget = null; |
| + /** @type {!UI.ToolbarToggle|undefined} */ |
| + this._pendingWidgetToggle; |
| + this._toolbarPaneElement = this._createStylesSidebarToolbar(); |
| this._sectionsContainer = this.element.createChild('div'); |
| this._swatchPopoverHelper = new InlineEditor.SwatchPopoverHelper(); |
| this._linkifier = new Components.Linkifier(Elements.StylesSidebarPane._maxLinkLength, /* useLinkDecorator */ true); |
| @@ -222,7 +231,7 @@ Elements.StylesSidebarPane = class extends Elements.ElementsSidebarPane { |
| /** |
| * @param {?RegExp} regex |
| */ |
| - onFilterChanged(regex) { |
| + _onFilterChanged(regex) { |
| this._filterRegex = regex; |
| this._updateFilter(); |
| } |
| @@ -518,6 +527,94 @@ Elements.StylesSidebarPane = class extends Elements.ElementsSidebarPane { |
| _clipboardCopy(event) { |
| Host.userMetrics.actionTaken(Host.UserMetrics.Action.StyleRuleCopied); |
| } |
| + |
| + /** |
| + * @return {!Element} |
| + */ |
| + _createStylesSidebarToolbar() { |
| + var container = this.element.createChild('div', 'styles-sidebar-pane-toolbar-container'); |
| + var hbox = container.createChild('div', 'hbox styles-sidebar-pane-toolbar'); |
| + var filterContainerElement = hbox.createChild('div', 'styles-sidebar-pane-filter-box'); |
| + var filterInput = Elements.StylesSidebarPane.createPropertyFilterElement( |
| + Common.UIString('Filter'), hbox, this._onFilterChanged.bind(this)); |
| + UI.ARIAUtils.setAccessibleName(filterInput, Common.UIString('Filter Styles')); |
| + filterContainerElement.appendChild(filterInput); |
| + var toolbar = new UI.Toolbar('styles-pane-toolbar', hbox); |
| + toolbar.makeToggledGray(); |
| + toolbar.appendLocationItems('styles-sidebarpane-toolbar'); |
| + var toolbarPaneContainer = container.createChild('div', 'styles-sidebar-toolbar-pane-container'); |
| + var toolbarPaneContent = toolbarPaneContainer.createChild('div', 'styles-sidebar-toolbar-pane'); |
| + |
| + return toolbarPaneContent; |
|
luoe
2017/06/02 21:43:55
tldr: `_toolbarPaneElement` refers to the same thi
|
| + } |
| + |
| + /** |
| + * @param {?UI.Widget} widget |
| + * @param {!UI.ToolbarToggle=} toggle |
| + */ |
| + showToolbarPane(widget, toggle) { |
| + if (this._pendingWidgetToggle) |
| + this._pendingWidgetToggle.setToggled(false); |
| + this._pendingWidgetToggle = toggle; |
| + |
| + if (this._animatedToolbarPane) |
| + this._pendingWidget = widget; |
| + else |
| + this._startToolbarPaneAnimation(widget); |
| + |
| + if (widget && toggle) |
| + toggle.setToggled(true); |
| + } |
| + |
| + /** |
| + * @param {?UI.Widget} widget |
| + */ |
| + _startToolbarPaneAnimation(widget) { |
|
einbinder
2017/06/03 01:50:57
This seems like a lot of work for 60 frames of ani
luoe
2017/06/05 19:03:37
That sounds like a good idea, I can tackle it sepa
|
| + if (widget === this._currentToolbarPane) |
| + return; |
| + |
| + if (widget && this._currentToolbarPane) { |
| + this._currentToolbarPane.detach(); |
| + widget.show(this._toolbarPaneElement); |
| + this._currentToolbarPane = widget; |
| + this._currentToolbarPane.focus(); |
| + return; |
| + } |
| + |
| + this._animatedToolbarPane = widget; |
| + |
| + if (this._currentToolbarPane) |
| + this._toolbarPaneElement.style.animationName = 'styles-element-state-pane-slideout'; |
| + else if (widget) |
| + this._toolbarPaneElement.style.animationName = 'styles-element-state-pane-slidein'; |
| + |
| + if (widget) |
| + widget.show(this._toolbarPaneElement); |
| + |
| + var listener = onAnimationEnd.bind(this); |
| + this._toolbarPaneElement.addEventListener('animationend', listener, false); |
| + |
| + /** |
| + * @this {!Elements.StylesSidebarPane} |
| + */ |
| + function onAnimationEnd() { |
| + this._toolbarPaneElement.style.removeProperty('animation-name'); |
| + this._toolbarPaneElement.removeEventListener('animationend', listener, false); |
| + |
| + if (this._currentToolbarPane) |
| + this._currentToolbarPane.detach(); |
| + |
| + this._currentToolbarPane = this._animatedToolbarPane; |
| + if (this._currentToolbarPane) |
| + this._currentToolbarPane.focus(); |
| + this._animatedToolbarPane = null; |
| + |
| + if (this._pendingWidget) { |
| + this._startToolbarPaneAnimation(this._pendingWidget); |
| + this._pendingWidget = null; |
| + } |
| + } |
| + } |
| }; |
| Elements.StylesSidebarPane._maxLinkLength = 30; |