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

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

Issue 2560553004: Revert of [DevTools] Remove methods on Common.Event. (Closed)
Patch Set: Created 4 years 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
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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 715
716 /** 716 /**
717 * @param {!Element} container 717 * @param {!Element} container
718 */ 718 */
719 _createHoverMenuToolbar(container) { 719 _createHoverMenuToolbar(container) {
720 if (!this.editable) 720 if (!this.editable)
721 return; 721 return;
722 var items = []; 722 var items = [];
723 723
724 var textShadowButton = new UI.ToolbarButton(Common.UIString('Add text-shadow '), 'largeicon-text-shadow'); 724 var textShadowButton = new UI.ToolbarButton(Common.UIString('Add text-shadow '), 'largeicon-text-shadow');
725 textShadowButton.addEventListener( 725 textShadowButton.addEventListener('click', this._onInsertShadowPropertyClick .bind(this, 'text-shadow'));
726 UI.ToolbarButton.Events.Click, this._onInsertShadowPropertyClick.bind(th is, 'text-shadow'));
727 items.push(textShadowButton); 726 items.push(textShadowButton);
728 727
729 var boxShadowButton = new UI.ToolbarButton(Common.UIString('Add box-shadow') , 'largeicon-box-shadow'); 728 var boxShadowButton = new UI.ToolbarButton(Common.UIString('Add box-shadow') , 'largeicon-box-shadow');
730 boxShadowButton.addEventListener( 729 boxShadowButton.addEventListener('click', this._onInsertShadowPropertyClick. bind(this, 'box-shadow'));
731 UI.ToolbarButton.Events.Click, this._onInsertShadowPropertyClick.bind(th is, 'box-shadow'));
732 items.push(boxShadowButton); 730 items.push(boxShadowButton);
733 731
734 var colorButton = new UI.ToolbarButton(Common.UIString('Add color'), 'largei con-foreground-color'); 732 var colorButton = new UI.ToolbarButton(Common.UIString('Add color'), 'largei con-foreground-color');
735 colorButton.addEventListener(UI.ToolbarButton.Events.Click, this._onInsertCo lorPropertyClick, this); 733 colorButton.addEventListener('click', this._onInsertColorPropertyClick.bind( this));
736 items.push(colorButton); 734 items.push(colorButton);
737 735
738 var backgroundButton = new UI.ToolbarButton(Common.UIString('Add background- color'), 'largeicon-background-color'); 736 var backgroundButton = new UI.ToolbarButton(Common.UIString('Add background- color'), 'largeicon-background-color');
739 backgroundButton.addEventListener(UI.ToolbarButton.Events.Click, this._onIns ertBackgroundColorPropertyClick, this); 737 backgroundButton.addEventListener('click', this._onInsertBackgroundColorProp ertyClick.bind(this));
740 items.push(backgroundButton); 738 items.push(backgroundButton);
741 739
742 var newRuleButton = null; 740 var newRuleButton = null;
743 if (this._style.parentRule) { 741 if (this._style.parentRule) {
744 newRuleButton = new UI.ToolbarButton(Common.UIString('Insert Style Rule Be low'), 'largeicon-add'); 742 newRuleButton = new UI.ToolbarButton(Common.UIString('Insert Style Rule Be low'), 'largeicon-add');
745 newRuleButton.addEventListener(UI.ToolbarButton.Events.Click, this._onNewR uleClick, this); 743 newRuleButton.addEventListener('click', this._onNewRuleClick.bind(this));
746 items.push(newRuleButton); 744 items.push(newRuleButton);
747 } 745 }
748 746
749 var sectionToolbar = new UI.Toolbar('sidebar-pane-section-toolbar', containe r); 747 var sectionToolbar = new UI.Toolbar('sidebar-pane-section-toolbar', containe r);
750 for (var i = 0; i < items.length; ++i) 748 for (var i = 0; i < items.length; ++i)
751 sectionToolbar.appendToolbarItem(items[i]); 749 sectionToolbar.appendToolbarItem(items[i]);
752 750
753 var menuButton = new UI.ToolbarButton(Common.UIString('More tools\u2026'), ' largeicon-menu'); 751 var menuButton = new UI.ToolbarButton(Common.UIString('More tools\u2026'), ' largeicon-menu');
754 sectionToolbar.appendToolbarItem(menuButton); 752 sectionToolbar.appendToolbarItem(menuButton);
755 setItemsVisibility.call(this, items, false); 753 setItemsVisibility.call(this, items, false);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 curElement = curElement.previousSibling; 876 curElement = curElement.previousSibling;
879 while (curElement && !curElement._section); 877 while (curElement && !curElement._section);
880 878
881 return curElement ? curElement._section : null; 879 return curElement ? curElement._section : null;
882 } 880 }
883 881
884 /** 882 /**
885 * @param {!Common.Event} event 883 * @param {!Common.Event} event
886 */ 884 */
887 _onNewRuleClick(event) { 885 _onNewRuleClick(event) {
888 event.data.consume(); 886 event.consume();
889 var rule = this._style.parentRule; 887 var rule = this._style.parentRule;
890 var range = Common.TextRange.createFromLocation(rule.style.range.endLine, ru le.style.range.endColumn + 1); 888 var range = Common.TextRange.createFromLocation(rule.style.range.endLine, ru le.style.range.endColumn + 1);
891 this._parentPane._addBlankSection(this, /** @type {string} */ (rule.styleShe etId), range); 889 this._parentPane._addBlankSection(this, /** @type {string} */ (rule.styleShe etId), range);
892 } 890 }
893 891
894 /** 892 /**
895 * @param {string} propertyName 893 * @param {string} propertyName
896 * @param {!Common.Event} event 894 * @param {!Common.Event} event
897 */ 895 */
898 _onInsertShadowPropertyClick(propertyName, event) { 896 _onInsertShadowPropertyClick(propertyName, event) {
899 event.data.consume(true); 897 event.consume(true);
900 var treeElement = this.addNewBlankProperty(); 898 var treeElement = this.addNewBlankProperty();
901 treeElement.property.name = propertyName; 899 treeElement.property.name = propertyName;
902 treeElement.property.value = '0 0 black'; 900 treeElement.property.value = '0 0 black';
903 treeElement.updateTitle(); 901 treeElement.updateTitle();
904 var shadowSwatchPopoverHelper = Elements.ShadowSwatchPopoverHelper.forTreeEl ement(treeElement); 902 var shadowSwatchPopoverHelper = Elements.ShadowSwatchPopoverHelper.forTreeEl ement(treeElement);
905 if (shadowSwatchPopoverHelper) 903 if (shadowSwatchPopoverHelper)
906 shadowSwatchPopoverHelper.showPopover(); 904 shadowSwatchPopoverHelper.showPopover();
907 } 905 }
908 906
909 /** 907 /**
910 * @param {!Common.Event} event 908 * @param {!Common.Event} event
911 */ 909 */
912 _onInsertColorPropertyClick(event) { 910 _onInsertColorPropertyClick(event) {
913 event.data.consume(true); 911 event.consume(true);
914 var treeElement = this.addNewBlankProperty(); 912 var treeElement = this.addNewBlankProperty();
915 treeElement.property.name = 'color'; 913 treeElement.property.name = 'color';
916 treeElement.property.value = 'black'; 914 treeElement.property.value = 'black';
917 treeElement.updateTitle(); 915 treeElement.updateTitle();
918 var colorSwatch = Elements.ColorSwatchPopoverIcon.forTreeElement(treeElement ); 916 var colorSwatch = Elements.ColorSwatchPopoverIcon.forTreeElement(treeElement );
919 if (colorSwatch) 917 if (colorSwatch)
920 colorSwatch.showPopover(); 918 colorSwatch.showPopover();
921 } 919 }
922 920
923 /** 921 /**
924 * @param {!Common.Event} event 922 * @param {!Common.Event} event
925 */ 923 */
926 _onInsertBackgroundColorPropertyClick(event) { 924 _onInsertBackgroundColorPropertyClick(event) {
927 event.data.consume(true); 925 event.consume(true);
928 var treeElement = this.addNewBlankProperty(); 926 var treeElement = this.addNewBlankProperty();
929 treeElement.property.name = 'background-color'; 927 treeElement.property.name = 'background-color';
930 treeElement.property.value = 'white'; 928 treeElement.property.value = 'white';
931 treeElement.updateTitle(); 929 treeElement.updateTitle();
932 var colorSwatch = Elements.ColorSwatchPopoverIcon.forTreeElement(treeElement ); 930 var colorSwatch = Elements.ColorSwatchPopoverIcon.forTreeElement(treeElement );
933 if (colorSwatch) 931 if (colorSwatch)
934 colorSwatch.showPopover(); 932 colorSwatch.showPopover();
935 } 933 }
936 934
937 /** 935 /**
(...skipping 2076 matching lines...) Expand 10 before | Expand all | Expand 10 after
3014 } 3012 }
3015 }; 3013 };
3016 3014
3017 /** 3015 /**
3018 * @implements {UI.ToolbarItem.Provider} 3016 * @implements {UI.ToolbarItem.Provider}
3019 * @unrestricted 3017 * @unrestricted
3020 */ 3018 */
3021 Elements.StylesSidebarPane.ButtonProvider = class { 3019 Elements.StylesSidebarPane.ButtonProvider = class {
3022 constructor() { 3020 constructor() {
3023 this._button = new UI.ToolbarButton(Common.UIString('New Style Rule'), 'larg eicon-add'); 3021 this._button = new UI.ToolbarButton(Common.UIString('New Style Rule'), 'larg eicon-add');
3024 this._button.addEventListener(UI.ToolbarButton.Events.Click, this._clicked, this); 3022 this._button.addEventListener('click', this._clicked, this);
3025 var longclickTriangle = UI.Icon.create('largeicon-longclick-triangle', 'long -click-glyph'); 3023 var longclickTriangle = UI.Icon.create('largeicon-longclick-triangle', 'long -click-glyph');
3026 this._button.element.appendChild(longclickTriangle); 3024 this._button.element.appendChild(longclickTriangle);
3027 3025
3028 new UI.LongClickController(this._button.element, this._longClicked.bind(this )); 3026 new UI.LongClickController(this._button.element, this._longClicked.bind(this ));
3029 UI.context.addFlavorChangeListener(SDK.DOMNode, onNodeChanged.bind(this)); 3027 UI.context.addFlavorChangeListener(SDK.DOMNode, onNodeChanged.bind(this));
3030 onNodeChanged.call(this); 3028 onNodeChanged.call(this);
3031 3029
3032 /** 3030 /**
3033 * @this {Elements.StylesSidebarPane.ButtonProvider} 3031 * @this {Elements.StylesSidebarPane.ButtonProvider}
3034 */ 3032 */
3035 function onNodeChanged() { 3033 function onNodeChanged() {
3036 var node = UI.context.flavor(SDK.DOMNode); 3034 var node = UI.context.flavor(SDK.DOMNode);
3037 node = node ? node.enclosingElementOrSelf() : null; 3035 node = node ? node.enclosingElementOrSelf() : null;
3038 this._button.setEnabled(!!node); 3036 this._button.setEnabled(!!node);
3039 } 3037 }
3040 } 3038 }
3041 3039
3042 /** 3040 _clicked() {
3043 * @param {!Common.Event} event
3044 */
3045 _clicked(event) {
3046 Elements.StylesSidebarPane._instance._createNewRuleInViaInspectorStyleSheet( ); 3041 Elements.StylesSidebarPane._instance._createNewRuleInViaInspectorStyleSheet( );
3047 } 3042 }
3048 3043
3049 /** 3044 /**
3050 * @param {!Event} e 3045 * @param {!Event} e
3051 */ 3046 */
3052 _longClicked(e) { 3047 _longClicked(e) {
3053 Elements.StylesSidebarPane._instance._onAddButtonLongClick(e); 3048 Elements.StylesSidebarPane._instance._onAddButtonLongClick(e);
3054 } 3049 }
3055 3050
3056 /** 3051 /**
3057 * @override 3052 * @override
3058 * @return {!UI.ToolbarItem} 3053 * @return {!UI.ToolbarItem}
3059 */ 3054 */
3060 item() { 3055 item() {
3061 return this._button; 3056 return this._button;
3062 } 3057 }
3063 }; 3058 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698