mirror of https://github.com/roytam1/kmeleon.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
774 lines
25 KiB
774 lines
25 KiB
<?xml version="1.0"?> |
|
|
|
<bindings |
|
xmlns="http://www.mozilla.org/xbl" |
|
xmlns:html="http://www.w3.org/1999/xhtml" |
|
> |
|
|
|
<binding id="flash" |
|
bindToUntrustedContent="true"> |
|
<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; |
|
var placeholder; |
|
try { |
|
flashblockCreateElement = nativeMethod(document, "createElementNS"); |
|
placeholder = flashblockCreateElement("http://www.w3.org/1999/xhtml", "div"); |
|
} catch (e) { |
|
placeholder = document.createElementNS( "http://www.w3.org/1999/xhtml", "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; |
|
|
|
// Fix for Flashblock Bug 22168 (Node was not found" code: "8"). |
|
// if the LSB is 1, it means the nodes are unrelated (e.g. different window). |
|
if (current.compareDocumentPosition(parent)&1) |
|
return; |
|
|
|
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(event) { |
|
if( event.type == "keypress" && event.keyCode != KeyEvent.DOM_VK_RETURN) |
|
return false; |
|
event.stopPropagation(); |
|
var parent = placeholder.parentNode; |
|
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.srcParam) { |
|
var mparam = placeholder.srcParam; |
|
mparam[0].value = mparam[1]; |
|
} |
|
if (placeholder.sourceParam) { |
|
var mparam = placeholder.sourceParam; |
|
mparam[0].value = mparam[1]; |
|
} |
|
} |
|
parent.removeChild(placeholder); |
|
} |
|
|
|
function flashblockIsWhitelisted(node, type) { |
|
// 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) |
|
// bz says QI is a no-op. |
|
document.QueryInterface(Components.interfaces.nsIDOMDocument); |
|
var flashblockEvent = document.createEvent("UIEvents"); |
|
if(flashblockEvent) { |
|
var evt = type == "silverlight" ? "silverblockCheckLoad" : "flashblockCheckLoad"; |
|
flashblockEvent.initEvent(evt, true, true); |
|
node.dispatchEvent(flashblockEvent); |
|
if(flashblockEvent.defaultPrevented || node.hasAttribute("data-flashblockWhitelisted")) { |
|
// Whitelisted |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
function flashblockSetImage(placeholder, type) { |
|
var inactiveurl = "url(chrome://flashblock/content/" + type + ".png) no-repeat center"; |
|
var playimage = "url(chrome://flashblock/content/flashplay.png)"; |
|
switch (type) { |
|
case "silverlight": |
|
playimage = "url(chrome://flashblock/content/silverplay.png)"; |
|
break; |
|
default: |
|
break; |
|
} |
|
var activeurl = playimage + " no-repeat center"; |
|
placeholder.setAttribute("bgInactive", inactiveurl); |
|
placeholder.setAttribute("bgActive", activeurl); |
|
placeholder.style.setProperty("background", inactiveurl, "important"); |
|
} |
|
|
|
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); |
|
|
|
var fStyle = window.getComputedStyle(flash, ""); |
|
|
|
var fWidth = fStyle.getPropertyValue("width"); |
|
var width = parseInt(flash.width || flash.style.width); |
|
if (fWidth && parseInt(fWidth) > 32) |
|
width = fWidth; |
|
else if(flash.width.match("%$")) |
|
width = flash.width; |
|
else if (width) |
|
width = Math.max(width,32) + "px"; |
|
else |
|
width = "32px" |
|
placeholder.style.width = width; |
|
|
|
var fHeight = fStyle.getPropertyValue("height"); |
|
var height = parseInt(flash.height || flash.style.height); |
|
if (fHeight && parseInt(fHeight) > 32) |
|
height = fHeight; |
|
else if(flash.height.match("%$")) |
|
height = flash.height; |
|
else if (height) |
|
height = Math.max(height,32) + "px"; |
|
else |
|
height = "32px" |
|
placeholder.style.height = height; |
|
|
|
// Add styling rules to placeholder div. |
|
placeholder.style.border = "1px solid #dfdfdf"; |
|
placeholder.style.cursor = "pointer"; |
|
placeholder.style.overflow = "hidden"; |
|
var disp = fStyle.getPropertyValue("display"); |
|
placeholder.style.display = disp == "block" ? "block" : "inline-block"; |
|
placeholder.style.setProperty("visibility", "visible", "important"); |
|
placeholder.style.setProperty("opacity", "100", "important"); |
|
|
|
// 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") && !/application\/x-silverlight/.test(current.getAttribute("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; |
|
} |
|
if (params[ii].getAttribute("name") == "src" && |
|
params[ii].hasAttribute("value")) { |
|
placeholder.title = params[ii].value; |
|
placeholder.srcParam = [ params[ii], placeholder.title ]; |
|
params[ii].value = fakeURI; |
|
break; |
|
} |
|
if (params[ii].getAttribute("name") == "source" && |
|
params[ii].hasAttribute("value")) { |
|
placeholder.title = params[ii].value; |
|
placeholder.sourceParam = [ params[ii], placeholder.title ]; |
|
params[ii].value = fakeURI; |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
|
|
var type = this.flashblockType ? this.flashblockType : "flash" |
|
if (/silverlight|ag-plugin/i.test(this.getAttribute("type")) || |
|
/32C73088-76AE-40F7-AC40-81F62CB2C1DA/i.test(this.getAttribute("classid")) ) { |
|
type = "silverlight"; |
|
} |
|
|
|
if(flashblockIsWhitelisted(this, type)) |
|
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; |
|
|
|
// Flowplayer specific workaround. |
|
var flow = parent.getAttribute("href"); |
|
if (flow) { |
|
var prevDef = function (event) { |
|
event.preventDefault(); |
|
event.currentTarget.removeEventListener("load", arguments.callee, true); |
|
} |
|
parent.addEventListener("click", prevDef , true) |
|
} |
|
|
|
// Create placeholder div |
|
var isStandalone = ("src" in current && current.src == current.ownerDocument.location); |
|
var placeholder = flashblockCreatePlaceholder(isStandalone); |
|
|
|
// Set placeholder image |
|
flashblockSetImage(placeholder, type); |
|
|
|
flashblockStylePlaceholder(current, placeholder, isStandalone); |
|
|
|
flashblockSetTitle(current, placeholder, isStandalone); |
|
|
|
// Replace the flash document with a placeholder. |
|
try { |
|
var flashblockSetTimeout = nativeMethod(window, "setTimeout"); |
|
flashblockSetTimeout(flashblockShowPlaceholder, 0); |
|
} |
|
catch (e) { |
|
window.setTimeout(flashblockShowPlaceholder, 0); |
|
} |
|
|
|
// Change the placeholder background when the mouse enters/exits the div. |
|
placeholder.addEventListener("mouseover", |
|
function(event) {event.target.style.setProperty("background", |
|
event.target.getAttribute("bgActive"), |
|
"important"); }, |
|
"false" |
|
); |
|
placeholder.addEventListener("mouseout", |
|
function(event) {event.target.style.setProperty("background", |
|
event.target.getAttribute("bgInactive"), |
|
"important"); }, |
|
"false" |
|
); |
|
|
|
// Replace the placeholder with the flash document. |
|
placeholder.addEventListener("click", flashblockShowFlash, "false"); |
|
|
|
// Accessibility |
|
placeholder.setAttribute("tabindex", "0"); |
|
placeholder.setAttribute("role", "button"); |
|
placeholder.addEventListener("keypress", flashblockShowFlash, "false"); |
|
|
|
]]> |
|
</constructor> |
|
</implementation> |
|
</binding> |
|
|
|
<binding id="director" extends="#flash" |
|
bindToUntrustedContent="true"> |
|
<implementation> |
|
<field name="flashblockType">"director"</field> |
|
</implementation> |
|
</binding> |
|
|
|
<binding id="authorware" extends="#flash" |
|
bindToUntrustedContent="true"> |
|
<implementation> |
|
<field name="flashblockType">"authorware"</field> |
|
</implementation> |
|
</binding> |
|
|
|
<binding id="silverlight" extends="#flash" |
|
bindToUntrustedContent="true"> |
|
<implementation> |
|
<field name="flashblockType">"silverlight"</field> |
|
</implementation> |
|
</binding> |
|
|
|
<binding id="brokenobject" |
|
bindToUntrustedContent="true"> |
|
<implementation> |
|
|
|
<field name="brokenObject">"yes"</field> |
|
|
|
<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; |
|
var placeholder; |
|
try { |
|
flashblockCreateElement = nativeMethod(document, "createElementNS"); |
|
placeholder = flashblockCreateElement("http://www.w3.org/1999/xhtml", "div"); |
|
} catch (e) { |
|
placeholder = document.createElementNS( "http://www.w3.org/1999/xhtml", "div"); |
|
} |
|
placeholder.isStandalone = isStandalone; |
|
return placeholder; |
|
} |
|
|
|
// Substitute the animation with a placeholder |
|
function flashblockShowPlaceholder(placeholder, current, parent) { |
|
// 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; |
|
|
|
// Fix for Flashblock Bug 22168 (Node was not found" code: "8"). |
|
// if the LSB is 1, it means the nodes are unrelated (e.g. different window). |
|
if (current.compareDocumentPosition(parent)&1) |
|
return; |
|
|
|
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(event) { |
|
if( event.type == "keypress" && event.keyCode != KeyEvent.DOM_VK_RETURN) |
|
return false; |
|
event.stopPropagation(); |
|
var parent = placeholder.parentNode; |
|
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.srcParam) { |
|
var mparam = placeholder.srcParam; |
|
mparam[0].value = mparam[1]; |
|
} |
|
if (placeholder.sourceParam) { |
|
var mparam = placeholder.sourceParam; |
|
mparam[0].value = mparam[1]; |
|
} |
|
} |
|
parent.removeChild(placeholder); |
|
} |
|
|
|
function flashblockIsWhitelisted(node, type) { |
|
// 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) |
|
// bz says QI is a no-op. |
|
document.QueryInterface(Components.interfaces.nsIDOMDocument); |
|
var flashblockEvent = document.createEvent("UIEvents"); |
|
if(flashblockEvent) { |
|
var evt = type == "silverlight" ? "silverblockCheckLoad" : "flashblockCheckLoad"; |
|
flashblockEvent.initEvent(evt, true, true); |
|
node.dispatchEvent(flashblockEvent); |
|
node.ownerDocument.defaultView.console.log(node.ownerDocument.URL + " ==> " + flashblockEvent.defaultPrevented); |
|
if(flashblockEvent.defaultPrevented || node.hasAttribute("data-flashblockWhitelisted")) { |
|
// Whitelisted |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
function flashblockSetImage(placeholder, type) { |
|
var inactiveurl = "url(chrome://flashblock/content/" + type + ".png) no-repeat center"; |
|
var playimage = "url(chrome://flashblock/content/flashplay.png)"; |
|
switch (type) { |
|
case "silverlight": |
|
playimage = "url(chrome://flashblock/content/silverplay.png)"; |
|
break; |
|
default: |
|
break; |
|
} |
|
var activeurl = playimage + " no-repeat center"; |
|
placeholder.setAttribute("bgInactive", inactiveurl); |
|
placeholder.setAttribute("bgActive", activeurl); |
|
placeholder.style.setProperty("background", inactiveurl, "important"); |
|
} |
|
|
|
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); |
|
|
|
var fStyle = window.getComputedStyle(flash, ""); |
|
|
|
var fWidth = fStyle.getPropertyValue("width"); |
|
var width = parseInt(flash.width || flash.style.width); |
|
if (fWidth && parseInt(fWidth) > 32) |
|
width = fWidth; |
|
else if(flash.width.match("%$")) |
|
width = flash.width; |
|
else if (width) |
|
width = Math.max(width,32) + "px"; |
|
else |
|
width = "32px" |
|
placeholder.style.width = width; |
|
|
|
var fHeight = fStyle.getPropertyValue("height"); |
|
var height = parseInt(flash.height || flash.style.height); |
|
if (fHeight && parseInt(fHeight) > 32) |
|
height = fHeight; |
|
else if(flash.height.match("%$")) |
|
height = flash.height; |
|
else if (height) |
|
height = Math.max(height,32) + "px"; |
|
else |
|
height = "32px" |
|
placeholder.style.height = height; |
|
|
|
// Add styling rules to placeholder div. |
|
placeholder.style.border = "1px solid #dfdfdf"; |
|
placeholder.style.cursor = "pointer"; |
|
placeholder.style.overflow = "hidden"; |
|
var disp = fStyle.getPropertyValue("display"); |
|
placeholder.style.display = disp == "block" ? "block" : "inline-block"; |
|
placeholder.style.setProperty("visibility", "visible", "important"); |
|
placeholder.style.setProperty("opacity", "100", "important"); |
|
|
|
// 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") && !/application\/x-silverlight/.test(current.getAttribute("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; |
|
} |
|
if (params[ii].getAttribute("name") == "src" && |
|
params[ii].hasAttribute("value")) { |
|
placeholder.title = params[ii].value; |
|
placeholder.srcParam = [ params[ii], placeholder.title ]; |
|
params[ii].value = fakeURI; |
|
break; |
|
} |
|
if (params[ii].getAttribute("name") == "source" && |
|
params[ii].hasAttribute("value")) { |
|
placeholder.title = params[ii].value; |
|
placeholder.sourceParam = [ params[ii], placeholder.title ]; |
|
params[ii].value = fakeURI; |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
|
|
function isBrokenFlash(element) { |
|
var params = element.getElementsByTagName("param"); |
|
var isFlash = false; |
|
for (var ii = 0; ii < params.length; ii++) { |
|
var pvalue = params[ii].getAttribute("value"); |
|
if (/\.swf/i.test(pvalue)) |
|
return true; |
|
var pname = params[ii].getAttribute("name"); |
|
if (/movie/i.test(pname)) |
|
return true; |
|
} |
|
var embeds = element.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"))) { |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
var type = this.flashblockType ? this.flashblockType : "flash" |
|
if (/silverlight|ag-plugin/i.test(this.getAttribute("type")) || |
|
/32C73088-76AE-40F7-AC40-81F62CB2C1DA/i.test(this.getAttribute("classid")) ) { |
|
type = "silverlight"; |
|
} |
|
|
|
if(flashblockIsWhitelisted(this, type)) |
|
return; |
|
|
|
if (!isBrokenFlash(this)) |
|
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; |
|
|
|
// Flowplayer specific workaround. |
|
var flow = parent.getAttribute("href"); |
|
if (flow) { |
|
var prevDef = function (event) { |
|
event.preventDefault(); |
|
event.currentTarget.removeEventListener("load", arguments.callee, true); |
|
} |
|
parent.addEventListener("click", prevDef , true) |
|
} |
|
|
|
// Create placeholder div |
|
var isStandalone = ("src" in current && current.src == current.ownerDocument.location); |
|
var placeholder = flashblockCreatePlaceholder(isStandalone); |
|
|
|
// Set placeholder image |
|
flashblockSetImage(placeholder, type); |
|
|
|
flashblockStylePlaceholder(current, placeholder, isStandalone); |
|
|
|
flashblockSetTitle(current, placeholder, isStandalone); |
|
|
|
// Replace the flash document with a placeholder. |
|
try { |
|
var flashblockSetTimeout = nativeMethod(window, "setTimeout"); |
|
flashblockSetTimeout(flashblockShowPlaceholder, 0, placeholder, current, parent); |
|
} |
|
catch (e) { |
|
window.setTimeout(flashblockShowPlaceholder, 0, placeholder, current, parent); |
|
} |
|
|
|
// Change the placeholder background when the mouse enters/exits the div. |
|
placeholder.addEventListener("mouseover", |
|
function(event) {event.target.style.setProperty("background", |
|
event.target.getAttribute("bgActive"), |
|
"important"); }, |
|
"false" |
|
); |
|
placeholder.addEventListener("mouseout", |
|
function(event) {event.target.style.setProperty("background", |
|
event.target.getAttribute("bgInactive"), |
|
"important"); }, |
|
"false" |
|
); |
|
|
|
// Replace the placeholder with the flash document. |
|
placeholder.addEventListener("click", flashblockShowFlash, "false"); |
|
|
|
// Accessibility |
|
placeholder.setAttribute("tabindex", "0"); |
|
placeholder.setAttribute("role", "button"); |
|
placeholder.addEventListener("keypress", flashblockShowFlash, "false"); |
|
|
|
]]> |
|
</constructor> |
|
</implementation> |
|
</binding> |
|
|
|
<binding id="sifr-replaced" |
|
bindToUntrustedContent="true"> |
|
<implementation> |
|
<constructor> |
|
<![CDATA[ |
|
|
|
// bz says QI is a no-op. |
|
document.QueryInterface(Components.interfaces.nsIDOMDocument); |
|
event = document.createEvent("UIEvents"); |
|
|
|
if(event) { |
|
event.initEvent("flashblockCheckLoad", true, true); |
|
this.dispatchEvent(event); |
|
if(event.defaultPrevented || this.hasAttribute("data-flashblockWhitelisted")) { |
|
// 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" |
|
bindToUntrustedContent="true"> |
|
<implementation> |
|
<constructor> |
|
<![CDATA[ |
|
|
|
// bz says QI is a no-op. |
|
document.QueryInterface(Components.interfaces.nsIDOMDocument); |
|
var event = document.createEvent("UIEvents"); |
|
|
|
if(event) { |
|
event.initEvent("flashblockCheckLoad", true, true); |
|
this.dispatchEvent(event); |
|
if(event.defaultPrevented || this.hasAttribute("data-flashblockWhitelisted")) { |
|
// Whitelisted |
|
return; |
|
} |
|
} |
|
|
|
this.style.setProperty("visibility", "visible", "important"); |
|
placeholder.style.setProperty("opacity", "100", "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"; |
|
this.style.setProperty("position", "static", "important"); |
|
]]> |
|
</constructor> |
|
</implementation> |
|
</binding> |
|
|
|
</bindings>
|
|
|