gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r11559: Rejig properties more.


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11559: Rejig properties more.
Date: Tue, 13 Oct 2009 10:52:24 +0200
User-agent: Bazaar (1.16.1)

------------------------------------------------------------
revno: 11559 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Tue 2009-10-13 10:52:24 +0200
message:
  Rejig properties more.
modified:
  libcore/DisplayObject.cpp
  libcore/DisplayObject.h
  libcore/MovieClip.cpp
  libcore/MovieClip.h
  libcore/TextField.h
  libcore/asobj/flash/display/MovieClip_as.cpp
  libcore/vm/ASHandlers.cpp
  testsuite/actionscript.all/MovieClip.as
  testsuite/actionscript.all/TextField.as
  testsuite/swfdec/PASSING
=== modified file 'libcore/DisplayObject.cpp'
--- a/libcore/DisplayObject.cpp 2009-10-12 09:42:13 +0000
+++ b/libcore/DisplayObject.cpp 2009-10-13 08:04:52 +0000
@@ -65,6 +65,9 @@
     const Getters displayObjectGetters();
     const Setters displayObjectSetters();
 
+    bool doSet(string_table::key prop, DisplayObject& o, const as_value& val);
+    bool doGet(string_table::key prop, DisplayObject& o, as_value& val);
+    string_table::key getPropertyByIndex(size_t index);
 }
 
 // Define static const members.
@@ -881,12 +884,73 @@
     return get_root();
 }
 
+void
+setIndexedProperty(size_t index, DisplayObject& o, const as_value& val)
+{
+    string_table::key prop = getPropertyByIndex(index);
+    if (!prop) return;
+    doSet(prop, o, val);
+}
+
+void
+getIndexedProperty(size_t index, DisplayObject& o, as_value& val)
+{
+    string_table::key prop = getPropertyByIndex(index);
+    if (!prop) {
+        val.set_undefined();
+        return;
+    }
+    doGet(prop, o, val);
+}
+
+
+/// DisplayObject property lookup 
+//
+/// This function is only called on the first object in the inheritance chain
+/// after the object's own properties have been checked.
+/// In AS2, any DisplayObject marks the end of the inheritance chain for
+/// lookups.
+//
+/// Lookup order:
+//
+/// 1. _level0.._level9
+/// 2. Objects on the DisplayList of a MovieClip
+/// 3. DisplayObject magic properties (_x, _y etc).
+/// 4. MovieClips' TextField variables (this is probably not the best
+///    way to do it, but as it is done like this, this must be called here.
+///    It will cause an infinite recursion otherwise.
 bool
 getDisplayObjectProperty(as_object& obj, string_table::key key,
         as_value& val)
 {
+    assert(obj.displayObject());
+    
+    string_table& st = getStringTable(obj);
+    const std::string& propname = st.value(key);
+    
     DisplayObject& o = static_cast<DisplayObject&>(obj);
 
+    // Check _level0.._level9
+    movie_root& mr = getRoot(o);
+    unsigned int levelno;
+    if (mr.isLevelTarget(propname, levelno)) {
+        Movie* mo = mr.getLevel(levelno).get();
+        if (mo) {
+            val = mo;
+            return true;
+        }
+        return false;
+    }
+    
+    MovieClip* mc = dynamic_cast<MovieClip*>(&obj);
+    if (mc) {
+        DisplayObject* ch = mc->getDisplayListObject(key);
+        if (ch) {
+           val = ch;
+           return true;
+        }
+    }
+
     // These properties have normal case-sensitivity.
     // They are tested to exist for TextField, MovieClip, and Button
     // but do not belong to the inheritance chain.
@@ -904,39 +968,16 @@
             return true;
     }
     
-    string_table& st = getStringTable(obj);
-    const std::string& propname = st.value(key);
-
-    // Check _level0.._level9
-    movie_root& mr = getRoot(o);
-    unsigned int levelno;
-    if (mr.isLevelTarget(propname, levelno)) {
-        Movie* mo = mr.getLevel(levelno).get();
-        if (mo) {
-            val = mo;
-            return true;
-        }
-        return false;
-    }
-
-    const Getters& getters = displayObjectGetters();
+
 
     // These magic properties are case insensitive in all versions!
     const string_table::key noCaseKey = 
st.find(boost::to_lower_copy(propname));
 
-    Getters::const_iterator it = getters.find(noCaseKey);
-    if (it != getters.end()) {
-        val = (*it->second)(o);
-        return true;
-    }
+    if (doGet(noCaseKey, o, val)) return true;
 
     // Check MovieClip such as TextField variables.
     // TODO: check if there's a better way to find these properties.
-    //
-    // Some tests in the swfdec testsuite suggest that these properties are
-    // checked only after the magic properties.
-    MovieClip* mc = dynamic_cast<MovieClip*>(&obj);
-    if (mc && mc->getMovieClipProperty(key, val)) return true;
+    if (mc && mc->getTextFieldVariables(key, val)) return true;
 
     return false;
 }
@@ -946,35 +987,12 @@
 setDisplayObjectProperty(as_object& obj, string_table::key key, 
         const as_value& val)
 {
-
-    const Setters& setters = displayObjectSetters();
-
+    assert(obj.displayObject());
     // These magic properties are case insensitive in all versions!
     string_table& st = getStringTable(obj);
     const std::string& propname = st.value(key);
     const string_table::key noCaseKey = 
st.find(boost::to_lower_copy(propname));
-
-    Setters::const_iterator it = setters.find(noCaseKey);
-    if (it == setters.end()) return false;
-
-    DisplayObject& o = static_cast<DisplayObject&>(obj);
-
-    Setter s = it->second;
-
-    // Read-only.
-    if (!s) return true;
-    
-    if (val.is_undefined() || val.is_null()) {
-        IF_VERBOSE_ASCODING_ERRORS(
-            log_aserror(_("Attempt to set property to %s, refused"),
-                o.getTarget(), val);
-        );
-        return true;
-    }
-
-    (*s)(o, val);
-    return true;
-
+    return doSet(noCaseKey, static_cast<DisplayObject&>(obj), val);
 }
 
 namespace {
@@ -1393,6 +1411,122 @@
     LOG_ONCE(log_unimpl("_focusrect setting"));
 }
 
+as_value
+getDropTarget(DisplayObject& o)
+{
+    // This property only applies to MovieClips.
+    MovieClip* mc = dynamic_cast<MovieClip*>(&o);
+    if (!mc) return as_value();
+    return as_value(mc->getDropTarget());
+}
+
+as_value
+getCurrentFrame(DisplayObject& o)
+{
+    // This property only applies to MovieClips.
+    MovieClip* mc = dynamic_cast<MovieClip*>(&o);
+    if (!mc) return as_value();
+    const int currframe =
+        std::min(mc->get_loaded_frames(), mc->get_current_frame() + 1);
+    return as_value(currframe);
+}
+
+as_value
+getFramesLoaded(DisplayObject& o)
+{
+    // This property only applies to MovieClips.
+    MovieClip* mc = dynamic_cast<MovieClip*>(&o);
+    if (!mc) return as_value();
+    return as_value(mc->get_frame_count());
+}
+
+as_value
+getTotalFrames(DisplayObject& o)
+{
+    // This property only applies to MovieClips.
+    MovieClip* mc = dynamic_cast<MovieClip*>(&o);
+    if (!mc) return as_value();
+    return as_value(mc->get_loaded_frames());
+}
+
+
+string_table::key
+getPropertyByIndex(size_t index)
+{
+
+    // This is a magic number; defining it here makes sure that the
+    // table is really this size.
+    const size_t size = 22;
+
+    if (index >= size) return 0;
+
+    static const string_table::key props[size] = {
+        NSV::PROP_uX,
+        NSV::PROP_uY,
+        NSV::PROP_uXSCALE,
+        NSV::PROP_uYSCALE,
+        NSV::PROP_uCURRENTFRAME,
+        NSV::PROP_uTOTALFRAMES,
+        NSV::PROP_uALPHA,
+        NSV::PROP_uVISIBLE,
+        NSV::PROP_uWIDTH,
+        NSV::PROP_uHEIGHT,
+        NSV::PROP_uROTATION, 
+        NSV::PROP_uTARGET, 
+        NSV::PROP_uFRAMESLOADED, 
+        NSV::PROP_uNAME, 
+        NSV::PROP_uDROPTARGET, 
+        NSV::PROP_uURL, 
+        NSV::PROP_uHIGHQUALITY, 
+        NSV::PROP_uFOCUSRECT, 
+        NSV::PROP_uSOUNDBUFTIME, 
+        NSV::PROP_uQUALITY, 
+        NSV::PROP_uXMOUSE, 
+        NSV::PROP_uYMOUSE 
+    };
+    return props[index];
+}
+
+bool
+doGet(string_table::key prop, DisplayObject& o, as_value& val)
+{
+    const Getters& getters = displayObjectGetters();
+    const Getters::const_iterator it = getters.find(prop);
+    if (it == getters.end()) return false;
+
+    val = (*it->second)(o);
+    return true;
+}
+
+
+/// Do the actual setProperty
+//
+/// Return true if the property is a DisplayObject property, regardless of
+/// whether it was successfully set or not.
+bool
+doSet(string_table::key prop, DisplayObject& o, const as_value& val)
+{
+    const Setters& setters = displayObjectSetters();
+    const Setters::const_iterator it = setters.find(prop);
+    if (it == setters.end()) return false;
+
+    const Setter s = it->second;
+
+    // Read-only.
+    if (!s) return true;
+    
+    if (val.is_undefined() || val.is_null()) {
+        IF_VERBOSE_ASCODING_ERRORS(
+            log_aserror(_("Attempt to set property to %s, refused"),
+                o.getTarget(), val);
+        );
+        return true;
+    }
+
+    (*s)(o, val);
+    return true;
+}
+
 const Getters
 displayObjectGetters()
 {
@@ -1412,6 +1546,10 @@
         (NSV::PROP_uVISIBLE, getVisible)
         (NSV::PROP_uSOUNDBUFTIME, getSoundBufTime)
         (NSV::PROP_uFOCUSRECT, getFocusRect)
+        (NSV::PROP_uDROPTARGET, getDropTarget)
+        (NSV::PROP_uCURRENTFRAME, getCurrentFrame)
+        (NSV::PROP_uFRAMESLOADED, getFramesLoaded)
+        (NSV::PROP_uTOTALFRAMES, getTotalFrames)
         (NSV::PROP_uPARENT, getParent)
         (NSV::PROP_uTARGET, getTarget)
         (NSV::PROP_uXMOUSE, getMouseX)
@@ -1439,6 +1577,10 @@
         (NSV::PROP_uVISIBLE, setVisible)
         (NSV::PROP_uSOUNDBUFTIME, setSoundBufTime)
         (NSV::PROP_uFOCUSRECT, setFocusRect)
+        (NSV::PROP_uDROPTARGET, n)
+        (NSV::PROP_uCURRENTFRAME, n)
+        (NSV::PROP_uFRAMESLOADED, n)
+        (NSV::PROP_uTOTALFRAMES, n)
         (NSV::PROP_uPARENT, n)
         (NSV::PROP_uURL, n)
         (NSV::PROP_uTARGET, n)

=== modified file 'libcore/DisplayObject.h'
--- a/libcore/DisplayObject.h   2009-10-12 09:42:13 +0000
+++ b/libcore/DisplayObject.h   2009-10-13 07:32:05 +0000
@@ -66,12 +66,31 @@
 /// the correct properties are attached.
 void attachDisplayObjectProperties(as_object& o);
 
+/// Set special properties
+//
+/// This will abort if called with a non DisplayObject. It sets the magic
+/// properties of DisplayObjects.
 bool setDisplayObjectProperty(as_object& obj, string_table::key key,
         const as_value& val);
 
+/// Get special properties
+//
+/// This will abort if called with a non DisplayObject. It gets the magic
+/// properties of DisplayObjects and handles special MovieClip properties
+/// such as DisplayList members.
 bool getDisplayObjectProperty(as_object& obj, string_table::key key,
         as_value& val);
 
+/// Get a property by its numeric index.
+//
+/// By ASHandlers to get the DisplayObject properties indexed by number
+void getIndexedProperty(size_t index, DisplayObject& o, as_value& val);
+
+/// Set a property by its numeric index.
+//
+/// By ASHandlers to set the DisplayObject properties indexed by number
+void setIndexedProperty(size_t index, DisplayObject& o, const as_value& val);
+
 /// DisplayObject is the base class for all DisplayList objects.
 //
 /// It represents a single active element in a movie. This class does not

=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp     2009-10-12 09:42:13 +0000
+++ b/libcore/MovieClip.cpp     2009-10-13 07:59:26 +0000
@@ -495,28 +495,11 @@
 /// The TextField variables should probably be handled in a more generic
 /// way.
 bool
-MovieClip::getMovieClipProperty(string_table::key name_key, as_value& val)
+MovieClip::getTextFieldVariables(string_table::key name_key, as_value& val)
 {
+
     const std::string& name = getStringTable(*this).value(name_key);
 
-    // Try items on our display list.
-    DisplayObject* ch;
-    if (getSWFVersion(*this) >= 7 ) {
-        ch = _displayList.getDisplayObjectByName(name);
-    }
-    else ch = _displayList.getDisplayObjectByName_i(name);
-    if (ch) {
-            // Found object.
-
-            // If the object is an ActionScript referenciable one we
-            // return it, otherwise we return ourselves
-            if (ch->isActionScriptReferenceable()) {
-                val = ch;
-            }
-            else val = this;
-            return true;
-    }
-
     // Try textfield variables
     TextFields* etc = get_textfield_variable(name);
     if ( etc )
@@ -843,31 +826,13 @@
     as_object* obj = DisplayObject::get_path_element(key);
     if (obj) return obj;
 
+    // See if we have a match on the display list.
+    DisplayObject* ch = getDisplayListObject(key);
+    if (ch) return ch;
+
     std::string name = getStringTable(*this).value(key);
-
-    // See if we have a match on the display list.
-    DisplayObject* ch;
-    if (getSWFVersion(*this) >= 7 ) ch = 
-        _displayList.getDisplayObjectByName(name);
-
-    else ch = _displayList.getDisplayObjectByName_i(name);
-
-            // TODO: should we check for isActionScriptReferenceable here ?
-    if ( ch )
-    {
-        // If the object is an ActionScript referenciable one we
-        // return it, otherwise we return ourselves
-        if ( ch->isActionScriptReferenceable() ) return ch;
-        else return this;
-    }
-
+    
     // See if it's a member
-
-    // NOTE: direct use of the base class's get_member avoids
-    //             triggering a call to MovieClip::get_member
-    //             which would scan the child DisplayObjects again
-    //             w/out a need for it
-
     as_value tmp;
     if ( !as_object::get_member(key, &tmp, 0) )
     {
@@ -1857,6 +1822,30 @@
 } 
 
 
+DisplayObject*
+MovieClip::getDisplayListObject(string_table::key key)
+{
+
+    const std::string& name = getStringTable(*this).value(key);
+
+    // Try items on our display list.
+    DisplayObject* ch;
+    if (getSWFVersion(*this) >= 7 ) {
+        ch = _displayList.getDisplayObjectByName(name);
+    }
+    else ch = _displayList.getDisplayObjectByName_i(name);
+    if (!ch) return 0;
+
+    // Found object.
+
+    // If the object is an ActionScript referenciable one we
+    // return it, otherwise we return ourselves
+    if (ch->isActionScriptReferenceable()) {
+        return ch;
+    }
+    return this;
+}
+
 void 
 MovieClip::add_invalidated_bounds(InvalidatedRanges& ranges, 
     bool force)

=== modified file 'libcore/MovieClip.h'
--- a/libcore/MovieClip.h       2009-10-12 09:42:13 +0000
+++ b/libcore/MovieClip.h       2009-10-13 07:59:26 +0000
@@ -522,15 +522,22 @@
     void loadVariables(const std::string& urlstr,
             VariablesMethod sendVarsMethod);
 
-    /// Get special MovieClip properties
-    //
-    /// These are properties not attached as genuine members to the MovieClip
-    /// object. Currently they include DisplayList members and TextField
-    /// variables.
-    //
-    /// TODO: work out if there is a better way of doing this, such as
-    /// attaching special properties as real members.
-    bool getMovieClipProperty(string_table::key name, as_value& val);
+    /// Get TextField variables
+    //
+    /// TODO: this is unlikely to be the best way of doing it, and it would
+    /// simplify things if this function could be dropped.
+    bool getTextFieldVariables(string_table::key name, as_value& val);
+
+    /// Search for a named object on the DisplayList
+    //
+    /// These are properties, but not attached as genuine members to the
+    /// MovieClip object. They take priority over DisplayObject magic
+    /// properties and inherited properties, but not over own properties.
+    //
+    /// @param name     The name of the object. This function handles
+    ///                 case-sensitivity.
+    /// @return         The object if found, otherwise 0.
+    DisplayObject* getDisplayListObject(string_table::key name);
 
     // See dox in as_object.h
     virtual bool set_member(string_table::key name, const as_value& val,

=== modified file 'libcore/TextField.h'
--- a/libcore/TextField.h       2009-10-12 09:42:13 +0000
+++ b/libcore/TextField.h       2009-10-13 05:58:20 +0000
@@ -91,21 +91,6 @@
                typeInput
        };
 
-       static void htmlptag() {
-
-       }
-       
-       typedef void dotag ();
-    typedef std::map<std::string,dotag*> HTMLTags;
-       
-       HTMLTags _htmltags;
-
-       void maptags()
-       {
-               _htmltags["P"] = htmlptag;
-               //_htmltags.insert(std::make_pair("P",ptag*()));
-       }
-
     /// Constructs a TextField as specified in a DefineEditText tag.
        TextField(DisplayObject* parent, const SWF::DefineEditTextTag& def);
 
@@ -126,8 +111,7 @@
        //
        /// @param x x-coordinate
        /// @param y y-coordinate
-       InteractiveObject* topmostMouseEntity(boost::int32_t x,
-            boost::int32_t y);
+       InteractiveObject* topmostMouseEntity(boost::int32_t x, boost::int32_t 
y);
 
        // Text fields need to handle cxform specially 
        virtual cxform get_world_cxform() const;
@@ -181,17 +165,17 @@
         return m_cursor;
     }
 
-       /// /brief get a std::pair of size_t with start/end of selection
+       /// Get a std::pair of size_t with start/end of selection
     const std::pair<size_t, size_t>& getSelection() const {
         return _selection;
     }
 
-    /// /brief Replace the current selection with the new text.
+    /// Replace the current selection with the new text.
        //
        /// @param replace String to replace the current selection
     void replaceSelection(const std::string& replace);
 
-    /// /brief Set the current selection
+    /// Set the current selection
     //
     /// @param start    The index of the beginning of the selection.
     /// @param end      The index of the end of the selection.
@@ -200,7 +184,14 @@
     /// end is never less than start.
     void setSelection(int start, int end);
 
+    /// Override of DisplayObject::setWidth
+    //
+    /// TextField width currently behaves differently from MovieClip width
     virtual void setWidth(double width);
+    
+    /// Override of DisplayObject::setHeight
+    //
+    /// TextField height currently behaves differently from MovieClip height
     virtual void setHeight(double height);
 
        /// Draw the dynamic string.
@@ -208,7 +199,7 @@
 
        void add_invalidated_bounds(InvalidatedRanges& ranges, bool force);
 
-       /// \brief Get bounding SWFRect of this TextField
+       /// Get bounding SWFRect of this TextField
        virtual SWFRect getBounds() const
        {
                return _bounds;
@@ -220,7 +211,7 @@
        /// Return true if the 'background' should be drawn
        bool getDrawBackground() const;
 
-       /// \brief Specify wheter to draw the background
+       /// Specify whether to draw the background
        //
        /// @param draw If true the background of this TextField will be drawn
        void setDrawBackground(bool draw);
@@ -228,38 +219,38 @@
        /// \brief Return color of the background
        rgba getBackgroundColor() const;
 
-       /// \brief Set color of the background
+       /// Set color of the background
        //
        /// Use setDrawBackground to actually use this value.
        /// @param col RGBA Object with color information. TextField
        ///     background will be drawn in this color
        void setBackgroundColor(const rgba& col);
 
-       /// \brief Return true if this TextField should have it's border visible
+       /// Return true if this TextField should have its border visible
        bool getDrawBorder() const;
 
-       /// \brief Specify whether to draw the border
+       /// Specify whether to draw the border
        //
        /// @param draw If true the border of this TextField will be drawn
        void setDrawBorder(bool draw);
 
-       /// \brief Return color of the border
+       /// Return color of the border
        rgba getBorderColor() const;
 
-       /// \brief Set color of the border
+       /// Set color of the border
        //
        /// Use setDrawBorder to actually use this value.
        /// @param col RGBA Object with color information. TextField border
        ///     will be drawn in this color.
        void setBorderColor(const rgba& col);
 
-       /// \brief Return color of the text
+       /// Return color of the text
        const rgba& getTextColor() const 
        {
                return _textColor;
        }
 
-       /// \brief Set color of the text
+       /// Set color of the text
        //
        /// @param col RGBA Object with color information. Text in this 
TextField
        ///     will be displayed in this color.
@@ -272,12 +263,12 @@
                return _embedFonts;
        }
 
-    /// \brief Get the current maxChars setting of the TextField
+    /// Get the current maxChars setting of the TextField
     boost::int32_t maxChars() const {
         return _maxChars;
     }
 
-    /// \brief Set the current maxChars setting of the TextField
+    /// Set the current maxChars setting of the TextField
        //
        /// @param max The maximum number of characters that can be
        ///     input by the user (Does not restrict Scripts)
@@ -285,12 +276,12 @@
         _maxChars = max;
     }
 
-    /// \brief Get the current multiline setting of the TextField
+    /// Get the current multiline setting of the TextField
     bool multiline() const {
         return _multiline;
     }
 
-    /// \brief Set the current multiline setting of the TextField
+    /// Set the current multiline setting of the TextField
        //
        /// @param b If true "Enter" key will be recognized (Does not
        ///     restrict Scripts)
@@ -298,12 +289,12 @@
         _multiline = b;
     }
        
-    /// \brief Get the current password setting of the TextField
+    /// Get the current password setting of the TextField
     bool password() const {
         return _password;
     }
 
-    /// \brief Set the current password setting of the TextField
+    /// Set the current password setting of the TextField
        //
        /// @param b If true characters in the TextField will be displayed
        ///     as (*)
@@ -317,23 +308,23 @@
        /// @param use
        void setEmbedFonts(bool use);
 
-       /// \brief Get autoSize value 
+       /// Get autoSize value 
        AutoSizeValue getAutoSize() const
        {
                return _autoSize;
        }
 
-       /// \brief Return text TextAlignment
+       /// Return text TextAlignment
     TextAlignment getTextAlignment();
 
-       /// \brief Set autoSize value 
+       /// Set autoSize value 
        //
        /// @param val
        ///     The AutoSizeValue to use
        ///
        void setAutoSize(AutoSizeValue val);
 
-       /// \brief Parse autoSize string value
+       /// Parse autoSize string value
        //
        /// @param val
        ///     Auto size value as a string (one of none, left, center, right)
@@ -342,7 +333,7 @@
        ///
        static AutoSizeValue parseAutoSizeValue(const std::string& val);
 
-       /// \brief Return autoSize value as a string
+       /// Return autoSize value as a string
        //
        /// @param val
        ///     Auto size value 
@@ -352,20 +343,20 @@
        ///
        static const char* autoSizeValueName(AutoSizeValue val);
 
-       /// \brief Set type (input or dynamic)
+       /// Set type (input or dynamic)
        //
        /// @param val
        ///     The TypeValue to use, no-op if typeInvalid.
        ///
        void setType(TypeValue val) { if (val != typeInvalid) _type=val; }
 
-       /// \brief Get type (input, dynamic or invalid)
+       /// Get type (input, dynamic or invalid)
        TypeValue getType() const
        {
                return _type;
        }
 
-       /// \brief Return true if this TextField is read-only
+       /// Return true if this TextField is read-only
        bool isReadOnly() const { return _type != typeInput; }
 
        /// Parse type string value
@@ -395,7 +386,7 @@
                return _wordWrap;
        }
 
-       /// \brief Set wordWrap parameter 
+       /// Set wordWrap parameter 
        //
        /// @param on
        ///     If true text hitting bounding box limits will continue
@@ -405,14 +396,12 @@
        ///
        void setWordWrap(bool on);
 
-       /// \brief
        /// Return true if HTML markup in text should be rendered.
-       ///
        bool doHtml() const {
                return _html;
        }
 
-       /// \brief Set html parameter
+       /// Set html parameter
        //
        /// @param on
        ///     If true HTML tags in the text will be parsed and rendered
@@ -420,7 +409,7 @@
                _html = on;
        }
 
-       /// \brief Return true if the TextField text is selectable
+       /// Return true if the TextField text is selectable
        bool isSelectable() const
        {
                return _selectable;

=== modified file 'libcore/asobj/flash/display/MovieClip_as.cpp'
--- a/libcore/asobj/flash/display/MovieClip_as.cpp      2009-10-12 12:15:41 
+0000
+++ b/libcore/asobj/flash/display/MovieClip_as.cpp      2009-10-13 07:32:05 
+0000
@@ -103,9 +103,6 @@
     as_value movieclip_meth(const fn_call& fn);
     as_value movieclip_getSWFVersion(const fn_call& fn);
     as_value movieclip_loadVariables(const fn_call& fn);
-    as_value movieclip_currentFrame(const fn_call& fn);
-    as_value movieclip_totalFrames(const fn_call& fn);
-    as_value movieclip_framesLoaded(const fn_call& fn);
     as_value movieclip_dropTarget(const fn_call& fn);
 
     // =============================================
@@ -239,20 +236,6 @@
     if (!o.get_parent()) o.init_member("$version",
             getVM(o).getPlayerVersion(), 0); 
 
-    as_c_function_ptr gettersetter;
-
-    gettersetter = movieclip_currentFrame;
-    o.init_property(NSV::PROP_uCURRENTFRAME, gettersetter, gettersetter);
-
-    gettersetter = movieclip_totalFrames;
-    o.init_property(NSV::PROP_uTOTALFRAMES, gettersetter, gettersetter);
-
-    gettersetter = movieclip_framesLoaded;
-    o.init_property(NSV::PROP_uFRAMESLOADED, gettersetter, gettersetter);
-
-    gettersetter = movieclip_dropTarget;
-    o.init_property(NSV::PROP_uDROPTARGET, gettersetter, gettersetter);
-
 }
 
 as_object*
@@ -638,10 +621,8 @@
     boost::intrusive_ptr<MovieClip> movieclip = 
         ensureType<MovieClip>(fn.this_ptr);
 
-    if (fn.nargs != 2)
-    {
-        if (fn.nargs < 2)
-        {
+    if (fn.nargs != 2) {
+        if (fn.nargs < 2) {
             IF_VERBOSE_ASCODING_ERRORS(
                 log_aserror(_("createEmptyMovieClip needs "
                     "2 args, but %d given,"
@@ -650,15 +631,12 @@
             );
             return as_value();
         }
-        else
-        {
-            IF_VERBOSE_ASCODING_ERRORS(
-                log_aserror(_("createEmptyMovieClip takes "
-                    "2 args, but %d given, discarding"
-                    " the excess"),
-                    fn.nargs);
-            )
-        }
+        IF_VERBOSE_ASCODING_ERRORS(
+            log_aserror(_("createEmptyMovieClip takes "
+                "2 args, but %d given, discarding"
+                " the excess"),
+                fn.nargs);
+        )
     }
 
     // Unlike other MovieClip methods, the depth argument of an empty movie 
clip
@@ -1239,19 +1217,21 @@
 {
     boost::intrusive_ptr<MovieClip> mc = ensureType<MovieClip>(fn.this_ptr);
 
-    if (fn.nargs < 1)
-    {
+    if (fn.nargs < 1 || fn.arg(0).is_undefined()) {
         IF_VERBOSE_ASCODING_ERRORS(
-        log_aserror("MovieClip.getInstanceAtDepth(): missing depth argument");
+        log_aserror("MovieClip.getInstanceAtDepth(): missing or "
+            "undefined depth argument");
         );
         return as_value();
     }
 
-    int depth = fn.arg(0).to_int();
+    const int depth = fn.arg(0).to_int();
+
     boost::intrusive_ptr<DisplayObject> ch = 
mc->getDisplayObjectAtDepth(depth);
  
     // we want 'undefined', not 'null'
     if (!ch) return as_value();
+
     return as_value(ch.get());
 }
 
@@ -2477,42 +2457,6 @@
 
 
 as_value
-movieclip_currentFrame(const fn_call& fn)
-{
-    boost::intrusive_ptr<MovieClip> ptr = ensureType<MovieClip>(fn.this_ptr);
-
-    return as_value(std::min(ptr->get_loaded_frames(),
-                ptr->get_current_frame() + 1));
-}
-
-as_value
-movieclip_totalFrames(const fn_call& fn)
-{
-    boost::intrusive_ptr<MovieClip> ptr = 
-        ensureType<MovieClip>(fn.this_ptr);
-
-    return as_value(ptr->get_frame_count());
-}
-
-as_value
-movieclip_framesLoaded(const fn_call& fn)
-{
-    boost::intrusive_ptr<MovieClip> ptr = 
-        ensureType<MovieClip>(fn.this_ptr);
-
-    return as_value(ptr->get_loaded_frames());
-}
-
-as_value
-movieclip_dropTarget(const fn_call& fn)
-{
-    boost::intrusive_ptr<MovieClip> ptr = 
-        ensureType<MovieClip>(fn.this_ptr);
-
-    return ptr->getDropTarget();
-}
-
-as_value
 movieclip_transform(const fn_call& fn)
 {
     boost::intrusive_ptr<MovieClip> ptr = ensureType<MovieClip>(fn.this_ptr);

=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2009-10-07 09:30:57 +0000
+++ b/libcore/vm/ASHandlers.cpp 2009-10-13 07:32:05 +0000
@@ -49,6 +49,7 @@
 #include "StringPredicates.h" 
 #include "GnashNumeric.h"
 #include "Global_as.h"
+#include "DisplayObject.h"
 
 #include <string>
 #include <vector>
@@ -368,49 +369,6 @@
     return handlers;
 }
 
-/// @todo: make properties available outside, for
-///        example for Machine.cpp
-/// @todo: consider sorting named strings so that
-///        the first 22 or more elements have
-///        the corresponding property number (drops
-///        one level of indirection).
-///
-static const string_table::key&
-propertyKey(unsigned int val)
-{
-    static const string_table::key invalidKey=0;
-
-    if ( val > 21u ) return invalidKey;
-
-    static const string_table::key props[22] = {
-        NSV::PROP_uX, // 0
-        NSV::PROP_uY, // 1
-        NSV::PROP_uXSCALE, // 2
-        NSV::PROP_uYSCALE, // 3
-        NSV::PROP_uCURRENTFRAME, // 4
-        NSV::PROP_uTOTALFRAMES, // 5
-        NSV::PROP_uALPHA, // 6
-        NSV::PROP_uVISIBLE, // 7
-        NSV::PROP_uWIDTH, // 8
-        NSV::PROP_uHEIGHT, // 9
-        NSV::PROP_uROTATION, // 10
-        NSV::PROP_uTARGET, // 11
-        NSV::PROP_uFRAMESLOADED, // 12
-        NSV::PROP_uNAME, // 13
-        NSV::PROP_uDROPTARGET, // 14
-        NSV::PROP_uURL, // 15
-        NSV::PROP_uHIGHQUALITY, // 16
-        NSV::PROP_uFOCUSRECT, // 17
-        NSV::PROP_uSOUNDBUFTIME, // 18
-        NSV::PROP_uQUALITY, // 19
-        NSV::PROP_uXMOUSE, // 20
-        NSV::PROP_uYMOUSE // 21
-    };
-
-    return props[val];
-}
-
-
 const SWFHandlers&
 SWFHandlers::instance()
 {
@@ -421,8 +379,6 @@
 void
 SWFHandlers::execute(ActionType type, ActionExec& thread) const
 {
-//    It is very heavy operation
-//    if ( _handlers[type].getName() == "unsupported" ) return false;
     try {
         get_handlers()[type].execute(thread);
     }
@@ -1100,21 +1056,8 @@
     unsigned int prop_number =
         static_cast<unsigned int>(env.top(0).to_number());
 
-    if (target)
-    {
-        string_table::key propKey = propertyKey(prop_number);
-        if ( propKey == 0 )
-        {
-            log_error(_("invalid property query, property "
-                "number %d"), prop_number);
-            env.top(1) = as_value();
-        }
-        else
-        {
-            as_value val;
-            target->get_member(propKey, &val);
-            env.top(1) = val;
-        }
+    if (target) {
+        getIndexedProperty(prop_number, *target, env.top(1));
     }
     else
     {
@@ -1141,20 +1084,8 @@
 
     as_value prop_val = env.top(0);
 
-    if (target)
-    {
-        string_table::key propKey = propertyKey(prop_number);
-        if ( propKey == 0 )
-        {
-            // Malformed SWF ? (don't think this is possible to do with 
syntactically valid ActionScript)
-            IF_VERBOSE_MALFORMED_SWF (
-            log_swferror(_("invalid set_property, property number %d"), 
prop_number);
-            )
-        }
-        else
-        {
-            target->set_member(propKey, prop_val);
-        }
+    if (target) {
+        setIndexedProperty(prop_number, *target, prop_val);
     }
     else
     {

=== modified file 'testsuite/actionscript.all/MovieClip.as'
--- a/testsuite/actionscript.all/MovieClip.as   2009-10-12 09:12:02 +0000
+++ b/testsuite/actionscript.all/MovieClip.as   2009-10-13 08:12:25 +0000
@@ -451,7 +451,7 @@
 check(!MovieClip.prototype.hasOwnProperty("_rotation"));
 
 check_equals(typeof(mc._totalframes), 'number');
-xcheck(!mc.hasOwnProperty("_totalframes"));
+check(!mc.hasOwnProperty("_totalframes"));
 check(!mc.__proto__.hasOwnProperty("_totalframes"));
 check(!MovieClip.prototype.hasOwnProperty("_totalframes"));
 
@@ -461,7 +461,7 @@
 check(!mc.hasOwnProperty("_url"));
 check(!mc.hasOwnProperty("_soundbuftime"));
 check(!mc.hasOwnProperty("_focusrect"));
-xcheck(!mc.hasOwnProperty("_framesloaded"));
+check(!mc.hasOwnProperty("_framesloaded"));
 check(!mc.hasOwnProperty("_lockroot"));
 check(!mc.hasOwnProperty("_highquality"));
 #endif //if OUTPUT_VERSION >= 6
@@ -2000,7 +2000,7 @@
        setvariable
 };
 // setMember did set the prop, didn't call the setter
-xcheck_equals(propinspect, 20);
+check_equals(propinspect, 20);
 #endif //MING_SUPPORTS_ASM
 
 createEmptyMovieClip('mc', 10);

=== modified file 'testsuite/actionscript.all/TextField.as'
--- a/testsuite/actionscript.all/TextField.as   2009-10-06 14:21:50 +0000
+++ b/testsuite/actionscript.all/TextField.as   2009-10-13 07:31:47 +0000
@@ -601,11 +601,18 @@
 check( ! tf.__proto__.hasOwnProperty('_soundbuftime') ); 
 xcheck_equals(tf._soundbuftime, 5); // the default is 5, it seems
 
-// These seem to be only MovieClip properties.
-
+// These seem to be only valid for MovieClips, but they are still read-only
 check_equals(typeof(tf._currentframe), 'undefined');
+tf._currentframe = "6";
+check_equals(tf._currentframe, undefined);
+
 check_equals(typeof(tf._totalframes), 'undefined');
+tf._totalframes = 67;
+check_equals(tf._totalframes, undefined);
+
 check_equals(typeof(tf._framesloaded), 'undefined');
+tf._framesloaded = "hi";
+check_equals(tf._framesloaded, undefined);
 
 // Check TextField._focusrect
 check(tf._focusrect !== 'null');
@@ -1139,11 +1146,11 @@
 //------------------------------------------------------------
 
 #if OUTPUT_VERSION == 6
-     check_totals(499);
+     check_totals(502);
 #elif OUTPUT_VERSION == 7
- check_totals(505);
+ check_totals(508);
 #elif OUTPUT_VERSION == 8
- check_totals(506);
+ check_totals(509);
 #endif
 
 #endif

=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING  2009-10-12 12:55:10 +0000
+++ b/testsuite/swfdec/PASSING  2009-10-13 08:09:53 +0000
@@ -740,6 +740,9 @@
 movieclip-lockroot-loadmovie-7.swf:84ad9218797251db3ee79f9241f27b67
 movieclip-lockroot-loadmovie-8.swf:3ac7430bf84185e34aee32b2d2394600
 movieclip-property-priorities-5.swf:21ffe3baf551c2dea5d2e04db214ff7f
+movieclip-property-priorities-6.swf:9427268276bf314a62c4c05198e678e6
+movieclip-property-priorities-7.swf:93b473f965fc9d74742eebb282ce1398
+movieclip-property-priorities-8.swf:ff29d6b0d091084d8003508bcf65dac6
 movieclip-references-5.swf:1a9faa42d479cff63da56135c1b298aa
 movieclip-references-6.swf:d3cc27ec41e9368c21f27fee48027b89
 movieclip-set-prototype-5.swf:99235a738d69d9c78fa2bc5d355c6dae


reply via email to

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