flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - Fixes issues presenting scrolled content (vertical only).
Date Wed, 03 Jun 2015 20:15:07 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 67a1f8ee3 -> 01a641514


Fixes issues presenting scrolled content (vertical only).


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

Branch: refs/heads/develop
Commit: 01a641514b3d77a2f5c39c1d317bb65c3ecd2ae7
Parents: 67a1f8e
Author: Peter Ent <pent@apache.org>
Authored: Wed Jun 3 16:14:55 2015 -0400
Committer: Peter Ent <pent@apache.org>
Committed: Wed Jun 3 16:14:55 2015 -0400

----------------------------------------------------------------------
 .../src/org/apache/flex/html/beads/ListView.as  |   4 +-
 .../flex/html/beads/ScrollingContainerView.as   | 102 ++++---
 .../html/beads/layouts/BasicScrollingLayout.as  |  26 +-
 .../flex/html/beads/layouts/VScrollBarLayout.as |  17 +-
 .../beads/layouts/VerticalScrollingLayout.as    | 281 +++++++++++++++----
 .../flex/html/supportClasses/ScrollBar.as       |   3 +-
 6 files changed, 335 insertions(+), 98 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/01a64151/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ListView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ListView.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ListView.as
index e35e87f..86ea70d 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ListView.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ListView.as
@@ -262,7 +262,9 @@ package org.apache.flex.html.beads
 			vsbm.stepSize = 1;
 			vsbm.value = 0;
 			vsb.model = vsbm;
-			vsb.width = 16;
+			vsb.x = IUIBase(_strand).width - 16;
+			vsb.y = 0;
+			vsb.setWidthAndHeight(16, IUIBase(_strand).height, true);
             IParent(_strand).addElement(vsb);
 			return vsb;
 		}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/01a64151/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ScrollingContainerView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ScrollingContainerView.as
b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ScrollingContainerView.as
index ca702ee..a859b07 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ScrollingContainerView.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ScrollingContainerView.as
@@ -20,6 +20,7 @@ package org.apache.flex.html.beads
 {
 	
 	import org.apache.flex.core.BeadViewBase;
+	import org.apache.flex.core.ContainerBase;
 	import org.apache.flex.core.IBead;
 	import org.apache.flex.core.IBeadLayout;
 	import org.apache.flex.core.IBeadView;
@@ -29,6 +30,7 @@ package org.apache.flex.html.beads
 	import org.apache.flex.core.IStrand;
 	import org.apache.flex.core.IUIBase;
 	import org.apache.flex.core.UIBase;
+	import org.apache.flex.core.UIMetrics;
 	import org.apache.flex.core.ValuesManager;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.html.Container;
@@ -36,6 +38,7 @@ package org.apache.flex.html.beads
 	import org.apache.flex.html.supportClasses.Border;
 	import org.apache.flex.html.supportClasses.ContainerContentArea;
 	import org.apache.flex.html.supportClasses.ScrollBar;
+	import org.apache.flex.utils.BeadMetrics;
 	
     /**
      *  The ContainerView class is the default view for
@@ -107,6 +110,13 @@ package org.apache.flex.html.beads
 		{
 			super.strand = value;
             var host:UIBase = value as UIBase;
+			
+			actualParent = new ContainerContentArea();
+			actualParent.className = "ActualParent";
+			host.addElement(actualParent, false);
+			ContainerBase(host).setActualParent(actualParent);
+			
+			host.addEventListener("beadsAdded", changeHandler);
             
             if (host.isWidthSizedToContent() && host.isHeightSizedToContent())
             {
@@ -132,12 +142,12 @@ package org.apache.flex.html.beads
                 // parent won't kick off any other event in the child
                 if (!isNaN(host.explicitWidth) && !isNaN(host.explicitHeight))
                 {
-                    if (host.numChildren > 0)
-                        changeHandler(null);
-                    else
+                    if (host.numChildren == 0)
                         host.addEventListener("childrenAdded", changeHandler);
                 }
             }
+			
+			displayBackgroundAndBorder(host);
         }
         
         private function sizeChangeHandler(event:Event):void
@@ -146,11 +156,16 @@ package org.apache.flex.html.beads
             host.addEventListener("childrenAdded", changeHandler);
             host.addEventListener("layoutNeeded", changeHandler);
             host.addEventListener("itemsCreated", changeHandler);
-            changeHandler(event);
         }
+		
+		private var inChangeHandler:Boolean = false;
 
         private function changeHandler(event:Event):void
         {
+			if (inChangeHandler) return;
+			
+			inChangeHandler = true;
+			
             var host:UIBase = _strand as UIBase;
             if (layout == null)
             {
@@ -165,37 +180,19 @@ package org.apache.flex.html.beads
                     }
                 }
             }
-            
-            if (host.numChildren > 0)
-            {
-                actualParent = host.getChildAt(0) as UIBase;   
-            }
+			
+			var metrics:UIMetrics = BeadMetrics.getMetrics(host);
+			
+			actualParent.x = metrics.left;
+			actualParent.y = metrics.top;
+			actualParent.width = host.width - metrics.left - metrics.right;
+			actualParent.height = host.height - metrics.top -metrics.bottom;
+			// note that adding a scrollbar will go against the host's right
+			// edge and be separated from the actualParent by padding-right
         
             layout.layout();
-            
-			var backgroundColor:Object = ValuesManager.valuesImpl.getValue(host, "background-color");
-			var backgroundImage:Object = ValuesManager.valuesImpl.getValue(host, "background-image");
-			if (backgroundColor != null || backgroundImage != null)
-			{
-				if (host.getBeadByType(IBackgroundBead) == null)
-                    host.addBead(new (ValuesManager.valuesImpl.getValue(host, "iBackgroundBead"))
as IBead);					
-			}
 			
-			var borderStyle:String;
-			var borderStyles:Object = ValuesManager.valuesImpl.getValue(host, "border");
-			if (borderStyles is Array)
-			{
-				borderStyle = borderStyles[1];
-			}
-			if (borderStyle == null)
-			{
-				borderStyle = ValuesManager.valuesImpl.getValue(host, "border-style") as String;
-			}
-			if (borderStyle != null && borderStyle != "none")
-			{
-				if (host.getBeadByType(IBorderBead) == null)
-                    host.addBead(new (ValuesManager.valuesImpl.getValue(host, "iBorderBead"))
as IBead);	
-			}
+			inChangeHandler = false;
 		}
 		
         /**
@@ -276,7 +273,10 @@ package org.apache.flex.html.beads
             var vsb:ScrollBar;
             vsb = new ScrollBar();
             vsb.model = _vScrollBarModel;
-            vsb.width = 16;
+			// pin to right side by default
+			vsb.x = IUIBase(_strand).width - 16;
+			vsb.y = 0;
+			vsb.setWidthAndHeight(16, IUIBase(_strand).height, true);
             IParent(_strand).addElement(vsb, false);
             return vsb;
         }
@@ -315,7 +315,41 @@ package org.apache.flex.html.beads
             return _vScrollBarModel.maximum - 
                 _vScrollBarModel.pageSize;
         }
-        
+		
+		/**
+		 *  Sets up the border and background beads if necessary
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		protected function displayBackgroundAndBorder(host:UIBase) : void
+		{
+			var backgroundColor:Object = ValuesManager.valuesImpl.getValue(host, "background-color");
+			var backgroundImage:Object = ValuesManager.valuesImpl.getValue(host, "background-image");
+			if (backgroundColor != null || backgroundImage != null)
+			{
+				if (host.getBeadByType(IBackgroundBead) == null)
+					host.addBead(new (ValuesManager.valuesImpl.getValue(host, "iBackgroundBead")) as IBead);
				
+			}
+			
+			var borderStyle:String;
+			var borderStyles:Object = ValuesManager.valuesImpl.getValue(host, "border");
+			if (borderStyles is Array)
+			{
+				borderStyle = borderStyles[1];
+			}
+			if (borderStyle == null)
+			{
+				borderStyle = ValuesManager.valuesImpl.getValue(host, "border-style") as String;
+			}
+			if (borderStyle != null && borderStyle != "none")
+			{
+				if (host.getBeadByType(IBorderBead) == null)
+					host.addBead(new (ValuesManager.valuesImpl.getValue(host, "iBorderBead")) as IBead);

+			}
+		}
     
     }
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/01a64151/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/BasicScrollingLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/BasicScrollingLayout.as
b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/BasicScrollingLayout.as
index c432985..bd440da 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/BasicScrollingLayout.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/BasicScrollingLayout.as
@@ -112,7 +112,9 @@ package org.apache.flex.html.beads.layouts
             }
             contentView.x = (border) ? borderModel.offsets.left : 0;
             contentView.y = (border) ? borderModel.offsets.top : 0;
-			DisplayObject(contentView).scrollRect = new Rectangle(0,0,contentView.width,contentView.height);
+			if (DisplayObject(contentView).scrollRect == null) {
+				DisplayObject(contentView).scrollRect = new Rectangle(0,0,contentView.width,contentView.height);
+			}
             
             var w:Number = contentView.width;
             var h:Number = contentView.height;
@@ -179,7 +181,11 @@ package org.apache.flex.html.beads.layouts
 			}
             if (yy > contentView.height)
             {
-                vScrollBar = layoutParent.vScrollBar;
+				if (vScrollBar == null) {
+					vScrollBar = layoutParent.vScrollBar;
+					vScrollBar.addEventListener("scroll", scrollHandler);
+					contentView.width -= vScrollBar.width;
+				}
                 if (ilcv)
                     ilcv.setWidth(contentView.width - vScrollBar.width);
                 else
@@ -188,12 +194,14 @@ package org.apache.flex.html.beads.layouts
                 IScrollBarModel(vScrollBar.model).pageSize = contentView.height;
                 IScrollBarModel(vScrollBar.model).pageStepSize = contentView.height;
                 vScrollBar.visible = true;
-                vScrollBar.height = contentView.height;
-                vScrollBar.y = contentView.y;
-                vScrollBar.x = contentView.width;
                 var vpos:Number = IScrollBarModel(vScrollBar.model).value;
-                DisplayObject(contentView).scrollRect = new Rectangle(0, vpos, contentView.width,
vpos + contentView.height);
-                vScrollBar.addEventListener("scroll", scrollHandler);
+				if (DisplayObject(contentView).scrollRect == null) {
+					var rect:Rectangle = new Rectangle(0, 0, contentView.width, contentView.height);
+					DisplayObject(contentView).scrollRect = rect;
+				}
+				rect = DisplayObject(contentView).scrollRect;
+				rect.y = vpos;
+				DisplayObject(contentView).scrollRect = rect;
             }
             else if (vScrollBar)
             {
@@ -209,7 +217,9 @@ package org.apache.flex.html.beads.layouts
             var contentView:IParentIUIBase = layoutParent.contentView;
             
             var vpos:Number = IScrollBarModel(vScrollBar.model).value;
-            DisplayObject(contentView).scrollRect = new Rectangle(0, vpos, contentView.width,
vpos + contentView.height);
+			var rect:Rectangle = DisplayObject(contentView).scrollRect;
+			rect.y = vpos;
+			DisplayObject(contentView).scrollRect = rect;
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/01a64151/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VScrollBarLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VScrollBarLayout.as
b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VScrollBarLayout.as
index 6d299eb..081208c 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VScrollBarLayout.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VScrollBarLayout.as
@@ -23,9 +23,11 @@ package org.apache.flex.html.beads.layouts
 	import org.apache.flex.core.IBeadLayout;
 	import org.apache.flex.core.IScrollBarModel;
 	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.UIMetrics;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.IEventDispatcher;
 	import org.apache.flex.html.beads.IScrollBarView;
+	import org.apache.flex.utils.BeadMetrics;
 
     /**
      *  The VScrollBarLayout class is a layout
@@ -70,7 +72,7 @@ package org.apache.flex.html.beads.layouts
 			_strand = value;
 			sbView = _strand.getBeadByType(IScrollBarView) as IScrollBarView;
 		}
-	
+			
         /**
          * @copy org.apache.flex.core.IBeadLayout#layout
          */
@@ -78,8 +80,10 @@ package org.apache.flex.html.beads.layouts
 		{
             if (!sbModel)
                 sbModel = _strand.getBeadByType(IScrollBarModel) as IScrollBarModel
+					
+			var metrics:UIMetrics = BeadMetrics.getMetrics(_strand);
                     
-			var h:Number = DisplayObject(_strand).height;
+			var h:Number = DisplayObject(_strand).height + metrics.top + metrics.bottom;
 			var increment:DisplayObject = sbView.increment;
 			var decrement:DisplayObject = sbView.decrement;
 			var track:DisplayObject = sbView.track;
@@ -87,8 +91,14 @@ package org.apache.flex.html.beads.layouts
 			
 			decrement.x = 0;
 			decrement.y = 0;
+			decrement.width = DisplayObject(_strand).width;
+			decrement.height = decrement.width;
+			
 			increment.x = 0;
-			increment.y = h - increment.height;
+			increment.width = DisplayObject(_strand).width;
+			increment.height = increment.width;
+			increment.y = h - increment.height - 1;
+
 			track.x = 0;
 			track.y = decrement.height;
 			track.height = increment.y - decrement.height;
@@ -102,6 +112,7 @@ package org.apache.flex.html.beads.layouts
 			{
 				thumb.visible = false;
 			}
+			
             return true;
 		}
 						

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/01a64151/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.as
b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.as
index 2c6116c..91f3f7c 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.as
@@ -23,13 +23,14 @@ package org.apache.flex.html.beads.layouts
 	
 	import org.apache.flex.core.IBeadLayout;
 	import org.apache.flex.core.IBorderModel;
-    import org.apache.flex.core.ILayoutChild;
+	import org.apache.flex.core.ILayoutChild;
 	import org.apache.flex.core.ILayoutParent;
 	import org.apache.flex.core.IParentIUIBase;
 	import org.apache.flex.core.IScrollBarModel;
 	import org.apache.flex.core.IScrollingLayoutParent;
 	import org.apache.flex.core.IStrand;
 	import org.apache.flex.core.IUIBase;
+	import org.apache.flex.core.ValuesManager;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.IEventDispatcher;
 	import org.apache.flex.html.supportClasses.Border;
@@ -61,9 +62,12 @@ package org.apache.flex.html.beads.layouts
 		{
 		}
         
-        private var vScrollBar:ScrollBar;	
-
-		private var _strand:IStrand;
+        private var vScrollBar:ScrollBar;
+		
+		// the strand/host container is also an ILayoutChild because
+		// can have its size dictated by the host's parent which is
+		// important to know for layout optimization
+		private var host:ILayoutChild;
 		
         /**
          *  @copy org.apache.flex.core.IBead#strand
@@ -75,7 +79,7 @@ package org.apache.flex.html.beads.layouts
          */
 		public function set strand(value:IStrand):void
 		{
-			_strand = value;
+			host = value as ILayoutChild; 
 		}
 		
         /**
@@ -83,80 +87,255 @@ package org.apache.flex.html.beads.layouts
          */
 		public function layout():Boolean
 		{            
-            var layoutParent:IScrollingLayoutParent = 
-                _strand.getBeadByType(IScrollingLayoutParent) as IScrollingLayoutParent;
-            var contentView:IParentIUIBase = layoutParent.contentView as IParentIUIBase;
-            
-			var border:Border = layoutParent.border;
-   			var borderModel:IBorderModel;
-            if (border)
-                borderModel = border.model as IBorderModel;
-            var ww:Number = layoutParent.resizableView.width;
-            var hh:Number = layoutParent.resizableView.height;
-            if (border)
-            {
-                border.width = ww;
-                border.height = hh;
-            }
-            
-            var ilc:ILayoutChild = contentView as ILayoutChild;
-            if (ilc)
-            {
-                ilc.setWidth(ww - ((border) ? borderModel.offsets.left + borderModel.offsets.right
: 0));
-                ilc.setHeight(hh - ((border) ? borderModel.offsets.top - borderModel.offsets.bottom
: 0));                
-            }
-            else
-            {
-                contentView.width = ww - ((border) ? borderModel.offsets.left + borderModel.offsets.right
: 0);
-                contentView.height = hh - ((border) ? borderModel.offsets.top - borderModel.offsets.bottom
: 0);                
-            }
-			contentView.x = (border) ? borderModel.offsets.left : 0;
-			contentView.y = (border) ? borderModel.offsets.top : 0;
+			var layoutParent:IScrollingLayoutParent = host.getBeadByType(IScrollingLayoutParent) as
IScrollingLayoutParent;
+			var contentView:IParentIUIBase = layoutParent ? layoutParent.contentView : IParentIUIBase(host);
 			
 			var n:int = contentView.numElements;
-			var yy:Number = 0;
-			
+			var hasHorizontalFlex:Boolean;
+			var hostSizedToContent:Boolean = host.isWidthSizedToContent();
+			var flexibleHorizontalMargins:Array = [];
+			var ilc:ILayoutChild;
+			var marginLeft:Object;
+			var marginRight:Object;
+			var marginTop:Object;
+			var marginBottom:Object;
+			var margin:Object;
+			var maxWidth:Number = 0;
+			// asking for contentView.width can result in infinite loop if host isn't sized already
+			var w:Number = hostSizedToContent ? 0 : contentView.width;
 			for (var i:int = 0; i < n; i++)
 			{
-				var ir:IUIBase = contentView.getElementAt(i) as IUIBase;
-				if (ir == null || !ir.visible) continue;
-				ir.y = yy;
-				ir.width = contentView.width;
-				yy += ir.height;			
+				var child:IUIBase = contentView.getElementAt(i) as IUIBase;
+				if (child == null || !child.visible) continue;
+				ilc = child as ILayoutChild;
+				var left:Number = ValuesManager.valuesImpl.getValue(child, "left");
+				var right:Number = ValuesManager.valuesImpl.getValue(child, "right");
+				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 lastmb:Number;
+				mt = Number(marginTop);
+				if (isNaN(mt))
+					mt = 0;
+				mb = Number(marginBottom);
+				if (isNaN(mb))
+					mb = 0;
+				var yy:Number;
+				if (i == 0)
+					child.y = mt;
+				else
+					child.y = yy + Math.max(mt, lastmb);
+				if (ilc)
+				{
+					if (!isNaN(ilc.percentHeight))
+						ilc.setHeight(contentView.height * ilc.percentHeight / 100, !isNaN(ilc.percentWidth));
+				}
+				lastmb = mb;
+				var marginObject:Object = {};
+				flexibleHorizontalMargins[i] = marginObject;
+				if (marginLeft == "auto")
+				{
+					ml = 0;
+					marginObject.marginLeft = marginLeft;
+					hasHorizontalFlex = true;
+				}
+				else
+				{
+					ml = Number(marginLeft);
+					if (isNaN(ml))
+					{
+						ml = 0;
+						marginObject.marginLeft = marginLeft;
+					}
+					else
+						marginObject.marginLeft = ml;
+				}
+				if (marginRight == "auto")
+				{
+					mr = 0;
+					marginObject.marginRight = marginRight;
+					hasHorizontalFlex = true;
+				}
+				else
+				{
+					mr = Number(marginRight);
+					if (isNaN(mr))
+					{
+						mr = 0;
+						marginObject.marginRight = marginRight;
+					}
+					else
+						marginObject.marginRight = mr;
+				}
+				if (!hostSizedToContent)
+				{
+					// if host is sized by parent,
+					// we can position and size children horizontally now
+					setPositionAndWidth(child, left, ml, right, mr, w);
+				}
+				else
+				{
+					if (!isNaN(left))
+					{
+						ml = left;
+						marginObject.left = ml;
+					}
+					if (!isNaN(right))
+					{
+						mr = right;
+						marginObject.right = mr;
+					}
+					maxWidth = Math.max(maxWidth, ml + child.width + mr);                    
+				}
+				yy = child.y + child.height;
+			}
+			if (hostSizedToContent)
+			{
+				ILayoutChild(contentView).setWidth(maxWidth, true);
+				if (host.isHeightSizedToContent())
+					ILayoutChild(contentView).setHeight(yy, true);
+				for (i = 0; i < n; i++)
+				{
+					child = contentView.getElementAt(i) as IUIBase;
+					if (child == null || !child.visible) continue;
+					var obj:Object = flexibleHorizontalMargins[i];
+					setPositionAndWidth(child, obj.left, obj.marginLeft,
+						obj.right, obj.marginRight, maxWidth);
+				}
+			}
+			if (hasHorizontalFlex)
+			{
+				for (i = 0; i < n; i++)
+				{
+					child = contentView.getElementAt(i) as IUIBase;
+					if (child == null || !child.visible) continue;
+					ilc = child as ILayoutChild;
+					obj = flexibleHorizontalMargins[i];
+					if (hasHorizontalFlex)
+					{
+						if (obj.marginLeft == "auto" && obj.marginRight == "auto")
+							child.x = maxWidth - child.width / 2;
+						else if (obj.marginLeft == "auto")
+							child.x = maxWidth - child.width - obj.marginRight;
+					}
+				}
 			}
 			if (yy > contentView.height)
 			{
-				vScrollBar = layoutParent.vScrollBar;
+				if (vScrollBar == null) {
+					vScrollBar = layoutParent.vScrollBar;
+					vScrollBar.addEventListener("scroll", scrollHandler);
+					contentView.width -= vScrollBar.width;
+				}
                 if (ilc)
     				ilc.setWidth(contentView.width - vScrollBar.width);
-                else
-                    contentView.width -= vScrollBar.width;
 				IScrollBarModel(vScrollBar.model).maximum = yy;
 				IScrollBarModel(vScrollBar.model).pageSize = contentView.height;
 				IScrollBarModel(vScrollBar.model).pageStepSize = contentView.height;
 				vScrollBar.visible = true;
-				vScrollBar.height = contentView.height;
-				vScrollBar.y = contentView.y;
-				vScrollBar.x = contentView.width;
                 var vpos:Number = IScrollBarModel(vScrollBar.model).value;
-                DisplayObject(contentView).scrollRect = new Rectangle(0, vpos, contentView.width,
vpos + contentView.height);
-                vScrollBar.addEventListener("scroll", scrollHandler);
+				if (DisplayObject(contentView).scrollRect == null) {
+					var rect:Rectangle = new Rectangle(0, 0, contentView.width, contentView.height);
+					DisplayObject(contentView).scrollRect = rect;
+				}
+				rect = DisplayObject(contentView).scrollRect;
+				rect.y = vpos;
+                DisplayObject(contentView).scrollRect = rect;//new Rectangle(0, vpos, contentView.width,
vpos + contentView.height);
 			}
 			else if (vScrollBar)
 			{
                 DisplayObject(contentView).scrollRect = null;
 				vScrollBar.visible = false;
 			}
+			
+			
 			return true;
 		}
+		
+		private function setPositionAndWidth(child:IUIBase, left:Number, ml:Number,
+											 right:Number, mr:Number, w:Number):void
+		{
+			var widthSet:Boolean = false;
+			
+			var ww:Number = w;
+			var ilc:ILayoutChild = child as ILayoutChild;
+			if (!isNaN(left))
+			{
+				child.x = left + ml;
+				ww -= left + ml;
+			}
+			else 
+			{
+				child.x = ml;
+				ww -= ml;
+			}
+			if (!isNaN(right))
+			{
+				if (!isNaN(left))
+				{
+					if (ilc)
+						ilc.setWidth(ww - right - mr, true);
+					else
+					{
+						child.width = ww - right - mr;
+						widthSet = true;
+					}
+				}
+				else
+					child.x = w - right - mr - child.width;
+			}
+			if (ilc)
+			{
+				if (!isNaN(ilc.percentWidth))
+					ilc.setWidth(w * ilc.percentWidth / 100, true);
+				else {
+					child.width = ww;
+					widthSet = true;
+				}
+			}
+			if (!widthSet)
+				child.dispatchEvent(new Event("sizeChanged"));
+		}
 
         private function scrollHandler(event:Event):void
         {
-			var layoutParent:ILayoutParent = _strand.getBeadByType(ILayoutParent) as ILayoutParent;
+			var layoutParent:ILayoutParent = host.getBeadByType(ILayoutParent) as ILayoutParent;
 			var contentView:IParentIUIBase = layoutParent.contentView;
 			
             var vpos:Number = IScrollBarModel(vScrollBar.model).value;
-			DisplayObject(contentView).scrollRect = new Rectangle(0, vpos, contentView.width, vpos
+ contentView.height);
+			var rect:Rectangle = DisplayObject(contentView).scrollRect;
+			rect.y = vpos;
+			DisplayObject(contentView).scrollRect = rect;//new Rectangle(0, vpos, contentView.width,
vpos + contentView.height);
         }
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/01a64151/frameworks/projects/HTML/as/src/org/apache/flex/html/supportClasses/ScrollBar.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/supportClasses/ScrollBar.as
b/frameworks/projects/HTML/as/src/org/apache/flex/html/supportClasses/ScrollBar.as
index 5cf725d..3aa2571 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/supportClasses/ScrollBar.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/supportClasses/ScrollBar.as
@@ -19,6 +19,7 @@
 package org.apache.flex.html.supportClasses
 {
 	import org.apache.flex.core.UIBase;
+	import org.apache.flex.core.IChrome;
 	
 	/**
 	 *  The ScrollBar class represents either a vertical or horizontal control
@@ -30,7 +31,7 @@ package org.apache.flex.html.supportClasses
 	 *  @playerversion AIR 2.6
 	 *  @productversion FlexJS 0.0
 	 */
-	public class ScrollBar extends UIBase
+	public class ScrollBar extends UIBase implements IChrome
 	{
 		/**
 		 *  constructor.


Mime
View raw message