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

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

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {HTMLSpanElement} 7 * @extends {HTMLSpanElement}
8 */ 8 */
9 WebInspector.Icon = class extends HTMLSpanElement { 9 UI.Icon = class extends HTMLSpanElement {
10 constructor() { 10 constructor() {
11 super(); 11 super();
12 throw new Error('icon must be created via factory method.'); 12 throw new Error('icon must be created via factory method.');
13 } 13 }
14 14
15 /** 15 /**
16 * @param {string=} iconType 16 * @param {string=} iconType
17 * @param {string=} className 17 * @param {string=} className
18 * @return {!WebInspector.Icon} 18 * @return {!UI.Icon}
19 */ 19 */
20 static create(iconType, className) { 20 static create(iconType, className) {
21 if (!WebInspector.Icon._constructor) 21 if (!UI.Icon._constructor)
22 WebInspector.Icon._constructor = registerCustomElement('span', 'ui-icon', WebInspector.Icon.prototype); 22 UI.Icon._constructor = registerCustomElement('span', 'ui-icon', UI.Icon.pr ototype);
23 23
24 var icon = /** @type {!WebInspector.Icon} */ (new WebInspector.Icon._constru ctor()); 24 var icon = /** @type {!UI.Icon} */ (new UI.Icon._constructor());
25 if (className) 25 if (className)
26 icon.className = className; 26 icon.className = className;
27 if (iconType) 27 if (iconType)
28 icon.setIconType(iconType); 28 icon.setIconType(iconType);
29 return icon; 29 return icon;
30 } 30 }
31 31
32 /** 32 /**
33 * @override 33 * @override
34 */ 34 */
35 createdCallback() { 35 createdCallback() {
36 /** @type {?WebInspector.Icon.Descriptor} */ 36 /** @type {?UI.Icon.Descriptor} */
37 this._descriptor = null; 37 this._descriptor = null;
38 /** @type {string} */ 38 /** @type {string} */
39 this._iconType = ''; 39 this._iconType = '';
40 } 40 }
41 41
42 /** 42 /**
43 * @param {string} iconType 43 * @param {string} iconType
44 */ 44 */
45 setIconType(iconType) { 45 setIconType(iconType) {
46 if (this._descriptor) { 46 if (this._descriptor) {
47 this.style.removeProperty(this._propertyName()); 47 this.style.removeProperty(this._propertyName());
48 this.style.removeProperty('width'); 48 this.style.removeProperty('width');
49 this.style.removeProperty('height'); 49 this.style.removeProperty('height');
50 this.style.removeProperty('transform'); 50 this.style.removeProperty('transform');
51 this.classList.remove(this._spritesheetClass()); 51 this.classList.remove(this._spritesheetClass());
52 this.classList.remove(this._iconType); 52 this.classList.remove(this._iconType);
53 this._iconType = ''; 53 this._iconType = '';
54 this._descriptor = null; 54 this._descriptor = null;
55 } 55 }
56 var descriptor = WebInspector.Icon.Descriptors[iconType] || null; 56 var descriptor = UI.Icon.Descriptors[iconType] || null;
57 if (descriptor) { 57 if (descriptor) {
58 this._iconType = iconType; 58 this._iconType = iconType;
59 this._descriptor = descriptor; 59 this._descriptor = descriptor;
60 this.style.setProperty(this._propertyName(), this._propertyValue()); 60 this.style.setProperty(this._propertyName(), this._propertyValue());
61 this.style.setProperty('width', this._descriptor.width + 'px'); 61 this.style.setProperty('width', this._descriptor.width + 'px');
62 this.style.setProperty('height', this._descriptor.height + 'px'); 62 this.style.setProperty('height', this._descriptor.height + 'px');
63 if (this._descriptor.transform) 63 if (this._descriptor.transform)
64 this.style.setProperty('transform', this._descriptor.transform); 64 this.style.setProperty('transform', this._descriptor.transform);
65 this.classList.add(this._spritesheetClass()); 65 this.classList.add(this._spritesheetClass());
66 this.classList.add(this._iconType); 66 this.classList.add(this._iconType);
(...skipping 18 matching lines...) Expand all
85 85
86 /** 86 /**
87 * @return {string} 87 * @return {string}
88 */ 88 */
89 _propertyValue() { 89 _propertyValue() {
90 return `${this._descriptor.x}px ${this._descriptor.y}px`; 90 return `${this._descriptor.x}px ${this._descriptor.y}px`;
91 } 91 }
92 }; 92 };
93 93
94 /** @typedef {{x: number, y: number, width: number, height: number, spritesheet: string, isMask: (boolean|undefined)}} */ 94 /** @typedef {{x: number, y: number, width: number, height: number, spritesheet: string, isMask: (boolean|undefined)}} */
95 WebInspector.Icon.Descriptor; 95 UI.Icon.Descriptor;
96 96
97 /** @enum {!WebInspector.Icon.Descriptor} */ 97 /** @enum {!UI.Icon.Descriptor} */
98 WebInspector.Icon.Descriptors = { 98 UI.Icon.Descriptors = {
99 'smallicon-error': {x: -20, y: 0, width: 10, height: 10, spritesheet: 'smallic ons'}, 99 'smallicon-error': {x: -20, y: 0, width: 10, height: 10, spritesheet: 'smallic ons'},
100 'smallicon-revoked-error': {x: -40, y: 0, width: 10, height: 10, spritesheet: 'smallicons'}, 100 'smallicon-revoked-error': {x: -40, y: 0, width: 10, height: 10, spritesheet: 'smallicons'},
101 'smallicon-warning': {x: -60, y: 0, width: 10, height: 10, spritesheet: 'small icons'}, 101 'smallicon-warning': {x: -60, y: 0, width: 10, height: 10, spritesheet: 'small icons'},
102 'smallicon-info': {x: -80, y: 0, width: 10, height: 10, spritesheet: 'smallico ns'}, 102 'smallicon-info': {x: -80, y: 0, width: 10, height: 10, spritesheet: 'smallico ns'},
103 'smallicon-device': {x: -100, y: 0, width: 10, height: 10, spritesheet: 'small icons'}, 103 'smallicon-device': {x: -100, y: 0, width: 10, height: 10, spritesheet: 'small icons'},
104 'smallicon-red-ball': {x: -120, y: 0, width: 10, height: 10, spritesheet: 'sma llicons'}, 104 'smallicon-red-ball': {x: -120, y: 0, width: 10, height: 10, spritesheet: 'sma llicons'},
105 'smallicon-green-ball': {x: -140, y: 0, width: 10, height: 10, spritesheet: 's mallicons'}, 105 'smallicon-green-ball': {x: -140, y: 0, width: 10, height: 10, spritesheet: 's mallicons'},
106 'smallicon-orange-ball': {x: -160, y: 0, width: 10, height: 10, spritesheet: ' smallicons'}, 106 'smallicon-orange-ball': {x: -160, y: 0, width: 10, height: 10, spritesheet: ' smallicons'},
107 'smallicon-thick-right-arrow': {x: -180, y: 0, width: 10, height: 10, spritesh eet: 'smallicons'}, 107 'smallicon-thick-right-arrow': {x: -180, y: 0, width: 10, height: 10, spritesh eet: 'smallicons'},
108 'smallicon-user-command': {x: 0, y: -20, width: 10, height: 10, spritesheet: ' smallicons'}, 108 'smallicon-user-command': {x: 0, y: -20, width: 10, height: 10, spritesheet: ' smallicons'},
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 'largeicon-show-left-sidebar': {x: -160, y: -72, width: 28, height: 24, sprit esheet: 'largeicons', isMask: true}, 162 'largeicon-show-left-sidebar': {x: -160, y: -72, width: 28, height: 24, sprit esheet: 'largeicons', isMask: true},
163 'largeicon-hide-left-sidebar': {x: -192, y: -72, width: 28, height: 24, sprit esheet: 'largeicons', isMask: true}, 163 'largeicon-hide-left-sidebar': {x: -192, y: -72, width: 28, height: 24, sprit esheet: 'largeicons', isMask: true},
164 'largeicon-show-right-sidebar': {x: -160, y: -72, width: 28, height: 24, spri tesheet: 'largeicons', isMask: true, transform: 'rotate(180deg)'}, 164 'largeicon-show-right-sidebar': {x: -160, y: -72, width: 28, height: 24, spri tesheet: 'largeicons', isMask: true, transform: 'rotate(180deg)'},
165 'largeicon-hide-right-sidebar': {x: -192, y: -72, width: 28, height: 24, spri tesheet: 'largeicons', isMask: true, transform: 'rotate(180deg)'}, 165 'largeicon-hide-right-sidebar': {x: -192, y: -72, width: 28, height: 24, spri tesheet: 'largeicons', isMask: true, transform: 'rotate(180deg)'},
166 'largeicon-show-top-sidebar': {x: -160, y: -72, width: 28, height: 24, sprite sheet: 'largeicons', isMask: true, transform: 'translate(4px, 0) rotate(90deg)'} , 166 'largeicon-show-top-sidebar': {x: -160, y: -72, width: 28, height: 24, sprite sheet: 'largeicons', isMask: true, transform: 'translate(4px, 0) rotate(90deg)'} ,
167 'largeicon-hide-top-sidebar': {x: -192, y: -72, width: 28, height: 24, sprite sheet: 'largeicons', isMask: true, transform: 'translate(4px, 1px) rotate(90deg) '}, 167 'largeicon-hide-top-sidebar': {x: -192, y: -72, width: 28, height: 24, sprite sheet: 'largeicons', isMask: true, transform: 'translate(4px, 1px) rotate(90deg) '},
168 'largeicon-show-bottom-sidebar': {x: -160, y: -72, width: 28, height: 24, spr itesheet: 'largeicons', isMask: true, transform: 'translate(4px, 0) rotate(-90de g)'}, 168 'largeicon-show-bottom-sidebar': {x: -160, y: -72, width: 28, height: 24, spr itesheet: 'largeicons', isMask: true, transform: 'translate(4px, 0) rotate(-90de g)'},
169 'largeicon-hide-bottom-sidebar': {x: -192, y: -72, width: 28, height: 24, spr itesheet: 'largeicons', isMask: true, transform: 'translate(4px, 1px) rotate(-90 deg)'}, 169 'largeicon-hide-bottom-sidebar': {x: -192, y: -72, width: 28, height: 24, spr itesheet: 'largeicons', isMask: true, transform: 'translate(4px, 1px) rotate(-90 deg)'},
170 }; 170 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698