[Laszlo-checkins] r13235 - openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf

bargull@openlaszlo.org bargull at openlaszlo.org
Mon Mar 9 17:07:41 PDT 2009


Author: bargull
Date: 2009-03-09 17:07:38 -0700 (Mon, 09 Mar 2009)
New Revision: 13235

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzHTTPLoader.as
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzXMLLoader.lzs
Log:
Change 20090309-bargull-AKA by bargull at dell--p4--2-53 on 2009-03-09 23:32:56
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: another round of clean-up for swf8-data

New Features:

Bugs Fixed: LPP-7881 (SWF8: rawtext stored in data-node)

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

Documentation:

Release Notes:

Details:
LzLoader:
- don't save rawtext in data-node, this is not needed anymore

LzXMLLoader:
- fix method comments
- add declarations for copyTaskDel, lfcrootnode, trimwhitespace, nsprefix
- call removeCopyTask() in destroy() to be sure to stop copy-task and clear delegate
- clear lfcrootnode in removeCopyTask()
- use "rawtext" directly in translateXML() and don't pass it back and forth
- use "localName" instead of manually splitting localName from "nodeName"

LzHTTPLoader:
- update call to translateXML()
    

Tests:
alldata passes



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzHTTPLoader.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzHTTPLoader.as	2009-03-09 23:12:23 UTC (rev 13234)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzHTTPLoader.as	2009-03-10 00:07:38 UTC (rev 13235)
@@ -1,7 +1,7 @@
 /**
   * LzHTTPLoader.as
   *
-  * @copyright Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.
+  * @copyright Copyright 2001-2009 Laszlo Systems, Inc.  All Rights Reserved.
   *            Use is subject to license terms.
   *
   * @topic Kernel
@@ -57,7 +57,8 @@
 LzHTTPLoader.prototype.loadContent = function (content) {
     if (this.options.parsexml) {
         // Parse and translate XML to LZX format
-        this.lzloader.translateXML(content);
+        // lzloader dispatches "ondata"-event when finished translation
+        this.lzloader.translateXML();
     } else {
         // Otherwise, return the raw content string
         this._loadSuccessHandler(content);

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs	2009-03-09 23:12:23 UTC (rev 13234)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs	2009-03-10 00:07:38 UTC (rev 13235)
@@ -130,10 +130,7 @@
     if (loadobj instanceof MovieClip) {
         // Nothing to do
     } else if (loadobj instanceof XMLNode) {
-        // The raw XML response string was stashed here by LzLoadQueue.XMLOnDataHandler
-        // TODO [2005-08-11 ptw] Is there not an issue that there
-        // could be multiple requests?
-        data.rawtext = this.rawtext;
+        // Nothing to do
     } else if ($debug) {
         Debug.error("%w.returnData: unhandled loadobj %w", this, loadobj);
     }

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzXMLLoader.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzXMLLoader.lzs	2009-03-09 23:12:23 UTC (rev 13234)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzXMLLoader.lzs	2009-03-10 00:07:38 UTC (rev 13235)
@@ -1,7 +1,7 @@
 /**
   * LzXMLLoader.as
   *
-  * @copyright Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.
+  * @copyright Copyright 2001-2009 Laszlo Systems, Inc.  All Rights Reserved.
   *            Use is subject to license terms.
   *
   * @topic Kernel
@@ -30,6 +30,10 @@
     var copyQueue = null;
     var copyLoopsPerFrame = 1000;
     var maxLoopTime = 2000; // 2 seconds
+    var copyTaskDel = null;
+    var lfcrootnode = null;
+    var trimwhitespace;
+    var nsprefix;
 
     function LzXMLLoader (owner, args) {
         super(owner, args);
@@ -44,7 +48,8 @@
       * (not really, but the doc tools will complain
       */
     override function destroy () {
-        this.copyTaskDel.unregisterAll();
+        this.removeCopyTask();
+        this.copyTaskDel = null;
         super.destroy();
     }
 
@@ -69,18 +74,23 @@
     }
 
     /**
-     * @access private
-     * called by loader when raw data was arrived, but not yet been parsed
-     */
+      * @access private
+      * called by loader when raw data was arrived, but not yet been parsed
+      */
     function gotRawData(content:String, loadobj:XML) {
         this.rawtext = content;
         this.xmlloadobj = loadobj;
         if (this.oncontent.ready) this.oncontent.sendEvent(content);
     }
 
-    function translateXML (content) {
-        this.xmlloadobj.parseXML(content);
-        // Copy the Flash XML tree into  tree of LFC LzData classes
+    /**
+      * Translate loaded XML document to LFC data-nodes
+      * @access private
+      */
+    function translateXML () {
+        this.xmlloadobj.parseXML(this.rawtext);
+        // Copy the Flash XML tree into tree of LFC LzData classes,
+        // on finish returnData() will be called
         this.queuedCopyFlashXML(this.xmlloadobj);
     }
 
@@ -126,18 +136,18 @@
         }
     }
 
-    // Recursively copy a Flash XML(Node) tree into a LzDataElement
-    // tree. Used by LzDataNode.stringToLzData
     /**
+      * Recursively copy a Flash XML(Node) tree into a LzDataElement
+      * tree. Used by LzDataNode.stringToLzData
       * @param boolean trimwhitespace: trim whitespace from start and end of text nodes
       * @param boolean nsprefix: preserve namespace prefixes on node names and attribute names
       * @access private
       */
     function copyFlashXML (node, trimwhitespace, nsprefix) {
-        var nv = node.nodeValue;
         var lfcnode = null;
         // text node?
         if (node.nodeType == 3) {
+            var nv = node.nodeValue;
             if (trimwhitespace == true) {
                 nv = LzDataElement.trim(nv);
             }
@@ -173,15 +183,7 @@
                 ASSetPropFlags(cattrs, ['__proto__', 'constructor'], 1, 7);
             }
 
-            var nname = node.nodeName;
-            if (nname && !nsprefix) {
-                // strip namespace prefix
-                var npos = nname.indexOf(':');
-                if (npos >= 0) {
-                    nname = nname.substring(npos+1);
-                }
-            }
-
+            var nname = nsprefix ? node.nodeName : node.localName;
             lfcnode = new LzDataElement(nname, cattrs);
             var children = node.childNodes;
             var newchildren = [];
@@ -195,8 +197,8 @@
         return lfcnode;
     }
 
-    // Set up the work queue
     /**
+      * Set up the work queue
       * @access private
       */
     function queuedCopyFlashXML(xmlnode) {
@@ -216,10 +218,10 @@
         }
     }
 
-    // Task that is called periodically from Idle loop.
-    // This does the work of copying the Flash XML tree into a LzDataElement tree.
-    // Run the copy queue
     /**
+      * Task that is called periodically from Idle loop.
+      * This does the work of copying the Flash XML tree into a LzDataElement tree.
+      * Run the copy queue
       * @access private
       */
     function copyFlashData ( ignore ) {
@@ -248,13 +250,13 @@
         //    Debug.write("removing copy idle task ", this);
         this.copyTaskDel.unregisterAll();
         this.copyQueue = null;
+        this.lfcrootnode = null;
     }
 
-    // Iterative implementation, using a queue, to translate a XMLNode tree into
-    // a tree of LzDataElement.
-    //
-    // Queue contains list of XMLNodes to be copied
     /**
+      * Iterative implementation, using a queue, to translate a XMLNode tree into
+      * a tree of LzDataElement.
+      * Queue contains list of XMLNodes to be copied
       * @access private
       */
     function queuedCopyFlashXML_internal () {
@@ -280,11 +282,11 @@
             var node = q[ptr++];
             var lfcparent = node._lfcparent;
             delete node._lfcparent;
-            var nv = node.nodeValue;
             var lfcnode = null;
 
             // text node?
             if (node.nodeType == 3) {
+                var nv = node.nodeValue;
                 if (trimwhitespace == true) {
                     nv = LzDataElement.trim(nv);
                 }
@@ -327,16 +329,7 @@
 
                 //lfcnode = new LzDataElement(node.nodeName, cattrs);
 
-                ////////
-
-                var nodename = node.nodeName;
-                if (nodename && !nsprefix) {
-                    var npos = nodename.indexOf(':');
-                    if (npos >= 0) {
-                        nodename = nodename.substring(npos+1);
-                    }
-                }
-
+                var nodename = nsprefix ? node.nodeName : node.localName;
                 // FIXME: [2008-3-31 pbr] This bypasses initialization
                 lfcnode = { __proto__: LzDataElement.prototype,
                             nodeType: LzDataElement.ELEMENT_NODE,
@@ -369,9 +362,11 @@
             // If we get here, we're finished with the tree copy.
             // Unregister the idle loop handler
             var xmlobj = this.copyQueue.xmlobj;
+            // <body><null>DATA</null></body>
+            var data = this.lfcrootnode.childNodes[0].childNodes[0];
             this.removeCopyTask();
             // Proceed with getting this dataset returned to the customer
-            xmlobj.loader.returnData(xmlobj, this.lfcrootnode.childNodes[0].childNodes[0]);
+            xmlobj.loader.returnData(xmlobj, data);
             // Indicate that we finished it all in one go, no need to queue more copy tasks
             return true;
         } else {



More information about the Laszlo-checkins mailing list