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, 07 Feb 2008 18:48:04 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/02/07 18:48:03

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

Log message:
        Add support for TextField.type 

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5587&r2=1.5588
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.149&r2=1.150
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.h?cvsroot=gnash&r1=1.66&r2=1.67
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/TextField.as?cvsroot=gnash&r1=1.44&r2=1.45

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5587
retrieving revision 1.5588
diff -u -b -r1.5587 -r1.5588
--- ChangeLog   7 Feb 2008 16:15:32 -0000       1.5587
+++ ChangeLog   7 Feb 2008 18:48:02 -0000       1.5588
@@ -1,3 +1,10 @@
+2008-02-07 Sandro Santilli <address@hidden>
+
+       * server/edit_text_character.{cpp,h}: add support for
+         TextField.type
+       * testsuite/actionscript.all/TextField.as: additional test
+         for TextField.type, fix a test for textWidth.
+
 2008-02-07 Benjamin Wolsey <address@hidden>
 
        * libbase/utf8.h: document utf8 code.

Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -b -r1.149 -r1.150
--- server/edit_text_character.cpp      7 Feb 2008 16:15:34 -0000       1.149
+++ server/edit_text_character.cpp      7 Feb 2008 18:48:03 -0000       1.150
@@ -38,6 +38,7 @@
 #include "namedStrings.h"
 #include "array.h" // for _listeners construction
 #include "AsBroadcaster.h" // for initializing self as a broadcaster
+#include "StringPredicates.h"
 
 #include <algorithm>
 #include <string>
@@ -82,6 +83,7 @@
 static as_value textfield_textColor_getset(const fn_call& fn);
 static as_value textfield_embedFonts_getset(const fn_call& fn);
 static as_value textfield_autoSize_getset(const fn_call& fn);
+static as_value textfield_type_getset(const fn_call& fn);
 static as_value textfield_wordWrap_getset(const fn_call& fn);
 static as_value textfield_html_getset(const fn_call& fn);
 static as_value textfield_selectable_getset(const fn_call& fn);
@@ -304,6 +306,8 @@
        o.init_property("embedFonts", *getset, *getset);
        getset = new builtin_function(textfield_autoSize_getset);
        o.init_property("autoSize", *getset, *getset);
+       getset = new builtin_function(textfield_type_getset);
+       o.init_property("type", *getset, *getset);
        getset = new builtin_function(textfield_wordWrap_getset);
        o.init_property("wordWrap", *getset, *getset);
        getset = new builtin_function(textfield_html_getset);
@@ -390,6 +394,7 @@
        _html(m_def->htmlAllowed()),
        _selectable(!m_def->get_no_select()),
        _autoSize(autoSizeNone),
+       _type(typeDynamic),
        _bounds(m_def->get_bounds().getRange())
 {
        assert(parent);
@@ -592,6 +597,7 @@
 
                case event_id::KEY_PRESS:
                {
+                       if ( getType() != typeInput ) break; // not an input 
field
                        std::wstring s = _text;
 
                        // id.keyCode is the unique gnash::key::code for a 
character/key.
@@ -2033,6 +2039,31 @@
        return as_value();
 }
 
+static as_value
+textfield_type_getset(const fn_call& fn)
+{
+       boost::intrusive_ptr<edit_text_character> ptr = 
ensureType<edit_text_character>(fn.this_ptr);
+
+       if ( fn.nargs == 0 ) // getter
+       {
+               return ptr->typeValueName(ptr->getType());
+       }
+
+       // setter
+       as_value& arg = fn.arg(0);
+       std::string strval = arg.to_string();
+       edit_text_character::TypeValue val = ptr->parseTypeValue(strval);
+       //log_debug("%s (toString->%s) => %d", arg.to_debug_string().c_str(), 
strval.c_str(), val);
+       IF_VERBOSE_ASCODING_ERRORS(
+       if ( val == edit_text_character::typeInvalid )
+       {
+               log_aserror(_("Invalid value given to TextField.type: %s"), 
strval.c_str());
+       }
+       );
+       ptr->setType(val);
+       return as_value();
+}
+
 /* public static */
 edit_text_character::AutoSizeValue
 edit_text_character::parseAutoSizeValue(const std::string& val)
@@ -2072,6 +2103,46 @@
 
 }
 
+/* public static */
+edit_text_character::TypeValue
+edit_text_character::parseTypeValue(const std::string& val)
+{
+       StringNoCaseLessThen cmp;
+
+       if ( ! cmp(val, "input") )
+       {
+               //log_debug("parsing type value %s: typeInput", val.c_str());
+               return typeInput;
+       }
+       if ( ! cmp(val, "dynamic") )
+       {
+               //log_debug("parsing type value %s: typeDynamic", val.c_str());
+               return typeDynamic;
+       }
+       //log_debug("parsing type value %s: typeInvalid", val.c_str());
+       return typeInvalid;
+
+}
+
+/* public static */
+const char*
+edit_text_character::typeValueName(TypeValue val)
+{
+       switch (val)
+       {
+               case typeInput:
+                       //log_debug("typeInput returned as 'input'");
+                       return "input";
+               case typeDynamic:
+                       //log_debug("typeDynamic returned as 'dynamic'");
+                       return "dynamic";
+               default:
+                       //log_debug("invalid type %d returned as 'invalid'", 
(int)val);
+                       return "invalid";
+       }
+
+}
+
 void
 edit_text_character::setAutoSize(AutoSizeValue val)
 {

Index: server/edit_text_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.h,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- server/edit_text_character.h        5 Feb 2008 12:01:51 -0000       1.66
+++ server/edit_text_character.h        7 Feb 2008 18:48:03 -0000       1.67
@@ -58,6 +58,20 @@
                autoSizeRight
        };
 
+       /// Possible type values
+       enum TypeValue {
+
+               /// Invalid value
+               typeInvalid,
+
+               /// Do not accept input, text is only changed by variable name
+               /// or assigning to the .text member
+               typeDynamic,
+
+               /// Accept user input
+               typeInput
+       };
+
        edit_text_character(
                        character* parent,
                        edit_text_character_def* def,
@@ -215,6 +229,38 @@
        ///
        static const char* autoSizeValueName(AutoSizeValue val);
 
+       /// Set type (input or dynamic)
+       //
+       /// @param val
+       ///     The TypeValue to use, no-op if typeInvalid.
+       ///
+       void setType(TypeValue val) { if (val != typeInvalid) _type=val; }
+
+       /// Get type (input, dynamic or invalid)
+       TypeValue getType() const
+       {
+               return _type;
+       }
+
+       /// Parse type string value
+       //
+       /// @param val
+       ///     Type value as a string (one of input or dynamic)
+       ///
+       /// @return an TypeValue identifier. typeInvalid if invalid.
+       ///
+       static TypeValue parseTypeValue(const std::string& val);
+
+       /// Return type value as a string
+       //
+       /// @param val
+       ///     Type value  (enum)
+       ///
+       /// @return a C-string representation of the type value.
+       ///     The returns is *never* NULL.
+       ///
+       static const char* typeValueName(TypeValue val);
+
        /// \brief
        /// Return true if text should continue to next available line
        /// when hitting end of bounding box.
@@ -421,6 +467,8 @@
 
        AutoSizeValue _autoSize;
 
+       TypeValue _type;
+
        /// Area in which the text is drawn. 
        //
        /// This area encloses all the text, can be automatically

Index: testsuite/actionscript.all/TextField.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/TextField.as,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- testsuite/actionscript.all/TextField.as     2 Feb 2008 10:58:11 -0000       
1.44
+++ testsuite/actionscript.all/TextField.as     7 Feb 2008 18:48:03 -0000       
1.45
@@ -19,7 +19,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: TextField.as,v 1.44 2008/02/02 10:58:11 strk Exp $";
+rcsid="$Id: TextField.as,v 1.45 2008/02/07 18:48:03 strk Exp $";
 
 #include "check.as"
 
@@ -71,7 +71,7 @@
 xcheck( !TextField.prototype.hasOwnProperty('textColor') );
 check( !TextField.prototype.hasOwnProperty('textHeight') );
 check( !TextField.prototype.hasOwnProperty('textWidth') );
-check( !TextField.prototype.hasOwnProperty('type') );
+xcheck( !TextField.prototype.hasOwnProperty('type') ); // should be available 
on first instantiation
 xcheck( !TextField.prototype.hasOwnProperty('variable') );
 xcheck( !TextField.prototype.hasOwnProperty('wordWrap') );
 
@@ -146,7 +146,7 @@
 check( TextField.prototype.hasOwnProperty('textColor') );
 xcheck( TextField.prototype.hasOwnProperty('textHeight') );
 xcheck( TextField.prototype.hasOwnProperty('textWidth') );
-xcheck( TextField.prototype.hasOwnProperty('type') );
+check( TextField.prototype.hasOwnProperty('type') );
 check( TextField.prototype.hasOwnProperty('variable') );
 check( TextField.prototype.hasOwnProperty('wordWrap') );
 
@@ -524,18 +524,21 @@
 
 // Check TextField.type (input or dynamic)
 
-xcheck_equals(typeof(tf.type), 'string');
+check_equals(typeof(tf.type), 'string');
 check( ! tf.hasOwnProperty('type') ); 
-xcheck_equals(tf.type, 'dynamic'); 
+check_equals(tf.type, 'dynamic'); 
 tf.type = "input";
 check_equals(tf.type, 'input'); 
 tf.type = new Array();
-xcheck_equals(typeof(tf.type), 'string');  // invalid assignment
-xcheck_equals(tf.type, 'input');  // keeps previous value
+check_equals(typeof(tf.type), 'string');  // invalid assignment
+check_equals(tf.type, 'input');  // keeps previous value
 tf.type = "dynamic";
 check_equals(tf.type, 'dynamic');  
 tf.type = new Array();
-xcheck_equals(tf.type, 'dynamic'); // keeps previous value 
+check_equals(tf.type, 'dynamic'); // keeps previous value 
+o = {}; o.toString = function() { return 'Input'; };
+tf.type = o;
+check_equals(tf.type, 'input');
 
 // Check TextField._url (url of the SWF that created the textfield)
 
@@ -759,7 +762,8 @@
 check_equals(tf.textWidth, origTextWidth); // textWidth isn't influenced by 
autoSize 
 tf.autoSize = 'none';
 tf.wordWrap = true;
-xcheck(tf.textWidth < origTextWidth);  // this can fail depending on the font 
used !
+note("textWidth: "+tf.textWidth+" origTextWidth:"+origTextWidth);
+check_equals(tf.textWidth, origTextWidth);  
 tf._width = 10;
 check_equals(tf._width, 10);
 
@@ -823,9 +827,9 @@
 
 
 #if OUTPUT_VERSION < 8
- check_totals(391);
-#else
  check_totals(392);
+#else
+ check_totals(393);
 #endif
 
 #else // OUTPUT_VERSION <= 5




reply via email to

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