gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/event_id.h server/sprite...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/event_id.h server/sprite...
Date: Thu, 08 Feb 2007 16:23:29 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/02/08 16:23:28

Modified files:
        .              : ChangeLog 
        server         : event_id.h sprite_instance.cpp 

Log message:
                * server/event_id.h: add id() accessor, properly use the 
id_code enum.
                * server/sprite_instance.cpp (can_handle_mouse_event): handle
                  case insensitiveness for SWF<7 fixing bug exposed by
                  loadMovieTest.swf; (sprite_load_movie): add
                  a few more checks, needs more work.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2275&r2=1.2276
http://cvs.savannah.gnu.org/viewcvs/gnash/server/event_id.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.150&r2=1.151

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2275
retrieving revision 1.2276
diff -u -b -r1.2275 -r1.2276
--- ChangeLog   8 Feb 2007 14:40:19 -0000       1.2275
+++ ChangeLog   8 Feb 2007 16:23:28 -0000       1.2276
@@ -1,3 +1,14 @@
+2007-02-08 Sandro Santilli <address@hidden>
+
+       * server/event_id.h: add id() accessor, properly use the id_code enum.
+       * server/sprite_instance.cpp (can_handle_mouse_event): handle
+         case insensitiveness for SWF<7 fixing bug exposed by
+         loadMovieTest.swf; (sprite_load_movie): add
+         a few more checks, needs more work.
+       * testsuite/misc-ming.all/: Makefile.am, loadMovieTest.c:
+         simple testcase for MovieClip.loadMovie(); exposes a bug
+         in event handling too. No runner for it (yet).
+
 2007-02-08 Tomas Groth Christensen <address@hidden>
 
        * libbase/embedVideoDecoder.h, libbase/embedVideoDecoderFfmpeg.cpp:

Index: server/event_id.h
===================================================================
RCS file: /sources/gnash/gnash/server/event_id.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/event_id.h   18 Jan 2007 22:53:21 -0000      1.3
+++ server/event_id.h   8 Feb 2007 16:23:28 -0000       1.4
@@ -92,14 +92,14 @@
                EVENT_COUNT
        };
 
-       unsigned char   m_id;
+       id_code m_id;
        unsigned char   m_key_code;
 
        event_id() : m_id(INVALID), m_key_code(key::INVALID) {}
 
        event_id(id_code id, key::code c = key::INVALID)
                :
-               m_id((unsigned char) id),
+               m_id(id),
                m_key_code((unsigned char) c)
        {
                // For the button key events, you must supply a keycode.
@@ -128,6 +128,8 @@
        /// Return true if this is a mouse event
        /// (triggerable with a mouse activity)
        bool is_mouse_event() const;
+
+       id_code id() const { return m_id; }
 };
 
 }      // end namespace gnash

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -b -r1.150 -r1.151
--- server/sprite_instance.cpp  7 Feb 2007 16:47:03 -0000       1.150
+++ server/sprite_instance.cpp  8 Feb 2007 16:23:28 -0000       1.151
@@ -46,6 +46,7 @@
 #include "VM.h"
 #include "Range2d.h" // for getBounds
 #include "GnashException.h"
+#include "URL.h"
 
 #include <vector>
 #include <string>
@@ -502,11 +503,48 @@
        fn.result->set_int(sprite->get_bytes_total());
 }
 
+// my_mc.loadMovie(url:String [,variables:String]) : Void
 static void sprite_load_movie(const fn_call& fn)
 {
        sprite_instance* sprite = ensure_sprite(fn.this_ptr);
        UNUSED(sprite);
 
+       if (fn.nargs < 1) // url
+       {
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_msg("Invalid call to MovieClip.loadMove(), "
+                       "expected 1 or 2 args, got %d - returning undefined",
+                       fn.nargs);
+               );
+               return;
+       }
+
+       std::string urlstr = fn.arg(0).to_std_string();
+       if (urlstr.empty())
+       {
+               IF_VERBOSE_ASCODING_ERRORS(
+               std::stringstream ss; fn.dump_args(ss);
+               log_msg("First argument passed to MovieClip.loadMove(%s) "
+                       "evaluates to an empty string - "
+                       "returning undefined",
+                       ss.str().c_str());
+               );
+               return;
+       }
+       const URL& baseurl = get_base_url();
+       URL url(urlstr, baseurl);
+
+       if (fn.nargs > 1)
+       {
+               // TODO: implement support for second argument
+               log_error("FIXME: second argument of MovieClip.loadMovie(%s, 
<variables>) "
+                       "will be discarded (unsupported)", urlstr.c_str());
+               //return;
+       }
+
+       log_msg("MovieClip.loadMovie: url is %s", url.str().c_str());
+
+
        log_error("FIXME: %s not implemented yet", __PRETTY_FUNCTION__);
        //moviecliploader_loadclip(fn);
 }
@@ -3061,44 +3099,53 @@
 bool
 sprite_instance::can_handle_mouse_event() const
 {
-    // We should cache this!
     as_value dummy;
 
-    // Functions that qualify as mouse event handlers.
-    const char* FN_NAMES[] = {
-       "onKeyPress",
-       "onRelease",
-       "onDragOver",
-       "onDragOut",
-       "onPress",
-       "onReleaseOutside",
-       "onRollout",
-       "onRollover",
+       // Event handlers that qualify as mouse event handlers.
+       static const event_id EH[] =
+       {
+               event_id(event_id::PRESS),
+               event_id(event_id::RELEASE),
+               event_id(event_id::RELEASE_OUTSIDE),
+               event_id(event_id::ROLL_OVER),
+               event_id(event_id::ROLL_OUT),
+               event_id(event_id::DRAG_OVER),
+               event_id(event_id::DRAG_OUT),
     };
-    for (unsigned int i = 0; i < ARRAYSIZE(FN_NAMES); i++) {
-           // The const_cast is needed because get_member, due to
-           // possible "getter" methods executing stuff, is a non-const
-           // function. We take the "risk" here...
-       if (const_cast<sprite_instance*>(this)->get_member(FN_NAMES[i], 
&dummy)) {
+
+       int swfversion =  _vm.getSWFVersion();
+       for (unsigned int i = 0; i < ARRAYSIZE(EH); i++)
+       {
+               const event_id &event = EH[i];
+
+               // Check event handlers
+               if (get_event_handler(event.id(), &dummy))
+               {
            return true;
        }
+
+               // Check user-defined event handlers
+               // TODO: check if it's possible to actually
+               //       have an hard-coded handler and a user-defined
+               //       one. If this is not the case we should add
+               //       gettersetter memebers for all these handlers.
+               //
+               std::string fname = event.get_function_name();
+               if ( swfversion < 7 )
+               {
+                       // TODO: have event.get_function_name()
+                       //       return an SWF-contextual string  instead!
+                       boost::to_lower(fname, _vm.getLocale());
     }
 
-    // Event handlers that qualify as mouse event handlers.
-    const event_id::id_code EH_IDS[] = {
-       event_id::PRESS,
-       event_id::RELEASE,
-       event_id::RELEASE_OUTSIDE,
-       event_id::ROLL_OVER,
-       event_id::ROLL_OUT,
-       event_id::DRAG_OVER,
-       event_id::DRAG_OUT,
-    };
-    {for (unsigned int i = 0; i < ARRAYSIZE(EH_IDS); i++) {
-       if (get_event_handler(EH_IDS[i], &dummy)) {
+               // The const_cast is needed because get_member, due to
+               // possible "getter" methods executing stuff, is a non-const
+               // function. We take the "risk" here...
+               if (const_cast<sprite_instance*>(this)->get_member(fname, 
&dummy))
+               {
            return true;
        }
-    }}
+       }
 
     return false;
 }




reply via email to

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