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 {
|
fn tab_enabled_default(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||||
self.get_avm1_boolean_property(context, "tabEnabled", |_| true)
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn highlight_bounds(self) -> Rectangle<Twips> {
|
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
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2459,11 +2459,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
|
||||||
self.tab_enabled(context)
|
self.tab_enabled(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tab_enabled_avm1(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
|
fn tab_enabled_default(&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 {
|
|
||||||
self.is_editable()
|
self.is_editable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -641,20 +641,16 @@ pub trait TInteractiveObject<'gc>:
|
||||||
if context.swf.is_action_script_3() {
|
if context.swf.is_action_script_3() {
|
||||||
self.raw_interactive()
|
self.raw_interactive()
|
||||||
.tab_enabled
|
.tab_enabled
|
||||||
.unwrap_or_else(|| self.tab_enabled_avm2_default(context))
|
.unwrap_or_else(|| self.tab_enabled_default(context))
|
||||||
} else {
|
} 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.
|
fn tab_enabled_default(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||||
///
|
|
||||||
/// 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 {
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3369,14 +3369,17 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tab_enabled_avm1(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
|
fn tab_enabled_default(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
|
||||||
self.get_avm1_boolean_property(context, "tabEnabled", |context| {
|
if self.is_button_mode(context) {
|
||||||
self.tab_index().is_some() || self.is_button_mode(context)
|
return true;
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tab_enabled_avm2_default(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
|
let is_avm1 = !context.swf.is_action_script_3();
|
||||||
self.is_button_mode(context)
|
if is_avm1 && self.tab_index().is_some() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue