You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2018/03/26 11:42:35 UTC

[royale-asjs] branch feature/layout-optimization updated: Observed about a 17% performance imporvement

This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch feature/layout-optimization
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/feature/layout-optimization by this push:
     new e93d7f5  Observed about a 17% performance imporvement
e93d7f5 is described below

commit e93d7f5f4614823a420fff573b4cd8694e2c3b6b
Author: Harbs <ha...@in-tools.com>
AuthorDate: Mon Mar 26 14:42:26 2018 +0300

    Observed about a 17% performance imporvement
---
 .../main/royale/org/apache/royale/core/UIBase.as   | 17 +++++++--------
 .../html/beads/layouts/VerticalColumnLayout.as     | 25 ++++++++++++++--------
 2 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/UIBase.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/UIBase.as
index 2e2c777..60cae37 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/UIBase.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/UIBase.as
@@ -711,17 +711,14 @@ package org.apache.royale.core
             else
                 style.left = value;
         }
-        
         /**
          * @royaleignorecoercion HTMLElement
          */
         COMPILE::JS
         public function set x(value:Number):void
         {
-            //positioner.style.position = 'absolute';
-            if (positioner.parentNode != positioner.offsetParent)
-                value += (positioner.parentNode as HTMLElement).offsetLeft;
-            positioner.style.left = value.toString() + 'px';
+            _x = value;
+            setX(value);
         }
 
         /**
@@ -731,6 +728,8 @@ package org.apache.royale.core
         COMPILE::JS
         public function get x():Number
         {
+            if(!isNaN(_x))
+                return _x
             var strpixels:String = positioner.style.left as String;
             var pixels:Number = parseFloat(strpixels);
             if (isNaN(pixels))
@@ -787,10 +786,8 @@ package org.apache.royale.core
         COMPILE::JS
         public function set y(value:Number):void
         {
-            //positioner.style.position = 'absolute';
-            if (positioner.parentNode != positioner.offsetParent)
-                value += (positioner.parentNode as HTMLElement).offsetTop;
-            positioner.style.top = value.toString() + 'px';
+            _y = value;
+            setY(value);
         }
         
         /**
@@ -800,6 +797,8 @@ package org.apache.royale.core
         COMPILE::JS
         public function get y():Number
         {
+            if(!isNaN(_y))
+                return _y
             var strpixels:String = positioner.style.top as String;
             var pixels:Number = parseFloat(strpixels);
             if (isNaN(pixels))
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/VerticalColumnLayout.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/VerticalColumnLayout.as
index 5ee83d4..38aef24 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/VerticalColumnLayout.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/VerticalColumnLayout.as
@@ -102,8 +102,8 @@ package org.apache.royale.html.beads.layouts
 			}
 			
             var padding:EdgeData = (ValuesManager.valuesImpl as IBorderPaddingMarginValuesImpl).getPaddingMetrics(host);
-			var sw:Number = host.width;
-			var sh:Number = host.height;
+			var sw:Number = host.measuredWidth;
+			var sh:Number = host.measuredHeight;
 
             var hasWidth:Boolean = !host.isWidthSizedToContent();
             var hasHeight:Boolean = !host.isHeightSizedToContent();
@@ -119,9 +119,16 @@ package org.apache.royale.html.beads.layouts
 			var n:int = contentView.numElements;
             var rowData:Object = { rowHeight: 0 };
 
+			//cache values to prevent layout thrashing
+			var views:Array = [];
+			var heights:Array = [];
+			var widths:Array = [];
 			// determine max widths of columns
 			for (i = 0; i < n; i++) {
-				e = contentView.getElementAt(i) as IUIBase;
+				views[i] = contentView.getElementAt(i);
+				heights[i] = views[i].height;
+				widths[i] = views[i].width;
+				e = views[i];
 				if (e == null || !e.visible) continue;
 				var margins:Object = childMargins(e, sw, sh);
 				
@@ -133,12 +140,12 @@ package org.apache.royale.html.beads.layouts
 					if (measure)
 						thisPrefWidth = measure.measuredWidth + margins.left + margins.right;
 					else
-						thisPrefWidth = e.width + margins.left + margins.right;
+						thisPrefWidth = widths[i] + margins.left + margins.right;
 				}
 				else
-					thisPrefWidth = e.width + margins.left + margins.right;
+					thisPrefWidth = widths[i] + margins.left + margins.right;
 
-                rowData.rowHeight = Math.max(rowData.rowHeight, e.height + margins.top + margins.bottom);
+                rowData.rowHeight = Math.max(rowData.rowHeight, heights[i] + margins.top + margins.bottom);
 				columns[col] = Math.max(columns[col], thisPrefWidth);
                 col = col + 1;
                 if (col == numColumns)
@@ -157,13 +164,13 @@ package org.apache.royale.html.beads.layouts
 			col = 0;
 			for (i = 0; i < n; i++)
             {
-				e = contentView.getElementAt(i) as IUIBase;
+				e = views[i];
 				if (e == null || !e.visible) continue;
 				e.x = curx + data[i].ml;
 				e.y = cury + data[i].mt;
 				curx += columns[col++];
-                maxHeight = Math.max(maxHeight, e.y + e.height + data[i].mb);
-                maxWidth = Math.max(maxWidth, e.x + e.width + data[i].mr);
+                maxHeight = Math.max(maxHeight, e.y + heights[i] + data[i].mb);
+                maxWidth = Math.max(maxWidth, e.x + widths[i] + data[i].mr);
 				if (col == numColumns)
 				{
 					cury += rows[0].rowHeight;

-- 
To stop receiving notification emails like this one, please contact
harbs@apache.org.