Added 'supportsPathBBox' to svgedit.browser to replace a webkit browser sniff

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1965 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2011-02-01 20:25:06 +00:00
parent aeaa8b0213
commit fe537b05a8
2 changed files with 13 additions and 1 deletions

View File

@ -85,6 +85,17 @@ var supportsTextCharPos_ = (function() {
return retValue;
})();
var supportsPathBBox_ = (function() {
var svgcontent = document.createElementNS(svgns, 'svg');
document.documentElement.appendChild(svgcontent);
var path = document.createElementNS(svgns, 'path');
path.setAttribute('d','M0,0 C0,0 10,10 10,0');
svgcontent.appendChild(path);
var bbox = path.getBBox();
document.documentElement.removeChild(svgcontent);
return (bbox.height > 4 && bbox.height < 5);
})();
var supportsEditableText_ = (function() {
// TODO: Find better way to check support for this
return isOpera_;
@ -129,6 +140,7 @@ svgedit.browser.supportsXpath = function() { return supportsXpath_; }
svgedit.browser.supportsPathReplaceItem = function() { return supportsPathReplaceItem_; }
svgedit.browser.supportsPathInsertItemBefore = function() { return supportsPathInsertItemBefore_; }
svgedit.browser.supportsPathBBox = function() { return supportsPathBBox_; }
svgedit.browser.supportsTextCharPos = function() { return supportsTextCharPos_; }
svgedit.browser.supportsEditableText = function() { return supportsEditableText_; }
svgedit.browser.supportsGoodDecimals = function() { return supportsGoodDecimals_; }

View File

@ -418,7 +418,7 @@ svgedit.utilities.getBBox = function(elem) {
selected.textContent = 'a'; // Some character needed for the selector to use.
ret = selected.getBBox();
selected.textContent = '';
} else if(elname === 'path' && svgedit.browser.isWebkit()) {
} else if(elname === 'path' && !svgedit.browser.supportsPathBBox()) {
ret = svgedit.utilities.getPathBBox(selected);
} else if(elname === 'use' && !svgedit.browser.isWebkit() || elname === 'foreignObject') {
ret = selected.getBBox();