flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [9/9] git commit: [flex-asjs] [refs/heads/develop] - replicate childrenAdded logic in JS
Date Thu, 27 Aug 2015 06:46:10 GMT
replicate childrenAdded logic in JS


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

Branch: refs/heads/develop
Commit: 94502fde91a06f878df8411993e3b6a88b5760b2
Parents: 97f6f66
Author: Alex Harui <aharui@apache.org>
Authored: Wed Aug 26 23:45:47 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Wed Aug 26 23:45:47 2015 -0700

----------------------------------------------------------------------
 .../src/org/apache/flex/core/ContainerBase.js   | 14 ++++++++++--
 .../Core/js/src/org/apache/flex/core/UIBase.js  | 10 ++++----
 .../apache/flex/utils/MXMLDataInterpreter.js    |  6 +++--
 .../org/apache/flex/html/beads/ContainerView.js | 24 ++++++++++----------
 4 files changed, 34 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94502fde/frameworks/projects/Core/js/src/org/apache/flex/core/ContainerBase.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/core/ContainerBase.js b/frameworks/projects/Core/js/src/org/apache/flex/core/ContainerBase.js
index 7bec248..450bce8 100644
--- a/frameworks/projects/Core/js/src/org/apache/flex/core/ContainerBase.js
+++ b/frameworks/projects/Core/js/src/org/apache/flex/core/ContainerBase.js
@@ -157,7 +157,10 @@ org.apache.flex.core.ContainerBase.prototype.setActualParent = function(parent)
 /**
  * @override
  */
-org.apache.flex.core.ContainerBase.prototype.addElement = function(c) {
+org.apache.flex.core.ContainerBase.prototype.addElement = function(c, opt_dispatchEvent)
{
+  if (opt_dispatchEvent === undefined)
+    opt_dispatchEvent = true;
+
   if (this.supportsChromeChildren && org.apache.flex.utils.Language.is(c, org.apache.flex.core.IChrome))
{
      //org.apache.flex.core.ContainerBase.base(this, 'addElement', c);
      this.element.appendChild(c.positioner);
@@ -168,13 +171,18 @@ org.apache.flex.core.ContainerBase.prototype.addElement = function(c)
{
      this.actualParent.element.appendChild(c.positioner);
      c.addedToParent();
   }
+  if (opt_dispatchEvent)
+    this.dispatchEvent('childrenAdded');
 };
 
 
 /**
  * @override
  */
-org.apache.flex.core.ContainerBase.prototype.addElementAt = function(c, index) {
+org.apache.flex.core.ContainerBase.prototype.addElementAt = function(c, index, opt_dispatchEvent)
{
+  if (opt_dispatchEvent === undefined)
+    opt_dispatchEvent = true;
+
   if (this.supportsChromeChildren && org.apache.flex.utils.Language.is(c, org.apache.flex.core.IChrome))
{
      //org.apache.flex.core.ContainerBase.base(this, 'addElementAt', c, index);
      var children1 = this.internalChildren();
@@ -197,6 +205,8 @@ org.apache.flex.core.ContainerBase.prototype.addElementAt = function(c,
index) {
        c.addedToParent();
      }
    }
+  if (opt_dispatchEvent)
+    this.dispatchEvent('childrenAdded');
 };
 
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94502fde/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js b/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js
index 3721dc0..602201e 100644
--- a/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js
+++ b/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js
@@ -163,8 +163,9 @@ org.apache.flex.core.UIBase.prototype.finalizeElement = null;
 
 /**
  * @param {Object} c The child element.
+ * @param {boolean=} opt_dispatchEvent Use 'false' to skip sending a childrenAdded event.
  */
-org.apache.flex.core.UIBase.prototype.addElement = function(c) {
+org.apache.flex.core.UIBase.prototype.addElement = function(c, opt_dispatchEvent) {
   this.element.appendChild(c.positioner);
   c.addedToParent();
 };
@@ -173,8 +174,9 @@ org.apache.flex.core.UIBase.prototype.addElement = function(c) {
 /**
  * @param {Object} c The child element.
  * @param {number} index The index.
+ * @param {boolean=} opt_dispatchEvent Use 'false' to skip sending a childrenAdded event.
  */
-org.apache.flex.core.UIBase.prototype.addElementAt = function(c, index) {
+org.apache.flex.core.UIBase.prototype.addElementAt = function(c, index, opt_dispatchEvent)
{
   var children = this.internalChildren();
   if (index >= children.length)
     this.addElement(c);
@@ -802,7 +804,7 @@ org.apache.flex.core.UIBase.prototype.isWidthSizedToContent = function()
 {
   if (!isNaN(this.explicitWidth_) || !isNaN(this.percentWidth_))
     return false;
-  var scv = window.getComputedStyle(this.element);
+  var scv = window.getComputedStyle(this.positioner);
   if (scv.left != 'auto' && scv.right != 'auto')
     return false;
   return true;
@@ -817,7 +819,7 @@ org.apache.flex.core.UIBase.prototype.isHeightSizedToContent = function()
 {
   if (!isNaN(this.explicitHeight_) || !isNaN(this.percentHeight_))
     return false;
-  var scv = window.getComputedStyle(this.element);
+  var scv = window.getComputedStyle(this.positioner);
   if (scv.top != 'auto' && scv.bottom != 'auto')
     return false;
   return true;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94502fde/frameworks/projects/Core/js/src/org/apache/flex/utils/MXMLDataInterpreter.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/utils/MXMLDataInterpreter.js
b/frameworks/projects/Core/js/src/org/apache/flex/utils/MXMLDataInterpreter.js
index 7faacb5..8af3fdb 100644
--- a/frameworks/projects/Core/js/src/org/apache/flex/utils/MXMLDataInterpreter.js
+++ b/frameworks/projects/Core/js/src/org/apache/flex/utils/MXMLDataInterpreter.js
@@ -250,13 +250,15 @@ org.apache.flex.utils.MXMLDataInterpreter.initializeStrandBasedObject
=
     comp.addEventListener(name, goog.bind(value, document));
   }
 
+  var isContainer = (typeof comp.childrenAdded === 'function');
+
   children = data[i++];
   if (children && comp['setMXMLDescriptor']) {
     comp['setMXMLDescriptor'](document, children);
   }
   if (parent && org.apache.flex.utils.Language.is(comp,
       org.apache.flex.core.IUIBase)) {
-    parent.addElement(comp);
+    parent.addElement(comp, !isContainer);
   }
 
   if (children) {
@@ -264,7 +266,7 @@ org.apache.flex.utils.MXMLDataInterpreter.initializeStrandBasedObject
=
       self = org.apache.flex.utils.MXMLDataInterpreter;
       self.generateMXMLInstances(
             document, comp, children);
-      if (typeof comp.childrenAdded === 'function')
+      if (isContainer)
         comp.childrenAdded();
     }
   }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94502fde/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
index 859a923..858da12 100644
--- a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
+++ b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
@@ -98,7 +98,7 @@ org.apache.flex.html.beads.ContainerView.
    }
    else {
      this._strand.addEventListener('sizeChanged',
-       org.apache.flex.utils.Language.closure(this.deferredSizeHandler, this, 'defer_sizeChanged'));
+       org.apache.flex.utils.Language.closure(this.deferredSizeHandler, this, 'deferredSizeHandler'));
    }
 };
 
@@ -109,7 +109,7 @@ org.apache.flex.html.beads.ContainerView.
 org.apache.flex.html.beads.ContainerView.
     prototype.deferredSizeHandler = function(event) {
     this._strand.removeEventListener('sizeChanged',
-      org.apache.flex.utils.Language.closure(this.deferredSizeHandler, this, 'defer_sizeChanged'));
+      org.apache.flex.utils.Language.closure(this.deferredSizeHandler, this, 'deferredSizeHandler'));
     this.completeSetup();
 
     var num = this.contentView.numElements;
@@ -137,9 +137,9 @@ org.apache.flex.html.beads.ContainerView.
     for (var i = 0; i < num; i++) {
       var child = this.contentView.getElementAt(i);
       child.addEventListener('widthChanged',
-          org.apache.flex.utils.Language.closure(this.childResizeHandler, this, 'child_widthChanged'));
+          org.apache.flex.utils.Language.closure(this.childResizeHandler, this, 'childResizeHandler'));
       child.addEventListener('heightChanged',
-          org.apache.flex.utils.Language.closure(this.childResizeHandler, this, 'child_heightChanged'));
+          org.apache.flex.utils.Language.closure(this.childResizeHandler, this, 'childResizeHandler'));
     }
 };
 
@@ -182,20 +182,20 @@ org.apache.flex.html.beads.ContainerView.
   this.createViewport();
 
   this._strand.addEventListener('childrenAdded',
-      org.apache.flex.utils.Language.closure(this.childrenChangedHandler, this, 'childrenAdded'));
+      org.apache.flex.utils.Language.closure(this.childrenChangedHandler, this, 'childrenChangedHandler'));
   this.childrenChangedHandler(null);
   this._strand.addEventListener('childrenAdded',
-      org.apache.flex.utils.Language.closure(this.changeHandler, this, 'childrenAdded'));
+      org.apache.flex.utils.Language.closure(this.changeHandler, this, 'changeHandler'));
   this._strand.addEventListener('childrenRemoved',
-      org.apache.flex.utils.Language.closure(this.changeHandler, this, 'childrenRemoved'));
+      org.apache.flex.utils.Language.closure(this.changeHandler, this, 'changeHandler'));
   this._strand.addEventListener('layoutNeeded',
-     org.apache.flex.utils.Language.closure(this.performLayout, this, 'layoutNeeded'));
+     org.apache.flex.utils.Language.closure(this.performLayout, this, 'performLayout'));
   this._strand.addEventListener('widthChanged',
-     org.apache.flex.utils.Language.closure(this.resizeHandler, this, 'widthChanged'));
+     org.apache.flex.utils.Language.closure(this.resizeHandler, this, 'resizeHandler'));
   this._strand.addEventListener('heightChanged',
-     org.apache.flex.utils.Language.closure(this.resizeHandler, this, 'heightChanged'));
+     org.apache.flex.utils.Language.closure(this.resizeHandler, this, 'resizeHandler'));
   this._strand.addEventListener('sizeChanged',
-     org.apache.flex.utils.Language.closure(this.resizeHandler, this, 'sizeChanged'));
+     org.apache.flex.utils.Language.closure(this.resizeHandler, this, 'resizeHandler'));
 };
 
 
@@ -368,7 +368,7 @@ Object.defineProperties(org.apache.flex.html.beads.ContainerView.prototype,
{
             this.host.addElement(this.contentView);
             this.host.setActualParent(this.contentView);
             this._strand.addEventListener('initComplete',
-                  org.apache.flex.utils.Language.closure(this.initCompleteHandler, this,
'initComplete'));
+                  org.apache.flex.utils.Language.closure(this.initCompleteHandler, this,
'initCompleteHandler'));
          }
     },
     /** @export */


Mime
View raw message