Split COMPILE::SWF and COMPILE::JS into separate functions.
Use setDisplayStyleForLayout() for compatibility with the visible property.


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

Branch: refs/heads/feature/strand-work
Commit: 0bc728cf5f37793f01c2645fdeaa143e37d82ca2
Parents: ff5cf8e
Author: Harbs <ha...@in-tools.com>
Authored: Thu Aug 3 18:56:45 2017 +0300
Committer: Harbs <ha...@in-tools.com>
Committed: Thu Aug 3 18:56:45 2017 +0300

----------------------------------------------------------------------
 .../html/beads/layouts/HorizontalFlexLayout.as  | 298 ++++++++++---------
 .../layouts/OneFlexibleChildHorizontalLayout.as |   3 +-
 .../layouts/OneFlexibleChildVerticalLayout.as   |   3 +-
 .../html/beads/layouts/VerticalFlexLayout.as    | 288 +++++++++---------
 4 files changed, 308 insertions(+), 284 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0bc728cf/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as
 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as
index d6d2449..52550ed 100644
--- 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as
+++ 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalFlexLayout.as
@@ -95,178 +95,190 @@ package org.apache.flex.html.beads.layouts
 
                /**
                 * @copy org.apache.flex.core.IBeadLayout#layout
-                * @flexjsignorecoercion org.apache.flex.core.ILayoutHost
                 *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
                 *  @productversion FlexJS 0.8
                 */
+               COMPILE::SWF
                override public function layout():Boolean
                {
-                       COMPILE::SWF {
-                               var contentView:ILayoutView = layoutView;
-
-                               var n:Number = contentView.numElements;
-                               if (n == 0) return false;
-
-                               var spacing:String = "none";
-
-                               var maxWidth:Number = 0;
-                               var maxHeight:Number = 0;
-                               var growCount:Number = 0;
-                               var childData:Array = [];
-                               var hostWidthSizedToContent:Boolean = 
host.isWidthSizedToContent();
-                               var hostHeightSizedToContent:Boolean = 
host.isHeightSizedToContent();
-                               var hostWidth:Number = host.width;
-                               var hostHeight:Number = host.height;
-
-                               var ilc:ILayoutChild;
-                               var data:Object;
-                               var canAdjust:Boolean = false;
-                               
-                               var paddingMetrics:Rectangle = 
CSSContainerUtils.getPaddingMetrics(host);
-                               var borderMetrics:Rectangle = 
CSSContainerUtils.getBorderMetrics(host);
-                               
-                               // adjust the host's usable size by the 
metrics. If hostSizedToContent, then the
-                               // resulting adjusted value may be less than 
zero.
-                               hostWidth -= paddingMetrics.left + 
paddingMetrics.right + borderMetrics.left + borderMetrics.right;
-                               hostHeight -= paddingMetrics.top + 
paddingMetrics.bottom + borderMetrics.top + borderMetrics.bottom;
-                               
-                               if ((hostWidth <= 0 && 
!hostWidthSizedToContent) || (hostHeight <= 0 && !hostHeightSizedToContent)) 
return false;
-                               
-                               var remainingWidth:Number = hostWidth;
+                       
+                       var contentView:ILayoutView = layoutView;
+
+                       var n:Number = contentView.numElements;
+                       if (n == 0) return false;
+
+                       var spacing:String = "none";
+
+                       var maxWidth:Number = 0;
+                       var maxHeight:Number = 0;
+                       var growCount:Number = 0;
+                       var childData:Array = [];
+                       var hostWidthSizedToContent:Boolean = 
host.isWidthSizedToContent();
+                       var hostHeightSizedToContent:Boolean = 
host.isHeightSizedToContent();
+                       var hostWidth:Number = host.width;
+                       var hostHeight:Number = host.height;
+
+                       var ilc:ILayoutChild;
+                       var data:Object;
+                       var canAdjust:Boolean = false;
+                       
+                       var paddingMetrics:Rectangle = 
CSSContainerUtils.getPaddingMetrics(host);
+                       var borderMetrics:Rectangle = 
CSSContainerUtils.getBorderMetrics(host);
+                       
+                       // adjust the host's usable size by the metrics. If 
hostSizedToContent, then the
+                       // resulting adjusted value may be less than zero.
+                       hostWidth -= paddingMetrics.left + paddingMetrics.right 
+ borderMetrics.left + borderMetrics.right;
+                       hostHeight -= paddingMetrics.top + 
paddingMetrics.bottom + borderMetrics.top + borderMetrics.bottom;
+                       
+                       if ((hostWidth <= 0 && !hostWidthSizedToContent) || 
(hostHeight <= 0 && !hostHeightSizedToContent)) return false;
+                       
+                       var remainingWidth:Number = hostWidth;
+
+                       //trace("HorizontalFlexLayout for "+UIBase(host).id+" 
with remainingWidth: "+remainingWidth);
+
+                       // First pass determines the data about the child.
+                       for(var i:int=0; i < n; i++)
+                       {
+                               var child:IUIBase = contentView.getElementAt(i) 
as IUIBase;
+                               if (child == null || !child.visible) {
+                                       childData.push({width:0, height:0, 
mt:0, ml:0, mr:0, mb:0, canAdjust:false});
+                                       continue;
+                               }
 
-                               //trace("HorizontalFlexLayout for 
"+UIBase(host).id+" with remainingWidth: "+remainingWidth);
+                               ilc = child as ILayoutChild;
+                               
+                               var margins:Object = childMargins(child, 
hostWidth, hostHeight);
+
+                               var flexGrow:Object = 
ValuesManager.valuesImpl.getValue(child, "flex-grow");
+                               var growValue:Number = 0;
+                               if (flexGrow != null) {
+                                       growValue = Number(flexGrow);
+                                       if (!isNaN(growValue) && growValue > 0) 
growCount++;
+                                       else growValue = 0;
+                               }
 
-                               // First pass determines the data about the 
child.
-                               for(var i:int=0; i < n; i++)
-                               {
-                                       var child:IUIBase = 
contentView.getElementAt(i) as IUIBase;
-                                       if (child == null || !child.visible) {
-                                               childData.push({width:0, 
height:0, mt:0, ml:0, mr:0, mb:0, canAdjust:false});
-                                               continue;
+                               var useHeight:Number = -1;
+                               if (!hostHeightSizedToContent) {
+                                       if (ilc) {
+                                               if (!isNaN(ilc.percentHeight)) 
useHeight = hostHeight * (ilc.percentHeight/100.0);
+                                               else if 
(!isNaN(ilc.explicitHeight)) useHeight = ilc.explicitHeight;
+                                               else useHeight = hostHeight;
                                        }
+                               }
 
-                                       ilc = child as ILayoutChild;
-                                       
-                                       var margins:Object = 
childMargins(child, hostWidth, hostHeight);
-
-                                       var flexGrow:Object = 
ValuesManager.valuesImpl.getValue(child, "flex-grow");
-                                       var growValue:Number = 0;
-                                       if (flexGrow != null) {
-                                               growValue = Number(flexGrow);
-                                               if (!isNaN(growValue) && 
growValue > 0) growCount++;
-                                               else growValue = 0;
-                                       }
+                               var useWidth:Number = -1;
+                               if (ilc) {
+                                       if (!isNaN(ilc.explicitWidth)) useWidth 
= ilc.explicitWidth;
+                                       else if (!isNaN(ilc.percentWidth)) 
useWidth = hostWidth * (ilc.percentWidth/100.0);
+                                       else if (ilc.width > 0) useWidth = 
ilc.width;
+                               }
+                               if (growValue == 0 && useWidth > 0) 
remainingWidth -= useWidth + margins.left + margins.right;
+                               else remainingWidth -= margins.left + 
margins.right;
 
-                                       var useHeight:Number = -1;
-                                       if (!hostHeightSizedToContent) {
-                                               if (ilc) {
-                                                       if 
(!isNaN(ilc.percentHeight)) useHeight = hostHeight * (ilc.percentHeight/100.0);
-                                                       else if 
(!isNaN(ilc.explicitHeight)) useHeight = ilc.explicitHeight;
-                                                       else useHeight = 
hostHeight;
-                                               }
-                                       }
+                               if (maxWidth < useWidth) maxWidth = useWidth;
+                               if (maxHeight < useHeight) maxHeight = 
useHeight;
 
-                                       var useWidth:Number = -1;
-                                       if (ilc) {
-                                               if (!isNaN(ilc.explicitWidth)) 
useWidth = ilc.explicitWidth;
-                                               else if 
(!isNaN(ilc.percentWidth)) useWidth = hostWidth * (ilc.percentWidth/100.0);
-                                               else if (ilc.width > 0) 
useWidth = ilc.width;
-                                       }
-                                       if (growValue == 0 && useWidth > 0) 
remainingWidth -= useWidth + margins.left + margins.right;
-                                       else remainingWidth -= margins.left + 
margins.right;
+                               childData.push({width:useWidth, 
height:useHeight, 
+                                                               mt:margins.top, 
ml:margins.left, mr:margins.right, mb:margins.bottom, 
+                                                               grow:growValue, 
canAdjust:canAdjust});
+                       }
 
-                                       if (maxWidth < useWidth) maxWidth = 
useWidth;
-                                       if (maxHeight < useHeight) maxHeight = 
useHeight;
+                       var xpos:Number = borderMetrics.left + 
paddingMetrics.left;
+                       var ypos:Number = borderMetrics.top + 
paddingMetrics.top;
 
-                                       childData.push({width:useWidth, 
height:useHeight, 
-                                                           mt:margins.top, 
ml:margins.left, mr:margins.right, mb:margins.bottom, 
-                                                                       
grow:growValue, canAdjust:canAdjust});
-                               }
+                       // Second pass sizes and positions the children based 
on the data gathered.
+                       for(i=0; i < n; i++)
+                       {
+                               child = contentView.getElementAt(i) as IUIBase;
+                               data = childData[i];
+                               //if (data.width == 0 || data.height == 0) 
continue;
 
-                               var xpos:Number = borderMetrics.left + 
paddingMetrics.left;
-                               var ypos:Number = borderMetrics.top + 
paddingMetrics.top;
+                               useHeight = (data.height < 0 ? maxHeight : 
data.height);
 
-                               // Second pass sizes and positions the children 
based on the data gathered.
-                               for(i=0; i < n; i++)
-                               {
-                                       child = contentView.getElementAt(i) as 
IUIBase;
-                                       data = childData[i];
-                                       //if (data.width == 0 || data.height == 
0) continue;
-
-                                       useHeight = (data.height < 0 ? 
maxHeight : data.height);
-
-                                       var setWidth:Boolean = true;
-                                       if (data.width != 0) {
-                                               if (data.grow > 0 && growCount 
> 0) {
-                                                       useWidth = 
remainingWidth / growCount;
-                                                       setWidth = false;
-                                               } else {
-                                                       useWidth = data.width;
-                                               }
+                               var setWidth:Boolean = true;
+                               if (data.width != 0) {
+                                       if (data.grow > 0 && growCount > 0) {
+                                               useWidth = remainingWidth / 
growCount;
+                                               setWidth = false;
                                        } else {
-                                               useWidth = child.width;
+                                               useWidth = data.width;
                                        }
+                               } else {
+                                       useWidth = child.width;
+                               }
 
-                                       ilc = child as ILayoutChild;
-                                       if (ilc) {
-                                               ilc.setX(xpos + data.ml);
-                                               ilc.setY(ypos + data.mt);
-                                               if (data.height > 0) {
-                                                       //ilc.height = 
useHeight;
-                                                       
ilc.setHeight(useHeight);
-                                               }
-                                               if (useWidth > 0) {
-                                                       if (setWidth) 
ilc.setWidth(useWidth);
-                                                       else ilc.width = 
useWidth;
-                                               }
-                                       } else {
-                                               child.x = xpos + data.ml;
-                                               child.y = ypos + data.mt;
-                                               child.height = useHeight;
-                                               if (data.width > 0) {
-                                                       child.width = useWidth;
-                                               }
+                               ilc = child as ILayoutChild;
+                               if (ilc) {
+                                       ilc.setX(xpos + data.ml);
+                                       ilc.setY(ypos + data.mt);
+                                       if (data.height > 0) {
+                                               //ilc.height = useHeight;
+                                               ilc.setHeight(useHeight);
+                                       }
+                                       if (useWidth > 0) {
+                                               if (setWidth) 
ilc.setWidth(useWidth);
+                                               else ilc.width = useWidth;
+                                       }
+                               } else {
+                                       child.x = xpos + data.ml;
+                                       child.y = ypos + data.mt;
+                                       child.height = useHeight;
+                                       if (data.width > 0) {
+                                               child.width = useWidth;
                                        }
-
-                                       xpos += useWidth + data.mr + data.ml;
-
-                                       //trace("HorizontalFlexLayout: setting 
child "+i+" to "+child.width+" x "+child.height+" at "+child.x+", "+child.y);
                                }
 
-                               //trace("HorizontalFlexLayout: complete");
+                               xpos += useWidth + data.mr + data.ml;
 
-                               return true;
+                               //trace("HorizontalFlexLayout: setting child 
"+i+" to "+child.width+" x "+child.height+" at "+child.x+", "+child.y);
                        }
 
-                       COMPILE::JS {
-                               var contentView:ILayoutView = layoutView;
-
-                               // set the display on the contentView
-                               contentView.element.style["display"] = "flex";
-                               contentView.element.style["flex-flow"] = "row";
-
-                               var n:int = contentView.numElements;
-                               if (n == 0) return false;
-
-                               for(var i:int=0; i < n; i++) {
-                                       var child:UIBase = 
contentView.getElementAt(i) as UIBase;
-                                       if (!child)
-                                       {
-                                               continue;
-                    }
-                                       
-                                       if (grow >= 0) 
child.element.style["flex-grow"] = String(grow);
-                                       if (shrink >= 0) 
child.element.style["flex-shrink"] = String(shrink);
-                                       if (!isNaN(child.percentWidth))
-                                               
child.element.style["flex-basis"] = child.percentWidth.toString() + "%";
-                                       child.dispatchEvent(new 
Event("layoutNeeded"));
-                               }
+                       //trace("HorizontalFlexLayout: complete");
+
+                       return true;
+               }
+               /**
+                * @copy org.apache.flex.core.IBeadLayout#layout
+                * @flexjsignorecoercion org.apache.flex.core.ILayoutHost
+                * @flexjsignorecoercion org.apache.flex.core.UIBase
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.8
+                */
+               COMPILE::JS
+               override public function layout():Boolean
+               {
+
+                       var contentView:ILayoutView = layoutView;
 
-                               return true;
+                       // set the display on the contentView
+                       (contentView as 
UIBase).setDisplayStyleForLayout("flex");
+                       // contentView.element.style["display"] = "flex";
+                       contentView.element.style["flex-flow"] = "row";
+
+                       var n:int = contentView.numElements;
+                       if (n == 0) return false;
+
+                       for(var i:int=0; i < n; i++) {
+                               var child:UIBase = contentView.getElementAt(i) 
as UIBase;
+                               if (!child)
+                               {
+                                       continue;
+                               }
+                               
+                               if (grow >= 0) child.element.style["flex-grow"] 
= String(grow);
+                               if (shrink >= 0) 
child.element.style["flex-shrink"] = String(shrink);
+                               if (!isNaN(child.percentWidth))
+                                       child.element.style["flex-basis"] = 
child.percentWidth.toString() + "%";
+                               child.dispatchEvent(new Event("layoutNeeded"));
                        }
+
+                       return true;
                }
        }
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0bc728cf/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
index f0853fa..abfe593 100644
--- 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
+++ 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildHorizontalLayout.as
@@ -153,7 +153,8 @@ package org.apache.flex.html.beads.layouts
                        actualChild = document[flexibleChild];
 
                        // set the display on the contentView
-                       contentView.element.style["display"] = "flex";
+                       (contentView as 
UIBase).setDisplayStyleForLayout("flex");
+                       // contentView.element.style["display"] = "flex";
                        contentView.element.style["flex-flow"] = "row";
                        var align:String = 
ValuesManager.valuesImpl.getValue(host, "alignItems");
                        if (align == "center")

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0bc728cf/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
index c4d70e1..e7c1d58 100644
--- 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
+++ 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/OneFlexibleChildVerticalLayout.as
@@ -154,7 +154,8 @@ package org.apache.flex.html.beads.layouts
                        actualChild = document[flexibleChild];
 
                        // set the display on the contentView
-                       contentView.element.style["display"] = "flex";
+                       (contentView as 
UIBase).setDisplayStyleForLayout("flex");
+                       // contentView.element.style["display"] = "flex";
                        contentView.element.style["flex-flow"] = "column";
                        var align:String = 
ValuesManager.valuesImpl.getValue(host, "alignItems");
                        if (align == "center")

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0bc728cf/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as
 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as
index 2126616..d0b1c23 100644
--- 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as
+++ 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/VerticalFlexLayout.as
@@ -102,173 +102,183 @@ package org.apache.flex.html.beads.layouts
                 *  @playerversion AIR 2.6
                 *  @productversion FlexJS 0.8
                 */
+               COMPILE::SWF
                override public function layout():Boolean
                {
-                       COMPILE::SWF {
-                               var contentView:ILayoutView = layoutView;
-
-                               var n:Number = contentView.numElements;
-                               if (n == 0) return false;
-
-                               var maxWidth:Number = 0;
-                               var maxHeight:Number = 0;
-                               var growCount:Number = 0;
-                               var childData:Array = [];
-                               var hostWidthSizedToContent:Boolean = 
host.isWidthSizedToContent();
-                               var hostHeightSizedToContent:Boolean = 
host.isHeightSizedToContent();
-                               var hostWidth:Number = host.width;
-                               var hostHeight:Number = host.height;
-
-                               var ilc:ILayoutChild;
-                               var data:Object;
-                               var canAdjust:Boolean = false;
-                               
-                               var paddingMetrics:Rectangle = 
CSSContainerUtils.getPaddingMetrics(host);
-                               var borderMetrics:Rectangle = 
CSSContainerUtils.getBorderMetrics(host);
-                               
-                               // adjust the host's usable size by the 
metrics. If hostSizedToContent, then the
-                               // resulting adjusted value may be less than 
zero.
-                               var extra:Number = paddingMetrics.left + 
paddingMetrics.right + borderMetrics.left + borderMetrics.right;
-                               if (hostWidthSizedToContent)
-                                       hostWidth += extra;
-                               else
-                                       hostWidth -= extra;
-                               extra = paddingMetrics.top + 
paddingMetrics.bottom + borderMetrics.top + borderMetrics.bottom;
-                               if (hostHeightSizedToContent)
-                                       hostHeight += extra;
-                               else
-                                       hostHeight -= extra;
-                               
-                               var remainingHeight:Number = hostHeight;
+                       var contentView:ILayoutView = layoutView;
+
+                       var n:Number = contentView.numElements;
+                       if (n == 0) return false;
+
+                       var maxWidth:Number = 0;
+                       var maxHeight:Number = 0;
+                       var growCount:Number = 0;
+                       var childData:Array = [];
+                       var hostWidthSizedToContent:Boolean = 
host.isWidthSizedToContent();
+                       var hostHeightSizedToContent:Boolean = 
host.isHeightSizedToContent();
+                       var hostWidth:Number = host.width;
+                       var hostHeight:Number = host.height;
+
+                       var ilc:ILayoutChild;
+                       var data:Object;
+                       var canAdjust:Boolean = false;
+                       
+                       var paddingMetrics:Rectangle = 
CSSContainerUtils.getPaddingMetrics(host);
+                       var borderMetrics:Rectangle = 
CSSContainerUtils.getBorderMetrics(host);
+                       
+                       // adjust the host's usable size by the metrics. If 
hostSizedToContent, then the
+                       // resulting adjusted value may be less than zero.
+                       var extra:Number = paddingMetrics.left + 
paddingMetrics.right + borderMetrics.left + borderMetrics.right;
+                       if (hostWidthSizedToContent)
+                               hostWidth += extra;
+                       else
+                               hostWidth -= extra;
+                       extra = paddingMetrics.top + paddingMetrics.bottom + 
borderMetrics.top + borderMetrics.bottom;
+                       if (hostHeightSizedToContent)
+                               hostHeight += extra;
+                       else
+                               hostHeight -= extra;
+                       
+                       var remainingHeight:Number = hostHeight;
+
+                       //trace("VerticalFlexLayout for "+UIBase(host).id+" 
with remainingHeight: "+remainingHeight);
+
+                       // First pass determines the data about the child.
+                       for(var i:int=0; i < n; i++)
+                       {
+                               var child:IUIBase = contentView.getElementAt(i) 
as IUIBase;
+                               if (child == null || !child.visible) {
+                                       childData.push({width:0, height:0, 
mt:0, ml:0, mr:0, mb:0, grow:0, canAdjust:false});
+                                       continue;
+                               }
 
-                               //trace("VerticalFlexLayout for 
"+UIBase(host).id+" with remainingHeight: "+remainingHeight);
+                               ilc = child as ILayoutChild;
+                               
+                               var margins:Object = childMargins(child, 
hostWidth, hostHeight);
+
+                               var flexGrow:Object = 
ValuesManager.valuesImpl.getValue(child, "flex-grow");
+                               var growValue:Number = 0;
+                               if (flexGrow != null) {
+                                       growValue = Number(flexGrow);
+                                       if (!isNaN(growValue) && growValue > 0) 
growCount++;
+                                       else growValue = 0;
+                               }
 
-                               // First pass determines the data about the 
child.
-                               for(var i:int=0; i < n; i++)
-                               {
-                                       var child:IUIBase = 
contentView.getElementAt(i) as IUIBase;
-                                       if (child == null || !child.visible) {
-                                               childData.push({width:0, 
height:0, mt:0, ml:0, mr:0, mb:0, grow:0, canAdjust:false});
-                                               continue;
+                               var useWidth:Number = -1;
+                               if (ilc) {
+                                       if (!isNaN(ilc.percentWidth)) useWidth 
= hostWidth * (ilc.percentWidth/100.0);
+                                       else if (!isNaN(ilc.explicitWidth)) 
useWidth = ilc.explicitWidth;
+                                       else if (!hostWidthSizedToContent) {
+                                               useWidth = hostWidth;
                                        }
+                               }
 
-                                       ilc = child as ILayoutChild;
-                                       
-                                       var margins:Object = 
childMargins(child, hostWidth, hostHeight);
-
-                                       var flexGrow:Object = 
ValuesManager.valuesImpl.getValue(child, "flex-grow");
-                                       var growValue:Number = 0;
-                                       if (flexGrow != null) {
-                                               growValue = Number(flexGrow);
-                                               if (!isNaN(growValue) && 
growValue > 0) growCount++;
-                                               else growValue = 0;
-                                       }
+                               var useHeight:Number = -1;
+                               if (ilc) {
+                                       if (!isNaN(ilc.explicitHeight)) 
useHeight = ilc.explicitHeight;
+                                       else if (!isNaN(ilc.percentHeight)) 
useHeight = hostHeight * (ilc.percentHeight/100.0);
+                                       else if (ilc.height > 0) useHeight = 
ilc.height;
+                               }
+                               if (growValue == 0 && useHeight > 0) 
remainingHeight -= useHeight + margins.top + margins.bottom;
+                               else remainingHeight -= margins.top + 
margins.bottom;
 
-                                       var useWidth:Number = -1;
-                                       if (ilc) {
-                                               if (!isNaN(ilc.percentWidth)) 
useWidth = hostWidth * (ilc.percentWidth/100.0);
-                                               else if 
(!isNaN(ilc.explicitWidth)) useWidth = ilc.explicitWidth;
-                                               else if 
(!hostWidthSizedToContent) {
-                                                       useWidth = hostWidth;
-                                               }
-                                       }
+                               if (maxWidth < useWidth) maxWidth = useWidth;
+                               if (maxHeight < useHeight) maxHeight = 
useHeight;
 
-                                       var useHeight:Number = -1;
-                                       if (ilc) {
-                                               if (!isNaN(ilc.explicitHeight)) 
useHeight = ilc.explicitHeight;
-                                               else if 
(!isNaN(ilc.percentHeight)) useHeight = hostHeight * (ilc.percentHeight/100.0);
-                                               else if (ilc.height > 0) 
useHeight = ilc.height;
-                                       }
-                                       if (growValue == 0 && useHeight > 0) 
remainingHeight -= useHeight + margins.top + margins.bottom;
-                                       else remainingHeight -= margins.top + 
margins.bottom;
+                               childData.push({width:useWidth, 
height:useHeight, 
+                                                               mt:margins.top, 
ml:margins.left, mr:margins.right, mb:margins.bottom, 
+                                                               grow:growValue, 
canAdjust:canAdjust});
+                       }
 
-                                       if (maxWidth < useWidth) maxWidth = 
useWidth;
-                                       if (maxHeight < useHeight) maxHeight = 
useHeight;
+                       var xpos:Number = borderMetrics.left + 
paddingMetrics.left;
+                       var ypos:Number = borderMetrics.top + 
paddingMetrics.top;
 
-                                       childData.push({width:useWidth, 
height:useHeight, 
-                                                           mt:margins.top, 
ml:margins.left, mr:margins.right, mb:margins.bottom, 
-                                                                       
grow:growValue, canAdjust:canAdjust});
-                               }
+                       // Second pass sizes and positions the children based 
on the data gathered.
+                       for(i=0; i < n; i++)
+                       {
+                               child = contentView.getElementAt(i) as IUIBase;
+                               data = childData[i];
 
-                               var xpos:Number = borderMetrics.left + 
paddingMetrics.left;
-                               var ypos:Number = borderMetrics.top + 
paddingMetrics.top;
+                               useWidth = (data.width < 0 ? hostWidth : 
data.width);
 
-                               // Second pass sizes and positions the children 
based on the data gathered.
-                               for(i=0; i < n; i++)
-                               {
-                                       child = contentView.getElementAt(i) as 
IUIBase;
-                                       data = childData[i];
-
-                                       useWidth = (data.width < 0 ? hostWidth 
: data.width);
-
-                                       var setHeight:Boolean = true;
-                                       if (data.height != 0 && 
!hostHeightSizedToContent) {
-                                               if (data.grow > 0 && growCount 
> 0) {
-                                                       useHeight = 
remainingHeight / growCount;
-                                                       setHeight = false;
-                                               } else {
-                                                       useHeight = data.height;
-                                               }
+                               var setHeight:Boolean = true;
+                               if (data.height != 0 && 
!hostHeightSizedToContent) {
+                                       if (data.grow > 0 && growCount > 0) {
+                                               useHeight = remainingHeight / 
growCount;
+                                               setHeight = false;
                                        } else {
-                                               useHeight = child.height;
+                                               useHeight = data.height;
                                        }
+                               } else {
+                                       useHeight = child.height;
+                               }
 
-                                       ilc = child as ILayoutChild;
-                                       if (ilc) {
-                                               ilc.setX(xpos + data.ml);
-                                               ilc.setY(ypos + data.mt);
-                                               if (data.width > 0) {
-                                                       //ilc.width = useWidth;
-                                                       ilc.setWidth(useWidth);
-                                               }
-                                               if (useHeight > 0) {
-                                                       if (setHeight) 
ilc.setHeight(useHeight);
-                                                       else ilc.height = 
useHeight;
-                                               }
-                                       } else {
-                                               child.x = xpos + data.ml;
-                                               child.y = ypos + data.mt;
-                                               child.width = useWidth;
-                                               if (useHeight > 0) {
-                                                       child.height = 
useHeight;
-                                               }
+                               ilc = child as ILayoutChild;
+                               if (ilc) {
+                                       ilc.setX(xpos + data.ml);
+                                       ilc.setY(ypos + data.mt);
+                                       if (data.width > 0) {
+                                               //ilc.width = useWidth;
+                                               ilc.setWidth(useWidth);
+                                       }
+                                       if (useHeight > 0) {
+                                               if (setHeight) 
ilc.setHeight(useHeight);
+                                               else ilc.height = useHeight;
+                                       }
+                               } else {
+                                       child.x = xpos + data.ml;
+                                       child.y = ypos + data.mt;
+                                       child.width = useWidth;
+                                       if (useHeight > 0) {
+                                               child.height = useHeight;
                                        }
-
-                                       ypos += useHeight + data.mt + data.mb;
-
-                                       //trace("VerticalFlexLayout: setting 
child "+i+" to "+child.width+" x "+child.height+" at "+child.x+", "+child.y);
                                }
 
-                               //trace("VerticalFlexLayout: complete");
+                               ypos += useHeight + data.mt + data.mb;
 
-                               return true;
+                               //trace("VerticalFlexLayout: setting child 
"+i+" to "+child.width+" x "+child.height+" at "+child.x+", "+child.y);
                        }
 
-                       COMPILE::JS {
-                               var contentView:ILayoutView = layoutView;
+                       //trace("VerticalFlexLayout: complete");
 
-                               contentView.element.style["display"] = "flex";
-                               contentView.element.style["flex-flow"] = 
"column";
+                       return true;
+               }
+               /**
+                *
+                *  @flexjsignorecoercion org.apache.flex.core.ILayoutHost
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.8
+                */
+               COMPILE::JS
+               override public function layout():Boolean
+               {
+                       var contentView:ILayoutView = layoutView;
 
-                               var n:int = contentView.numElements;
-                               if (n == 0) return false;
+                       (contentView as 
UIBase).setDisplayStyleForLayout("flex");
+                       // contentView.element.style["display"] = "flex";
+                       contentView.element.style["flex-flow"] = "column";
 
-                               for(var i:int=0; i < n; i++) {
-                                       var child:UIBase = 
contentView.getElementAt(i) as UIBase;
-                                       if (!child)
-                                       {
-                                               continue;
-                    }
+                       var n:int = contentView.numElements;
+                       if (n == 0) return false;
 
-                                       if (grow >= 0) 
child.element.style["flex-grow"] = String(grow);
-                                       if (shrink >= 0) 
child.element.style["flex-shrink"] = String(shrink);
-                                       if (!isNaN(child.percentHeight))
-                                               
child.element.style["flex-basis"] = child.percentHeight.toString() + "%";
-                                       child.dispatchEvent(new 
Event("layoutNeeded"));
+                       for(var i:int=0; i < n; i++) {
+                               var child:UIBase = contentView.getElementAt(i) 
as UIBase;
+                               if (!child)
+                               {
+                                       continue;
                                }
 
-                               return true;
+                               if (grow >= 0) child.element.style["flex-grow"] 
= String(grow);
+                               if (shrink >= 0) 
child.element.style["flex-shrink"] = String(shrink);
+                               if (!isNaN(child.percentHeight))
+                                       child.element.style["flex-basis"] = 
child.percentHeight.toString() + "%";
+                               child.dispatchEvent(new Event("layoutNeeded"));
                        }
+
+                       return true;
                }
        }
 }

Reply via email to