diff --git a/core/src/avm1/globals.rs b/core/src/avm1/globals.rs index fe90300c7..65769d8cc 100644 --- a/core/src/avm1/globals.rs +++ b/core/src/avm1/globals.rs @@ -9,6 +9,7 @@ use gc_arena::Collect; use gc_arena::MutationContext; use std::str; +mod accessibility; mod array; pub(crate) mod as_broadcaster; mod bevel_filter; @@ -1150,6 +1151,16 @@ pub fn create_globals<'gc>( )), Attribute::DONT_ENUM, ); + globals.define_value( + gc_context, + "Accessibility", + Value::Object(accessibility::create_accessibility_object( + gc_context, + Some(object_proto), + function_proto, + )), + Attribute::DONT_ENUM, + ); define_properties_on(GLOBAL_DECLS, gc_context, globals, function_proto); diff --git a/core/src/avm1/globals/accessibility.rs b/core/src/avm1/globals/accessibility.rs new file mode 100644 index 000000000..bf2ebed57 --- /dev/null +++ b/core/src/avm1/globals/accessibility.rs @@ -0,0 +1,50 @@ +//! Accessibility class + +use crate::avm1::activation::Activation; +use crate::avm1::error::Error; +use crate::avm1::property_decl::{define_properties_on, Declaration}; +use crate::avm1::{Object, ScriptObject, Value}; +use gc_arena::MutationContext; + +const OBJECT_DECLS: &[Declaration] = declare_properties! { + "isActive" => method(is_active; DONT_DELETE | READ_ONLY); + "sendEvent" => method(send_event; DONT_DELETE | READ_ONLY); + "updateProperties" => method(update_properties; DONT_DELETE | READ_ONLY); +}; + +pub fn is_active<'gc>( + _activation: &mut Activation<'_, 'gc, '_>, + _this: Object<'gc>, + _args: &[Value<'gc>], +) -> Result, Error<'gc>> { + log::warn!("Accessibility.isActive: not yet implemented"); + Ok(Value::Bool(false)) +} + +pub fn send_event<'gc>( + _activation: &mut Activation<'_, 'gc, '_>, + _this: Object<'gc>, + _args: &[Value<'gc>], +) -> Result, Error<'gc>> { + log::warn!("Accessibility.sendEvent: not yet implemented"); + Ok(Value::Undefined) +} + +pub fn update_properties<'gc>( + _activation: &mut Activation<'_, 'gc, '_>, + _this: Object<'gc>, + _args: &[Value<'gc>], +) -> Result, Error<'gc>> { + log::warn!("Accessibility.updateProperties: not yet implemented"); + Ok(Value::Undefined) +} + +pub fn create_accessibility_object<'gc>( + gc_context: MutationContext<'gc, '_>, + proto: Option>, + fn_proto: Object<'gc>, +) -> Object<'gc> { + let accessibility = ScriptObject::object(gc_context, proto); + define_properties_on(OBJECT_DECLS, gc_context, accessibility, fn_proto); + accessibility.into() +}