Author: ptw
Date: 2007-10-23 09:54:41 -0700 (Tue, 23 Oct 2007)
New Revision: 6968

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzRuntime.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzDebug.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/debugger/platform/dhtml/LzDebug.js
Log:
Change 20071018-ptw-X by [EMAIL PROTECTED] on 2007-10-18 18:34:57 EDT
    in /Users/ptw/OpenLaszlo/ringding-2
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Be more careful detecting DOM nodes

Bugs Fixed:
LPP-4739 'Printing LzDataText in Debugger is erronous for "%w"'

Technical Reviewer: [EMAIL PROTECTED] (Message-ID: <[EMAIL PROTECTED]>)
QA Reviewer: [EMAIL PROTECTED] (pending)

Details:
    LzDebug.lzs: objectOwnProperties: Be more careful detecting
    prototypes, simplify test for 'own' properties to be any property
    that is different from that same property in the prototype (or all
    properties, if there is no prototype).  Take care poking at the
    prototype, which may be a runtime native object.

    LzDebug.js:  Tighten up the test for DOM nodes so that we don't
    mistake an LZ node for one.

    LzRuntime:  Eliminate old debugging output that was there just to
    verify source warnings were working.  Add Debug.ignoringErrors
    which can be used on any platform to evaluate a closure without
    recursing into the debugger.

Tests:
    1. Verified that LzDataText is printed as an LZX object (in SWF,
    Firefox, Safari, Opera):

    lzx> Debug.write("%#w\n", new LzDataText('test'))
    ?\194?\171LzDataText(0)#71| test?\194?\187

    2. Verified that DOM nodes can still be inspected (does not apply to SWF):

    lzx> Debug.inspect(canvas.sprite.__LZdiv)
    ?\194?\171HTMLDivElement#22| 
#document/html/body/div#lzappContainer/div.lzcanvasdiv[1]?\194?\187 {
    align: ''
    attributes: [object NamedNodeMap]
    ...
    tagName: 'DIV'
    textContent: ''
    title: ''
    }
    #document/html/body/div#lzappContainer/div.lzcanvasdiv[1]

    3. Verified that movieclips can still be inspected (only applies to
    SWF):

    lzx> Debug.inspect(_level0.spriteroot) 
    ?\194?\171MovieClip#160| _level0.spriteroot?\194?\187 { 
    _currentframe: 0 
    _opacity: ?\194?\171undefined?\194?\187 
    ...
    _visible: true 
    _x: 0 
    _xscale: 100 
    _y: 0 
    _yscale: 100 
    }?\194?\171MovieClip#160| _level0.spriteroot?\194?\187 
    lzx> 

    4. Ran smokecheck in swf and dhtml on Firefox



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzRuntime.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzRuntime.lzs     2007-10-23 
16:36:57 UTC (rev 6967)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzRuntime.lzs     2007-10-23 
16:54:41 UTC (rev 6968)
@@ -222,9 +222,6 @@
     Debug.__write(warning);
   };
 
-  Debug.debug("Source warnings enabled");
-  $reportSourceWarning('testing', 0, 'Test source warning');
-
   // Each of the warnings that the compile may call maintains a flag to
   // avoid recursing (e.g., when the debugger has a bug).
 
@@ -341,3 +338,34 @@
   }
 }
 
+if ($as2) {
+  /**
+   * Evaluate a closure in context, ignoring any errors
+   * @param closure:Function the closure to evaluate
+   * @param context:Object the context to evaluate the closure in
+   * @param errval:* the value to return if there is an error
+   * @access private
+   */
+  Debug.ignoringErrors = function ignoringErrors (closure, context, errval) {
+#pragma "warnUndefinedReferences=false"
+      return closure.call(context);
+  }
+} else {
+  /**
+   * Evaluate a closure in context, ignoring any errors
+   * @param closure:Function the closure to evaluate
+   * @param context:Object the context to evaluate the closure in
+   * @param errval:* the value to return if there is an error
+   * @access private
+   */
+  Debug.ignoringErrors = function ignoringErrors (closure, context, errval) {
+#pragma "warnUndefinedReferences=false"
+    try {
+      return closure.call(context);
+    } catch(e) {
+      return errval;
+    }
+  }
+}
+
+

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzDebug.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzDebug.lzs       2007-10-23 
16:36:57 UTC (rev 6967)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzDebug.lzs       2007-10-23 
16:54:41 UTC (rev 6968)
@@ -481,15 +481,19 @@
   var alen = (('length' in obj) &&
               (Math.floor(obj.length) === obj.length) &&
               (obj.length >= 0)) ? obj.length : false;
-  var hopp = 'hasOwnProperty' in obj;
-  var proto = (('__proto__' in obj) ? obj.__proto__ :
-               (('constructor' in obj) ? obj.constructor.prototype : false));
+  var hopp = 'hasOwnProperty' in obj && obj.hasOwnProperty instanceof Function;
+  // Use typeof == 'object' rather than instanceof Object for native prototypes
+  var proto = (('__proto__' in obj && (typeof obj.__proto__ == 'object')) ? 
obj.__proto__ :
+               (('constructor' in obj && (typeof obj.constructor.prototype == 
'object')) ? obj.constructor.prototype : false));
   for (var key in obj) {
-    if ((! hopp) ||
-        obj.hasOwnProperty(key) ||
-        // Heuristic to find getter slots (there is no way to ask if a
-        // property is a getter)
-        (proto && (obj[key] !== proto[key]))) {
+    // Heuristic to find 'interesting' slots, by which we mean slots
+    // that have a non-inherited value.  This should find 'own' slots,
+    // getters, and funny 'native' slots like swf movieclips, etc.
+    if ((! proto) ||
+        this.ignoringErrors(function () { return obj.hasOwnProperty(key);}, 
this, (! (key in proto))) ||
+        // Be careful poking at prototypes (consider getters that may
+        // fail when called on the prototype)
+        (obj[key] !== this.ignoringErrors(function () { return proto[key];}, 
this, {}))) {
       if ((alen != false) &&
           // Only `==` here because all keys are strings
           (Math.floor(key) == key) &&

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/debugger/platform/dhtml/LzDebug.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/debugger/platform/dhtml/LzDebug.js 
2007-10-23 16:36:57 UTC (rev 6967)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/debugger/platform/dhtml/LzDebug.js 
2007-10-23 16:54:41 UTC (rev 6968)
@@ -222,8 +222,9 @@
         s = this.functionName(thing, false);
         if (s == null) { s = ''; }
       }
-    } else if (! isNaN(Number(thing['nodeType']))) { // Doesn't work in Opera 
(thing instanceof Node) {
-      // tip o' the pin to osteele.com fot the notation format
+    } else if ((thing instanceof HTMLElement) &&
+               (! isNaN(Number(thing['nodeType'])))) {
+      // tip o' the pin to osteele.com for the notation format
       function nodeToString(node) {
         var tn = node.nodeName || '';
         var path = tn.toLowerCase();


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to