зеркало из https://github.com/mozilla/pjs.git
Bug 410290 - Update to Flashblock 1.5.5 plus regression fixes. r/sr=mento
This commit is contained in:
Родитель
cf60df0154
Коммит
f60ac45667
|
@ -6,5 +6,5 @@ manifest. A contents.rdf file is included to allow Camino to identify
|
|||
the contents of flashblock.jar.
|
||||
|
||||
Camino's bundled Flashblock extension is currently synchronized with
|
||||
Flashblock 1.5.4.1 from
|
||||
http://downloads.mozdev.org/flashblock/flashblock-1.5.4.1.xpi.
|
||||
Flashblock 1.5.5+ from
|
||||
http://downloads.mozdev.org/flashblock/flashblock-1.5.unstable.xpi.
|
||||
|
|
|
@ -1,90 +1,91 @@
|
|||
/*
|
||||
* Flash Click to View by Ted Mielczarek (luser_mozilla@perilith.com)
|
||||
* Original code by Jesse Ruderman (jruderman@hmc.edu)
|
||||
* taken from http://www.squarefree.com/userstyles/xbl.html
|
||||
*
|
||||
* Change XBL binding for <object> tags, click to view flash
|
||||
*/
|
||||
|
||||
/*
|
||||
* Flash identifiers.
|
||||
*/
|
||||
object[classid*=":D27CDB6E-AE6D-11cf-96B8-444553540000"],
|
||||
object[codebase*="swflash.cab"],
|
||||
object[data*=".swf"],
|
||||
embed[type="application/x-shockwave-flash"],
|
||||
embed[src*=".swf"],
|
||||
object[type="application/x-shockwave-flash"],
|
||||
object[src*=".swf"]
|
||||
{ -moz-binding: url("chrome://flashblock/content/flashblock.xml#flash") !important; }
|
||||
|
||||
/*
|
||||
* Director identifiers.
|
||||
*/
|
||||
object[classid*=":166B1BCA-3F9C-11CF-8075-444553540000"],
|
||||
object[codebase*="sw.cab"],
|
||||
object[data*=".dcr"],
|
||||
embed[type="application/x-director"],
|
||||
embed[src*=".dcr"],
|
||||
object[type="application/x-director"],
|
||||
object[src*=".dcr"]
|
||||
{ -moz-binding: url("chrome://flashblock/content/flashblock.xml#director") !important; }
|
||||
|
||||
/*
|
||||
* Authorware identifiers.
|
||||
*/
|
||||
object[classid*=":15B782AF-55D8-11D1-B477-006097098764"],
|
||||
object[codebase*="awswaxf.cab"],
|
||||
object[data*=".aam"],
|
||||
embed[type="application/x-authorware-map"],
|
||||
embed[src*=".aam"],
|
||||
object[type="application/x-authorware-map"],
|
||||
object[src*=".aam"]
|
||||
{ -moz-binding: url("chrome://flashblock/content/flashblock.xml#authorware") !important; }
|
||||
|
||||
/*
|
||||
* Java identifiers.
|
||||
*/
|
||||
applet,
|
||||
object[classid*=":8AD9C840-044E-11D1-B3E9-00805F499D93"],
|
||||
object[classid^="clsid:CAFEEFAC-"],
|
||||
object[classid^="java:"],
|
||||
object[type="application/x-java-applet"],
|
||||
embed[classid*=":8AD9C840-044E-11D1-B3E9-00805F499D93"],
|
||||
embed[classid^="clsid:CAFEEFAC-"],
|
||||
embed[classid^="java:"],
|
||||
embed[type="application/x-java-applet"]
|
||||
{
|
||||
-moz-binding: none !important;
|
||||
}
|
||||
|
||||
/*
|
||||
* Silverlight identifiers.
|
||||
*/
|
||||
object[classid*="32C73088-76AE-40F7-AC40-81F62CB2C1DA"],
|
||||
object[type="application/ag-plugin"],
|
||||
object[source*=".xaml"],
|
||||
object[sourceelement*="xaml"],
|
||||
embed[type="application/ag-plugin"],
|
||||
embed[source*=".xaml"]
|
||||
{
|
||||
-moz-binding: none !important;
|
||||
}
|
||||
|
||||
/*
|
||||
* Broken Objects.
|
||||
*/
|
||||
object
|
||||
{ -moz-binding: url("chrome://flashblock/content/flashblock.xml#brokenobject") !important; }
|
||||
|
||||
/* sIFR styles */
|
||||
.sIFR-flash, .sIFR-flash object, .sIFR-flash embed,
|
||||
.sIFR-replaced div[style*="chrome://flashblock"] {
|
||||
-moz-binding: url("chrome://flashblock/content/flashblock.xml#sifr-replaced") !important;
|
||||
}
|
||||
|
||||
span.sIFR-alternate {
|
||||
-moz-binding: url("chrome://flashblock/content/flashblock.xml#sifr-alternate") !important;
|
||||
position: static !important;
|
||||
letter-spacing: normal !important;
|
||||
}
|
||||
/*
|
||||
* Flash Click to View by Ted Mielczarek (luser_mozilla@perilith.com)
|
||||
* Original code by Jesse Ruderman (jruderman@hmc.edu)
|
||||
* taken from http://www.squarefree.com/userstyles/xbl.html
|
||||
*
|
||||
* Change XBL binding for <object> tags, click to view flash
|
||||
*/
|
||||
|
||||
/*
|
||||
* Flash identifiers.
|
||||
*/
|
||||
object[classid*=":D27CDB6E-AE6D-11cf-96B8-444553540000"],
|
||||
object[codebase*="swflash.cab"],
|
||||
object[data*=".swf"],
|
||||
embed[type="application/x-shockwave-flash"],
|
||||
embed[src*=".swf"],
|
||||
object[type="application/x-shockwave-flash"],
|
||||
object[src*=".swf"]
|
||||
{ -moz-binding: url("chrome://flashblock/content/flashblock.xml#flash") !important; }
|
||||
|
||||
/*
|
||||
* Director identifiers.
|
||||
*/
|
||||
object[classid*=":166B1BCA-3F9C-11CF-8075-444553540000"],
|
||||
object[codebase*="sw.cab"],
|
||||
object[data*=".dcr"],
|
||||
embed[type="application/x-director"],
|
||||
embed[src*=".dcr"],
|
||||
object[type="application/x-director"],
|
||||
object[src*=".dcr"]
|
||||
{ -moz-binding: url("chrome://flashblock/content/flashblock.xml#director") !important; }
|
||||
|
||||
/*
|
||||
* Authorware identifiers.
|
||||
*/
|
||||
object[classid*=":15B782AF-55D8-11D1-B477-006097098764"],
|
||||
object[codebase*="awswaxf.cab"],
|
||||
object[data*=".aam"],
|
||||
embed[type="application/x-authorware-map"],
|
||||
embed[src*=".aam"],
|
||||
object[type="application/x-authorware-map"],
|
||||
object[src*=".aam"]
|
||||
{ -moz-binding: url("chrome://flashblock/content/flashblock.xml#authorware") !important; }
|
||||
|
||||
/*
|
||||
* Java identifiers.
|
||||
*/
|
||||
applet,
|
||||
object[classid*=":8AD9C840-044E-11D1-B3E9-00805F499D93"],
|
||||
object[classid^="clsid:CAFEEFAC-"],
|
||||
object[classid^="java:"],
|
||||
object[type="application/x-java-applet"],
|
||||
embed[classid*=":8AD9C840-044E-11D1-B3E9-00805F499D93"],
|
||||
embed[classid^="clsid:CAFEEFAC-"],
|
||||
embed[classid^="java:"],
|
||||
embed[type="application/x-java-applet"]
|
||||
{
|
||||
-moz-binding: none !important;
|
||||
}
|
||||
|
||||
/*
|
||||
* Silverlight identifiers.
|
||||
*/
|
||||
object[classid*="32C73088-76AE-40F7-AC40-81F62CB2C1DA"],
|
||||
object[type="application/ag-plugin"],
|
||||
object[type="application/x-silverlight"],
|
||||
object[source*=".xaml"],
|
||||
object[sourceelement*="xaml"],
|
||||
embed[type="application/ag-plugin"],
|
||||
embed[source*=".xaml"]
|
||||
{
|
||||
-moz-binding: none !important;
|
||||
}
|
||||
|
||||
/*
|
||||
* Broken Objects.
|
||||
*/
|
||||
object
|
||||
{ -moz-binding: url("chrome://flashblock/content/flashblock.xml#brokenobject") !important; }
|
||||
|
||||
/* sIFR styles */
|
||||
.sIFR-flash, .sIFR-flash object, .sIFR-flash embed,
|
||||
.sIFR-replaced div[style*="chrome://flashblock"] {
|
||||
-moz-binding: url("chrome://flashblock/content/flashblock.xml#sifr-replaced") !important;
|
||||
}
|
||||
|
||||
span.sIFR-alternate {
|
||||
-moz-binding: url("chrome://flashblock/content/flashblock.xml#sifr-alternate") !important;
|
||||
position: static !important;
|
||||
letter-spacing: normal !important;
|
||||
}
|
||||
|
|
|
@ -1,357 +1,362 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<bindings
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
>
|
||||
|
||||
<binding id="flash">
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
|
||||
//From Jesse's XPCNativeWrapper: http://mavra.perilith.com/~luser/content/native.js
|
||||
function nativeMethod(untrustedObject, methodName)
|
||||
{
|
||||
// happier stack traces and faster multiple calls
|
||||
var fun = Components.lookupMethod(untrustedObject, methodName);
|
||||
|
||||
return function()
|
||||
{
|
||||
return fun.apply(untrustedObject, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
function flashblockCreatePlaceholder(isStandalone) {
|
||||
// Create placeholder
|
||||
var flashblockCreateElement = nativeMethod(document, "createElement");
|
||||
var placeholder = flashblockCreateElement("div");
|
||||
placeholder.isStandalone = isStandalone;
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
// Substitute the animation with a placeholder
|
||||
function flashblockShowPlaceholder() {
|
||||
// Just in case the object has been moved away from under our feet during
|
||||
// the timeout, re-assign the parent node. See bug 13680
|
||||
// parent = current.parentNode;
|
||||
var newParent = current.parentNode;
|
||||
parent = newParent ? newParent : parent;
|
||||
parent.insertBefore(placeholder, current);
|
||||
if(placeholder.isStandalone) {
|
||||
placeholder.flashblock = "frame";
|
||||
if ("StopPlay" in current)
|
||||
current.StopPlay();
|
||||
if ("LoadMovie" in current)
|
||||
current.LoadMovie(0, "");
|
||||
current.prevWidth = current.width;
|
||||
current.prevHeight = current.height;
|
||||
current.width = current.height = 0;
|
||||
} else {
|
||||
placeholder.flashblock = "normal";
|
||||
parent.removeChild(current);
|
||||
}
|
||||
}
|
||||
|
||||
// Show the original animation
|
||||
function flashblockShowFlash() {
|
||||
if(placeholder.flashblock == "frame") {
|
||||
current.height = current.prevHeight;
|
||||
current.width = current.prevWidth;
|
||||
current.src = placeholder.title;
|
||||
if ("LoadMovie" in current)
|
||||
current.LoadMovie(0, current.src);
|
||||
} else {
|
||||
parent.insertBefore(current, placeholder);
|
||||
if (placeholder.hasAttribute("srcAttribute")) {
|
||||
current.setAttribute("src", placeholder.getAttribute("srcAttribute"));
|
||||
}
|
||||
if (placeholder.hasAttribute("movieAttribute")) {
|
||||
current.setAttribute("movie", placeholder.getAttribute("movieAttribute"));
|
||||
}
|
||||
if (placeholder.hasAttribute("dataAttribute")) {
|
||||
current.setAttribute("data", placeholder.getAttribute("dataAttribute"));
|
||||
}
|
||||
if (placeholder.movieParam) {
|
||||
var mparam = placeholder.movieParam;
|
||||
mparam[0].value = mparam[1];
|
||||
}
|
||||
if (placeholder.hasAttribute("embedsrc")) {
|
||||
var embeds = current.getElementsByTagName("embed");
|
||||
if (embeds && embeds.length > 0) {
|
||||
embeds[0].setAttribute("src", placeholder.getAttribute("embedsrc"));
|
||||
}
|
||||
}
|
||||
}
|
||||
parent.removeChild(placeholder);
|
||||
}
|
||||
|
||||
function flashblockIsWhitelisted() {
|
||||
// Check if the page that loaded the Flash site is whitelisted
|
||||
// Thanks to Neil on #mozilla for suggesting this method, I would never have
|
||||
// thought of it on my own. :-)
|
||||
// Lor 20041215: Use "UIEvents" to make it work in post-1.0 FF
|
||||
// (thanks to Neil again)
|
||||
var flashblockEvent = document.createEvent("UIEvents");
|
||||
|
||||
if(flashblockEvent) {
|
||||
flashblockEvent.initEvent("flashblockCheckLoad", true, true);
|
||||
document.dispatchEvent(flashblockEvent);
|
||||
if(flashblockEvent.getPreventDefault() == true) {
|
||||
// Whitelisted
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function flashblockSetImage(placeholder, type) {
|
||||
var inactiveurl = "chrome://flashblock/content/" + type + ".png";
|
||||
var activeurl = "chrome://flashblock/content/flashplay.png";
|
||||
placeholder.bgInactive = "url(" + inactiveurl + ") no-repeat center";
|
||||
placeholder.bgActive = "url(" + activeurl + ") no-repeat center";
|
||||
placeholder.style.background = placeholder.bgInactive;
|
||||
}
|
||||
|
||||
function flashblockStylePlaceholder(flash, placeholder, isStandalone) {
|
||||
// If object's size was relative, use that.
|
||||
// Otherwise, set size to minimum 32x32 px
|
||||
placeholder.style.minWidth = "32px !important";
|
||||
placeholder.style.minHeight = "32px !important";
|
||||
// The size and positioning may come from a class
|
||||
// or from the id for id-specific CSS styles
|
||||
var fId = flash.getAttribute("id");
|
||||
if (fId)
|
||||
placeholder.setAttribute("id", fId);
|
||||
var fClass = flash.getAttribute("class");
|
||||
if (fClass)
|
||||
placeholder.setAttribute("class", fClass);
|
||||
|
||||
if(flash.width.match("%$")) {
|
||||
placeholder.style.width = current.width;
|
||||
} else {
|
||||
var width = parseInt(flash.width || flash.style.width);
|
||||
if (width) {
|
||||
if (width >= 32) {
|
||||
placeholder.style.width = width + "px";
|
||||
}
|
||||
else {
|
||||
placeholder.style.width = "32px";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(flash.height.match("%$")) {
|
||||
placeholder.style.height = flash.height;
|
||||
} else {
|
||||
var height = parseInt(flash.height || flash.style.height);
|
||||
if (height) {
|
||||
if (height >= 32) {
|
||||
placeholder.style.height = height + "px";
|
||||
}
|
||||
else {
|
||||
placeholder.style.height = "32px";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add styling rules to placeholder div.
|
||||
placeholder.style.background = placeholder.bgInactive;
|
||||
placeholder.style.border = "1px solid #dfdfdf";
|
||||
placeholder.style.cursor = "pointer";
|
||||
placeholder.style.overflow = "hidden";
|
||||
|
||||
// The size of the placeholder should include borders too,
|
||||
// otherwise scrollbars appear for blocked standalone objects
|
||||
placeholder.style.MozBoxSizing = "border-box";
|
||||
|
||||
// Make some style adjustments since the placeholder is a <div> // element instead of a <embed>, <object>, ... element. // An <embed> will be centered if the parent has // 'text-align: center' but a <div> will not. This code fixes that. var parentStyle = window.getComputedStyle(flash.parentNode, ""); if (parentStyle.getPropertyValue("text-align") == "center") { placeholder.style.marginRight = "auto"; placeholder.style.marginLeft = "auto"; }
|
||||
}
|
||||
|
||||
function flashblockSetTitle(current, placeholder, isStandalone) {
|
||||
// non-null "about:blank" value to prevent OS/2 crashing
|
||||
var fakeURI = "about:blank";
|
||||
if (isStandalone) {
|
||||
placeholder.title = current.src;
|
||||
current.src = fakeURI;
|
||||
}
|
||||
else if (current.hasAttribute("src") ||
|
||||
current.hasAttribute("data") ||
|
||||
current.hasAttribute("movie") ) {
|
||||
var srcURI = current.getAttribute("src") ||
|
||||
current.getAttribute("movie") ||
|
||||
current.getAttribute("data") ;
|
||||
placeholder.title = srcURI;
|
||||
if (current.hasAttribute("src")) {
|
||||
placeholder.setAttribute("srcAttribute", current.getAttribute("src"));
|
||||
current.setAttribute("src", fakeURI);
|
||||
}
|
||||
if (current.hasAttribute("data")) {
|
||||
placeholder.setAttribute("dataAttribute", current.getAttribute("data"));
|
||||
current.setAttribute("data", fakeURI);
|
||||
}
|
||||
if (current.hasAttribute("movie")) {
|
||||
placeholder.setAttribute("movieAttribute", current.getAttribute("movie"));
|
||||
current.setAttribute("movie", fakeURI);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var params = current.getElementsByTagName("param");
|
||||
for (var ii = 0; ii < params.length; ii++) {
|
||||
if (params[ii].getAttribute("name") == "movie" &&
|
||||
params[ii].hasAttribute("value")) {
|
||||
placeholder.title = params[ii].value;
|
||||
placeholder.movieParam = [ params[ii], placeholder.title ];
|
||||
params[ii].value = fakeURI;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var embeds = current.getElementsByTagName("embed");
|
||||
if (embeds && embeds.length > 0 && embeds[0].hasAttribute("src")) {
|
||||
placeholder.title = embeds[0].getAttribute("src");
|
||||
placeholder.setAttribute("embedsrc", embeds[0].getAttribute("src"));
|
||||
embeds[0].setAttribute("src",fakeURI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(flashblockIsWhitelisted())
|
||||
return;
|
||||
|
||||
var current = this;
|
||||
var parent = current.parentNode;
|
||||
|
||||
// Check parent too (case of working EMBED inside broken OBJECT)
|
||||
if (current.overrideCTV || parentNode.overrideCTV) {
|
||||
return;
|
||||
}
|
||||
current.overrideCTV = true;
|
||||
|
||||
if (this.brokenObject) {
|
||||
var params = this.getElementsByTagName("param");
|
||||
var isFlash = false;
|
||||
for (var ii = 0; ii < params.length; ii++) {
|
||||
var pvalue = params[ii].getAttribute("value");
|
||||
if (/\.swf/i.test(pvalue)) {
|
||||
isFlash = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var embeds = this.getElementsByTagName("embed");
|
||||
for (var jj = 0; jj < embeds.length; jj++) {
|
||||
var embed = embeds[jj];
|
||||
if (/x-shockwave-flash/i.test(embed.getAttribute("type")) ||
|
||||
/\.swf/i.test(embed.getAttribute("src"))) {
|
||||
isFlash = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isFlash) {return;}
|
||||
}
|
||||
|
||||
// Create placeholder div
|
||||
var isStandalone = ("src" in current && current.src == current.ownerDocument.location);
|
||||
var placeholder = flashblockCreatePlaceholder(isStandalone);
|
||||
|
||||
// Set placeholder image
|
||||
var type = this.flashblockType ? this.flashblockType : "flash"
|
||||
flashblockSetImage(placeholder, type);
|
||||
|
||||
flashblockStylePlaceholder(current, placeholder, isStandalone);
|
||||
|
||||
flashblockSetTitle(current, placeholder, isStandalone);
|
||||
|
||||
// Change the placeholder background when the mouse enters/exits the div.
|
||||
placeholder.onmouseover = function()
|
||||
{
|
||||
this.style.background = this.bgActive;
|
||||
}
|
||||
|
||||
placeholder.onmouseout = function()
|
||||
{
|
||||
this.style.background = this.bgInactive;
|
||||
}
|
||||
|
||||
// Replace the flash document with a placeholder.
|
||||
var flashblockSetTimeout = nativeMethod(window, "setTimeout");
|
||||
flashblockSetTimeout(flashblockShowPlaceholder, 0);
|
||||
|
||||
// Replace the placeholder with the flash document.
|
||||
placeholder.onclick = flashblockShowFlash;
|
||||
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="director" extends="#flash">
|
||||
<implementation>
|
||||
<field name="flashblockType">"director"</field>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="authorware" extends="#flash">
|
||||
<implementation>
|
||||
<field name="flashblockType">"authorware"</field>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="brokenobject" extends="#flash">
|
||||
<implementation>
|
||||
<field name="brokenObject">"yes"</field>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="sifr-replaced">
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
event = document.createEvent("UIEvents");
|
||||
|
||||
if(event) {
|
||||
event.initEvent("flashblockCheckLoad", true, true);
|
||||
document.dispatchEvent(event);
|
||||
if(event.getPreventDefault() == true) {
|
||||
// Whitelisted
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.style.height = 0;
|
||||
this.style.width = 0;
|
||||
this.style.display = "none !important";
|
||||
this.style.position ="absolute";
|
||||
this.style.overflow ="hidden";
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="sifr-alternate">
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
var event = document.createEvent("UIEvents");
|
||||
|
||||
if(event) {
|
||||
event.initEvent("flashblockCheckLoad", true, true);
|
||||
document.dispatchEvent(event);
|
||||
if(event.getPreventDefault() == true) {
|
||||
// Whitelisted
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.style.visibility = "visible !important";
|
||||
this.style.display = "block !important";
|
||||
//this.style.position = "static !important";
|
||||
this.style.left = "auto !important";
|
||||
this.style.top = "auto !important";
|
||||
this.style.height = "auto !important";
|
||||
this.style.width = "auto !important";
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
</bindings>
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<bindings
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
>
|
||||
|
||||
<binding id="flash">
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
|
||||
//From Jesse's XPCNativeWrapper: http://mavra.perilith.com/~luser/content/native.js
|
||||
function nativeMethod(untrustedObject, methodName)
|
||||
{
|
||||
// happier stack traces and faster multiple calls
|
||||
var fun = Components.lookupMethod(untrustedObject, methodName);
|
||||
|
||||
return function()
|
||||
{
|
||||
return fun.apply(untrustedObject, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
function flashblockCreatePlaceholder(isStandalone) {
|
||||
// Create placeholder
|
||||
var flashblockCreateElement = nativeMethod(document, "createElement");
|
||||
var placeholder = flashblockCreateElement("div");
|
||||
placeholder.isStandalone = isStandalone;
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
// Substitute the animation with a placeholder
|
||||
function flashblockShowPlaceholder() {
|
||||
// Just in case the object has been moved away from under our feet during
|
||||
// the timeout, re-assign the parent node. See bug 13680
|
||||
// parent = current.parentNode;
|
||||
var newParent = current.parentNode;
|
||||
parent = newParent ? newParent : parent;
|
||||
parent.insertBefore(placeholder, current);
|
||||
if(placeholder.isStandalone) {
|
||||
placeholder.flashblock = "frame";
|
||||
if ("StopPlay" in current)
|
||||
current.StopPlay();
|
||||
if ("LoadMovie" in current)
|
||||
current.LoadMovie(0, "");
|
||||
current.prevWidth = current.width;
|
||||
current.prevHeight = current.height;
|
||||
current.width = current.height = 0;
|
||||
} else {
|
||||
placeholder.flashblock = "normal";
|
||||
parent.removeChild(current);
|
||||
}
|
||||
}
|
||||
|
||||
// Show the original animation
|
||||
function flashblockShowFlash() {
|
||||
if(placeholder.flashblock == "frame") {
|
||||
current.height = current.prevHeight;
|
||||
current.width = current.prevWidth;
|
||||
current.src = placeholder.title;
|
||||
if ("LoadMovie" in current)
|
||||
current.LoadMovie(0, current.src);
|
||||
} else {
|
||||
parent.insertBefore(current, placeholder);
|
||||
if (placeholder.hasAttribute("srcAttribute")) {
|
||||
current.setAttribute("src", placeholder.getAttribute("srcAttribute"));
|
||||
}
|
||||
if (placeholder.hasAttribute("movieAttribute")) {
|
||||
current.setAttribute("movie", placeholder.getAttribute("movieAttribute"));
|
||||
}
|
||||
if (placeholder.hasAttribute("dataAttribute")) {
|
||||
current.setAttribute("data", placeholder.getAttribute("dataAttribute"));
|
||||
}
|
||||
if (placeholder.movieParam) {
|
||||
var mparam = placeholder.movieParam;
|
||||
mparam[0].value = mparam[1];
|
||||
}
|
||||
if (placeholder.hasAttribute("embedsrc")) {
|
||||
var embeds = current.getElementsByTagName("embed");
|
||||
if (embeds && embeds.length > 0) {
|
||||
embeds[0].setAttribute("src", placeholder.getAttribute("embedsrc"));
|
||||
}
|
||||
}
|
||||
}
|
||||
parent.removeChild(placeholder);
|
||||
}
|
||||
|
||||
function flashblockIsWhitelisted() {
|
||||
// Check if the page that loaded the Flash site is whitelisted
|
||||
// Thanks to Neil on #mozilla for suggesting this method, I would never have
|
||||
// thought of it on my own. :-)
|
||||
// Lor 20041215: Use "UIEvents" to make it work in post-1.0 FF
|
||||
// (thanks to Neil again)
|
||||
var flashblockEvent = document.createEvent("UIEvents");
|
||||
|
||||
if(flashblockEvent) {
|
||||
flashblockEvent.initEvent("flashblockCheckLoad", true, true);
|
||||
document.dispatchEvent(flashblockEvent);
|
||||
if(flashblockEvent.getPreventDefault() == true) {
|
||||
// Whitelisted
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function flashblockSetImage(placeholder, type) {
|
||||
var inactiveurl = "chrome://flashblock/content/" + type + ".png";
|
||||
var activeurl = "chrome://flashblock/content/flashplay.png";
|
||||
placeholder.bgInactive = "url(" + inactiveurl + ") no-repeat center";
|
||||
placeholder.bgActive = "url(" + activeurl + ") no-repeat center";
|
||||
placeholder.style.background = placeholder.bgInactive;
|
||||
}
|
||||
|
||||
function flashblockStylePlaceholder(flash, placeholder, isStandalone) {
|
||||
// If object's size was relative, use that.
|
||||
// Otherwise, set size to minimum 32x32 px
|
||||
placeholder.style.setProperty("min-width", "32px", "important");
|
||||
placeholder.style.setProperty("min-height", "32px", "important");
|
||||
// The size and positioning may come from a class
|
||||
var fClass = flash.getAttribute("class");
|
||||
if (fClass)
|
||||
placeholder.setAttribute("class", fClass);
|
||||
|
||||
if(flash.width.match("%$")) {
|
||||
placeholder.style.width = current.width;
|
||||
} else {
|
||||
var width = parseInt(flash.width || flash.style.width);
|
||||
if (width) {
|
||||
if (width >= 32) {
|
||||
placeholder.style.width = width + "px";
|
||||
}
|
||||
else {
|
||||
placeholder.style.width = "32px";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(flash.height.match("%$")) {
|
||||
placeholder.style.height = flash.height;
|
||||
} else {
|
||||
var height = parseInt(flash.height || flash.style.height);
|
||||
if (height) {
|
||||
if (height >= 32) {
|
||||
placeholder.style.height = height + "px";
|
||||
}
|
||||
else {
|
||||
placeholder.style.height = "32px";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add styling rules to placeholder div.
|
||||
placeholder.style.background = placeholder.bgInactive;
|
||||
placeholder.style.border = "1px solid #dfdfdf";
|
||||
placeholder.style.cursor = "pointer";
|
||||
placeholder.style.overflow = "hidden";
|
||||
placeholder.style.display = "inline-block";
|
||||
|
||||
// The size of the placeholder should include borders too,
|
||||
// otherwise scrollbars appear for blocked standalone objects
|
||||
placeholder.style.MozBoxSizing = "border-box";
|
||||
|
||||
// Make some style adjustments since the placeholder is a <div>
|
||||
// element instead of a <embed>, <object>, ... element.
|
||||
// An <embed> will be centered if the parent has
|
||||
// 'text-align: center' but a <div> will not. This code fixes that.
|
||||
var parentStyle = window.getComputedStyle(flash.parentNode, "");
|
||||
if (parentStyle.getPropertyValue("text-align") == "center") {
|
||||
placeholder.style.marginRight = "auto";
|
||||
placeholder.style.marginLeft = "auto";
|
||||
}
|
||||
}
|
||||
|
||||
function flashblockSetTitle(current, placeholder, isStandalone) {
|
||||
// non-null "about:blank" value to prevent OS/2 crashing
|
||||
var fakeURI = "about:blank";
|
||||
if (isStandalone) {
|
||||
placeholder.title = current.src;
|
||||
current.src = fakeURI;
|
||||
}
|
||||
else if (current.hasAttribute("src") ||
|
||||
current.hasAttribute("data") ||
|
||||
current.hasAttribute("movie") ) {
|
||||
var srcURI = current.getAttribute("src") ||
|
||||
current.getAttribute("movie") ||
|
||||
current.getAttribute("data") ;
|
||||
placeholder.title = srcURI;
|
||||
if (current.hasAttribute("src")) {
|
||||
placeholder.setAttribute("srcAttribute", current.getAttribute("src"));
|
||||
current.setAttribute("src", fakeURI);
|
||||
}
|
||||
if (current.hasAttribute("data")) {
|
||||
placeholder.setAttribute("dataAttribute", current.getAttribute("data"));
|
||||
current.setAttribute("data", fakeURI);
|
||||
}
|
||||
if (current.hasAttribute("movie")) {
|
||||
placeholder.setAttribute("movieAttribute", current.getAttribute("movie"));
|
||||
current.setAttribute("movie", fakeURI);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var params = current.getElementsByTagName("param");
|
||||
for (var ii = 0; ii < params.length; ii++) {
|
||||
if (params[ii].getAttribute("name") == "movie" &&
|
||||
params[ii].hasAttribute("value")) {
|
||||
placeholder.title = params[ii].value;
|
||||
placeholder.movieParam = [ params[ii], placeholder.title ];
|
||||
params[ii].value = fakeURI;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var embeds = current.getElementsByTagName("embed");
|
||||
if (embeds && embeds.length > 0 && embeds[0].hasAttribute("src")) {
|
||||
placeholder.title = embeds[0].getAttribute("src");
|
||||
placeholder.setAttribute("embedsrc", embeds[0].getAttribute("src"));
|
||||
embeds[0].setAttribute("src",fakeURI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(flashblockIsWhitelisted())
|
||||
return;
|
||||
|
||||
var current = this;
|
||||
var parent = current.parentNode;
|
||||
|
||||
// Check parent too (case of working EMBED inside broken OBJECT)
|
||||
if (current.overrideCTV || parentNode.overrideCTV) {
|
||||
return;
|
||||
}
|
||||
current.overrideCTV = true;
|
||||
|
||||
if (this.brokenObject) {
|
||||
var params = this.getElementsByTagName("param");
|
||||
var isFlash = false;
|
||||
for (var ii = 0; ii < params.length; ii++) {
|
||||
var pvalue = params[ii].getAttribute("value");
|
||||
if (/\.swf/i.test(pvalue)) {
|
||||
isFlash = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var embeds = this.getElementsByTagName("embed");
|
||||
for (var jj = 0; jj < embeds.length; jj++) {
|
||||
var embed = embeds[jj];
|
||||
if (/x-shockwave-flash/i.test(embed.getAttribute("type")) ||
|
||||
/\.swf/i.test(embed.getAttribute("src"))) {
|
||||
isFlash = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isFlash) {return;}
|
||||
}
|
||||
|
||||
// Create placeholder div
|
||||
var isStandalone = ("src" in current && current.src == current.ownerDocument.location);
|
||||
var placeholder = flashblockCreatePlaceholder(isStandalone);
|
||||
|
||||
// Set placeholder image
|
||||
var type = this.flashblockType ? this.flashblockType : "flash"
|
||||
flashblockSetImage(placeholder, type);
|
||||
|
||||
flashblockStylePlaceholder(current, placeholder, isStandalone);
|
||||
|
||||
flashblockSetTitle(current, placeholder, isStandalone);
|
||||
|
||||
// Change the placeholder background when the mouse enters/exits the div.
|
||||
placeholder.onmouseover = function()
|
||||
{
|
||||
this.style.background = this.bgActive;
|
||||
}
|
||||
|
||||
placeholder.onmouseout = function()
|
||||
{
|
||||
this.style.background = this.bgInactive;
|
||||
}
|
||||
|
||||
// Replace the flash document with a placeholder.
|
||||
var flashblockSetTimeout = nativeMethod(window, "setTimeout");
|
||||
flashblockSetTimeout(flashblockShowPlaceholder, 0);
|
||||
|
||||
// Replace the placeholder with the flash document.
|
||||
placeholder.onclick = flashblockShowFlash;
|
||||
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="director" extends="#flash">
|
||||
<implementation>
|
||||
<field name="flashblockType">"director"</field>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="authorware" extends="#flash">
|
||||
<implementation>
|
||||
<field name="flashblockType">"authorware"</field>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="brokenobject" extends="#flash">
|
||||
<implementation>
|
||||
<field name="brokenObject">"yes"</field>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="sifr-replaced">
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
event = document.createEvent("UIEvents");
|
||||
|
||||
if(event) {
|
||||
event.initEvent("flashblockCheckLoad", true, true);
|
||||
document.dispatchEvent(event);
|
||||
if(event.getPreventDefault() == true) {
|
||||
// Whitelisted
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.style.height = 0;
|
||||
this.style.width = 0;
|
||||
this.style.setProperty("display", "none", "important");
|
||||
this.style.position ="absolute";
|
||||
this.style.overflow ="hidden";
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="sifr-alternate">
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
var event = document.createEvent("UIEvents");
|
||||
|
||||
if(event) {
|
||||
event.initEvent("flashblockCheckLoad", true, true);
|
||||
document.dispatchEvent(event);
|
||||
if(event.getPreventDefault() == true) {
|
||||
// Whitelisted
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.style.setProperty("visibility", "visible", "important");
|
||||
this.style.setProperty("display", "block", "important");
|
||||
this.style.setProperty("left", "auto", "important");
|
||||
this.style.setProperty("top", "auto", "important");
|
||||
this.style.setProperty("height", "auto", "important");
|
||||
this.style.setProperty("width", "auto", "important");
|
||||
//this.style.position = "static";
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
</bindings>
|
||||
|
|
Загрузка…
Ссылка в новой задаче