Bug 516645: Preload border-image images to speed up the rendering [r=gavin.sharp]

This commit is contained in:
Mark Finkle 2009-10-29 18:58:40 -04:00
Родитель 77b7d0f07c
Коммит 161d672a1f
1 изменённых файлов: 27 добавлений и 3 удалений

Просмотреть файл

@ -343,8 +343,6 @@ var Browser = {
startup: function() { startup: function() {
var self = this; var self = this;
//dump("begin startup\n");
let container = document.getElementById("tile-container"); let container = document.getElementById("tile-container");
let bv = this._browserView = new BrowserView(container, Browser.getVisibleRect); let bv = this._browserView = new BrowserView(container, Browser.getVisibleRect);
@ -573,7 +571,8 @@ var Browser = {
gPrefService.clearUserPref("temporary.disabledFlash"); gPrefService.clearUserPref("temporary.disabledFlash");
} }
//dump("end startup\n"); // Force commonly used border-images into the image cache
ImagePreloader.cache();
}, },
shutdown: function() { shutdown: function() {
@ -2688,3 +2687,28 @@ Tab.prototype = {
return "[Tab " + (this._browser ? this._browser.contentDocument.location.toString() : "(no browser)") + "]"; 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";
}
}
}