[Laszlo-checkins] r12346 - in openlaszlo/branches/4.2: . WEB-INF/lps/lfc/views
ptw@openlaszlo.org
ptw at openlaszlo.org
Wed Jan 7 13:38:45 PST 2009
Author: ptw
Date: 2009-01-07 13:38:43 -0800 (Wed, 07 Jan 2009)
New Revision: 12346
Modified:
openlaszlo/branches/4.2/
openlaszlo/branches/4.2/WEB-INF/lps/lfc/views/LaszloView.lzs
Log:
Merged revisions 12345 via svnmerge from
http://svn.openlaszlo.org/openlaszlo/trunk
.......
r12345 | ptw | 2009-01-07 16:34:48 -0500 (Wed, 07 Jan 2009) | 26 lines
Change 20090106-ptw-x by ptw at dueling-banjos.home on 2009-01-06 16:01:34 EST
in /Users/ptw/OpenLaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Fix view position and dimension memoization
Bugs Fixed:
LPP-7560 null value of an attribute should not be 0
Technical Reviewer: a.bargull at intensis.de (Message-ID: <4963E363.4060002 at udo.edu>)
QA Reviewer: fguo at laszlosystems.com (pending)
Details:
Renamed the memoization fields to be more explicit. Made the
memoization comparison use identity not equality. Removed the
redundant recompute flags (replaced by just clearing
memoization). Corrected constructor test for explicit
height/width. Added extensive comments so this code won't seem so
magical to the next viewer. Moved kernel calls for width/height
so unnecessary calls are not made (kernels should never see a null
value now...)
Tests:
smokecheck, test case from bug
.......
Property changes on: openlaszlo/branches/4.2
___________________________________________________________________
Name: svnmerge-integrated
- /openlaszlo/branches/4.1:1-10153 /openlaszlo/branches/devildog:1-8432 /openlaszlo/branches/pagan-deities:1-7955,8825,10756-10920,10922-10928,10930-10935,11151,11207,11554 /openlaszlo/branches/paperpie:1-6504,6506-6574,6576-7135,7137-7235 /openlaszlo/branches/wafflecone:1-5746,5818-6068,6070-6205,6207-6213,6216-6265,6267-6368,6370-6431,6433-6450,6497,6509,6661,7097,7872 /openlaszlo/trunk:1-12154,12172-12175,12177-12185,12187-12194,12196,12201,12208,12251-12252,12254-12255,12257-12258,12260,12262-12266,12268-12269,12271-12275,12278-12285,12303,12318-12323
+ /openlaszlo/branches/4.1:1-10153 /openlaszlo/branches/devildog:1-8432 /openlaszlo/branches/pagan-deities:1-7955,8825,10756-10920,10922-10928,10930-10935,11151,11207,11554 /openlaszlo/branches/paperpie:1-6504,6506-6574,6576-7135,7137-7235 /openlaszlo/branches/wafflecone:1-5746,5818-6068,6070-6205,6207-6213,6216-6265,6267-6368,6370-6431,6433-6450,6497,6509,6661,7097,7872 /openlaszlo/trunk:1-12154,12172-12175,12177-12185,12187-12194,12196,12201,12208,12251-12252,12254-12255,12257-12258,12260,12262-12266,12268-12269,12271-12275,12278-12285,12303,12318-12323,12345
Modified: openlaszlo/branches/4.2/WEB-INF/lps/lfc/views/LaszloView.lzs
===================================================================
--- openlaszlo/branches/4.2/WEB-INF/lps/lfc/views/LaszloView.lzs 2009-01-07 21:34:48 UTC (rev 12345)
+++ openlaszlo/branches/4.2/WEB-INF/lps/lfc/views/LaszloView.lzs 2009-01-07 21:38:43 UTC (rev 12346)
@@ -1,6 +1,6 @@
/**
*
- * @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.
*
* @affects lzview
@@ -77,13 +77,7 @@
static var __LZdelayedSetters = new LzInheritedHash(LzNode.__LZdelayedSetters);
/** @access private */
static var earlySetters = new LzInheritedHash(LzNode.earlySetters);
-
- /** true forces next call to setAttribute('x',...) to run
- @access private */
- var _xrecompute:Boolean = false;
- /** true forces next call to setAttribute('y',...) to run
- @access private */
- var _yrecompute:Boolean = false;
+
/** @access private */
var __LZlayout
@@ -101,8 +95,8 @@
* @keywords readonly
*/
var playing = false;
-
+
/** @access private */
var _visible;
@@ -438,11 +432,11 @@
this.__makeSprite(args);
- if ( 'width' in args || this.__LZhasConstraint('width')) {
+ if (args['width'] != null || this.__LZhasConstraint('width')) {
this.hassetwidth = true;
this.__LZcheckwidth = false;
}
- if ( 'height' in args || this.__LZhasConstraint('height')) {
+ if (args['height'] != null || this.__LZhasConstraint('height')) {
this.hassetheight = true;
this.__LZcheckheight = false;
}
@@ -1030,71 +1024,102 @@
* @lzxtype numberExpression
* @lzxdefault "0"
*/
-var x = 0;
+var x = 0;
-/** @access private */
-var _x:Number;
+/**
+ * Memo of last x _set_. Used for optimizing out redundant calls
+ * (profiling showed many calls during initialization as constraints
+ * settled).
+ *
+ * @devnote [2009-01-06 ptw] This is strictly a memoization of the
+ * last value set. It starts out as `undefined`, and the comparison
+ * uses identity (`===`) to ensure that an initial setting of `null`
+ * is not ignored.
+ *
+ * @access private
+ */
+var __set_x_memo:*;
/** @access private */
function $lzc$set_x(v) {
- if (this._xrecompute || this._x != v) {
- this._x = v;
- this.x = v;
- if ( this.__LZhasoffset ){
- if (this.capabilities.rotation) {
- v -= ( this.xoffset * this.__LZrcos -
- this.yoffset * this.__LZrsin );
- } else {
- v -= this.xoffset;
- }
+ // NOTE: [2009-01-06 ptw] See @devnote at __set_x_memo
+ if (this.__set_x_memo === v) {
+ // Always send the event
+ if (this.onx.ready) { this.onx.sendEvent( this.x ); }
+ return;
+ }
+ // memoize
+ this.__set_x_memo = v;
+
+ this.x = v;
+ if ( this.__LZhasoffset ){
+ if (this.capabilities.rotation) {
+ v -= ( this.xoffset * this.__LZrcos -
+ this.yoffset * this.__LZrsin );
+ } else {
+ v -= this.xoffset;
}
-
- if ( this.pixellock ) v = Math.floor( v );
- this.sprite.setX(v)
-
- var vip:LzView = (this.immediateparent cast LzView);
- if (vip.__LZcheckwidth)
- vip.__LZcheckwidthFunction( this );
- if (this.onx.ready) this.onx.sendEvent( this.x );
- this._xrecompute = false;
}
+
+ if ( this.pixellock ) v = Math.floor( v );
+ this.sprite.setX(v)
+ var vip:LzView = (this.immediateparent cast LzView);
+ if (vip.__LZcheckwidth) { vip.__LZcheckwidthFunction( this ); }
+ if (this.onx.ready) { this.onx.sendEvent( this.x ); }
}
+
/** The vertical offset of this view's upper left corner from the
* upper left corner of its container
* @type Number
* @lzxtype numberExpression
* @lzxdefault "0"
*/
-var y = 0;
+var y = 0;
-/** @access private */
-var _y:Number;
+/**
+ * Memo of last y _set_. Used for optimizing out redundant calls
+ * (profiling showed many calls during initialization as constraints
+ * settled).
+ *
+ * @devnote [2009-01-06 ptw] This is strictly a memoization of the
+ * last value set. It starts out as `undefined`, and the comparison
+ * uses identity (`===`) to ensure that an initial setting of `null`
+ * is not ignored.
+ *
+ * @access private
+ */
+var __set_y_memo:*;
/** @access private */
function $lzc$set_y(v) {
- if (this._yrecompute || this._y != v) {
- this._y = v;
- this.y = v;
- if ( this.__LZhasoffset ){
- if (this.capabilities.rotation) {
- v -= ( this.xoffset * this.__LZrsin +
- this.yoffset * this.__LZrcos );
- } else {
- v -= this.yoffset;
- }
+ // NOTE: [2009-01-06 ptw] See @devnote at __set_y_memo
+ if (this.__set_y_memo === v) {
+ // Always send the event
+ if (this.onx.ready) { this.onx.sendEvent( this.x ); }
+ return;
+ }
+ // memoize
+ this.__set_y_memo = v;
+
+ this.y = v;
+ if ( this.__LZhasoffset ){
+ if (this.capabilities.rotation) {
+ v -= ( this.xoffset * this.__LZrsin +
+ this.yoffset * this.__LZrcos );
+ } else {
+ v -= this.yoffset;
}
-
- if ( this.pixellock ) v = Math.floor( v );
- this.sprite.setY(v)
- var vip:LzView = (this.immediateparent cast LzView);
- if (vip.__LZcheckheight)
- vip.__LZcheckheightFunction( this );
- if (this.ony.ready) this.ony.sendEvent( this.y );
- this._yrecompute = false;
}
+
+ if ( this.pixellock ) v = Math.floor( v );
+ this.sprite.setY(v)
+ var vip:LzView = (this.immediateparent cast LzView);
+ if (vip.__LZcheckheight) { vip.__LZcheckheightFunction( this ); }
+ if (this.ony.ready) { this.ony.sendEvent( this.y ); }
}
+
/** The rotation value for the view (in degrees).
* Value may be less than zero or greater than 360.
* @type Number
@@ -1117,9 +1142,11 @@
if (this.onrotation.ready) this.onrotation.sendEvent( v );
if ( this.__LZhasoffset ){
- this._xrecompute = true;
- this._yrecompute = true;
+ // Clear the memo cache to force a recompute
+ this.__set_x_memo = void 0;
this.$lzc$set_x(this.x);
+ // Clear the memo cache to force a recompute
+ this.__set_y_memo = void 0;
this.$lzc$set_y(this.y);
}
@@ -1131,109 +1158,151 @@
}
/**
- * The width of the view
+ * The width of the view. Can be set to either a number, or
+ * <code>null</code>, to indicate that the view should be sized to
+ * hold its content. When read, reflects the actual size of the view.
+ *
* @access public
- * @type Number
+ * @type *
* @lzxtype sizeExpression
*/
-var width = 0;
+var width:* = 0;
-/** @access private */
-var _width:Number;
+/**
+ * Memo of last width _set_. Used for optimizing out redundant calls
+ * (profiling showed many calls during initialization as constraints
+ * settled).
+ *
+ * @devnote [2009-01-06 ptw] This is strictly a memoization of the
+ * last value set. It starts out as `undefined`, and the comparison
+ * uses identity (`===`) to ensure that an initial setting of `null`
+ * is not ignored.
+ *
+ * @access private
+ */
+var __set_width_memo:*;
/** @access private */
function $lzc$set_width(v) {
- if (this._width != v) {
- this._width = v;
- this.sprite.setWidth(v);
+ // NOTE: [2009-01-06 ptw] See @devnote at __set_width_memo
+ if (this.__set_width_memo === v) {
+ // Always send the event
+ if (this.onwidth.ready) { this.onwidth.sendEvent( this.width ); }
+ return;
+ }
+ // memoize
+ this.__set_width_memo = v;
- if ( v == null ){
- this.hassetwidth = false;
- // expose proto method
- this.__LZcheckwidth = true;
- if ( this._setrescwidth ){
- // will be updated by reevaluateSize
- this.unstretchedwidth = null;
- // defaults
- this._xscale = 1;
- //this.__LZmovieClipRef._xscale = 100;
- }
- this.reevaluateSize( 'width' );
- return;
+ // NOTE: [2009-01-06 ptw] We used to unconditionally call
+ // `sprite.setWidth` here, but that is bogus because a null value
+ // will immediately be overridden by `reevaluateSize` below, and a
+ // non-null value will not be adjusted by `pixellock`.
+ if ( v == null ){
+ this.hassetwidth = false;
+ // expose proto method
+ this.__LZcheckwidth = true;
+ if ( this._setrescwidth ){
+ // will be updated by reevaluateSize
+ this.unstretchedwidth = null;
+ // defaults
+ this._xscale = 1;
}
- this.width = v;
- if ( this.pixellock ) v = Math.floor( v );
- if ( this._setrescwidth ){
+ // NOTE: [2009-01-06 ptw] This will end up setting `width` to
+ // the width of the contents, will call `sprite.setWidth`
+ // with that value, and will send `onwidth`.
+ this.reevaluateSize( 'width' );
+ return;
+ }
+
+ this.width = v;
+ this.hassetwidth = true;
+ if ( this.pixellock ) { v = Math.floor( v ); }
+ if ( this._setrescwidth ){
var xscale = this.unstretchedwidth == 0 ? 100 : v/this.unstretchedwidth;
this._xscale = xscale;
- //this.__LZmovieClipRef._xscale = xscale * 100;
- } else {
- this.__LZcheckwidth = false;
- }
-
- this.hassetwidth = true;
-
- //this.__LZbgRef._xscale = v;
+ } else {
+ this.__LZcheckwidth = false;
+ }
+ this.sprite.setWidth(v);
- var vip:LzView = (this.immediateparent cast LzView);
- if (vip && vip.__LZcheckwidth)
- vip.__LZcheckwidthFunction( this );
+ var vip:LzView = (this.immediateparent cast LzView);
+ if (vip && vip.__LZcheckwidth) { vip.__LZcheckwidthFunction( this ); }
-
- if (this.onwidth.ready) this.onwidth.sendEvent( v );
- }
+ if (this.onwidth.ready) { this.onwidth.sendEvent( this.width ); }
}
+
/**
- * The height of the view
+ * The height of the view. Can be set to either a number, or
+ * <code>null</code>, to indicate that the view should be sized to
+ * hold its content. When read, reflects the actual size of the view.
+ *
* @access public
- * @type Number
+ * @type *
* @lzxtype sizeExpression
*/
-var height = 0;
+var height:* = 0;
-/** @access private */
-var _height:Number;
+/**
+ * Memo of last height _set_. Used for optimizing out redundant calls
+ * (profiling showed many calls during initialization as constraints
+ * settled).
+ *
+ * @devnote [2009-01-06 ptw] This is strictly a memoization of the
+ * last value set. It starts out as `undefined`, and the comparison
+ * uses identity (`===`) to ensure that an initial setting of `null`
+ * is not ignored.
+ *
+ * @access private
+ */
+var __set_height_memo:*;
/** @access private */
function $lzc$set_height(v) {
- if (this._height != v) {
- this._height = v;
- this.sprite.setHeight(v);
+ // NOTE: [2009-01-06 ptw] See @devnote at __set_height_memo
+ if (this.__set_height_memo === v) {
+ // Always send the event
+ if (this.onheight.ready) { this.onheight.sendEvent( this.height ); }
+ return;
+ }
+ // memoize
+ this.__set_height_memo = v;
- if ( v == null ){
- this.hassetheight = false;
- // expose proto method
- this.__LZcheckheight = true;
-
- if ( this._setrescheight ){
- // will be updated by reevaluateSize
- this.unstretchedheight = null;
- // defaults
- this._yscale = 1;
- //this.__LZmovieClipRef._yscale = 100;
- }
- this.reevaluateSize( 'height' );
- return;
- }
- this.height = v;
- if ( this.pixellock ) v = Math.floor( v );
+ // NOTE: [2009-01-06 ptw] We used to unconditionally call
+ // `sprite.setHeight` here, but that is bogus because a null value
+ // will immediately be overridden by `reevaluateSize` below, and a
+ // non-null value will not be adjusted by `pixellock`.
+ if ( v == null ){
+ this.hassetheight = false;
+ // expose proto method
+ this.__LZcheckheight = true;
if ( this._setrescheight ){
- var yscale = this.unstretchedheight == 0 ? 100 : v/this.unstretchedheight;
- this._yscale = yscale;
- //this.__LZmovieClipRef._yscale = yscale * 100;
- } else {
- this.__LZcheckheight = false;
+ // will be updated by reevaluateSize
+ this.unstretchedheight = null;
+ // defaults
+ this._yscale = 1;
}
- this.hassetheight = true;
-
- var vip:LzView = (this.immediateparent cast LzView);
- if (vip && vip.__LZcheckheight)
- vip.__LZcheckheightFunction( this );
+ // NOTE: [2009-01-06 ptw] This will end up setting `height` to
+ // the height of the contents, will call `sprite.setHeight`
+ // with that value, and will send `onheight`.
+ this.reevaluateSize( 'height' );
+ return;
+ }
+ this.height = v;
+ this.hassetheight = true;
+ if ( this.pixellock ) { v = Math.floor( v ); }
+ if ( this._setrescheight ){
+ this._yscale = this.unstretchedheight == 0 ? 100 : v/this.unstretchedheight;
+ } else {
+ this.__LZcheckheight = false;
+ }
+ this.sprite.setHeight(v);
- if (this.onheight.ready) this.onheight.sendEvent( v );
- }
+ var vip:LzView = (this.immediateparent cast LzView);
+ if (vip && vip.__LZcheckheight) { vip.__LZcheckheightFunction( this ); }
+
+ if (this.onheight.ready) { this.onheight.sendEvent( this.height ); }
}
/** If stretches is not set to none, the width
@@ -1278,9 +1347,11 @@
function $lzc$set_xoffset(o) {
this.__LZhasoffset = o != 0;
this.xoffset = o;
- this._xrecompute = true;
- this._yrecompute = true;
+ // Clear the memo cache to force a recompute
+ this.__set_x_memo = void 0;
this.$lzc$set_x(this.x);
+ // Clear the memo cache to force a recompute
+ this.__set_y_memo = void 0;
this.$lzc$set_y(this.y);
if (this.onxoffset.ready) this.onxoffset.sendEvent( o );
}
@@ -1302,9 +1373,11 @@
function $lzc$set_yoffset(o) {
this.__LZhasoffset = o != 0;
this.yoffset = o;
- this._xrecompute = true;
- this._yrecompute = true;
+ // Clear the memo cache to force a recompute
+ this.__set_x_memo = void 0;
this.$lzc$set_x(this.x);
+ // Clear the memo cache to force a recompute
+ this.__set_y_memo = void 0;
this.$lzc$set_y(this.y);
if (this.onyoffset.ready) this.onyoffset.sendEvent( o );
}
@@ -1367,17 +1440,21 @@
*/
var loadratio = 0;
-/** If true, then setWidth() has been called on this
- * view, and the view will not be sized to its contents.
- * @type Boolean
- * @keywords readonly
- */
+/**
+ * If true, then this view has an assigned or constrained height, and
+ * the view will not be sized to its contents.
+ *
+ * @type Boolean
+ * @keywords readonly
+ */
var hassetheight = false;
-/** If true, then setHeight() has been called on this
- * view, and the view will not be sized to its contents.
- * @type Boolean
- * @keywords readonly
- */
+/**
+ * If true, then this view has an assigned or constrained width, and
+ * the view will not be sized to its contents.
+ *
+ * @type Boolean
+ * @keywords readonly
+ */
var hassetwidth = false;
/** need quick check for viewness
More information about the Laszlo-checkins
mailing list