[Laszlo-checkins] r13831 - openlaszlo/trunk/WEB-INF/lps/lfc/views

max@openlaszlo.org max at openlaszlo.org
Thu May 7 19:02:51 PDT 2009


Author: max
Date: 2009-05-07 19:02:49 -0700 (Thu, 07 May 2009)
New Revision: 13831

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/views/LzText.lzs
Log:
Change 20090507-maxcarlson-Z by maxcarlson at Bank on 2009-05-07 14:52:09 PDT
    in /Users/maxcarlson/openlaszlo/trunk-clean
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Improve argument checking for fontsize, fontstyle, letterspacing and textindent

Bugs Fixed: LPP-7861 - Invalid value passed into LzTextSprite.prototype.setFontStyle errors out in MSIE in DHTML

Technical Reviewer: andre.bargull at udo.edu
QA Reviewer: hminsky

Details: LzText - Check and warn for invalid fontsize, fontstyle, letterspacing and textindent values.

LaszloView - Check and warn for invalid fontsize and fontstyle values.

Tests: See updated testcase for LPP-7861



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs	2009-05-08 00:44:04 UTC (rev 13830)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs	2009-05-08 02:02:49 UTC (rev 13831)
@@ -770,9 +770,13 @@
 
 /** @access private */
 function $lzc$set_fontstyle(val) {
-    this.fontstyle = val;
-    if (this.onfontstyle.ready) { 
-        this.onfontstyle.sendEvent( this.fontstyle ); 
+    if (val == 'plain' || val == 'bold' || val == 'italic' || val == 'bolditalic') {
+        this.fontstyle = val;
+        if (this.onfontstyle.ready) { 
+            this.onfontstyle.sendEvent( this.fontstyle ); 
+        }
+    } else {
+        if ($debug) Debug.warn('invalid font style', val);
     }
 }
 
@@ -785,9 +789,13 @@
 
 /** @access private */
 function $lzc$set_fontsize(val) {
-    this.fontsize = val;
-    if (this.onfontsize.ready) { 
-        this.onfontsize.sendEvent( this.fontsize ); 
+    if (val <= 0 || isNaN(val)) {
+        if ($debug) Debug.warn('invalid font size', val);
+    } else {
+        this.fontsize = val;
+        if (this.onfontsize.ready) { 
+            this.onfontsize.sendEvent( this.fontsize ); 
+        }
     }
 }
 

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LzText.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/LzText.lzs	2009-05-08 00:44:04 UTC (rev 13830)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LzText.lzs	2009-05-08 02:02:49 UTC (rev 13831)
@@ -774,9 +774,13 @@
 
   /** @access private */
   override function $lzc$set_fontstyle(fstyle) {
-    super.$lzc$set_fontstyle(fstyle);
-    this.tsprite.setFontStyle(fstyle);
-    this._updateSize();
+    if (fstyle == 'plain' || fstyle == 'bold' || fstyle == 'italic' || fstyle == 'bolditalic') {
+      super.$lzc$set_fontstyle(fstyle);
+      this.tsprite.setFontStyle(fstyle);
+      this._updateSize();
+    } else {
+      if ($debug) Debug.warn('invalid font style', fstyle);
+    }
   }
 
   /** @access private */
@@ -788,9 +792,13 @@
 
   /** @access private */
   override function $lzc$set_fontsize(fsize) {
-    super.$lzc$set_fontsize(fsize);
-    this.tsprite.setFontSize(fsize);
-    this._updateSize();
+    if (fsize <= 0 || isNaN(fsize)) {
+      if ($debug) Debug.warn('invalid font size', fsize);
+    } else {
+      super.$lzc$set_fontsize(fsize);
+      this.tsprite.setFontSize(fsize);
+      this._updateSize();
+    }
   }
 
   /** text-align for this text
@@ -820,9 +828,13 @@
   var textindent :Number = 0;
   /** @access private */
   function $lzc$set_textindent (indent:Number) :void {
-    this.textindent = indent;
-    this.tsprite.setTextIndent(indent);
-    this._updateSize();
+    if (indent < 0 || isNaN(indent)) {
+      if ($debug) Debug.warn('invalid text indent', indent);
+    } else {
+      this.textindent = indent;
+      this.tsprite.setTextIndent(indent);
+      this._updateSize();
+    }
   }
 
   /** letter-spacing for this text
@@ -832,9 +844,13 @@
   var letterspacing :Number = 0;
   /** @access private */
   function $lzc$set_letterspacing (spacing:Number) :void {
-    this.letterspacing = spacing;
-    this.tsprite.setLetterSpacing(spacing);
-    this._updateSize();
+    if (spacing < 0 || isNaN(spacing)) {
+      if ($debug) Debug.warn('invalid letter spacing', spacing);
+    } else {
+      this.letterspacing = spacing;
+      this.tsprite.setLetterSpacing(spacing);
+      this._updateSize();
+    }
   }
 
   /** text-decoration for this text



More information about the Laszlo-checkins mailing list