4xx / svg-edit

Automatically exported from code.google.com/p/svg-edit
MIT License
0 stars 0 forks source link

initialization of display:none iframe #1129

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. in firefox open this fiddle: http://jsfiddle.net/scytacki/QB9yf/
2. click the show editor button

What is the expected output? What do you see instead?

svg-edit should appear. It ought to have all the icons and should work.
Instead the icons are missing and it doesn't work.

In what browser did you experience this problem?
Firefox on OS X 10.6, I'd guess it also happens on FF on other platforms.

In what version of SVG-edit does the problem occur? (Latest trunk, 2.5.1,
etc)
2.6

Please provide any additional information below.

The initialization code is throwing an exception here:
https://code.google.com/p/svg-edit/source/browse/trunk/editor/browser.js#88

This could be seen as a bug in Firefox, but it seems reasonable to me that font 
metrics methods of SVG don't always work or don't work correctly when the SVG 
is not displayed.

I can think of a few ways to fix this in svg-edit, but I wanted to know if you 
think this mode of using svg-edit should be supported? 

An alternative solution from fixing it in the svg-edit is to change the code so 
the svg-edit iframe is not added to the page until it is visible.

Original issue reported on code.google.com by scyta...@concord.org on 16 Aug 2013 at 12:59

GoogleCodeExporter commented 9 years ago
I went looking at Modernizr to see if it also has to deal with the hidden 
iframe problem. And it does:
https://github.com/Modernizr/Modernizr/commit/ef14ae79e7cd1e210b4529e646efd4ba1e
25b7e8

Modernizr just assumes the feature it is looking for doesn't work even though 
it probably would work if the iframe wasn't hidden.

Original comment by scyta...@concord.org on 18 Aug 2013 at 2:58

GoogleCodeExporter commented 9 years ago
Here is one way to fix this problem:
https://github.com/concord-consortium/sketchily/commit/61df7c00356250dfeb2e4e1cd
6e220e9388f2da8

That is the same approach as what Modernizr does for the feature tests.  
Additionally it uses a standard default for the units calculation since those 
require getBBox which fails in the invisible iframe.  With some basic testing 
it seems like svg-edit works with just this change, but I'm pretty sure this 
will cause something to be broken that I haven't found yet.

This next change makes it possible to re-run the feature tests after the iframe 
is visible:
https://github.com/concord-consortium/sketchily/commit/5b4b2a52f1d33fe43288393d8
4a466e8d3d22ded
So then after the iframe is visible, svgedit.browser.checkFeatures() can be 
run, and then after that re-initializing the units. If that is done, I don't 
think anything should be broken in svg-edit.

Again I don't know if this is something you think should be in svg-edit or not. 
If it is something you want, I can put together a patch for trunk.

Original comment by scyta...@concord.org on 18 Aug 2013 at 3:07