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