[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 Nov 2006 14:11:30 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/11/13 14:11:30
Modified files:
. : ChangeLog
server : edit_text_character.cpp edit_text_character.h
testsuite/misc-ming.all: Makefile.am
Added files:
testsuite : generic-testrunner.sh
Log message:
* server/edit_text_character.{h,cpp}: added primitive support
for VariableName targets referring to yet-to-be-instantiated
characters.
* testsuite/generic-testrunner.sh: new file to generate runners
for self-contained SWF testfiles.
* testsuite/misc-ming.all/Makefile.am: run
DefineEditTextVariableName
test again (uses the generic-testrunner.sh file)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1604&r2=1.1605
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.h?cvsroot=gnash&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/generic-testrunner.sh?cvsroot=gnash&rev=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/Makefile.am?cvsroot=gnash&r1=1.29&r2=1.30
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1604
retrieving revision 1.1605
diff -u -b -r1.1604 -r1.1605
--- ChangeLog 13 Nov 2006 14:08:48 -0000 1.1604
+++ ChangeLog 13 Nov 2006 14:11:29 -0000 1.1605
@@ -1,5 +1,15 @@
2006-11-13 Sandro Santilli <address@hidden>
+ * server/edit_text_character.{h,cpp}: added primitive support
+ for VariableName targets referring to yet-to-be-instantiated
+ characters.
+ * testsuite/generic-testrunner.sh: new file to generate runners
+ for self-contained SWF testfiles.
+ * testsuite/misc-ming.all/Makefile.am: run DefineEditTextVariableName
+ test again (uses the generic-testrunner.sh file)
+
+2006-11-13 Sandro Santilli <address@hidden>
+
* testsuite/simple.exp: check for XPASSED before PASSED.
* testsuite/misc-ming.all/DefineEditTextVariableNameTest.c:
make the DefineEditTextVariableNameTest.swf file a self-contained
Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- server/edit_text_character.cpp 13 Nov 2006 09:06:50 -0000 1.26
+++ server/edit_text_character.cpp 13 Nov 2006 14:11:30 -0000 1.27
@@ -3,7 +3,7 @@
// This source code has been donated to the Public Domain. Do
// whatever you want with it.
-/* $Id: edit_text_character.cpp,v 1.26 2006/11/13 09:06:50 strk Exp $ */
+/* $Id: edit_text_character.cpp,v 1.27 2006/11/13 14:11:30 strk Exp $ */
#include "utf8.h"
#include "log.h"
@@ -29,7 +29,8 @@
m_has_focus(false),
m_cursor(0),
m_xcursor(0.0f),
- m_ycursor(0.0f)
+ m_ycursor(0.0f),
+ _text_variable_registered(false)
{
assert(parent);
assert(m_def);
@@ -44,22 +45,14 @@
m_dummy_style.push_back(fill_style());
- //
- // If this EditText definition contained a VariableName
- // member, handle it by adding the textfield_variable
- // to the appropriate sprite
- //
- const std::string& varname = m_def->get_variable_name();
- if ( ! varname.empty() )
- {
- registerTextVariable(varname);
- }
+ registerTextVariable();
reset_bounding_box(0, 0);
}
edit_text_character::~edit_text_character()
{
+ // TODO: unregisterTextVariable() ?
on_event(event_id::KILLFOCUS);
}
@@ -86,6 +79,8 @@
{
// GNASH_REPORT_FUNCTION;
+ registerTextVariable();
+
if (m_def->has_border())
{
matrix mat = get_world_matrix();
@@ -319,6 +314,20 @@
}
+const char*
+edit_text_character::get_text_value() const
+{
+ // we need the const_cast here because registerTextVariable
+ // *might* change our text value, calling the non-const
+ // set_text_value().
+ // This happens if the TextVariable has not been already registered
+ // and during registration comes out to name an existing variable
+ // with a pre-existing value.
+ const_cast<edit_text_character*>(this)->registerTextVariable();
+
+ return _text.c_str();
+}
+
void
edit_text_character::set_member(const tu_stringi& name,
const as_value& val)
@@ -822,14 +831,31 @@
}
void
-edit_text_character::registerTextVariable(const std::string& var_str)
+edit_text_character::registerTextVariable()
{
//#define DEBUG_DYNTEXT_VARIABLES 1
- assert ( ! var_str.empty() );
+
+ if ( _text_variable_registered ) {
+#ifdef DEBUG_DYNTEXT_VARIABLES
+ log_msg(" registerTextVariable() no-op call (alread registered)");
+#endif
+ return;
+ }
+
+ const std::string& var_str = m_def->get_variable_name();
+
+ if ( var_str.empty() )
+ {
+#ifdef DEBUG_DYNTEXT_VARIABLES
+ log_msg(" string is empty, consider as registered");
+#endif
+ _text_variable_registered=true;
+ return;
+ }
const char* varname = var_str.c_str();
#ifdef DEBUG_DYNTEXT_VARIABLES
- log_msg("registerTextVariable(%s) called", varname);
+ log_msg(" VariableName: %s", var_str.c_str());
#endif
as_environment& env = get_environment();
@@ -886,6 +912,7 @@
// add the textfield variable to the target sprite
sprite->set_textfield_variable(varname, this);
+ _text_variable_registered=true;
}
float
Index: server/edit_text_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- server/edit_text_character.h 3 Nov 2006 14:03:37 -0000 1.16
+++ server/edit_text_character.h 13 Nov 2006 14:11:30 -0000 1.17
@@ -63,10 +63,8 @@
/// Set our text to the given string.
virtual void set_text_value(const char* new_text);
- virtual const char* get_text_value() const
- {
- return _text.c_str();
- }
+ /// Return value of our text.
+ virtual const char* get_text_value() const;
/// We have a "text" member.
void set_member(const tu_stringi& name, const as_value& val);
@@ -140,12 +138,22 @@
/// If the given variable already exist use it to set
/// current text before overriding it.
///
- /// @param varname
- /// Name of the variable. Can contain path information,
- /// in that case the path is resolved relative to this
- /// character's parent.
+ /// Since the variable target may be undefined at time
+ /// of instantiation of this EditText character, the
+ /// class keeps track of wheter it succeeded registering
+ /// the variable and this function will do nothing in this
+ /// case. Thus it is safe to call it multiple time, using
+ /// an as-needed policy (will be called from get_text_value and
+ /// display)
+ ///
+ void registerTextVariable();
+
+ /// The flag keeping status of TextVariable registration
+ //
+ /// It will be set to true if there's no need to register
+ /// a text variable (ie. non-specified in the SWF)
///
- void registerTextVariable(const std::string& varname);
+ bool _text_variable_registered;
};
Index: testsuite/misc-ming.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/Makefile.am,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- testsuite/misc-ming.all/Makefile.am 13 Nov 2006 12:59:20 -0000 1.29
+++ testsuite/misc-ming.all/Makefile.am 13 Nov 2006 14:11:30 -0000 1.30
@@ -104,6 +104,9 @@
DefineEditTextVariableNameTest.swf: DefineEditTextVariableNameTest
./DefineEditTextVariableNameTest $(top_srcdir)/testsuite/media
+DefineEditTextVariableNameTest-Runner: $(srcdir)/../generic-testrunner.sh
+ sh $(srcdir)/../generic-testrunner.sh $(top_builddir)
DefineEditTextVariableNameTest.swf > $@
+
spritehier.swf: spritehier
./spritehier
@@ -155,6 +158,7 @@
TEST_DRIVERS = ../simple.exp
TEST_CASES = \
RollOverOutTest-Runner \
+ DefineEditTextVariableNameTest-Runner \
ButtonEventsTest-Runner
check-DEJAGNU: site-update $(check_PROGRAMS)
Index: testsuite/generic-testrunner.sh
===================================================================
RCS file: testsuite/generic-testrunner.sh
diff -N testsuite/generic-testrunner.sh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/generic-testrunner.sh 13 Nov 2006 14:11:30 -0000 1.2
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+top_builddir=$1
+testfile=$2
+
+cat << EOF
+#!/bin/sh
+${top_builddir}/utilities/gprocessor -v ${testfile}
+EOF