| 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 var api = {}; | 5 var api = {}; | 
| 6 | 6 | 
| 7 /** | 7 /** | 
| 8  * Enumeration of scene update commands. | 8  * Enumeration of scene update commands. | 
| 9  * @enum {number} | 9  * @enum {number} | 
| 10  * @const | 10  * @const | 
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 98 /** | 98 /** | 
| 99  * Sets the CSS size for this page. | 99  * Sets the CSS size for this page. | 
| 100  * @param {number} width | 100  * @param {number} width | 
| 101  * @param {number} height | 101  * @param {number} height | 
| 102  * @param {number} dpr | 102  * @param {number} dpr | 
| 103  */ | 103  */ | 
| 104 api.setUiCssSize = function(width, height, dpr) { | 104 api.setUiCssSize = function(width, height, dpr) { | 
| 105   chrome.send('setUiCssSize', [width, height, dpr]); | 105   chrome.send('setUiCssSize', [width, height, dpr]); | 
| 106 }; | 106 }; | 
| 107 | 107 | 
|  | 108 api.FillType = { | 
|  | 109   'NONE': 0, | 
|  | 110   'SPRITE': 1, | 
|  | 111   'OPAQUE_GRADIENT': 2, | 
|  | 112   'GRID_GRADIENT': 3, | 
|  | 113   'CONTENT': 4 | 
|  | 114 }; | 
|  | 115 | 
|  | 116 api.Fill = class { | 
|  | 117   constructor(type) { | 
|  | 118     this.properties = {}; | 
|  | 119     this.properties['fillType'] = type; | 
|  | 120   } | 
|  | 121 } | 
|  | 122 | 
|  | 123 api.Sprite = class extends api.Fill { | 
|  | 124   constructor(pixelX, pixelY, pixelWidth, pixelHeight) { | 
|  | 125     super(api.FillType.SPRITE); | 
|  | 126     this.properties.copyRect = {x: pixelX, y: pixelY, width: pixelWidth, height:
      pixelHeight}; | 
|  | 127   } | 
|  | 128 } | 
|  | 129 | 
|  | 130 api.OpaqueGradient = class extends api.Fill { | 
|  | 131   constructor(edgeColor, centerColor) { | 
|  | 132     super(api.FillType.OPAQUE_GRADIENT); | 
|  | 133     this.properties.edgeColor = edgeColor; | 
|  | 134     this.properties.centerColor = centerColor; | 
|  | 135   } | 
|  | 136 } | 
|  | 137 | 
|  | 138 api.GridGradient = class extends api.Fill { | 
|  | 139   constructor(edgeColor, centerColor, tileNumber) { | 
|  | 140     super(api.FillType.GRID_GRADIENT); | 
|  | 141     this.properties.edgeColor = edgeColor; | 
|  | 142     this.properties.centerColor = centerColor; | 
|  | 143     this.properties.tileNumber = tileNumber; | 
|  | 144   } | 
|  | 145 } | 
|  | 146 | 
|  | 147 api.Content = class extends api.Fill { | 
|  | 148   constructor() { | 
|  | 149     super(api.FillType.CONTENT); | 
|  | 150   } | 
|  | 151 } | 
|  | 152 | 
| 108 /** | 153 /** | 
| 109  * Represents updates to UI element properties. Any properties set on this | 154  * Represents updates to UI element properties. Any properties set on this | 
| 110  * object are relayed to an underlying native element via scene command. | 155  * object are relayed to an underlying native element via scene command. | 
| 111  * Properties that are not set on this object are left unchanged. | 156  * Properties that are not set on this object are left unchanged. | 
| 112  * @struct | 157  * @struct | 
| 113  */ | 158  */ | 
| 114 api.UiElementUpdate = class { | 159 api.UiElementUpdate = class { | 
| 115   constructor() { | 160   constructor() { | 
| 116     /** @private {!Object} */ | 161     /** @private {!Object} */ | 
| 117     this.properties = {'id': -1}; | 162     this.properties = {'id': -1}; | 
| 118   } | 163   } | 
| 119 | 164 | 
| 120   /** | 165   /** | 
| 121    * Set the id of the element to update. | 166    * Set the id of the element to update. | 
| 122    * @param {number} id | 167    * @param {number} id | 
| 123    */ | 168    */ | 
| 124   setId(id) { | 169   setId(id) { | 
| 125     this.properties['id'] = id; | 170     this.properties['id'] = id; | 
| 126   } | 171   } | 
| 127 | 172 | 
| 128   /** | 173   /** | 
| 129   * Operates on an instance of MyClass and returns something. |  | 
| 130   */ |  | 
| 131   setIsContentQuad() { |  | 
| 132     this.properties['contentQuad'] = true; |  | 
| 133   } |  | 
| 134 |  | 
| 135   /** |  | 
| 136    * Specify a parent for this element. If set, this element is positioned | 174    * Specify a parent for this element. If set, this element is positioned | 
| 137    * relative to its parent element, rather than absolutely. This allows | 175    * relative to its parent element, rather than absolutely. This allows | 
| 138    * elements to automatically move with a parent. | 176    * elements to automatically move with a parent. | 
| 139    * @param {number} id | 177    * @param {number} id | 
| 140    */ | 178    */ | 
| 141   setParentId(id) { | 179   setParentId(id) { | 
| 142     this.properties['parentId'] = id; | 180     this.properties['parentId'] = id; | 
| 143   } | 181   } | 
| 144 | 182 | 
| 145   /** | 183   /** | 
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 224   } | 262   } | 
| 225 | 263 | 
| 226   /** | 264   /** | 
| 227    * Causes an element to be rendered with a specified opacity, between 0.0 and | 265    * Causes an element to be rendered with a specified opacity, between 0.0 and | 
| 228    * 1.0. Opacity is inherited by children. | 266    * 1.0. Opacity is inherited by children. | 
| 229    * @param {number} opacity | 267    * @param {number} opacity | 
| 230    */ | 268    */ | 
| 231   setOpacity(opacity) { | 269   setOpacity(opacity) { | 
| 232     this.properties['opacity'] = opacity; | 270     this.properties['opacity'] = opacity; | 
| 233   } | 271   } | 
|  | 272 | 
|  | 273   setFill(fill) { | 
|  | 274     Object.assign(this.properties, fill.properties); | 
|  | 275   } | 
| 234 }; | 276 }; | 
| 235 | 277 | 
| 236 /** | 278 /** | 
| 237  * Represents a new UI element. This object builds on UiElementUpdate, | 279  * Represents a new UI element. This object builds on UiElementUpdate, | 
| 238  * forcing the underlying texture coordinates to be specified. | 280  * forcing the underlying texture coordinates to be specified. | 
| 239  * @struct | 281  * @struct | 
| 240  */ | 282  */ | 
| 241 api.UiElement = class extends api.UiElementUpdate { | 283 api.UiElement = class extends api.UiElementUpdate { | 
| 242   /** | 284   /** | 
| 243    * Constructor of UiElement. | 285    * Constructor of UiElement. | 
| 244    * pixelX and pixelY values indicate the left upper corner; pixelWidth and | 286    * pixelX and pixelY values indicate the left upper corner; pixelWidth and | 
| 245    * pixelHeight is width and height of the texture to be copied from the web | 287    * pixelHeight is width and height of the texture to be copied from the web | 
| 246    * contents. | 288    * contents. | 
| 247    * @param {number} pixelX | 289    * @param {number} pixelX | 
| 248    * @param {number} pixelY | 290    * @param {number} pixelY | 
| 249    * @param {number} pixelWidth | 291    * @param {number} pixelWidth | 
| 250    * @param {number} pixelHeight | 292    * @param {number} pixelHeight | 
| 251    */ | 293    */ | 
| 252   constructor(pixelX, pixelY, pixelWidth, pixelHeight) { | 294   constructor(pixelX, pixelY, pixelWidth, pixelHeight) { | 
| 253     super(); | 295     super(); | 
| 254 | 296 | 
| 255     /** @private {Object} */ | 297     this.setFill(new api.Sprite(pixelX, pixelY, pixelWidth, pixelHeight)); | 
| 256     this.properties['copyRect'] = |  | 
| 257         {x: pixelX, y: pixelY, width: pixelWidth, height: pixelHeight}; |  | 
| 258   } | 298   } | 
| 259 }; | 299 }; | 
| 260 | 300 | 
| 261 /** | 301 /** | 
| 262  * Enumeration of animatable properties. | 302  * Enumeration of animatable properties. | 
| 263  * @enum {number} | 303  * @enum {number} | 
| 264  * @const | 304  * @const | 
| 265  */ | 305  */ | 
| 266 api.Property = { | 306 api.Property = { | 
| 267   'COPYRECT': 0, | 307   'COPYRECT': 0, | 
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 374 | 414 | 
| 375   /** | 415   /** | 
| 376    * Set the animation's final element opacity. | 416    * Set the animation's final element opacity. | 
| 377    * @param {number} opacity | 417    * @param {number} opacity | 
| 378    */ | 418    */ | 
| 379   setOpacity(opacity) { | 419   setOpacity(opacity) { | 
| 380     this.property = api.Property.OPACITY; | 420     this.property = api.Property.OPACITY; | 
| 381     this.to.x = opacity; | 421     this.to.x = opacity; | 
| 382   } | 422   } | 
| 383 }; | 423 }; | 
| OLD | NEW | 
|---|