gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10283: Use numerical value instead


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10283: Use numerical value instead of boolean for _visibility. Add tests.
Date: Sat, 15 Nov 2008 14:25:03 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10283
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Sat 2008-11-15 14:25:03 +0100
message:
  Use numerical value instead of boolean for _visibility. Add tests. 
  Fixes bug #24839.
modified:
  libcore/character.cpp
  testsuite/actionscript.all/MovieClip.as
=== modified file 'libcore/character.cpp'
--- a/libcore/character.cpp     2008-10-25 10:38:32 +0000
+++ b/libcore/character.cpp     2008-11-15 13:25:03 +0000
@@ -429,6 +429,8 @@
 
 }
 
+/// _visible can be set with true/false, but also
+/// 0 and 1.
 as_value
 character::visible_getset(const fn_call& fn)
 {
@@ -441,8 +443,17 @@
        }
        else // setter
        {
-               ptr->set_visible(fn.arg(0).to_bool());
-               ptr->transformedByScript(); // m_accept_anim_moves = false; 
+        /// We cast to number and rely (mostly) on C++'s automatic
+        /// cast to bool, as string "0" should be converted to
+        /// its numeric equivalent, not interpreted as 'true', which
+        /// SWF7+ does for strings.
+        double d = fn.arg(0).to_number();
+
+        // Undefined or NaN is false.
+        if (isInf(d) || isNaN(d)) ptr->set_visible(false);
+               else ptr->set_visible(d);
+
+               ptr->transformedByScript();
        }
        return rv;
 

=== modified file 'testsuite/actionscript.all/MovieClip.as'
--- a/testsuite/actionscript.all/MovieClip.as   2008-11-13 15:33:38 +0000
+++ b/testsuite/actionscript.all/MovieClip.as   2008-11-15 13:25:03 +0000
@@ -115,15 +115,15 @@
 #endif
 
 #if OUTPUT_VERSION == 6
-       check_totals(815); // SWF6
+       check_totals(823); // SWF6
 #endif
 
 #if OUTPUT_VERSION == 7
-       check_totals(832); // SWF7
+       check_totals(840); // SWF7
 #endif
 
 #if OUTPUT_VERSION >= 8
-       check_totals(906); // SWF8+
+       check_totals(914); // SWF8+
 #endif
 
        play();
@@ -2139,6 +2139,27 @@
 
 #endif
 
+// Test _visible property
+
+#if OUTPUT_VERSION > 5
+vis = _root.createEmptyMovieClip("vis", getNextHighestDepth());
+check_equals(vis._visible, true);
+vis._visible = false;
+check_equals(vis._visible, false);
+vis._visible = "1";
+check_equals(vis._visible, true);
+vis._visible = 0;
+check_equals(vis._visible, false);
+vis._visible = "true";
+check_equals(vis._visible, false);
+vis._visible = "false";
+check_equals(vis._visible, false);
+vis._visible = "gibberish";
+check_equals(vis._visible, false);
+vis._visible = undefined;
+check_equals(vis._visible, false);
+#endif
+
 //_root.loadVariables(MEDIA(vars.txt), "GET");
 
 // Can't rely on this to call onData!


reply via email to

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