Keep the Util.alphaHack function result in a cache. r=pgiraud (closes #1825)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@8419 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Frédéric Junod
2008-11-27 14:23:11 +00:00
parent b694095a89
commit 274afe0a5f

View File

@@ -390,6 +390,12 @@ OpenLayers.Util.onImageLoadError = function() {
this.style.display = "";
};
/**
* Property: alphaHackNeeded
* {Boolean} true if the png alpha hack is necessary and possible, false otherwise.
*/
OpenLayers.Util.alphaHackNeeded = null;
/**
* Function: alphaHack
* Checks whether it's necessary (and possible) to use the png alpha
@@ -397,25 +403,27 @@ OpenLayers.Util.onImageLoadError = function() {
* Explorer.
*
* Returns:
* {Boolean} true if alpha has is necessary and possible, false otherwise.
* {Boolean} true if the png alpha hack is necessary and possible, false otherwise.
*/
OpenLayers.Util.alphaHack = function() {
var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);
var filter = false;
if (OpenLayers.Util.alphaHackNeeded == null) {
var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);
var filter = false;
// IEs4Lin dies when trying to access document.body.filters, because
// the property is there, but requires a DLL that can't be provided. This
// means that we need to wrap this in a try/catch so that this can
// continue.
// IEs4Lin dies when trying to access document.body.filters, because
// the property is there, but requires a DLL that can't be provided. This
// means that we need to wrap this in a try/catch so that this can
// continue.
try {
filter = !!(document.body.filters);
} catch (e) {
try {
filter = !!(document.body.filters);
} catch (e) {}
OpenLayers.Util.alphaHackNeeded = (filter &&
(version >= 5.5) && (version < 7));
}
return ( filter &&
(version >= 5.5) && (version < 7) );
return OpenLayers.Util.alphaHackNeeded;
};
/**