Gnash  0.8.10
Classes | Public Types | Public Member Functions
gnash::movie_root Class Reference

This class represents the 'Stage' and top-level movie. More...

#include <movie_root.h>

Inheritance diagram for gnash::movie_root:
gnash::GcRoot

List of all members.

Classes

class  LoadCallback
struct  SoundStream

Public Types

enum  DisplayState { DISPLAYSTATE_NORMAL, DISPLAYSTATE_FULLSCREEN }
 The possible values of Stage.displayState. More...
enum  ScaleMode { SCALEMODE_SHOWALL, SCALEMODE_NOSCALE, SCALEMODE_EXACTFIT, SCALEMODE_NOBORDER }
 The possibile values of Stage.scaleMode. More...
enum  StageHorizontalAlign { STAGE_H_ALIGN_C, STAGE_H_ALIGN_L, STAGE_H_ALIGN_R }
 The possible horizonal positions of the Stage. More...
enum  StageVerticalAlign { STAGE_V_ALIGN_C, STAGE_V_ALIGN_T, STAGE_V_ALIGN_B }
 The possible vertical position of the Stage. More...
enum  AlignMode { STAGE_ALIGN_L, STAGE_ALIGN_T, STAGE_ALIGN_R, STAGE_ALIGN_B }
 The possible elements of a Stage.alignMode. More...
enum  AllowScriptAccessMode { SCRIPT_ACCESS_NEVER, SCRIPT_ACCESS_SAME_DOMAIN, SCRIPT_ACCESS_ALWAYS }
 The possibile values of AllowScriptAccess. More...
enum  ActionPriorityLevel { PRIORITY_INIT, PRIORITY_CONSTRUCT, PRIORITY_DOACTION, PRIORITY_SIZE }
 Action priority levels. More...
typedef std::list< LoadCallbackLoadCallbacks
typedef std::bitset
< key::KEYCOUNT > 
Keys
typedef std::pair
< StageHorizontalAlign,
StageVerticalAlign
StageAlign
typedef boost::array
< boost::ptr_deque
< ExecutableCode >
, PRIORITY_SIZE > 
ActionQueue
 A number of queues of code to execute.

Public Member Functions

 movie_root (VirtualClock &clock, const RunResources &runResources)
 Default constructor.
 ~movie_root ()
Movieinit (movie_definition *def, const MovieClip::MovieVariables &variables)
 Initialize movie_root with a parsed movie definition.
MovieClipgetLevel (unsigned int num) const
 Return the movie at the given level (0 if unloaded level).
void setLevel (unsigned int num, Movie *movie)
 Put the given movie at the given level.
void replaceLevel (unsigned int num, Movie *external_movie)
 Replace an existing level with a new movie.
void swapLevels (MovieClip *sp, int depth)
 Swap depth of a level (or two)
void dropLevel (int depth)
 Drop level at given depth.
void setDimensions (size_t w, size_t h)
 Change stage size.
size_t getStageWidth () const
 Notional width of the stage, actual value depending on scaleMode.
size_t getStageHeight () const
 Notional height of the stage, actual value depending on scaleMode.
DSOEXPORT bool mouseMoved (boost::int32_t x, boost::int32_t y)
 Inform the Stage that the mouse has moved.
DSOEXPORT bool mouseClick (bool press)
 Inform the Stage that a mouse click has occurred.
DSOEXPORT bool mouseWheel (int delta)
 Inform the Stage that a mouse wheel has moved.
DSOEXPORT bool keyEvent (key::code k, bool down)
 Tell the movie when the user pressed or released a key.
std::pair< boost::int32_t,
boost::int32_t > 
mousePosition () const
 Use this to retrieve the last state of the mouse.
void setDragState (const DragState &st)
MoviegetRootMovie ()
 Access the originating root movie (not necessarily _level0)
void stop_drag ()
boost::uint32_t addIntervalTimer (std::auto_ptr< Timer > timer)
 Add an interval timer.
void addLoadableObject (as_object *obj, std::auto_ptr< IOChannel > str)
 Register an object for loading data to.
void addAdvanceCallback (ActiveRelay *obj)
void removeAdvanceCallback (ActiveRelay *obj)
bool clearIntervalTimer (boost::uint32_t x)
 Remove timer identified by given integer.
void set_background_color (const rgba &color)
void set_background_alpha (float alpha)
VMgetVM ()
 Return the VM used by this movie_root.
bool advance ()
int timeToNextFrame () const
 Return the number of milliseconds available before it's time to advance the timeline again.
void advanceMovie ()
 Entry point for movie advancement.
void display ()
size_t nextUnnamedInstance ()
 Get a unique number for unnamed instances.
void registerButton (Button *listener)
 Push a new DisplayObject listener for key events.
void removeButton (Button *listener)
 Remove a DisplayObject listener for key events.
DisplayObjectgetFocus ()
 Get the DisplayObject having focus.
bool setFocus (DisplayObject *to)
 Set the DisplayObject having focus.
DSOEXPORT void add_invalidated_bounds (InvalidatedRanges &ranges, bool force)
DisplayObjectgetActiveEntityUnderPointer () const
 Return the topmost active entity under the pointer.
const DisplayObjectgetEntityUnderPointer () const
 Return the topmost non-dragging entity under the pointer.
DisplayObjectgetDraggingCharacter () const
 Return the DisplayObject currently being dragged, if any.
bool testInvariant () const
void setQuality (Quality q)
 Set the current display quality of the entire SWF.
Quality getQuality () const
 Get the current display quality.
void setStageAlignment (short s)
void setAllowScriptAccess (AllowScriptAccessMode mode)
 The mode is one of never, always, with sameDomain the default.
AllowScriptAccessMode getAllowScriptAccess ()
 Gets the current Access Mode for ExternalInterface.
StageAlign getStageAlignment () const
bool getShowMenuState () const
void setShowMenuState (bool state)
void setStageScaleMode (ScaleMode sm)
 Sets the Stage object's align mode.
ScaleMode getStageScaleMode () const
 Returns the Stage object's align mode.
std::string getStageAlignMode () const
DisplayState getStageDisplayState () const
 Returns the Stage object's align mode.
void setStageDisplayState (const DisplayState ds)
void pushAction (std::auto_ptr< ExecutableCode > code, size_t lvl)
 Push an executable code to the ActionQueue.
void pushAction (const action_buffer &buf, DisplayObject *target)
 Push an executable code to the ActionQueue.
void markReachableResources () const
 Mark all reachable resources (for GC)
void addLiveChar (MovieClip *ch)
 Register a newly born advanceable DisplayObject to the list of DisplayObjects to be advanced on next ::advance call.
void reset ()
 Reset stage to its initial state.
void disableScripts ()
 Call this method for disabling run of actions.
bool scriptsDisabled () const
 Return true if scripts execution is disabled.
void flushHigherPriorityActionQueues ()
DisplayObjectfindCharacterByTarget (const std::string &tgtstr) const
void loadMovie (const std::string &url, const std::string &target, const std::string &data, MovieClip::VariablesMethod method, as_object *handler=0)
 Queue a request for loading a movie.
void getURL (const std::string &urlstr, const std::string &target, const std::string &data, MovieClip::VariablesMethod method)
 Send a request to the hosting application (e.g. browser).
key::code lastKeyEvent () const
const KeysunreleasedKeys () const
void registerClass (const SWF::DefinitionTag *sprite, as_function *cls)
 Register an actionscript class for construction of a MovieClip.
as_functiongetRegisteredClass (const SWF::DefinitionTag *sprite) const
 Get the actionscript class for constructing a MovieClip.
void setHostFD (int fd)
void setControlFD (int fd)
int getHostFD () const
int getControlFD () const
DSOEXPORT void registerFSCommandCallback (FsCallback *handler)
DSOEXPORT void handleFsCommand (const std::string &cmd, const std::string &arg) const
 Call this to notify FS commands.
DSOEXPORT void registerEventCallback (HostInterface *handler)
void callInterface (const HostInterface::Message &e) const
 Call the hosting application without expecting a reply.
template<typename T >
callInterface (const HostInterface::Message &e) const
 Call the hosting application, ensuring a return of the requested type.
void setScriptLimits (boost::uint16_t recursion, boost::uint16_t timeout)
boost::uint16_t getRecursionLimit () const
boost::uint16_t getTimeoutLimit () const
const RunResourcesrunResources () const
void addExternalCallback (const std::string &name, as_object *callback)
 Add an ExternalInterface callback object with an associated name.
bool processInvoke (ExternalInterface::invoke_t *)
std::string callExternalCallback (const std::string &name, const std::vector< as_value > &args)
std::string callExternalJavascript (const std::string &name, const std::vector< as_value > &args)
void removeQueuedConstructor (MovieClip *target)
 Removes a queued constructor from the execution queue.
GCgc ()
bool queryInterface (const std::string &what) const
 Ask the host interface a question.
void setStreamBlock (int id, int block)
 Set the current stream block for the driving streaming sound.
void stopStream (int id)
 Notify the stage that a sound stream has stopped.

Detailed Description

This class represents the 'Stage' and top-level movie.

It is a wrapper around the set of loaded levels being played. Each 'run' of a SWF movie, including all further movies loaded during the run, has exactly one movie_root, which is kept for the entire run. Loading a new top-level movie does not create a new movie_root. The 'Stage' part of movie_root is accessible through the ActionScript Stage object, implemented in Stage_as.cpp. The movie_root class is responsible for accepting and passing on user events (mouse or key events), for maintaining the heart-beat mechanism, and for advancing all MovieClips on request from the hosting application. The _root object is provided by getAsRoot().


Member Typedef Documentation

typedef boost::array<boost::ptr_deque<ExecutableCode>, PRIORITY_SIZE> gnash::movie_root::ActionQueue

A number of queues of code to execute.

This is a ptr_deque because it needs no insertion in the middle but frequent push_back and pop_front. We also have to traverse it, so a queue is not usable.

typedef std::bitset<key::KEYCOUNT> gnash::movie_root::Keys

Member Enumeration Documentation

Action priority levels.

Enumerator:
PRIORITY_INIT 

Init actions, Init event handlers.

PRIORITY_CONSTRUCT 

Construct event handlers.

PRIORITY_DOACTION 

Frame actions, load handlers, unload handlers.

PRIORITY_SIZE 

Last element used to easy computation of size...

The possible elements of a Stage.alignMode.

Enumerator:
STAGE_ALIGN_L 
STAGE_ALIGN_T 
STAGE_ALIGN_R 
STAGE_ALIGN_B 

The possibile values of AllowScriptAccess.

Enumerator:
SCRIPT_ACCESS_NEVER 
SCRIPT_ACCESS_SAME_DOMAIN 
SCRIPT_ACCESS_ALWAYS 

The possible values of Stage.displayState.

Enumerator:
DISPLAYSTATE_NORMAL 
DISPLAYSTATE_FULLSCREEN 

The possibile values of Stage.scaleMode.

Enumerator:
SCALEMODE_SHOWALL 
SCALEMODE_NOSCALE 
SCALEMODE_EXACTFIT 
SCALEMODE_NOBORDER 

The possible horizonal positions of the Stage.

Enumerator:
STAGE_H_ALIGN_C 
STAGE_H_ALIGN_L 
STAGE_H_ALIGN_R 

The possible vertical position of the Stage.

Enumerator:
STAGE_V_ALIGN_C 
STAGE_V_ALIGN_T 
STAGE_V_ALIGN_B 

Constructor & Destructor Documentation

gnash::movie_root::movie_root ( VirtualClock clock,
const RunResources runResources 
)

Default constructor.

Make sure to call setRootMovie() before using any of this class methods !

References setQuality(), gnash::QUALITY_HIGH, gnash::RcInitFile::getDefaultInstance(), gnash::RcInitFile::getScriptsRecursionLimit(), and gnash::RcInitFile::getScriptsTimeout().

gnash::movie_root::~movie_root ( )

Member Function Documentation

void gnash::movie_root::add_invalidated_bounds ( InvalidatedRanges ranges,
bool  force 
)
void gnash::movie_root::addAdvanceCallback ( ActiveRelay obj)
void gnash::movie_root::addExternalCallback ( const std::string &  name,
as_object callback 
)

Add an ExternalInterface callback object with an associated name.

This should store a callback object in movie_root.

TODO: currently it doesn't.

References UNUSED, gnash::ExternalInterface::makeInvoke(), gnash::ExternalInterface::writeBrowser(), and _.

boost::uint32_t gnash::movie_root::addIntervalTimer ( std::auto_ptr< Timer timer)

Add an interval timer.

Parameters:
timerA Timer, ownership will be transferred. Must not be NULL.
internalIf true, this is an internal timer, so will get a negative id.
Returns:
An integer indentifying the timer for subsequent call to clear_interval_timer. It will NEVER be zero.

References assert, testInvariant(), and gnash::key::t.

void gnash::movie_root::addLiveChar ( MovieClip ch) [inline]

Register a newly born advanceable DisplayObject to the list of DisplayObjects to be advanced on next ::advance call.

The DisplayObject will only be advanced if not unloaded when its turn comes. Characters are advanced in reverse-placement order (first registered is advanced last)

References assert.

Referenced by gnash::MovieClip::construct().

void gnash::movie_root::addLoadableObject ( as_object obj,
std::auto_ptr< IOChannel str 
)

Register an object for loading data to.

When complete, the object's onData function is called. The callback is removed when the load is complete, including failed loads. There is no restriction on the type of as_object that can registered.

Parameters:
objThe object to update when data is received.
strThe stream to load from. TODO: this function could be improved, e.g. by handling the URL checking and stream construction as well. It may be possible for this function to handle all connections if it also takes a callback function to call on each advance.
bool gnash::movie_root::advance ( )

Main and only callback from hosting application. Expected to be called at 10ms resolution.

Returns:
true if the heart-beat resulted in actual SWF playhead advancement (frame advancement)

References gnash::VM::getTime(), gnash::key::s, gnash::RunResources::soundHandler(), gnash::sound::sound_handler::streamingSound(), _, gnash::sound::sound_handler::getStreamBlock(), getTimeoutLimit(), advanceMovie(), gnash::SystemClock::elapsed(), queryInterface(), and gnash::fontlib::clear().

Referenced by gnash::Gui::advanceMovie(), and nsPluginInstance::threadMain().

void gnash::movie_root::advanceMovie ( )

Entry point for movie advancement.

This function does:

  • Execute all timers
  • Reset the next Random number
  • Advance all advanceable DisplayObjects in reverse-placement order
  • Cleanup key listeners
  • Process all queued actions
  • Remove unloaded DisplayObjects from the advanceable DisplayObjects list.
  • Run the GC collector

References gnash::MovieLoader::processCompletedRequests(), assert, and testInvariant().

Referenced by advance().

std::string gnash::movie_root::callExternalCallback ( const std::string &  name,
const std::vector< as_value > &  args 
)
std::string gnash::movie_root::callExternalJavascript ( const std::string &  name,
const std::vector< as_value > &  args 
)
T gnash::movie_root::callInterface ( const HostInterface::Message e) const

Call the hosting application without expecting a reply.

Parameters:
eThe message to send to the interface.

References _, and gnash::HostInterface::call().

Referenced by setStageAlignment(), setShowMenuState(), setStageScaleMode(), setStageDisplayState(), and processInvoke().

template<typename T >
T gnash::movie_root::callInterface ( const HostInterface::Message e) const

Call the hosting application, ensuring a return of the requested type.

If the return type is other than the requested type, this represents a bug in the hosting application. An error is logged and the default constructed type T is returned. This may cause unexpected ActionScript behaviour, but is otherwise safe.

Template Parameters:
TThe return type expected.
Parameters:
eThe message to send to the interface.
bool gnash::movie_root::clearIntervalTimer ( boost::uint32_t  x)

Remove timer identified by given integer.

Returns:
true on success, false on error (no such timer)
void gnash::movie_root::disableScripts ( )

Call this method for disabling run of actions.

NOTE: this will only work for queued actions, not for *every* action. Supposedly all actions should be queued, but this is not really always the case. Notable exceptions are:

  • Actions in callFrame target frame but only executed by execution of the callFrame opcode
  • on{,Clip}{Initialize,Construct} event handlers
  • User event handlers (mouse,keyboard)
void gnash::movie_root::display ( )
void gnash::movie_root::dropLevel ( int  depth)

Drop level at given depth.

Parameters:
depthDepth of the level to drop. Note that this is -DisplayObject::staticDepthOffset for the root movie. Must be >=0 and <= 1048575 or an assertion will fail. Note that if the depth evaluates to the original root movie nothing happens (not allowed to remove that). It is not tested if it's allowed to remove _level0 after loading into it.

References assert, _, IF_VERBOSE_ASCODING_ERRORS, gnash::DisplayObject::unload(), gnash::MovieClip::destroy(), and testInvariant().

Referenced by gnash::MovieClip::removeMovieClip().

DisplayObject * gnash::movie_root::findCharacterByTarget ( const std::string &  tgtstr) const
void gnash::movie_root::flushHigherPriorityActionQueues ( )

Process action queues with higher priority then the priority of the action queue currently being processed. This is intended to be called at the end of any function call and at the end of an action block.

TODO: be aware of infinite loops !

cleanup anything pushed later..

References gnash::fontlib::clear().

GC& gnash::movie_root::gc ( ) [inline]
DisplayObject * gnash::movie_root::getActiveEntityUnderPointer ( ) const

Return the topmost active entity under the pointer.

This method returns cached info, with cache updated by notify_mouse_moved (and should be updated also by movie advancement or actions execution maybe, not currently implmented).

Returns:
the topmost active entity under pointer or NULL if none.

References gnash::MouseButtonState::activeEntity.

Referenced by gnash::Gui::notifyMouseMove().

movie_root::AllowScriptAccessMode gnash::movie_root::getAllowScriptAccess ( )

Gets the current Access Mode for ExternalInterface.

int gnash::movie_root::getControlFD ( ) const [inline]
DisplayObject * gnash::movie_root::getDraggingCharacter ( ) const

Return the DisplayObject currently being dragged, if any.

Referenced by getEntityUnderPointer().

const DisplayObject * gnash::movie_root::getEntityUnderPointer ( ) const

Return the topmost non-dragging entity under the pointer.

This method triggers a displaylist scan

Returns:
the topmost non-dragging entity under pointer or NULL if none

References gnash::pixelsToTwips(), and getDraggingCharacter().

DisplayObject * gnash::movie_root::getFocus ( )

Get the DisplayObject having focus.

The DisplayObject having focus will receive mouse button and key presses/releases.

Returns:
the DisplayObject having focus or NULL of none.

Referenced by gnash::DisplayObject::set_visible().

int gnash::movie_root::getHostFD ( ) const [inline]

Get the filedescriptor to use for host application requests (for browser communication mostly)

Returns:
-1 if no filedescriptor is provided by host app.
MovieClip * gnash::movie_root::getLevel ( unsigned int  num) const

Return the movie at the given level (0 if unloaded level).

POST CONDITIONS:

References gnash::key::i, and gnash::DisplayObject::staticDepthOffset.

Referenced by gnash::getDisplayObjectProperty(), processInvoke(), and callExternalCallback().

Quality gnash::movie_root::getQuality ( ) const [inline]

Get the current display quality.

References _quality.

Referenced by gnash::Gui::getQuality().

boost::uint16_t gnash::movie_root::getRecursionLimit ( ) const [inline]

Get the current global recursion limit for this movie: it can be changed by loaded movies.

Referenced by gnash::VM::pushCallFrame().

as_function * gnash::movie_root::getRegisteredClass ( const SWF::DefinitionTag sprite) const

Get the actionscript class for constructing a MovieClip.

Parameters:
spriteThe definition tag for the MovieClip to be placed on stage
Returns:
The class to be used, or 0 if no class is associated.

Referenced by gnash::MovieClip::constructAsScriptObject().

Movie& gnash::movie_root::getRootMovie ( ) [inline]
bool gnash::movie_root::getShowMenuState ( ) const

Returns the current value of _showMenu which instructs the gui about how much to display in the context menu

Returns a string that represents the boolean state of the _showMenu variable

movie_root::StageAlign gnash::movie_root::getStageAlignment ( ) const

Returns the current alignment of the stage (left/right/centre, top/ bottom/centre) as a std::pair

Returns a pair of enum values giving the actual alignment of the stage after align mode flags are evaluated.

L takes precedence over R. Default is centred.

T takes precedence over B. Default is centred.

References STAGE_H_ALIGN_C, STAGE_ALIGN_L, STAGE_H_ALIGN_L, STAGE_ALIGN_R, STAGE_H_ALIGN_R, STAGE_V_ALIGN_C, STAGE_ALIGN_T, STAGE_V_ALIGN_T, STAGE_ALIGN_B, and STAGE_V_ALIGN_B.

Referenced by gnash::Gui::updateStageMatrix().

std::string gnash::movie_root::getStageAlignMode ( ) const

Returns the string representation of the current align mode, which must always be in the order: LTRB

References STAGE_ALIGN_L, STAGE_ALIGN_T, STAGE_ALIGN_R, and STAGE_ALIGN_B.

DisplayState gnash::movie_root::getStageDisplayState ( ) const [inline]

Returns the Stage object's align mode.

size_t gnash::movie_root::getStageHeight ( ) const

Notional height of the stage, actual value depending on scaleMode.

Get actionscript height of stage, in pixels. The height returned depends on the scale mode.

References SCALEMODE_NOSCALE, and gnash::Movie::heightPixels().

ScaleMode gnash::movie_root::getStageScaleMode ( ) const [inline]

Returns the Stage object's align mode.

Referenced by gnash::Gui::updateStageMatrix().

size_t gnash::movie_root::getStageWidth ( ) const

Notional width of the stage, actual value depending on scaleMode.

Get actionscript width of stage, in pixels. The width returned depends on the scale mode.

References SCALEMODE_NOSCALE, and gnash::Movie::widthPixels().

boost::uint16_t gnash::movie_root::getTimeoutLimit ( ) const [inline]

Get the current global script timeout limit for this movie: it can be changed by loaded movies.

Referenced by gnash::ActionExec::operator()(), and advance().

void gnash::movie_root::getURL ( const std::string &  urlstr,
const std::string &  target,
const std::string &  data,
MovieClip::VariablesMethod  method 
)

Send a request to the hosting application (e.g. browser).

This function constructs the URL and, if required, the postdata from the arguments. The variables to send should *not* be appended to

Parameters:
urlstrbefore calling this function.
urlstrThe url exactly as requested. This may already contain a query string.
targetTarget for request.
dataThe variables data to send, URL encoded in key/value pairs
methodThe VariablesMethod to use for sending the data. If MovieClip::METHOD_NONE, no data will be sent.

If there is no hosting application, call the URL launcher. For safety, we resolve the URL against the base URL for this run. The data is not sent at all.

Try to avoid letting flash movies execute arbitrary commands (sic)

Maybe we should exec here, but if we do we might have problems with complex urlOpenerFormats like: firefox -remote 'openurl(u)'

This is when there is a hosting application.

References __FUNCTION__, url, gnash::RunResources::streamProvider(), gnash::StreamProvider::baseURL(), gnash::RcInitFile::getDefaultInstance(), _, gnash::ExternalInterface::makeInvoke(), and gnash::ExternalInterface::writeBrowser().

Referenced by gnash::TextField::mouseEvent().

VM& gnash::movie_root::getVM ( ) [inline]
void gnash::movie_root::handleFsCommand ( const std::string &  cmd,
const std::string &  arg 
) const

Call this to notify FS commands.

References gnash::FsCallback::notify().

Movie * gnash::movie_root::init ( movie_definition def,
const MovieClip::MovieVariables variables 
)

Initialize movie_root with a parsed movie definition.

The definition may be a SWF or Bitmap movie definition. The created Movie is returned; it is non-const so may be stored, queried, and changed by the caller for debugging or manipulation. Direct use of the pointer may result in unexpected behaviour during SWF playback, so for normal playback this pointer should not be used.

References gnash::VM::setSWFVersion(), gnash::movie_definition::get_version(), gnash::movie_definition::createMovie(), gnash::VM::getGlobal(), and gnash::MovieClip::setVariables().

Referenced by gnash::Gui::start().

bool gnash::movie_root::keyEvent ( key::code  k,
bool  down 
)
key::code gnash::movie_root::lastKeyEvent ( ) const [inline]
void gnash::movie_root::loadMovie ( const std::string &  url,
const std::string &  target,
const std::string &  data,
MovieClip::VariablesMethod  method,
as_object handler = 0 
) [inline]

Queue a request for loading a movie.

This function constructs the URL and, if required, the postdata from the arguments. The variables to send should *not* be appended to

Parameters:
urlstrbefore calling this function.
urlstrThe url exactly as requested. This may already contain a query string.
targetTarget for request.
dataThe variables data to send, URL encoded in key/value pairs
methodThe VariablesMethod to use for sending the data. If MovieClip::METHOD_NONE, no data will be sent.
handlerAn object which will be signalled of load events (onLoadStart, onLoadComplete, onLoadInit, onLoadError). Can be null if caller doesn't care.
void gnash::movie_root::markReachableResources ( ) const [virtual]

Mark all reachable resources (for GC)

Resources reachable from movie_root are:

  • All _level# movies (_movies)
  • The original root movie (_rootMovie)
  • Mouse entities (m_mouse_button_state)
  • Timer targets (_intervalTimers)
  • Resources reachable by ActionQueue code (_actionQueue)
  • Any DisplayObject being dragged

Implements gnash::GcRoot.

References gnash::VM::markReachableResources(), gnash::foreachSecond(), assert, gnash::GcResource::setReachable(), gnash::MouseButtonState::markReachableResources(), gnash::renderer::opengl::for_each(), gnash::ActiveRelay::setReachable(), gnash::movie_root::LoadCallback::setReachable(), gnash::MovieLoader::setReachable(), PRIORITY_SIZE, gnash::ExecutableCode::markReachableResources(), gnash::key::i, and gnash::key::e.

bool gnash::movie_root::mouseClick ( bool  press)

Inform the Stage that a mouse click has occurred.

Parameters:
presstrue for a mouse click, false for a release
Returns:
true if any action triggered requires a redraw.

References assert, testInvariant(), gnash::MouseButtonState::isDown, gnash::event_id::MOUSE_DOWN, and gnash::event_id::MOUSE_UP.

Referenced by gnash::Gui::notifyMouseClick().

bool gnash::movie_root::mouseMoved ( boost::int32_t  x,
boost::int32_t  y 
)

Inform the Stage that the mouse has moved.

Coordinates are in Stage Coordinate Space (pseudo-pixels units).

Parameters:
xThe x co-ordinate in pixels.
yThe y co-ordinate in pixels.
Returns:
true if any action triggered requires a redraw.

TODO: take twips (or float pixels), or we won't be able to support sub-pixel accuracy in collision detection.

References assert, testInvariant(), x, y, and gnash::event_id::MOUSE_MOVE.

Referenced by gnash::Gui::notifyMouseMove().

std::pair< boost::int32_t, boost::int32_t > gnash::movie_root::mousePosition ( ) const

Use this to retrieve the last state of the mouse.

Coordinates are in PIXELS, NOT TWIPS.

References assert, and testInvariant().

Referenced by gnash::TextField::mouseEvent().

bool gnash::movie_root::mouseWheel ( int  delta)

Inform the Stage that a mouse wheel has moved.

Parameters:
deltaThe direction of the scroll: positive for up, negative for down. Although values from about -3 to 3 are documented, only -1 and 1 have been observed.
Returns:
true if any action triggered requires a redraw.

References gnash::getURI(), gnash::NSV::CLASS_MOUSE, x, gnash::pixelsToTwips(), y, gnash::key::i, gnash::NSV::PROP_BROADCAST_MESSAGE, and gnash::getObject().

Referenced by gnash::Gui::notifyMouseWheel().

size_t gnash::movie_root::nextUnnamedInstance ( ) [inline]

Get a unique number for unnamed instances.

Referenced by gnash::DisplayObject::getNextUnnamedInstanceName().

bool gnash::movie_root::processInvoke ( ExternalInterface::invoke_t invoke)
void gnash::movie_root::pushAction ( std::auto_ptr< ExecutableCode code,
size_t  lvl 
)
void gnash::movie_root::pushAction ( const action_buffer buf,
DisplayObject target 
)

Push an executable code to the ActionQueue.

References gnash::DisplayObject::getTargetPath(), and PRIORITY_DOACTION.

bool gnash::movie_root::queryInterface ( const std::string &  what) const

Ask the host interface a question.

Parameters:
whatThe question to pose.
Returns:
The answer (true for yes, false for no).

References gnash::HostMessage::QUERY, and _.

Referenced by gnash::ActionExec::operator()(), and advance().

void gnash::movie_root::registerButton ( Button listener)

Push a new DisplayObject listener for key events.

Referenced by gnash::Button::construct().

void gnash::movie_root::registerClass ( const SWF::DefinitionTag sprite,
as_function cls 
)

Register an actionscript class for construction of a MovieClip.

Parameters:
spriteThe definition tag for the MovieClip to be placed on stage
classThe ActionScript class to be used in construction.
DSOEXPORT void gnash::movie_root::registerEventCallback ( HostInterface handler) [inline]

A callback to the GUI (or whatever is listening) for sending events and receiving replies. Used for ActionScript interface with the gui (Mouse visibility, Stage alignment etc and System information, for instance).

See callInterface method

DSOEXPORT void gnash::movie_root::registerFSCommandCallback ( FsCallback handler) [inline]

ActionScript embedded in a movie can use the built-in fscommand() function to send data back to the host application. If you are interested in this data, register a handler, which will be called when the embedded scripts call fscommand().

The handler gets the MovieClip* that the script is embedded in, and the two string arguments passed by the script to fscommand().

Referenced by nsPluginInstance::threadMain().

void gnash::movie_root::removeAdvanceCallback ( ActiveRelay obj)
void gnash::movie_root::removeButton ( Button listener)

Remove a DisplayObject listener for key events.

Referenced by gnash::Button::destroy().

void gnash::movie_root::removeQueuedConstructor ( MovieClip target)

Removes a queued constructor from the execution queue.

This is used to prevent construction of targets that are placed and then removed in skipped frames. Callers are responsible for determining whether it should be removed, for instance by checking for an onUnload handler.

References PRIORITY_CONSTRUCT.

Referenced by gnash::MovieClip::unloadChildren().

void gnash::movie_root::replaceLevel ( unsigned int  num,
Movie external_movie 
)

Replace an existing level with a new movie.

Depth will be assigned to external_movie by this function. If the give level number doesn't exist an error is logged and nothing else happens.

This method is intended for use by xxx.loadMovie(yyy) when 'xxx' is a top-level movie.

References gnash::DisplayObject::set_depth(), gnash::DisplayObject::staticDepthOffset, gnash::DisplayObject::get_depth(), _, and setLevel().

Referenced by gnash::MovieClip::getLoadedMovie().

void gnash::movie_root::reset ( )
const RunResources& gnash::movie_root::runResources ( ) const [inline]
bool gnash::movie_root::scriptsDisabled ( ) const [inline]

Return true if scripts execution is disabled.

Referenced by gnash::ActionExec::operator()().

void gnash::movie_root::set_background_alpha ( float  alpha)
void gnash::movie_root::set_background_color ( const rgba color)
void gnash::movie_root::setAllowScriptAccess ( AllowScriptAccessMode  mode)

The mode is one of never, always, with sameDomain the default.

Sets the flag to allow interfacing with JavaScript in the browser. This is disabled by default, but enabled for ExternalInterface.

void gnash::movie_root::setControlFD ( int  fd) [inline]

Set a filedescriptor to use for host application requests (for browser communication mostly)

void gnash::movie_root::setDimensions ( size_t  w,
size_t  h 
)

Change stage size.

This may be smaller than the size of the root movie. It determines how much of the movie is visible.

Parameters:
wThe width of the stage
hThe height of the stage.

References assert, testInvariant(), test::w, gnash::key::h, SCALEMODE_NOSCALE, gnash::getURI(), gnash::NSV::CLASS_STAGE, and gnash::NSV::PROP_BROADCAST_MESSAGE.

Referenced by gnash::Gui::resize_view().

void gnash::movie_root::setDragState ( const DragState st)
bool gnash::movie_root::setFocus ( DisplayObject to)

Set the DisplayObject having focus.

Parameters:
toThe DisplayObject to receive focus. NULL to kill focus.
Returns:
true if the focus operation succeeded, false if the passed DisplayObject cannot receive focus. setFocus(0) is a valid operation, so returns true (always succeeds).

A valid focus must have an associated object.

References gnash::DisplayObject::handleFocus(), gnash::DisplayObject::killFocus(), assert, gnash::getObject(), gnash::NSV::PROP_ON_KILL_FOCUS, gnash::NSV::PROP_ON_SET_FOCUS, gnash::NSV::CLASS_SELECTION, gnash::NSV::PROP_BROADCAST_MESSAGE, and testInvariant().

Referenced by gnash::DisplayObject::set_visible().

void gnash::movie_root::setHostFD ( int  fd) [inline]

Set a filedescriptor to use for host application requests (for browser communication mostly)

References assert.

void gnash::movie_root::setLevel ( unsigned int  num,
Movie movie 
)

Put the given movie at the given level.

Parameters:
movieThe Movie to store at the given level. Its depth will be set to <num>+DisplayObject::staticDepthOffset and its name to _level<num>

Notify placement

References assert, gnash::DisplayObject::get_depth(), gnash::DisplayObject::staticDepthOffset, gnash::Movie::widthPixels(), gnash::Movie::heightPixels(), gnash::key::e, gnash::HostMessage::RESIZE_STAGE, gnash::HostInterface::call(), gnash::DisplayObject::set_invalidated(), gnash::MovieClip::construct(), and testInvariant().

Referenced by replaceLevel().

void gnash::movie_root::setQuality ( Quality  q)
void gnash::movie_root::setScriptLimits ( boost::uint16_t  recursion,
boost::uint16_t  timeout 
)

Called from the ScriptLimits tag parser to set the global script limits. It is expected behaviour that each new loaded movie should override this. Can be overridden from gnashrc.

Parameters:
recursionthe maximum number of recursions when finding 'super'. The default value for this (i.e. when no ScriptLimits tag is present) is documented to be 256, but this may change and appears not to be crucial for (backward) compatibility.
timeoutthe timeout in seconds for script execution. The default value for this (i.e. when no ScriptLimits tag is present) is documented to be 15 to 20 seconds, depending on platform.

References gnash::RcInitFile::getDefaultInstance(), and LOG_ONCE.

Referenced by gnash::SWF::ScriptLimitsTag::executeState().

void gnash::movie_root::setShowMenuState ( bool  state)

Sets the value of _showMenu and calls the fscommand handler for the current gui

Sets the value of _showMenu and calls the gui handler to process the fscommand to change the display of the context menu

References callInterface(), and gnash::HostMessage::SHOW_MENU.

void gnash::movie_root::setStageAlignment ( short  s)

Sets movie_root's horizontal and vertical alignment to one of the three possible positions for each dimension.

Takes a short int bitfield: the four bits correspond to the AlignMode enum

References gnash::key::s, callInterface(), and gnash::HostMessage::UPDATE_STAGE.

void gnash::movie_root::setStageDisplayState ( const DisplayState  ds)
void gnash::movie_root::setStageScaleMode ( ScaleMode  sm)
void gnash::movie_root::setStreamBlock ( int  id,
int  block 
)

Set the current stream block for the driving streaming sound.

The frame rate will be changed so that it advances only when the block for a particular frame is reached. Only one sound can drive the frame: the first one to be registered.

Parameters:
idThe id of the stream; if another stream is already driving the frame rate, nothing happens.
blockThe block of sound currently being played. The current frame will be advanced or delayed until the frame corresponding to this block is reached.

Referenced by gnash::SWF::StreamSoundBlockTag::executeActions().

void gnash::movie_root::stop_drag ( ) [inline]
void gnash::movie_root::stopStream ( int  id)

Notify the stage that a sound stream has stopped.

If it's the one driving the frame rate, the frame rate will return to the nominal rate

Parameters:
idThe id of the streaming sound.
void gnash::movie_root::swapLevels ( MovieClip sp,
int  depth 
)

Swap depth of a level (or two)

Character's depths are updated.

Parameters:
spThe level to change depth/level of. A pointer to it is expected to be found in the _level# container, or an error will be printed and the call would result in a no-op.
depthNew depth to assign to the DisplayObject. If another level exists at the target depth the latter is moved in place of the former, with its depth also updated.

References assert, gnash::DisplayObject::get_depth(), gnash::key::i, gnash::key::e, gnash::DisplayObject::staticDepthOffset, IF_VERBOSE_ASCODING_ERRORS, _, gnash::DisplayObject::getTarget(), gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), and testInvariant().

bool gnash::movie_root::testInvariant ( ) const [inline]
int gnash::movie_root::timeToNextFrame ( ) const

Return the number of milliseconds available before it's time to advance the timeline again.

Return value can be negative if we're late...

References gnash::VM::getTime().

const Keys& gnash::movie_root::unreleasedKeys ( ) const [inline]

Referenced by gnash::key_is_down().


The documentation for this class was generated from the following files: