From 748c3a4057e5172ac8978d5a50bb0d148469c139 Mon Sep 17 00:00:00 2001 From: Alexis Deveria Date: Thu, 23 Sep 2010 16:28:08 +0000 Subject: [PATCH] Fixed bug where selection box of group was incorrect in Webkit git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1746 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index c78a4916..02273422 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -184,6 +184,7 @@ var isOpera = !!window.opera, // Much faster than running getBBox() every time var visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use'; + var visElems_arr = visElems.split(','); // var hidElems = 'clipPath,defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath'; @@ -2620,13 +2621,15 @@ var getBBox = this.getBBox = function(elem) { var selected = elem || selectedElements[0]; if (elem.nodeType != 1) return null; var ret = null; - if(elem.nodeName == 'text' && selected.textContent == '') { + var elname = selected.nodeName; + + if(elname === 'text' && selected.textContent === '') { selected.textContent = 'a'; // Some character needed for the selector to use. ret = selected.getBBox(); selected.textContent = ''; - } else if(elem.nodeName == 'path' && isWebkit) { + } else if(elname === 'path' && isWebkit) { ret = getPathBBox(selected); - } else if(elem.nodeName == 'use' && !isWebkit || elem.nodeName == 'foreignObject') { + } else if(elname === 'use' && !isWebkit || elname === 'foreignObject') { ret = selected.getBBox(); var bb = {}; bb.width = ret.width; @@ -2634,8 +2637,8 @@ var getBBox = this.getBBox = function(elem) { bb.x = ret.x + parseFloat(selected.getAttribute('x')||0); bb.y = ret.y + parseFloat(selected.getAttribute('y')||0); ret = bb; - } else { - try { ret = selected.getBBox(); } + } else if(~$.inArray(elname, visElems_arr)) { + try { ret = selected.getBBox();} catch(e) { // Check if element is child of a foreignObject var fo = $(selected).closest("foreignObject");