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 995ab60c18 used svg options
995ab60c18 is described below
commit 995ab60c1871e2b94213f3cc30c7d48fda5158cd
Author: Harbs <[email protected]>
AuthorDate: Sun Mar 8 10:56:09 2026 +0200
used svg options
---
.../main/royale/org/apache/royale/style/Icon.as | 83 ++++++++--------------
1 file changed, 28 insertions(+), 55 deletions(-)
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/Icon.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/Icon.as
index 3f4ee341d2..d6388c27a3 100644
--- a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/Icon.as
+++ b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/Icon.as
@@ -64,7 +64,6 @@ package org.apache.royale.style
{
_iconPath = value;
}
- private var markup:XML;
override public function addedToParent():void
{
super.addedToParent();
@@ -74,20 +73,21 @@ package org.apache.royale.style
{
return;
}
- assert(markup || _registeredIcons.has(iconName)
|| _registeredIcons.has(iconPath), "Icon name must be provided");
+ assert(_registeredIcons.has(iconName) ||
iconPath, "Icon name or path must be provided");
+ var markup:XML;
+ if(_registeredIcons.has(iconName))
+ {
+ markup = _registeredIcons.get(iconName);
+ }
+ else if(_registeredIcons.has(iconPath))
+ {
+ markup = _registeredIcons.get(iconPath);
+ }
if(!markup)
{
- if(_registeredIcons.has(iconName))
- {
- markup =
_registeredIcons.get(iconName);
- }
- else if(_registeredIcons.has(iconPath))
- {
- markup =
_registeredIcons.get(iconPath);
- }
}
if(markup)
- parseMarkup();
+ parseMarkup(markup);
else if(iconPath)
{
return loadMarkup();
@@ -101,16 +101,14 @@ package org.apache.royale.style
{
if(task.completed)
{
- var data:String = task.data as String;
- markup = new XML(data);
- parseMarkup();
+ parseMarkup(new XML(task.resultString));
}
//TODO do we want some kind of error handling
here?
});
}
COMPILE::JS
private var iconElement:SVGElement;
- private function parseMarkup():void
+ private function parseMarkup(markup:XML):void
{
COMPILE::JS
{
@@ -129,7 +127,7 @@ package org.apache.royale.style
for each(var attr:XML in attrs)
{
var attName:String = attr.localName();
- if(!getBasicAttributes()[attName])
+ if(!getAttributes()[attName])
{
continue;
}
@@ -139,12 +137,9 @@ package org.apache.royale.style
for each(var child:XML in children)
{
var childName:String = child.localName();
- if(!getBasicElements()[childName])
- {
- continue;
- }
- if(!getOtherElements()[childName])
+ if(!getElements()[childName])
{
+ assert(false, "Unsupported SVG element:
" + childName);
continue;
}
var element:SVGElement = createSVG(childName);
@@ -170,51 +165,29 @@ package org.apache.royale.style
_registeredIcons.set(name, svgMarkup);
}
}
- private static function getBasicAttributes():Object
+ private static function getAttributes():Object
{
- if(!_basicAttributes)
+ if(!_attributes)
{
- _basicAttributes = {
-
"viewBox":1,"fill":1,"stroke":1,"d":1,"x":1,"y":1,"width":1,"height":1
+ _attributes = {
+
"width":1,"height":1,"viewBox":1,"fill":1,"stroke":1,"stroke-width":1,"stroke-linecap":1,"stroke-linejoin":1,"class":1,"focusable":1,"style":1,"d":1,"fill-rule":1,"clip-rule":1,"cx":1,"cy":1,"r":1,"x1":1,"y1":1,"x2":1,"y2":1,"points":1,"x":1,"y":1,"rx":1,"ry":1,"transform":1,"opacity":1,"role":1,"aria-hidden":1,"aria-label":1
};
}
- return _basicAttributes;
+ return _attributes;
}
// TODO: Optimize the list of attrbutes and elements to only
those that are needed for icons.
// There is a very large list of all SVG attributes and
elements.
- private static var _basicAttributes:Object;
- private static var _restAttributes:Object;
- private static function getOtherAttributes():Object
- {
- if(!_restAttributes)
- {
- _restAttributes = {
-
"cx":1,"cy":1,"r":1,"rx":1,"ry":1,"points":1,"x1":1,"y1":1,"x2":1,"y2":1,"transform":1,"offset":1,"in":1,"type":1,"values":1,"keyTimes":1,"dur":1,"repeatCount":1,"attributeName":1,"from":1,"to":1,"by":1,"begin":1,"end":1,"restart":1,"calcMode":1,"keySplines":1,"additive":1,"accumulate":1,"attributeType":1,"stop-color":1,"stop-opacity":1,"gradientUnits":1,"gradientTransform":1,"spreadMethod":1,"preserveAspectRatio":1,"role":1,"stdDeviation":1,"edgeMode":1,"in2":1,"result":1,"primitiv
[...]
- };
- }
- return _restAttributes;
- }
- private static function getBasicElements():Object
- {
- if(!_basicElements)
- {
- _basicElements = {
-
"svg":1,"path":1,"g":1,"rect":1,"circle":1,"ellipse":1,"line":1,"polyline":1,"polygon":1,"text":1,"tspan":1,"textPath":1,"use":1,"defs":1
- };
- }
- return _basicElements;
- }
- private static var _basicElements:Object;
- private static function getOtherElements():Object
+ private static var _attributes:Object;
+ private static function getElements():Object
{
- if(!_restElements)
+ if(!_elements)
{
- _restElements = {
-
"marker":1,"pattern":1,"mask":1,"clipPath":1,"filter":1,"feGaussianBlur":1,"feOffset":1,"feBlend":1,"feColorMatrix":1,"feComponentTransfer":1,"feComposite":1,"feConvolveMatrix":1,"feDiffuseLighting":1,"feDisplacementMap":1,"feFlood":1,"feImage":1,"feMerge":1,"feMorphology":1,"feSpecularLighting":1,"feTile":1,"feTurbulence":1,"animate":1,"animateMotion":1,"animateTransform":1,"mpath":1,"set":1,"altGlyph":1,"altGlyphDef":1,"altGlyphItem":1,"glyph":1,"glyphRef":1,"marker":1,"color-prof
[...]
+ _elements = {
+
"svg":1,"path":1,"g":1,"rect":1,"circle":1,"line":1,"polyline":1,"polygon":1,"defs":1,"clipPath":1,"title":1,"mask":1,"use":1,"symbol":1
};
}
- return _restElements;
+ return _elements;
}
- private static var _restElements:Object;
+ private static var _elements:Object;
}
}
\ No newline at end of file