[Top][All Lists]
[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: |
Mon, 13 Aug 2007 03:26:10 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/08/13 03:26:10
Modified files:
. : ChangeLog
server : edit_text_character.cpp edit_text_character.h
testsuite/actionscript.all: TextField.as
testsuite/misc-ming.all: DefineEditTextTest.c
Log message:
* server/edit_text_character.{cpp,h}: add autoSize getter/setter
(still not used)
* testsuite/actionscript.all/TextField.as: add tests for
autoSize
member.
* testsuite/misc-ming.all/DefineEditTextTest.c: add TODO items.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3998&r2=1.3999
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.96&r2=1.97
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.h?cvsroot=gnash&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/TextField.as?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/DefineEditTextTest.c?cvsroot=gnash&r1=1.25&r2=1.26
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3998
retrieving revision 1.3999
diff -u -b -r1.3998 -r1.3999
--- ChangeLog 13 Aug 2007 02:47:57 -0000 1.3998
+++ ChangeLog 13 Aug 2007 03:26:09 -0000 1.3999
@@ -1,6 +1,14 @@
2007-08-12 Sandro Santilli <address@hidden>
+ * server/edit_text_character.{cpp,h}: add autoSize getter/setter
+ (still not used)
+ * testsuite/actionscript.all/TextField.as: add tests for autoSize
+ member.
+ * testsuite/misc-ming.all/DefineEditTextTest.c: add TODO items.
* server/as_value.h: add is_bool()
+
+2007-08-12 Sandro Santilli <address@hidden>
+
* server/edit_text_character.h (getBounds): add TODO item
(I belive is a fix for bug #20760)
Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -b -r1.96 -r1.97
--- server/edit_text_character.cpp 2 Aug 2007 21:23:42 -0000 1.96
+++ server/edit_text_character.cpp 13 Aug 2007 03:26:09 -0000 1.97
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: edit_text_character.cpp,v 1.96 2007/08/02 21:23:42 strk Exp $ */
+/* $Id: edit_text_character.cpp,v 1.97 2007/08/13 03:26:09 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -81,6 +81,7 @@
static as_value textfield_borderColor_getset(const fn_call& fn);
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);
//
@@ -326,6 +327,8 @@
o.init_property("textColor", *getset, *getset);
getset = new builtin_function(textfield_embedFonts_getset);
o.init_property("embedFonts", *getset, *getset);
+ getset = new builtin_function(textfield_autoSize_getset);
+ o.init_property("autoSize", *getset, *getset);
if ( target_version < 7 ) return;
@@ -389,7 +392,8 @@
_drawBorder(m_def->has_border()),
_borderColor(0,0,0,255),
_textColor(m_def->get_text_color()),
- _embedFonts(m_def->getUseEmbeddedGlyphs())
+ _embedFonts(m_def->getUseEmbeddedGlyphs()),
+ _autoSize(autoSizeNone)
{
assert(parent);
assert(m_def);
@@ -1148,6 +1152,11 @@
// Whoops, we just exceeded the box width.
// Do word-wrap if requested to do so.
+ // TODO: don't query the definition about wordWrap,
+ // we should have a wordWrap getter/setter
instead !
+ // Also, we should check autoSize (getAutoSize)
and
+ // behave accordingly
+ //
if ( ! m_def->do_word_wrap() )
{
bool newlinefound = false;
@@ -1590,6 +1599,98 @@
return as_value();
}
+static as_value
+textfield_autoSize_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->autoSizeValueName(ptr->getAutoSize());
+ }
+ else // setter
+ {
+ as_value& arg = fn.arg(0);
+ if ( arg.is_bool() )
+ {
+ if ( arg.to_bool() ) // true == left
+ {
+ ptr->setAutoSize(
edit_text_character::autoSizeLeft );
+ }
+ else
+ {
+ ptr->setAutoSize(
edit_text_character::autoSizeNone );
+ }
+ }
+ else
+ {
+ std::string strval = arg.to_string(&(fn.env()));
+ edit_text_character::AutoSizeValue val =
ptr->parseAutoSizeValue(strval);
+ log_debug("%s => %d", strval.c_str(), val);
+ ptr->setAutoSize( val );
+ }
+ }
+
+ return as_value();
+}
+
+/* public static */
+edit_text_character::AutoSizeValue
+edit_text_character::parseAutoSizeValue(const string& val)
+{
+ if ( val == "left" )
+ {
+ return autoSizeLeft;
+ }
+ if ( val == "right" )
+ {
+ return autoSizeRight;
+ }
+ if ( val == "center" )
+ {
+ return autoSizeCenter;
+ }
+ return autoSizeNone;
+
+}
+
+/* public static */
+const char*
+edit_text_character::autoSizeValueName(AutoSizeValue val)
+{
+ switch (val)
+ {
+ case autoSizeLeft:
+ return "left";
+ case autoSizeRight:
+ return "right";
+ case autoSizeCenter:
+ return "center";
+ case autoSizeNone:
+ default:
+ return "none";
+ }
+
+}
+
+void
+edit_text_character::setAutoSize(AutoSizeValue val)
+{
+ if ( val == _autoSize ) return;
+
+ static bool warned = false;
+ if ( ! warned ) {
+ log_unimpl(_("TextField.autoSize unused"));
+ warned = true;
+ }
+
+
+ set_invalidated();
+
+ _autoSize = val;
+ format_text();
+}
+
} // namespace gnash
Index: server/edit_text_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- server/edit_text_character.h 12 Aug 2007 23:38:56 -0000 1.43
+++ server/edit_text_character.h 13 Aug 2007 03:26:09 -0000 1.44
@@ -46,6 +46,22 @@
public:
+ /// Possible autoSize values
+ enum AutoSizeValue {
+
+ /// Do not automatically resize TextField as text grow/shrink
+ autoSizeNone,
+
+ /// Expand TextField, anchor the top-left side
+ autoSizeLeft,
+
+ /// Expand TextField, anchor the horizontal center
+ autoSizeCenter,
+
+ /// Expand TextField, anchor the top-right side
+ autoSizeRight
+ };
+
edit_text_character(
character* parent,
edit_text_character_def* def,
@@ -162,6 +178,38 @@
/// @param use
void setEmbedFonts(bool use);
+ /// Get autoSize value
+ AutoSizeValue getAutoSize() const
+ {
+ return _autoSize;
+ }
+
+ /// Set autoSize value
+ //
+ /// @param val
+ /// The AutoSizeValue to use
+ ///
+ void setAutoSize(AutoSizeValue val);
+
+ /// Parse autoSize string value
+ //
+ /// @param val
+ /// Auto size value as a string (one of none, left, center, right)
+ ///
+ /// @return an AutoSizeValue identifier. autoSizeNone if invalid
+ ///
+ static AutoSizeValue parseAutoSizeValue(const string& val);
+
+ /// Return autoSize value as a string
+ //
+ /// @param val
+ /// Auto size value
+ ///
+ /// @return a C-string representation of the autoSize value.
+ /// The returns is *never* NULL.
+ ///
+ static const char* autoSizeValueName(AutoSizeValue val);
+
private:
/// Return true if HTML text is allowed
@@ -269,6 +317,8 @@
bool _embedFonts;
+ AutoSizeValue _autoSize;
+
protected:
#ifdef GNASH_USE_GC
Index: testsuite/actionscript.all/TextField.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/TextField.as,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- testsuite/actionscript.all/TextField.as 30 Jul 2007 18:38:15 -0000
1.13
+++ testsuite/actionscript.all/TextField.as 13 Aug 2007 03:26:10 -0000
1.14
@@ -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.13 2007/07/30 18:38:15 strk Exp $";
+rcsid="$Id: TextField.as,v 1.14 2007/08/13 03:26:10 strk Exp $";
#include "check.as"
@@ -40,7 +40,7 @@
// NOTE: the following will be true after a call to createTextField ! Seek
forward to see..
xcheck( !TextField.prototype.hasOwnProperty('background'));
xcheck( !TextField.prototype.hasOwnProperty('backgroundColor'));
-check( !TextField.prototype.hasOwnProperty('autoSize') );
+xcheck( !TextField.prototype.hasOwnProperty('autoSize') );
xcheck( !TextField.prototype.hasOwnProperty('border') );
xcheck( !TextField.prototype.hasOwnProperty('borderColor') );
check( !TextField.prototype.hasOwnProperty('bottomScroll') );
@@ -109,7 +109,7 @@
// NOTE: the following were false before the call to createTextField ! Seek
backward to see..
check( TextField.prototype.hasOwnProperty('background'));
check( TextField.prototype.hasOwnProperty('backgroundColor'));
-xcheck( TextField.prototype.hasOwnProperty('autoSize') );
+check( TextField.prototype.hasOwnProperty('autoSize') );
check( TextField.prototype.hasOwnProperty('border') );
check( TextField.prototype.hasOwnProperty('borderColor') );
xcheck( TextField.prototype.hasOwnProperty('bottomScroll') );
@@ -142,9 +142,28 @@
// Check TextField.autoSize
-xcheck_equals(typeof(tf.autoSize), 'string');
-xcheck_equals(tf.autoSize, 'none'); // TODO: research which valid values we
have
+check_equals(typeof(tf.autoSize), 'string');
+check_equals(tf.autoSize, 'none'); // TODO: research which valid values we have
check(! tf.hasOwnProperty('autoSize'));
+tf.autoSize = false;
+check_equals(tf.autoSize, 'none'); // false is a synonim for 'none'
+tf.autoSize = true;
+check_equals(tf.autoSize, 'left'); // true is a synonim for 'left'
+tf.autoSize = 'true';
+check_equals(tf.autoSize, 'none'); // 'true' (as a string) is invalid, thus
equivalent to 'none'
+tf.autoSize = 'center';
+check_equals(tf.autoSize, 'center'); // 'center' is a valid value
+tf.autoSize = 'right';
+check_equals(tf.autoSize, 'right'); // 'right' is a valid value
+o = new Object(); o.toString = function() { return 'center'; };
+tf.autoSize = o;
+check_equals(tf.autoSize, 'center'); // toString is called for object args
+tf.autoSize = 'lEft';
+xcheck_equals(tf.autoSize, 'left'); // arg is not case sensitive
+tf.autoSize = new Boolean(true);
+check_equals(tf.autoSize, 'none'); // a Boolean is the same as any other object
+
+tf.autoSize = 'none';
// Check TextField.background
Index: testsuite/misc-ming.all/DefineEditTextTest.c
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/DefineEditTextTest.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- testsuite/misc-ming.all/DefineEditTextTest.c 9 Aug 2007 08:46:44
-0000 1.25
+++ testsuite/misc-ming.all/DefineEditTextTest.c 13 Aug 2007 03:26:10
-0000 1.26
@@ -24,6 +24,7 @@
* Text at the bottom is the one with embedded fonts.
*
* TODO: add a testrunner for pixel checking.
+ * TODO: test autoSize and wordWrap interaction (what takes precedence?)
*
* run as ./DefineEditTextTest
*/