summaryrefslogtreecommitdiffstats
path: root/assets
diff options
context:
space:
mode:
authorAndy Huang <ath@google.com>2012-10-05 21:20:56 -0700
committerAndy Huang <ath@google.com>2012-10-07 17:33:58 -0700
commitbffc312614505b923f0054fde20d015bd21112cf (patch)
tree24a1f3d576eaeb9f635950b6753a2f4f15c88d29 /assets
parented152093a01d6df9946c1ee575f63823369f4afb (diff)
downloadandroid_packages_apps_UnifiedEmail-bffc312614505b923f0054fde20d015bd21112cf.tar.gz
android_packages_apps_UnifiedEmail-bffc312614505b923f0054fde20d015bd21112cf.tar.bz2
android_packages_apps_UnifiedEmail-bffc312614505b923f0054fde20d015bd21112cf.zip
do not wait for DOM onload before starting content ready signal
Gmail1 started the content-ready animation right away; the initial state of the HTML had the animation already. Gmail2 was waiting for the DOM load event before even starting the animation, wasting a lot of time. Starting the animation right away had a race condition where the listener wasn't installed until later, so avoid any such race by starting the animation immediately after registering the listener. Bug: 7258363 Change-Id: I00fc06998a06e1e4dce0d490ead9fbc6fef63ae0
Diffstat (limited to 'assets')
-rw-r--r--assets/script.js40
1 files changed, 22 insertions, 18 deletions
diff --git a/assets/script.js b/assets/script.js
index f458204ea..3fcfdae11 100644
--- a/assets/script.js
+++ b/assets/script.js
@@ -227,6 +227,27 @@ function restoreScrollPosition() {
}
}
+function onContentReady(event) {
+ window.mail.onContentReady();
+}
+
+function setupContentReady() {
+ var signalDiv;
+
+ // PAGE READINESS SIGNAL FOR JELLYBEAN AND NEWER
+ // Notify the app on 'webkitAnimationStart' of a simple dummy element with a simple no-op
+ // animation that immediately runs on page load. The app uses this as a signal that the
+ // content is loaded and ready to draw, since WebView delays firing this event until the
+ // layers are composited and everything is ready to draw.
+ //
+ // This code is conditionally enabled on JB+ by setting the ENABLE_CONTENT_READY flag.
+ if (ENABLE_CONTENT_READY) {
+ signalDiv = document.getElementById("initial-load-signal");
+ signalDiv.addEventListener("webkitAnimationStart", onContentReady, false);
+ signalDiv.classList.add("initial-load");
+ }
+}
+
// BEGIN Java->JavaScript handlers
function measurePositions() {
var overlayBottoms;
@@ -329,10 +350,6 @@ function replaceSuperCollapsedBlock(startIndex) {
measurePositions();
}
-function onContentReady(event) {
- window.mail.onContentReady();
-}
-
function replaceMessageBodies(messageIds) {
var i;
var id;
@@ -348,24 +365,11 @@ function replaceMessageBodies(messageIds) {
// END Java->JavaScript handlers
-window.onload = function() {
- // PAGE READINESS SIGNAL FOR JELLYBEAN AND NEWER
- // Notify the app on 'webkitAnimationStart' of a simple dummy element with a simple no-op
- // animation that immediately runs on page load. The app uses this as a signal that the
- // content is loaded and ready to draw, since WebView delays firing this event until the
- // layers are composited and everything is ready to draw.
- //
- // This code is conditionally enabled on JB+ by setting the 'initial-load' CSS class on this
- // dummy element.
- document.getElementById("initial-load-signal")
- .addEventListener("webkitAnimationStart", onContentReady, false);
- document.getElementById("initial-load-signal").style.webkitAnimationName = 'initial-load';
-};
-
collapseAllQuotedText();
hideUnsafeImages();
normalizeAllMessageWidths();
//setWideViewport();
restoreScrollPosition();
measurePositions();
+setupContentReady();