flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [2/3] git commit: [flex-asjs] [refs/heads/develop] - fix margin handling
Date Fri, 04 Sep 2015 18:11:25 GMT
fix margin handling


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

Branch: refs/heads/develop
Commit: 02c3efbf2c87ce243ac1dd4ba1bd72ab9e8c257f
Parents: d3197d6
Author: Alex Harui <aharui@apache.org>
Authored: Fri Sep 4 11:10:59 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Sep 4 11:11:42 2015 -0700

----------------------------------------------------------------------
 .../flex/html/beads/layouts/HorizontalLayout.as | 65 ++++----------------
 1 file changed, 13 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/02c3efbf/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalLayout.as
b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalLayout.as
index 0ebdc52..986359e 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalLayout.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalLayout.as
@@ -30,6 +30,7 @@ package org.apache.flex.html.beads.layouts
 	import org.apache.flex.events.IEventDispatcher;
 	import org.apache.flex.geom.Rectangle;
 	import org.apache.flex.utils.dbg.DOMPathUtil;
+    import org.apache.flex.utils.CSSUtils;
     import org.apache.flex.utils.CSSContainerUtils;
 
     /**
@@ -94,8 +95,9 @@ package org.apache.flex.html.beads.layouts
 			var marginBottom:Object;
 			var margin:Object;
 			var maxHeight:Number = 0;
-            // asking for contentView.width can result in infinite loop if host isn't sized
already
+            // asking for contentView.height can result in infinite loop if host isn't sized
already
             var h:Number = hostSizedToContent ? 0 : contentView.height;
+            var w:Number = contentView.width;
 			var verticalMargins:Array = [];
 			
 			for (var i:int = 0; i < n; i++)
@@ -104,63 +106,22 @@ package org.apache.flex.html.beads.layouts
 				if (child == null || !child.visible) continue;
                 var top:Number = ValuesManager.valuesImpl.getValue(child, "top");
                 var bottom:Number = ValuesManager.valuesImpl.getValue(child, "bottom");
+                margin = ValuesManager.valuesImpl.getValue(child, "margin");
+                marginLeft = ValuesManager.valuesImpl.getValue(child, "margin-left");
+                marginTop = ValuesManager.valuesImpl.getValue(child, "margin-top");
+                marginRight = ValuesManager.valuesImpl.getValue(child, "margin-right");
+                marginBottom = ValuesManager.valuesImpl.getValue(child, "margin-bottom");
+                var ml:Number = CSSUtils.getLeftValue(marginLeft, margin, w);
+                var mr:Number = CSSUtils.getRightValue(marginRight, margin, w);
+                var mt:Number = CSSUtils.getTopValue(marginTop, margin, h);
+                var mb:Number = CSSUtils.getBottomValue(marginBottom, margin, h);
+                
                 ilc = child as ILayoutChild;
-				margin = ValuesManager.valuesImpl.getValue(child, "margin");
-				if (margin is Array)
-				{
-					if (margin.length == 1)
-						marginLeft = marginTop = marginRight = marginBottom = margin[0];
-					else if (margin.length <= 3)
-					{
-						marginLeft = marginRight = margin[1];
-						marginTop = marginBottom = margin[0];
-					}
-					else if (margin.length == 4)
-					{
-						marginLeft = margin[3];
-						marginBottom = margin[2];
-						marginRight = margin[1];
-						marginTop = margin[0];					
-					}
-				}
-				else if (margin == null)
-				{
-					marginLeft = ValuesManager.valuesImpl.getValue(child, "margin-left");
-					marginTop = ValuesManager.valuesImpl.getValue(child, "margin-top");
-					marginRight = ValuesManager.valuesImpl.getValue(child, "margin-right");
-					marginBottom = ValuesManager.valuesImpl.getValue(child, "margin-bottom");
-				}
-				else
-				{
-					marginLeft = marginTop = marginBottom = marginRight = margin;
-				}
-				var ml:Number;
-				var mr:Number;
-				var mt:Number;
-				var mb:Number;
 				var lastmr:Number;
 				if (marginLeft == "auto")
 					ml = 0;
-				else
-				{
-					ml = Number(marginLeft);
-					if (isNaN(ml))
-						ml = 0;
-				}
 				if (marginRight == "auto")
 					mr = 0;
-				else
-				{
-					mr = Number(marginRight);
-					if (isNaN(mr))
-						mr = 0;
-				}
-				mt = Number(marginTop);
-				if (isNaN(mt))
-					mt = 0;
-				mb = Number(marginBottom);
-				if (isNaN(mb))
-					mb = 0;
                 var xx:Number;
                 if (i == 0)
                 {


Mime
View raw message