| 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 scene = {}; | 5 var scene = {}; | 
| 6 | 6 | 
| 7 /** | 7 /** | 
| 8  * The scene class assists in managing element and animations in the UI.  It | 8  * The scene class assists in managing element and animations in the UI.  It | 
| 9  * allows UI update API commands to be queued in batches, and manages allocation | 9  * allows UI update API commands to be queued in batches, and manages allocation | 
| 10  * of element and animation IDs. | 10  * of element and animation IDs. | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 56 | 56 | 
| 57   /** | 57   /** | 
| 58    * Flush all queued commands to native. | 58    * Flush all queued commands to native. | 
| 59    */ | 59    */ | 
| 60   flush() { | 60   flush() { | 
| 61     api.sendCommands(this.commands); | 61     api.sendCommands(this.commands); | 
| 62     this.commands = []; | 62     this.commands = []; | 
| 63   } | 63   } | 
| 64 | 64 | 
| 65   /** | 65   /** | 
| 66    * Add a new UiElement to the scene, returning the ID assigned. | 66    * Add a new UiElementUpdate to the scene, returning the ID assigned. | 
| 67    * @param {api.UiElement} element | 67    * @param {api.UiElementUpdate} element | 
| 68    */ | 68    */ | 
| 69   addElement(element) { | 69   addElement(element) { | 
| 70     var id = this.idIndex++; | 70     var id = this.idIndex++; | 
| 71     element.setId(id); | 71     element.setId(id); | 
| 72     this.commands.push( | 72     this.commands.push( | 
| 73         {'type': api.Command.ADD_ELEMENT, 'data': element.properties}); | 73         {'type': api.Command.ADD_ELEMENT, 'data': element.properties}); | 
| 74     this.elements.add(id); | 74     this.elements.add(id); | 
| 75     return id; | 75     return id; | 
| 76   } | 76   } | 
| 77 | 77 | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 138       var id = parseInt(id_key, 10); | 138       var id = parseInt(id_key, 10); | 
| 139       this.removeAnimation(id); | 139       this.removeAnimation(id); | 
| 140     } | 140     } | 
| 141     var ids = this.elements.values(); | 141     var ids = this.elements.values(); | 
| 142     for (let id of ids) { | 142     for (let id of ids) { | 
| 143       this.removeElement(id); | 143       this.removeElement(id); | 
| 144     } | 144     } | 
| 145     this.flush(); | 145     this.flush(); | 
| 146   } | 146   } | 
| 147 }; | 147 }; | 
| OLD | NEW | 
|---|