You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2017/05/24 05:37:17 UTC

[1/2] git commit: [flex-asjs] [refs/heads/release0.8.0] - switch to using addRule so styles set up properly for JS

Repository: flex-asjs
Updated Branches:
  refs/heads/release0.8.0 90eda31d4 -> 1ee9866b5


switch to using addRule so styles set up properly for JS


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

Branch: refs/heads/release0.8.0
Commit: 1ee9866b578146c8576cc23a30816bc1c0e86e1d
Parents: 7b26ee3
Author: Alex Harui <ah...@apache.org>
Authored: Tue May 23 22:37:07 2017 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Tue May 23 22:37:13 2017 -0700

----------------------------------------------------------------------
 .../src/main/flex/DataBindingExample.as         | 52 +++++++++++++-------
 1 file changed, 33 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1ee9866b/examples/flexjs/DataBindingExample_as/src/main/flex/DataBindingExample.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_as/src/main/flex/DataBindingExample.as b/examples/flexjs/DataBindingExample_as/src/main/flex/DataBindingExample.as
index 848b0ab..225271b 100644
--- a/examples/flexjs/DataBindingExample_as/src/main/flex/DataBindingExample.as
+++ b/examples/flexjs/DataBindingExample_as/src/main/flex/DataBindingExample.as
@@ -104,40 +104,44 @@ public class DataBindingExample extends Application
     private function setupStyles(vi:SimpleCSSValuesImpl):void
     {
         var viv:Object = vi.values = {};
-        viv["global"] =
+        vi.addRule("global",
         {
             fontFamily: "Arial",
             fontSize: 12
-        };
+        });
 
-        var o:Object;
-
-        o = viv[makeDefinitionName("org.apache.flex.html::Container")] =
+		var s:String = makeDefinitionName("org.apache.flex.html::Container");
+        vi.addRule(s,
         {
 
             iBeadView: ContainerView,
     		iBeadLayout: BasicLayout
-        };
+        });
 
+	   var o:Object;
        COMPILE::SWF {
+		    o = vi.values[s];
         	o.iContentView = ContainerContentArea;
          	o.iViewport = Viewport;
          	o.iViewportModel = ViewportModel;
          };
 
-        o = viv[makeDefinitionName("org.apache.flex.core::View")] =
+        s = makeDefinitionName("org.apache.flex.core::View");
+		vi.addRule(s,
         {
 
             iBeadView: GroupView,
     		iBeadLayout: BasicLayout
-        };
+        });
 
         COMPILE::SWF {
+		    o = vi.values[s];
             o.iBackgroundBead = SolidBackgroundBead;
             o.iBorderBead = SingleLineBorderBead;
         }
 
-        viv[makeDefinitionName("org.apache.flex.html::List")] =
+        s = makeDefinitionName("org.apache.flex.html::List");
+		vi.addRule(s,
         {
             iBeadModel: ArraySelectionModel,
             iBeadView:  ListView,
@@ -149,31 +153,41 @@ public class DataBindingExample extends Application
 			iViewportModel: ViewportModel,
             iItemRendererClassFactory: ItemRendererClassFactory,
             iItemRenderer: StringItemRenderer
-        };
+        });
 
-        o = viv[makeDefinitionName("org.apache.flex.html::Button")] =
+        s = makeDefinitionName("org.apache.flex.html::Button");
+		vi.addRule(s,
         {
             backgroundColor: 0xd8d8d8,
-            border: [1, "solid", 0x000000],
+			borderWidth: 1,
+			borderStyle: "solid",
+			borderColor: 0x000000,
             padding: 4
-        };
+        });
         COMPILE::SWF {
+		    o = vi.values[s];
             o.iBeadView = CSSButtonView;
         }
 
-        viv[makeDefinitionName("org.apache.flex.html::Button:hover")] =
+        s = makeDefinitionName("org.apache.flex.html::Button:hover");
+		vi.addRule(s,
         {
             backgroundColor: 0x9fa0a1,
-            border: [1, "solid", 0x000000],
+			borderWidth: 1,
+			borderStyle: "solid",
+			borderColor: 0x000000,
             padding: 4
-        };
+        });
 
-        viv[makeDefinitionName("org.apache.flex.html::Button:active")] =
+        s = makeDefinitionName("org.apache.flex.html::Button:active");
+		vi.addRule(s,
         {
             backgroundColor: 0x929496,
-            border: [1, "solid", 0x000000],
+			borderWidth: 1,
+			borderStyle: "solid",
+			borderColor: 0x000000,
             padding: 4
-        };
+        });
 
         COMPILE::SWF {
             viv["org.apache.flex.html::CheckBox"] =


[2/2] git commit: [flex-asjs] [refs/heads/release0.8.0] - get addRule to work for JS

Posted by ah...@apache.org.
get addRule to work for JS


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

Branch: refs/heads/release0.8.0
Commit: 7b26ee3dfc97e2968d6df20fbb5f69185468d821
Parents: 90eda31
Author: Alex Harui <ah...@apache.org>
Authored: Tue May 23 22:36:23 2017 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Tue May 23 22:37:13 2017 -0700

----------------------------------------------------------------------
 .../org/apache/flex/core/SimpleCSSValuesImpl.as | 37 ++++++++++++++++++++
 1 file changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7b26ee3d/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as
index 4e1cd47..7965712 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as
@@ -632,6 +632,10 @@ package org.apache.flex.core
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
+		 *
+		 *  @flexjsignorecoercion HTMLStyleElement
+		 *  @flexjsignorecoercion CSSStyleSheet
+		 *  @flexjsignorecoercion uint
          */
         public function addRule(ruleName:String, values:Object):void
         {
@@ -650,7 +654,40 @@ package org.apache.flex.core
                 asValues[valueName] = v;
             }
             this.values[ruleName] = asValues;
+			COMPILE::JS
+			{
+				if (!ss)
+				{
+					var styleElement:HTMLStyleElement = document.createElement('style') as HTMLStyleElement;
+					document.head.appendChild(styleElement);
+					ss = styleElement.sheet as CSSStyleSheet;
+				}
+				var cssString:String = ruleName + " {"
+				for (var p:String in values)
+				{
+					var value:Object = values[p];
+				    if (typeof(value) === 'function') continue;
+					cssString += p + ": ";
+					if (typeof(value) == 'number') {
+                    	if (colorStyles[p])
+                        	value = CSSUtils.attributeFromColor(value as uint);
+                    	else
+                        	value = value.toString() + 'px';
+                	}
+                	else if (p == 'backgroundImage') {
+                    	if (p.indexOf('url') !== 0)
+                        	value = 'url(' + value + ')';
+                	}
+					cssString += value + ";";
+					
+				}
+				cssString += "}";
+				ss.insertRule(cssString, ss.cssRules.length);
+			}
         }
+		
+		COMPILE::JS
+		private var ss:CSSStyleSheet;
         
         /**
          *  A map of inheriting styles