[Laszlo-checkins] r13862 - openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml
bargull@openlaszlo.org
bargull at openlaszlo.org
Mon May 11 14:49:04 PDT 2009
Author: bargull
Date: 2009-05-11 14:49:01 -0700 (Mon, 11 May 2009)
New Revision: 13862
Modified:
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
Log:
Change 20090511-bargull-T7M by bargull at dell--p4--2-53 on 2009-05-11 01:19:06
in /home/Admin/src/svn/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: fix position-cache bug in LzSprite
New Features:
Bugs Fixed: LPP-8163 (DHTML: cannot select items in combobox), LPP-8168 (DHTML: scrollbar and drag oddness)
Technical Reviewer: max
QA Reviewer: henry
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
The simple poscachedirty flag meachanism doesn't work because:
(1) if view "a" cached position, it's parent-view moves (this sets the dirty-flag) and then a sibling view of "a" calls getMouse(), view "a" will use the invalid cache (first additional testcase for LPP-8163)
(2) if view "a" cached position, it moves (this sets the dirty-flag) and then a subview calls getMouse(), view "a" will use the invalid cache (second additional testcase for LPP-8163)
LPP-8163 and LPP-8168 are types of these general bugs.
So replace the flag with a cache-id to know when any parent has got newer cache-information.
Tests:
see bugreport
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js 2009-05-11 19:18:49 UTC (rev 13861)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js 2009-05-11 21:49:01 UTC (rev 13862)
@@ -1252,7 +1252,7 @@
LzSprite.prototype.setX = function ( x ){
if (x == null || x == this.x) return;
- this.__poscachedirty = true;
+ this.__poscacheid = -1;
this.x = x;
x = this.CSSDimension(x);
if (this._x != x) {
@@ -1283,7 +1283,7 @@
LzSprite.prototype.setY = function ( y ){
//Debug.info('setY', y);
if (y == null || y == this.y) return;
- this.__poscachedirty = true;
+ this.__poscacheid = -1;
this.y = y;
y = this.CSSDimension(y);
if (this._y != y) {
@@ -1456,14 +1456,11 @@
*/
LzSprite.prototype.__findParents = function ( prop ){
var out = [];
- var sprite = this;
- if (sprite[prop] != null) out.push(sprite);
- do {
- sprite = sprite.__parent;
- if (! sprite) return out;
+ var root = LzSprite.__rootSprite;
+ for (var sprite = this; sprite; sprite = sprite.__parent) {
if (sprite[prop] != null) out.push(sprite);
- //alert(sprite);
- } while (sprite != LzSprite.__rootSprite)
+ if (sprite === root) break;
+ }
return out;
}
@@ -1932,10 +1929,10 @@
//Debug.debug('LzSprite.getMouse', this.owner.classname, LzSprite.__rootSprite.getMouse('x'), LzSprite.__rootSprite.getMouse('y'));
var p = this.__getPos();
if (this.isroot) {
- return {x: LzMouseKernel.__x - p.x, y: LzMouseKernel.__y - p.y}
+ return {x: LzMouseKernel.__x - p.x, y: LzMouseKernel.__y - p.y};
} else {
- var m = LzSprite.__rootSprite.getMouse()
- return {x: m.x - p.x, y: m.y - p.y}
+ var m = LzSprite.__rootSprite.getMouse();
+ return {x: m.x - p.x, y: m.y - p.y};
}
}
@@ -1946,38 +1943,58 @@
/**
* @access private
*/
-LzSprite.prototype.__poscachedirty = true;
+LzSprite.prototype.__poscacheid = 0;
/**
* @access private
*/
+LzSprite.__poscachecnt = 0;
+/**
+ * @access private
+ */
LzSprite.prototype.__getPos = function() {
- // Handle lpp-4357
+ // Handle LPP-4357
if (! LzSprite.__rootSprite.__initdone) {
return lz.embed.getAbsolutePosition(this.__LZdiv);
}
// check if any this sprite or any parents are dirty
var dirty = false;
- var p = this;
- while (p != LzSprite.__rootSprite) {
- if (p.__poscachedirty) {
- dirty = true;
+ var attached = true;
+ var root = LzSprite.__rootSprite;
+ var pp, ppmax;
+ for (var p = this; p !== root; p = pp) {
+ pp = p.__parent;
+ if (pp) {
+ if (p.__poscacheid < pp.__poscacheid) {
+ // cache is too old or invalid
+ dirty = true;
+ ppmax = pp;
+ }
+ } else {
+ // not yet attached to the DOM
+ attached = false;
break;
}
- p = p.__parent;
}
- if (dirty == false && this.__poscache) return this.__poscache;
- // compute position, temporarily showing hidden parents so they can be measured
- var pos = this.__processHiddenParents(lz.embed.getAbsolutePosition, this.__LZdiv);
+ if (dirty && attached) {
+ var next = ++LzSprite.__poscachecnt;
+ for (var p = this; p !== ppmax; p = p.__parent) {
+ // invalidate all bad caches
+ p.__poscache = null;
+ p.__poscacheid = next;
+ }
+ }
- // set this and parents' __poscachedirty to false
- var p = this;
- while (p && p != LzSprite.__rootSprite) {
- if (p.__parent) p.__poscachedirty = false;
- p = p.__parent;
+ var pos = this.__poscache;
+ if (! pos) {
+ // compute position, temporarily showing hidden parents so they can be measured
+ pos = this.__processHiddenParents(lz.embed.getAbsolutePosition, this.__LZdiv);
+ if (attached) {
+ // only cache position if the sprite is attached to the DOM (LPP-4357)
+ this.__poscache = pos;
+ }
}
- this.__poscache = pos;
return pos;
}
More information about the Laszlo-checkins
mailing list