You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2017/12/03 10:42:53 UTC
[royale-asjs] branch develop updated: Cleaned up GraphicShape
This is an automated email from the ASF dual-hosted git repository.
harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new a84af91 Cleaned up GraphicShape
a84af91 is described below
commit a84af915f8f0b247f8626b600183de91a127b06f
Author: Harbs <ha...@in-tools.com>
AuthorDate: Sun Dec 3 12:42:41 2017 +0200
Cleaned up GraphicShape
getBBox does not appear to have been doing anything for a long time already
I removed it and *if* width and height are specifically set, the attributes should now be applied to the SVG element
---
.../main/royale/org/apache/royale/svg/Circle.as | 4 +-
.../main/royale/org/apache/royale/svg/Ellipse.as | 4 +-
.../royale/org/apache/royale/svg/GraphicShape.as | 60 +++++++++++++---------
.../src/main/royale/org/apache/royale/svg/Path.as | 5 +-
.../src/main/royale/org/apache/royale/svg/Rect.as | 3 +-
.../src/main/royale/org/apache/royale/svg/Text.as | 4 +-
6 files changed, 46 insertions(+), 34 deletions(-)
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Circle.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Circle.as
index d89a1ef..77abe08 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Circle.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Circle.as
@@ -110,8 +110,8 @@ package org.apache.royale.svg
_circle.setAttribute('r', radius);
- //resize(x-radius, y-radius, (_circle as SVGCircleElement).getBBox());
- resize(x-radius, y-radius, getBBox(_circle));
+ // resize(x-radius, y-radius, getBBox(_circle));
+ resize(x-radius, y-radius);
}
}
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Ellipse.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Ellipse.as
index e40a322..6391daa 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Ellipse.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Ellipse.as
@@ -156,8 +156,8 @@ package org.apache.royale.svg
_ellipse.setAttribute('rx', rx);
_ellipse.setAttribute('ry', ry);
- //resize(x, y, (_ellipse as SVGEllipseElement).getBBox());
- resize(x, y, getBBox(_ellipse));
+ // resize(x, y, getBBox(_ellipse));
+ resize(x, y);
}
}
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/GraphicShape.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/GraphicShape.as
index 7e0dab5..38a091b 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/GraphicShape.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/GraphicShape.as
@@ -103,15 +103,15 @@ package org.apache.royale.svg
* @private
* @royaleignorecoercion 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::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
@@ -202,24 +202,36 @@ package org.apache.royale.svg
* @param bbox The bounding box of the svg element.
*/
COMPILE::JS
- public function resize(x:Number, y:Number, bbox:Object):void
+ public function resize(x:Number, y:Number):void
{
- var useWidth:Number = Math.max(this.width, bbox.width);
- var useHeight:Number = Math.max(this.height, bbox.height);
+ // var useWidth:Number = Math.max(this.width, bbox.width);
+ // var useHeight:Number = Math.max(this.height, bbox.height);
+ var useWidth:Number = explicitWidth;
+ var useHeight:Number = explicitHeight;
element.style.position = 'absolute';
- if (!isNaN(x)) element.style.top = x + "px";
- if (!isNaN(y)) element.style.left = y + "px";
- // element.setAttribute("width", useWidth);
- // element.setAttribute("height", useHeight);
- element.style.width = useWidth;
- element.style.height = useHeight;
- // Needed for SVG inside SVG
- element.setAttribute("x", x);
- element.setAttribute("y", y);
- //Needed for SVG inside DOM elements
- element.style.left = x + "px";
- element.style.top = y + "px";
+ //style needed for SVG inside DOM elements
+ // attributes for SVG inside SVG
+ if (!isNaN(x))
+ {
+ element.style.top = x + "px";
+ element.setAttribute("x", x);
+ }
+ if (!isNaN(y))
+ {
+ element.style.left = y + "px";
+ element.setAttribute("y", y);
+ }
+ if(!isNaN(useWidth))
+ {
+ element.style.width = useWidth + "px";
+ element.setAttribute("width", useWidth);
+ }
+ if(!isNaN(useHeight))
+ {
+ element.style.height = useHeight + "px";
+ element.setAttribute("height", useHeight);
+ }
}
COMPILE::JS
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Path.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Path.as
index dfccf85..769b21d 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Path.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Path.as
@@ -125,9 +125,8 @@ package org.apache.royale.svg
_path.setAttribute('style', style);
_path.setAttribute('d', data);
- //resize(x, y, _path['getBBox']());
- resize(x, y, getBBox(_path));
-
+ // resize(x, y, getBBox(_path));
+ resize(x, y);
}
}
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Rect.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Rect.as
index 55c11d2..58c352d 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Rect.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Rect.as
@@ -151,7 +151,8 @@ package org.apache.royale.svg
if(height)
_rect.setAttribute('height', height);
- resize(x, y, getBBox(_rect));
+ // resize(x, y, getBBox(_rect));
+ resize(x, y);
}
}
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Text.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Text.as
index 91e0f18..61b499c 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Text.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/svg/Text.as
@@ -145,8 +145,8 @@ package org.apache.royale.svg
var textNode:Text = document.createTextNode(value) as Text;
_textElem.appendChild(textNode as Node);
- //resize(x, y, (_textElem as SVGLocatable).getBBox());
- resize(x, y, getBBox(_textElem));
+ // resize(x, y, getBBox(_textElem));
+ resize(x, y);
}
}
--
To stop receiving notification emails like this one, please contact
['"commits@royale.apache.org" <co...@royale.apache.org>'].