Repository: flex-asjs
Updated Branches:
  refs/heads/develop 24a297a9c -> 93caf80fc


Attempt to fix issue with SVG and Firefox: local getBBox function uses 
try...catch and returns a suitable replacement box if the SVG call fails.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/93caf80f
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/93caf80f
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/93caf80f

Branch: refs/heads/develop
Commit: 93caf80fc2150cf2b6742e342fba2687b052a501
Parents: 24a297a
Author: Peter Ent <p...@apache.org>
Authored: Sat May 6 07:47:31 2017 -0400
Committer: Peter Ent <p...@apache.org>
Committed: Sat May 6 07:47:31 2017 -0400

----------------------------------------------------------------------
 .../src/main/flex/org/apache/flex/svg/Circle.as | 17 ++++++-----
 .../main/flex/org/apache/flex/svg/Ellipse.as    | 23 ++++++++-------
 .../org/apache/flex/svg/GraphicContainer.as     | 12 ++++----
 .../flex/org/apache/flex/svg/GraphicShape.as    | 16 +++++++++-
 .../src/main/flex/org/apache/flex/svg/Path.as   |  7 +++--
 .../src/main/flex/org/apache/flex/svg/Rect.as   |  2 +-
 .../src/main/flex/org/apache/flex/svg/Text.as   | 31 ++++++++++----------
 7 files changed, 63 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/93caf80f/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Circle.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Circle.as 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Circle.as
index 8f9ae16..77511a3 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Circle.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Circle.as
@@ -21,7 +21,7 @@ package org.apache.flex.svg
     {
         import flash.display.Graphics;
         import flash.geom.Point;
-        import flash.geom.Rectangle;            
+        import flash.geom.Rectangle;
     }
     COMPILE::JS
     {
@@ -56,7 +56,7 @@ package org.apache.flex.svg
         {
             _radius = value;
         }
-        
+
         COMPILE::JS
         private var _circle:WrappedHTMLElement;
 
@@ -83,7 +83,7 @@ package org.apache.flex.svg
                 graphics.drawCircle(cx+radius,cy+radius,radius);
                 endFill();
             }
-            COMPILE::JS                
+            COMPILE::JS
             {
                 var style:String = getStyleStr();
 
@@ -103,14 +103,15 @@ package org.apache.flex.svg
                     _circle.setAttribute('cx', radius);
                     _circle.setAttribute('cy', radius);
                 }
-                
+
                 _circle.setAttribute('r', radius);
-                
-                resize(x-radius, y-radius, (_circle as 
SVGCircleElement).getBBox());
+
+                //resize(x-radius, y-radius, (_circle as 
SVGCircleElement).getBBox());
+                resize(x-radius, y-radius, getBBox(_circle));
 
             }
         }
-        
+
         override protected function drawImpl():void
         {
             drawCircle(0, 0, radius);
@@ -120,6 +121,6 @@ package org.apache.flex.svg
                {
                        drawImpl();
                }
-        
+
     }
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/93caf80f/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Ellipse.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Ellipse.as 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Ellipse.as
index b118d30..2ccf505 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Ellipse.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Ellipse.as
@@ -24,7 +24,7 @@ package org.apache.flex.svg
     COMPILE::SWF
     {
         import flash.geom.Point;
-        import flash.geom.Rectangle;            
+        import flash.geom.Rectangle;
     }
     COMPILE::JS
     {
@@ -48,12 +48,12 @@ package org.apache.flex.svg
                        this.rx = rx;
                        this.ry = ry;
                }
-               
+
                private var _rx:Number;
 
                /**
                 * The horizontal radius of the ellipse.
-                * 
+                *
                 *  @langversion 3.0
                 *  @playerversion Flash 9
                 *  @playerversion AIR 1.1
@@ -73,7 +73,7 @@ package org.apache.flex.svg
 
                /**
                 * The vertical radius of the ellipse.
-                * 
+                *
          *  @langversion 3.0
          *  @playerversion Flash 9
          *  @playerversion AIR 1.1
@@ -108,10 +108,10 @@ package org.apache.flex.svg
         {
             _ry = value/2;
         }
-        
+
         COMPILE::JS
         private var _ellipse:WrappedHTMLElement;
-        
+
         /**
          *  Draw the ellipse.
          *  @param xp The x position of the top-left corner of the bounding 
box of the ellipse.
@@ -132,7 +132,7 @@ package org.apache.flex.svg
                 applyStroke();
                 beginFill(new Rectangle(xp, yp, width, height), new 
Point(xp,yp));
                 graphics.drawEllipse(xp,yp,width,height);
-                endFill();                    
+                endFill();
             }
             COMPILE::JS
             {
@@ -155,12 +155,13 @@ package org.apache.flex.svg
                 }
                 _ellipse.setAttribute('rx', rx);
                 _ellipse.setAttribute('ry', ry);
-                
-                resize(x, y, (_ellipse as SVGEllipseElement).getBBox());
+
+                //resize(x, y, (_ellipse as SVGEllipseElement).getBBox());
+                resize(x, y, getBBox(_ellipse));
 
             }
         }
-        
+
         override protected function drawImpl():void
         {
             drawEllipse(0, 0);
@@ -170,6 +171,6 @@ package org.apache.flex.svg
                {
                        drawImpl();
                }
-        
+
     }
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/93caf80f/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicContainer.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicContainer.as
 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicContainer.as
index 8bd841f..0cd57e2 100644
--- 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicContainer.as
+++ 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicContainer.as
@@ -13,7 +13,7 @@
  */
 package org.apache.flex.svg
 {
-    import org.apache.flex.core.ContainerBase;
+    import org.apache.flex.core.GroupBase;
     import org.apache.flex.core.IChild;
     import org.apache.flex.core.IFlexJSElement;
     import org.apache.flex.core.ITransformHost;
@@ -27,7 +27,7 @@ package org.apache.flex.svg
        [DefaultProperty("mxmlContent")]
 
        COMPILE::SWF
-    public class GraphicContainer extends ContainerBase implements 
ITransformHost
+    public class GraphicContainer extends GroupBase implements ITransformHost
     {
         public function GraphicContainer()
         {
@@ -37,9 +37,9 @@ package org.apache.flex.svg
     }
 
        COMPILE::JS
-       public class GraphicContainer extends ContainerBase implements 
ITransformHost
+       public class GraphicContainer extends GroupBase implements 
ITransformHost
        {
-               private var graphicGroup:ContainerBase;
+               private var graphicGroup:GroupBase;
 
                public function GraphicContainer()
                {
@@ -182,9 +182,9 @@ package org.apache.flex.svg
        }
 }
 
-import org.apache.flex.core.ContainerBase;
+import org.apache.flex.core.GroupBase;
 
-class GraphicGroup extends ContainerBase
+class GraphicGroup extends GroupBase
 {
        /**
         * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/93caf80f/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicShape.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicShape.as 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicShape.as
index 523bbe3..73d8dfe 100644
--- 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicShape.as
+++ 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/GraphicShape.as
@@ -98,6 +98,20 @@ package org.apache.flex.svg
 
                        return element;
                }
+               
+               /**
+                * @private
+                * @flexjsignorecoercion SVGRect
+                */
+               COMPILE::JS
+               protected function getBBox(svgElement:WrappedHTMLElement):Object
+               {
+                       try {
+                               return svgElement['getBBox']();
+                       } catch (err) {
+                               return {x: 0, y:0, width:this.width, 
height:this.height};
+                       }
+               }
 
 
         COMPILE::SWF
@@ -188,7 +202,7 @@ package org.apache.flex.svg
          * @param bbox The bounding box of the svg element.
          */
         COMPILE::JS
-        public function resize(x:Number, y:Number, bbox:SVGRect):void
+        public function resize(x:Number, y:Number, bbox:Object):void
         {
             var useWidth:Number = Math.max(this.width, bbox.width);
             var useHeight:Number = Math.max(this.height, bbox.height);

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/93caf80f/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Path.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Path.as 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Path.as
index 126a437..2d882a3 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Path.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Path.as
@@ -46,7 +46,7 @@ package org.apache.flex.svg
             _data = value;
             _pathCommands = null;
         }
-        
+
         private var _pathCommands:PathBuilder;
 
         public function get pathCommands():PathBuilder
@@ -60,7 +60,7 @@ package org.apache.flex.svg
             _data = _pathCommands.getPathString();
         }
 
-        
+
         COMPILE::JS
         private var _path:WrappedHTMLElement;
 
@@ -121,7 +121,8 @@ package org.apache.flex.svg
                 _path.setAttribute('style', style);
                 _path.setAttribute('d', data);
 
-                resize(x, y, _path['getBBox']());
+                //resize(x, y, _path['getBBox']());
+                resize(x, y, getBBox(_path));
 
             }
         }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/93caf80f/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Rect.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Rect.as 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Rect.as
index 6cacf41..09ce190 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Rect.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Rect.as
@@ -144,7 +144,7 @@ package org.apache.flex.svg
                                _rect.setAttribute('width', width);
                                _rect.setAttribute('height', height);
                 
-                resize(x, y, _rect['getBBox']());
+                               resize(x, y, getBBox(_rect));
             }
                }
                

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/93caf80f/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Text.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Text.as 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Text.as
index 7b22aab..0b5c907 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Text.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/svg/Text.as
@@ -24,14 +24,14 @@ package org.apache.flex.svg
 
     COMPILE::SWF
     {
-        import flash.text.TextFieldType;        
-        import org.apache.flex.core.CSSTextField;            
+        import flash.text.TextFieldType;
+        import org.apache.flex.core.CSSTextField;
     }
     COMPILE::JS
     {
         import org.apache.flex.core.WrappedHTMLElement;
     }
-       
+
        /**
         *  Draws a string of characters at a specific location using the fill
         *  value of color and alpha.
@@ -56,14 +56,14 @@ package org.apache.flex.svg
                public function Text()
                {
                        super();
-                       
+
             COMPILE::SWF
             {
                 _textField = new CSSTextField();
                 addChild(_textField);
             }
                }
-               
+
                private var _text:String;
                public function get text():String
                {
@@ -76,13 +76,13 @@ package org.apache.flex.svg
 
         COMPILE::SWF
                private var _textField:CSSTextField;
-               
+
                COMPILE::JS
                private var _textElem:WrappedHTMLElement;
-               
+
                /**
                 *  @copy org.apache.flex.core.ITextModel#textField
-                *  
+                *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
@@ -93,7 +93,7 @@ package org.apache.flex.svg
                {
                        return _textField;
                }
-               
+
                /**
                 *  Draws text at the given point.
                 *  @param value The string to draw.
@@ -118,15 +118,15 @@ package org.apache.flex.svg
                 textField.mouseEnabled = false;
                 textField.autoSize = "left";
                 textField.text = value;
-                
+
                 var color:SolidColor = fill as SolidColor;
                 if (color) {
                     textField.textColor = color.color;
                     textField.alpha = color.alpha;
                 }
-                
+
                 textField.x = xt;
-                textField.y = yt;                    
+                textField.y = yt;
             }
             COMPILE::JS
             {
@@ -144,12 +144,13 @@ package org.apache.flex.svg
                 _textElem.setAttribute('y', yt);
                                var textNode:Text = 
document.createTextNode(value) as Text;
                                _textElem.appendChild(textNode as Node);
-                
-                resize(x, y, (_textElem as SVGLocatable).getBBox());
+
+                //resize(x, y, (_textElem as SVGLocatable).getBBox());
+                resize(x, y, getBBox(_textElem));
 
             }
                }
-        
+
         override protected function drawImpl():void
         {
             drawText(text,x,y);

Reply via email to