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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/Toolbar.js

Issue 2553043003: [DevTools] Remove methods on Common.Event. (Closed)
Patch Set: rebased 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 /** 51 /**
52 * @param {!UI.Action} action 52 * @param {!UI.Action} action
53 * @param {!Array<!UI.ToolbarButton>=} toggledOptions 53 * @param {!Array<!UI.ToolbarButton>=} toggledOptions
54 * @param {!Array<!UI.ToolbarButton>=} untoggledOptions 54 * @param {!Array<!UI.ToolbarButton>=} untoggledOptions
55 * @return {!UI.ToolbarItem} 55 * @return {!UI.ToolbarItem}
56 */ 56 */
57 static createActionButton(action, toggledOptions, untoggledOptions) { 57 static createActionButton(action, toggledOptions, untoggledOptions) {
58 var button = new UI.ToolbarToggle(action.title(), action.icon(), action.togg ledIcon()); 58 var button = new UI.ToolbarToggle(action.title(), action.icon(), action.togg ledIcon());
59 button.setToggleWithRedColor(action.toggleWithRedColor()); 59 button.setToggleWithRedColor(action.toggleWithRedColor());
60 button.addEventListener('click', action.execute, action); 60 button.addEventListener(UI.ToolbarButton.Events.Click, action.execute, actio n);
61 action.addEventListener(UI.Action.Events.Enabled, enabledChanged); 61 action.addEventListener(UI.Action.Events.Enabled, enabledChanged);
62 action.addEventListener(UI.Action.Events.Toggled, toggled); 62 action.addEventListener(UI.Action.Events.Toggled, toggled);
63 /** @type {?UI.LongClickController} */ 63 /** @type {?UI.LongClickController} */
64 var longClickController = null; 64 var longClickController = null;
65 /** @type {?Array<!UI.ToolbarButton>} */ 65 /** @type {?Array<!UI.ToolbarButton>} */
66 var longClickButtons = null; 66 var longClickButtons = null;
67 /** @type {?Element} */ 67 /** @type {?Element} */
68 var longClickGlyph = null; 68 var longClickGlyph = null;
69 toggled(); 69 toggled();
70 return button; 70 return button;
(...skipping 29 matching lines...) Expand all
100 longClickGlyph.remove(); 100 longClickGlyph.remove();
101 longClickGlyph = null; 101 longClickGlyph = null;
102 longClickButtons = null; 102 longClickButtons = null;
103 } 103 }
104 } 104 }
105 } 105 }
106 106
107 function showOptions() { 107 function showOptions() {
108 var buttons = longClickButtons.slice(); 108 var buttons = longClickButtons.slice();
109 var mainButtonClone = new UI.ToolbarToggle(action.title(), action.icon(), action.toggledIcon()); 109 var mainButtonClone = new UI.ToolbarToggle(action.title(), action.icon(), action.toggledIcon());
110 mainButtonClone.addEventListener('click', clicked); 110 mainButtonClone.addEventListener(UI.ToolbarButton.Events.Click, clicked);
111 111
112 /** 112 /**
113 * @param {!Common.Event} event 113 * @param {!Common.Event} event
114 */ 114 */
115 function clicked(event) { 115 function clicked(event) {
116 button._clicked(/** @type {!Event} */ (event.data)); 116 button._clicked(/** @type {!Event} */ (event.data));
117 } 117 }
118 118
119 mainButtonClone.setToggled(action.toggled()); 119 mainButtonClone.setToggled(action.toggled());
120 buttons.push(mainButtonClone); 120 buttons.push(mainButtonClone);
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 var dropdownArrowIcon = UI.Icon.create('smallicon-dropdown-arrow', 'toolbar- dropdown-arrow'); 504 var dropdownArrowIcon = UI.Icon.create('smallicon-dropdown-arrow', 'toolbar- dropdown-arrow');
505 this.element.appendChild(dropdownArrowIcon); 505 this.element.appendChild(dropdownArrowIcon);
506 if (width) 506 if (width)
507 this.element.style.width = width + 'px'; 507 this.element.style.width = width + 'px';
508 } 508 }
509 509
510 /** 510 /**
511 * @param {!Event} event 511 * @param {!Event} event
512 */ 512 */
513 _clicked(event) { 513 _clicked(event) {
514 var defaultPrevented = this.dispatchEventToListeners('click', event); 514 this.dispatchEventToListeners(UI.ToolbarButton.Events.Click, event);
515 event.consume(defaultPrevented);
516 } 515 }
517 516
518 /** 517 /**
519 * @param {!Event} event 518 * @param {!Event} event
520 */ 519 */
521 _mouseDown(event) { 520 _mouseDown(event) {
522 this.dispatchEventToListeners('mousedown', event); 521 this.dispatchEventToListeners(UI.ToolbarButton.Events.MouseDown, event);
523 } 522 }
524 523
525 /** 524 /**
526 * @param {!Event} event 525 * @param {!Event} event
527 */ 526 */
528 _mouseUp(event) { 527 _mouseUp(event) {
529 this.dispatchEventToListeners('mouseup', event); 528 this.dispatchEventToListeners(UI.ToolbarButton.Events.MouseUp, event);
530 } 529 }
531 }; 530 };
532 531
532 UI.ToolbarButton.Events = {
533 Click: Symbol('Click'),
534 MouseDown: Symbol('MouseDown'),
535 MouseUp: Symbol('MouseUp')
536 };
537
533 /** 538 /**
534 * @unrestricted 539 * @unrestricted
535 */ 540 */
536 UI.ToolbarInput = class extends UI.ToolbarItem { 541 UI.ToolbarInput = class extends UI.ToolbarItem {
537 /** 542 /**
538 * @param {string=} placeholder 543 * @param {string=} placeholder
539 * @param {number=} growFactor 544 * @param {number=} growFactor
540 */ 545 */
541 constructor(placeholder, growFactor) { 546 constructor(placeholder, growFactor) {
542 super(createElementWithClass('input', 'toolbar-item')); 547 super(createElementWithClass('input', 'toolbar-item'));
(...skipping 19 matching lines...) Expand all
562 value() { 567 value() {
563 return this.element.value; 568 return this.element.value;
564 } 569 }
565 570
566 _onChangeCallback() { 571 _onChangeCallback() {
567 this.dispatchEventToListeners(UI.ToolbarInput.Event.TextChanged, this.elemen t.value); 572 this.dispatchEventToListeners(UI.ToolbarInput.Event.TextChanged, this.elemen t.value);
568 } 573 }
569 }; 574 };
570 575
571 UI.ToolbarInput.Event = { 576 UI.ToolbarInput.Event = {
572 TextChanged: 'TextChanged' 577 TextChanged: Symbol('TextChanged')
573 }; 578 };
574 579
575 /** 580 /**
576 * @unrestricted 581 * @unrestricted
577 */ 582 */
578 UI.ToolbarToggle = class extends UI.ToolbarButton { 583 UI.ToolbarToggle = class extends UI.ToolbarButton {
579 /** 584 /**
580 * @param {string} title 585 * @param {string} title
581 * @param {string=} glyph 586 * @param {string=} glyph
582 * @param {string=} toggledGlyph 587 * @param {string=} toggledGlyph
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 return this.inputElement.checked; 901 return this.inputElement.checked;
897 } 902 }
898 903
899 /** 904 /**
900 * @param {boolean} value 905 * @param {boolean} value
901 */ 906 */
902 setChecked(value) { 907 setChecked(value) {
903 this.inputElement.checked = value; 908 this.inputElement.checked = value;
904 } 909 }
905 }; 910 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698