Add a shadow to the canvas in Firefox (experimental)

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1373 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Jeff Schiller 2010-02-10 20:12:48 +00:00
parent 984d6263c9
commit ae214cfe0e
1 changed files with 20 additions and 11 deletions

View File

@ -87,8 +87,6 @@ function SvgCanvas(container)
var isOpera = !!window.opera, var isOpera = !!window.opera,
isWebkit = navigator.userAgent.indexOf("AppleWebKit") != -1, isWebkit = navigator.userAgent.indexOf("AppleWebKit") != -1,
support = {}, support = {},
htmlns = "http://www.w3.org/1999/xhtml",
mathns = "http://www.w3.org/1998/Math/MathML",
// this defines which elements and attributes that we support // this defines which elements and attributes that we support
svgWhiteList = { svgWhiteList = {
@ -673,6 +671,9 @@ function BatchCommand(text) {
'y': 0, 'y': 0,
'style': 'pointer-events:none' 'style': 'pointer-events:none'
}); });
// Opera has a rendering bug
if (!window.opera) canvasbg.setAttribute("filter", "url(#canvashadow)");
var rect = svgdoc.createElementNS(svgns, "rect"); var rect = svgdoc.createElementNS(svgns, "rect");
assignAttributes(rect, { assignAttributes(rect, {
'width': '100%', 'width': '100%',
@ -917,17 +918,25 @@ function BatchCommand(text) {
xlinkns = "http://www.w3.org/1999/xlink", xlinkns = "http://www.w3.org/1999/xlink",
xmlns = "http://www.w3.org/XML/1998/namespace", xmlns = "http://www.w3.org/XML/1998/namespace",
se_ns = "http://svg-edit.googlecode.com", se_ns = "http://svg-edit.googlecode.com",
htmlns = "http://www.w3.org/1999/xhtml",
mathns = "http://www.w3.org/1998/Math/MathML",
idprefix = "svg_", idprefix = "svg_",
svgdoc = container.ownerDocument, svgdoc = container.ownerDocument,
svgroot = svgdoc.createElementNS(svgns, "svg"); svgroot = svgdoc.importNode(Utils.text2xml('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
'width="640" height="480" x="640" y="480" overflow="visible">' +
$(svgroot).attr({ '<defs>' +
width: 640, '<filter id="canvashadow" filterUnits="objectBoundingBox">' +
height: 480, '<feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>'+
id: "svgroot", '<feOffset in="blur" dx="5" dy="5" result="offsetBlur"/>'+
xmlns: svgns, '<feMerge>'+
"xmlns:xlink": xlinkns '<feMergeNode in="offsetBlur"/>'+
}).appendTo(container); '<feMergeNode in="SourceGraphic"/>'+
'</feMerge>'+
'</filter>'+
'</defs>'+
'</svg>').documentElement, true);
$(svgroot).appendTo(container);
var svgcontent = svgdoc.createElementNS(svgns, "svg"); var svgcontent = svgdoc.createElementNS(svgns, "svg");
$(svgcontent).attr({ $(svgcontent).attr({