flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [2/2] git commit: [flex-asjs] [refs/heads/develop] - update the way layout works
Date Mon, 18 May 2015 17:44:53 GMT
update the way layout works


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

Branch: refs/heads/develop
Commit: 3c23b3a1a2882cd13bfccdfa14044e470a12bc20
Parents: 40b5b8c
Author: Alex Harui <aharui@apache.org>
Authored: Mon May 18 10:43:35 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Mon May 18 10:44:42 2015 -0700

----------------------------------------------------------------------
 .../src/productsView/CatalogTitleButtons.mxml   |   1 +
 .../ProductCatalogPanelTitleBarView.mxml        |   4 +-
 .../productsView/ProductCatalogThumbnail.mxml   |   1 +
 .../flex/binding/ApplicationDataBinding.as      |   4 +-
 .../apache/flex/binding/ContainerDataBinding.as |   4 +-
 .../org/apache/flex/charts/beads/ChartView.as   |  16 +-
 .../charts/beads/layouts/ChartBaseLayout.as     |  13 +-
 .../as/src/org/apache/flex/core/Application.as  |   8 +
 .../src/org/apache/flex/core/ContainerBase.as   | 138 +++++++++++++-
 .../as/src/org/apache/flex/core/IBeadLayout.as  |   5 +-
 .../Core/as/src/org/apache/flex/core/UIBase.as  |  16 +-
 .../as/src/org/apache/flex/core/UIButtonBase.as |  20 +-
 .../as/src/org/apache/flex/core/ViewBase.as     |   2 +
 .../apache/flex/utils/MXMLDataInterpreter.as    |  13 +-
 frameworks/projects/HTML/as/defaults.css        |  12 ++
 .../as/src/org/apache/flex/html/Container.as    | 119 +-----------
 .../HTML/as/src/org/apache/flex/html/Label.as   |  15 +-
 .../org/apache/flex/html/beads/ContainerView.as | 173 ++++++++++++-----
 .../src/org/apache/flex/html/beads/ListView.as  |  62 ++++--
 .../src/org/apache/flex/html/beads/PanelView.as |   1 +
 .../org/apache/flex/html/beads/ScrollBarView.as |  30 ++-
 .../flex/html/beads/ScrollingContainerView.as   |  77 +++++++-
 .../flex/html/beads/SolidBackgroundBead.as      |   7 +-
 .../flex/html/beads/layouts/BasicLayout.as      | 170 ++++++++++++-----
 .../html/beads/layouts/BasicScrollingLayout.as  |  19 +-
 .../flex/html/beads/layouts/ButtonBarLayout.as  |  11 +-
 .../flex/html/beads/layouts/HorizontalLayout.as | 190 ++++++++++++-------
 .../beads/layouts/HorizontalScrollingLayout.as  |  15 +-
 .../flex/html/beads/layouts/TileLayout.as       |  28 +--
 .../flex/html/beads/layouts/VScrollBarLayout.as |  18 +-
 .../flex/html/beads/layouts/VerticalLayout.as   | 188 +++++++++++-------
 .../beads/layouts/VerticalScrollingLayout.as    |  18 +-
 .../org/apache/flex/html/beads/DataGridView.as  |   2 +-
 .../flex/html/beads/layouts/DataGridLayout.as   |  15 +-
 .../FlexibleFirstChildHorizontalLayout.as       |  40 ++--
 .../layouts/OneFlexibleChildHorizontalLayout.as |  36 +---
 .../layouts/OneFlexibleChildVerticalLayout.as   |  38 +---
 .../html/beads/layouts/VerticalColumnLayout.as  |  13 +-
 38 files changed, 938 insertions(+), 604 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/examples/FlexJSStore/src/productsView/CatalogTitleButtons.mxml
----------------------------------------------------------------------
diff --git a/examples/FlexJSStore/src/productsView/CatalogTitleButtons.mxml b/examples/FlexJSStore/src/productsView/CatalogTitleButtons.mxml
index 9dbd4c8..5269fc0 100755
--- a/examples/FlexJSStore/src/productsView/CatalogTitleButtons.mxml
+++ b/examples/FlexJSStore/src/productsView/CatalogTitleButtons.mxml
@@ -28,6 +28,7 @@ limitations under the License.
     <js:beads>
         <js:ParentDocumentBead id="pdb" />
         <js:ContainerDataBinding />
+        <js:LayoutChangeNotifier watchedProperty="{viewCart.text}" initialValue="#FFFFFF" />
     </js:beads>
     <fx:Script>
         <![CDATA[

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/examples/FlexJSStore/src/productsView/ProductCatalogPanelTitleBarView.mxml
----------------------------------------------------------------------
diff --git a/examples/FlexJSStore/src/productsView/ProductCatalogPanelTitleBarView.mxml b/examples/FlexJSStore/src/productsView/ProductCatalogPanelTitleBarView.mxml
index b89c7b6..5e82f95 100755
--- a/examples/FlexJSStore/src/productsView/ProductCatalogPanelTitleBarView.mxml
+++ b/examples/FlexJSStore/src/productsView/ProductCatalogPanelTitleBarView.mxml
@@ -38,12 +38,12 @@ limitations under the License.
     <js:beads>
         <js:MXMLBeadViewBaseDataBinding />
         <js:ParentDocumentBead id="pdb" />
-        <js:LayoutChangeNotifier watchedProperty="{titleLabel.height}" />
+        <js:LayoutChangeNotifier watchedProperty="{buttons.width}" />
     </js:beads>
     <js:Label id="titleLabel" text="{ITitleBarModel(model).title}" 
                  />
     <js:CloseButton id="closeButton" click="clickHandler()"
                        visible="{ITitleBarModel(model).showCloseButton}";
                        />
-    <productsView:CatalogTitleButtons />
+    <productsView:CatalogTitleButtons id="buttons" />
 </js:MXMLBeadViewBase>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/examples/FlexJSStore/src/productsView/ProductCatalogThumbnail.mxml
----------------------------------------------------------------------
diff --git a/examples/FlexJSStore/src/productsView/ProductCatalogThumbnail.mxml b/examples/FlexJSStore/src/productsView/ProductCatalogThumbnail.mxml
index 848d202..cabbe81 100755
--- a/examples/FlexJSStore/src/productsView/ProductCatalogThumbnail.mxml
+++ b/examples/FlexJSStore/src/productsView/ProductCatalogThumbnail.mxml
@@ -73,6 +73,7 @@ limitations under the License.
             borderStyles.borderColor = "#CCCCCC";
             //style["dropShadowEnabled"] = true;
             buttons.visible = true;
+            dispatchEvent(new Event("layoutNeeded"));
         }
 
         private function rollOutHandler(event:MouseEvent):void

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/Binding/asjs/src/org/apache/flex/binding/ApplicationDataBinding.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Binding/asjs/src/org/apache/flex/binding/ApplicationDataBinding.as b/frameworks/projects/Binding/asjs/src/org/apache/flex/binding/ApplicationDataBinding.as
index e4379bd..4038645 100644
--- a/frameworks/projects/Binding/asjs/src/org/apache/flex/binding/ApplicationDataBinding.as
+++ b/frameworks/projects/Binding/asjs/src/org/apache/flex/binding/ApplicationDataBinding.as
@@ -150,11 +150,11 @@ package org.apache.flex.binding
                                     if (destObject)
                                     {
                                         cb.destination = destObject;
-                                        _strand.addBead(sb);
+                                        _strand.addBead(cb);
                                     }
                                     else
                                     {
-                                        deferredBindings[binding.destination[0]] = sb;
+                                        deferredBindings[binding.destination[0]] = cb;
                                         IEventDispatcher(_strand).addEventListener("valueChange", deferredBindingsHandler);
                                     }
                                 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/Binding/asjs/src/org/apache/flex/binding/ContainerDataBinding.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Binding/asjs/src/org/apache/flex/binding/ContainerDataBinding.as b/frameworks/projects/Binding/asjs/src/org/apache/flex/binding/ContainerDataBinding.as
index fbe399f..d138d60 100644
--- a/frameworks/projects/Binding/asjs/src/org/apache/flex/binding/ContainerDataBinding.as
+++ b/frameworks/projects/Binding/asjs/src/org/apache/flex/binding/ContainerDataBinding.as
@@ -153,11 +153,11 @@ package org.apache.flex.binding
                                     if (destObject)
                                     {
                                         cb.destination = destObject;
-                                        _strand.addBead(sb);
+                                        _strand.addBead(cb);
                                     }
                                     else
                                     {
-                                        deferredBindings[binding.destination[0]] = sb;
+                                        deferredBindings[binding.destination[0]] = cb;
                                         IEventDispatcher(_strand).addEventListener("valueChange", deferredBindingsHandler);
                                     }
                                 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/ChartView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/ChartView.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/ChartView.as
index 6593d1a..feadcce 100644
--- a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/ChartView.as
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/ChartView.as
@@ -56,9 +56,7 @@ package org.apache.flex.charts.beads
 			super.strand = value;
 			
 			_strand = value;
-			IEventDispatcher(_strand).addEventListener("widthChanged", handleLocalChange);
-			IEventDispatcher(_strand).addEventListener("heightChanged",handleLocalChange);
-			
+            
 			var listModel:ISelectionModel = value.getBeadByType(ISelectionModel) as ISelectionModel;
 			listModel.addEventListener("dataProviderChanged", dataProviderChangeHandler);
 			
@@ -77,15 +75,7 @@ package org.apache.flex.charts.beads
 				vaxis.axisGroup = _verticalAxisGroup;
 				IParent(_strand).addElement(_verticalAxisGroup);
 			}
-			
-			if (_strand.getBeadByType(IBeadLayout) == null)
-			{
-				var layout:IBeadLayout = new (ValuesManager.valuesImpl.getValue(_strand, "iBeadLayout")) as IBeadLayout;
-				_strand.addBead(layout);
-			}
-			
-			handleLocalChange(null);
-			
+						
 			IEventDispatcher(_strand).dispatchEvent( new Event("viewCreated") );
 		}
 		
@@ -118,7 +108,7 @@ package org.apache.flex.charts.beads
 		/**
 		 * @private
 		 */
-		private function handleLocalChange(event:Event):void
+		override protected function layoutList():void
 		{	
 			var widthAdjustment:Number = 0;
 			var heightAdjustment:Number = 0;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/ChartBaseLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/ChartBaseLayout.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/ChartBaseLayout.as
index ef4e9b8..87f288b 100644
--- a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/ChartBaseLayout.as
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/ChartBaseLayout.as
@@ -47,10 +47,6 @@ package org.apache.flex.charts.beads.layouts
 		public function set strand(value:IStrand):void
 		{
 			_strand = value;
-			IEventDispatcher(value).addEventListener("widthChanged", changeHandler);
-			IEventDispatcher(value).addEventListener("childrenAdded", changeHandler);
-			IEventDispatcher(value).addEventListener("itemsCreated", changeHandler);
-			IEventDispatcher(value).addEventListener("layoutNeeded", changeHandler);
 		}
 		
 		/**
@@ -122,12 +118,13 @@ package org.apache.flex.charts.beads.layouts
 			return _chartDataGroup;
 		}
 		
-		/**
-		 * @private
-		 */
-		private function changeHandler(event:Event):void
+        /**
+         * @copy org.apache.flex.core.IBeadLayout#layout
+         */
+		public function layout():Boolean
 		{
 			performLayout();
+            return true;
 		}
 		
 		/**

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/Core/as/src/org/apache/flex/core/Application.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/Application.as b/frameworks/projects/Core/as/src/org/apache/flex/core/Application.as
index a7d0a77..c44a0bb 100644
--- a/frameworks/projects/Core/as/src/org/apache/flex/core/Application.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/Application.as
@@ -147,6 +147,14 @@ package org.apache.flex.core
                 if (isNaN(initialView.explicitHeight))
                     initialView.setHeight(stage.stageHeight);
         	    this.addElement(initialView);
+                var bgColor:Object = ValuesManager.valuesImpl.getValue(this, "background-color");
+                if (bgColor != null)
+                {
+                    var backgroundColor:uint = ValuesManager.valuesImpl.convertColor(bgColor);
+                    graphics.beginFill(backgroundColor);
+                    graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
+                    graphics.endFill();
+                }
                 dispatchEvent(new org.apache.flex.events.Event("viewChanged"));
             }
             dispatchEvent(new org.apache.flex.events.Event("applicationComplete"));

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/Core/as/src/org/apache/flex/core/ContainerBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/ContainerBase.as b/frameworks/projects/Core/as/src/org/apache/flex/core/ContainerBase.as
index daeeae6..f3efca6 100644
--- a/frameworks/projects/Core/as/src/org/apache/flex/core/ContainerBase.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/ContainerBase.as
@@ -18,12 +18,14 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.core
 {
-	import org.apache.flex.states.State;
+	import flash.display.DisplayObject;
+	import flash.display.DisplayObjectContainer;
 	
 	import org.apache.flex.core.IMXMLDocument;
-    import org.apache.flex.core.ValuesManager;
+	import org.apache.flex.core.ValuesManager;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.ValueChangeEvent;
+	import org.apache.flex.states.State;
 	import org.apache.flex.utils.MXMLDataInterpreter;
 
     /**
@@ -72,7 +74,7 @@ package org.apache.flex.core
      *  @playerversion AIR 2.6
      *  @productversion FlexJS 0.0
      */
-	public class ContainerBase extends UIBase implements IMXMLDocument, IStatesObject
+	public class ContainerBase extends UIBase implements IMXMLDocument, IStatesObject, IContainer
 	{
         /**
          *  Constructor.
@@ -85,9 +87,138 @@ package org.apache.flex.core
 		public function ContainerBase()
 		{
 			super();
+            actualParent = this;
 		}
 		
         /**
+         *  False if IChrome children are treated just like
+         *  any other children.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        protected var supportsChromeChildren:Boolean = true;
+        
+        private var actualParent:DisplayObjectContainer;
+        
+        /**
+         *  Set a platform-specific object as the actual parent for 
+         *  children.  This must be public so it can be accessed
+         *  by beads.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function setActualParent(parent:DisplayObjectContainer):void
+        {
+            actualParent = parent;	
+        }
+        
+        /**
+         *  @private
+         */
+        override public function getElementIndex(c:Object):int
+        {
+            if (c is IUIBase)
+                return actualParent.getChildIndex(IUIBase(c).element as DisplayObject);
+            else
+                return actualParent.getChildIndex(c as DisplayObject);
+        }
+        
+        /**
+         *  @private
+         */
+        override public function addElement(c:Object, dispatchEvent:Boolean = true):void
+        {
+            if (c is IUIBase)
+            {
+                if (supportsChromeChildren && c is IChrome) {
+                    addChild(IUIBase(c).element as DisplayObject);
+                    IUIBase(c).addedToParent();
+                }
+                else {
+                    actualParent.addChild(IUIBase(c).element as DisplayObject);
+                    IUIBase(c).addedToParent();
+                }
+            }
+            else {
+                if (supportsChromeChildren && c is IChrome) {
+                    addChild(c as DisplayObject);
+                }
+                else {
+                    actualParent.addChild(c as DisplayObject);
+                }
+            }
+            if (dispatchEvent)
+                this.dispatchEvent(new Event("childrenAdded"));
+        }
+        
+        /**
+         *  @private
+         */
+        override public function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void
+        {
+            if (c is IUIBase)
+            {
+                if (supportsChromeChildren && c is IChrome) {
+                    addChildAt(IUIBase(c).element as DisplayObject, index);
+                    IUIBase(c).addedToParent();
+                }
+                else {
+                    actualParent.addChildAt(IUIBase(c).element as DisplayObject, index);
+                    IUIBase(c).addedToParent();
+                }
+            }
+            else {
+                if (supportsChromeChildren && c is IChrome) {
+                    addChildAt(c as DisplayObject, index);
+                } else {
+                    actualParent.addChildAt(c as DisplayObject, index);
+                }
+            }
+            if (dispatchEvent)
+                this.dispatchEvent(new Event("childrenAdded"));
+        }
+        
+        /**
+         *  @private
+         */
+        override public function removeElement(c:Object, dispatchEvent:Boolean = true):void
+        {
+            if (c is IUIBase)
+                actualParent.removeChild(IUIBase(c).element as DisplayObject);
+            else
+                actualParent.removeChild(c as DisplayObject);
+            if (dispatchEvent)
+                this.dispatchEvent(new Event("childrenRemoved"));
+        }
+        
+        /**
+         *  Get the array of children.  To change the children use
+         *  addElement, removeElement.
+         */
+        public function getChildren():Array
+        {
+            var children:Array = [];
+            var n:int = actualParent.numChildren;
+            for (var i:int = 0; i < n; i++)
+                children.push(actualParent.getChildAt(i));
+            return children;
+        }
+        
+        /**
+         *  @private
+         */
+        public function childrenAdded():void
+        {
+            dispatchEvent(new Event("childrenAdded"));
+        }
+        
+        /**
          *  A ContainerBase doesn't create its children until it is added to
          *  a parent.
          *  
@@ -114,7 +245,6 @@ package org.apache.flex.core
     			dispatchEvent(new Event("initComplete"));
                 _initialized = true;
             }
-			dispatchEvent(new Event("childrenAdded"));
 		}
 
         private var _mxmlDescriptor:Array;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadLayout.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadLayout.as
index 0166f24..fcc5569 100644
--- a/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadLayout.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadLayout.as
@@ -32,6 +32,9 @@ package org.apache.flex.core
      */
 	public interface IBeadLayout extends IBead
 	{
-		
+        /**
+         * @return true if size changed 
+         */
+		function layout():Boolean;
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/Core/as/src/org/apache/flex/core/UIBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/UIBase.as b/frameworks/projects/Core/as/src/org/apache/flex/core/UIBase.as
index 2f8bca1..3bec8fb 100644
--- a/frameworks/projects/Core/as/src/org/apache/flex/core/UIBase.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/UIBase.as
@@ -518,7 +518,11 @@ package org.apache.flex.core
             if (!isNaN(_percentWidth))
                 return false;
             var value:* = ValuesManager.valuesImpl.getValue(this, "width");
-            return value === undefined;
+            if (value !== undefined)
+                return false;
+            var left:* = ValuesManager.valuesImpl.getValue(this, "left");
+            var right:* = ValuesManager.valuesImpl.getValue(this, "right");
+            return (left === undefined || right === undefined);
 
         }
         
@@ -537,7 +541,11 @@ package org.apache.flex.core
             if (!isNaN(_percentHeight))
                 return false;
             var value:* = ValuesManager.valuesImpl.getValue(this, "height");
-            return value === undefined;            
+            if (value !== undefined)
+                return false;
+            var top:* = ValuesManager.valuesImpl.getValue(this, "top");
+            var bottom:* = ValuesManager.valuesImpl.getValue(this, "bottom");
+            return (top === undefined || bottom === undefined);          
         }
 		
 		/**
@@ -1056,5 +1064,9 @@ package org.apache.flex.core
             _stageProxy = null;
         }
         
+        protected function repeaterListener(event:Event):void
+        {
+            dispatchEvent(event);
+        }
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/Core/as/src/org/apache/flex/core/UIButtonBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/UIButtonBase.as b/frameworks/projects/Core/as/src/org/apache/flex/core/UIButtonBase.as
index d3f0a25..be1bc05 100644
--- a/frameworks/projects/Core/as/src/org/apache/flex/core/UIButtonBase.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/UIButtonBase.as
@@ -256,13 +256,10 @@ package org.apache.flex.core
 		 *  @productversion FlexJS 0.0
 		 */
 		public function get clientWidth():Number
-		{
-			var padding:Object = determinePadding();
-			var pl:Number = 0;
-			var pr:Number = 0;
-			if (!isNaN(padding.paddingLeft)) pl = padding.paddingLeft;
-			if (!isNaN(padding.paddingRight)) pr = padding.paddingRight;
-			return width + pl + pr;
+		{			
+            // button views should already factor in padding to set
+            // the borders
+			return width;
 		}
 		
 		/**
@@ -276,12 +273,9 @@ package org.apache.flex.core
 		 */
 		public function get clientHeight():Number
 		{
-			var padding:Object = determinePadding();
-			var pt:Number = 0;
-			var pb:Number = 0;
-			if (!isNaN(padding.paddingTop)) pt = padding.paddingTop;
-			if (!isNaN(padding.paddingBottom)) pb = padding.paddingBottom;
-			return height + pt + pb;
+            // button views should already factor in padding to set
+            // the borders
+			return height;
 		}
 		
 		private var _width:Number;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/Core/as/src/org/apache/flex/core/ViewBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/ViewBase.as b/frameworks/projects/Core/as/src/org/apache/flex/core/ViewBase.as
index fc4fafb..74c30ce 100644
--- a/frameworks/projects/Core/as/src/org/apache/flex/core/ViewBase.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/ViewBase.as
@@ -63,6 +63,8 @@ package org.apache.flex.core
 		{
 			super();
 			
+            supportsChromeChildren = false;
+            
 			className = "flexjs";
 		}
 		

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/Core/as/src/org/apache/flex/utils/MXMLDataInterpreter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/MXMLDataInterpreter.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/MXMLDataInterpreter.as
index 7b2982d..89ce693 100644
--- a/frameworks/projects/Core/as/src/org/apache/flex/utils/MXMLDataInterpreter.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/utils/MXMLDataInterpreter.as
@@ -269,7 +269,7 @@ public class MXMLDataInterpreter
         }
         if (parent && comp is DisplayObject)
         {
-            parent.addElement(comp, !(comp is IContainer));
+            parent.addElement(comp, !(parent is IContainer));
         }
         
         if (children)
@@ -277,12 +277,6 @@ public class MXMLDataInterpreter
             if (!(comp is IMXMLDocument))
             {
                 generateMXMLInstances(document, comp as IParent, children);
-            
-                // maybe we can remove this.  All IContainers should be IMXMLDocuments?
-                if (comp is IContainer)
-                {
-                    IContainer(comp).childrenAdded();
-                }
             }
         }
         
@@ -313,6 +307,11 @@ public class MXMLDataInterpreter
 		if (!data) return;
 		
         generateMXMLArray(document, parent, data);
+        // maybe we can remove this.  All IContainers should be IMXMLDocuments?
+        if (parent is IContainer)
+        {
+            IContainer(parent).childrenAdded();
+        }
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/as/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/defaults.css b/frameworks/projects/HTML/as/defaults.css
index 1363157..67717a6 100644
--- a/frameworks/projects/HTML/as/defaults.css
+++ b/frameworks/projects/HTML/as/defaults.css
@@ -213,6 +213,13 @@ ToolTip
     background-color: #FFFFCC;
 }
 
+ViewBase
+{
+    IBeadView: ClassReference("org.apache.flex.html.beads.ContainerView");
+    IBeadLayout: ClassReference("org.apache.flex.html.beads.layouts.BasicLayout");
+}
+
+
 /* Global Style Declaration */
 global
 {
@@ -448,6 +455,11 @@ ToggleTextButton
     IBeadView:  ClassReference("org.apache.flex.html.beads.CSSTextButtonView");
 }
 
+ViewBase
+{
+    iBackgroundBead: ClassReference("org.apache.flex.html.beads.SolidBackgroundBead");
+    iBorderBead: ClassReference("org.apache.flex.html.beads.SingleLineBorderBead");
+}
 
 /* SVG */
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/as/src/org/apache/flex/html/Container.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/Container.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/Container.as
index 70caf45..fb9b867 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/Container.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/Container.as
@@ -58,7 +58,7 @@ package org.apache.flex.html
      *  @playerversion AIR 2.6
      *  @productversion FlexJS 0.0
      */    
-	public class Container extends ContainerBase implements IContainer
+	public class Container extends ContainerBase
 	{
         /**
          *  Constructor.
@@ -71,124 +71,7 @@ package org.apache.flex.html
 		public function Container()
 		{
 			super();
-			actualParent = this;
-		}
-		
-		private var actualParent:DisplayObjectContainer;
-		
-        /**
-         *  Set a platform-specific object as the actual parent for 
-         *  children.  This must be public so it can be accessed
-         *  by beads.
-         *  
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion FlexJS 0.0
-         */
-		public function setActualParent(parent:DisplayObjectContainer):void
-		{
-			actualParent = parent;	
-		}
-		
-        /**
-         *  @private
-         */
-        override public function getElementIndex(c:Object):int
-        {
-            if (c is IUIBase)
-                return actualParent.getChildIndex(IUIBase(c).element as DisplayObject);
-            else
-                return actualParent.getChildIndex(c as DisplayObject);
-        }
-
-        /**
-         *  @private
-         */
-        override public function addElement(c:Object, dispatchEvent:Boolean = true):void
-        {
-            if (c is IUIBase)
-            {
-				if (c is IChrome ) {
-					addChild(IUIBase(c).element as DisplayObject);
-					IUIBase(c).addedToParent();
-				}
-				else {
-                	actualParent.addChild(IUIBase(c).element as DisplayObject);
-                	IUIBase(c).addedToParent();
-				}
-            }
-            else {
-				if (c is IChrome) {
-					addChild(c as DisplayObject);
-				}
-				else {
-					actualParent.addChild(c as DisplayObject);
-				}
-			}
-            if (dispatchEvent)
-                this.dispatchEvent(new Event("childrenAdded"));
-        }
-        
-        /**
-         *  @private
-         */
-        override public function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void
-        {
-            if (c is IUIBase)
-            {
-				if (c is IChrome) {
-					addChildAt(IUIBase(c).element as DisplayObject, index);
-					IUIBase(c).addedToParent();
-				}
-				else {
-                	actualParent.addChildAt(IUIBase(c).element as DisplayObject, index);
-                	IUIBase(c).addedToParent();
-				}
-            }
-            else {
-				if (c is IChrome) {
-					addChildAt(c as DisplayObject, index);
-				} else {
-                	actualParent.addChildAt(c as DisplayObject, index);
-				}
-			}
-            if (dispatchEvent)
-                this.dispatchEvent(new Event("childrenAdded"));
-        }
-        
-        /**
-         *  @private
-         */
-        override public function removeElement(c:Object, dispatchEvent:Boolean = true):void
-        {
-            if (c is IUIBase)
-                actualParent.removeChild(IUIBase(c).element as DisplayObject);
-            else
-                actualParent.removeChild(c as DisplayObject);
-            if (dispatchEvent)
-                this.dispatchEvent(new Event("childrenRemoved"));
-        }
-        
-        /**
-         *  Get the array of children.  To change the children use
-         *  addElement, removeElement.
-         */
-        public function getChildren():Array
-		{
-			var children:Array = [];
-			var n:int = actualParent.numChildren;
-			for (var i:int = 0; i < n; i++)
-				children.push(actualParent.getChildAt(i));
-			return children;
 		}
 
-        /**
-         *  @private
-         */
-		public function childrenAdded():void
-		{
-			dispatchEvent(new Event("childrenAdded"));
-		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/as/src/org/apache/flex/html/Label.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/Label.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/Label.as
index 27d54ed..c47d8b9 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/Label.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/Label.as
@@ -56,6 +56,7 @@ package org.apache.flex.html
 			super();
 		}
 		
+        [Bindable("textChange")]
         /**
          *  The text to display in the label.
          *  
@@ -77,6 +78,7 @@ package org.apache.flex.html
 			ITextModel(model).text = value;
 		}
 		
+        [Bindable("htmlChange")]
         /**
          *  The html-formatted text to display in the label.
          *  
@@ -97,6 +99,17 @@ package org.apache.flex.html
 		{
 			ITextModel(model).html = value;
 		}
-				
+
+        
+        /**
+         *  @private
+         */
+        override public function addedToParent():void
+        {
+            super.addedToParent();
+            model.addEventListener("textChange", repeaterListener);
+            model.addEventListener("htmlChange", repeaterListener);
+        }
+
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ContainerView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ContainerView.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ContainerView.as
index 59fb6f5..a6e8b25 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ContainerView.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ContainerView.as
@@ -19,25 +19,25 @@
 package org.apache.flex.html.beads
 {
     import org.apache.flex.core.BeadViewBase;
-	import org.apache.flex.core.IBead;
+    import org.apache.flex.core.ContainerBase;
+    import org.apache.flex.core.IBead;
     import org.apache.flex.core.IBeadLayout;
-	import org.apache.flex.core.IBeadView;
-	import org.apache.flex.core.ILayoutParent;
+    import org.apache.flex.core.IBeadView;
+    import org.apache.flex.core.ILayoutParent;
     import org.apache.flex.core.IParentIUIBase;
-	import org.apache.flex.core.IStrand;
+    import org.apache.flex.core.IStrand;
     import org.apache.flex.core.IUIBase;
     import org.apache.flex.core.UIBase;
-	import org.apache.flex.core.ValuesManager;
+    import org.apache.flex.core.ValuesManager;
     import org.apache.flex.events.Event;
     import org.apache.flex.events.IEventDispatcher;
-	import org.apache.flex.html.Container;
-	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.html.supportClasses.Border;
+    import org.apache.flex.html.supportClasses.ContainerContentArea;
+    import org.apache.flex.html.supportClasses.ScrollBar;
 	
     /**
      *  The ContainerView class is the default view for
-     *  the org.apache.flex.html.Container class.
+     *  the org.apache.flex.core.ContainerBase classes.
      *  It lets you use some CSS styles to manage the border, background
      *  and padding around the content area.
      *  
@@ -71,6 +71,20 @@ package org.apache.flex.html.beads
 		protected var actualParent:UIBase;
 				
         /**
+         *  The layout.  The layout may actually layout
+         *  the children of the internal content area
+         *  and not the pieces of the "chrome" like titlebars
+         *  and borders.  The ContainerView or its subclass will have some
+         *  baked-in logic for handling the chrome.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */        
+        protected var layout:IBeadLayout;
+        
+        /**
          *  @copy org.apache.flex.core.IBead#strand
          *  
          *  @langversion 3.0
@@ -86,29 +100,30 @@ package org.apache.flex.html.beads
             
             if (host.isWidthSizedToContent() && host.isHeightSizedToContent())
             {
+                // if both dimensions are sized to content, then only draw the
+                // borders, etc, after a child is added.  The children in an MXML
+                // document don't send this event until the last child is added.
                 host.addEventListener("childrenAdded", changeHandler);
-                checkActualParent();
+                host.addEventListener("layoutNeeded", changeHandler);
+                // listen for width and height changes as well in case the app
+                // switches away from content sizing via binding or other code
+                host.addEventListener("widthChanged", changeHandler);
+                host.addEventListener("heightChanged", changeHandler);
             }
             else
             {
+                // otherwise, listen for size changes before drawing
+                // borders and laying out children.
                 host.addEventListener("widthChanged", changeHandler);
                 host.addEventListener("heightChanged", changeHandler);
                 host.addEventListener("sizeChanged", sizeChangeHandler);
+                // if we have fixed size in both dimensions, wait for children
+                // to be added then run a layout pass right then as the
+                // parent won't kick off any other event in the child
                 if (!isNaN(host.explicitWidth) && !isNaN(host.explicitHeight))
-                    sizeChangeHandler(null);
-                else
-                    checkActualParent();
-            }
-            
-            if (_strand.getBeadByType(IBeadLayout) == null)
-            {
-                var c:Class = ValuesManager.valuesImpl.getValue(host, "iBeadLayout");
-                if (c)
-                {
-                    var layout:IBeadLayout = new c() as IBeadLayout;
-                    _strand.addBead(layout);
-                }
+                    host.addEventListener("childrenAdded", changeHandler);
             }            
+            checkActualParent();
         }
         
         private function checkActualParent():Boolean
@@ -120,8 +135,8 @@ package org.apache.flex.html.beads
                 {
                     actualParent = new ContainerContentArea();
 					actualParent.className = "ActualParent";
-                    host.addElement(actualParent);
-                    Container(host).setActualParent(actualParent);
+                    host.addElement(actualParent, false);
+                    ContainerBase(host).setActualParent(actualParent);
                 }
                 return true;
             }
@@ -137,6 +152,7 @@ package org.apache.flex.html.beads
             var host:UIBase = UIBase(_strand);
             host.addEventListener("childrenAdded", changeHandler);
             host.addEventListener("layoutNeeded", changeHandler);
+            host.addEventListener("itemsCreated", changeHandler);
             changeHandler(event);
         }
         
@@ -157,29 +173,73 @@ package org.apache.flex.html.beads
             inChangeHandler = true;
             
             var host:UIBase = UIBase(_strand);
-			
+
+            if (layout == null)
+            {
+                layout = _strand.getBeadByType(IBeadLayout) as IBeadLayout;
+                if (layout == null)
+                {
+                    var c:Class = ValuesManager.valuesImpl.getValue(host, "iBeadLayout");
+                    if (c)
+                    {
+                        layout = new c() as IBeadLayout;
+                        _strand.addBead(layout);
+                    }
+                }
+            }
+            
 			var padding:Object = determinePadding();
 			
 			if (checkActualParent())
 			{
 				actualParent.x = padding.paddingLeft;
 				actualParent.y = padding.paddingTop;
-                var pb:Number = padding.paddingBottom;
-                if (isNaN(pb))
-                    pb = 0;
-                var pr:Number = padding.paddingRight;
-                if (isNaN(pr))
-                    pr = 0;
-                if (!isNaN(host.explicitWidth) || !isNaN(host.percentWidth))
+            }
+            var pb:Number = padding.paddingBottom;
+            if (isNaN(pb))
+                pb = 0;
+            var pr:Number = padding.paddingRight;
+            if (isNaN(pr))
+                pr = 0;
+            // if the width is dictated by the parent
+            if (!host.isWidthSizedToContent())
+            {
+                if (actualParent != host)
+                {
+                    // force the width of the internal content area as desired.
                     actualParent.setWidth(host.width - padding.paddingLeft - pr);
+                }
+                // run the layout
+                layout.layout();
+            }
+            else 
+            {
+                // if the height is dictated by the parent
+                if (!host.isHeightSizedToContent())
+                {
+                    if (actualParent != host)
+                    {
+                        // force the height
+                        actualParent.setHeight(host.height - padding.paddingTop - pb);
+                    }
+                }
+                layout.layout();
+                if (actualParent != host)
+                {
+                    // actualParent.width should be the new width after layout.
+                    // set the host's width.  This should send a widthChanged event and
+                    // have it blocked at the beginning of this method
+                    host.setWidth(padding.paddingLeft + pr + actualParent.width);
+                }
+            }
+            // and if the height is sized to content, set the height now as well.
+            if (host != actualParent)
+            {
+                if (host.isHeightSizedToContent())
+                    host.setHeight(padding.paddingTop + pb + actualParent.height);
                 else
-                    host.dispatchEvent(new Event("widthChanged"));
-                
-                if (!isNaN(host.explicitHeight) || !isNaN(host.percentHeight))
                     actualParent.setHeight(host.height - padding.paddingTop - pb);
-                else
-                    host.dispatchEvent(new Event("heightChanged"));
-			}
+            }
 			
 			var backgroundColor:Object = ValuesManager.valuesImpl.getValue(host, "background-color");
 			var backgroundImage:Object = ValuesManager.valuesImpl.getValue(host, "background-image");
@@ -272,11 +332,10 @@ package org.apache.flex.html.beads
 		 */
 		protected function contentAreaNeeded():Boolean
 		{
-			return true;
-//			var padding:Object = determinePadding();
-//			
-//			return (!isNaN(padding.paddingLeft) && padding.paddingLeft > 0 ||
-//				    !isNaN(padding.paddingTop) && padding.paddingTop > 0);
+			var padding:Object = determinePadding();
+			
+			return (!isNaN(padding.paddingLeft) && padding.paddingLeft > 0 ||
+				    !isNaN(padding.paddingTop) && padding.paddingTop > 0);
 		}
 		
         /**
@@ -305,6 +364,8 @@ package org.apache.flex.html.beads
 			return _strand as IUIBase;
 		}
 		
+        private var inGetViewHeight:Boolean;
+        
 		/**
 		 *  @copy org.apache.flex.core.IBeadView#viewHeight
 		 *  
@@ -315,11 +376,19 @@ package org.apache.flex.html.beads
 		 */
 		override public function get viewHeight():Number
 		{
-			// don't want to put $height in an interface
+            if (inGetViewHeight)
+            {
+                trace("ContainerView: no height set for " + host);
+                return host["$height"];
+            }
+            inGetViewHeight = true;
 			var vh:Number = contentView.height;
-			return vh;
+            inGetViewHeight = false;
+            return vh;
 		}
 		
+        private var inGetViewWidth:Boolean;
+        
 		/**
 		 *  @copy org.apache.flex.core.IBeadView#viewWidth
 		 *  
@@ -330,10 +399,16 @@ package org.apache.flex.html.beads
 		 */
 		override public function get viewWidth():Number
 		{
-			// don't want to put $width in an interface
+            if (inGetViewWidth)
+            {
+                trace("ContainerView: no width set for " + host);
+                return host["$width"];
+            }
+            inGetViewWidth = true;
 			var vw:Number = contentView.width;
+            inGetViewWidth = false;
 			return vw;
 		}
-				
+		
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/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 7b14d2a..87ac761 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
@@ -147,6 +147,8 @@ package org.apache.flex.html.beads
 			return _strand as IUIBase;
 		}
 		
+        private var _layout:IBeadLayout;
+        
         /**
          * @private
          */
@@ -170,12 +172,15 @@ package org.apache.flex.html.beads
 			_strand = value;
 			
             for each (var bead:IBead in beads)
-            addBead(bead);
+                addBead(bead);
             
             dispatchEvent(new org.apache.flex.events.Event("beadsAdded"));
 			IEventDispatcher(_strand).addEventListener("widthChanged", handleSizeChange);
 			IEventDispatcher(_strand).addEventListener("heightChanged",handleSizeChange);
             
+            // this gets sent at least once after the beads are all in place.
+            IEventDispatcher(_strand).addEventListener("layoutNeeded",handleSizeChange);
+            
             listModel = value.getBeadByType(ISelectionModel) as ISelectionModel;
             listModel.addEventListener("selectedIndexChanged", selectionChangeHandler);
             listModel.addEventListener("rollOverIndexChanged", rollOverIndexChangeHandler);
@@ -191,13 +196,6 @@ package org.apache.flex.html.beads
 			}
 			IParent(_strand).addElement(_dataGroup);
             
-            if (_strand.getBeadByType(IBeadLayout) == null)
-            {
-                var mapper:IBeadLayout = new (ValuesManager.valuesImpl.getValue(_strand, "iBeadLayout")) as IBeadLayout;
-				_strand.addBead(mapper);
-            }  
-			
-			handleSizeChange(null);
 		}
 		
 		private var lastSelectedIndex:int = -1;
@@ -268,16 +266,46 @@ package org.apache.flex.html.beads
             IParent(_strand).addElement(vsb);
 			return vsb;
 		}
-		
-		/**
-		 * @private
-		 */
-		private function handleSizeChange(event:Event):void
+
+        /**
+         *  Layout everything except the DataGroup, 
+         *  but size the DataGroup as needed
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        protected function layoutList():void
+        {
+            UIBase(_dataGroup).x = 0;
+            UIBase(_dataGroup).y = 0;
+            UIBase(_dataGroup).width = UIBase(_strand).width;
+            UIBase(_dataGroup).height = UIBase(_strand).height;
+        }
+        
+        /**
+         *  respond to a change in size or request to re-layout everything
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		protected function handleSizeChange(event:Event):void
 		{
-			UIBase(_dataGroup).x = 0;
-			UIBase(_dataGroup).y = 0;
-			UIBase(_dataGroup).width = UIBase(_strand).width;
-			UIBase(_dataGroup).height = UIBase(_strand).height;
+            layoutList();
+            
+            if (_layout == null)
+            {
+                _layout = _strand.getBeadByType(IBeadLayout) as IBeadLayout;
+                if (_layout == null)
+                {
+                    _layout = new (ValuesManager.valuesImpl.getValue(_strand, "iBeadLayout")) as IBeadLayout;
+                    _strand.addBead(_layout);
+                }  
+            }
+            _layout.layout();
 		}
 				
         /**

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelView.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelView.as
index dac93ad..8be59e0 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelView.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelView.as
@@ -93,6 +93,7 @@ package org.apache.flex.html.beads
             
             if (!_titleBar)
                 _titleBar = new TitleBar();
+            _titleBar.percentWidth = 100;
 			// replace the TitleBar's model with the Panel's model (it implements ITitleBarModel) so that
 			// any changes to values in the Panel's model that correspond values in the TitleBar will 
 			// be picked up automatically by the TitleBar.

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ScrollBarView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ScrollBarView.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ScrollBarView.as
index 8091b71..e6f31cf 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ScrollBarView.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ScrollBarView.as
@@ -29,6 +29,8 @@ package org.apache.flex.html.beads
 	import org.apache.flex.core.Strand;
 	import org.apache.flex.core.UIBase;
 	import org.apache.flex.core.ValuesManager;
+    import org.apache.flex.events.IEventDispatcher;
+    import org.apache.flex.events.Event;
 	import org.apache.flex.html.Button;
 	import org.apache.flex.html.beads.controllers.ButtonAutoRepeatController;
 
@@ -63,6 +65,16 @@ package org.apache.flex.html.beads
 		private var _strand:IStrand;
 		
         /**
+         *  The layout. 
+         * 
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        private var layout:IBeadLayout;
+        
+        /**
          *  The host component. 
          * 
          *  @langversion 3.0
@@ -91,6 +103,13 @@ package org.apache.flex.html.beads
                 addBead(bead);
                         
 			sbModel = value.getBeadByType(IScrollBarModel) as IScrollBarModel;
+            sbModel = _strand.getBeadByType(IScrollBarModel) as IScrollBarModel;
+            sbModel.addEventListener("maximumChange", changeHandler);
+            sbModel.addEventListener("minimumChange", changeHandler);
+            sbModel.addEventListener("snapIntervalChange", changeHandler);
+            sbModel.addEventListener("stepSizeChange", changeHandler);
+            sbModel.addEventListener("pageSizeChange", changeHandler);
+            sbModel.addEventListener("valueChange", changeHandler);
             
             // TODO: (aharui) put in values impl
 			_increment = new Button();
@@ -109,13 +128,20 @@ package org.apache.flex.html.beads
             UIBase(value).addChild(_track);
             UIBase(value).addChild(_thumb);
             
+            IEventDispatcher(_strand).addEventListener("heightChanged", changeHandler);
+            
             if( _strand.getBeadByType(IBeadLayout) == null ) {
-                var layout:IBeadLayout = new (ValuesManager.valuesImpl.getValue(_strand, "iBeadLayout")) as IBeadLayout;
+                layout = new (ValuesManager.valuesImpl.getValue(_strand, "iBeadLayout")) as IBeadLayout;
                 _strand.addBead(layout);
             }
-            
+            layout.layout();
 		}
 						
+        private function changeHandler(event:Event):void
+        {
+            layout.layout();    
+        }
+        
 		private var _decrement:DisplayObject;
 		private var _increment:DisplayObject;
 		private var _track:DisplayObject;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/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 b6098cc..ca702ee 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
@@ -21,6 +21,7 @@ package org.apache.flex.html.beads
 	
 	import org.apache.flex.core.BeadViewBase;
 	import org.apache.flex.core.IBead;
+	import org.apache.flex.core.IBeadLayout;
 	import org.apache.flex.core.IBeadView;
 	import org.apache.flex.core.IParent;
 	import org.apache.flex.core.IParentIUIBase;
@@ -29,7 +30,7 @@ package org.apache.flex.html.beads
 	import org.apache.flex.core.IUIBase;
 	import org.apache.flex.core.UIBase;
 	import org.apache.flex.core.ValuesManager;
-    import org.apache.flex.events.Event;
+	import org.apache.flex.events.Event;
 	import org.apache.flex.html.Container;
 	import org.apache.flex.html.beads.models.ScrollBarModel;
 	import org.apache.flex.html.supportClasses.Border;
@@ -81,6 +82,20 @@ package org.apache.flex.html.beads
 		protected var actualParent:UIBase;
 				
         /**
+         *  The layout.  The layout may actually layout
+         *  the children of the internal content area
+         *  and not the pieces of the "chrome" like titlebars
+         *  and borders.  The ContainerView or its subclass will have some
+         *  baked-in logic for handling the chrome.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */        
+        protected var layout:IBeadLayout;
+        
+        /**
          *  @copy org.apache.flex.core.IBead#strand
          *  
          *  @langversion 3.0
@@ -92,20 +107,72 @@ package org.apache.flex.html.beads
 		{
 			super.strand = value;
             var host:UIBase = value as UIBase;
-            if (host.numChildren > 0)
-                childHandler(null);  
+            
+            if (host.isWidthSizedToContent() && host.isHeightSizedToContent())
+            {
+                // if both dimensions are sized to content, then only draw the
+                // borders, etc, after a child is added.  The children in an MXML
+                // document don't send this event until the last child is added.
+                host.addEventListener("childrenAdded", changeHandler);
+                host.addEventListener("layoutNeeded", changeHandler);
+                // listen for width and height changes as well in case the app
+                // switches away from content sizing via binding or other code
+                host.addEventListener("widthChanged", changeHandler);
+                host.addEventListener("heightChanged", changeHandler);
+            }
             else
-                host.addEventListener("childrenAdded", childHandler);
+            {
+                // otherwise, listen for size changes before drawing
+                // borders and laying out children.
+                host.addEventListener("widthChanged", changeHandler);
+                host.addEventListener("heightChanged", changeHandler);
+                host.addEventListener("sizeChanged", sizeChangeHandler);
+                // if we have fixed size in both dimensions, wait for children
+                // to be added then run a layout pass right then as the
+                // 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
+                        host.addEventListener("childrenAdded", changeHandler);
+                }
+            }
         }
         
-        private function childHandler(event:Event):void
+        private function sizeChangeHandler(event:Event):void
+        {
+            var host:UIBase = UIBase(_strand);
+            host.addEventListener("childrenAdded", changeHandler);
+            host.addEventListener("layoutNeeded", changeHandler);
+            host.addEventListener("itemsCreated", changeHandler);
+            changeHandler(event);
+        }
+
+        private function changeHandler(event:Event):void
         {
             var host:UIBase = _strand as UIBase;
+            if (layout == null)
+            {
+                layout = host.getBeadByType(IBeadLayout) as IBeadLayout;
+                if (layout == null)
+                {
+                    var c:Class = ValuesManager.valuesImpl.getValue(host, "iBeadLayout");
+                    if (c)
+                    {
+                        layout = new c() as IBeadLayout;
+                        host.addBead(layout);
+                    }
+                }
+            }
+            
             if (host.numChildren > 0)
             {
                 actualParent = host.getChildAt(0) as UIBase;   
             }
         
+            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)

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/SolidBackgroundBead.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/SolidBackgroundBead.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/SolidBackgroundBead.as
index c62b59b..3078048 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/SolidBackgroundBead.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/SolidBackgroundBead.as
@@ -86,12 +86,7 @@ package org.apache.flex.html.beads
 			if( bgAlpha != null ) {
 				opacity = Number(bgAlpha);
 			}
-            var ilc:ILayoutChild = value as ILayoutChild;
-            if (ilc)
-            {
-                if (!isNaN(ilc.explicitWidth) && !isNaN(ilc.explicitHeight))
-                    changeHandler(null);
-            }
+            changeHandler(null);
 		}
 		
 		private var _backgroundColor:uint;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/BasicLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/BasicLayout.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/BasicLayout.as
index 665e169..bb1bc08 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/BasicLayout.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/BasicLayout.as
@@ -71,46 +71,25 @@ package org.apache.flex.html.beads.layouts
 		public function set strand(value:IStrand):void
 		{
             host = value as ILayoutChild;
-            
-            // if host is going to be sized by its parent, then don't
-            // run layout when the children are added until after the
-            // initial sizing by the parent.
-            if (host.isWidthSizedToContent() && host.isHeightSizedToContent())
-            {
-                addOtherListeners();
-            }
-            else
-            {
-                host.addEventListener("heightChanged", changeHandler);
-                host.addEventListener("widthChanged", changeHandler);
-                host.addEventListener("sizeChanged", sizeChangeHandler);
-                if (!isNaN(host.explicitWidth) && !isNaN(host.explicitHeight))
-                    addOtherListeners();
-            }
 		}
-	
-        private function addOtherListeners():void
-        {
-            host.addEventListener("childrenAdded", changeHandler);
-            host.addEventListener("layoutNeeded", changeHandler);
-            host.addEventListener("itemsCreated", changeHandler);
-        }
-        
-        private function sizeChangeHandler(event:Event):void
-        {
-            addOtherListeners();
-            changeHandler(event);
-        }
-        
-		private function changeHandler(event:Event):void
+	        
+        /**
+         * @copy org.apache.flex.core.IBeadLayout#layout
+         */
+		public function layout():Boolean
 		{
             //trace(DOMPathUtil.getPath(host), event ? event.type : "fixed size");
 			var layoutParent:ILayoutParent = host.getBeadByType(ILayoutParent) as ILayoutParent;
 			var contentView:IParentIUIBase = layoutParent ? layoutParent.contentView : IParentIUIBase(host);
 			
-            var w:Number = contentView.width;
-            var h:Number = contentView.height;
+            var hostWidthSizedToContent:Boolean = host.isWidthSizedToContent();
+            var hostHeightSizedToContent:Boolean = host.isHeightSizedToContent();
+            var w:Number = hostWidthSizedToContent ? 0 : contentView.width;
+            var h:Number = hostHeightSizedToContent ? 0 : contentView.height;
 			var n:int = contentView.numElements;
+            var maxWidth:Number = 0;
+            var maxHeight:Number = 0;
+            var childData:Array = [];
 			for (var i:int = 0; i < n; i++)
 			{
 				var child:IUIBase = contentView.getElementAt(i) as IUIBase;
@@ -134,42 +113,131 @@ package org.apache.flex.html.beads.layouts
                 var ilc:ILayoutChild = child as ILayoutChild;
                 if (ilc)
                 {
-                    ilc = child as ILayoutChild;
-                    if (!isNaN(ilc.percentWidth))
-                        ilc.setWidth((ww - (isNaN(right) ? 0 : right)) * ilc.percentWidth / 100, true);
+                    if (!hostWidthSizedToContent)
+                    {
+                        if (!isNaN(ilc.percentWidth))
+                            ilc.setWidth((ww - (isNaN(right) ? 0 : right)) * ilc.percentWidth / 100, true);
+                    }
+                    else
+                        childData[i] = { bottom: bottom, right: right, ww: ww, ilc: ilc, child: child };
                 }
                 if (!isNaN(right))
                 {
-                    if (!isNaN(left))
+                    if (!hostWidthSizedToContent)
                     {
-                        if (ilc)
-                            ilc.setWidth(ww - right);
+                        if (!isNaN(left))
+                        {
+                            if (ilc)
+                                ilc.setWidth(ww - right, true);
+                            else
+                                child.width = ww - right;
+                        }
                         else
-                            child.width = ww - right;
+                            child.x = w - right - child.clientWidth;
                     }
                     else
-                        child.x = w - right - child.clientWidth;
+                        childData[i] = { ww: ww, left: left, right: right, ilc: ilc, child: child };
                 }
-                if (child is ILayoutChild)
+                if (ilc)
                 {
-                    ilc = child as ILayoutChild;
-                    if (!isNaN(ilc.percentHeight))
-                        ilc.setHeight((hh - (isNaN(bottom) ? 0 : bottom)) * ilc.percentHeight / 100, true);
+                    if (!hostHeightSizedToContent)
+                    {
+                        if (!isNaN(ilc.percentHeight))
+                            ilc.setHeight((hh - (isNaN(bottom) ? 0 : bottom)) * ilc.percentHeight / 100, true);
+                    }
+                    else
+                    {
+                        if (!childData[i])
+                            childData[i] = { hh: hh, bottom: bottom, ilc: ilc, child: child };
+                        else
+                        {
+                            childData[i].hh = hh;
+                            childData[i].bottom = bottom;
+                        }
+                    }
                 }
                 if (!isNaN(bottom))
                 {
-                    if (!isNaN(top))
+                    if (!hostHeightSizedToContent)
                     {
-                        if (ilc)
-                            ilc.setHeight(hh - bottom);
+                        if (!isNaN(top))
+                        {
+                            if (ilc)
+                                ilc.setHeight(hh - bottom, true);
+                            else
+                                child.height = hh - bottom;
+                        }
                         else
-                            child.height = hh - bottom;
+                            child.y = h - bottom - child.clientHeight;
                     }
                     else
-                        child.y = h - bottom - child.clientHeight;
+                    {
+                        if (!childData[i])
+                            childData[i] = { top: top, bottom: bottom, hh:hh, ilc: ilc, child: child };
+                        else
+                        {
+                            childData[i].top = top;
+                            childData[i].bottom = bottom;
+                            childData[i].hh = hh;
+                        }
+                    }
                 }
-                child.dispatchEvent(new Event("sizeChanged"));
+                if (!childData[i])
+                    child.dispatchEvent(new Event("sizeChanged"));
+                maxWidth = Math.max(maxWidth, child.x + child.clientWidth);
+                maxHeight = Math.max(maxHeight, child.y + child.clientHeight);
 			}
+            if (hostHeightSizedToContent || hostWidthSizedToContent)
+            {
+                if (hostHeightSizedToContent)
+                    ILayoutChild(contentView).setHeight(maxHeight, true);
+                if (hostHeightSizedToContent)
+                    ILayoutChild(contentView).setWidth(maxWidth, true);
+                for (i = 0; i < n; i++)
+                {
+                    var data:Object = childData[i];
+                    if (data)
+                    {
+                        if (hostWidthSizedToContent)
+                        {
+                            if (data.ilc && !isNaN(data.ilc.percentWidth))
+                                data.ilc.setWidth((data.ww - (isNaN(data.right) ? 0 : data.right)) * data.ilc.percentWidth / 100, true);
+                            if (!isNaN(data.right))
+                            {
+                                if (!isNaN(data.left))
+                                {
+                                    if (data.ilc)
+                                        data.ilc.setWidth(data.ww - data.right, true);
+                                    else
+                                        data.child.width = data.ww - data.right;
+                                }
+                                else
+                                    data.child.x = maxWidth - data.right - data.child.clientWidth;
+                            }
+                        }
+                        if (hostHeightSizedToContent)
+                        {
+                            if (data.ilc && !isNaN(data.ilc.percentHeight))
+                                data.ilc.setHeight((data.hh - (isNaN(data.bottom) ? 0 : data.bottom)) * data.ilc.percentHeight / 100, true);
+                            if (!isNaN(data.bottom))
+                            {
+                                if (!isNaN(data.top))
+                                {
+                                    if (data.ilc)
+                                        data.ilc.setHeight(data.hh - data.bottom, true);
+                                    else
+                                        data.child.height = data.hh - data.bottom;
+                                }
+                                else
+                                    data.child.y = maxHeight - data.bottom - data.child.clientHeight;
+                            }
+                        }
+                        child.dispatchEvent(new Event("sizeChanged"));
+                    }
+                }
+
+            }
+            return true;
 		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/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 e9ef9ef..c432985 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
@@ -77,23 +77,15 @@ package org.apache.flex.html.beads.layouts
 		public function set strand(value:IStrand):void
 		{
 			_strand = value;
-			IEventDispatcher(value).addEventListener("heightChanged", changeHandler);
-            IEventDispatcher(value).addEventListener("widthChanged", changeHandler);
-			IEventDispatcher(value).addEventListener("childrenAdded", changeHandler);
-            IEventDispatcher(value).addEventListener("layoutNeeded", changeHandler);
-			IEventDispatcher(value).addEventListener("itemsCreated", changeHandler);
-			IEventDispatcher(value).addEventListener("beadsAdded", changeHandler);
 		}
 	
-		private function changeHandler(event:Event):void
+        /**
+         * @copy org.apache.flex.core.IBeadLayout#layout
+         */
+		public function layout():Boolean
 		{
 			var layoutParent:IScrollingLayoutParent = _strand.getBeadByType(IScrollingLayoutParent) as IScrollingLayoutParent;
 			var contentView:IParentIUIBase = layoutParent.contentView;
-            if (!contentView)
-                return;
-            
-            IEventDispatcher(contentView).addEventListener("childrenAdded", changeHandler);
-            IEventDispatcher(contentView).addEventListener("layoutNeeded", changeHandler);
 			
             var border:Border = layoutParent.border;
             var borderModel:IBorderModel;
@@ -208,8 +200,7 @@ package org.apache.flex.html.beads.layouts
                 DisplayObject(contentView).scrollRect = null;
                 vScrollBar.visible = false;
             }
-            
-            IEventDispatcher(_strand).dispatchEvent(new Event("layoutComplete"));
+            return true;
         }
         
         private function scrollHandler(event:Event):void

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/ButtonBarLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/ButtonBarLayout.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/ButtonBarLayout.as
index 7589cdb..83e6803 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/ButtonBarLayout.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/ButtonBarLayout.as
@@ -71,12 +71,6 @@ package org.apache.flex.html.beads.layouts
 		public function set strand(value:IStrand):void
 		{
 			_strand = value;
-            IEventDispatcher(value).addEventListener("sizeChanged", changeHandler);
-			IEventDispatcher(value).addEventListener("widthChanged", changeHandler);
-			IEventDispatcher(value).addEventListener("heightChanged", changeHandler);
-			IEventDispatcher(value).addEventListener("childrenAdded", changeHandler);
-			IEventDispatcher(value).addEventListener("itemsCreated", changeHandler);
-			IEventDispatcher(value).addEventListener("layoutNeeded", changeHandler);
 		}
 		
 		private var _buttonWidths:Array = null;
@@ -100,9 +94,9 @@ package org.apache.flex.html.beads.layouts
 		}
 		
 		/**
-		 * @private
+		 * @copy org.apache.flex.core.IBeadLayout#layout
 		 */
-		private function changeHandler(event:Event):void
+		public function layout():Boolean
 		{
 			var layoutParent:ILayoutParent = _strand.getBeadByType(ILayoutParent) as ILayoutParent;
 			var contentView:IParent = layoutParent.contentView;
@@ -133,6 +127,7 @@ package org.apache.flex.html.beads.layouts
 				else UIBase(ir).width = useWidth;
 				xpos += UIBase(ir).width;
 			}
+            return true;
 		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/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 0105e2b..5400432 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
@@ -19,15 +19,15 @@
 package org.apache.flex.html.beads.layouts
 {
 	import org.apache.flex.core.IBeadLayout;
-    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.IStrand;
-    import org.apache.flex.core.IParentIUIBase;
-    import org.apache.flex.core.IUIBase;
+	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.utils.dbg.DOMPathUtil;
+	import org.apache.flex.utils.dbg.DOMPathUtil;
 
     /**
      *  The HorizontalLayout class is a simple layout
@@ -70,44 +70,19 @@ package org.apache.flex.html.beads.layouts
 		public function set strand(value:IStrand):void
 		{
 			host = value as ILayoutChild;
-            
-            // if host is going to be sized by its parent, then don't
-            // run layout when the children are added until after the
-            // initial sizing by the parent.
-            if (host.isWidthSizedToContent() && host.isHeightSizedToContent())
-            {
-                addOtherListeners();
-            }
-            else
-            {
-        		host.addEventListener("widthChanged", changeHandler);
-                host.addEventListener("heightChanged", changeHandler);
-                host.addEventListener("sizeChanged", sizeChangeHandler);
-                if (!isNaN(host.explicitWidth) && !isNaN(host.explicitHeight))
-                    addOtherListeners();
-            }
 		}
 	
-        private function addOtherListeners():void
-        {
-            host.addEventListener("childrenAdded", changeHandler);
-            host.addEventListener("layoutNeeded", changeHandler);
-            host.addEventListener("itemsCreated", changeHandler);
-        }
-        
-        private function sizeChangeHandler(event:Event):void
-        {
-            addOtherListeners();
-            changeHandler(event);
-        }
-        
-		private function changeHandler(event:Event):void
+        /**
+         * @copy org.apache.flex.core.IBeadLayout#layout
+         */
+		public function layout():Boolean
 		{
             //trace(DOMPathUtil.getPath(host), event ? event.type : "fixed size");
 			var layoutParent:ILayoutParent = host.getBeadByType(ILayoutParent) as ILayoutParent;
 			var contentView:IParentIUIBase = layoutParent.contentView;
 			
 			var n:int = contentView.numElements;
+            var hostSizedToContent:Boolean = host.isHeightSizedToContent();
             var ilc:ILayoutChild;
 			var marginLeft:Object;
 			var marginRight:Object;
@@ -115,12 +90,18 @@ 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
+            var h:Number = hostSizedToContent ? 0 : contentView.height;
 			var verticalMargins:Array = [];
+            var hasVerticalAlign:Boolean;
 			
 			for (var i:int = 0; i < n; i++)
 			{
 				var child:IUIBase = contentView.getElementAt(i) as IUIBase;
 				if (child == null || !child.visible) continue;
+                var top:Number = ValuesManager.valuesImpl.getValue(child, "top");
+                var bottom:Number = ValuesManager.valuesImpl.getValue(child, "bottom");
+                ilc = child as ILayoutChild;
 				margin = ValuesManager.valuesImpl.getValue(child, "margin");
 				if (margin is Array)
 				{
@@ -161,6 +142,16 @@ package org.apache.flex.html.beads.layouts
 				mb = Number(marginBottom);
 				if (isNaN(mb))
 					mb = 0;
+                var xx:Number;
+                if (i == 0)
+                    child.x = ml;
+                else
+                    child.x = xx + ml + lastmr;
+                if (ilc)
+                {
+                    if (!isNaN(ilc.percentWidth))
+                        ilc.setWidth(contentView.width * ilc.percentWidth / 100, !isNaN(ilc.percentHeight));
+                }
 				if (marginLeft == "auto")
 					ml = 0;
 				else
@@ -177,43 +168,112 @@ package org.apache.flex.html.beads.layouts
 					if (isNaN(mr))
 						mr = 0;
 				}
-				child.y = mt;
-				maxHeight = Math.max(maxHeight, ml + child.clientHeight + mr);
-				var xx:Number;
-				if (i == 0)
-					child.x = ml;
-				else
-					child.x = xx + ml + lastmr;
-                if (child is ILayoutChild)
+                lastmr = mr;
+                var marginObject:Object = {};
+                verticalMargins[i] = marginObject;
+                if (!hostSizedToContent)
                 {
-                    ilc = child as ILayoutChild;
-                    if (!isNaN(ilc.percentWidth))
-                        ilc.setWidth(contentView.width * ilc.percentWidth / 100, true);
+                    // if host is sized by parent,
+                    // we can position and size children horizontally now
+                    setPositionAndHeight(child, top, mt, bottom, mb, h);
+                }
+                else
+                {
+                    if (!isNaN(top))
+                    {
+                        mt = top;
+                        marginObject.top = mt;
+                    }
+                    if (!isNaN(bottom))
+                    {
+                        mb = bottom;
+                        marginObject.bottom = mb;
+                    }
+                    maxHeight = Math.max(maxHeight, mt + child.clientHeight + mb);
                 }
 				xx = child.x + child.clientWidth;
-				lastmr = mr;
-				var valign:Object = ValuesManager.valuesImpl.getValue(child, "vertical-align");
-				verticalMargins.push({ marginTop: mt, marginBottom: mb, valign: valign });
+				var valign:* = ValuesManager.valuesImpl.getValue(child, "vertical-align");
+				marginObject.valign = valign;
+                if (valign !== undefined)
+                    hasVerticalAlign = true;
 			}
-			for (i = 0; i < n; i++)
-			{
-				var obj:Object = verticalMargins[0]
-				child = contentView.getElementAt(i) as IUIBase;
-				if (child == null || !child.visible) continue;
-                if (child is ILayoutChild)
+            if (hostSizedToContent)
+            {
+                ILayoutChild(contentView).setHeight(maxHeight, true);
+                if (host.isWidthSizedToContent())
+                    ILayoutChild(contentView).setWidth(xx, true);
+                for (i = 0; i < n; i++)
                 {
-                    ilc = child as ILayoutChild;
-                    if (!isNaN(ilc.percentHeight))
-                        ilc.setHeight(contentView.height * ilc.percentHeight / 100, true);
+                    child = contentView.getElementAt(i) as IUIBase;
+                    if (child == null || !child.visible) continue;
+                    var obj:Object = verticalMargins[i];
+                    setPositionAndHeight(child, obj.top, obj.marginTop,
+                        obj.bottom, obj.marginBottom, maxHeight);
                 }
-				if (obj.valign == "middle")
-					child.y = (maxHeight - child.clientHeight) / 2;
-				else if (valign == "bottom")
-					child.y = maxHeight - child.clientHeight - obj.marginBottom;
-				else
-					child.y = obj.marginTop;
-                child.dispatchEvent(new Event("sizeChanged"));
-			}
+            }
+            if (hasVerticalAlign)
+            {
+    			for (i = 0; i < n; i++)
+    			{
+    				child = contentView.getElementAt(i) as IUIBase;
+    				if (child == null || !child.visible) continue;
+                    obj = verticalMargins[i];
+                    if (child is ILayoutChild)
+                    {
+                        ilc = child as ILayoutChild;
+                        if (!isNaN(ilc.percentHeight))
+                            ilc.setHeight(contentView.height * ilc.percentHeight / 100, !isNaN(ilc.percentHeight));
+                    }
+    				if (obj.valign == "middle")
+    					child.y = (maxHeight - child.clientHeight) / 2;
+    				else if (valign == "bottom")
+    					child.y = maxHeight - child.clientHeight - obj.marginBottom;
+    				else
+    					child.y = obj.marginTop;
+    			}
+            }
+            return true;
 		}
+        
+        private function setPositionAndHeight(child:IUIBase, top:Number, mt:Number,
+                                             bottom:Number, mb:Number, h:Number):void
+        {
+            var heightSet:Boolean = false;
+            
+            var hh:Number = h;
+            var ilc:ILayoutChild = child as ILayoutChild;
+            if (!isNaN(top))
+            {
+                child.y = top + mt;
+                hh -= top + mt;
+            }
+            else 
+            {
+                child.y = mt;
+                hh -= top;
+            }
+            if (!isNaN(bottom))
+            {
+                if (!isNaN(top))
+                {
+                    if (ilc)
+                        ilc.setHeight(hh - bottom - mb, true);
+                    else 
+                    {
+                        child.height = hh - bottom - mb;
+                        heightSet = true;
+                    }
+                }
+                else
+                    child.y = h - bottom - mb - child.clientHeight;
+            }
+            if (ilc)
+            {
+                if (!isNaN(ilc.percentHeight))
+                    ilc.setHeight(h * ilc.percentHeight / 100, true);
+            }
+            if (!heightSet)
+                child.dispatchEvent(new Event("sizeChanged"));
+        }
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalScrollingLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalScrollingLayout.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalScrollingLayout.as
index 1e19e48..066d5f1 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalScrollingLayout.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/HorizontalScrollingLayout.as
@@ -70,13 +70,17 @@ package org.apache.flex.html.beads.layouts
 		public function set strand(value:IStrand):void
 		{
 			_strand = value;
-			
-			IEventDispatcher(value).addEventListener("heightChanged", changeHandler);
-			IEventDispatcher(value).addEventListener("widthChanged", changeHandler);
-			IEventDispatcher(value).addEventListener("itemsCreated", changeHandler);
 		}
 		
-		private function changeHandler(event:Event):void
+        /**
+         *  @copy org.apache.flex.core.IBeadLayout#layout
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		public function layout():Boolean
 		{            
 			var layoutParent:IScrollingLayoutParent = 
                         _strand.getBeadByType(IScrollingLayoutParent) as IScrollingLayoutParent;
@@ -126,6 +130,7 @@ package org.apache.flex.html.beads.layouts
 				hScrollBar.visible = false;
 			}
 			*/
+            return true;
 		}
 		
 		/*private function scrollHandler(event:Event):void

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/TileLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/TileLayout.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/TileLayout.as
index cbdb4dc..ea7e7df 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/TileLayout.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/layouts/TileLayout.as
@@ -63,11 +63,7 @@ package org.apache.flex.html.beads.layouts
 		 */
 		public function set strand(value:IStrand):void
 		{
-			_strand = value;
-			
-			IEventDispatcher(_strand).addEventListener("itemsCreated",handleCreated);
-			IEventDispatcher(_strand).addEventListener("childrenAdded",handleCreated);
-			IEventDispatcher(_strand).addEventListener("layoutNeeded",handleCreated);
+			_strand = value;			
 		}
 		
 		private var _numColumns:Number = 4;
@@ -129,32 +125,21 @@ package org.apache.flex.html.beads.layouts
 			_rowHeight = value;
 		}
 		
-		/**
-		 * @private
-		 */
-		private function handleCreated(event:Event):void
-		{
-			// this is where we know the strand has things in it and we want to
-			// get the part of the strand that holds the items for the layout
-			updateLayout();
-		}
-		
-		/**
-		 * @private
-		 */
-		protected function updateLayout():void
+        /**
+         * @copy org.apache.flex.core.IBeadLayout#layout
+         */
+		public function layout():Boolean
 		{
 			// this is where the layout is calculated
 			var p:ILayoutParent = _strand.getBeadByType(ILayoutParent) as ILayoutParent;
 			var area:UIBase = p.contentView as UIBase;
-			if (area == null) return;
 			
 			var xpos:Number = 0;
 			var ypos:Number = 0;
 			var useWidth:Number = columnWidth;
 			var useHeight:Number = rowHeight;
 			var n:Number = area.numChildren;
-			if (n == 0) return;
+			if (n == 0) return false;
 			
 			var realN:Number = n;
 			for(var j:int=0; j < n; j++)
@@ -188,6 +173,7 @@ package org.apache.flex.html.beads.layouts
 					ypos += useHeight;
 				} 
 			}
+            return true;
 		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3c23b3a1/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 f01b2b4..6d299eb 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
@@ -69,19 +69,16 @@ package org.apache.flex.html.beads.layouts
 		{
 			_strand = value;
 			sbView = _strand.getBeadByType(IScrollBarView) as IScrollBarView;
-			sbModel = _strand.getBeadByType(IScrollBarModel) as IScrollBarModel;
-			sbModel.addEventListener("maximumChange", changeHandler);
-			sbModel.addEventListener("minimumChange", changeHandler);
-			sbModel.addEventListener("snapIntervalChange", changeHandler);
-			sbModel.addEventListener("stepSizeChange", changeHandler);
-            sbModel.addEventListener("pageSizeChange", changeHandler);
-			sbModel.addEventListener("valueChange", changeHandler);
-			IEventDispatcher(_strand).addEventListener("heightChanged", changeHandler);
-			changeHandler(null);
 		}
 	
-		private function changeHandler(event:Event):void
+        /**
+         * @copy org.apache.flex.core.IBeadLayout#layout
+         */
+		public function layout():Boolean
 		{
+            if (!sbModel)
+                sbModel = _strand.getBeadByType(IScrollBarModel) as IScrollBarModel
+                    
 			var h:Number = DisplayObject(_strand).height;
 			var increment:DisplayObject = sbView.increment;
 			var decrement:DisplayObject = sbView.decrement;
@@ -105,6 +102,7 @@ package org.apache.flex.html.beads.layouts
 			{
 				thumb.visible = false;
 			}
+            return true;
 		}
 						
 	}


Mime
View raw message