From 161d672a1f1200099a1caa0d88402d5cb3d166c9 Mon Sep 17 00:00:00 2001 From: Mark Finkle Date: Thu, 29 Oct 2009 18:58:40 -0400 Subject: [PATCH] Bug 516645: Preload border-image images to speed up the rendering [r=gavin.sharp] --- mobile/chrome/content/browser.js | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/mobile/chrome/content/browser.js b/mobile/chrome/content/browser.js index 9e66dd15e02..d838b7b115f 100644 --- a/mobile/chrome/content/browser.js +++ b/mobile/chrome/content/browser.js @@ -343,8 +343,6 @@ var Browser = { startup: function() { var self = this; - //dump("begin startup\n"); - let container = document.getElementById("tile-container"); let bv = this._browserView = new BrowserView(container, Browser.getVisibleRect); @@ -573,7 +571,8 @@ var Browser = { gPrefService.clearUserPref("temporary.disabledFlash"); } - //dump("end startup\n"); + // Force commonly used border-images into the image cache + ImagePreloader.cache(); }, shutdown: function() { @@ -2688,3 +2687,28 @@ Tab.prototype = { return "[Tab " + (this._browser ? this._browser.contentDocument.location.toString() : "(no browser)") + "]"; } }; + +var ImagePreloader = { + cache: function ip_cache() { + // Preload images used in border-image CSS + let images = ["button-active", "button-default", + "buttondark-active", "buttondark-default", + "toggleon-active", "toggleon-inactive", + "toggleoff-active", "toggleoff-inactive", + "toggleleft-active", "toggleleft-inactive", + "togglemiddle-active", "togglemiddle-inactive", + "toggleright-active", "toggleright-inactive", + "toggleboth-active", "toggleboth-inactive", + "toggledarkleft-active", "toggledarkleft-inactive", + "toggledarkmiddle-active", "toggledarkmiddle-inactive", + "toggledarkright-active", "toggledarkright-inactive", + "toggledarkboth-active", "toggledarkboth-inactive", + "toolbarbutton-active", "toolbarbutton-default"]; + + let size = screen.width > 400 ? "-64" : "-36"; + for (let i = 0; i < images.length; i++) { + let image = new Image(); + image.src = "chrome://browser/skin/images/" + images[i] + size + ".png"; + } + } +}