core: Add InteractiveObject.tab_enabled_default
This patch removes two methods: * `tab_enabled_avm1`, and * `tab_enabled_avm2_default`, and replaces them with `tab_enabled_default`. This refactor makes the code more readable and simple.
This commit is contained in:
parent
819abe8420
commit
4253525f8b
|
@ -599,8 +599,8 @@ impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> {
|
|||
}
|
||||
}
|
||||
|
||||
fn tab_enabled_avm1(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||
self.get_avm1_boolean_property(context, "tabEnabled", |_| true)
|
||||
fn tab_enabled_default(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn highlight_bounds(self) -> Rectangle<Twips> {
|
||||
|
|
|
@ -821,7 +821,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm2Button<'gc> {
|
|||
}
|
||||
}
|
||||
|
||||
fn tab_enabled_avm2_default(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||
fn tab_enabled_default(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2459,11 +2459,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
|
|||
self.tab_enabled(context)
|
||||
}
|
||||
|
||||
fn tab_enabled_avm1(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||
self.get_avm1_boolean_property(context, "tabEnabled", |_| true)
|
||||
}
|
||||
|
||||
fn tab_enabled_avm2_default(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||
fn tab_enabled_default(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||
self.is_editable()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -641,20 +641,16 @@ pub trait TInteractiveObject<'gc>:
|
|||
if context.swf.is_action_script_3() {
|
||||
self.raw_interactive()
|
||||
.tab_enabled
|
||||
.unwrap_or_else(|| self.tab_enabled_avm2_default(context))
|
||||
.unwrap_or_else(|| self.tab_enabled_default(context))
|
||||
} else {
|
||||
self.tab_enabled_avm1(context)
|
||||
self.as_displayobject()
|
||||
.get_avm1_boolean_property(context, "tabEnabled", |context| {
|
||||
self.tab_enabled_default(context)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Look up the `tabEnabled` property from AVM1.
|
||||
///
|
||||
/// Do not use this directly, use [`Self::is_tabbable()`] or [`Self::tab_enabled()`].
|
||||
fn tab_enabled_avm1(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn tab_enabled_avm2_default(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||
fn tab_enabled_default(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
|
|
|
@ -3369,14 +3369,17 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> {
|
|||
}
|
||||
}
|
||||
|
||||
fn tab_enabled_avm1(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||
self.get_avm1_boolean_property(context, "tabEnabled", |context| {
|
||||
self.tab_index().is_some() || self.is_button_mode(context)
|
||||
})
|
||||
fn tab_enabled_default(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||
if self.is_button_mode(context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
fn tab_enabled_avm2_default(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||
self.is_button_mode(context)
|
||||
let is_avm1 = !context.swf.is_action_script_3();
|
||||
if is_avm1 && self.tab_index().is_some() {
|
||||
return true;
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue