Author: max
Date: 2007-07-19 09:30:12 -0700 (Thu, 19 Jul 2007)
New Revision: 5703

Modified:
   openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
   openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
   openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzGlobalMouse.lzs
   openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloView.lzs
Log:
Change 20070718-maxcarlson-s by [EMAIL PROTECTED] on 2007-07-18 20:15:16 PDT
    in /Users/maxcarlson/openlaszlo/legals-checkin
    for http://svn.openlaszlo.org/openlaszlo/branches/legals

Summary: More efficient mouse handling

New Features:

Bugs Fixed: LPP-4329 - More efficient mouse handling

Technical Reviewer: promanik
QA Reviewer: jcrowley
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details: LzSprite.as - Return an object with both mouse coordinates.

LzSprite.js - Cache CSSDimension values for x, y, width and height and use them 
when seeing clipping size.  Return an object with both mouse coordinates.

LzGlobalMouse.lzs - Update _movecounter for each onmousemove event.

LaszloView.lzs - getMouse() returns cached value until next onmousemove.  
Passing null returns the raw x, y object.
    

Tests: All apps run as before.



Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js 
2007-07-19 16:06:26 UTC (rev 5702)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js 
2007-07-19 16:30:12 UTC (rev 5703)
@@ -654,9 +654,13 @@
     if (x == null || x == this.x || isNaN(x)) return;
     this.__poscachedirty = true;
     this.x = x;
-    this.__LZdiv.style.left = this.CSSDimension( x );
-    if (this.quirks.fix_clickable) {
-        this.__LZclickdiv.style.left = this.__LZdiv.style.left;
+    x = this.CSSDimension(x);
+    if (this._x != x) {
+        this._x = x;
+        this.__LZdiv.style.left = x;
+        if (this.quirks.fix_clickable) {
+            this.__LZclickdiv.style.left = x;
+        }
     }
 }
 
@@ -665,10 +669,14 @@
 
     //Debug.info('setWidth', w);
     this.width = w;
-    this.__LZdiv.style.width = this.CSSDimension( w );
-    if (this.clip) this.__updateClip();
-    if (this.stretches) this.__updateStretches();
-    if (this.__LZclick) this.__LZclick.style.width = this.__LZdiv.style.width;
+    w = this.CSSDimension(w);
+    if (this._w != w) {
+        this._w = w;
+        this.__LZdiv.style.width = w;
+        if (this.clip) this.__updateClip();
+        if (this.stretches) this.__updateStretches();
+        if (this.__LZclick) this.__LZclick.style.width = w;
+    }
 }
 
 LzSprite.prototype.setY = function ( y ){
@@ -676,9 +684,13 @@
     if (y == null || y == this.y || isNaN(y)) return;
     this.__poscachedirty = true;
     this.y = y;
-    this.__LZdiv.style.top = this.CSSDimension (y);
-    if (this.quirks.fix_clickable) {
-        this.__LZclickdiv.style.top = this.__LZdiv.style.top;
+    y = this.CSSDimension(y);
+    if (this._y != y) {
+        this._y = y;
+        this.__LZdiv.style.top = y;
+        if (this.quirks.fix_clickable) {
+            this.__LZclickdiv.style.top = y;
+        }
     }
 }
 
@@ -687,10 +699,14 @@
 
     this.height = h;
     //Debug.info('setHeight', h, this.height, this.owner);
-    this.__LZdiv.style.height = this.CSSDimension( h );
-    if (this.clip) this.__updateClip();
-    if (this.stretches) this.__updateStretches();
-    if (this.__LZclick) this.__LZclick.style.height = 
this.__LZdiv.style.height;
+    h = this.CSSDimension(h);
+    if (this._h != h) {
+        this._h = h;
+        this.__LZdiv.style.height = h; 
+        if (this.clip) this.__updateClip();
+        if (this.stretches) this.__updateStretches();
+        if (this.__LZclick) this.__LZclick.style.height = h;
+    }
 }
 
 /**
@@ -1018,10 +1034,10 @@
   */
 LzSprite.prototype.__updateClip = function() {
     if (this.clip && this.width != null && this.width >= 0 && this.height != 
null && this.height >= 0) {
-        //Debug.info('setClip', 'rect(0px ' + this.CSSDimension(this.width) + 
' ' + this.CSSDimension(this.height) + ' 0px)');
-        this.__LZdiv.style.clip = 'rect(0px ' + this.CSSDimension(this.width) 
+ ' ' + this.CSSDimension(this.height) + ' 0px)';
+        var s = 'rect(0px ' + this._w + ' ' + this._h + ' 0px)';
+        this.__LZdiv.style.clip = s
         if (this.quirks.fix_clickable) {
-            this.__LZclickdiv.style.clip = 'rect(0px ' + 
this.CSSDimension(this.width) + ' ' + this.CSSDimension(this.height) + ' 0px)';
+            this.__LZclickdiv.style.clip = s
         }
     } else if (this.__LZdiv.style.clip) {
         this.__LZdiv.style.clip = 'rect(auto auto auto auto)';
@@ -1115,22 +1131,20 @@
     this.destroyed = true;
 }
 
-LzSprite.prototype.getMouse = function(xy) {
+/**
+  * This method returns the position of the mouse relative to this sprite.
+  * 
+  * @return Object: The x and y position of the mouse relative to this sprite.
+  */
+LzSprite.prototype.getMouse = function() {
     // TODO: don't base these metrics on the mouse position
     //Debug.debug('LzSprite.getMouse', this.owner.classname, 
LzSprite.__rootSprite.getMouse('x'), LzSprite.__rootSprite.getMouse('y'));
     var p = this.__getPos();
     if (this.isroot) {
-        if (xy == 'x') {
-            return LzMouseKernel.__x - p.x;
-        } else {
-            return LzMouseKernel.__y - p.y;
-        }
+        return {x: LzMouseKernel.__x - p.x, y: LzMouseKernel.__y - p.y}
     } else {
-        if (xy == 'x') {
-            return LzSprite.__rootSprite.getMouse('x') - p.x;
-        } else {
-            return LzSprite.__rootSprite.getMouse('y') - p.y;
-        }
+        var m = LzSprite.__rootSprite.getMouse()
+        return {x: m.x - p.x, y: m.y - p.y}
     }
 }
 

Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzSprite.as   
2007-07-19 16:06:26 UTC (rev 5702)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzSprite.as   
2007-07-19 16:30:12 UTC (rev 5703)
@@ -924,13 +924,13 @@
 }
 
 /**
-  * This method returns the position of the mouse relative to this view.
-  * @param xory: a string ("x" | "y") specifying which axis to return
-  * @return Number: The position of the mouse relative to this view.
+  * This method returns the position of the mouse relative to this sprite.
+  * 
+  * @return Object: The x and y position of the mouse relative to this sprite.
   */
-LzSprite.prototype.getMouse = function( xory ) {
+LzSprite.prototype.getMouse = function() {
     if ( ! this.__LZmovieClipRef ) { this.makeContainerResource() };
-    return this.__LZmovieClipRef["_" + xory + "mouse" ];
+    return {x: this.__LZmovieClipRef._xmouse, y: this.__LZmovieClipRef._ymouse}
 }
 
 /**

Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzGlobalMouse.lzs
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzGlobalMouse.lzs       
2007-07-19 16:06:26 UTC (rev 5702)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzGlobalMouse.lzs       
2007-07-19 16:30:12 UTC (rev 5703)
@@ -78,7 +78,10 @@
 DeclareEvent(LzGlobalMouse, 'onmouseup' );
 DeclareEvent(LzGlobalMouse, 'onmousedown' );
 
+LzGlobalMouse.__movecounter = 0;
+
 /** @access private */
 LzGlobalMouse.__mouseEvent = function(eventname, view) {
+    if (eventname == 'onmousemove') LzGlobalMouse.__movecounter++;
     if (LzGlobalMouse[eventname]) LzGlobalMouse[eventname].sendEvent(view);
 }

Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloView.lzs
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloView.lzs     
2007-07-19 16:06:26 UTC (rev 5702)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloView.lzs     
2007-07-19 16:30:12 UTC (rev 5703)
@@ -1956,7 +1956,12 @@
   * @return Number: The position of the mouse relative to this view.
   */
 function getMouse( xory ) {
-    return this.sprite.getMouse(xory);
+    if (this.__movecounter != LzGlobalMouse.__movecounter) {
+        this.__movecounter = LzGlobalMouse.__movecounter;
+        this.__mousecache = this.sprite.getMouse(xory);
+    }
+    if (xory == null) return this.__mousecache;
+    return this.__mousecache[xory];
 }
 
 prototype.getMouse.dependencies = function( ) {


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

Reply via email to