gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ...
Date: Thu, 10 Apr 2008 15:33:19 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/04/10 15:33:19

Modified files:
        .              : ChangeLog 
        server         : edit_text_character.cpp 
        server/asobj   : TextFormat.cpp TextFormat.h 
        testsuite/actionscript.all: TextFormat.as 

Log message:
                * server/edit_text_character.cpp (setTextFormat): don't
                  use uninitialized members of a TextFormat.
                * server/asobj/TextFormat.{cpp,h}: support concept
                  of "undefined" members; fix constructor.
                * testsuite/actionscript.all/TextFormat.as: test that
                  most properties of a TextFormat are null when not
                  initialized; and test initialization.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6240&r2=1.6241
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.167&r2=1.168
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/TextFormat.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/TextFormat.h?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/TextFormat.as?cvsroot=gnash&r1=1.1&r2=1.2

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6240
retrieving revision 1.6241
diff -u -b -r1.6240 -r1.6241
--- ChangeLog   10 Apr 2008 14:05:21 -0000      1.6240
+++ ChangeLog   10 Apr 2008 15:33:17 -0000      1.6241
@@ -1,5 +1,15 @@
 2008-04-10 Sandro Santilli <address@hidden>
 
+       * server/edit_text_character.cpp (setTextFormat): don't
+         use uninitialized members of a TextFormat.
+       * server/asobj/TextFormat.{cpp,h}: support concept
+         of "undefined" members; fix constructor.
+       * testsuite/actionscript.all/TextFormat.as: test that
+         most properties of a TextFormat are null when not
+         initialized; and test initialization.
+
+2008-04-10 Sandro Santilli <address@hidden>
+
        * testsuite/misc-ming.all/Video-EmbedSquareTestRunner.cpp: don't
          check colors on the corners, and sample some more pixels around
          the point.

Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.167
retrieving revision 1.168
diff -u -b -r1.167 -r1.168
--- server/edit_text_character.cpp      10 Apr 2008 10:13:30 -0000      1.167
+++ server/edit_text_character.cpp      10 Apr 2008 15:33:18 -0000      1.168
@@ -231,14 +231,16 @@
                return as_value();
        }
 
-       text->setAlignment(tf->align());
-       text->setFontHeight(tf->size()); // keep twips
-       text->setIndent(tf->indent());
-       text->setLeading(tf->leading());
-       text->setLeftMargin(tf->leftMargin());
-       text->setRightMargin(tf->rightMargin());
-       text->setTextColor(tf->color());
+       if ( tf->alignDefined() ) text->setAlignment(tf->align());
+       if ( tf->sizeDefined() ) text->setFontHeight(tf->size()); // keep twips
+       if ( tf->indentDefined() ) text->setIndent(tf->indent());
+       if ( tf->leadingDefined() ) text->setLeading(tf->leading());
+       if ( tf->leftMarginDefined() ) text->setLeftMargin(tf->leftMargin());
+       if ( tf->rightMarginDefined() ) text->setRightMargin(tf->rightMargin());
+       if ( tf->colorDefined() ) text->setTextColor(tf->color());
 
+       if ( tf->fontDefined() )
+       {
        const std::string& fontName = tf->font();
        if ( ! fontName.empty() )
        {
@@ -251,6 +253,7 @@
                boost::intrusive_ptr<font> f ( new font(fontName, bold, italic) 
);
                text->setFont( f );
        }
+       }
 
        // TODO: add font color and some more
 

Index: server/asobj/TextFormat.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/TextFormat.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/asobj/TextFormat.cpp 10 Apr 2008 10:13:30 -0000      1.9
+++ server/asobj/TextFormat.cpp 10 Apr 2008 15:33:18 -0000      1.10
@@ -40,18 +40,20 @@
 TextFormat::TextFormat()
        :
        as_object(getTextFormatInterface()),
+       _flags(0),
        _underline(false),
        _bold(false),
        _italic(false),
        _bullet(false),
-       _block_indent(-1),
+       _align(edit_text_character_def::ALIGN_LEFT),
+       _blockIndent(-1),
        _color(),
        _indent(-1),
        _leading(-1),
-       _left_margin(-1),
-       _right_margin(-1),
-       _point_size(-1),
-       _tab_stops(-1),
+       _leftMargin(-1),
+       _rightMargin(-1),
+       _pointSize(-1),
+       _tabStops(-1),
        _target()
 {
        //log_debug("%s:", __FUNCTION__);
@@ -66,7 +68,7 @@
 
        boost::intrusive_ptr<TextFormat> tf = new TextFormat;
        if ( fn.nargs > 0  ) {  tf->fontSet(fn.arg(0).to_string());
-       if ( fn.nargs > 1  ) {  tf->sizeSet(fn.arg(1).to_int());
+       if ( fn.nargs > 1  ) {  
tf->sizeSet(PIXELS_TO_TWIPS(fn.arg(1).to_int()));
        if ( fn.nargs > 2  ) {  rgba col; col.parseRGB(fn.arg(2).to_int()); 
tf->colorSet(col); 
        if ( fn.nargs > 3  ) {  tf->boldSet(fn.arg(3).to_bool()); 
        if ( fn.nargs > 4  ) {  tf->italicedSet(fn.arg(4).to_bool()); 
@@ -74,10 +76,10 @@
        if ( fn.nargs > 6  ) {  tf->urlSet(fn.arg(6).to_string()); 
        if ( fn.nargs > 7  ) {  tf->targetSet(fn.arg(7).to_string()); 
        if ( fn.nargs > 8  ) {  tf->alignSet(fn.arg(8).to_string());
-       if ( fn.nargs > 9  ) {  tf->leftMarginSet(fn.arg(9).to_int());
-       if ( fn.nargs > 10 ) {  tf->rightMarginSet(fn.arg(10).to_int());
-       if ( fn.nargs > 11 ) {  tf->indentSet(fn.arg(11).to_int());
-       if ( fn.nargs > 12 ) {  tf->leadingSet(fn.arg(12).to_int());
+       if ( fn.nargs > 9  ) {  
tf->leftMarginSet(PIXELS_TO_TWIPS(fn.arg(9).to_int()));
+       if ( fn.nargs > 10 ) {  
tf->rightMarginSet(PIXELS_TO_TWIPS(fn.arg(10).to_int()));
+       if ( fn.nargs > 11 ) {  
tf->indentSet(PIXELS_TO_TWIPS(fn.arg(11).to_int()));
+       if ( fn.nargs > 12 ) {  
tf->leadingSet(PIXELS_TO_TWIPS(fn.arg(12).to_int()));
        }}}}}}}}}}}}}
 
        return as_value(tf.get());
@@ -116,16 +118,19 @@
 {
        boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
 
+       as_value ret;
+
        if ( fn.nargs == 0 ) // getter
        {
-               return as_value(TWIPS_TO_PIXELS(ptr->leading()));
+               if ( ptr->leadingDefined() ) 
ret.set_double(TWIPS_TO_PIXELS(ptr->leading()));
+               else ret.set_null();
        }
        else // setter
        {
                ptr->leadingSet(PIXELS_TO_TWIPS(fn.arg(0).to_int()));
        }
 
-       return as_value();
+       return ret;
 }
 
 as_value
@@ -133,16 +138,19 @@
 {
        boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
 
+       as_value ret;
+
        if ( fn.nargs == 0 ) // getter
        {
-               return as_value(TWIPS_TO_PIXELS(ptr->indent()));
+               if ( ptr->indentDefined() ) 
ret.set_double(TWIPS_TO_PIXELS(ptr->indent()));
+               else ret.set_null();
        }
        else // setter
        {
                ptr->indentSet(PIXELS_TO_TWIPS(fn.arg(0).to_int()));
        }
 
-       return as_value();
+       return ret;
 }
 
 as_value
@@ -150,16 +158,19 @@
 {
        boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
 
+       as_value ret;
+
        if ( fn.nargs == 0 ) // getter
        {
-               return as_value(TWIPS_TO_PIXELS(ptr->rightMargin()));
+               if ( ptr->rightMarginDefined() ) 
ret.set_double(TWIPS_TO_PIXELS(ptr->rightMargin()));
+               else ret.set_null();
        }
        else // setter
        {
                ptr->rightMarginSet(PIXELS_TO_TWIPS(fn.arg(0).to_int()));
        }
 
-       return as_value();
+       return ret;
 }
 
 as_value
@@ -167,16 +178,19 @@
 {
        boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
 
+       as_value ret;
+
        if ( fn.nargs == 0 ) // getter
        {
-               return as_value(TWIPS_TO_PIXELS(ptr->leftMargin()));
+               if ( ptr->leftMarginDefined() ) 
ret.set_double(TWIPS_TO_PIXELS(ptr->leftMargin()));
+               else ret.set_null();
        }
        else // setter
        {
                ptr->leftMarginSet(PIXELS_TO_TWIPS(fn.arg(0).to_int()));
        }
 
-       return as_value();
+       return ret;
 }
 
 as_value
@@ -184,16 +198,19 @@
 {
        boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
 
+       as_value ret;
+
        if ( fn.nargs == 0 ) // getter
        {
-               return as_value(ptr->getAlignString(ptr->align()));
+               if ( ptr->alignDefined() ) 
ret.set_string(ptr->getAlignString(ptr->align()));
+               else ret.set_null();
        }
        else // setter
        {
                ptr->alignSet(fn.arg(0).to_string());
        }
 
-       return as_value();
+       return ret;
 }
 
 as_value
@@ -208,16 +225,19 @@
 {
        boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
 
+       as_value ret;
+
        if ( fn.nargs == 0 ) // getter
        {
-               return as_value(ptr->italiced());
+               if ( ptr->italicedDefined() ) ret.set_bool(ptr->italiced());
+               else ret.set_null();
        }
        else // setter
        {
                ptr->italicedSet(fn.arg(0).to_bool());
        }
 
-       return as_value();
+       return ret;
 }
 
 as_value
@@ -225,16 +245,19 @@
 {
        boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
 
+       as_value ret;
+
        if ( fn.nargs == 0 ) // getter
        {
-               return as_value(ptr->bold());
+               if ( ptr->boldDefined() ) ret.set_bool(ptr->bold());
+               else ret.set_null();
        }
        else // setter
        {
                ptr->boldSet(fn.arg(0).to_bool());
        }
 
-       return as_value();
+       return ret;
 }
 
 as_value
@@ -256,9 +279,12 @@
 {
        boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
 
+       as_value ret;
+
        if ( fn.nargs == 0 ) // getter
        {
-               return as_value(ptr->color().toRGB());
+               if ( ptr->colorDefined() )  
ret.set_double(ptr->color().toRGB());
+               else ret.set_null();
        }
        else // setter
        {
@@ -267,7 +293,7 @@
                ptr->colorSet(newcolor);
        }
 
-       return as_value();
+       return ret;
 }
 
 as_value
@@ -275,16 +301,19 @@
 {
        boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
 
+       as_value ret;
+
        if ( fn.nargs == 0 ) // getter
        {
-               return as_value(TWIPS_TO_PIXELS(ptr->size()));
+               if ( ptr->sizeDefined() ) 
ret.set_double(TWIPS_TO_PIXELS(ptr->size()));
+               else ret.set_null();
        }
        else // setter
        {
                ptr->sizeSet(PIXELS_TO_TWIPS(fn.arg(0).to_int()));
        }
 
-       return as_value();
+       return ret;
 }
 
 as_value
@@ -292,16 +321,19 @@
 {
        boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
 
+       as_value ret;
+
        if ( fn.nargs == 0 ) // getter
        {
-               return as_value(ptr->font());
+               if ( ptr->fontDefined() ) ret.set_string(ptr->font());
+               else ret.set_null();
        }
        else // setter
        {
                ptr->fontSet(fn.arg(0).to_string());
        }
 
-       return as_value();
+       return ret;
 }
 
 as_value

Index: server/asobj/TextFormat.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/TextFormat.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- server/asobj/TextFormat.h   10 Apr 2008 10:13:30 -0000      1.7
+++ server/asobj/TextFormat.h   10 Apr 2008 15:33:19 -0000      1.8
@@ -42,88 +42,96 @@
        ~TextFormat() {}
 
        /// Return a Boolean value that indicates whether the text is 
underlined.
-       bool underlined()  { return _underline; }
+       bool underlined() const { return _underline; }
+       bool underlinedDefined() const { return _flags&DEFunderline; }
 
        /// Return a Boolean value that indicates whether the text is 
italicized.
-       bool italiced()    { return _italic; }
+       bool italiced() const { return _italic; }
+       bool italicedDefined() const { return _flags&DEFitalic; }
 
        /// Return a Boolean value that indicates whether the text is boldface.
-       bool bold()        { return _bold; }
+       bool bold() const { return _bold; }
+       bool boldDefined() const { return _flags&DEFbold; }
 
-       bool bullet()      { return _bullet; }
+       bool bullet() const { return _bullet; }
+       bool bulletDefined() const { return _flags&DEFbullet; }
 
        /// Return the color of text using this text format.
        const rgba& color() const { return _color; }
+       bool colorDefined() const { return _flags&DEFcolor; }
 
        /// \brief
        /// Return ann integer that indicates the indentation from the left
         /// margin to the first character in the paragraph
        boost::uint16_t indent() const { return _indent; }
+       bool indentDefined() const { return _flags&DEFindent; }
 
-       /// Return the alignment of the paragraph, represented as a string.
-       //
-       /// If "left", the paragraph is left-aligned. If "center", the
-       /// paragraph is centered. If "right", the paragraph is
-       /// right-aligned.
-       ///
-       /// FIXME: use an enum !
-       ///
+       /// Return the alignment of the paragraph.
        edit_text_character_def::alignment align() const { return _align; }
+       bool alignDefined() const { return _flags&DEFalign; }
 
        /// Return the name of a font for text as a string.
        const std::string& font() const { return _font; }
+       bool fontDefined() const { return _flags&DEFfont; }
 
        // See doc for _target member
        const std::string& target() const { return _target; }
+       bool targetDefined() const { return _flags&DEFtarget; }
 
        // See doc for _target member
-       void targetSet(const std::string& s) { _target=s; }
+       void targetSet(const std::string& s) { _target=s; _flags |= DEFtarget; }
 
        // See doc for _url member
        const std::string& url() const { return _url; }
+       bool urlDefined() const { return _flags&DEFurl; }
 
        // See doc for _url member
-       void urlSet(const std::string& s) { _url=s; }
+       void urlSet(const std::string& s) { _url=s; _flags |= DEFurl; }
 
        ///
-       boost::uint16_t blockIndent() { return _block_indent; }
+       boost::uint16_t blockIndent() { return _blockIndent; }
+       bool blockIndentDefined() const { return _flags&DEFblockIndent; }
 
        /// Return a number that indicates the amount of leading vertical
        /// space between lines.
        boost::uint16_t leading()     { return _leading; }
+       bool leadingDefined() const { return _flags&DEFleading; }
 
        /// Indicates the left margin of the paragraph, in points.
-       boost::uint16_t leftMargin()  { return _left_margin; }
+       boost::uint16_t leftMargin()  { return _leftMargin; }
+       bool leftMarginDefined() const { return _flags&DEFleftMargin; }
 
        /// Indicates the right margin of the paragraph, in points.
-       boost::uint16_t rightMargin() { return _right_margin; }
+       boost::uint16_t rightMargin() { return _rightMargin; }
+       bool rightMarginDefined() const { return _flags&DEFrightMargin; }
 
        /// Return a float that indicates the point size in twips.
-       boost::uint16_t size()        { return _point_size; }
-
-       void underlinedSet(bool x)   { _underline = x; }
-       void italicedSet(bool x)     { _italic = x; }
-       void boldSet(bool x)         { _bold = x; }
-       void bulletSet(bool x)       { _bullet = x; }
-       void colorSet(const rgba& x)      { _color = x; }
-       void indentSet(boost::uint16_t x)      { _indent = x; }
-       void fontSet(const std::string& font) { _font=font; }
+       boost::uint16_t size()        { return _pointSize; }
+       bool sizeDefined() const { return _flags&DEFsize; }
 
-       void alignSet(edit_text_character_def::alignment x)  { _align = x; }
+       void underlinedSet(bool x)   { _underline = x; _flags |= DEFunderline; }
+       void italicedSet(bool x)     { _italic = x; _flags |= DEFitalic; }
+       void boldSet(bool x)         { _bold = x; _flags |= DEFbold; }
+       void bulletSet(bool x)       { _bullet = x; _flags |= DEFbullet; }
+       void colorSet(const rgba& x)      { _color = x; _flags |= DEFcolor; }
+       void indentSet(boost::uint16_t x)      { _indent = x; _flags |= 
DEFindent; }
+       void fontSet(const std::string& font) { _font=font; _flags |= DEFfont; }
+       void alignSet(edit_text_character_def::alignment x)  { _align = x; 
_flags |= DEFalign; }
 
        static edit_text_character_def::alignment parseAlignString(const 
std::string& align);
 
+       /// Return the text representation of alignment value.
        static const char* getAlignString(edit_text_character_def::alignment a);
 
        void alignSet(const std::string& align) { 
alignSet(parseAlignString(align)); }
 
-       void blockIndentSet(boost::uint16_t x)   { _block_indent = x; }
-       void leadingSet(boost::uint16_t x)     { _leading = x; }
-       void leftMarginSet(boost::uint16_t x)  { _left_margin = x; }
-       void rightMarginSet(boost::uint16_t x) { _right_margin = x; }
+       void blockIndentSet(boost::uint16_t x)   { _blockIndent = x; _flags |= 
DEFblockIndent; }
+       void leadingSet(boost::uint16_t x)     { _leading = x; _flags |= 
DEFleading; }
+       void leftMarginSet(boost::uint16_t x)  { _leftMargin = x; _flags |= 
DEFleftMargin; }
+       void rightMarginSet(boost::uint16_t x) { _rightMargin = x; _flags |= 
DEFrightMargin; }
 
        /// Set font point size in twips
-       void sizeSet(boost::uint16_t x)        { _point_size = x; }
+       void sizeSet(boost::uint16_t x)        { _pointSize = x; _flags |= 
DEFsize; }
 
        static as_value display_getset(const fn_call& fn);
        static as_value bullet_getset(const fn_call& fn);
@@ -147,6 +155,27 @@
   
 private:
 
+        enum {
+               DEFunderline    =1<<0,
+               DEFbold         =1<<1,
+               DEFitalic       =1<<2,
+               DEFbullet       =1<<3,
+               DEFalign        =1<<4,
+               DEFblockIndent  =1<<5,
+               DEFcolor        =1<<6,
+               DEFfont         =1<<7,
+               DEFindent       =1<<8,
+               DEFleading      =1<<9,
+               DEFleftMargin   =1<<10,
+               DEFrightMargin  =1<<11,
+               DEFpointSize    =1<<12,
+               DEFtabStops     =1<<13,
+               DEFtarget       =1<<14,
+               DEFurl          =1<<15,
+               DEFsize         =1<<16
+       };
+
+       long int _flags; // need at least 17 bit here... (1<<16)
 
        /// A Boolean value that indicates whether the text is underlined.
        bool          _underline;
@@ -169,7 +198,7 @@
        edit_text_character_def::alignment _align;
 
        // 
-       boost::uint16_t         _block_indent;
+       boost::uint16_t         _blockIndent;
 
        /// The color of text using this text format.
        //
@@ -189,16 +218,16 @@
        boost::uint16_t _leading;
 
        /// Indicates the left margin of the paragraph, in points (twips)
-       boost::uint16_t _left_margin;
+       boost::uint16_t _leftMargin;
 
        /// Indicates the right margin of the paragraph, in points (twips).
-       boost::uint16_t _right_margin;
+       boost::uint16_t _rightMargin;
 
        /// Point size in twips.
-       boost::uint16_t _point_size;
+       boost::uint16_t _pointSize;
 
        ///
-       int _tab_stops;
+       int _tabStops;
 
        /// The target window where the hyperlink is displayed. 
         /// If the target window is an empty string, the text is displayed in
@@ -210,7 +239,6 @@
        /// The URL to which the text in this text format hyperlinks.
        /// If url is an empty string, the text does not have a hyperlink
        std::string      _url;  
-
 };
  
 

Index: testsuite/actionscript.all/TextFormat.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/TextFormat.as,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- testsuite/actionscript.all/TextFormat.as    9 Apr 2008 20:34:54 -0000       
1.1
+++ testsuite/actionscript.all/TextFormat.as    10 Apr 2008 15:33:19 -0000      
1.2
@@ -20,7 +20,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: TextFormat.as,v 1.1 2008/04/09 20:34:54 strk Exp $";
+rcsid="$Id: TextFormat.as,v 1.2 2008/04/10 15:33:19 strk Exp $";
 
 #include "check.as"
 
@@ -55,4 +55,53 @@
 check(tfObj.hasOwnProperty('getTextExtent'));
 
 
-check_totals(23);
+// When you construct a TextFormat w/out args all members
+// are of the 'null' type. In general, uninitialized members
+// are all of the 'null' type.
+xcheck_equals(typeof(tfObj.display), 'string');
+xcheck_equals(tfObj.display, 'block');
+xcheck_equals(typeof(tfObj.bullet), 'null');
+xcheck_equals(typeof(tfObj.tabStops), 'null');
+xcheck_equals(typeof(tfObj.blockIndent), 'null');
+check_equals(typeof(tfObj.leading), 'null');
+check_equals(typeof(tfObj.indent), 'null');
+check_equals(typeof(tfObj.rightMargin), 'null');
+check_equals(typeof(tfObj.leftMargin), 'null');
+check_equals(typeof(tfObj.align), 'null');
+xcheck_equals(typeof(tfObj.underline), 'null');
+check_equals(typeof(tfObj.italic), 'null');
+check_equals(typeof(tfObj.bold), 'null');
+xcheck_equals(typeof(tfObj.target), 'null');
+xcheck_equals(typeof(tfObj.url), 'null');
+check_equals(typeof(tfObj.color), 'null');
+check_equals(typeof(tfObj.size), 'null');
+check_equals(typeof(tfObj.font), 'null');
+check_equals(typeof(tfObj.getTextExtent), 'function');
+
+// new TextFormat([font, [size, [color, [bold, [italic, [underline, [url, 
[target, [align,[leftMargin, [rightMargin, [indent, [leading]]]]]]]]]]]]])
+tfObj = new TextFormat("fname", 2, 30, true, false, true, 'http', 'tgt', 
'cEnter', '23', '32', 12, 4);
+xcheck_equals(typeof(tfObj.display), 'string');
+xcheck_equals(tfObj.display, 'block');
+xcheck_equals(typeof(tfObj.bullet), 'null');
+xcheck_equals(typeof(tfObj.tabStops), 'null');
+xcheck_equals(typeof(tfObj.blockIndent), 'null');
+check_equals(tfObj.leading, 4);
+check_equals(tfObj.indent, 12);
+check_equals(typeof(tfObj.rightMargin), 'number'); // even if we passed a 
string to it
+check_equals(tfObj.rightMargin, 32);
+check_equals(typeof(tfObj.leftMargin), 'number'); // even if we passed a 
string to it
+check_equals(tfObj.leftMargin, 23);
+check_equals(tfObj.align, 'center');
+xcheck_equals(tfObj.target, 'tgt');
+xcheck_equals(tfObj.url, 'http');
+xcheck_equals(tfObj.underline, true);
+check_equals(typeof(tfObj.italic), 'boolean');
+check_equals(tfObj.italic, false);
+check_equals(tfObj.bold, true);
+check_equals(tfObj.color, 30);
+check_equals(tfObj.size, 2);
+check_equals(tfObj.font, 'fname');
+
+
+
+check_totals(63);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]