Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js

Issue 2917033004: DevTools: move styles sidebar toolbar into StylesSidebarPane (Closed)
Patch Set: a Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/elements/ElementsPanel.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
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 34
35 Common.moduleSetting('colorFormat').addChangeListener(this.update.bind(this) ); 35 Common.moduleSetting('colorFormat').addChangeListener(this.update.bind(this) );
36 Common.moduleSetting('textEditorIndent').addChangeListener(this.update.bind( this)); 36 Common.moduleSetting('textEditorIndent').addChangeListener(this.update.bind( this));
37 37
38 /** @type {?UI.Widget} */
39 this._currentToolbarPane = null;
40 /** @type {?UI.Widget} */
41 this._animatedToolbarPane = null;
42 /** @type {?UI.Widget} */
43 this._pendingWidget = null;
44 /** @type {!UI.ToolbarToggle|undefined} */
45 this._pendingWidgetToggle;
46 this._toolbarPaneElement = this._createStylesSidebarToolbar();
38 this._sectionsContainer = this.element.createChild('div'); 47 this._sectionsContainer = this.element.createChild('div');
39 this._swatchPopoverHelper = new InlineEditor.SwatchPopoverHelper(); 48 this._swatchPopoverHelper = new InlineEditor.SwatchPopoverHelper();
40 this._linkifier = new Components.Linkifier(Elements.StylesSidebarPane._maxLi nkLength, /* useLinkDecorator */ true); 49 this._linkifier = new Components.Linkifier(Elements.StylesSidebarPane._maxLi nkLength, /* useLinkDecorator */ true);
41 /** @type {?Elements.StylePropertyHighlighter} */ 50 /** @type {?Elements.StylePropertyHighlighter} */
42 this._decorator = null; 51 this._decorator = null;
43 this._userOperation = false; 52 this._userOperation = false;
44 this._isEditingStyle = false; 53 this._isEditingStyle = false;
45 /** @type {?RegExp} */ 54 /** @type {?RegExp} */
46 this._filterRegex = null; 55 this._filterRegex = null;
47 56
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 * @return {boolean} 224 * @return {boolean}
216 */ 225 */
217 function styleSheetResourceHeader(header) { 226 function styleSheetResourceHeader(header) {
218 return !header.isViaInspector() && !header.isInline && !!header.resourceUR L(); 227 return !header.isViaInspector() && !header.isInline && !!header.resourceUR L();
219 } 228 }
220 } 229 }
221 230
222 /** 231 /**
223 * @param {?RegExp} regex 232 * @param {?RegExp} regex
224 */ 233 */
225 onFilterChanged(regex) { 234 _onFilterChanged(regex) {
226 this._filterRegex = regex; 235 this._filterRegex = regex;
227 this._updateFilter(); 236 this._updateFilter();
228 } 237 }
229 238
230 /** 239 /**
231 * @param {!Elements.StylePropertiesSection=} editedSection 240 * @param {!Elements.StylePropertiesSection=} editedSection
232 */ 241 */
233 _refreshUpdate(editedSection) { 242 _refreshUpdate(editedSection) {
234 var node = this.node(); 243 var node = this.node();
235 if (!node) 244 if (!node)
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 sections = sections.concat(block.sections); 520 sections = sections.concat(block.sections);
512 return sections; 521 return sections;
513 } 522 }
514 523
515 /** 524 /**
516 * @param {!Event} event 525 * @param {!Event} event
517 */ 526 */
518 _clipboardCopy(event) { 527 _clipboardCopy(event) {
519 Host.userMetrics.actionTaken(Host.UserMetrics.Action.StyleRuleCopied); 528 Host.userMetrics.actionTaken(Host.UserMetrics.Action.StyleRuleCopied);
520 } 529 }
530
531 /**
532 * @return {!Element}
533 */
534 _createStylesSidebarToolbar() {
535 var container = this.element.createChild('div', 'styles-sidebar-pane-toolbar -container');
536 var hbox = container.createChild('div', 'hbox styles-sidebar-pane-toolbar');
537 var filterContainerElement = hbox.createChild('div', 'styles-sidebar-pane-fi lter-box');
538 var filterInput = Elements.StylesSidebarPane.createPropertyFilterElement(
539 Common.UIString('Filter'), hbox, this._onFilterChanged.bind(this));
540 UI.ARIAUtils.setAccessibleName(filterInput, Common.UIString('Filter Styles') );
541 filterContainerElement.appendChild(filterInput);
542 var toolbar = new UI.Toolbar('styles-pane-toolbar', hbox);
543 toolbar.makeToggledGray();
544 toolbar.appendLocationItems('styles-sidebarpane-toolbar');
545 var toolbarPaneContainer = container.createChild('div', 'styles-sidebar-tool bar-pane-container');
546 var toolbarPaneContent = toolbarPaneContainer.createChild('div', 'styles-sid ebar-toolbar-pane');
547
548 return toolbarPaneContent;
luoe 2017/06/02 21:43:55 tldr: `_toolbarPaneElement` refers to the same thi
549 }
550
551 /**
552 * @param {?UI.Widget} widget
553 * @param {!UI.ToolbarToggle=} toggle
554 */
555 showToolbarPane(widget, toggle) {
556 if (this._pendingWidgetToggle)
557 this._pendingWidgetToggle.setToggled(false);
558 this._pendingWidgetToggle = toggle;
559
560 if (this._animatedToolbarPane)
561 this._pendingWidget = widget;
562 else
563 this._startToolbarPaneAnimation(widget);
564
565 if (widget && toggle)
566 toggle.setToggled(true);
567 }
568
569 /**
570 * @param {?UI.Widget} widget
571 */
572 _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
573 if (widget === this._currentToolbarPane)
574 return;
575
576 if (widget && this._currentToolbarPane) {
577 this._currentToolbarPane.detach();
578 widget.show(this._toolbarPaneElement);
579 this._currentToolbarPane = widget;
580 this._currentToolbarPane.focus();
581 return;
582 }
583
584 this._animatedToolbarPane = widget;
585
586 if (this._currentToolbarPane)
587 this._toolbarPaneElement.style.animationName = 'styles-element-state-pane- slideout';
588 else if (widget)
589 this._toolbarPaneElement.style.animationName = 'styles-element-state-pane- slidein';
590
591 if (widget)
592 widget.show(this._toolbarPaneElement);
593
594 var listener = onAnimationEnd.bind(this);
595 this._toolbarPaneElement.addEventListener('animationend', listener, false);
596
597 /**
598 * @this {!Elements.StylesSidebarPane}
599 */
600 function onAnimationEnd() {
601 this._toolbarPaneElement.style.removeProperty('animation-name');
602 this._toolbarPaneElement.removeEventListener('animationend', listener, fal se);
603
604 if (this._currentToolbarPane)
605 this._currentToolbarPane.detach();
606
607 this._currentToolbarPane = this._animatedToolbarPane;
608 if (this._currentToolbarPane)
609 this._currentToolbarPane.focus();
610 this._animatedToolbarPane = null;
611
612 if (this._pendingWidget) {
613 this._startToolbarPaneAnimation(this._pendingWidget);
614 this._pendingWidget = null;
615 }
616 }
617 }
521 }; 618 };
522 619
523 Elements.StylesSidebarPane._maxLinkLength = 30; 620 Elements.StylesSidebarPane._maxLinkLength = 30;
524 621
525 Elements.SectionBlock = class { 622 Elements.SectionBlock = class {
526 /** 623 /**
527 * @param {?Element} titleElement 624 * @param {?Element} titleElement
528 */ 625 */
529 constructor(titleElement) { 626 constructor(titleElement) {
530 this._titleElement = titleElement; 627 this._titleElement = titleElement;
(...skipping 2611 matching lines...) Expand 10 before | Expand all | Expand 10 after
3142 } 3239 }
3143 3240
3144 /** 3241 /**
3145 * @override 3242 * @override
3146 * @return {!UI.ToolbarItem} 3243 * @return {!UI.ToolbarItem}
3147 */ 3244 */
3148 item() { 3245 item() {
3149 return this._button; 3246 return this._button;
3150 } 3247 }
3151 }; 3248 };
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/elements/ElementsPanel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698