Applied patch to issue 565 by peter.d.reid

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1582 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2010-05-31 15:27:40 +00:00
parent 4eae367b9a
commit b61de7cc25
1 changed files with 37 additions and 25 deletions

View File

@ -2927,6 +2927,39 @@ function BatchCommand(text) {
return {tl:topleft, tr:topright, bl:botleft, br:botright, return {tl:topleft, tr:topright, bl:botleft, br:botright,
aabox: {x:minx, y:miny, width:(maxx-minx), height:(maxy-miny)} }; aabox: {x:minx, y:miny, width:(maxx-minx), height:(maxy-miny)} };
}; };
var getMouseTarget = function(evt) {
if (evt == null) {
return null;
}
var mouse_target = evt.target;
// if it was a <use>, Opera and WebKit return the SVGElementInstance
if (mouse_target.correspondingUseElement)
mouse_target = mouse_target.correspondingUseElement;
// for foreign content, go up until we find the foreignObject
// WebKit browsers set the mouse target to the svgcanvas div
if ($.inArray(mouse_target.namespaceURI, [mathns, htmlns]) != -1 &&
mouse_target.id != "svgcanvas")
{
while (mouse_target.nodeName != "foreignObject") {
mouse_target = mouse_target.parentNode;
}
}
// go up until we hit a child of a layer
while (mouse_target.parentNode.parentNode.tagName == "g") {
mouse_target = mouse_target.parentNode;
}
// Webkit bubbles the mouse event all the way up to the div, so we
// set the mouse_target to the svgroot like the other browsers
if (mouse_target.nodeName.toLowerCase() == "div") {
mouse_target = svgroot;
}
return mouse_target;
};
// Mouse events // Mouse events
(function() { (function() {
@ -2961,34 +2994,11 @@ function BatchCommand(text) {
var x = mouse_x / current_zoom, var x = mouse_x / current_zoom,
y = mouse_y / current_zoom, y = mouse_y / current_zoom,
mouse_target = evt.target; mouse_target = getMouseTarget(evt);
start_x = x; start_x = x;
start_y = y; start_y = y;
// if it was a <use>, Opera and WebKit return the SVGElementInstance
if (mouse_target.correspondingUseElement)
mouse_target = mouse_target.correspondingUseElement;
// for foreign content, go up until we find the foreignObject
// WebKit browsers set the mouse target to the svgcanvas div
if ($.inArray(mouse_target.namespaceURI, [mathns, htmlns]) != -1 &&
mouse_target.id != "svgcanvas")
{
while (mouse_target.nodeName != "foreignObject") {
mouse_target = mouse_target.parentNode;
}
}
// go up until we hit a child of a layer
while (mouse_target.parentNode.parentNode.tagName == "g") {
mouse_target = mouse_target.parentNode;
}
// Webkit bubbles the mouse event all the way up to the div, so we
// set the mouse_target to the svgroot like the other browsers
if (mouse_target.nodeName.toLowerCase() == "div") {
mouse_target = svgroot;
}
// if it is a selector grip, then it must be a single element selected, // if it is a selector grip, then it must be a single element selected,
// set the mouse_target to that and update the mode to rotate/resize // set the mouse_target to that and update the mode to rotate/resize
if (mouse_target.parentNode == selectorManager.selectorParentGroup && selectedElements[0] != null) { if (mouse_target.parentNode == selectorManager.selectorParentGroup && selectedElements[0] != null) {
@ -5522,8 +5532,9 @@ function BatchCommand(text) {
// else, create a new point, append to pts array, update path element // else, create a new point, append to pts array, update path element
else { else {
// Checks if current target or parents are #svgcontent // Checks if current target or parents are #svgcontent
if(!$.contains(container, evt.target)) { if(!$.contains(container, getMouseTarget(evt))) {
// Clicked outside canvas, so don't make point // Clicked outside canvas, so don't make point
console.log("Clicked outside canvas");
return false; return false;
} }
@ -9201,6 +9212,7 @@ function BatchCommand(text) {
getElem: getElem, getElem: getElem,
getId: getId, getId: getId,
getIntersectionList: getIntersectionList, getIntersectionList: getIntersectionList,
getMouseTarget: getMouseTarget,
getNextId: getNextId, getNextId: getNextId,
getPathBBox: getPathBBox, getPathBBox: getPathBBox,
getUrlFromAttr: getUrlFromAttr, getUrlFromAttr: getUrlFromAttr,