[Laszlo-checkins] r9515 - openlaszlo/trunk/WEB-INF/lps/lfc/data

bargull@openlaszlo.org bargull at openlaszlo.org
Sun Jun 8 23:13:21 PDT 2008


Author: bargull
Date: 2008-06-08 23:13:16 -0700 (Sun, 08 Jun 2008)
New Revision: 9515

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzResizeReplicationManager.lzs
Log:
Change 20080607-bargull-WtV by bargull at dell--p4--2-53 on 2008-06-07 15:37:39
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: replication-manager pooling

New Features:

Bugs Fixed: LPP-5997, LPP-5455

Technical Reviewer: hminsky
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
- set pooling in constructor instead of "construct"-method to resolve LPP-5997 
- fixed a braino in "LzLazyReplicationManager#__LZsetCloneAttrs()" 
- added slots for constraint-/dependency-method in LzReplicationManager, so we don't need to declare the class as dynamic
- updated "LzReplicationManager#construct()" to remove constraints properly instead of using the "LzReplicationManager.__LZemptyFuntion" workaround
- added even more typing
    

Tests:
alldata passes, testcase from bugreport



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs	2008-06-08 19:52:35 UTC (rev 9514)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs	2008-06-09 06:13:16 UTC (rev 9515)
@@ -53,15 +53,15 @@
  * @lzxdefault 'y'
  * @keywords final
  */
-var axis = "y"
+var axis :String = "y"
 /** @access private */
-var sizeAxis;
+var sizeAxis :String;
 /** @access private */
-var cloneimmediateparent;
+var cloneimmediateparent :LzView;
 /** @access private */
-var updateDel;
+var updateDel :LzDelegate;
 /** @access private */
-var __LZoldnodelen;
+var __LZoldnodelen :int;
 
 /**
  * The spacing (in pixels) between replicated views.
@@ -71,22 +71,25 @@
  * @lzxdefault 0
  * @keywords final
  */
-var spacing = 0;
+var spacing :Number = 0;
 /** @access private */
-var mask = null;
+var viewsize :Number = 0;
+/** @access private */
+var totalsize :Number = 0;
+/** @access private */
+var mask :LzView = null;
 
 /**
   * @access private
   */
 function LzLazyReplicationManager ( odp , args, children:* = null, instcall:* = null ){
     super(odp, args, children, instcall);
+    //replication argument needs to control pooling
+    this.pooling = true; // Defined in LzDatapath
 }
 
 /** @access private */
 override function construct ( odp , args ){
-    //replication argument needs to control pooling
-    this.pooling = true; // Defined in LzReplicationManager
-
     if ( args.pooling != null ){
         args.pooling = true;
         if ( $debug ){
@@ -106,18 +109,23 @@
 
     this.mask = odp.immediateparent.immediateparent.mask;
 
-
-    var cloneopt = { ignorelayout : true };
+    /* TODO [20080605 anba]: why do we need this copy?
+     * isn't this done by __LZsetCloneAttrs() in LzReplicationManager#construct(..)!?
+     */
+    var cloneopt:Object;
     if ( this.cloneAttrs.options != null ){
         cloneopt = new LzInheritedHash(this.cloneAttrs.options);
+        cloneopt['ignorelayout'] = true;
+    } else {
+        cloneopt = { ignorelayout : true };
     }
 
-    var firstcl = this.clones[ 0 ];
+    var firstcl:LzView = this.clones[ 0 ];
     if (firstcl) {
         firstcl.setOption( 'ignorelayout', true );
-        var layo = firstcl.immediateparent.layouts;
+        var layo:Array = firstcl.immediateparent.layouts;
         if (layo != null) {
-            for ( var i = 0; i < layo.length; i++ ){
+            for ( var i:int = 0; i < layo.length; i++ ){
                 layo[ i ].removeSubview( firstcl );
             }
         }
@@ -125,7 +133,7 @@
 
     this.cloneAttrs.options = cloneopt;
 
-    var v = this.getNewClone( true );
+    var v:LzView = this.getNewClone( true );
     //datamap the new view, to make sure that any members which are datamapped
     //are shown
     this.cloneimmediateparent = v.immediateparent;
@@ -162,18 +170,16 @@
   this.__LZadjustVisibleClones(null, null);
 }
 
-/** @access private */
-var viewsize = 0;
-/** @access private */
-var totalsize = 0;
-
 /**
   * @access private
   */
 override function __LZsetCloneAttrs () :void {
-    var cloneopt = { ignorelayout : true };
+    var cloneopt:Object;
     if ( this.cloneAttrs.options != null ){
         cloneopt = new LzInheritedHash(this.cloneAttrs.options);
+        cloneopt['ignorelayout'] = true;
+    } else {
+        cloneopt = { ignorelayout : true };
     }
     this.cloneAttrs.options = cloneopt;
 }
@@ -209,51 +215,49 @@
   *
   * @access private
   */
-override function __LZadjustVisibleClones (ln:Array, nn:Boolean) :void {
-    var nodelen = null;
-    if (this.nodes) {
-        nodelen = this.nodes.length;
-    }
-
-    if (nodelen != null) {
-        if ( this.__LZoldnodelen != this.nodes.length ){
-            this.cloneimmediateparent.setAttribute( this.sizeAxis , this.nodes.length*
-                                               this.totalsize -
-                                               this.spacing );
-            this.__LZoldnodelen = this.nodes.length;
+override function __LZadjustVisibleClones (lastnodes:Array, newnodes:Boolean) :void {
+    var cloneip:LzView = this.cloneimmediateparent;
+    
+    var _nodes:Array = this.nodes;
+    var _axis:String = this.axis;
+    var _sizeAxis:String = this.sizeAxis;
+    var _totalsize:Number = this.totalsize;
+    
+    if (_nodes) {
+        var nodelen:int = _nodes.length;
+        if ( this.__LZoldnodelen != nodelen ){
+            cloneip.setAttribute( _sizeAxis, nodelen * _totalsize - this.spacing );
+            this.__LZoldnodelen = nodelen;
         }
     }
 
 
-    if (! (this.mask && this.mask[ "hasset" + this.sizeAxis ]) ) return;
+    if (! (this.mask && this.mask[ "hasset" + _sizeAxis ]) ) return;
 
-    var newstart = 0;
+    var newstart:int = 0;
 
-    if (this.totalsize != 0) {
-        newstart = Math.floor( - this.cloneimmediateparent[ this.axis ]
-                               / this.totalsize );
+    if (_totalsize != 0) {
+        newstart = Math.floor( - cloneip[ _axis ] / _totalsize );
+        if ( 0 > newstart  ) newstart = 0;
     }
 
-    if ( 0 > newstart  ) newstart = 0;
+    var oldstart:int = 0;
+    var oldlength:int = this.clones.length;
+    var offset:int = newstart - this.__LZdataoffset;
 
-    var oldstart = 0;
-    var oldlength = this.clones.length;
-    var offset = newstart - this.__LZdataoffset;
+    var remainder:* = ( newstart * _totalsize ) + cloneip[_axis];
+    var newlength:int = 0;
 
-    var remainder = ( newstart * this.totalsize ) +
-                    this.cloneimmediateparent[this.axis];
-    var newlength = 0;
-
     if (typeof(remainder) == 'number') {
-        newlength= 1 + Math.floor( ( this.mask[ this.sizeAxis ] - remainder ) /
-                                     this.totalsize );
+        newlength = 1 + Math.floor( ( this.mask[ _sizeAxis ] - remainder ) / _totalsize );
     }
 
     //newstart is the new absolute lowerbound of the data winodw
     //newlength is the new length of the data window
-    if (this.nodes != null) {
-        if ( newlength + newstart >  this.nodes.length ) {
-            newlength = this.nodes.length - newstart;
+    if (_nodes != null) {
+        var nodelen:int = _nodes.length;
+        if ( newlength + newstart > nodelen ) {
+            newlength = nodelen - newstart;
         }
     }
 
@@ -261,12 +265,12 @@
     if ( offset == 0 && newlength == oldlength ) return;
 
     LzInstantiator.enableDataReplicationQueuing( );
-    var oldclones = this.clones;
-    this.clones = [];
+    var oldclones:Array = this.clones;
+    this.clones = new Array(newlength);
 
-    for ( var i = 0 ; i < newlength; i++ ){
+    for ( var i:int = 0; i < newlength; i++ ){
         //before the new beginning
-        var cl = false;
+        var cl:LzView = null;
         if ( i + offset < 0 ){
             //this comes before the old data window
             if ( newlength + offset < oldlength  && oldlength > 0){
@@ -287,10 +291,10 @@
 
         if ( cl ){
             this.clones[ i ] = cl;
-            cl.setAttribute( this.axis , ( i + newstart ) * this.totalsize );
+            cl.setAttribute( _axis, ( i + newstart ) * _totalsize );
             cl.clonenumber = newstart + i ;
-            if (this.nodes) {
-                cl.datapath.setClonePointer( this.nodes[ newstart + i ]);
+            if (_nodes) {
+                cl.datapath.setClonePointer( _nodes[ newstart + i ]);
             }
             if (cl.onclonenumber.ready) cl.onclonenumber.sendEvent( i );
         } else {
@@ -299,16 +303,17 @@
         }
     }
 
+    var cpool:Array = this.clonePool;
     while ( oldstart < offset  && oldstart < oldlength ){
-        var v = oldclones[ oldstart++ ];
+        var v:LzView = oldclones[ oldstart++ ];
         this.detachClone( v );
-        this.clonePool.push ( v );
+        cpool.push ( v );
     }
 
     while ( oldlength > newlength + offset && oldlength > 0 ){
-        var v = oldclones[ --oldlength ];
+        var v:LzView = oldclones[ --oldlength ];
         this.detachClone( v );
-        this.clonePool.push ( v );
+        cpool.push ( v );
     }
 
     this.__LZdataoffset = newstart;
@@ -326,8 +331,7 @@
  * @access private
  */
 override function getCloneForNode ( p , dontmake:Boolean = false ) :LzNode {
-    var cl:LzNode = super.getCloneForNode( p ) ||
-             null;
+    var cl:LzView = (super.getCloneForNode( p ) cast LzView) || null;
     if ( !cl && !dontmake ){
         //even though we're going to return this to the pool immediately,
         //use the class API to get a clone
@@ -338,7 +342,6 @@
     }
 
     return cl;
-
 }
 
 

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs	2008-06-08 19:52:35 UTC (rev 9514)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs	2008-06-09 06:13:16 UTC (rev 9515)
@@ -77,12 +77,10 @@
   * name, so that it can be referred to the same way the non-replicated view
   * would have been. 
   */
-dynamic class LzReplicationManager extends LzDatapath {
+class LzReplicationManager extends LzDatapath {
+  #pragma "warnUndefinedReferences=true"
 
 /** @access private */
-override function $lzc$set_datapath(v) { this.setXPath(v); }
-
-/** @access private */
 var asyncnew :Boolean = true;
 /** @access private */
 var initialnodes :Array;
@@ -99,13 +97,22 @@
 /** @access private */
 var hasdata :Boolean;
 /** @access private */
-var orderpath :*;
+var orderpath :String;
 
 /** @access private */
-var comp_orderf;  // Was this.orderf.comp
+var comp_orderf :Function;  // Was this.orderf.comp
 /** @access private */
-var op_orderf;    // Was this.orderf.op
+var op_orderf :String;    // Was this.orderf.op
 
+/** Slot for constraint-method, see LzReplicationManager#construct(..)
+  * @access private 
+  */
+var __LZxpathconstr: Function = null;
+/** Slot for dependency-method, see LzReplicationManager#construct(..)
+  * @access private 
+  */
+var __LZxpathdepend: Function = null;
+
 // var datacontrolsvisibility = false; // Defined in LzDatapath
 /** 
   * @modifiers override
@@ -162,16 +169,13 @@
 function LzReplicationManager ( odp , args, children:* = null, instcall:* = null ){
     //the real parent for this is datapaths view's (immediateparent) parent
     super(odp, args, children, instcall);
+    this.pooling = false; // Defined in LzDatapath
+    this.__LZtakeDPSlot = false; // Defined in LzDatapath
+    this.datacontrolsvisibility = false; // Defined in LzDatapath
 }
 
 /** @access private */
 override function construct ( odp , args ){
-    this.__LZtakeDPSlot = false; // Defined in LzDatapath
-    this.datacontrolsvisibility = false; // Defined in LzDatapath
-
-    if (this.pooling == null)
-        this.pooling = false; // Defined in LzDatapath
-
     //odp: original datapath
     var view:LzNode = odp.immediateparent;
     if (view === canvas) {
@@ -235,7 +239,7 @@
         if ( odp.__LZdotdotCheckDel ){
             odp.__LZdotdotCheckDel.unregisterAll();
         }
-        odp.__LZspecialDotDot = null;
+        odp.__LZspecialDotDot = false;
     }
         
 
@@ -272,68 +276,81 @@
       }
     }
 
-    var hadxpathconstraint:Boolean = false;
+    //set visible-property
+    if (odp.datacontrolsvisibility) {
+        this.visible = true;
+    } else {
+        if (!view.isinited) {
+            var via:Object = view._instanceAttrs;
+            if (via != null && 'visible' in via && !(via.visible is LzInitExpr)) {
+                this.visible = via.visible;
+            } else {
+                this.visible = view.visible;
+            }
+        } else {
+            this.visible = view.visible;
+        }
+    }
+
+    if ( args.pooling != null ){
+        this.pooling = args.pooling;
+    }
+
     var ia:Object = view._instanceAttrs;
     var oa:Object = odp._instanceAttrs;
-    if (ia && 'datapath' in ia && ia.datapath is LzConstraintExpr) {
+    if (ia && 'datapath' in ia && ia.datapath is LzAlwaysExpr) {
         // <view datapath="${ ... }"/>
-        hadxpathconstraint = true;
         // we need to mask this constraint
+        
         // NOTE: [2008-02-07 ptw] Why?  Why can't this just execute as
         // a constraint on the clone via the normal mechanism?
         // but, we want the constraint to apply to this object instead
-        this.__LZpreventXPathUpdate = true;
-        var methodName:String = ia.datapath.methodName;
         if ($swf9) {
             //FIXME: cannot copy a method in swf9, because 'this' is bound!
-            this[methodName] = function (ignore) {};
+            this.__LZxpathconstr = function (ignore) {};
+            this.__LZxpathdepend = function () {return [];};
         } else {
-            this[methodName] = view[methodName];
+            this.__LZxpathconstr = view[ia.datapath.methodName];
+            this.__LZxpathdepend = view[ia.datapath.dependenciesName];
         }
-        if (ia.datapath is LzAlwaysExpr) {
-            var dependencyName:String = ia.datapath.dependenciesName;
-            if ($swf9) {
-                //FIXME: cannot copy a method in swf9, because 'this' is bound!
-                this[dependencyName] = function () {return [];};
-            } else {
-                this[dependencyName] = view[dependencyName];
-            }
-        }
         // NOTE: [2008-02-07 ptw] The method had better be available
         // on the clone (which means we really want a clone class here
         // to instantiate, rather than an instance to clone).
-        this.applyConstraintExpr(ia.datapath);
+        this.__LZpreventXPathUpdate = true;
+        this.applyConstraintExpr(new LzAlwaysExpr("__LZxpathconstr", "__LZxpathdepend"));
         this.__LZpreventXPathUpdate = false;
-    } else if (oa && 'xpath' in oa && oa.xpath is LzConstraintExpr){
+        
+        if (this.pooling) {
+            //if we're pooling, release constraint from view so it won't run again
+            view.releaseConstraint("datapath");
+        }
+    } else if (oa && 'xpath' in oa && oa.xpath is LzAlwaysExpr){
         //<view><datapath xpath="${ ... }"/>
-        hadxpathconstraint = true;
         //we want the constraint to apply to this object instead
-        this.__LZpreventXPathUpdate = true;
+        
         // we need to have an intermediate node, so relative constraints 
         // like "xpath='${this.immediateparent.parent.anyproperty}'" 
         // work for a replication-manager 
         var refObj:LzRefNode = new LzRefNode(this);
-        var methodName:String = oa.xpath.methodName;
         if ($swf9) {
             //FIXME: cannot copy a method in swf9, because 'this' is bound!
-            refObj[methodName] = function (ignore) {};
+            refObj.__LZxpathconstr = function (ignore) {};
+            refObj.__LZxpathdepend = function () {return [];};
         } else {
-            refObj[methodName] = odp[methodName];
+            refObj.__LZxpathconstr = odp[oa.xpath.methodName];
+            refObj.__LZxpathdepend = odp[oa.xpath.dependenciesName];
         }
-        if (oa.xpath is LzAlwaysExpr) {
-            var dependencyName:String = oa.xpath.dependenciesName;
-            if ($swf9) {
-                //FIXME: cannot copy a method in swf9, because 'this' is bound!
-                refObj[dependencyName] = function () {return [];};
-            } else {
-                refObj[dependencyName] = odp[dependencyName];
-            }
-        }
         // NOTE: [2008-02-07 ptw] The method had better be available
         // on the clone (which means the compiler really has to move
         // it from the datapath subnode to the clone class).
-        refObj.applyConstraintExpr(oa.xpath);
+        this.__LZpreventXPathUpdate = true;
+        refObj.applyConstraintExpr(new LzAlwaysExpr("__LZxpathconstr", "__LZxpathdepend"));
         this.__LZpreventXPathUpdate = false;
+        
+        if (this.pooling) {
+            //if we're pooling, release constraint from datapath so it won't run again
+            odp.releaseConstraint("xpath");
+        }
     }
 
     this.__LZsetCloneAttrs();
@@ -344,14 +361,6 @@
     } else {
         this.cloneChildren = [];
     }
-
-    this.visible = odp.datacontrolsvisibility ||
-        (!view.isinited &&
-            (view._instanceAttrs != null && 'visible' in view._instanceAttrs) ? view._instanceAttrs.visible : view.visible);
-
-    if ( args.pooling != null ){
-        this.pooling = args.pooling;
-    }
     
     var mycontext:* = odp.context;
 
@@ -361,12 +370,6 @@
 
     if ( this.pooling ){
         odp.$lzc$set___LZmanager( this );
-        //make sure that the original view and datapath don't get their xpath 
-        //set by a constraint..
-        if ( hadxpathconstraint ){
-            //FIXME: breaks in swf9!
-            odp.setXPath =  LzReplicationManager.__LZemptyFuntion;
-        }
         this.clones.push ( view );
         // Because we're about to start making siblings to this view, (i.e. out
         // of lexical order) make sure that the replicated view has been added
@@ -389,13 +392,6 @@
 /**
   * @access private
   */
-static function __LZemptyFuntion ( ){
-    return;
-}
-
-/**
-  * @access private
-  */
 override function constructWithArgs ( args ){
     this.__LZHandleMultiNodes( this.initialnodes );
     this.initialnodes = null;
@@ -575,16 +571,14 @@
   * @access private
   */
 //PBR TODO
-function orderf ( a , b ){
+function orderf ( a , b ) :int {
     //a and b are dataset nodes
+    var op:String = this.op_orderf;
 
-
-    var op = this.op_orderf;
-
     this.p = a;
-    var aa = this.xpathQuery( op );
+    var aa:* = this.xpathQuery( op );
     this.p = b;
-    var bb = this.xpathQuery( op );
+    var bb:* = this.xpathQuery( op );
     this.p = null;
 
     //this is lame, but comparison with null and "" doens't work right
@@ -603,6 +597,7 @@
     if (a.toLowerCase() < b.toLowerCase()) {
         return 1;
     } else {
+        //could also be -1, but we don't care..
         return 0;
     }
 }
@@ -614,6 +609,7 @@
     if (a.toLowerCase() > b.toLowerCase()) {
         return 1;
     } else {
+        //could also be -1, but we don't care..
         return 0;
     }
 }
@@ -694,7 +690,7 @@
   * @access private
   */
 function poolClone ( ) :void {
-    var v:LzNode = this.clones.pop();
+    var v:LzView = this.clones.pop();
     this.detachClone( v );
     this.clonePool.push ( v );
 }
@@ -720,6 +716,11 @@
     this.setXPath( xp );
 }
 
+/** @access private */
+override function $lzc$set_datapath(v) :void {
+    this.setXPath(v);
+}
+
 /**
   * @access private
   */
@@ -734,7 +735,7 @@
   * @access private
   */
 function handleDeletedNode ( c:int ) :void {
-    var tclone:LzNode = this.clones[ c ];
+    var tclone:LzView = this.clones[ c ];
     if ( this.pooling ){
         this.detachClone( tclone );
         this.clonePool.push ( tclone );
@@ -750,7 +751,7 @@
   * @param LzDataElement p: The data node for which to return the clone.
   * @return LzView: A clone mapped to the given data.
   */
-function getCloneForNode ( p, dontmake:Boolean = false ){
+function getCloneForNode ( p, dontmake:Boolean = false ) :LzNode {
     var cls:Array = this.clones;
     var len:int = cls.length; 
     for ( var i:int = 0; i < len; i++ ){
@@ -791,11 +792,11 @@
   */
 override function __LZcheckChange (chgpkg:Object) :Boolean {
     this.p = this.nodes[ 0 ];
-    var didrun:Boolean = super.__LZcheckChange.apply(this, arguments);
+    var didrun:Boolean = super.__LZcheckChange(chgpkg);
     this.p = null;
 
     if ( !didrun ){
-        var who = chgpkg.who;
+        var who /*:LzDataNodeMixin*/ = chgpkg.who;
         var cls:Array = this.clones;
         var len:int = cls.length; 
         for ( var i:int = 0; i < len; i++ ){
@@ -829,8 +830,7 @@
 /**
   * @access private
   */
-function detachClone ( cl:LzNode ){
-    //cl is instance of LzView
+function detachClone ( cl:LzView ) :void {
     if ( cl.isdetatchedclone ) return;
 
     cl.$lzc$set_visible(false);
@@ -845,7 +845,8 @@
     }
 
     cl.datapath.__LZtrackDel.unregisterAll();
-    if (cl.immediateparent.onremovesubview.ready) cl.immediateparent.onremovesubview.sendEvent( cl );
+    var onremsub:LzDeclaredEventClass = cl.immediateparent.onremovesubview;
+    if (onremsub.ready) onremsub.sendEvent( cl );
     cl.isdetatchedclone = true;
     cl.p = null;
 }
@@ -904,7 +905,16 @@
 } // End of LzReplicationManager
 
 /** @access private */
-dynamic class LzRefNode extends LzNode {
+class LzRefNode extends LzNode {
+    /** Slot for constraint-method, see LzReplicationManager#construct(..)
+      * @access private 
+      */
+    var __LZxpathconstr: Function = null;
+    /** Slot for dependency-method, see LzReplicationManager#construct(..)
+      * @access private 
+      */
+    var __LZxpathdepend: Function = null;
+    
     /**
       * @access private
       */

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzResizeReplicationManager.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzResizeReplicationManager.lzs	2008-06-08 19:52:35 UTC (rev 9514)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzResizeReplicationManager.lzs	2008-06-09 06:13:16 UTC (rev 9515)
@@ -82,30 +82,27 @@
   */
 class LzResizeReplicationManager extends LzLazyReplicationManager {
   #pragma "warnUndefinedReferences=true"
-//need to destroy the original clone for resize in order to insert the
-//appropriate setHeight call
 
 /** @access private */
-var datasizevar;
+var datasizevar :String;
 /** @access private */
-var __LZresizeupdating;
+var __LZresizeupdating :Boolean;
 
 /**
   * @access private
   */
 function LzResizeReplicationManager ( odp , args, children:* = null, instcall:* = null ){
     super(odp, args, children, instcall);
+    //need to destroy the original clone for resize in order to insert the
+    //appropriate onwidth-/onheight-delegate
+    this.pooling = false; // Defined in LzDatapath
 }
 
 /** @access private */
 override function construct ( odp , args ){
-    this.pooling = false; // Defined in LzReplicationManager
-    //Debug.write( 'making resize repl' );
-
     super.construct.apply(this, arguments);
 
     this.datasizevar = '$' + this.getUID() + 'track';
-
 }
 
 /**
@@ -118,11 +115,11 @@
   * @devnote:  This could be a closure over the cloneManager, but we
   * believe this is a more efficient implementation
   */
-var __LZHandleCloneResize = function ( s) {
+var __LZHandleCloneResize = function ( s:Number ) {
     if (! this.datapath.p) return;
-    var cloneManager = this.cloneManager;
-    var datasizevar = cloneManager.datasizevar;
-    var osize = this.datapath.p[ datasizevar ] || cloneManager.viewsize;
+    var cloneManager:LzResizeReplicationManager = this.cloneManager cast LzResizeReplicationManager;
+    var datasizevar:String = cloneManager.datasizevar;
+    var osize:Number = this.datapath.p[ datasizevar ] || cloneManager.viewsize;
     if ( s != osize ){
         this.datapath.p[ datasizevar ] = s;
         cloneManager.__LZadjustVisibleClones(null, false);
@@ -132,33 +129,34 @@
 /**
   * @access private
   */
-override function __LZsetCloneAttrs (){
-  super.__LZsetCloneAttrs.apply(this, arguments);
+override function __LZsetCloneAttrs () :void {
+  super.__LZsetCloneAttrs();
 
-  this.cloneAttrs.__LZHandleCloneResize = this.__LZHandleCloneResize;
-  if (! this.cloneAttrs['$delegates']) {
-    this.cloneAttrs.$delegates = [];
+  var cattrs:Object = this.cloneAttrs;
+  cattrs.__LZHandleCloneResize = this.__LZHandleCloneResize;
+  if (! cattrs['$delegates']) {
+    cattrs.$delegates = [];
   }
-  this.cloneAttrs.$delegates.push('on' + (this.axis == 'y' ? 'height' : 'width'),
+  cattrs.$delegates.push('on' + (this.axis == 'y' ? 'height' : 'width'),
                                  '__LZHandleCloneResize',
                                  null);
 }
 
 /**
+  * TODO: [20080605 anba] no reference to this function in the LFC, remove it?
   * @access private
   */
-function getPositionByNode ( n ){
-    var pos = -this.spacing;
-    var cnode;
+function getPositionByNode ( n ) :Number? {
+    var pos:Number = -this.spacing;
+    var cnode /*:LzDataNodeMixin*/;
     if (this.nodes != null) {
-        for ( var i = 0; i < this.nodes.length; i++ ){
+        for ( var i:int = 0; i < this.nodes.length; i++ ){
             cnode = this.nodes[ i ];
             if ( n == this.nodes[ i ] ){
                 return pos + this.spacing;
             }
 
             pos += this.spacing + ( cnode[this.datasizevar] || this.viewsize );
-
         }
     }
 }
@@ -167,67 +165,65 @@
 /**
   * @access private
   */
-function __LZreleaseClone ( v ){
+function __LZreleaseClone ( v:LzView ) :void {
     this.detachClone( v );
     this.clonePool.push ( v );
 }
 
 /**
   * @access private
-  * ln: lastnodes, old list of nodes
-  * nn: newnodes, boolean flag, true when __LZadjustVisibleClones is called
+  * lastnodes: old list of nodes
+  * newnodes: boolean flag, true when __LZadjustVisibleClones is called
   * because of a change in the node list (e.g. setdatapointer, sort, etc)
   * (as opposed to, for example, when
   * the mask changes its height or item changes size
   */
-override function __LZadjustVisibleClones(ln:Array, nn:Boolean) :void {
-    //if the mask doesn't have a set size in the replication axis, don't affect
-    //it
+override function __LZadjustVisibleClones(lastnodes:Array, newnodes:Boolean) :void {
+    //if the mask doesn't have a set size in the replication axis, don't affect it
 
     if (! this.mask[ "hasset" + this.sizeAxis ] ) return;
     if ( this.__LZresizeupdating ) return;
     this.__LZresizeupdating = true;
-    //Debug.write( 'adj viz' , this.clones.length, this.nodes.length );
 
-    var nl = (this.nodes != null) ? this.nodes.length : 0;
-    var newstart =  - this.cloneimmediateparent[ this.axis ];
-    var newstart =  0 > newstart ? 0 : Math.floor( newstart );
-    var masksize = this.mask[ this.sizeAxis ];
+    var nodelen:int = (this.nodes != null) ? this.nodes.length : 0;
+    var newstart:int = Math.floor( - this.cloneimmediateparent[ this.axis ] );
+    if (0 > newstart) newstart = 0;
+    var masksize:Number = this.mask[ this.sizeAxis ];
 
-    var newoffset = -1;
-    var oldoffset = this.__LZdataoffset;
-    if ( nn ){
+    var newoffset:int = -1;
+    var oldoffset:int = this.__LZdataoffset;
+    if ( newnodes ){
         while( this.clones.length ) this.poolClone();
-        var oldclones = null;
-        var ocl = 0;
+        var oldclones:Array = null;
+        var ocl:int = 0;
     } else {
-        var oldclones = this.clones;
-        var ocl = oldclones.length;
+        var oldclones:Array = this.clones;
+        var ocl:int = oldclones.length;
     }
 
     this.clones = [];
 
-
     //cpos is used at the end of this method to size the immediateparent
     //of the replication manager
-    var cpos = -this.spacing;
-    var inwindow = false;
-    var newend = -1;
+    var cpos:Number = -this.spacing;
+    var inwindow:Boolean = false;
+    var newend:int = -1;
+    var newstartpos:Number;
 
     //Debug.write( 'oldclones', oldclones );
-    var notfirst = true;
-    for ( var i = 0; i < nl; i++ ){
-        var cnode = this.nodes[ i ];
-        var ds = cnode[ this.datasizevar ];
-        var csiz = ( ds == null ) ? this.viewsize : ds;
+    var notfirst:Boolean = true;
+    for ( var i:int = 0; i < nodelen; i++ ){
+        var cnode /*:LzDataNodeMixin*/ = this.nodes[ i ];
+        var ds:* = cnode[ this.datasizevar ];
+        var csiz:Number = ( ds == null ) ? this.viewsize : ds;
 
         cpos += this.spacing;
 
         if ( !inwindow && newoffset == -1  && cpos - newstart +csiz >= 0 ) {
             //Debug.write( 'inwindow at ' + i );
-            var notfirst = i != 0;
+            notfirst = i != 0;
             inwindow = true;
-            var newstartpos = cpos;
+            newstartpos = cpos;
             newoffset = i;
             //we can keep what we had
             var firstkept = i - oldoffset;
@@ -236,9 +232,8 @@
             //Debug.write( 'firstkept' , firstkept );
             //don't setup loop unless we have to
             if ( firstkept > 0 ) {
-                for ( var j =0; j < firstkept; j++ ){
-
-                    var v = oldclones[ j ];
+                for ( var j:int = 0; j < firstkept; j++ ){
+                    var v:LzView = oldclones[ j ];
                     //can't call poolClone here...
                     this.__LZreleaseClone( v );
                 }
@@ -247,14 +242,13 @@
             inwindow = false;
             //pool any left over clones here
             newend = i - newoffset;
-            var lastkept = i - oldoffset;
+            var lastkept:int = i - oldoffset;
             lastkept = lastkept < 0 ? 0 : lastkept;
             //Debug.write( 'lk' , lastkept , ocl );
             //don't setup loop unless we have to
             if ( lastkept < ocl ) {
-                for ( var j =lastkept; j < ocl; j++ ){
-
-                    var v = oldclones[ j ];
+                for ( var j:int = lastkept; j < ocl; j++ ){
+                    var v:LzView = oldclones[ j ];
                     //if ( v == null ) Debug.write( 'bad pool', j , lastkept );
                     //can't call poolClone here...
                     this.__LZreleaseClone( v );
@@ -265,28 +259,26 @@
         if ( inwindow ){
             if ( i >= oldoffset && i < oldoffset + ocl ){
                 //we can keep what we had
-                var cl = oldclones[ i - oldoffset ];
+                var cl:LzView = oldclones[ i - oldoffset ];
                 //if ( cl == null ) Debug.write( 'bad keep' , i );
             } else {
-                var cl = null;
+                var cl:LzView = null;
                 //if ( cl == null ) Debug.write( 'bad get' , i );
             }
 
             //Debug.write( i, newoffset );
             this.clones[ i - newoffset ] = cl;
-
         }
 
         cpos += csiz;
-
     }
 
-    var clpos = newstartpos;
+    var clpos:Number = newstartpos;
     if ( notfirst ) clpos += this.spacing;
-    for( var i = 0; i < this.clones.length; i++ ){
-        var cnode = this.nodes[ i + newoffset ];
+    for( var i:int = 0; i < this.clones.length; i++ ){
+        var cnode /*:LzDataNodeMixin*/ = this.nodes[ i + newoffset ];
 
-        var cl = this.clones[ i ];
+        var cl:LzView = this.clones[ i ];
         if ( !cl ){
             cl = this.getNewClone( );
             cl.clonenumber = i + newoffset;
@@ -298,13 +290,12 @@
 
         this.clones[ i ] = cl;
         cl.setAttribute( this.axis , clpos );
-        var ds = cnode[ this.datasizevar ];
-        var csiz = ( ds == null ) ? this.viewsize : ds;
+        var ds:* = cnode[ this.datasizevar ];
+        var csiz:Number = ( ds == null ) ? this.viewsize : ds;
         if ( cl[ this.sizeAxis ] != csiz ){
             cl.setAttribute( this.sizeAxis, csiz, true );
         }
         clpos += csiz + this.spacing;
-
     }
 
     //Debug.write( 'newoffset' , newoffset );
@@ -312,7 +303,6 @@
     this.__LZdataoffset = newoffset;
     //Debug.write( 'clones' , this.clones.length, 'pool', this.clonePool.length);
     //Debug.write( 'oldclones' , oldclones );
-    //clo = this.clones;
     this.cloneimmediateparent.setAttribute( this.sizeAxis , cpos );
     this.__LZresizeupdating = false;
 }



More information about the Laszlo-checkins mailing list