[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10257: Stub unimplemented Video pro
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10257: Stub unimplemented Video properties and modify the prototype when there |
Date: |
Tue, 11 Nov 2008 14:26:59 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10257
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Tue 2008-11-11 14:26:59 +0100
message:
Stub unimplemented Video properties and modify the prototype when there
is an embedded Video stream.
Rearrange TextField.cpp.
modified:
libcore/TextField.cpp
libcore/TextField.h
libcore/Video.cpp
testsuite/actionscript.all/Video.as
testsuite/misc-ming.all/NetStream-SquareTest.c
------------------------------------------------------------
revno: 10256.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-11-11 11:50:09 +0100
message:
More tests for Video interface.
modified:
testsuite/actionscript.all/Video.as
------------------------------------------------------------
revno: 10256.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-11-11 13:30:34 +0100
message:
More tests for Video properties. Add deblocking, smoothing, width and
height properties to prototype only on construction of embedded Video
stream.
modified:
libcore/Video.cpp
testsuite/actionscript.all/Video.as
testsuite/misc-ming.all/NetStream-SquareTest.c
------------------------------------------------------------
revno: 10256.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-11-11 13:45:13 +0100
message:
Correct Video test totals.
modified:
testsuite/actionscript.all/Video.as
------------------------------------------------------------
revno: 10256.1.4
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-11-11 13:51:35 +0100
message:
Rearrange TextField.cpp to keep class and AS interface functions together.
modified:
libcore/TextField.cpp
libcore/TextField.h
libcore/Video.cpp
=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp 2008-11-11 08:43:14 +0000
+++ b/libcore/TextField.cpp 2008-11-11 12:51:35 +0000
@@ -74,634 +74,49 @@
namespace gnash {
// Forward declarations
-static as_value textfield_variable(const fn_call& fn);
-static as_value textfield_setTextFormat(const fn_call& fn);
-static as_value textfield_getTextFormat(const fn_call& fn);
-static as_value textfield_setNewTextFormat(const fn_call& fn);
-static as_value textfield_getNewTextFormat(const fn_call& fn);
-
-static as_value textfield_getDepth(const fn_call& fn);
-static as_value textfield_getFontList(const fn_call& fn);
-static as_value textfield_removeTextField(const fn_call& fn);
-static as_value textfield_replaceSel(const fn_call& fn);
-static as_value textfield_replaceText(const fn_call& fn);
-
-static as_object* getTextFieldInterface(VM& vm);
-
-static as_value textfield_background(const fn_call& fn);
-static as_value textfield_border(const fn_call& fn);
-static as_value textfield_backgroundColor(const fn_call& fn);
-static as_value textfield_borderColor(const fn_call& fn);
-static as_value textfield_text(const fn_call& fn);
-static as_value textfield_textColor(const fn_call& fn);
-static as_value textfield_embedFonts(const fn_call& fn);
-static as_value textfield_autoSize(const fn_call& fn);
-static as_value textfield_type(const fn_call& fn);
-static as_value textfield_wordWrap(const fn_call& fn);
-static as_value textfield_html(const fn_call& fn);
-static as_value textfield_selectable(const fn_call& fn);
-static as_value textfield_length(const fn_call& fn);
-static as_value textfield_textWidth(const fn_call& fn);
-static as_value textfield_textHeight(const fn_call& fn);
-
-
-//
-// TextField interface functions
-//
-
-static as_value
-textfield_variable(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
-
- if (!fn.nargs)
- {
- // Getter
- const std::string& varName = text->getVariableName();
- // An empty variable name returns null.
- if (varName.empty()) {
- as_value null;
- null.set_null();
- return null;
- }
- return as_value(varName);
- }
-
- // Setter
- const as_value& varName = fn.arg(0);
- if (varName.is_undefined() || varName.is_null()) {
- text->set_variable_name("");
- }
- else text->set_variable_name(varName.to_string());
-
- return as_value();
-
-}
-
-
-static as_value
-textfield_getDepth(const fn_call& fn)
-{
- // TODO: make this a character::getDepth_method function...
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
-
- int n = text->get_depth();
-
- return as_value(n);
-
-}
-
-static as_value
-textfield_getFontList(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
- UNUSED(text);
-
- LOG_ONCE(log_unimpl("TextField.getFontList()"));
-
- return as_value();
-}
-
-static as_value
-textfield_getNewTextFormat(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
- UNUSED(text);
-
- LOG_ONCE(log_unimpl("TextField.getNewTextFormat()"));
-
- return as_value();
-}
-
-static as_value
-textfield_getTextFormat(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
-
- boost::intrusive_ptr<TextFormat> tf = new TextFormat();
- tf->alignSet(text->getTextAlignment());
- tf->sizeSet(text->getFontHeight());
- tf->indentSet(text->getIndent());
- tf->blockIndentSet(text->getBlockIndent());
- tf->leadingSet(text->getLeading());
- tf->leftMarginSet(text->getLeftMargin());
- tf->rightMarginSet(text->getRightMargin());
- tf->colorSet(text->getTextColor());
- tf->underlinedSet(text->getUnderlined());
-
- const Font* font = text->getFont();
- if (font)
- {
- tf->fontSet(font->get_name());
- tf->italicedSet(font->isItalic());
- tf->boldSet(font->isBold());
- }
-
- // TODO: add font color and some more
-
- LOG_ONCE(
- log_unimpl("TextField.getTextFormat() discards url, target, "
- "tabStops, bullet and display")
- );
-
- return as_value(tf.get());
-}
-
-static as_value
-textfield_setTextFormat(const fn_call& fn)
-{
- //GNASH_REPORT_FUNCTION;
-
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
-
- if ( ! fn.nargs )
- {
- IF_VERBOSE_ASCODING_ERRORS(
- std::stringstream ss; fn.dump_args(ss);
- log_aserror("TextField.setTextFormat(%s) : %s", ss.str(),
- _("missing arg"))
- );
- return as_value();
- }
- else if ( fn.nargs > 2 )
- {
- std::stringstream ss; fn.dump_args(ss);
- log_debug("TextField.setTextFormat(%s) : args past the first are "
- "unhandled by Gnash", ss.str());
- }
-
- as_object* obj = fn.arg(0).to_object().get();
- if ( ! obj )
- {
- IF_VERBOSE_ASCODING_ERRORS(
- std::stringstream ss; fn.dump_args(ss);
- log_aserror("TextField.setTextFormat(%s) : %s", ss.str(), _("first
argument is not an object"))
- );
- return as_value();
- }
-
- TextFormat* tf = dynamic_cast<TextFormat*>(obj);
- if ( ! tf )
- {
- IF_VERBOSE_ASCODING_ERRORS(
- std::stringstream ss; fn.dump_args(ss);
- log_aserror("TextField.setTextFormat(%s) : %s", ss.str(),
- _("first argument is not a TextFormat"))
- );
- return as_value();
- }
-
- if ( tf->alignDefined() ) text->setAlignment(tf->align());
- if ( tf->sizeDefined() ) text->setFontHeight(tf->size()); // keep twips
- if ( tf->indentDefined() ) text->setIndent(tf->indent());
- if ( tf->blockIndentDefined() ) text->setBlockIndent(tf->blockIndent());
- if ( tf->leadingDefined() ) text->setLeading(tf->leading());
- if ( tf->leftMarginDefined() ) text->setLeftMargin(tf->leftMargin());
- if ( tf->rightMarginDefined() ) text->setRightMargin(tf->rightMargin());
- if ( tf->colorDefined() ) text->setTextColor(tf->color());
- if ( tf->underlinedDefined() ) text->setUnderlined(tf->underlined());
-
- if ( tf->fontDefined() )
- {
- const std::string& fontName = tf->font();
- if ( ! fontName.empty() )
- {
- bool bold = tf->bold();
- bool italic = tf->italiced();
-
- // NOTE: should query movie-private font lib, not global-shared one
- movie_instance* mi = text->get_root();
- assert(mi);
- movie_definition* md = mi->get_movie_definition();
- assert(md);
- Font* f = md->get_font(fontName, bold, italic);
- if ( ! f ) f = fontlib::get_font(fontName, bold, italic);
- text->setFont( f );
- }
- }
-
- // TODO: add font color and some more
-
- LOG_ONCE( log_unimpl("TextField.setTextFormat() discards url, target,
tabStops, bullet and display") );
-
- return as_value();
-
-}
-
-static as_value
-textfield_setNewTextFormat(const fn_call& fn)
-{
- //boost::intrusive_ptr<TextField> text =
ensureType<TextField>(fn.this_ptr);
- //UNUSED(text);
-
- LOG_ONCE( log_unimpl("TextField.setNewTextFormat(), we'll delegate to
setTextFormat") );
- return textfield_setTextFormat(fn);
-
- //return as_value();
-}
-
-static as_value
-textfield_password(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
-
- LOG_ONCE(log_unimpl("TextField.password"));
-
- if (!fn.nargs)
- {
- // Getter
- return as_value(text->password());
- }
- // Setter
- text->password(fn.arg(0).to_bool());
- return as_value();
-}
-
-static as_value
-textfield_multiline(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
-
- LOG_ONCE(log_unimpl("TextField.multiline"));
-
- if (!fn.nargs) {
- // Getter
- return as_value(text->multiline());
- }
- // Setter
- text->multiline(fn.arg(0).to_bool());
- return as_value();
-}
-
-static as_value
-textfield_restrict(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
- UNUSED(text);
-
- LOG_ONCE (log_unimpl("TextField.restrict"));
-
- return as_value();
-}
-
-static as_value
-textfield_bottomScroll(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
- UNUSED(text);
-
- LOG_ONCE (log_unimpl("TextField.bottomScroll"));
-
- return as_value();
-}
-
-static as_value
-textfield_maxhscroll(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
- UNUSED(text);
-
- LOG_ONCE (log_unimpl("TextField.maxhscroll"));
-
- return as_value();
-}
-
-/// TextField.maxChars().
-//
-/// This does not limit the length of the text, but rather the
-/// number of characters that can be entered in the TextField.
-//
-/// Returns null when the value is 0.
-static as_value
-textfield_maxChars(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
-
- LOG_ONCE(log_unimpl("TextField.maxChars"));
-
- if (!fn.nargs)
- {
- boost::int32_t maxChars = text->maxChars();
- if (maxChars == 0)
- {
- as_value null;
- null.set_null();
- return null;
- }
- return as_value(maxChars);
- }
- // Setter
- text->maxChars(fn.arg(0).to_int());
- return as_value();
-}
-
-static as_value
-textfield_text(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
- if (!fn.nargs)
- {
- // Getter
- //
- // FIXME: should return text without HTML tags.
- return as_value(ptr->get_text_value());
- }
-
- // Setter
- int version = ptr->getVM().getSWFVersion();
- ptr->setTextValue(
- utf8::decodeCanonicalString(fn.arg(0).to_string(), version));
-
- return as_value();
-}
-
-static as_value
-textfield_htmlText(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
- if (!fn.nargs)
- {
- // Getter
- return as_value(ptr->get_text_value());
- }
-
- // Setter
- int version = ptr->getVM().getSWFVersion();
- ptr->setTextValue(
- utf8::decodeCanonicalString(fn.arg(0).to_string(), version));
-
- return as_value();
-}
-
-
-static as_value
-textfield_replaceSel(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
- UNUSED(text);
-
- LOG_ONCE (log_unimpl("TextField.replaceSel()"));
-
- return as_value();
-}
-
-static as_value
-textfield_scroll(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
- UNUSED(text);
-
- LOG_ONCE (log_unimpl("TextField.scroll()"));
-
- return as_value();
-}
-
-static as_value
-textfield_hscroll(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
- UNUSED(text);
-
- LOG_ONCE (log_unimpl("TextField.hscroll()"));
-
- return as_value();
-}
-
-static as_value
-textfield_maxscroll(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
- UNUSED(text);
-
- LOG_ONCE (log_unimpl("TextField.maxscroll"));
-
- return as_value();
-}
-
-static as_value
-textfield_replaceText(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
- UNUSED(text);
-
- LOG_ONCE(log_unimpl("TextField.replaceText()"));
-
- return as_value();
-}
-
-static as_value
-textfield_removeTextField(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
-
- text->removeTextField();
-
- LOG_ONCE(log_debug("TextField.removeTextField() TESTING"));
-
- return as_value();
-}
-
-/// This is called for 'new TextField()' only
-static as_value
-textfield_ctor(const fn_call& /* fn */)
-{
- as_object* proto = getTextFieldInterface(VM::get());
-
- // We should attach more properties to the prototype on first
- // instantiation.
- // TODO: this also attaches properties to the SWF5 prototype but makes
- // them invisible with prop flags. Is this correct?
- TextField::attachTextFieldInstanceProperties(*proto);
-
- boost::intrusive_ptr<as_object> obj = new as_object(proto);
-
- return as_value(obj);
-}
-
-//
-// TextField interface initialization
-//
-
-static void
-attachTextFieldInterface(as_object& o)
-{
- boost::intrusive_ptr<builtin_function> getset;
-
- // TextField is an AsBroadcaster
- AsBroadcaster::initialize(o);
-
- int propFlags = as_prop_flags::dontDelete
- |as_prop_flags::dontEnum
- |as_prop_flags::readOnly
- |as_prop_flags::isProtected;
-
- // Parent seems to not be a normal property
- getset = new builtin_function(&character::parent_getset, NULL);
- o.init_property(NSV::PROP_uPARENT, *getset, *getset);
-
- // Target seems to not be a normal property
- getset = new builtin_function(&character::target_getset, NULL);
- o.init_property(NSV::PROP_uTARGET, *getset, *getset);
-
- // _name should be a property of the instance, not the prototype
- getset = new builtin_function(&character::name_getset, NULL);
- o.init_property(NSV::PROP_uNAME, *getset, *getset);
-
- o.init_property(NSV::PROP_uXMOUSE,
- character::xmouse_get, character::xmouse_get, propFlags);
- o.init_property(NSV::PROP_uYMOUSE,
- character::ymouse_get, character::ymouse_get, propFlags);
- o.init_property(NSV::PROP_uXSCALE,
- character::xscale_getset, character::xscale_getset);
- o.init_property(NSV::PROP_uYSCALE,
- character::yscale_getset, character::yscale_getset);
- // Standard flags.
- const int flags = as_prop_flags::dontDelete
- |as_prop_flags::dontEnum;
-
- // SWF6 or higher
- const int swf6Flags = flags | as_prop_flags::onlySWF6Up;
-
- o.init_member("setTextFormat",
- new builtin_function(textfield_setTextFormat), swf6Flags);
- o.init_member("getTextFormat",
- new builtin_function(textfield_getTextFormat), swf6Flags);
- o.init_member("setNewTextFormat",
- new builtin_function(textfield_setNewTextFormat), swf6Flags);
- o.init_member("getNewTextFormat",
- new builtin_function(textfield_getNewTextFormat), swf6Flags);
- o.init_member("getNewTextFormat",
- new builtin_function(textfield_getNewTextFormat), swf6Flags);
- o.init_member("getDepth",
- new builtin_function(textfield_getDepth), swf6Flags);
- o.init_member("removeTextField",
- new builtin_function(textfield_removeTextField), swf6Flags);
- o.init_member("replaceSel",
- new builtin_function(textfield_replaceSel), swf6Flags);
-
- // SWF7 or higher
- const int swf7Flags = flags | as_prop_flags::onlySWF7Up;
-
- o.init_member("replaceText",
- new builtin_function(textfield_replaceText), swf7Flags);
-
-}
-
-void
-TextField::attachTextFieldInstanceProperties(as_object& o)
-{
- // Standard flags.
- const int flags = as_prop_flags::dontDelete
- |as_prop_flags::dontEnum;
-
- // SWF6 or higher
- const int swf6Flags = flags | as_prop_flags::onlySWF6Up;
-
- boost::intrusive_ptr<builtin_function> getset;
-
- // The following properties should only be attached to the prototype
- // on first textfield creation.
- o.init_property(NSV::PROP_TEXT_WIDTH,
- textfield_textWidth, textfield_textWidth);
- o.init_property(NSV::PROP_TEXT_HEIGHT,
- textfield_textHeight, textfield_textHeight);
-
- getset = new builtin_function(textfield_variable);
- o.init_property("variable", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_background);
- o.init_property("background", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_text);
- o.init_property("text", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_backgroundColor);
- o.init_property("backgroundColor", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_border);
- o.init_property("border", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_borderColor);
- o.init_property("borderColor", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_textColor);
- o.init_property("textColor", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_embedFonts);
- o.init_property("embedFonts", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_autoSize);
- o.init_property("autoSize", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_type);
- o.init_property("type", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_wordWrap);
- o.init_property("wordWrap", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_html);
- o.init_property("html", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_selectable);
- o.init_property("selectable", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_length);
- o.init_property("length", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_maxscroll);
- o.init_property("maxscroll", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_maxhscroll);
- o.init_property("maxhscroll", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_maxChars);
- o.init_property("maxChars", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_bottomScroll);
- o.init_property("bottomScroll", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_scroll);
- o.init_property("scroll", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_hscroll);
- o.init_property("hscroll", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_restrict);
- o.init_property("restrict", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_multiline);
- o.init_property("multiline", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_password);
- o.init_property("password", *getset, *getset, swf6Flags);
- getset = new builtin_function(textfield_htmlText);
- o.init_property("htmlText", *getset, *getset, swf6Flags);
-}
-
-
-static void
-attachTextFieldStaticMembers(as_object& o)
-{
- // Standard flags.
- const int flags = as_prop_flags::dontDelete
- |as_prop_flags::dontEnum;
-
- // SWF6 or higher
- const int swf6Flags = flags | as_prop_flags::onlySWF6Up;
-
- o.init_member("getFontList",
- new builtin_function(textfield_getFontList), swf6Flags);
-
-}
-
-/// This is called when a prototype should be added
-//
-/// @note This is called at different times, depending on the version.
-/// For SWF5 it is called only on first instantiation. For SWF6 it
-/// is called at the registration of _global.TextField.
-static as_object*
-getTextFieldInterface(VM& vm)
-{
- static boost::intrusive_ptr<as_object> proto;
-
- if ( proto == NULL )
- {
- if (vm.getSWFVersion() < 6) {
- /// The prototype for SWF5 is a simple as_object without
- /// toString() or valueOf().
- proto = new as_object();
- }
- else {
- proto = new as_object(getObjectInterface());
- vm.addStatic(proto.get());
- attachTextFieldInterface(*proto);
- }
-
- }
- return proto.get();
-}
-
-//
-// TextField class
-//
+namespace {
+ as_object* getTextFieldInterface(VM& vm);
+ void attachPrototypeProperties(as_object& proto);
+ void attachTextFieldStaticMembers(as_object& o);
+
+ as_value textfield_variable(const fn_call& fn);
+ as_value textfield_setTextFormat(const fn_call& fn);
+ as_value textfield_getTextFormat(const fn_call& fn);
+ as_value textfield_setNewTextFormat(const fn_call& fn);
+ as_value textfield_getNewTextFormat(const fn_call& fn);
+ as_value textfield_getDepth(const fn_call& fn);
+ as_value textfield_getFontList(const fn_call& fn);
+ as_value textfield_removeTextField(const fn_call& fn);
+ as_value textfield_replaceSel(const fn_call& fn);
+ as_value textfield_replaceText(const fn_call& fn);
+
+ as_value textfield_password(const fn_call& fn);
+ as_value textfield_ctor(const fn_call& fn);
+ as_value textfield_multiline(const fn_call& fn);
+ as_value textfield_scroll(const fn_call& fn);
+ as_value textfield_maxscroll(const fn_call& fn);
+ as_value textfield_maxhscroll(const fn_call& fn);
+ as_value textfield_maxChars(const fn_call& fn);
+ as_value textfield_bottomScroll(const fn_call& fn);
+ as_value textfield_hscroll(const fn_call& fn);
+ as_value textfield_htmlText(const fn_call& fn);
+ as_value textfield_restrict(const fn_call& fn);
+ as_value textfield_background(const fn_call& fn);
+ as_value textfield_border(const fn_call& fn);
+ as_value textfield_backgroundColor(const fn_call& fn);
+ as_value textfield_borderColor(const fn_call& fn);
+ as_value textfield_text(const fn_call& fn);
+ as_value textfield_textColor(const fn_call& fn);
+ as_value textfield_embedFonts(const fn_call& fn);
+ as_value textfield_autoSize(const fn_call& fn);
+ as_value textfield_type(const fn_call& fn);
+ as_value textfield_wordWrap(const fn_call& fn);
+ as_value textfield_html(const fn_call& fn);
+ as_value textfield_selectable(const fn_call& fn);
+ as_value textfield_length(const fn_call& fn);
+ as_value textfield_textWidth(const fn_call& fn);
+ as_value textfield_textHeight(const fn_call& fn);
+}
TextField::TextField(character* parent, const SWF::DefineEditTextTag& def,
int id)
@@ -814,7 +229,7 @@
// prototype.
// TODO: is it correct to do it here, or can some TextFields
// be constructed without attaching these?
- attachTextFieldInstanceProperties(*proto);
+ attachPrototypeProperties(*proto);
set_prototype(proto);
@@ -2359,300 +1774,7 @@
}
}
-static as_value
-textfield_background(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
-
- if ( fn.nargs == 0 ) // getter
- {
- return as_value(ptr->getDrawBackground());
- }
- else // setter
- {
- ptr->setDrawBackground(fn.arg(0).to_bool());
- }
-
- return as_value();
-}
-
-static as_value
-textfield_border(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
-
- if ( fn.nargs == 0 ) // getter
- {
- return as_value(ptr->getDrawBorder());
- }
- else // setter
- {
- ptr->setDrawBorder(fn.arg(0).to_bool());
- }
-
- return as_value();
-}
-
-static as_value
-textfield_backgroundColor(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
-
- if ( fn.nargs == 0 ) // getter
- {
- return as_value(ptr->getBackgroundColor().toRGB());
- }
- else // setter
- {
- rgba newColor;
- newColor.parseRGB(static_cast<boost::uint32_t>(fn.arg(0).to_int()));
- ptr->setBackgroundColor(newColor);
- }
-
- return as_value();
-}
-
-static as_value
-textfield_borderColor(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
-
- if ( fn.nargs == 0 ) // getter
- {
- return as_value(ptr->getBorderColor().toRGB());
- }
- else // setter
- {
- rgba newColor;
- newColor.parseRGB( static_cast<boost::uint32_t>(fn.arg(0).to_number())
);
- ptr->setBorderColor(newColor);
- }
-
- return as_value();
-}
-
-
-static as_value
-textfield_textColor(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
-
- if (!fn.nargs)
- {
- // Getter
- return as_value(ptr->getTextColor().toRGB());
- }
-
- // Setter
- rgba newColor;
- newColor.parseRGB(static_cast<boost::uint32_t>(fn.arg(0).to_number()));
- ptr->setTextColor(newColor);
-
- return as_value();
-}
-
-static as_value
-textfield_embedFonts(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
-
- if (!fn.nargs)
- {
- // Getter
- return as_value(ptr->getEmbedFonts());
- }
-
- // Setter
- ptr->setEmbedFonts( fn.arg(0).to_bool() );
- return as_value();
-}
-
-static as_value
-textfield_wordWrap(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
-
- if ( fn.nargs == 0 ) // getter
- {
- return as_value(ptr->doWordWrap());
- }
- else // setter
- {
- ptr->setWordWrap( fn.arg(0).to_bool() );
- }
-
- return as_value();
-}
-
-static as_value
-textfield_html(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
-
- if ( fn.nargs == 0 ) // getter
- {
- return as_value(ptr->doHtml());
- }
- else // setter
- {
- ptr->setHtml( fn.arg(0).to_bool() );
- }
-
- return as_value();
-}
-
-static as_value
-textfield_selectable(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
-
- if ( fn.nargs == 0 ) // getter
- {
- return as_value(ptr->isSelectable());
- }
- else // setter
- {
- ptr->setSelectable( fn.arg(0).to_bool() );
- }
-
- return as_value();
-}
-
-static as_value
-textfield_length(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
-
- if ( fn.nargs == 0 ) // getter
- {
- const std::string& s = ptr->get_text_value();
- return as_value(s.length()); // TOCHECK: utf-8 ?
- }
- else // setter
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("Attempt to set length property of TextField %s"),
- ptr->getTarget());
- );
- }
-
- return as_value();
-}
-
-static as_value
-textfield_textHeight(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
-
- if ( fn.nargs == 0 ) // getter
- {
- // Return the height, in pixels, of the text as laid out.
- // (I.e. the actual text content, not our defined
- // bounding box.)
- //
- // In local coords. Verified against Macromedia Flash.
- return as_value(TWIPS_TO_PIXELS(ptr->getTextBoundingBox().height()));
-
- }
- else // setter
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("Attempt to set read-only %s property of TextField "
- "%s"), "textHeight", ptr->getTarget());
- );
- }
-
- return as_value();
-}
-
-static as_value
-textfield_textWidth(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
-
- if ( fn.nargs == 0 ) // getter
- {
- // Return the width, in pixels, of the text as laid out.
- // (I.e. the actual text content, not our defined
- // bounding box.)
- //
- // In local coords. Verified against Macromedia Flash.
- return as_value(TWIPS_TO_PIXELS(ptr->getTextBoundingBox().width()));
-
- }
- else // setter
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("Attempt to set read-only %s property of TextField %s"),
- "textWidth", ptr->getTarget());
- );
- }
-
- return as_value();
-}
-
-static as_value
-textfield_autoSize(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
-
- if ( fn.nargs == 0 ) // getter
- {
- return ptr->autoSizeValueName(ptr->getAutoSize());
- }
- else // setter
- {
- const as_value& arg = fn.arg(0);
- if ( arg.is_bool() )
- {
- if ( arg.to_bool() ) // true == left
- {
- ptr->setAutoSize( TextField::autoSizeLeft );
- }
- else
- {
- ptr->setAutoSize( TextField::autoSizeNone );
- }
- }
- else
- {
- std::string strval = arg.to_string();
- TextField::AutoSizeValue val = ptr->parseAutoSizeValue(strval);
- //log_debug("%s => %d", strval, val);
- ptr->setAutoSize( val );
- }
- }
-
- return as_value();
-}
-
-static as_value
-textfield_type(const fn_call& fn)
-{
- boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
-
- if (!fn.nargs)
- {
- // getter
- return ptr->typeValueName(ptr->getType());
- }
-
- // setter
- const as_value& arg = fn.arg(0);
- std::string strval = arg.to_string();
- TextField::TypeValue val = ptr->parseTypeValue(strval);
-
- IF_VERBOSE_ASCODING_ERRORS(
- if ( val == TextField::typeInvalid )
- {
- log_aserror(_("Invalid value given to TextField.type: %s"),
strval);
- }
- );
- ptr->setType(val);
- return as_value();
-}
-
-/* public static */
+
TextField::AutoSizeValue
TextField::parseAutoSizeValue(const std::string& val)
{
@@ -2674,7 +1796,7 @@
}
-/* public static */
+
const char*
TextField::autoSizeValueName(AutoSizeValue val)
{
@@ -2693,7 +1815,7 @@
}
-/* public static */
+
TextField::TypeValue
TextField::parseTypeValue(const std::string& val)
{
@@ -2711,7 +1833,7 @@
}
-/* public static */
+
const char*
TextField::typeValueName(TypeValue val)
{
@@ -2819,6 +1941,897 @@
markCharacterReachable();
}
+/// TextField interface functions
+
+namespace {
+
+void
+attachPrototypeProperties(as_object& o)
+{
+ // Standard flags.
+ const int flags = as_prop_flags::dontDelete
+ |as_prop_flags::dontEnum;
+
+ // SWF6 or higher
+ const int swf6Flags = flags | as_prop_flags::onlySWF6Up;
+
+ boost::intrusive_ptr<builtin_function> getset;
+
+ // The following properties should only be attached to the prototype
+ // on first textfield creation.
+ o.init_property(NSV::PROP_TEXT_WIDTH,
+ textfield_textWidth, textfield_textWidth);
+ o.init_property(NSV::PROP_TEXT_HEIGHT,
+ textfield_textHeight, textfield_textHeight);
+
+ getset = new builtin_function(textfield_variable);
+ o.init_property("variable", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_background);
+ o.init_property("background", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_text);
+ o.init_property("text", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_backgroundColor);
+ o.init_property("backgroundColor", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_border);
+ o.init_property("border", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_borderColor);
+ o.init_property("borderColor", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_textColor);
+ o.init_property("textColor", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_embedFonts);
+ o.init_property("embedFonts", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_autoSize);
+ o.init_property("autoSize", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_type);
+ o.init_property("type", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_wordWrap);
+ o.init_property("wordWrap", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_html);
+ o.init_property("html", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_selectable);
+ o.init_property("selectable", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_length);
+ o.init_property("length", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_maxscroll);
+ o.init_property("maxscroll", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_maxhscroll);
+ o.init_property("maxhscroll", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_maxChars);
+ o.init_property("maxChars", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_bottomScroll);
+ o.init_property("bottomScroll", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_scroll);
+ o.init_property("scroll", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_hscroll);
+ o.init_property("hscroll", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_restrict);
+ o.init_property("restrict", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_multiline);
+ o.init_property("multiline", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_password);
+ o.init_property("password", *getset, *getset, swf6Flags);
+ getset = new builtin_function(textfield_htmlText);
+ o.init_property("htmlText", *getset, *getset, swf6Flags);
+}
+
+
+as_value
+textfield_background(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ return as_value(ptr->getDrawBackground());
+ }
+ else // setter
+ {
+ ptr->setDrawBackground(fn.arg(0).to_bool());
+ }
+
+ return as_value();
+}
+
+as_value
+textfield_border(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ return as_value(ptr->getDrawBorder());
+ }
+ else // setter
+ {
+ ptr->setDrawBorder(fn.arg(0).to_bool());
+ }
+
+ return as_value();
+}
+
+as_value
+textfield_backgroundColor(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ return as_value(ptr->getBackgroundColor().toRGB());
+ }
+ else // setter
+ {
+ rgba newColor;
+ newColor.parseRGB(static_cast<boost::uint32_t>(fn.arg(0).to_int()));
+ ptr->setBackgroundColor(newColor);
+ }
+
+ return as_value();
+}
+
+as_value
+textfield_borderColor(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ return as_value(ptr->getBorderColor().toRGB());
+ }
+ else // setter
+ {
+ rgba newColor;
+ newColor.parseRGB( static_cast<boost::uint32_t>(fn.arg(0).to_number())
);
+ ptr->setBorderColor(newColor);
+ }
+
+ return as_value();
+}
+
+
+as_value
+textfield_textColor(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+
+ if (!fn.nargs)
+ {
+ // Getter
+ return as_value(ptr->getTextColor().toRGB());
+ }
+
+ // Setter
+ rgba newColor;
+ newColor.parseRGB(static_cast<boost::uint32_t>(fn.arg(0).to_number()));
+ ptr->setTextColor(newColor);
+
+ return as_value();
+}
+
+as_value
+textfield_embedFonts(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+
+ if (!fn.nargs)
+ {
+ // Getter
+ return as_value(ptr->getEmbedFonts());
+ }
+
+ // Setter
+ ptr->setEmbedFonts( fn.arg(0).to_bool() );
+ return as_value();
+}
+
+as_value
+textfield_wordWrap(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ return as_value(ptr->doWordWrap());
+ }
+ else // setter
+ {
+ ptr->setWordWrap( fn.arg(0).to_bool() );
+ }
+
+ return as_value();
+}
+
+as_value
+textfield_html(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ return as_value(ptr->doHtml());
+ }
+ else // setter
+ {
+ ptr->setHtml( fn.arg(0).to_bool() );
+ }
+
+ return as_value();
+}
+
+as_value
+textfield_selectable(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ return as_value(ptr->isSelectable());
+ }
+ else // setter
+ {
+ ptr->setSelectable( fn.arg(0).to_bool() );
+ }
+
+ return as_value();
+}
+
+as_value
+textfield_length(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ const std::string& s = ptr->get_text_value();
+ return as_value(s.length()); // TOCHECK: utf-8 ?
+ }
+ else // setter
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("Attempt to set length property of TextField %s"),
+ ptr->getTarget());
+ );
+ }
+
+ return as_value();
+}
+
+as_value
+textfield_textHeight(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ // Return the height, in pixels, of the text as laid out.
+ // (I.e. the actual text content, not our defined
+ // bounding box.)
+ //
+ // In local coords. Verified against Macromedia Flash.
+ return as_value(TWIPS_TO_PIXELS(ptr->getTextBoundingBox().height()));
+
+ }
+ else // setter
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("Attempt to set read-only %s property of TextField "
+ "%s"), "textHeight", ptr->getTarget());
+ );
+ }
+
+ return as_value();
+}
+
+as_value
+textfield_textWidth(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ // Return the width, in pixels, of the text as laid out.
+ // (I.e. the actual text content, not our defined
+ // bounding box.)
+ //
+ // In local coords. Verified against Macromedia Flash.
+ return as_value(TWIPS_TO_PIXELS(ptr->getTextBoundingBox().width()));
+
+ }
+ else // setter
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("Attempt to set read-only %s property of TextField %s"),
+ "textWidth", ptr->getTarget());
+ );
+ }
+
+ return as_value();
+}
+
+as_value
+textfield_autoSize(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ return ptr->autoSizeValueName(ptr->getAutoSize());
+ }
+ else // setter
+ {
+ const as_value& arg = fn.arg(0);
+ if ( arg.is_bool() )
+ {
+ if ( arg.to_bool() ) // true == left
+ {
+ ptr->setAutoSize( TextField::autoSizeLeft );
+ }
+ else
+ {
+ ptr->setAutoSize( TextField::autoSizeNone );
+ }
+ }
+ else
+ {
+ std::string strval = arg.to_string();
+ TextField::AutoSizeValue val = ptr->parseAutoSizeValue(strval);
+ //log_debug("%s => %d", strval, val);
+ ptr->setAutoSize( val );
+ }
+ }
+
+ return as_value();
+}
+
+as_value
+textfield_type(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+
+ if (!fn.nargs)
+ {
+ // getter
+ return ptr->typeValueName(ptr->getType());
+ }
+
+ // setter
+ const as_value& arg = fn.arg(0);
+ std::string strval = arg.to_string();
+ TextField::TypeValue val = ptr->parseTypeValue(strval);
+
+ IF_VERBOSE_ASCODING_ERRORS(
+ if ( val == TextField::typeInvalid )
+ {
+ log_aserror(_("Invalid value given to TextField.type: %s"),
strval);
+ }
+ );
+ ptr->setType(val);
+ return as_value();
+}
+
+
+as_value
+textfield_variable(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+
+ if (!fn.nargs)
+ {
+ // Getter
+ const std::string& varName = text->getVariableName();
+ // An empty variable name returns null.
+ if (varName.empty()) {
+ as_value null;
+ null.set_null();
+ return null;
+ }
+ return as_value(varName);
+ }
+
+ // Setter
+ const as_value& varName = fn.arg(0);
+ if (varName.is_undefined() || varName.is_null()) {
+ text->set_variable_name("");
+ }
+ else text->set_variable_name(varName.to_string());
+
+ return as_value();
+
+}
+
+
+as_value
+textfield_getDepth(const fn_call& fn)
+{
+ // TODO: make this a character::getDepth_method function...
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+
+ int n = text->get_depth();
+
+ return as_value(n);
+
+}
+
+as_value
+textfield_getFontList(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+ UNUSED(text);
+
+ LOG_ONCE(log_unimpl("TextField.getFontList()"));
+
+ return as_value();
+}
+
+as_value
+textfield_getNewTextFormat(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+ UNUSED(text);
+
+ LOG_ONCE(log_unimpl("TextField.getNewTextFormat()"));
+
+ return as_value();
+}
+
+as_value
+textfield_getTextFormat(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+
+ boost::intrusive_ptr<TextFormat> tf = new TextFormat();
+ tf->alignSet(text->getTextAlignment());
+ tf->sizeSet(text->getFontHeight());
+ tf->indentSet(text->getIndent());
+ tf->blockIndentSet(text->getBlockIndent());
+ tf->leadingSet(text->getLeading());
+ tf->leftMarginSet(text->getLeftMargin());
+ tf->rightMarginSet(text->getRightMargin());
+ tf->colorSet(text->getTextColor());
+ tf->underlinedSet(text->getUnderlined());
+
+ const Font* font = text->getFont();
+ if (font)
+ {
+ tf->fontSet(font->get_name());
+ tf->italicedSet(font->isItalic());
+ tf->boldSet(font->isBold());
+ }
+
+ // TODO: add font color and some more
+
+ LOG_ONCE(
+ log_unimpl("TextField.getTextFormat() discards url, target, "
+ "tabStops, bullet and display")
+ );
+
+ return as_value(tf.get());
+}
+
+as_value
+textfield_setTextFormat(const fn_call& fn)
+{
+ //GNASH_REPORT_FUNCTION;
+
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+
+ if ( ! fn.nargs )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::stringstream ss; fn.dump_args(ss);
+ log_aserror("TextField.setTextFormat(%s) : %s", ss.str(),
+ _("missing arg"))
+ );
+ return as_value();
+ }
+ else if ( fn.nargs > 2 )
+ {
+ std::stringstream ss; fn.dump_args(ss);
+ log_debug("TextField.setTextFormat(%s) : args past the first are "
+ "unhandled by Gnash", ss.str());
+ }
+
+ as_object* obj = fn.arg(0).to_object().get();
+ if ( ! obj )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::stringstream ss; fn.dump_args(ss);
+ log_aserror("TextField.setTextFormat(%s) : %s", ss.str(),
+ _("first argument is not an object"))
+ );
+ return as_value();
+ }
+
+ TextFormat* tf = dynamic_cast<TextFormat*>(obj);
+ if ( ! tf )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::stringstream ss; fn.dump_args(ss);
+ log_aserror("TextField.setTextFormat(%s) : %s", ss.str(),
+ _("first argument is not a TextFormat"))
+ );
+ return as_value();
+ }
+
+ if ( tf->alignDefined() ) text->setAlignment(tf->align());
+ if ( tf->sizeDefined() ) text->setFontHeight(tf->size()); // keep twips
+ if ( tf->indentDefined() ) text->setIndent(tf->indent());
+ if ( tf->blockIndentDefined() ) text->setBlockIndent(tf->blockIndent());
+ if ( tf->leadingDefined() ) text->setLeading(tf->leading());
+ if ( tf->leftMarginDefined() ) text->setLeftMargin(tf->leftMargin());
+ if ( tf->rightMarginDefined() ) text->setRightMargin(tf->rightMargin());
+ if ( tf->colorDefined() ) text->setTextColor(tf->color());
+ if ( tf->underlinedDefined() ) text->setUnderlined(tf->underlined());
+
+ if ( tf->fontDefined() )
+ {
+ const std::string& fontName = tf->font();
+ if ( ! fontName.empty() )
+ {
+ bool bold = tf->bold();
+ bool italic = tf->italiced();
+
+ // NOTE: should query movie-private font lib, not global-shared one
+ movie_instance* mi = text->get_root();
+ assert(mi);
+ movie_definition* md = mi->get_movie_definition();
+ assert(md);
+ Font* f = md->get_font(fontName, bold, italic);
+ if ( ! f ) f = fontlib::get_font(fontName, bold, italic);
+ text->setFont( f );
+ }
+ }
+
+ // TODO: add font color and some more
+
+ LOG_ONCE( log_unimpl("TextField.setTextFormat() discards url, target, "
+ "tabStops, bullet and display") );
+
+ return as_value();
+
+}
+
+as_value
+textfield_setNewTextFormat(const fn_call& fn)
+{
+ //boost::intrusive_ptr<TextField> text =
ensureType<TextField>(fn.this_ptr);
+ //UNUSED(text);
+
+ LOG_ONCE( log_unimpl("TextField.setNewTextFormat(), we'll delegate "
+ "to setTextFormat") );
+ return textfield_setTextFormat(fn);
+
+ //return as_value();
+}
+
+as_value
+textfield_password(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+
+ LOG_ONCE(log_unimpl("TextField.password"));
+
+ if (!fn.nargs)
+ {
+ // Getter
+ return as_value(text->password());
+ }
+ // Setter
+ text->password(fn.arg(0).to_bool());
+ return as_value();
+}
+
+as_value
+textfield_multiline(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+
+ LOG_ONCE(log_unimpl("TextField.multiline"));
+
+ if (!fn.nargs) {
+ // Getter
+ return as_value(text->multiline());
+ }
+ // Setter
+ text->multiline(fn.arg(0).to_bool());
+ return as_value();
+}
+
+as_value
+textfield_restrict(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+ UNUSED(text);
+
+ LOG_ONCE (log_unimpl("TextField.restrict"));
+
+ return as_value();
+}
+
+as_value
+textfield_bottomScroll(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+ UNUSED(text);
+
+ LOG_ONCE (log_unimpl("TextField.bottomScroll"));
+
+ return as_value();
+}
+
+as_value
+textfield_maxhscroll(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+ UNUSED(text);
+
+ LOG_ONCE (log_unimpl("TextField.maxhscroll"));
+
+ return as_value();
+}
+
+/// TextField.maxChars().
+//
+/// This does not limit the length of the text, but rather the
+/// number of characters that can be entered in the TextField.
+//
+/// Returns null when the value is 0.
+as_value
+textfield_maxChars(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+
+ LOG_ONCE(log_unimpl("TextField.maxChars"));
+
+ if (!fn.nargs)
+ {
+ boost::int32_t maxChars = text->maxChars();
+ if (maxChars == 0)
+ {
+ as_value null;
+ null.set_null();
+ return null;
+ }
+ return as_value(maxChars);
+ }
+ // Setter
+ text->maxChars(fn.arg(0).to_int());
+ return as_value();
+}
+
+as_value
+textfield_text(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+ if (!fn.nargs)
+ {
+ // Getter
+ //
+ // FIXME: should return text without HTML tags.
+ return as_value(ptr->get_text_value());
+ }
+
+ // Setter
+ int version = ptr->getVM().getSWFVersion();
+ ptr->setTextValue(
+ utf8::decodeCanonicalString(fn.arg(0).to_string(), version));
+
+ return as_value();
+}
+
+as_value
+textfield_htmlText(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> ptr = ensureType<TextField>(fn.this_ptr);
+ if (!fn.nargs)
+ {
+ // Getter
+ return as_value(ptr->get_text_value());
+ }
+
+ // Setter
+ int version = ptr->getVM().getSWFVersion();
+ ptr->setTextValue(
+ utf8::decodeCanonicalString(fn.arg(0).to_string(), version));
+
+ return as_value();
+}
+
+
+as_value
+textfield_replaceSel(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+ UNUSED(text);
+
+ LOG_ONCE (log_unimpl("TextField.replaceSel()"));
+
+ return as_value();
+}
+
+as_value
+textfield_scroll(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+ UNUSED(text);
+
+ LOG_ONCE (log_unimpl("TextField.scroll()"));
+
+ return as_value();
+}
+
+as_value
+textfield_hscroll(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+ UNUSED(text);
+
+ LOG_ONCE (log_unimpl("TextField.hscroll()"));
+
+ return as_value();
+}
+
+as_value
+textfield_maxscroll(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+ UNUSED(text);
+
+ LOG_ONCE (log_unimpl("TextField.maxscroll"));
+
+ return as_value();
+}
+
+as_value
+textfield_replaceText(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+ UNUSED(text);
+
+ LOG_ONCE(log_unimpl("TextField.replaceText()"));
+
+ return as_value();
+}
+
+as_value
+textfield_removeTextField(const fn_call& fn)
+{
+ boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
+
+ text->removeTextField();
+
+ LOG_ONCE(log_debug("TextField.removeTextField() TESTING"));
+
+ return as_value();
+}
+
+
+/// This is called for 'new TextField()' only
+as_value
+textfield_ctor(const fn_call& /* fn */)
+{
+ as_object* proto = getTextFieldInterface(VM::get());
+
+ // We should attach more properties to the prototype on first
+ // instantiation.
+ // TODO: this also attaches properties to the SWF5 prototype but makes
+ // them invisible with prop flags. Is this correct?
+ attachPrototypeProperties(*proto);
+
+ boost::intrusive_ptr<as_object> obj = new as_object(proto);
+
+ return as_value(obj);
+}
+
+
+void
+attachTextFieldInterface(as_object& o)
+{
+ boost::intrusive_ptr<builtin_function> getset;
+
+ // TextField is an AsBroadcaster
+ AsBroadcaster::initialize(o);
+
+ int propFlags = as_prop_flags::dontDelete
+ |as_prop_flags::dontEnum
+ |as_prop_flags::readOnly
+ |as_prop_flags::isProtected;
+
+ // Parent seems to not be a normal property
+ getset = new builtin_function(&character::parent_getset, NULL);
+ o.init_property(NSV::PROP_uPARENT, *getset, *getset);
+
+ // Target seems to not be a normal property
+ getset = new builtin_function(&character::target_getset, NULL);
+ o.init_property(NSV::PROP_uTARGET, *getset, *getset);
+
+ // _name should be a property of the instance, not the prototype
+ getset = new builtin_function(&character::name_getset, NULL);
+ o.init_property(NSV::PROP_uNAME, *getset, *getset);
+
+ o.init_property(NSV::PROP_uXMOUSE,
+ character::xmouse_get, character::xmouse_get, propFlags);
+ o.init_property(NSV::PROP_uYMOUSE,
+ character::ymouse_get, character::ymouse_get, propFlags);
+ o.init_property(NSV::PROP_uXSCALE,
+ character::xscale_getset, character::xscale_getset);
+ o.init_property(NSV::PROP_uYSCALE,
+ character::yscale_getset, character::yscale_getset);
+ // Standard flags.
+ const int flags = as_prop_flags::dontDelete
+ |as_prop_flags::dontEnum;
+
+ // SWF6 or higher
+ const int swf6Flags = flags | as_prop_flags::onlySWF6Up;
+
+ o.init_member("setTextFormat",
+ new builtin_function(textfield_setTextFormat), swf6Flags);
+ o.init_member("getTextFormat",
+ new builtin_function(textfield_getTextFormat), swf6Flags);
+ o.init_member("setNewTextFormat",
+ new builtin_function(textfield_setNewTextFormat), swf6Flags);
+ o.init_member("getNewTextFormat",
+ new builtin_function(textfield_getNewTextFormat), swf6Flags);
+ o.init_member("getNewTextFormat",
+ new builtin_function(textfield_getNewTextFormat), swf6Flags);
+ o.init_member("getDepth",
+ new builtin_function(textfield_getDepth), swf6Flags);
+ o.init_member("removeTextField",
+ new builtin_function(textfield_removeTextField), swf6Flags);
+ o.init_member("replaceSel",
+ new builtin_function(textfield_replaceSel), swf6Flags);
+
+ // SWF7 or higher
+ const int swf7Flags = flags | as_prop_flags::onlySWF7Up;
+
+ o.init_member("replaceText",
+ new builtin_function(textfield_replaceText), swf7Flags);
+
+}
+
+void
+attachTextFieldStaticMembers(as_object& o)
+{
+ // Standard flags.
+ const int flags = as_prop_flags::dontDelete
+ |as_prop_flags::dontEnum;
+
+ // SWF6 or higher
+ const int swf6Flags = flags | as_prop_flags::onlySWF6Up;
+
+ o.init_member("getFontList",
+ new builtin_function(textfield_getFontList), swf6Flags);
+
+}
+
+/// This is called when a prototype should be added
+//
+/// @note This is called at different times, depending on the version.
+/// For SWF5 it is called only on first instantiation. For SWF6 it
+/// is called at the registration of _global.TextField.
+as_object*
+getTextFieldInterface(VM& vm)
+{
+ static boost::intrusive_ptr<as_object> proto;
+
+ if ( proto == NULL )
+ {
+ if (vm.getSWFVersion() < 6) {
+ /// The prototype for SWF5 is a simple as_object without
+ /// toString() or valueOf().
+ proto = new as_object();
+ }
+ else {
+ proto = new as_object(getObjectInterface());
+ vm.addStatic(proto.get());
+ attachTextFieldInterface(*proto);
+ }
+
+ }
+ return proto.get();
+}
+
+} // anonymous namespace
+
} // namespace gnash
=== modified file 'libcore/TextField.h'
--- a/libcore/TextField.h 2008-11-11 07:30:33 +0000
+++ b/libcore/TextField.h 2008-11-11 12:51:35 +0000
@@ -273,13 +273,6 @@
///
static const char* autoSizeValueName(AutoSizeValue val);
- /// Attaches more properties to the prototype on first instantiation.
- //
- /// @param proto The prototype of the TextField object.
- //
- /// This is used when constructing non-AS textfields.
- static void attachTextFieldInstanceProperties(as_object& proto);
-
/// Set type (input or dynamic)
//
/// @param val
=== modified file 'libcore/Video.cpp'
--- a/libcore/Video.cpp 2008-11-11 08:43:14 +0000
+++ b/libcore/Video.cpp 2008-11-11 12:51:35 +0000
@@ -38,130 +38,45 @@
namespace gnash {
-static as_object* getVideoInterface(as_object& where);
-static void attachVideoInterface(as_object& o);
-static void attachVideoProperties(as_object& o);
-static as_value video_ctor(const fn_call& fn);
-static as_value video_attach(const fn_call& fn);
-static as_value video_clear(const fn_call& fn);
-
-static as_object* getVideoInterface(as_object& where)
-{
- static boost::intrusive_ptr<as_object> proto;
- if ( proto == NULL )
- {
- proto = new as_object(getObjectInterface());
- where.getVM().addStatic(proto.get());
-
- attachVideoInterface(*proto);
- //proto->init_member("constructor", new
builtin_function(video_ctor));
- }
- return proto.get();
-}
-
-static void attachVideoInterface(as_object& o)
-{
- o.init_member("attachVideo", new builtin_function(video_attach));
- o.init_member("clear", new builtin_function(video_clear));
-}
-
-static void attachVideoProperties(as_object& o)
-{
- //int target_version = o.getVM().getSWFVersion();
-
- as_c_function_ptr gettersetter;
-
- gettersetter = &character::x_getset;
- o.init_property(NSV::PROP_uX, *gettersetter, *gettersetter);
-
- gettersetter = &character::y_getset;
- o.init_property(NSV::PROP_uY, *gettersetter, *gettersetter);
-
- gettersetter = &character::xscale_getset;
- o.init_property(NSV::PROP_uXSCALE, *gettersetter, *gettersetter);
-
- gettersetter = &character::yscale_getset;
- o.init_property(NSV::PROP_uYSCALE, *gettersetter, *gettersetter);
-
- gettersetter = &character::xmouse_get;
- o.init_readonly_property(NSV::PROP_uXMOUSE, *gettersetter);
-
- gettersetter = &character::ymouse_get;
- o.init_readonly_property(NSV::PROP_uYMOUSE, *gettersetter);
-
- gettersetter = &character::alpha_getset;
- o.init_property(NSV::PROP_uALPHA, *gettersetter, *gettersetter);
-
- gettersetter = &character::visible_getset;
- o.init_property(NSV::PROP_uVISIBLE, *gettersetter, *gettersetter);
-
- gettersetter = &character::width_getset;
- o.init_property(NSV::PROP_uWIDTH, *gettersetter, *gettersetter);
-
- gettersetter = &character::height_getset;
- o.init_property(NSV::PROP_uHEIGHT, *gettersetter, *gettersetter);
-
- gettersetter = &character::rotation_getset;
- o.init_property(NSV::PROP_uROTATION, *gettersetter, *gettersetter);
-
- gettersetter = &character::parent_getset;
- o.init_property(NSV::PROP_uPARENT, *gettersetter, *gettersetter);
-
- gettersetter = &character::target_getset;
- o.init_property(NSV::PROP_uTARGET, *gettersetter, *gettersetter);
-}
-
-static as_value
-video_attach(const fn_call& fn)
-{
- boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
-
- if (fn.nargs < 1)
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("attachVideo needs 1 arg"));
- );
- return as_value();
- }
-
- boost::intrusive_ptr<NetStream_as> ns =
- boost::dynamic_pointer_cast<NetStream_as>(fn.arg(0).to_object());
- if (ns)
- {
- video->setStream(ns);
- }
- else
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("attachVideo(%s) first arg is not a NetStream
instance"),
- fn.arg(0));
- );
- }
- return as_value();
-}
-
-static as_value
-video_clear(const fn_call& fn)
-{
- boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
-
- video->clear();
- return as_value();
-}
-
-static as_value
-video_ctor(const fn_call& /* fn */)
-{
- log_debug("new Video() TESTING !");
-
- // I'm not sure We can rely on the def and parent values being accepted
- // as NULL. Not till we add some testing...
- boost::intrusive_ptr<character> obj = new Video(NULL, NULL, -1);
- obj->setDynamic();
- return as_value(obj.get()); // will keep alive
-}
-
-/*private*/
+namespace {
+ as_object* getVideoInterface(as_object& where);
+ void attachPrototypeProperties(as_object& o);
+ void attachVideoInterface(as_object& o);
+ void attachVideoProperties(as_object& o);
+ as_value video_ctor(const fn_call& fn);
+ as_value video_attach(const fn_call& fn);
+ as_value video_clear(const fn_call& fn);
+ as_value video_deblocking(const fn_call& fn);
+ as_value video_smoothing(const fn_call& fn);
+ as_value video_width(const fn_call& fn);
+ as_value video_height(const fn_call& fn);
+}
+
+Video::Video(SWF::DefineVideoStreamTag* def,
+ character* parent, int id)
+ :
+ character(parent, id),
+ m_def(def),
+ _ns(0),
+ _embeddedStream(m_def ? true : false),
+ _lastDecodedVideoFrameNum(-1),
+ _lastDecodedVideoFrame()
+{
+
+ set_prototype(getVideoInterface(*this));
+ if (_embeddedStream)
+ {
+ attachVideoProperties(*this);
+ initializeDecoder();
+
+ attachPrototypeProperties(*get_prototype());
+ }
+}
+
+Video::~Video()
+{
+}
+
void
Video::initializeDecoder()
{
@@ -191,30 +106,6 @@
}
}
-Video::Video(SWF::DefineVideoStreamTag* def,
- character* parent, int id)
- :
- character(parent, id),
- m_def(def),
- _ns(NULL),
- _embeddedStream(m_def ? true : false),
- _lastDecodedVideoFrameNum(-1),
- _lastDecodedVideoFrame()
-{
-
- if (_embeddedStream)
- {
- attachVideoProperties(*this);
- initializeDecoder();
- }
-
- set_prototype(getVideoInterface(*this));
-}
-
-Video::~Video()
-{
-}
-
void
Video::clear()
{
@@ -388,7 +279,8 @@
}
// extern (used by Global.cpp)
-void video_class_init(as_object& global)
+void
+video_class_init(as_object& global)
{
// This is going to be the global Video "class"/"function"
static boost::intrusive_ptr<builtin_function> cl;
@@ -424,4 +316,178 @@
}
#endif // GNASH_USE_GC
+namespace {
+
+as_object*
+getVideoInterface(as_object& where)
+{
+ static boost::intrusive_ptr<as_object> proto;
+ if ( proto == NULL )
+ {
+ proto = new as_object(getObjectInterface());
+ where.getVM().addStatic(proto.get());
+
+ attachVideoInterface(*proto);
+ //proto->init_member("constructor", new
builtin_function(video_ctor));
+ }
+ return proto.get();
+}
+
+void
+attachVideoInterface(as_object& o)
+{
+ o.init_member("attachVideo", new builtin_function(video_attach));
+ o.init_member("clear", new builtin_function(video_clear));
+}
+
+void
+attachPrototypeProperties(as_object& proto)
+{
+ proto.init_property("deblocking", &video_deblocking, &video_deblocking);
+ proto.init_property("smoothing", &video_smoothing, &video_smoothing);
+ proto.init_property("height", &video_height, &video_height);
+ proto.init_property("width", &video_width, &video_width);
+}
+
+void
+attachVideoProperties(as_object& o)
+{
+
+ as_c_function_ptr gettersetter;
+
+ gettersetter = &character::x_getset;
+ o.init_property(NSV::PROP_uX, *gettersetter, *gettersetter);
+
+ gettersetter = &character::y_getset;
+ o.init_property(NSV::PROP_uY, *gettersetter, *gettersetter);
+
+ gettersetter = &character::xscale_getset;
+ o.init_property(NSV::PROP_uXSCALE, *gettersetter, *gettersetter);
+
+ gettersetter = &character::yscale_getset;
+ o.init_property(NSV::PROP_uYSCALE, *gettersetter, *gettersetter);
+
+ gettersetter = &character::xmouse_get;
+ o.init_readonly_property(NSV::PROP_uXMOUSE, *gettersetter);
+
+ gettersetter = &character::ymouse_get;
+ o.init_readonly_property(NSV::PROP_uYMOUSE, *gettersetter);
+
+ gettersetter = &character::alpha_getset;
+ o.init_property(NSV::PROP_uALPHA, *gettersetter, *gettersetter);
+
+ gettersetter = &character::visible_getset;
+ o.init_property(NSV::PROP_uVISIBLE, *gettersetter, *gettersetter);
+
+ gettersetter = &character::width_getset;
+ o.init_property(NSV::PROP_uWIDTH, *gettersetter, *gettersetter);
+
+ gettersetter = &character::height_getset;
+ o.init_property(NSV::PROP_uHEIGHT, *gettersetter, *gettersetter);
+
+ gettersetter = &character::rotation_getset;
+ o.init_property(NSV::PROP_uROTATION, *gettersetter, *gettersetter);
+
+ gettersetter = &character::parent_getset;
+ o.init_property(NSV::PROP_uPARENT, *gettersetter, *gettersetter);
+
+ gettersetter = &character::target_getset;
+ o.init_property(NSV::PROP_uTARGET, *gettersetter, *gettersetter);
+}
+
+as_value
+video_attach(const fn_call& fn)
+{
+ boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
+
+ if (fn.nargs < 1)
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("attachVideo needs 1 arg"));
+ );
+ return as_value();
+ }
+
+ boost::intrusive_ptr<NetStream_as> ns =
+ boost::dynamic_pointer_cast<NetStream_as>(fn.arg(0).to_object());
+ if (ns)
+ {
+ video->setStream(ns);
+ }
+ else
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("attachVideo(%s) first arg is not a NetStream
instance"),
+ fn.arg(0));
+ );
+ }
+ return as_value();
+}
+
+as_value
+video_deblocking(const fn_call& fn)
+{
+ boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
+ UNUSED(video);
+
+ log_unimpl("Video.deblocking");
+ return as_value();
+}
+
+as_value
+video_smoothing(const fn_call& fn)
+{
+ boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
+ UNUSED(video);
+
+ log_unimpl("Video.smoothing");
+ return as_value();
+}
+
+as_value
+video_width(const fn_call& fn)
+{
+ boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
+ UNUSED(video);
+
+ log_unimpl("Video.width");
+ return as_value();
+}
+
+as_value
+video_height(const fn_call& fn)
+{
+ boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
+ UNUSED(video);
+
+ log_unimpl("Video.height");
+ return as_value();
+}
+
+as_value
+video_clear(const fn_call& fn)
+{
+ boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
+
+ video->clear();
+ return as_value();
+}
+
+as_value
+video_ctor(const fn_call& /* fn */)
+{
+ log_debug("new Video() TESTING !");
+
+ // I'm not sure We can rely on the def and parent values being accepted
+ // as NULL. Not till we add some testing...
+ boost::intrusive_ptr<character> obj = new Video(NULL, NULL, -1);
+ obj->setDynamic();
+ return as_value(obj.get()); // will keep alive
+}
+
+} // anonymous namespace
+
} // end of namespace gnash
+
+
+
=== modified file 'testsuite/actionscript.all/Video.as'
--- a/testsuite/actionscript.all/Video.as 2008-03-29 22:50:53 +0000
+++ b/testsuite/actionscript.all/Video.as 2008-11-11 12:45:13 +0000
@@ -31,6 +31,27 @@
#else
+check(Video.prototype.hasOwnProperty("attachVideo"));
+check(Video.prototype.hasOwnProperty("clear"));
+check(!Video.prototype.hasOwnProperty("smoothing"));
+check(!Video.prototype.hasOwnProperty("deblocking"));
+check(!Video.prototype.hasOwnProperty("_alpha"));
+check(!Video.prototype.hasOwnProperty("_height"));
+check(!Video.prototype.hasOwnProperty("height"));
+check(!Video.prototype.hasOwnProperty("_name"));
+check(!Video.prototype.hasOwnProperty("_parent"));
+check(!Video.prototype.hasOwnProperty("_rotation"));
+check(!Video.prototype.hasOwnProperty("_visible"));
+check(!Video.prototype.hasOwnProperty("_width"));
+check(!Video.prototype.hasOwnProperty("width"));
+check(!Video.prototype.hasOwnProperty("_x"));
+check(!Video.prototype.hasOwnProperty("_xmouse"));
+check(!Video.prototype.hasOwnProperty("_xscale"));
+check(!Video.prototype.hasOwnProperty("_y"));
+check(!Video.prototype.hasOwnProperty("_ymouse"));
+check(!Video.prototype.hasOwnProperty("_yscale"));
+check(!Video.prototype.hasOwnProperty("_xmouse"));
+
// test Video class an interface availability
check_equals(typeof(Video), 'function');
check_equals(typeof(Video.prototype), 'object');
@@ -57,8 +78,52 @@
check_equals (typeof(videoObj._target), 'undefined');
check_equals (typeof(videoObj._parent), 'undefined');
-// TODO: test other properties !
-
-check_totals(21);
+nc = new NetConnection();
+nc.connect(null);
+ns = new NetStream(nc);
+videoObj.attachVideo(ns);
+ns.play(MEDIA(square.flv));
+
+check(!videoObj.hasOwnProperty("attachVideo"));
+check(!videoObj.hasOwnProperty("smoothing"));
+check(!videoObj.hasOwnProperty("deblocking"));
+check(!videoObj.hasOwnProperty("clear"));
+check(!videoObj.hasOwnProperty("_alpha"));
+check(!videoObj.hasOwnProperty("_height"));
+check(!videoObj.hasOwnProperty("height"));
+check(!videoObj.hasOwnProperty("_name"));
+check(!videoObj.hasOwnProperty("_parent"));
+check(!videoObj.hasOwnProperty("_rotation"));
+check(!videoObj.hasOwnProperty("_visible"));
+check(!videoObj.hasOwnProperty("_width"));
+check(!videoObj.hasOwnProperty("width"));
+check(!videoObj.hasOwnProperty("_x"));
+check(!videoObj.hasOwnProperty("_xmouse"));
+check(!videoObj.hasOwnProperty("_xscale"));
+check(!videoObj.hasOwnProperty("_y"));
+check(!videoObj.hasOwnProperty("_ymouse"));
+check(!videoObj.hasOwnProperty("_yscale"));
+check(!videoObj.hasOwnProperty("_xmouse"));
+
+check(!Video.prototype.hasOwnProperty("smoothing"));
+check(!Video.prototype.hasOwnProperty("deblocking"));
+check(!Video.prototype.hasOwnProperty("_alpha"));
+check(!Video.prototype.hasOwnProperty("_height"));
+check(!Video.prototype.hasOwnProperty("height"));
+check(!Video.prototype.hasOwnProperty("_name"));
+check(!Video.prototype.hasOwnProperty("_parent"));
+check(!Video.prototype.hasOwnProperty("_rotation"));
+check(!Video.prototype.hasOwnProperty("_visible"));
+check(!Video.prototype.hasOwnProperty("_width"));
+check(!Video.prototype.hasOwnProperty("width"));
+check(!Video.prototype.hasOwnProperty("_x"));
+check(!Video.prototype.hasOwnProperty("_xmouse"));
+check(!Video.prototype.hasOwnProperty("_xscale"));
+check(!Video.prototype.hasOwnProperty("_y"));
+check(!Video.prototype.hasOwnProperty("_ymouse"));
+check(!Video.prototype.hasOwnProperty("_yscale"));
+check(!Video.prototype.hasOwnProperty("_xmouse"));
+
+check_totals(79);
#endif
=== modified file 'testsuite/misc-ming.all/NetStream-SquareTest.c'
--- a/testsuite/misc-ming.all/NetStream-SquareTest.c 2008-10-06 13:30:57
+0000
+++ b/testsuite/misc-ming.all/NetStream-SquareTest.c 2008-11-11 13:26:59
+0000
@@ -296,6 +296,12 @@
//------------------------------------------
// Now attach video to the video characters
//------------------------------------------
+ check(mo, "Video.prototype.hasOwnProperty('attachVideo')");
+ check(mo, "Video.prototype.hasOwnProperty('smoothing')");
+ check(mo, "Video.prototype.hasOwnProperty('deblocking')");
+ check(mo, "Video.prototype.hasOwnProperty('clear')");
+ check(mo, "Video.prototype.hasOwnProperty('height')");
+ check(mo, "Video.prototype.hasOwnProperty('width')");
add_actions(mo, "video.attachVideo(stream);");
add_actions(mo, "video2.attachVideo(stream2);");
@@ -376,6 +382,27 @@
check_equals(mo, "video._yscale", "100");
check_equals(mo, "video._rotation", "0");
check_equals(mo, "video._target", "'/video'");
+ check(mo, "Video.prototype.hasOwnProperty('attachVideo')");
+ check(mo, "Video.prototype.hasOwnProperty('smoothing')");
+ check(mo, "Video.prototype.hasOwnProperty('deblocking')");
+ check(mo, "Video.prototype.hasOwnProperty('clear')");
+ check(mo, "Video.prototype.hasOwnProperty('height')");
+ check(mo, "Video.prototype.hasOwnProperty('width')");
+
+ check(mo, "!Video.prototype.hasOwnProperty('_alpha')");
+ check(mo, "!Video.prototype.hasOwnProperty('_height')");
+ check(mo, "!Video.prototype.hasOwnProperty('_name')");
+ check(mo, "!Video.prototype.hasOwnProperty('_parent')");
+ check(mo, "!Video.prototype.hasOwnProperty('_rotation')");
+ check(mo, "!Video.prototype.hasOwnProperty('_visible')");
+ check(mo, "!Video.prototype.hasOwnProperty('_width')");
+ check(mo, "!Video.prototype.hasOwnProperty('_x')");
+ check(mo, "!Video.prototype.hasOwnProperty('_xmouse')");
+ check(mo, "!Video.prototype.hasOwnProperty('_xscale')");
+ check(mo, "!Video.prototype.hasOwnProperty('_y')");
+ check(mo, "!Video.prototype.hasOwnProperty('_ymouse')");
+ check(mo, "!Video.prototype.hasOwnProperty('_yscale')");
+ check(mo, "!Video.prototype.hasOwnProperty('_xmouse')");
add_actions(mo,
"video._x = 100;"
@@ -615,7 +642,7 @@
check_equals(mo, "metadataNotified", "1");
check_equals(mo, "stopNotified", "2");
check_equals(mo, "startNotified", "1");
- SWFMovie_add(mo, (SWFBlock)newSWFAction("totals(142); stop();
end_of_test=true;"));
+ SWFMovie_add(mo, (SWFBlock)newSWFAction("totals(168); stop();
end_of_test=true;"));
SWFMovie_nextFrame(mo);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10257: Stub unimplemented Video properties and modify the prototype when there,
Benjamin Wolsey <=