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

Side by Side Diff: chrome/browser/resources/vr_shell/vr_shell_ui.js

Issue 2592143002: First cut of JS closure compiler use for VR HTML UI. (Closed)
Patch Set: Created 4 years 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 var vrShellUi = (function() { 5 var vrShellUi = (function() {
6 'use strict'; 6 'use strict';
7 7
8 let scene = new ui.Scene(); 8 let scene = new ui.Scene();
9 let sceneManager; 9 let sceneManager;
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 this.configure(1, 1, 0.015); 115 this.configure(1, 1, 0.015);
116 } 116 }
117 117
118 onMouseLeave() { 118 onMouseLeave() {
119 this.configure(0.8, 0, 0); 119 this.configure(0.8, 0, 0);
120 } 120 }
121 }; 121 };
122 122
123 class Controls { 123 class Controls {
124 constructor(contentQuadId) { 124 constructor(contentQuadId) {
125 this.enabled = false;
126 this.reloadUiEnabled = false;
127
125 this.buttons = []; 128 this.buttons = [];
126 let descriptors = [ 129 let descriptors = [
127 ['#back', function() { 130 ['#back', function() {
128 api.doAction(api.Action.HISTORY_BACK); 131 api.doAction(api.Action.HISTORY_BACK);
129 }], 132 }],
130 ['#reload', function() { 133 ['#reload', function() {
131 api.doAction(api.Action.RELOAD); 134 api.doAction(api.Action.RELOAD);
132 }], 135 }],
133 ['#forward', function() { 136 ['#forward', function() {
134 api.doAction(api.Action.HISTORY_FORWARD); 137 api.doAction(api.Action.HISTORY_FORWARD);
(...skipping 25 matching lines...) Expand all
160 this.reloadUiButton.domElement.addEventListener('click', function() { 163 this.reloadUiButton.domElement.addEventListener('click', function() {
161 scene.purge(); 164 scene.purge();
162 api.doAction(api.Action.RELOAD_UI); 165 api.doAction(api.Action.RELOAD_UI);
163 }); 166 });
164 167
165 let update = new api.UiElementUpdate(); 168 let update = new api.UiElementUpdate();
166 update.setParentId(contentQuadId); 169 update.setParentId(contentQuadId);
167 update.setVisible(false); 170 update.setVisible(false);
168 update.setScale(2.2, 2.2, 1); 171 update.setScale(2.2, 2.2, 1);
169 update.setTranslation(0, -0.6, 0.3); 172 update.setTranslation(0, -0.6, 0.3);
173
174 // The closure compiler should barf on this...
175 update.setTranslation(0, -0.6, 'cat');
cjgrant 2016/12/21 17:10:50 This is what I was playing with: - If I make a cal
176
170 update.setAnchoring(api.XAnchoring.XNONE, api.YAnchoring.YBOTTOM); 177 update.setAnchoring(api.XAnchoring.XNONE, api.YAnchoring.YBOTTOM);
171 scene.updateElement(this.reloadUiButton.uiElementId, update); 178 scene.updateElement(this.reloadUiButton.uiElementId, update);
172 } 179 }
173 180
174 setEnabled(enabled) { 181 setEnabled(enabled) {
175 this.enabled = enabled; 182 this.enabled = enabled;
176 this.configure(); 183 this.configure();
177 } 184 }
178 185
179 setReloadUiEnabled(enabled) { 186 setReloadUiEnabled(enabled) {
(...skipping 11 matching lines...) Expand all
191 update.setVisible(this.enabled && this.reloadUiEnabled); 198 update.setVisible(this.enabled && this.reloadUiEnabled);
192 scene.updateElement(this.reloadUiButton.uiElementId, update); 199 scene.updateElement(this.reloadUiButton.uiElementId, update);
193 } 200 }
194 }; 201 };
195 202
196 class SecureOriginWarnings { 203 class SecureOriginWarnings {
197 constructor() { 204 constructor() {
198 /** @const */ var DISTANCE = 0.7; 205 /** @const */ var DISTANCE = 0.7;
199 /** @const */ var ANGLE_UP = 16.3 * Math.PI / 180.0; 206 /** @const */ var ANGLE_UP = 16.3 * Math.PI / 180.0;
200 207
208 this.enabled = false;
209 this.secure = false;
210 this.secureOriginTimer = null;
211
201 // Permanent WebVR security warning. This warning is shown near the top of 212 // Permanent WebVR security warning. This warning is shown near the top of
202 // the field of view. 213 // the field of view.
203 this.webVrSecureWarning = new DomUiElement('#webvr-not-secure-permanent'); 214 this.webVrSecureWarning = new DomUiElement('#webvr-not-secure-permanent');
204 let update = new api.UiElementUpdate(); 215 let update = new api.UiElementUpdate();
205 update.setScale(DISTANCE, DISTANCE, 1); 216 update.setScale(DISTANCE, DISTANCE, 1);
206 update.setTranslation(0, DISTANCE * Math.sin(ANGLE_UP), 217 update.setTranslation(0, DISTANCE * Math.sin(ANGLE_UP),
207 -DISTANCE * Math.cos(ANGLE_UP)); 218 -DISTANCE * Math.cos(ANGLE_UP));
208 update.setRotation(1.0, 0.0, 0.0, ANGLE_UP); 219 update.setRotation(1.0, 0.0, 0.0, ANGLE_UP);
209 update.setHitTestable(false); 220 update.setHitTestable(false);
210 update.setVisible(false); 221 update.setVisible(false);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 scene.updateElement(this.transientWarning.uiElementId, update); 275 scene.updateElement(this.transientWarning.uiElementId, update);
265 this.secureOriginTimer = null; 276 this.secureOriginTimer = null;
266 scene.flush(); 277 scene.flush();
267 } 278 }
268 }; 279 };
269 280
270 class Omnibox { 281 class Omnibox {
271 constructor(contentQuadId) { 282 constructor(contentQuadId) {
272 this.domUiElement = new DomUiElement('#omni-container'); 283 this.domUiElement = new DomUiElement('#omni-container');
273 this.enabled = false; 284 this.enabled = false;
285 this.loading = false;
274 this.level = 0; 286 this.level = 0;
275 this.visibilityTimeout = 0; 287 this.visibilityTimeout = 0;
276 this.visibilityTimer = null; 288 this.visibilityTimer = null;
289 this.visibleAfterTransition = false;
277 this.nativeState = {}; 290 this.nativeState = {};
278 291
279 // Initially invisible. 292 // Initially invisible.
280 let update = new api.UiElementUpdate(); 293 let update = new api.UiElementUpdate();
281 update.setVisible(false); 294 update.setVisible(false);
282 scene.updateElement(this.domUiElement.uiElementId, update); 295 scene.updateElement(this.domUiElement.uiElementId, update);
283 this.nativeState.visible = false; 296 this.nativeState.visible = false;
284 297
285 // Listen to the end of transitions, so that the box can be natively 298 // Listen to the end of transitions, so that the box can be natively
286 // hidden after it finishes hiding itself. 299 // hidden after it finishes hiding itself.
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 scene.flush(); 489 scene.flush();
477 } 490 }
478 491
479 return { 492 return {
480 initialize: initialize, 493 initialize: initialize,
481 command: command, 494 command: command,
482 }; 495 };
483 })(); 496 })();
484 497
485 document.addEventListener('DOMContentLoaded', vrShellUi.initialize); 498 document.addEventListener('DOMContentLoaded', vrShellUi.initialize);
OLDNEW
« no previous file with comments | « chrome/browser/resources/vr_shell/compiled_resources2.gyp ('k') | chrome/browser/resources/vr_shell/vr_shell_ui_api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698