royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [royale-asjs] 21/21: refactor popuphost to have a reference from the effective parent back to the popuphost. this is better than walking the parent chain because in JS we are going to host the popups off the system manager so there is no parent chain to walk. Using systemmanager moves the popups out of the childlist in the application where the layouts try to run on the popup, which may not be a UIComponent (if it is a re-used UIBase from Basic).
Date Fri, 28 Sep 2018 03:43:01 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 642e35c553023301c01e2ff63d01780a6702a708
Author: Alex Harui <aharui@apache.org>
AuthorDate: Thu Sep 27 20:40:39 2018 -0700

    refactor popuphost to have a reference from the effective parent back to the popuphost.
 this is better than walking the parent chain because in JS we are going to host the popups
off the system manager so there is no parent chain to walk.  Using systemmanager moves the
popups out of the childlist in the application where the layouts try to run on the popup,
which may not be a UIComponent (if it is a re-used UIBase from Basic).
---
 .../royale/org/apache/royale/core/Application.as   | 10 +++-
 .../main/royale/org/apache/royale/core/ViewBase.as | 11 ++++-
 .../royale/core/ContainerBaseStrandChildren.as     | 10 +++-
 .../royale/org/apache/royale/core/IPopUpHost.as    |  2 +-
 .../core/{IPopUpHost.as => IPopUpHostParent.as}    | 10 ++--
 .../main/royale/org/apache/royale/utils/UIUtils.as | 13 +++---
 .../src/main/royale/mx/core/Application.as         | 29 ++++++++++--
 .../src/main/royale/mx/managers/SystemManager.as   | 53 ++++++++++++++++++++--
 8 files changed, 113 insertions(+), 25 deletions(-)

diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/Application.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/Application.as
index 6304126..efa7459 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/Application.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/Application.as
@@ -105,7 +105,7 @@ package org.apache.royale.core
      *  @playerversion AIR 2.6
      *  @productversion Royale 0.0
      */
-    public class Application extends ApplicationBase implements IStrand, IParent, IEventDispatcher,
IInitialViewApplication, IPopUpHost, IRenderedObject
+    public class Application extends ApplicationBase implements IStrand, IParent, IEventDispatcher,
IInitialViewApplication, IPopUpHost, IPopUpHostParent, IRenderedObject
     {
         /**
          *  Constructor.
@@ -329,7 +329,7 @@ package org.apache.royale.core
          *  @playerversion AIR 2.6
          *  @productversion Royale 0.0
          */
-        public function get popUpParent():IParent
+        public function get popUpParent():IPopUpHostParent
         {
             return this;
         }
@@ -723,5 +723,11 @@ package org.apache.royale.core
             // Setting this directly doesn't do anything
         }
 
+        /**
+         */
+        public function get popUpHost():IPopUpHost
+        {
+            return this;
+        }
     }
 }
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/ViewBase.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/ViewBase.as
index 33d9bcd..8bc8876 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/ViewBase.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/ViewBase.as
@@ -48,7 +48,7 @@ package org.apache.royale.core
      *  @playerversion AIR 2.6
      *  @productversion Royale 0.0
      */
-	public class ViewBase extends GroupBase implements IPopUpHost, IApplicationView
+	public class ViewBase extends GroupBase implements IPopUpHost, IPopUpHostParent, IApplicationView
 	{
         /**
          *  Constructor.
@@ -101,10 +101,17 @@ package org.apache.royale.core
          *  @playerversion AIR 2.6
          *  @productversion Royale 0.0
          */
-        public function get popUpParent():IParent
+        public function get popUpParent():IPopUpHostParent
         {
             return this;
         }
         
+        /**
+         */
+        public function get popUpHost():IPopUpHost
+        {
+            return this;
+        }
+
     }
 }
diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/ContainerBaseStrandChildren.as
b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/ContainerBaseStrandChildren.as
index a3b4601..6689b1e 100644
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/ContainerBaseStrandChildren.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/ContainerBaseStrandChildren.as
@@ -30,7 +30,7 @@ package org.apache.royale.core
      * 
      *  @royalesuppresspublicvarwarning
      */
-	public class ContainerBaseStrandChildren implements IParent
+	public class ContainerBaseStrandChildren implements IPopUpHostParent
 	{
         /**
          *  Constructor.
@@ -98,5 +98,13 @@ package org.apache.royale.core
 		{
 			return owner.$getElementAt(index);
 		}
+        
+        /**
+         */
+        public function get popUpHost():IPopUpHost
+        {
+            return owner as IPopUpHost;
+        }
+
     }
 }
diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IPopUpHost.as
b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IPopUpHost.as
index 6b62b10..b08ef88 100755
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IPopUpHost.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IPopUpHost.as
@@ -29,6 +29,6 @@ package org.apache.royale.core
      */
     public interface IPopUpHost
 	{
-        function get popUpParent():IParent;
+        function get popUpParent():IPopUpHostParent;
 	}
 }
diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IPopUpHost.as
b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IPopUpHostParent.as
similarity index 77%
copy from frameworks/projects/Core/src/main/royale/org/apache/royale/core/IPopUpHost.as
copy to frameworks/projects/Core/src/main/royale/org/apache/royale/core/IPopUpHostParent.as
index 6b62b10..cbec474 100755
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IPopUpHost.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IPopUpHostParent.as
@@ -19,16 +19,18 @@
 package org.apache.royale.core
 {
     /**
-     *  The IPopUpHost interface is a "marker" interface for a component that
-     *  parents components that implement IPopUp.
+     *  The IPopUpHostParent is the effective parent of popups.
+     *  The actual parent may not be the effective parent in some
+     *  implementations, so the effective parent provides a reference
+     *  back to the IPopUpHost for removing
      * 
      *  @langversion 3.0
      *  @playerversion Flash 10.2
      *  @playerversion AIR 2.6
      *  @productversion Royale 0.0
      */
-    public interface IPopUpHost
+    public interface IPopUpHostParent extends IParent
 	{
-        function get popUpParent():IParent;
+        function get popUpHost():IPopUpHost;
 	}
 }
diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/UIUtils.as b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/UIUtils.as
index c5ea044..de6d827 100644
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/UIUtils.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/UIUtils.as
@@ -21,6 +21,7 @@ package org.apache.royale.utils
 	import org.apache.royale.core.IChild;
 	import org.apache.royale.core.IParent;
 	import org.apache.royale.core.IPopUpHost;
+    import org.apache.royale.core.IPopUpHostParent;
 	import org.apache.royale.core.IUIBase;
 
 	/**
@@ -81,6 +82,9 @@ package org.apache.royale.utils
 		 */
 		public static function findPopUpHost(start:IUIBase):IPopUpHost
 		{
+            if (start.parent is IPopUpHostParent)
+                return (start.parent as IPopUpHostParent).popUpHost;
+            
 			while( start && !(start is IPopUpHost) ) {
 				// start.parent will be undefined in js if it's not an IChild and return null
 				COMPILE::SWF
@@ -105,16 +109,11 @@ package org.apache.royale.utils
 		 *  @playerversion AIR 2.6
 		 *  @productversion Royale 0.9
 		 *  @royaleignorecoercion org.apache.royale.core.IChild
-		 *  @royaleignorecoercion org.apache.royale.core.IPopUpHost
+		 *  @royaleignorecoercion org.apache.royale.core.IPopUpHostParent
 		 */
 		public static function removePopUp(popUp:IChild):void
 		{
-			//TODO (harbs) The loop appears to not be needed. If removeElement is being called, it
seems like the IPopUpHost would be the direct parent.
-			var start:IParent = popUp.parent;
-			while(!(start is IPopUpHost)) {
-				start = IChild(start).parent;
-			}
-			(start as IPopUpHost).popUpParent.removeElement(popUp);
+			(popUp.parent as IPopUpHostParent).popUpHost.popUpParent.removeElement(popUp);
 		}
 	}
 }
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/Application.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/Application.as
index 59fe205..a1fae52 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/Application.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/Application.as
@@ -39,7 +39,6 @@ import mx.effects.EffectManager;
 import mx.events.FlexEvent;
 import mx.managers.IActiveWindowManager;
 import mx.managers.ILayoutManager;
-import mx.managers.ISystemManager;
 import mx.styles.CSSStyleDeclaration;
 import mx.styles.IStyleClient;
 import mx.utils.LoaderUtil;
@@ -61,6 +60,7 @@ import org.apache.royale.events.utils.MouseEventConverter;
 import mx.containers.beads.ApplicationLayout;
 import mx.containers.beads.BoxLayout;
 import mx.managers.FocusManager;
+import mx.managers.ISystemManager;
 
 import org.apache.royale.binding.ApplicationDataBinding;
 import org.apache.royale.binding.ContainerDataBinding;
@@ -72,6 +72,7 @@ import org.apache.royale.core.IInitialViewApplication;
 import org.apache.royale.core.ILayoutChild;
 import org.apache.royale.core.IParent;
 import org.apache.royale.core.IPopUpHost;
+import org.apache.royale.core.IPopUpHostParent;
 import org.apache.royale.core.IRenderedObject;
 import org.apache.royale.core.IStatesImpl;
 import org.apache.royale.core.IStrand;
@@ -231,7 +232,7 @@ import org.apache.royale.utils.loadBeadFromValuesManager;
  *  @playerversion AIR 1.1
  *  @productversion Flex 3
  */
-public class Application extends Container implements IStrand, IParent, IEventDispatcher,
IPopUpHost, IRenderedObject, IFlexInfo
+public class Application extends Container implements IStrand, IParent, IEventDispatcher,
IPopUpHost, IPopUpHostParent, IRenderedObject, IFlexInfo
 {
 
     //--------------------------------------------------------------------------
@@ -642,10 +643,30 @@ public class Application extends Container implements IStrand, IParent,
IEventDi
      *  @playerversion AIR 2.6
      *  @productversion Royale 0.0
      */
-    public function get popUpParent():IParent
+    public function get popUpParent():IPopUpHostParent
     {
-        return strandChildren;
+        COMPILE::JS
+        {
+            return systemManager as IPopUpHostParent;
+        }
+        COMPILE::SWF
+        {
+            return strandChildren as IPopUpHostParent;
+        }
     }
+    
+    override public function get systemManager():ISystemManager
+    {
+        return parent as ISystemManager;
+    }
+    
+    /**
+     */
+    public function get popUpHost():IPopUpHost
+    {
+        return this;
+    }
+
 }
 
 }
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/managers/SystemManager.as b/frameworks/projects/MXRoyale/src/main/royale/mx/managers/SystemManager.as
index c341008..7542e15 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/managers/SystemManager.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/managers/SystemManager.as
@@ -87,14 +87,16 @@ import mx.utils.LoaderUtil;
 use namespace mx_internal;
 */
 
-import org.apache.royale.geom.Rectangle;
-
 import mx.core.IChildList;
 import mx.core.IFlexDisplayObject;
 import mx.core.IUIComponent;
 
+import org.apache.royale.core.IChild;
+import org.apache.royale.core.IPopUpHost;
+import org.apache.royale.core.IPopUpHostParent;
 import org.apache.royale.core.IUIBase;
 import org.apache.royale.events.IEventDispatcher;
+import org.apache.royale.geom.Rectangle;
 
 //--------------------------------------
 //  Events
@@ -189,7 +191,7 @@ import org.apache.royale.events.IEventDispatcher;
  *  @playerversion AIR 1.1
  *  @productversion Royale 0.9.4
  */
-public class SystemManager extends SystemManagerBase implements ISystemManager, IEventDispatcher,
IChildList
+public class SystemManager extends SystemManagerBase implements ISystemManager, IEventDispatcher,
IPopUpHostParent, IChildList
 { //extends MovieClip implements IFlexDisplayObject,IFlexModuleFactory, ISystemManager
    // include "../core/Version.as";
 
@@ -1821,7 +1823,43 @@ public class SystemManager extends SystemManagerBase implements ISystemManager,
             return ret as IUIComponent;
         }
     }
-            
+    
+    COMPILE::SWF
+    public function addElement(c:IChild, dispatchEvent:Boolean = true):void
+    {
+        trace("SystemManager:addElement should not be called");   
+    }
+    COMPILE::SWF
+    public function addElementAt(c:IChild, index:int, dispatchEvent:Boolean = true):void
+    {
+        trace("SystemManager:addElementAt should not be called");   
+        
+    }
+    COMPILE::SWF
+    public function removeElement(c:IChild, dispatchEvent:Boolean = true):void
+    {
+        trace("SystemManager:removeElement should not be called");   
+        
+    }
+    COMPILE::SWF
+    public function getElementIndex(c:IChild):int
+    {
+        trace("SystemManager:getElementIndex should not be called");   
+        return 0;
+    }
+    COMPILE::SWF
+    public function get numElements():int
+    {
+        trace("SystemManager:numElements should not be called");   
+        return 0;    
+    }
+    COMPILE::SWF
+    public function getElementAt(index:int):IChild
+    {
+        trace("SystemManager:getElementAt should not be called");   
+        return null;            
+    }
+    
     //--------------------------------------------------------------------------
     //
     //  Methods: IFlexModuleFactory
@@ -3667,6 +3705,13 @@ public class SystemManager extends SystemManagerBase implements ISystemManager,
         return true;
     }
     
+    /**
+     * @royaleignorecoercion org.apache.royale.core.IPopUpHost; 
+     */
+    public function get popUpHost():IPopUpHost
+    {
+        return component as IPopUpHost;
+    }
 
 }
 


Mime
View raw message