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 vrShellUi = (function() { | 5 var vrShellUi = (function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 let ui = new scene.Scene(); | 8 let ui = new scene.Scene(); |
9 let uiManager; | 9 let uiManager; |
10 let nativeCommandHandler; | 10 let nativeCommandHandler; |
11 | 11 |
12 let uiRootElement = document.querySelector('#ui'); | 12 let uiRootElement = document.querySelector('#ui'); |
13 let uiStyle = window.getComputedStyle(uiRootElement); | 13 let uiStyle = window.getComputedStyle(uiRootElement); |
14 /** @const */ var ANIM_DURATION = 150; | 14 /** @const */ var ANIM_DURATION = 150; |
15 | 15 |
16 // This value should match the one in VrShellImpl.java | 16 // This value should match the one in VrShellImpl.java |
17 /** @const */ var UI_DPR = 1.2; | 17 /** @const */ var UI_DPR = 1.2; |
18 | 18 |
19 function getStyleFloat(style, property) { | 19 function getStyleFloat(style, property, defaultValue) { |
20 let value = parseFloat(style.getPropertyValue(property)); | 20 let value = parseFloat(style.getPropertyValue(property)); |
21 return isNaN(value) ? 0 : value; | 21 return isNaN(value) ? defaultValue : value; |
22 } | 22 } |
23 | 23 |
24 function getStyleString(style, property) { | 24 function getStyleString(style, property) { |
25 let str = style.getPropertyValue(property); | 25 let str = style.getPropertyValue(property); |
26 return !str || 0 === str.length ? '' : str; | 26 return !str || 0 === str.length ? '' : str; |
27 } | 27 } |
28 | 28 |
29 class ContentQuad { | 29 class ContentQuad { |
30 constructor() { | 30 constructor() { |
31 /** @const */ this.SCREEN_HEIGHT = 1.6; | 31 /** @const */ this.SCREEN_HEIGHT = 1.375; |
32 /** @const */ this.SCREEN_RATIO = 16 / 9; | 32 /** @const */ this.SCREEN_RATIO = 9.6 / 6.4; |
| 33 /** @const */ this.BROWSING_SCREEN_ELEVATION = -0.15; |
33 /** @const */ this.BROWSING_SCREEN_DISTANCE = 2.0; | 34 /** @const */ this.BROWSING_SCREEN_DISTANCE = 2.0; |
34 /** @const */ this.FULLSCREEN_DISTANCE = 3.0; | 35 /** @const */ this.FULLSCREEN_DISTANCE = 3.0; |
35 /** @const */ this.CSS_WIDTH_PIXELS = 960.0; | 36 /** @const */ this.CSS_WIDTH_PIXELS = 960.0; |
36 /** @const */ this.CSS_HEIGHT_PIXELS = 640.0; | 37 /** @const */ this.CSS_HEIGHT_PIXELS = 640.0; |
37 /** @const */ this.DPR = 1.2; | 38 /** @const */ this.DPR = 1.2; |
38 /** @const */ this.MENU_MODE_SCREEN_DISTANCE = 2.0; | 39 /** @const */ this.MENU_MODE_SCREEN_DISTANCE = 2.0; |
39 /** @const */ this.MENU_MODE_SCREEN_HEIGHT = 0.8; | 40 /** @const */ this.MENU_MODE_SCREEN_HEIGHT = 0.48; |
40 /** @const */ this.MENU_MODE_SCREEN_ELEVATION = 0.2; | 41 /** @const */ this.MENU_MODE_SCREEN_ELEVATION = -0.125; |
41 /** @const */ this.BACKGROUND_DISTANCE_MULTIPLIER = 1.414; | 42 /** @const */ this.BACKGROUND_DISTANCE_MULTIPLIER = 1.414; |
42 /** @const */ this.DOM_INTERCEPTOR_SELECTOR = '#content-interceptor'; | 43 /** @const */ this.DOM_INTERCEPTOR_SELECTOR = '#content-interceptor'; |
43 /** @const */ this.DOM_INTERCEPTOR_ELEVATION = 0.01; | 44 /** @const */ this.DOM_INTERCEPTOR_ELEVATION = 0.01; |
44 | 45 |
45 this.menuMode = false; | 46 this.menuMode = false; |
46 this.fullscreen = false; | 47 this.fullscreen = false; |
47 | 48 |
48 let element = new api.UiElement(0, 0, 0, 0); | 49 let element = new api.UiElement(0, 0, 0, 0); |
49 element.setFill(new api.Content()); | 50 element.setFill(new api.Content()); |
50 element.setVisible(false); | 51 element.setVisible(false); |
51 element.setSize( | 52 element.setSize( |
52 this.SCREEN_HEIGHT * this.SCREEN_RATIO, this.SCREEN_HEIGHT); | 53 this.SCREEN_HEIGHT * this.SCREEN_RATIO, this.SCREEN_HEIGHT); |
53 element.setTranslation(0, 0, -this.BROWSING_SCREEN_DISTANCE); | 54 element.setTranslation( |
| 55 0, this.BROWSING_SCREEN_ELEVATION, -this.BROWSING_SCREEN_DISTANCE); |
54 this.elementId = ui.addElement(element); | 56 this.elementId = ui.addElement(element); |
55 | 57 |
56 // Place an invisible (fill none) but hittable plane behind the content | 58 // Place an invisible (fill none) but hittable plane behind the content |
57 // quad, to keep the reticle roughly planar with the content if near | 59 // quad, to keep the reticle roughly planar with the content if near |
58 // content. | 60 // content. |
59 let backPlane = new api.UiElement(0, 0, 0, 0); | 61 let backPlane = new api.UiElement(0, 0, 0, 0); |
60 backPlane.setSize(1000, 1000); | 62 backPlane.setSize(1000, 1000); |
61 backPlane.setTranslation(0, 0, -0.01); | 63 backPlane.setTranslation(0, 0, -0.01); |
62 backPlane.setParentId(this.elementId); | 64 backPlane.setParentId(this.elementId); |
63 backPlane.setFill(new api.NoFill()); | 65 backPlane.setFill(new api.NoFill()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 108 |
107 setFullscreen(enabled) { | 109 setFullscreen(enabled) { |
108 if (this.fullscreen == enabled) | 110 if (this.fullscreen == enabled) |
109 return; | 111 return; |
110 this.fullscreen = enabled; | 112 this.fullscreen = enabled; |
111 this.updateState(); | 113 this.updateState(); |
112 } | 114 } |
113 | 115 |
114 updateState() { | 116 updateState() { |
115 // Defaults content quad parameters. | 117 // Defaults content quad parameters. |
116 let y = 0; | 118 let y = this.BROWSING_SCREEN_ELEVATION; |
117 let distance = this.BROWSING_SCREEN_DISTANCE; | 119 let distance = this.BROWSING_SCREEN_DISTANCE; |
118 let height = this.SCREEN_HEIGHT; | 120 let height = this.SCREEN_HEIGHT; |
119 | 121 |
120 // Mode-specific overrides. | 122 // Mode-specific overrides. |
121 if (this.menuMode) { | 123 if (this.menuMode) { |
122 y = this.MENU_MODE_SCREEN_ELEVATION; | 124 y = this.MENU_MODE_SCREEN_ELEVATION; |
123 distance = this.MENU_MODE_SCREEN_DISTANCE; | 125 distance = this.MENU_MODE_SCREEN_DISTANCE; |
124 height = this.MENU_MODE_SCREEN_HEIGHT; | 126 height = this.MENU_MODE_SCREEN_HEIGHT; |
125 } else if (this.fullscreen) { | 127 } else if (this.fullscreen) { |
126 distance = this.FULLSCREEN_DISTANCE; | 128 distance = this.FULLSCREEN_DISTANCE; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 let pixelX = Math.floor(rect.left); | 162 let pixelX = Math.floor(rect.left); |
161 let pixelY = Math.floor(rect.top); | 163 let pixelY = Math.floor(rect.top); |
162 let pixelWidth = Math.ceil(rect.right) - pixelX; | 164 let pixelWidth = Math.ceil(rect.right) - pixelX; |
163 let pixelHeight = Math.ceil(rect.bottom) - pixelY; | 165 let pixelHeight = Math.ceil(rect.bottom) - pixelY; |
164 | 166 |
165 let element = new api.UiElement(pixelX, pixelY, pixelWidth, pixelHeight); | 167 let element = new api.UiElement(pixelX, pixelY, pixelWidth, pixelHeight); |
166 this.sizeX = pixelWidth / 1000; | 168 this.sizeX = pixelWidth / 1000; |
167 this.sizeY = pixelHeight / 1000; | 169 this.sizeY = pixelHeight / 1000; |
168 element.setSize(this.sizeX, this.sizeY); | 170 element.setSize(this.sizeX, this.sizeY); |
169 | 171 |
170 // Pull additional custom properties from CSS. | 172 // Parse element CSS properties. |
171 let style = window.getComputedStyle(domElement); | 173 let style = window.getComputedStyle(domElement); |
172 this.translationX = getStyleFloat(style, '--tranX'); | 174 |
173 this.translationY = getStyleFloat(style, '--tranY'); | 175 this.translationX = getStyleFloat(style, '--tranX', 0); |
174 this.translationZ = getStyleFloat(style, '--tranZ'); | 176 this.translationY = getStyleFloat(style, '--tranY', 0); |
175 element.setTranslation( | 177 this.translationZ = getStyleFloat(style, '--tranZ', 0); |
176 this.translationX, this.translationY, this.translationZ); | 178 if (this.translationX != 0 || this.translationY != 0 || |
| 179 this.translationZ != 0) { |
| 180 element.setTranslation( |
| 181 this.translationX, this.translationY, this.translationZ); |
| 182 } |
| 183 |
| 184 this.scale = getStyleFloat(style, '--scale', 1); |
| 185 if (this.scale != 1) { |
| 186 element.setScale(this.scale, this.scale, this.scale); |
| 187 } |
| 188 |
| 189 this.rotationX = getStyleFloat(style, '--rotX', 0); |
| 190 this.rotationY = getStyleFloat(style, '--rotY', 0); |
| 191 this.rotationZ = getStyleFloat(style, '--rotZ', 0); |
| 192 if (this.rotationX != 0 || this.rotationY != 0 || this.rotationZ != 0) { |
| 193 element.setRotation( |
| 194 this.rotationX, this.rotationY, this.rotationZ, 2 * Math.PI); |
| 195 } |
177 | 196 |
178 this.id = ui.addElement(element); | 197 this.id = ui.addElement(element); |
179 this.domElement = domElement; | 198 this.domElement = domElement; |
180 } | 199 } |
181 }; | 200 }; |
182 | 201 |
183 class Button { | 202 class Button { |
184 constructor(domId, callback, parentId) { | 203 constructor(domId, callback, parentId) { |
185 let captionId = domId + '-caption'; | 204 let captionId = domId + '-caption'; |
186 this.button = document.querySelector(domId); | 205 this.button = document.querySelector(domId); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 } | 396 } |
378 ], | 397 ], |
379 [ | 398 [ |
380 'forwardButton', '#forward-button', | 399 'forwardButton', '#forward-button', |
381 function() { | 400 function() { |
382 api.doAction(api.Action.HISTORY_FORWARD, {}); | 401 api.doAction(api.Action.HISTORY_FORWARD, {}); |
383 } | 402 } |
384 ], | 403 ], |
385 ]; | 404 ]; |
386 | 405 |
387 /** @const */ var BUTTON_Y = -0.27; | 406 /** @const */ var BUTTON_Y = -0.53; |
388 /** @const */ var BUTTON_Z = -1; | 407 /** @const */ var BUTTON_Z = -2; |
389 /** @const */ var BUTTON_SPACING = 0.11; | 408 /** @const */ var BUTTON_SPACING = 0.14; |
390 | 409 |
391 let controls = new api.UiElement(0, 0, 0, 0); | 410 let controls = new api.UiElement(0, 0, 0, 0); |
392 controls.setVisible(false); | 411 controls.setVisible(false); |
393 controls.setTranslation(0, BUTTON_Y, BUTTON_Z); | 412 controls.setTranslation(0, BUTTON_Y, BUTTON_Z); |
394 this.controlsId = ui.addElement(controls); | 413 this.controlsId = ui.addElement(controls); |
395 | 414 |
396 let startPosition = -BUTTON_SPACING * (descriptors.length / 2.0 - 0.5); | 415 let startPosition = -BUTTON_SPACING * (descriptors.length / 2.0 - 0.5); |
397 | 416 |
398 for (let i = 0; i < descriptors.length; i++) { | 417 for (let i = 0; i < descriptors.length; i++) { |
399 let name = descriptors[i][0]; | 418 let name = descriptors[i][0]; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 this.devMode = false; | 453 this.devMode = false; |
435 | 454 |
436 this.uiElement = new DomUiElement('#reload-ui-button'); | 455 this.uiElement = new DomUiElement('#reload-ui-button'); |
437 this.uiElement.domElement.addEventListener('click', function() { | 456 this.uiElement.domElement.addEventListener('click', function() { |
438 ui.purge(); | 457 ui.purge(); |
439 api.doAction(api.Action.RELOAD_UI, {}); | 458 api.doAction(api.Action.RELOAD_UI, {}); |
440 }); | 459 }); |
441 | 460 |
442 let update = new api.UiElementUpdate(); | 461 let update = new api.UiElementUpdate(); |
443 update.setVisible(false); | 462 update.setVisible(false); |
444 update.setSize(0.25, 0.1); | |
445 update.setTranslation(0, -1.0, -1.0); | |
446 update.setRotation(1, 0, 0, -0.8); | |
447 ui.updateElement(this.uiElement.id, update); | 463 ui.updateElement(this.uiElement.id, update); |
448 } | 464 } |
449 | 465 |
450 setEnabled(enabled) { | 466 setEnabled(enabled) { |
451 this.enabled = enabled; | 467 this.enabled = enabled; |
452 this.updateState(); | 468 this.updateState(); |
453 } | 469 } |
454 | 470 |
455 setDevMode(enabled) { | 471 setDevMode(enabled) { |
456 this.devMode = enabled; | 472 this.devMode = enabled; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 ui.updateElement(this.domUiElement.id, update); | 575 ui.updateElement(this.domUiElement.id, update); |
560 this.nativeState.visible = false; | 576 this.nativeState.visible = false; |
561 | 577 |
562 // Pull some CSS properties so that Javascript can reconfigure the | 578 // Pull some CSS properties so that Javascript can reconfigure the |
563 // indicator programmatically. | 579 // indicator programmatically. |
564 let border = | 580 let border = |
565 this.domUiElement.domElement.querySelector('#url-indicator-border'); | 581 this.domUiElement.domElement.querySelector('#url-indicator-border'); |
566 let style = window.getComputedStyle(border); | 582 let style = window.getComputedStyle(border); |
567 this.statusBarColor = getStyleString(style, '--statusBarColor'); | 583 this.statusBarColor = getStyleString(style, '--statusBarColor'); |
568 this.backgroundColor = style.backgroundColor; | 584 this.backgroundColor = style.backgroundColor; |
569 this.fadeTimeMs = getStyleFloat(style, '--fadeTimeMs'); | 585 this.fadeTimeMs = getStyleFloat(style, '--fadeTimeMs', 0); |
570 this.fadeYOffset = getStyleFloat(style, '--fadeYOffset'); | 586 this.fadeYOffset = getStyleFloat(style, '--fadeYOffset', 0); |
571 this.opacity = getStyleFloat(style, '--opacity'); | 587 this.opacity = getStyleFloat(style, '--opacity', 1); |
572 } | 588 } |
573 | 589 |
574 getSecurityIconElementId(level) { | 590 getSecurityIconElementId(level) { |
575 // See security_state.h and getSecurityIconResource() for this mapping. | 591 // See security_state.h and getSecurityIconResource() for this mapping. |
576 switch (level) { | 592 switch (level) { |
577 case 0: // NONE | 593 case 0: // NONE |
578 case 1: // HTTP_SHOW_WARNING | 594 case 1: // HTTP_SHOW_WARNING |
579 case 4: // SECURITY_WARNING | 595 case 4: // SECURITY_WARNING |
580 return '#url-indicator-info-icon'; | 596 return '#url-indicator-info-icon'; |
581 case 2: // SECURE: | 597 case 2: // SECURE: |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 update.setVisible(visible); | 720 update.setVisible(visible); |
705 ui.updateElement(this.domUiElement.id, update); | 721 ui.updateElement(this.domUiElement.id, update); |
706 ui.flush(); | 722 ui.flush(); |
707 } | 723 } |
708 }; | 724 }; |
709 | 725 |
710 class Background { | 726 class Background { |
711 constructor() { | 727 constructor() { |
712 /** @const */ this.SCENE_GROUND_SIZE = 25.0; | 728 /** @const */ this.SCENE_GROUND_SIZE = 25.0; |
713 /** @const */ this.SCENE_HEIGHT = 4.0; | 729 /** @const */ this.SCENE_HEIGHT = 4.0; |
714 /** @const */ this.GRIDLINE_COUNT = 10; | 730 /** @const */ this.GRIDLINE_COUNT = 40; |
715 /** @const */ this.HORIZON_COLOR = {r: 0.57, g: 0.57, b: 0.57, a: 1.0}; | 731 /** @const */ this.HORIZON_COLOR = {r: 0.57, g: 0.57, b: 0.57, a: 1.0}; |
716 /** @const */ this.CENTER_COLOR = {r: 0.48, g: 0.48, b: 0.48, a: 1.0}; | 732 /** @const */ this.CENTER_COLOR = {r: 0.48, g: 0.48, b: 0.48, a: 1.0}; |
717 /** @const */ this.FULLSCREEN_BACKGROUND_COLOR = | 733 /** @const */ this.FULLSCREEN_BACKGROUND_COLOR = |
718 {r: 0.1, g: 0.1, b: 0.1, a: 1.0}; | 734 {r: 0.1, g: 0.1, b: 0.1, a: 1.0}; |
719 | 735 |
720 // Make ground plane. | 736 // Make ground plane. |
721 let groundPlane = new api.UiElementUpdate(); | 737 let groundPlane = new api.UiElementUpdate(); |
722 groundPlane.setVisible(true); | 738 groundPlane.setVisible(true); |
723 groundPlane.setSize(this.SCENE_GROUND_SIZE, this.SCENE_GROUND_SIZE); | 739 groundPlane.setSize(this.SCENE_GROUND_SIZE, this.SCENE_GROUND_SIZE); |
724 groundPlane.setFill( | 740 groundPlane.setFill( |
725 new api.OpaqueGradient(this.HORIZON_COLOR, this.CENTER_COLOR)); | 741 new api.OpaqueGradient(this.HORIZON_COLOR, this.CENTER_COLOR)); |
726 groundPlane.setTranslation(0, -this.SCENE_HEIGHT / 2, 0); | 742 groundPlane.setTranslation(0, -this.SCENE_HEIGHT / 2, 0); |
727 groundPlane.setRotation(1.0, 0.0, 0.0, -Math.PI / 2); | 743 groundPlane.setRotation(1.0, 0.0, 0.0, -Math.PI / 2); |
728 groundPlane.setDrawPhase(0); | 744 groundPlane.setDrawPhase(0); |
729 this.groundPlaneId = ui.addElement(groundPlane); | 745 this.groundPlaneId = ui.addElement(groundPlane); |
730 | 746 |
731 // Make ceiling plane. | 747 // Make ceiling plane. |
732 let ceilingPlane = new api.UiElementUpdate(); | 748 let ceilingPlane = new api.UiElementUpdate(); |
733 ceilingPlane.setVisible(true); | 749 ceilingPlane.setVisible(true); |
734 ceilingPlane.setSize(this.SCENE_GROUND_SIZE, this.SCENE_GROUND_SIZE); | 750 ceilingPlane.setSize(this.SCENE_GROUND_SIZE, this.SCENE_GROUND_SIZE); |
735 ceilingPlane.setFill( | 751 ceilingPlane.setFill( |
736 new api.OpaqueGradient(this.HORIZON_COLOR, this.CENTER_COLOR)); | 752 new api.OpaqueGradient(this.HORIZON_COLOR, this.CENTER_COLOR)); |
737 ceilingPlane.setTranslation(0, this.SCENE_HEIGHT / 2, 0); | 753 ceilingPlane.setTranslation(0, this.SCENE_HEIGHT * 2, 0); |
738 ceilingPlane.setRotation(1.0, 0.0, 0.0, Math.PI / 2); | 754 ceilingPlane.setRotation(1.0, 0.0, 0.0, Math.PI / 2); |
739 ceilingPlane.setDrawPhase(0); | 755 ceilingPlane.setDrawPhase(0); |
740 this.ceilingPlaneId = ui.addElement(ceilingPlane); | 756 this.ceilingPlaneId = ui.addElement(ceilingPlane); |
741 | 757 |
742 // Ground grid. | 758 // Ground grid. |
743 let groundGrid = new api.UiElementUpdate(); | 759 let groundGrid = new api.UiElementUpdate(); |
744 groundGrid.setVisible(true); | 760 groundGrid.setVisible(true); |
745 groundGrid.setSize(this.SCENE_GROUND_SIZE, this.SCENE_GROUND_SIZE); | 761 groundGrid.setSize(this.SCENE_GROUND_SIZE, this.SCENE_GROUND_SIZE); |
746 let transparentHorizonColor = { | 762 let transparentHorizonColor = { |
747 r: this.HORIZON_COLOR.r, | 763 r: this.HORIZON_COLOR.r, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 } else { | 817 } else { |
802 this.setHiddenBackground(); | 818 this.setHiddenBackground(); |
803 } | 819 } |
804 break; | 820 break; |
805 } | 821 } |
806 } | 822 } |
807 }; | 823 }; |
808 | 824 |
809 class Omnibox { | 825 class Omnibox { |
810 constructor() { | 826 constructor() { |
| 827 /** @const */ this.ELEVATION = -0.7; |
| 828 /** @const */ this.DISTANCE = -1.99; |
| 829 /** @const */ this.SCALE = -this.DISTANCE; |
| 830 |
811 this.enabled = false; | 831 this.enabled = false; |
812 | 832 |
813 let root = document.querySelector('#omnibox-ui-element'); | 833 let root = document.querySelector('#omnibox-ui-element'); |
814 this.domUiElement = new DomUiElement('#omnibox-url-element'); | 834 this.domUiElement = new DomUiElement('#omnibox-url-element'); |
815 this.inputField = root.querySelector('#omnibox-input-field'); | 835 this.inputField = root.querySelector('#omnibox-input-field'); |
816 | 836 |
817 // Initially invisible. | 837 // Initially invisible. |
818 let update = new api.UiElementUpdate(); | 838 let update = new api.UiElementUpdate(); |
819 update.setVisible(false); | 839 update.setVisible(false); |
| 840 update.setTranslation(0, this.ELEVATION, this.DISTANCE); |
| 841 update.setScale(this.SCALE, this.SCALE, this.SCALE); |
820 ui.updateElement(this.domUiElement.id, update); | 842 ui.updateElement(this.domUiElement.id, update); |
821 | 843 |
822 // Field-clearing button. | 844 // Field-clearing button. |
823 let clearButton = root.querySelector('#omnibox-clear-button'); | 845 let clearButton = root.querySelector('#omnibox-clear-button'); |
824 clearButton.addEventListener('click', function() { | 846 clearButton.addEventListener('click', function() { |
825 this.inputField.value = ''; | 847 this.inputField.value = ''; |
826 api.doAction(api.Action.OMNIBOX_CONTENT, {'text': ''}); | 848 api.doAction(api.Action.OMNIBOX_CONTENT, {'text': ''}); |
827 }.bind(this)); | 849 }.bind(this)); |
828 | 850 |
829 // Watch for the enter key to trigger navigation. | 851 // Watch for the enter key to trigger navigation. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 // TODO(crbug/641487): currently, tabs cannot be scrolled because the | 938 // TODO(crbug/641487): currently, tabs cannot be scrolled because the |
917 // scrolling event is not sent to UI elements. | 939 // scrolling event is not sent to UI elements. |
918 class TabContainer { | 940 class TabContainer { |
919 constructor(contentQuadId) { | 941 constructor(contentQuadId) { |
920 /** @const */ var DOM_TAB_TEMPLATE_SELECTOR = '#tab-template'; | 942 /** @const */ var DOM_TAB_TEMPLATE_SELECTOR = '#tab-template'; |
921 /** @const */ var DOM_TAB_CONTAINER_SELECTOR = '#tab-container'; | 943 /** @const */ var DOM_TAB_CONTAINER_SELECTOR = '#tab-container'; |
922 /** @const */ var DOM_TAB_CLIP_SELECTOR = '#tab-clip'; | 944 /** @const */ var DOM_TAB_CLIP_SELECTOR = '#tab-clip'; |
923 /** @const */ var DOM_NEW_TAB_BUTTON_SELECTOR = '#new-tab'; | 945 /** @const */ var DOM_NEW_TAB_BUTTON_SELECTOR = '#new-tab'; |
924 /** @const */ var DOM_NEW_INCOGNITO_TAB_BUTTON_SELECTOR = | 946 /** @const */ var DOM_NEW_INCOGNITO_TAB_BUTTON_SELECTOR = |
925 '#new-incognito-tab'; | 947 '#new-incognito-tab'; |
926 /** @const */ var TAB_CONTAINER_Y_OFFSET = 0.4; | 948 /** @const */ var TAB_CONTAINER_Y_OFFSET = 0.3; |
927 /** @const */ var TAB_CONTAINER_Z_OFFSET = -1; | 949 /** @const */ var TAB_CONTAINER_Z_OFFSET = -2; |
928 | 950 |
929 this.domTabs = {}; | 951 this.domTabs = {}; |
930 this.contentQuadId = contentQuadId; | 952 this.contentQuadId = contentQuadId; |
931 this.domTabTemplate = document.querySelector(DOM_TAB_TEMPLATE_SELECTOR); | 953 this.domTabTemplate = document.querySelector(DOM_TAB_TEMPLATE_SELECTOR); |
932 this.domTabContainer = document.querySelector(DOM_TAB_CONTAINER_SELECTOR); | 954 this.domTabContainer = document.querySelector(DOM_TAB_CONTAINER_SELECTOR); |
933 this.domTabClip = document.querySelector(DOM_TAB_CLIP_SELECTOR); | 955 this.domTabClip = document.querySelector(DOM_TAB_CLIP_SELECTOR); |
934 | 956 |
935 // Add tab container to native scene. | 957 // Add tab container to native scene. |
936 this.tabContainerElement = new DomUiElement(DOM_TAB_CONTAINER_SELECTOR); | 958 this.tabContainerElement = new DomUiElement(DOM_TAB_CONTAINER_SELECTOR); |
937 let positionUpdate = new api.UiElementUpdate(); | 959 let positionUpdate = new api.UiElementUpdate(); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 update.setVisible(enabled); | 1065 update.setVisible(enabled); |
1044 ui.updateElement(buttonElement.id, update); | 1066 ui.updateElement(buttonElement.id, update); |
1045 }, this); | 1067 }, this); |
1046 } | 1068 } |
1047 }; | 1069 }; |
1048 | 1070 |
1049 class VirtualKeyboard { | 1071 class VirtualKeyboard { |
1050 constructor(contentQuadId) { | 1072 constructor(contentQuadId) { |
1051 /** @const */ this.SCALE = 1.4; | 1073 /** @const */ this.SCALE = 1.4; |
1052 /** @const */ this.ANGLE_UP = Math.PI / 8; | 1074 /** @const */ this.ANGLE_UP = Math.PI / 8; |
1053 /** @const */ this.Y_OFFSET = -0.9; | 1075 /** @const */ this.Y_OFFSET = -1.0; |
1054 /** @const */ this.Z_OFFSET = -1.8; | 1076 /** @const */ this.Z_OFFSET = -1.8; |
1055 | 1077 |
1056 this.element = new DomUiElement('#vkb'); | 1078 this.element = new DomUiElement('#vkb'); |
1057 let update = new api.UiElementUpdate(); | 1079 let update = new api.UiElementUpdate(); |
1058 update.setVisible(true); | 1080 update.setVisible(true); |
1059 update.setOpacity(0); | 1081 update.setOpacity(0); |
1060 update.setRotation(1, 0, 0, -this.ANGLE_UP); | 1082 update.setRotation(1, 0, 0, -this.ANGLE_UP); |
1061 update.setScale(this.SCALE, this.SCALE, this.SCALE); | 1083 update.setScale(this.SCALE, this.SCALE, this.SCALE); |
1062 update.setTranslation(0, this.Y_OFFSET, this.Z_OFFSET); | 1084 update.setTranslation(0, this.Y_OFFSET, this.Z_OFFSET); |
1063 ui.updateElement(this.element.id, update); | 1085 ui.updateElement(this.element.id, update); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 nativeCommandHandler.handleCommand(dict); | 1308 nativeCommandHandler.handleCommand(dict); |
1287 } | 1309 } |
1288 | 1310 |
1289 return { | 1311 return { |
1290 initialize: initialize, | 1312 initialize: initialize, |
1291 command: command, | 1313 command: command, |
1292 }; | 1314 }; |
1293 })(); | 1315 })(); |
1294 | 1316 |
1295 window.addEventListener('load', vrShellUi.initialize); | 1317 window.addEventListener('load', vrShellUi.initialize); |
OLD | NEW |