You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2018/08/16 00:53:57 UTC

[royale-asjs] 02/05: in emulation, default to absolute positioning because Flex layouts interpret percentages differently from the browser

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

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

commit ec75fd1d6c847a94925d5533496820e06f036a67
Author: Alex Harui <ah...@apache.org>
AuthorDate: Wed Aug 15 11:22:09 2018 -0700

    in emulation, default to absolute positioning because Flex layouts interpret percentages differently from the browser
---
 .../src/main/royale/mx/containers/beads/BoxLayout.as      | 15 +++++++++------
 .../main/royale/mx/core/LayoutElementUIComponentUtils.as  |  2 +-
 .../MXRoyale/src/main/royale/mx/core/UIComponent.as       |  8 ++++++++
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/BoxLayout.as b/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/BoxLayout.as
index fac8e12..2ae8fca 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/BoxLayout.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/BoxLayout.as
@@ -318,6 +318,9 @@ package mx.containers.beads
 				left = (w - child.width) * horizontalAlign + paddingLeft;
 				top = (h - child.height) * verticalAlign + paddingTop;
 				
+                COMPILE::JS {
+                    child.positioner.style.position = 'absolute';
+                }
 				child.move(Math.floor(left), Math.floor(top));
 			}
 				
@@ -354,12 +357,12 @@ package mx.containers.beads
 				{
 					obj = target.getLayoutChildAt(i);
 					left = (w - obj.width) * horizontalAlign + paddingLeft;
+                    COMPILE::JS {
+                        obj.positioner.style.position = 'absolute';
+                    }
 					obj.move(Math.floor(left), Math.floor(top));
 					if (obj.includeInLayout)
 						top += obj.height + gap;
-					COMPILE::JS {
-						obj.positioner.style.position = 'absolute';
-					}
 				}
 			}
 				
@@ -396,12 +399,12 @@ package mx.containers.beads
 				{
 					obj = target.getLayoutChildAt(i);
 					top = (h - obj.height) * verticalAlign + paddingTop;
+                    COMPILE::JS {
+                        obj.positioner.style.position = 'absolute';
+                    }
 					obj.move(Math.floor(left), Math.floor(top));
 					if (obj.includeInLayout)
 						left += obj.width + gap;
-					COMPILE::JS {
-						obj.positioner.style.position = 'absolute';
-					}
 				}
 			}
 		}
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/LayoutElementUIComponentUtils.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/LayoutElementUIComponentUtils.as
index 0f3ae73..7147d24 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/LayoutElementUIComponentUtils.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/LayoutElementUIComponentUtils.as
@@ -524,11 +524,11 @@ public class LayoutElementUIComponentUtils
             y = y - getLayoutBoundsY(obj,transformMatrix) + obj.y;
         }
         */
-        obj.move(x, y);
         COMPILE::JS
         {
             obj.element.style.position = "absolute";
         }
+        obj.move(x, y);
     }
 
     /**
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
index f15f481..0155cb3 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
@@ -1553,6 +1553,14 @@ COMPILE::JS
     
     override public function addedToParent():void
     {
+        COMPILE::JS
+        {
+            // Flex layouts don't use percentages the way the browser
+            // does, so we have to absolute position everything.  Before
+            // layout runs, we want to establish the parent as the
+            // offsetParent.  Other code may set position="absolute" later.
+            element.style.position = "relative";
+        }
         super.addedToParent();
         
         if (!initialized)