flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [1/3] git commit: [flex-asjs] [refs/heads/develop] - refactor to get style precedence correct
Date Thu, 30 Jul 2015 19:26:35 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 9c5d176a3 -> 364509efc


refactor to get style precedence correct


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

Branch: refs/heads/develop
Commit: 18b61d4da083c6396cd85898473cfc4db5276e2b
Parents: 9c5d176
Author: Alex Harui <aharui@apache.org>
Authored: Thu Jul 30 12:25:21 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Thu Jul 30 12:25:21 2015 -0700

----------------------------------------------------------------------
 .../as/src/org/apache/flex/utils/BeadMetrics.as | 117 ++++++-------------
 1 file changed, 38 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/18b61d4d/frameworks/projects/Core/as/src/org/apache/flex/utils/BeadMetrics.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/BeadMetrics.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/BeadMetrics.as
index 2902caf..bd87470 100644
--- a/frameworks/projects/Core/as/src/org/apache/flex/utils/BeadMetrics.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/utils/BeadMetrics.as
@@ -47,10 +47,20 @@ public class BeadMetrics
      */
 	public static function getMetrics(object:Object) : UIMetrics
 	{
-		var borderThickness:Object = ValuesManager.valuesImpl.getValue(object,"border-thickness");
+		var borderThickness:Object = ValuesManager.valuesImpl.getValue(object,"border-width");
 		var borderOffset:Number;
-		if( borderThickness == null ) {
-			borderOffset = 0;
+		if( borderThickness == null ) 
+        {
+            borderThickness = ValuesManager.valuesImpl.getValue(object,"border");
+            if (borderThickness != null)
+            {
+                if (borderThickness is Array)
+                    borderOffset = CSSUtils.toNumber(borderThickness[0], object.width);
+                else
+                    borderOffset = CSSUtils.toNumber(borderThickness as String, object.width);
+            }
+            else
+                borderOffset = 0;
 		}
 		else {
 			borderOffset = Number(borderThickness);
@@ -63,41 +73,14 @@ public class BeadMetrics
 		var paddingBottom:Object;
 		
 		var padding:Object = ValuesManager.valuesImpl.getValue(object, "padding");
-		if (padding is Array)
-		{
-			if (padding.length == 1)
-				paddingLeft = paddingTop = padding[0];
-			else if (padding.length <= 3)
-			{
-				paddingTop = padding[0];
-				paddingLeft = padding[1];
-				paddingBottom = padding[0];
-				paddingRight = padding[1];
-			}
-			else if (padding.length == 4)
-			{
-				paddingTop = padding[0];
-				paddingLeft = padding[1];
-				paddingBottom = padding[2];
-				paddingRight = padding[3];					
-			}
-		}
-		else if (padding == null)
-		{
-			paddingLeft = ValuesManager.valuesImpl.getValue(object, "padding-left");
-			paddingTop = ValuesManager.valuesImpl.getValue(object, "padding-top");
-			paddingRight = ValuesManager.valuesImpl.getValue(object, "padding-right");
-			paddingBottom = ValuesManager.valuesImpl.getValue(object, "padding-bottom");
-		}
-		else
-		{
-			paddingLeft = paddingTop = padding;
-			paddingRight = paddingBottom = padding;
-		}
-		var pl:Number = Number(paddingLeft);
-		var pt:Number = Number(paddingTop);
-		var pr:Number = Number(paddingRight);
-		var pb:Number = Number(paddingBottom);
+		paddingLeft = ValuesManager.valuesImpl.getValue(object, "padding-left");
+		paddingTop = ValuesManager.valuesImpl.getValue(object, "padding-top");
+		paddingRight = ValuesManager.valuesImpl.getValue(object, "padding-right");
+		paddingBottom = ValuesManager.valuesImpl.getValue(object, "padding-bottom");
+		var pl:Number = CSSUtils.getLeftValue(paddingLeft, padding, object.width);
+		var pt:Number = CSSUtils.getTopValue(paddingTop, padding, object.height);
+		var pr:Number = CSSUtils.getRightValue(paddingRight, padding, object.width);
+		var pb:Number = CSSUtils.getBottomValue(paddingBottom, padding, object.height);
 		
 		var marginLeft:Object;
 		var marginRight:Object;
@@ -105,35 +88,10 @@ public class BeadMetrics
 		var marginBottom:Object;
 		var margin:Object;
 		margin = ValuesManager.valuesImpl.getValue(object, "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(object, "margin-left");
-			marginTop = ValuesManager.valuesImpl.getValue(object, "margin-top");
-			marginRight = ValuesManager.valuesImpl.getValue(object, "margin-right");
-			marginBottom = ValuesManager.valuesImpl.getValue(object, "margin-bottom");
-		}
-		else
-		{
-			marginLeft = marginTop = marginBottom = marginRight = margin;
-		}
+		marginLeft = ValuesManager.valuesImpl.getValue(object, "margin-left");
+		marginTop = ValuesManager.valuesImpl.getValue(object, "margin-top");
+		marginRight = ValuesManager.valuesImpl.getValue(object, "margin-right");
+		marginBottom = ValuesManager.valuesImpl.getValue(object, "margin-bottom");
 		var ml:Number;
 		var mr:Number;
 		var mt:Number;
@@ -142,26 +100,27 @@ public class BeadMetrics
 		if (marginLeft == "auto")
 			ml = 0;
 		else
-		{
-			ml = Number(marginLeft);
-			if (isNaN(ml))
-				ml = 0;
-		}
+        {
+            ml = CSSUtils.getLeftValue(marginLeft, margin, object.width);
+            if (isNaN(ml))
+                ml = 0;
+        }
 		if (marginRight == "auto")
 			mr = 0;
 		else
-		{
-			mr = Number(marginRight);
-			if (isNaN(mr))
-				mr = 0;
-		}
-		mt = Number(marginTop);
+        {
+            mr = CSSUtils.getRightValue(marginRight, margin, object.width);
+            if (isNaN(mr))
+                mr = 0;
+        }
+		mt = CSSUtils.getTopValue(marginTop, margin, object.height);
 		if (isNaN(mt))
 			mt = 0;
-		mb = Number(marginBottom);
+        mb = CSSUtils.getBottomValue(marginBottom, margin, object.height);
 		if (isNaN(mb))
 			mb = 0;
 		
+        borderOffset *= 2; // border on each side
 		var result:UIMetrics = new UIMetrics();
 		result.top = borderOffset + pt;
 		result.left = borderOffset + pl;


Mime
View raw message