Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
| 6 * @fileoverview User pod row implementation. | 6 * @fileoverview User pod row implementation. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 cr.define('login', function() { | 9 cr.define('login', function() { |
| 10 /** | 10 /** |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 * @type {number} | 26 * @type {number} |
| 27 * @const | 27 * @const |
| 28 */ | 28 */ |
| 29 var WALLPAPER_LOAD_DELAY_MS = 500; | 29 var WALLPAPER_LOAD_DELAY_MS = 500; |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Wallpaper load delay in milliseconds. TODO(nkostylev): Tune this constant. | 32 * Wallpaper load delay in milliseconds. TODO(nkostylev): Tune this constant. |
| 33 * @type {number} | 33 * @type {number} |
| 34 * @const | 34 * @const |
| 35 */ | 35 */ |
| 36 var WALLPAPER_BOOT_LOAD_DELAY_MS = 500; | 36 var WALLPAPER_BOOT_LOAD_DELAY_MS = 100; |
| 37 | 37 |
| 38 /** | 38 /** |
| 39 * Maximum time for which the pod row remains hidden until all user images | 39 * Maximum time for which the pod row remains hidden until all user images |
| 40 * have been loaded. | 40 * have been loaded. |
| 41 * @type {number} | 41 * @type {number} |
| 42 * @const | 42 * @const |
| 43 */ | 43 */ |
| 44 var POD_ROW_IMAGES_LOAD_TIMEOUT_MS = 3000; | 44 var POD_ROW_IMAGES_LOAD_TIMEOUT_MS = 3000; |
| 45 | 45 |
| 46 /** | 46 /** |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 442 * @extends {HTMLDivElement} | 442 * @extends {HTMLDivElement} |
| 443 */ | 443 */ |
| 444 var PodRow = cr.ui.define('podrow'); | 444 var PodRow = cr.ui.define('podrow'); |
| 445 | 445 |
| 446 PodRow.prototype = { | 446 PodRow.prototype = { |
| 447 __proto__: HTMLDivElement.prototype, | 447 __proto__: HTMLDivElement.prototype, |
| 448 | 448 |
| 449 // Whether this user pod row is shown for the first time. | 449 // Whether this user pod row is shown for the first time. |
| 450 firstShown_: true, | 450 firstShown_: true, |
| 451 | 451 |
| 452 bootWallpaperLoaded_: false, | |
|
Nikita (slow)
2012/08/29 14:10:01
nit: comment
Ivan Korotkov
2012/08/30 12:26:06
Done.
| |
| 453 | |
| 452 // True if inside focusPod(). | 454 // True if inside focusPod(). |
| 453 insideFocusPod_: false, | 455 insideFocusPod_: false, |
| 454 | 456 |
| 455 // Focused pod. | 457 // Focused pod. |
| 456 focusedPod_: undefined, | 458 focusedPod_: undefined, |
| 457 | 459 |
| 458 // Activated pod, i.e. the pod of current login attempt. | 460 // Activated pod, i.e. the pod of current login attempt. |
| 459 activatedPod_: undefined, | 461 activatedPod_: undefined, |
| 460 | 462 |
| 461 // When moving through users quickly at login screen, set a timeout to | 463 // When moving through users quickly at login screen, set a timeout to |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 this.focusedPod_ = podToFocus; | 678 this.focusedPod_ = podToFocus; |
| 677 if (podToFocus) { | 679 if (podToFocus) { |
| 678 podToFocus.classList.remove('faded'); | 680 podToFocus.classList.remove('faded'); |
| 679 podToFocus.classList.add('focused'); | 681 podToFocus.classList.add('focused'); |
| 680 podToFocus.reset(true); // Reset and give focus. | 682 podToFocus.reset(true); // Reset and give focus. |
| 681 this.scrollPodIntoView(podToFocus); | 683 this.scrollPodIntoView(podToFocus); |
| 682 if (hadFocus) { | 684 if (hadFocus) { |
| 683 // Delay wallpaper loading to let user tab through pods without lag. | 685 // Delay wallpaper loading to let user tab through pods without lag. |
| 684 this.loadWallpaperTimeout_ = window.setTimeout( | 686 this.loadWallpaperTimeout_ = window.setTimeout( |
| 685 this.loadWallpaper_.bind(this), WALLPAPER_LOAD_DELAY_MS); | 687 this.loadWallpaper_.bind(this), WALLPAPER_LOAD_DELAY_MS); |
| 686 } else { | 688 } else if (!this.firstShown_) { |
| 687 if (!this.firstShown_) { | 689 // Load wallpaper immediately if there no pod was focused |
| 688 // Load wallpaper immediately if there no pod was focused | 690 // previously, and it is not a boot into user pod list case. |
| 689 // previously, and it is not a boot into user pod list case. | 691 this.loadWallpaper_(); |
| 690 this.loadWallpaper_(); | 692 this.firstShown_ = false; |
| 691 } else { | |
| 692 // Boot transition. Delay wallpaper load to remove jank | |
| 693 // happening when wallpaper load is competing for resources with | |
| 694 // login WebUI. | |
| 695 if (Oobe.getInstance().shouldLoadWallpaperOnBoot()) { | |
| 696 this.loadWallpaperTimeout_ = window.setTimeout( | |
| 697 this.loadWallpaper_.bind(this), WALLPAPER_BOOT_LOAD_DELAY_MS); | |
| 698 } | |
| 699 this.firstShown_ = false; | |
| 700 } | |
| 701 } | 693 } |
| 702 } else { | 694 } else { |
| 703 chrome.send('userDeselected'); | 695 chrome.send('userDeselected'); |
| 704 } | 696 } |
| 705 this.insideFocusPod_ = false; | 697 this.insideFocusPod_ = false; |
| 706 }, | 698 }, |
| 707 | 699 |
| 708 loadWallpaper_: function() { | 700 loadWallpaper_: function() { |
| 709 if (this.focusedPod_) | 701 if (this.focusedPod_) |
| 710 chrome.send('userSelectedDelayed', [this.focusedPod_.user.username]); | 702 chrome.send('userSelectedDelayed', [this.focusedPod_.user.username]); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 875 }, | 867 }, |
| 876 | 868 |
| 877 /** | 869 /** |
| 878 * Called right after the pod row is shown. | 870 * Called right after the pod row is shown. |
| 879 */ | 871 */ |
| 880 handleAfterShow: function() { | 872 handleAfterShow: function() { |
| 881 // Force input focus for user pod on show and once transition ends. | 873 // Force input focus for user pod on show and once transition ends. |
| 882 if (this.focusedPod_) { | 874 if (this.focusedPod_) { |
| 883 var focusedPod = this.focusedPod_; | 875 var focusedPod = this.focusedPod_; |
| 884 var screen = this.parentNode; | 876 var screen = this.parentNode; |
| 877 var self = this; | |
| 885 focusedPod.addEventListener('webkitTransitionEnd', function f(e) { | 878 focusedPod.addEventListener('webkitTransitionEnd', function f(e) { |
| 886 if (e.target == focusedPod) { | 879 if (e.target == focusedPod) { |
| 887 focusedPod.removeEventListener('webkitTransitionEnd', f); | 880 focusedPod.removeEventListener('webkitTransitionEnd', f); |
| 888 focusedPod.reset(true); | 881 focusedPod.reset(true); |
| 889 // Notify screen that it is ready. | 882 // Notify screen that it is ready. |
| 890 screen.onShow(); | 883 screen.onShow(); |
| 884 // Boot transition: load wallpaper. | |
| 885 if (!self.bootWallpaperLoaded_ && | |
| 886 Oobe.getInstance().shouldLoadWallpaperOnBoot()) { | |
| 887 self.loadWallpaperTimeout_ = window.setTimeout( | |
| 888 self.loadWallpaper_.bind(self), WALLPAPER_BOOT_LOAD_DELAY_MS); | |
| 889 self.bootWallpaperLoaded_ = true; | |
| 890 } | |
| 891 } | 891 } |
| 892 }); | 892 }); |
| 893 } | 893 } |
| 894 }, | 894 }, |
| 895 | 895 |
| 896 /** | 896 /** |
| 897 * Called right before the pod row is shown. | 897 * Called right before the pod row is shown. |
| 898 */ | 898 */ |
| 899 handleBeforeShow: function() { | 899 handleBeforeShow: function() { |
| 900 for (var event in this.listeners_) { | 900 for (var event in this.listeners_) { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 923 handlePodImageLoad: function(pod) { | 923 handlePodImageLoad: function(pod) { |
| 924 var index = this.podsWithPendingImages_.indexOf(pod); | 924 var index = this.podsWithPendingImages_.indexOf(pod); |
| 925 if (index == -1) { | 925 if (index == -1) { |
| 926 return; | 926 return; |
| 927 } | 927 } |
| 928 | 928 |
| 929 this.podsWithPendingImages_.splice(index, 1); | 929 this.podsWithPendingImages_.splice(index, 1); |
| 930 if (this.podsWithPendingImages_.length == 0) { | 930 if (this.podsWithPendingImages_.length == 0) { |
| 931 this.classList.remove('images-loading'); | 931 this.classList.remove('images-loading'); |
| 932 chrome.send('userImagesLoaded'); | 932 chrome.send('userImagesLoaded'); |
| 933 // Report back user pods being painted. | |
| 934 window.webkitRequestAnimationFrame(function() { | |
| 935 chrome.send('loginVisible'); | |
| 936 }); | |
| 937 } | 933 } |
| 938 } | 934 } |
| 939 }; | 935 }; |
| 940 | 936 |
| 941 return { | 937 return { |
| 942 PodRow: PodRow | 938 PodRow: PodRow |
| 943 }; | 939 }; |
| 944 }); | 940 }); |
| OLD | NEW |