Fixed sub-bug in Issue 717: Bounding box not surrounding entire image library image, started on Issue 782: Text editing is buggy (IE9)

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1996 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2011-02-23 15:56:14 +00:00
parent 90fffe8a09
commit 6d6c6aa61f
3 changed files with 28 additions and 9 deletions

View File

@ -34,6 +34,7 @@ var svg = document.createElementNS(svgns, 'svg');
var isOpera_ = !!window.opera; var isOpera_ = !!window.opera;
var isWebkit_ = userAgent.indexOf("AppleWebKit") >= 0; var isWebkit_ = userAgent.indexOf("AppleWebKit") >= 0;
var isGecko_ = userAgent.indexOf('Gecko/') >= 0; var isGecko_ = userAgent.indexOf('Gecko/') >= 0;
var isIE_ = userAgent.indexOf('MSIE') >= 0;
var supportsSelectors_ = (function() { var supportsSelectors_ = (function() {
return !!svg.querySelector; return !!svg.querySelector;
@ -151,6 +152,7 @@ var supportsNativeSVGTransformLists_ = (function() {
svgedit.browser.isOpera = function() { return isOpera_; } svgedit.browser.isOpera = function() { return isOpera_; }
svgedit.browser.isWebkit = function() { return isWebkit_; } svgedit.browser.isWebkit = function() { return isWebkit_; }
svgedit.browser.isGecko = function() { return isGecko_; } svgedit.browser.isGecko = function() { return isGecko_; }
svgedit.browser.isIE = function() { return isIE_; }
svgedit.browser.supportsSelectors = function() { return supportsSelectors_; } svgedit.browser.supportsSelectors = function() { return supportsSelectors_; }
svgedit.browser.supportsXpath = function() { return supportsXpath_; } svgedit.browser.supportsXpath = function() { return supportsXpath_; }

View File

@ -2367,8 +2367,9 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
var pt = transformPoint( evt.pageX, evt.pageY, root_sctm ), var pt = transformPoint( evt.pageX, evt.pageY, root_sctm ),
mouse_x = pt.x * current_zoom, mouse_x = pt.x * current_zoom,
mouse_y = pt.y * current_zoom; mouse_y = pt.y * current_zoom;
if($.browser.msie) { // TODO: Use feature detection
if(svgedit.browser.isIE()) {
var off = $(container.parentNode).offset(); var off = $(container.parentNode).offset();
off_x = svgcontent.getAttribute('x')-0 + off.left - container.parentNode.scrollLeft; off_x = svgcontent.getAttribute('x')-0 + off.left - container.parentNode.scrollLeft;
off_y = svgcontent.getAttribute('y')-0 + off.top - container.parentNode.scrollTop; off_y = svgcontent.getAttribute('y')-0 + off.top - container.parentNode.scrollTop;
@ -2717,7 +2718,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
shape = getElem(getId()); shape = getElem(getId());
// IE9 gives the wrong root_sctm // IE9 gives the wrong root_sctm
// TODO: Use non-browser sniffing way to make this work // TODO: Use non-browser sniffing way to make this work
if($.browser.msie) { if(svgedit.browser.isIE()) {
mouse_x = -(off_x - evt.pageX); mouse_x = -(off_x - evt.pageX);
mouse_y = -(off_y - evt.pageY); mouse_y = -(off_y - evt.pageY);
} }
@ -3764,7 +3765,15 @@ var textActions = canvas.textActions = function() {
// && !svgedit.math.rectsIntersect(transbb, {x: pt.x, y: pt.y, width:0, height:0})) { // && !svgedit.math.rectsIntersect(transbb, {x: pt.x, y: pt.y, width:0, height:0})) {
// textActions.toSelectMode(true); // textActions.toSelectMode(true);
// } // }
// For some reason points in IE are off by 1
if(svgedit.browser.isIE()) {
mouse_x++;
mouse_y++;
}
if(last_x === mouse_x && last_y === mouse_y && evt.target !== curtext) { if(last_x === mouse_x && last_y === mouse_y && evt.target !== curtext) {
textActions.toSelectMode(true); textActions.toSelectMode(true);
} }
@ -3869,6 +3878,12 @@ var textActions = canvas.textActions = function() {
for(var i=0; i<len; i++) { for(var i=0; i<len; i++) {
var start = curtext.getStartPositionOfChar(i); var start = curtext.getStartPositionOfChar(i);
var end = curtext.getEndPositionOfChar(i); var end = curtext.getEndPositionOfChar(i);
// TODO: Make support property for this
if(svgedit.browser.isIE()) {
var offset = canvas.contentW * current_zoom;
start.x -= offset;
end.x -= offset;
}
// Get a "bbox" equivalent for each character. Uses the // Get a "bbox" equivalent for each character. Uses the
// bbox data of the actual text for y, height purposes // bbox data of the actual text for y, height purposes

View File

@ -496,12 +496,14 @@ svgedit.utilities.getBBox = function(elem) {
if(elname === 'use' || elname === 'foreignObject') { if(elname === 'use' || elname === 'foreignObject') {
if(!ret) ret = selected.getBBox(); if(!ret) ret = selected.getBBox();
var bb = {}; if(!svgedit.browser.isWebkit()) {
bb.width = ret.width; var bb = {};
bb.height = ret.height; bb.width = ret.width;
bb.x = ret.x + parseFloat(selected.getAttribute('x')||0); bb.height = ret.height;
bb.y = ret.y + parseFloat(selected.getAttribute('y')||0); bb.x = ret.x + parseFloat(selected.getAttribute('x')||0);
ret = bb; bb.y = ret.y + parseFloat(selected.getAttribute('y')||0);
ret = bb;
}
} else if(~visElems_arr.indexOf(elname)) { } else if(~visElems_arr.indexOf(elname)) {
try { ret = selected.getBBox();} try { ret = selected.getBBox();}
catch(e) { catch(e) {