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

Unified Diff: chrome/browser/resources/vr_shell/vr_shell_ui_api.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/vr_shell/vr_shell_ui_api.js
diff --git a/chrome/browser/resources/vr_shell/vr_shell_ui_api.js b/chrome/browser/resources/vr_shell/vr_shell_ui_api.js
index 8f64ed4b0d7fdc07e95808fb2849cac0851b8367..4206327badb5e0bfe7f65d4f2d0cdecc9449914e 100644
--- a/chrome/browser/resources/vr_shell/vr_shell_ui_api.js
+++ b/chrome/browser/resources/vr_shell/vr_shell_ui_api.js
@@ -10,13 +10,13 @@ var api = (function() {
* @enum {number}
* @const
*/
- var Command = Object.freeze({
+ var Command = {
'ADD_ELEMENT': 0,
'UPDATE_ELEMENT': 1,
'REMOVE_ELEMENT': 2,
'ADD_ANIMATION': 3,
'REMOVE_ANIMATION': 4
- });
+ };
/**
* Sends one or more commands to native scene management. Commands are used
@@ -43,47 +43,47 @@ var api = (function() {
* @enum {number}
* @const
*/
- var XAnchoring = Object.freeze({
+ var XAnchoring = {
'XNONE': 0,
'XLEFT': 1,
'XRIGHT': 2
- });
+ };
/**
* Enumeration of valid Anchroing for Y axis.
* @enum {number}
* @const
*/
- var YAnchoring = Object.freeze({
+ var YAnchoring = {
'YNONE': 0,
'YTOP': 1,
'YBOTTOM': 2
- });
+ };
/**
* Enumeration of actions that can be triggered by the HTML UI.
* @enum {number}
* @const
*/
- var Action = Object.freeze({
+ var Action = {
'HISTORY_BACK': 0,
'HISTORY_FORWARD': 1,
'RELOAD': 2,
'ZOOM_OUT': 3,
'ZOOM_IN': 4,
'RELOAD_UI': 5,
- });
+ };
/**
* Enumeration of modes that can be specified by the native side.
* @enum {number}
* @const
*/
- var Mode = Object.freeze({
+ var Mode = {
'UNKNOWN': -1,
'STANDARD': 0,
'WEB_VR': 1,
- });
+ };
/**
* Triggers an Action.
@@ -114,8 +114,15 @@ var api = (function() {
*/
class UiElementUpdate {
+ constructor() {
+ this.properties = {};
+ }
+
+ /**
+ * Operates on an instance of MyClass and returns something.
+ */
setIsContentQuad() {
- this.contentQuad = true;
+ this.properties['contentQuad'] = true;
}
/**
@@ -124,21 +131,21 @@ var api = (function() {
* elements to automatically move with a parent.
*/
setParentId(id) {
- this.parentId = id;
+ this.properties['parentId'] = id;
}
/**
* Specify the width and height (in meters) of an element.
*/
setSize(x, y) {
- this.size = { x: x, y: y };
+ this.properties['size'] = { x: x, y: y };
}
/**
* Specify optional scaling of the element, and any children.
*/
setScale(x, y, z) {
- this.scale = { x: x, y: y, z: z };
+ this.properties['scale'] = { x: x, y: y, z: z };
}
/**
@@ -146,16 +153,22 @@ var api = (function() {
* representation (rotate around unit vector [x, y, z] by 'a' radians).
*/
setRotation(x, y, z, a) {
- this.rotation = { x: x, y: y, z: z, a: a };
+ this.properties['rotation'] = { x: x, y: y, z: z, a: a };
}
/**
* Specify the translation of the element. If anchoring is specified, the
* offset is applied to the anchoring position rather than the origin.
* Translation is applied after scaling and rotation.
+ * @param {number} x
+ * @param {number} y
+ * @param {number} z
*/
- setTranslation(x, y, z) {
- this.translation = { x: x, y: y, z: z };
+
+ // TODO - also test private member enforcement.
+
+ setTranslation(x, y, z, w) {
+ this.properties['translation'] = { x: x, y: y, z: z };
}
/**
@@ -165,22 +178,22 @@ var api = (function() {
* Example: element.setAnchoring(XAnchoring.XNONE, YAnchoring.YBOTTOM);
*/
setAnchoring(x, y) {
- this.xAnchoring = x;
- this.yAnchoring = y;
+ this.properties['xAnchoring'] = x;
+ this.properties['yAnchoring'] = y;
}
/**
* Visibility controls whether the element is rendered.
*/
setVisible(visible) {
- this.visible = !!visible;
+ this.properties['visible'] = !!visible;
}
/**
* Hit-testable implies that the reticle will hit the element, if visible.
*/
setHitTestable(testable) {
- this.hitTestable = !!testable;
+ this.properties['hitTestable'] = !!testable;
}
/**
@@ -188,7 +201,7 @@ var api = (function() {
* than the scene. Elements locked in this way should not have a parent.
*/
setLockToFieldOfView(locked) {
- this.lockToFov = !!locked;
+ this.properties['lockToFov'] = !!locked;
}
};
@@ -220,25 +233,25 @@ var api = (function() {
* @enum {number}
* @const
*/
- var Property = Object.freeze({
+ var Property = {
'COPYRECT': 0,
'SIZE': 1,
'TRANSLATION': 2,
- 'ORIENTATION': 3,
+ 'SCALE': 3,
'ROTATION': 4
- });
+ };
/**
* Enumeration of easing type.
* @enum {number}
* @const
*/
- var Easing = Object.freeze({
+ var Easing = {
'LINEAR': 0,
'CUBICBEZIER': 1,
'EASEIN': 2,
'EASEOUT': 3
- });
+ };
/**
* Base animation class. An animation can vary only one object property.
@@ -246,6 +259,7 @@ var api = (function() {
class Animation {
constructor(elementId, durationMs) {
this.meshId = elementId;
+ this.property = -1;
this.to = {};
this.easing = {};
this.easing.type = api.Easing.LINEAR;

Powered by Google App Engine
This is Rietveld 408576698