OLD | NEW |
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 UI.Icon = class extends HTMLSpanElement { | 9 UI.Icon = class extends HTMLSpanElement { |
10 constructor() { | 10 constructor() { |
(...skipping 26 matching lines...) Expand all Loading... |
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('-webkit-mask-position'); | 47 this.style.removeProperty('--spritesheet-position'); |
48 this.style.removeProperty('background-position'); | |
49 this.style.removeProperty('width'); | 48 this.style.removeProperty('width'); |
50 this.style.removeProperty('height'); | 49 this.style.removeProperty('height'); |
51 this._toggleClasses(false); | 50 this._toggleClasses(false); |
52 this._iconType = ''; | 51 this._iconType = ''; |
53 this._descriptor = null; | 52 this._descriptor = null; |
54 } | 53 } |
55 var descriptor = UI.Icon.Descriptors[iconType] || null; | 54 var descriptor = UI.Icon.Descriptors[iconType] || null; |
56 if (descriptor) { | 55 if (descriptor) { |
57 this._iconType = iconType; | 56 this._iconType = iconType; |
58 this._descriptor = descriptor; | 57 this._descriptor = descriptor; |
59 this.style.setProperty('-webkit-mask-position', this._propertyValue()); | 58 this.style.setProperty('--spritesheet-position', this._propertyValue()); |
60 this.style.setProperty('background-position', this._propertyValue()); | |
61 this.style.setProperty('width', this._descriptor.width + 'px'); | 59 this.style.setProperty('width', this._descriptor.width + 'px'); |
62 this.style.setProperty('height', this._descriptor.height + 'px'); | 60 this.style.setProperty('height', this._descriptor.height + 'px'); |
63 this._toggleClasses(true); | 61 this._toggleClasses(true); |
64 } else if (iconType) { | 62 } else if (iconType) { |
65 throw new Error(`ERROR: failed to find icon descriptor for type: ${iconTyp
e}`); | 63 throw new Error(`ERROR: failed to find icon descriptor for type: ${iconTyp
e}`); |
66 } | 64 } |
67 } | 65 } |
68 | 66 |
69 /** | 67 /** |
70 * @param {boolean} value | 68 * @param {boolean} value |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 'mediumicon-clear-storage': {x: -40, y: -0, width: 16, height: 16, spritesheet
: 'resourceicons', isMask: true}, | 223 'mediumicon-clear-storage': {x: -40, y: -0, width: 16, height: 16, spritesheet
: 'resourceicons', isMask: true}, |
226 'mediumicon-database': {x: -60, y: -0, width: 16, height: 16, spritesheet: 're
sourceicons', isMask: true}, | 224 'mediumicon-database': {x: -60, y: -0, width: 16, height: 16, spritesheet: 're
sourceicons', isMask: true}, |
227 'mediumicon-table': {x: -80, y: -0, width: 16, height: 16, spritesheet: 'resou
rceicons', isMask: true}, | 225 'mediumicon-table': {x: -80, y: -0, width: 16, height: 16, spritesheet: 'resou
rceicons', isMask: true}, |
228 'mediumicon-cookie': {x: -120, y: -0, width: 16, height: 16, spritesheet: 'res
ourceicons', isMask: true}, | 226 'mediumicon-cookie': {x: -120, y: -0, width: 16, height: 16, spritesheet: 'res
ourceicons', isMask: true}, |
229 | 227 |
230 'mediumicon-arrow-top': {x: 0, y: 0, width: 19, height: 19, spritesheet: 'arro
wicons'}, | 228 'mediumicon-arrow-top': {x: 0, y: 0, width: 19, height: 19, spritesheet: 'arro
wicons'}, |
231 'mediumicon-arrow-bottom': {x: 0, y: -19, width: 19, height: 19, spritesheet:
'arrowicons'}, | 229 'mediumicon-arrow-bottom': {x: 0, y: -19, width: 19, height: 19, spritesheet:
'arrowicons'}, |
232 'mediumicon-arrow-left': {x: 0, y: -38, width: 19, height: 19, spritesheet: 'a
rrowicons'}, | 230 'mediumicon-arrow-left': {x: 0, y: -38, width: 19, height: 19, spritesheet: 'a
rrowicons'}, |
233 'mediumicon-arrow-right': {x: 0, y: -57, width: 19, height: 19, spritesheet: '
arrowicons'}, | 231 'mediumicon-arrow-right': {x: 0, y: -57, width: 19, height: 19, spritesheet: '
arrowicons'}, |
234 }; | 232 }; |
OLD | NEW |