Gisellameloni / svg-edit

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

SVG-Edit fails to start because of an exception creating SVGCanvas on Firefox #1026

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi guys. I love svg-edit and am trying to integrate it in my project. I think 
I've found an issue:

Under Firefox OSX 16.01, SVGCanvas object fail to create. 

A little research & I found the offending line & the reason: At the END of 
svgcanvas.js (LINE 10309)

    var rect = document.createElementNS(svgns,'rect');
    rect.setAttribute('width',"1em");
    rect.setAttribute('height',"1ex");
    svgcontent.appendChild(rect);
    var bb = rect.getBBox();

    ^^^^^^^^^^^^ THIS FAILS if the window is hidden on FireFox, and is related to this: https://bugzilla.mozilla.org/show_bug.cgi/show_bug.cgi?id=528969

I 'fixed' it with a try-catch, so if the window is hidden it populates some 
default values to the em/ex -that I suppose are important and related to 
relative dimensions, but the good solution would for sure be delaying this call 
until the window is visible.
My solution:

10309: // Get correct em/ex values

    try {
        var rect = document.createElementNS(svgns,'rect');
        rect.setAttribute('width',"1em");
        rect.setAttribute('height',"1ex");
        svgcontent.appendChild(rect);
        var bb = rect.getBBox();
        unit_types.em = bb.width;
        unit_types.ex = bb.height;
    } catch (e) {
        unit_types.em = 11; // the values I get on chrome
        unit_types.ex = 6;  // but it's a dirty fix !!
    } finally {
        svgcontent.removeChild(rect);
    }

What steps will reproduce the problem?
1.
2.
3.

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

In what browser did you experience this problem? (ALL, Firefox, Opera, etc)

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

Please provide any additional information below.

Original issue reported on code.google.com by kowloon....@gmail.com on 28 Oct 2012 at 5:34

GoogleCodeExporter commented 9 years ago
sorry I forgot SVG-EDIT 2.5.1 stable

Original comment by kowloon....@gmail.com on 28 Oct 2012 at 5:36