avm1: Add Accessibility stub

This commit is contained in:
Mike Welsh 2022-04-15 13:20:11 -07:00
parent b83879c392
commit bce9398c0d
2 changed files with 61 additions and 0 deletions

View File

@ -9,6 +9,7 @@ use gc_arena::Collect;
use gc_arena::MutationContext; use gc_arena::MutationContext;
use std::str; use std::str;
mod accessibility;
mod array; mod array;
pub(crate) mod as_broadcaster; pub(crate) mod as_broadcaster;
mod bevel_filter; mod bevel_filter;
@ -1150,6 +1151,16 @@ pub fn create_globals<'gc>(
)), )),
Attribute::DONT_ENUM, 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); define_properties_on(GLOBAL_DECLS, gc_context, globals, function_proto);

View File

@ -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<Value<'gc>, 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<Value<'gc>, 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<Value<'gc>, Error<'gc>> {
log::warn!("Accessibility.updateProperties: not yet implemented");
Ok(Value::Undefined)
}
pub fn create_accessibility_object<'gc>(
gc_context: MutationContext<'gc, '_>,
proto: Option<Object<'gc>>,
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()
}