core: remove UpdateContext's unused lifetime and reborrow method

This commit is contained in:
Moulins 2024-08-03 17:06:33 +02:00 committed by Nathan Adams
parent 13cffa4c94
commit 47030b4f5b
70 changed files with 658 additions and 775 deletions

View File

@ -221,7 +221,7 @@ pub struct Activation<'a, 'gc: 'a> {
/// Whether the base clip was removed when we started this frame.
base_clip_unloaded: bool,
pub context: &'a mut UpdateContext<'a, 'gc>,
pub context: &'a mut UpdateContext<'gc>,
/// An identifier to refer to this activation by, when debugging.
/// This is often the name of a function (if known), or some static name to indicate where
@ -245,7 +245,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
#[allow(clippy::too_many_arguments)]
pub fn from_action(
context: &'a mut UpdateContext<'a, 'gc>,
context: &'a mut UpdateContext<'gc>,
id: ActivationIdentifier<'a>,
swf_version: u8,
scope: Gc<'gc, Scope<'gc>>,
@ -280,7 +280,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
avm_debug!(self.context.avm1, "START {id}");
Activation {
id,
context: self.context.reborrow(),
context: self.context,
swf_version: self.swf_version,
scope,
constant_pool: self.constant_pool,
@ -301,7 +301,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
/// Note: using the returned `Activation` directly to execute arbitrary bytecode and/or
/// to define new local variables is a logic error, and will corrupt the global scope.
pub fn from_nothing(
context: &'a mut UpdateContext<'a, 'gc>,
context: &'a mut UpdateContext<'gc>,
id: ActivationIdentifier<'a>,
base_clip: DisplayObject<'gc>,
) -> Self {
@ -324,10 +324,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
/// Construct an empty stack frame with no code running on the root movie in
/// layer 0.
pub fn from_stub(
context: &'a mut UpdateContext<'a, 'gc>,
id: ActivationIdentifier<'a>,
) -> Self {
pub fn from_stub(context: &'a mut UpdateContext<'gc>, id: ActivationIdentifier<'a>) -> Self {
// [NA]: we have 3 options here:
// 1 - Don't execute anything (return None and handle that at the caller)
// 2 - Execute something with a temporary orphaned movie
@ -345,7 +342,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
/// Construct an empty stack frame with no code running on the root move in
/// layer 0.
pub fn try_from_stub(
context: &'a mut UpdateContext<'a, 'gc>,
context: &'a mut UpdateContext<'gc>,
id: ActivationIdentifier<'a>,
) -> Option<Self> {
if let Some(level0) = context.stage.root_clip() {
@ -362,11 +359,8 @@ impl<'a, 'gc> Activation<'a, 'gc> {
active_clip: DisplayObject<'gc>,
code: SwfSlice,
) -> Result<ReturnType<'gc>, Error<'gc>> {
let mut parent_activation = Activation::from_nothing(
self.context.reborrow(),
self.id.child("[Actions Parent]"),
active_clip,
);
let mut parent_activation =
Activation::from_nothing(self.context, self.id.child("[Actions Parent]"), active_clip);
let clip_obj = active_clip
.object()
.coerce_to_object(&mut parent_activation);
@ -381,7 +375,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
let constant_pool = parent_activation.context.avm1.constant_pool();
let child_name = parent_activation.id.child(name);
let mut child_activation = Activation::from_action(
parent_activation.context.reborrow(),
parent_activation.context,
child_name,
active_clip.swf_version(),
child_scope,
@ -418,7 +412,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
);
let constant_pool = self.context.avm1.constant_pool();
let mut activation = Activation::from_action(
self.context.reborrow(),
self.context,
self.id.child(name),
swf_version,
child_scope,
@ -2267,7 +2261,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
if let Some((catch_vars, actions)) = &action.catch_body {
if let Err(Error::ThrownValue(value)) = &result {
let mut activation = Activation::from_action(
self.context.reborrow(),
self.context,
self.id.child("[Catch]"),
self.swf_version,
self.scope,

View File

@ -417,7 +417,7 @@ impl<'gc> Executable<'gc> {
let max_recursion_depth = activation.context.avm1.max_recursion_depth();
let mut frame = Activation::from_action(
activation.context.reborrow(),
activation.context,
activation.id.function(name, reason, max_recursion_depth)?,
swf_version,
child_scope,

View File

@ -73,7 +73,7 @@ pub fn clone<'gc>(
pub fn avm1_to_filter<'gc>(
object: Object<'gc>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Option<Filter> {
let native = object.native();
match native {

View File

@ -169,7 +169,7 @@ impl<'gc> ConvolutionFilter<'gc> {
Ok(())
}
fn matrix(&self, context: &mut UpdateContext<'_, 'gc>) -> ArrayObject<'gc> {
fn matrix(&self, context: &mut UpdateContext<'gc>) -> ArrayObject<'gc> {
ArrayObject::new(
context.gc_context,
context.avm1.prototypes().array,

View File

@ -140,7 +140,7 @@ impl<'gc> DisplacementMapFilter<'gc> {
Self(GcCell::new(gc_context, self.0.read().clone()))
}
fn map_bitmap(&self, context: &mut UpdateContext<'_, 'gc>) -> Option<Object<'gc>> {
fn map_bitmap(&self, context: &mut UpdateContext<'gc>) -> Option<Object<'gc>> {
if let Some(map_bitmap) = self.0.read().map_bitmap {
let proto = context.avm1.prototypes().bitmap_data;
let result = ScriptObject::new(context.gc_context, Some(proto));
@ -308,7 +308,7 @@ impl<'gc> DisplacementMapFilter<'gc> {
pub fn filter(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> ruffle_render::filters::DisplacementMapFilter {
let filter = self.0.read();
ruffle_render::filters::DisplacementMapFilter {

View File

@ -167,7 +167,7 @@ impl<'gc> GradientFilter<'gc> {
Ok(())
}
fn colors(&self, context: &mut UpdateContext<'_, 'gc>) -> ArrayObject<'gc> {
fn colors(&self, context: &mut UpdateContext<'gc>) -> ArrayObject<'gc> {
let read = self.0.read();
ArrayObject::new(
context.gc_context,
@ -205,7 +205,7 @@ impl<'gc> GradientFilter<'gc> {
Ok(())
}
fn alphas(&self, context: &mut UpdateContext<'_, 'gc>) -> ArrayObject<'gc> {
fn alphas(&self, context: &mut UpdateContext<'gc>) -> ArrayObject<'gc> {
let read = self.0.read();
ArrayObject::new(
context.gc_context,
@ -245,7 +245,7 @@ impl<'gc> GradientFilter<'gc> {
Ok(())
}
fn ratios(&self, context: &mut UpdateContext<'_, 'gc>) -> ArrayObject<'gc> {
fn ratios(&self, context: &mut UpdateContext<'gc>) -> ArrayObject<'gc> {
let read = self.0.read();
ArrayObject::new(
context.gc_context,

View File

@ -67,7 +67,7 @@ impl<'gc> LocalConnection<'gc> {
}
pub fn send_status(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
this: Object<'gc>,
status: &'static str,
) -> Result<(), Error<'gc>> {
@ -76,7 +76,7 @@ impl<'gc> LocalConnection<'gc> {
return Ok(());
};
let mut activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[LocalConnection onStatus]"),
root_clip,
);
@ -95,7 +95,7 @@ impl<'gc> LocalConnection<'gc> {
}
pub fn run_method(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
this: Object<'gc>,
method_name: AvmString<'gc>,
amf_arguments: Vec<AmfValue>,
@ -105,7 +105,7 @@ impl<'gc> LocalConnection<'gc> {
return Ok(());
};
let mut activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[LocalConnection call]"),
root_clip,
);

View File

@ -971,7 +971,7 @@ fn duplicate_movie_clip<'gc>(
pub fn clone_sprite<'gc>(
movie_clip: MovieClip<'gc>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
target: AvmString<'gc>,
depth: Depth,
init_object: Option<Object<'gc>>,

View File

@ -47,7 +47,7 @@ impl<'gc> NetConnection<'gc> {
}
pub fn on_status_event(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
this: Object<'gc>,
code: &'static str,
) -> Result<(), Error<'gc>> {
@ -56,7 +56,7 @@ impl<'gc> NetConnection<'gc> {
return Ok(());
};
let mut activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[NetConnection connect]"),
root_clip,
);
@ -77,7 +77,7 @@ impl<'gc> NetConnection<'gc> {
// [NA] I have no idea why this is a thing. It's similar in AVM2 too.
pub fn on_empty_status_event(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
this: Object<'gc>,
) -> Result<(), Error<'gc>> {
let Some(root_clip) = context.stage.root_clip() else {
@ -85,7 +85,7 @@ impl<'gc> NetConnection<'gc> {
return Ok(());
};
let mut activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[NetConnection connect]"),
root_clip,
);
@ -99,7 +99,7 @@ impl<'gc> NetConnection<'gc> {
}
pub fn send_callback(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
responder: Object<'gc>,
callback: ResponderCallback,
message: &flash_lso::types::Value,
@ -109,7 +109,7 @@ impl<'gc> NetConnection<'gc> {
return Ok(());
};
let mut activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[NetConnection response]"),
root_clip,
);

View File

@ -87,7 +87,7 @@ impl<'gc> StageObject<'gc> {
/// Clears all text field bindings from this stage object, and places the textfields on the unbound list.
/// This is called when the object is removed from the stage.
pub fn unregister_text_field_bindings(self, context: &mut UpdateContext<'_, 'gc>) {
pub fn unregister_text_field_bindings(self, context: &mut UpdateContext<'gc>) {
for binding in self
.0
.write(context.gc_context)

View File

@ -128,7 +128,7 @@ impl<'gc> Avm1<'gc> {
active_clip: DisplayObject<'gc>,
name: S,
code: SwfSlice,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) {
if context.avm1.halted {
// We've been told to ignore all future execution.
@ -136,7 +136,7 @@ impl<'gc> Avm1<'gc> {
}
let mut parent_activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[Actions Parent]"),
active_clip,
);
@ -155,7 +155,7 @@ impl<'gc> Avm1<'gc> {
let constant_pool = parent_activation.context.avm1.constant_pool;
let child_name = parent_activation.id.child(name);
let mut child_activation = Activation::from_action(
parent_activation.context.reborrow(),
parent_activation.context,
child_name,
active_clip.swf_version(),
child_scope,
@ -174,7 +174,7 @@ impl<'gc> Avm1<'gc> {
/// This creates a new frame stack.
pub fn run_with_stack_frame_for_display_object<'a, F, R>(
active_clip: DisplayObject<'gc>,
action_context: &mut UpdateContext<'_, 'gc>,
action_context: &mut UpdateContext<'gc>,
function: F,
) -> R
where
@ -194,7 +194,7 @@ impl<'gc> Avm1<'gc> {
);
let constant_pool = action_context.avm1.constant_pool;
let mut activation = Activation::from_action(
action_context.reborrow(),
action_context,
ActivationIdentifier::root("[Display Object]"),
active_clip.swf_version(),
child_scope,
@ -212,7 +212,7 @@ impl<'gc> Avm1<'gc> {
pub fn run_stack_frame_for_init_action(
active_clip: DisplayObject<'gc>,
code: SwfSlice,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) {
if context.avm1.halted {
// We've been told to ignore all future execution.
@ -220,7 +220,7 @@ impl<'gc> Avm1<'gc> {
}
let mut parent_activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[Init Parent]"),
active_clip,
);
@ -240,7 +240,7 @@ impl<'gc> Avm1<'gc> {
let constant_pool = parent_activation.context.avm1.constant_pool;
let child_name = parent_activation.id.child("[Init]");
let mut child_activation = Activation::from_action(
parent_activation.context.reborrow(),
parent_activation.context,
child_name,
active_clip.swf_version(),
child_scope,
@ -258,10 +258,10 @@ impl<'gc> Avm1<'gc> {
/// method, such as an event handler.
///
/// This creates a new frame stack.
pub fn run_stack_frame_for_method<'a, 'b>(
pub fn run_stack_frame_for_method(
active_clip: DisplayObject<'gc>,
obj: Object<'gc>,
context: &'a mut UpdateContext<'b, 'gc>,
context: &mut UpdateContext<'gc>,
name: AvmString<'gc>,
args: &[Value<'gc>],
) {
@ -271,7 +271,7 @@ impl<'gc> Avm1<'gc> {
}
let mut activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root(name.to_string()),
active_clip,
);
@ -281,13 +281,13 @@ impl<'gc> Avm1<'gc> {
pub fn notify_system_listeners(
active_clip: DisplayObject<'gc>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
broadcaster_name: AvmString<'gc>,
method: AvmString<'gc>,
args: &[Value<'gc>],
) {
let mut activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[System Listeners]"),
active_clip,
);
@ -434,7 +434,7 @@ impl<'gc> Avm1<'gc> {
/// Remove all display objects pending removal
/// See [`find_display_objects_pending_removal`] for details
fn remove_pending(context: &mut UpdateContext<'_, 'gc>) {
fn remove_pending(context: &mut UpdateContext<'gc>) {
// Storage for objects to remove
// Have to do this in two passes to avoid borrow-mut while already borrowed
let mut out = Vec::new();
@ -461,7 +461,7 @@ impl<'gc> Avm1<'gc> {
// Run a single frame.
#[instrument(level = "debug", skip_all)]
pub fn run_frame(context: &mut UpdateContext<'_, 'gc>) {
pub fn run_frame(context: &mut UpdateContext<'gc>) {
// Remove pending objects
Self::remove_pending(context);

View File

@ -15,7 +15,6 @@ where
.build();
let mut player = player.lock().unwrap();
player.mutate_with_update_context(|context| {
let context = context.reborrow();
let root = context
.stage
.root_clip()

View File

@ -272,9 +272,9 @@ impl<'gc> Avm2<'gc> {
}
}
pub fn load_player_globals(context: &mut UpdateContext<'_, 'gc>) -> Result<(), Error<'gc>> {
pub fn load_player_globals(context: &mut UpdateContext<'gc>) -> Result<(), Error<'gc>> {
let globals = context.avm2.playerglobals_domain;
let mut activation = Activation::from_domain(context.reborrow(), globals);
let mut activation = Activation::from_domain(context, globals);
globals::load_player_globals(&mut activation, globals)
}
@ -310,9 +310,9 @@ impl<'gc> Avm2<'gc> {
/// Run a script's initializer method.
pub fn run_script_initializer(
script: Script<'gc>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Result<(), Error<'gc>> {
let mut init_activation = Activation::from_script(context.reborrow(), script)?;
let mut init_activation = Activation::from_script(context, script)?;
let (method, scope, _domain) = script.init();
match method {
@ -380,8 +380,8 @@ impl<'gc> Avm2<'gc> {
}
pub fn each_orphan_obj(
context: &mut UpdateContext<'_, 'gc>,
mut f: impl FnMut(DisplayObject<'gc>, &mut UpdateContext<'_, 'gc>),
context: &mut UpdateContext<'gc>,
mut f: impl FnMut(DisplayObject<'gc>, &mut UpdateContext<'gc>),
) {
// Clone the Rc before iterating over it. Any modifications must go through
// `Rc::make_mut` in `orphan_objects_mut`, which will leave this `Rc` unmodified.
@ -399,7 +399,7 @@ impl<'gc> Avm2<'gc> {
/// Called at the end of `run_all_phases_avm2` - removes any movies
/// that have been garbage collected, or are no longer orphans
/// (they've since acquired a parent).
pub fn cleanup_dead_orphans(context: &mut UpdateContext<'_, 'gc>) {
pub fn cleanup_dead_orphans(context: &mut UpdateContext<'gc>) {
context.avm2.orphan_objects_mut().retain(|d| {
if let Some(dobj) = valid_orphan(*d, context.gc_context) {
// All clips that become orphaned (have their parent removed, or start out with no parent)
@ -438,7 +438,7 @@ impl<'gc> Avm2<'gc> {
///
/// Returns `true` if the event has been handled.
pub fn dispatch_event(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event: Object<'gc>,
target: Object<'gc>,
) -> bool {
@ -452,7 +452,7 @@ impl<'gc> Avm2<'gc> {
///
/// Returns `true` when the event would have been handled if not simulated.
pub fn simulate_event_dispatch(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event: Object<'gc>,
target: Object<'gc>,
) -> bool {
@ -460,7 +460,7 @@ impl<'gc> Avm2<'gc> {
}
fn dispatch_event_internal(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event: Object<'gc>,
target: Object<'gc>,
simulate_dispatch: bool,
@ -470,7 +470,7 @@ impl<'gc> Avm2<'gc> {
.map(|e| e.event_type())
.unwrap_or_else(|| panic!("cannot dispatch non-event object: {:?}", event));
let mut activation = Activation::from_nothing(context.reborrow());
let mut activation = Activation::from_nothing(context);
match events::dispatch_event(&mut activation, target, event, simulate_dispatch) {
Err(err) => {
tracing::error!(
@ -495,7 +495,7 @@ impl<'gc> Avm2<'gc> {
/// Attempts to register the same listener for the same event will also do
/// nothing.
pub fn register_broadcast_listener(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
object: Object<'gc>,
event_name: AvmString<'gc>,
) {
@ -531,7 +531,7 @@ impl<'gc> Avm2<'gc> {
///
/// Attempts to broadcast a non-event object will panic.
pub fn broadcast_event(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event: Object<'gc>,
on_type: ClassObject<'gc>,
) {
@ -564,7 +564,7 @@ impl<'gc> Avm2<'gc> {
.copied();
if let Some(object) = object.and_then(|obj| obj.upgrade(context.gc_context)) {
let mut activation = Activation::from_nothing(context.reborrow());
let mut activation = Activation::from_nothing(context);
if object.is_of_type(on_type.inner_class_definition()) {
if let Err(err) = events::dispatch_event(&mut activation, object, event, false)
@ -593,9 +593,9 @@ impl<'gc> Avm2<'gc> {
receiver: Value<'gc>,
args: &[Value<'gc>],
domain: Domain<'gc>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Result<(), String> {
let mut evt_activation = Activation::from_domain(context.reborrow(), domain);
let mut evt_activation = Activation::from_domain(context, domain);
callable
.call(receiver, args, &mut evt_activation)
.map_err(|e| format!("{e:?}"))?;
@ -605,7 +605,7 @@ impl<'gc> Avm2<'gc> {
/// Load an ABC file embedded in a `DoAbc` or `DoAbc2` tag.
pub fn do_abc(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
data: &[u8],
name: Option<AvmString<'gc>>,
flags: DoAbc2Flag,
@ -616,12 +616,12 @@ impl<'gc> Avm2<'gc> {
let abc = match reader.read() {
Ok(abc) => abc,
Err(_) => {
let mut activation = Activation::from_nothing(context.reborrow());
let mut activation = Activation::from_nothing(context);
return Err(make_error_1107(&mut activation));
}
};
let mut activation = Activation::from_domain(context.reborrow(), domain);
let mut activation = Activation::from_domain(context, domain);
// Make sure we have the correct domain for code that tries to access it
// using `activation.domain()`
activation.set_outer(ScopeChain::new(domain));

View File

@ -139,7 +139,7 @@ pub struct Activation<'a, 'gc: 'a> {
/// Maximum size for the scope frame.
max_scope_size: usize,
pub context: &'a mut UpdateContext<'a, 'gc>,
pub context: &'a mut UpdateContext<'gc>,
}
impl<'a, 'gc> Activation<'a, 'gc> {
@ -158,7 +158,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
///
/// It is a logic error to attempt to run AVM2 code in a nothing
/// `Activation`.
pub fn from_nothing(context: &'a mut UpdateContext<'a, 'gc>) -> Self {
pub fn from_nothing(context: &'a mut UpdateContext<'gc>) -> Self {
let local_registers = RegisterSet::new(0);
Self {
@ -187,7 +187,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
/// The 'Domain' should come from the SwfMovie associated with whatever
/// action you're performing. When running frame scripts, this is the
/// `SwfMovie` associated with the `MovieClip` being processed.
pub fn from_domain(context: &'a mut UpdateContext<'a, 'gc>, domain: Domain<'gc>) -> Self {
pub fn from_domain(context: &'a mut UpdateContext<'gc>, domain: Domain<'gc>) -> Self {
let local_registers = RegisterSet::new(0);
Self {
@ -210,7 +210,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
/// Construct an activation for the execution of a particular script's
/// initializer method.
pub fn from_script(
context: &'a mut UpdateContext<'a, 'gc>,
context: &'a mut UpdateContext<'gc>,
script: Script<'gc>,
) -> Result<Self, Error<'gc>> {
let (method, global_object, domain) = script.init();
@ -240,7 +240,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
BytecodeMethod::get_or_init_activation_class(method, context.gc_context, || {
let translation_unit = method.translation_unit();
let abc_method = method.method();
let mut dummy_activation = Activation::from_domain(context.reborrow(), domain);
let mut dummy_activation = Activation::from_domain(context, domain);
dummy_activation.set_outer(ScopeChain::new(domain));
let activation_class = Class::for_activation(
&mut dummy_activation,
@ -416,8 +416,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
BytecodeMethod::get_or_init_activation_class(method, self.context.gc_context, || {
let translation_unit = method.translation_unit();
let abc_method = method.method();
let mut dummy_activation =
Activation::from_domain(self.context.reborrow(), outer.domain());
let mut dummy_activation = Activation::from_domain(self.context, outer.domain());
dummy_activation.set_outer(outer);
let activation_class = Class::for_activation(
&mut dummy_activation,
@ -523,7 +522,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
/// function to construct a new activation for the builtin so that it can
/// properly supercall.
pub fn from_builtin(
context: &'a mut UpdateContext<'a, 'gc>,
context: &'a mut UpdateContext<'gc>,
subclass_object: Option<ClassObject<'gc>>,
outer: ScopeChain<'gc>,
caller_domain: Option<Domain<'gc>>,

View File

@ -328,7 +328,7 @@ impl<'gc> Class<'gc> {
/// This is used to parameterize a generic type. The returned class will no
/// longer be generic.
pub fn with_type_param(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
this: Class<'gc>,
param: Option<Class<'gc>>,
) -> Class<'gc> {
@ -730,7 +730,7 @@ impl<'gc> Class<'gc> {
Ok(())
}
pub fn init_vtable(self, context: &mut UpdateContext<'_, 'gc>) -> Result<(), Error<'gc>> {
pub fn init_vtable(self, context: &mut UpdateContext<'gc>) -> Result<(), Error<'gc>> {
let read = self.0.read();
if !read.traits_loaded {
@ -754,7 +754,7 @@ impl<'gc> Class<'gc> {
Ok(())
}
pub fn link_interfaces(self, context: &mut UpdateContext<'_, 'gc>) -> Result<(), Error<'gc>> {
pub fn link_interfaces(self, context: &mut UpdateContext<'gc>) -> Result<(), Error<'gc>> {
let mut interfaces = Vec::with_capacity(self.direct_interfaces().len());
let mut dedup = HashSet::new();

View File

@ -214,7 +214,7 @@ impl<'gc> Domain<'gc> {
pub fn get_class(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
multiname: &Multiname<'gc>,
) -> Option<Class<'gc>> {
let class = self.get_class_inner(multiname);

View File

@ -145,7 +145,7 @@ pub fn exec<'gc>(
let caller_domain = activation.caller_domain();
let caller_movie = activation.caller_movie();
let mut activation = Activation::from_builtin(
activation.context.reborrow(),
activation.context,
bound_class,
scope,
caller_domain,
@ -191,7 +191,7 @@ pub fn exec<'gc>(
// This used to be a one step called Activation::from_method,
// but avoiding moving an Activation around helps perf
let mut activation = Activation::from_nothing(activation.context.reborrow());
let mut activation = Activation::from_nothing(activation.context);
activation.init_from_method(bm, scope, receiver, arguments, bound_class, callee)?;
activation
.context

View File

@ -116,10 +116,7 @@ fn validate_remove_operation<'gc>(
}
/// Remove an element from it's parent display list.
fn remove_child_from_displaylist<'gc>(
context: &mut UpdateContext<'_, 'gc>,
child: DisplayObject<'gc>,
) {
fn remove_child_from_displaylist<'gc>(context: &mut UpdateContext<'gc>, child: DisplayObject<'gc>) {
if let Some(parent) = child.parent() {
if let Some(mut ctr) = parent.as_container() {
child.set_placed_by_script(context.gc_context, true);
@ -130,7 +127,7 @@ fn remove_child_from_displaylist<'gc>(
/// Add the `child` to `parent`'s display list.
pub(super) fn add_child_to_displaylist<'gc>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
parent: DisplayObject<'gc>,
child: DisplayObject<'gc>,
index: usize,

View File

@ -143,7 +143,7 @@ impl<'gc> Multiname<'gc> {
pub fn abc_namespace_set(
translation_unit: TranslationUnit<'gc>,
namespace_set_index: Index<AbcNamespaceSet>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Result<NamespaceSet<'gc>, Error<'gc>> {
if namespace_set_index.0 == 0 {
return Err(Error::RustError(
@ -178,7 +178,7 @@ impl<'gc> Multiname<'gc> {
pub fn from_abc_index(
translation_unit: TranslationUnit<'gc>,
multiname_index: Index<AbcMultiname>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Result<Self, Error<'gc>> {
let mc = context.gc_context;
let abc = translation_unit.abc();

View File

@ -82,7 +82,7 @@ impl<'gc> Namespace<'gc> {
pub fn from_abc_namespace(
translation_unit: TranslationUnit<'gc>,
namespace_index: Index<AbcNamespace>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Result<Self, Error<'gc>> {
if namespace_index.0 == 0 {
return Ok(Self::any(context.gc_context));

View File

@ -61,7 +61,7 @@ impl<'gc> EventObject<'gc> {
/// It's just slightly faster and doesn't require an Activation.
/// This is equivalent to
/// classes.event.construct(activation, &[event_type, false, false])
pub fn bare_default_event<S>(context: &mut UpdateContext<'_, 'gc>, event_type: S) -> Object<'gc>
pub fn bare_default_event<S>(context: &mut UpdateContext<'gc>, event_type: S) -> Object<'gc>
where
S: Into<AvmString<'gc>>,
{
@ -72,7 +72,7 @@ impl<'gc> EventObject<'gc> {
/// It's just slightly faster and doesn't require an Activation.
/// Note that if you need an Event subclass, you need to construct it via .construct().
pub fn bare_event<S>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event_type: S,
bubbles: bool,
cancelable: bool,

View File

@ -263,7 +263,7 @@ impl<'gc> LoaderInfoObject<'gc> {
pub fn fire_init_and_complete_events(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
status: u16,
redirected: bool,
) {
@ -291,7 +291,7 @@ impl<'gc> LoaderInfoObject<'gc> {
};
if should_complete {
let mut activation = Activation::from_nothing(context.reborrow());
let mut activation = Activation::from_nothing(context);
if from_url {
let http_status_evt = activation
.avm2()

View File

@ -88,8 +88,8 @@ impl<'gc> LocalConnectionObject<'gc> {
}
}
pub fn send_status(&self, context: &mut UpdateContext<'_, 'gc>, status: &'static str) {
let mut activation = Activation::from_nothing(context.reborrow());
pub fn send_status(&self, context: &mut UpdateContext<'gc>, status: &'static str) {
let mut activation = Activation::from_nothing(context);
if let Ok(event) = activation.avm2().classes().statusevent.construct(
&mut activation,
&[
@ -106,12 +106,12 @@ impl<'gc> LocalConnectionObject<'gc> {
pub fn run_method(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
domain: Domain<'gc>,
method_name: AvmString<'gc>,
amf_arguments: Vec<AmfValue>,
) {
let mut activation = Activation::from_domain(context.reborrow(), domain);
let mut activation = Activation::from_domain(context, domain);
let mut arguments = Vec::with_capacity(amf_arguments.len());
for argument in amf_arguments {

View File

@ -79,7 +79,7 @@ impl<'gc> ResponderObject<'gc> {
pub fn send_callback(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
callback: ResponderCallback,
message: &AMFValue,
) -> Result<(), Error<'gc>> {
@ -89,7 +89,7 @@ impl<'gc> ResponderObject<'gc> {
};
if let Some(function) = function {
let mut activation = Activation::from_nothing(context.reborrow());
let mut activation = Activation::from_nothing(context);
let value = crate::avm2::amf::deserialize_value(&mut activation, message)?;
function.call((*self).into(), &[value], &mut activation)?;
}

View File

@ -133,7 +133,7 @@ impl<'gc> SoundObject<'gc> {
pub fn set_sound(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
sound: SoundHandle,
) -> Result<(), Error<'gc>> {
let mut sound_data = unlock!(
@ -142,7 +142,7 @@ impl<'gc> SoundObject<'gc> {
sound_data
)
.borrow_mut();
let mut activation = Activation::from_nothing(context.reborrow());
let mut activation = Activation::from_nothing(context);
match &mut *sound_data {
SoundData::NotLoaded { queued_plays } => {
for queued in std::mem::take(queued_plays) {

View File

@ -103,7 +103,7 @@ impl<'gc> SoundChannelObject<'gc> {
}
/// Return the position of the playing sound in seconds.
pub fn position(self, context: &mut UpdateContext<'_, 'gc>) -> f64 {
pub fn position(self, context: &mut UpdateContext<'gc>) -> f64 {
// The position is cached on read. This means that if the position isn't read until after
// the sound has played, the position will be 0 (#9952).
let sound_channel_data = self.0.sound_channel_data.borrow();

View File

@ -45,7 +45,7 @@ impl<'gc> QName<'gc> {
pub fn from_abc_multiname(
translation_unit: TranslationUnit<'gc>,
multiname_index: Index<AbcMultiname>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Result<Self, Error<'gc>> {
if multiname_index.0 == 0 {
return Err("Attempted to load a trait name of index zero".into());
@ -100,7 +100,7 @@ impl<'gc> QName<'gc> {
pub fn from_qualified_name(
name: AvmString<'gc>,
api_version: ApiVersion,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Self {
let parts = name
.rsplit_once(WStr::from_units(b"::"))

View File

@ -349,7 +349,7 @@ impl<'gc> TranslationUnit<'gc> {
pub fn pool_namespace(
self,
ns_index: Index<AbcNamespace>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Result<Namespace<'gc>, Error<'gc>> {
let read = self.0.read();
if let Some(Some(namespace)) = read.namespaces.get(ns_index.0 as usize) {
@ -369,7 +369,7 @@ impl<'gc> TranslationUnit<'gc> {
pub fn pool_maybe_uninitialized_multiname(
self,
multiname_index: Index<AbcMultiname>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Result<Gc<'gc, Multiname<'gc>>, Error<'gc>> {
let mc = context.gc_context;
let read = self.0.read();
@ -393,7 +393,7 @@ impl<'gc> TranslationUnit<'gc> {
pub fn pool_multiname_static(
self,
multiname_index: Index<AbcMultiname>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Result<Gc<'gc, Multiname<'gc>>, Error<'gc>> {
let multiname = self.pool_maybe_uninitialized_multiname(multiname_index, context)?;
if multiname.has_lazy_component() {
@ -410,7 +410,7 @@ impl<'gc> TranslationUnit<'gc> {
pub fn pool_multiname_static_any(
self,
multiname_index: Index<AbcMultiname>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Result<Gc<'gc, Multiname<'gc>>, Error<'gc>> {
if multiname_index.0 == 0 {
let mc = context.gc_context;
@ -626,7 +626,7 @@ impl<'gc> Script<'gc> {
///
/// If the script has not yet been initialized, this will initialize it on
/// the same stack.
pub fn globals(self, context: &mut UpdateContext<'_, 'gc>) -> Result<Object<'gc>, Error<'gc>> {
pub fn globals(self, context: &mut UpdateContext<'gc>) -> Result<Object<'gc>, Error<'gc>> {
let mut write = self.0.write(context.gc_context);
if !write.initialized {

View File

@ -466,7 +466,7 @@ pub fn capture_specification(context: &mut UpdateContext, output: &Path) {
let mut definitions = FnvHashMap::<String, Definition>::default();
let defs = context.avm2.playerglobals_domain.defs().clone();
let mut activation = Activation::from_nothing(context.reborrow());
let mut activation = Activation::from_nothing(context);
for (name, namespace, _) in defs.iter() {
let value = activation
.context

View File

@ -378,7 +378,7 @@ impl<'gc> AudioManager<'gc> {
}
/// Update state of active sounds. Should be called once per frame.
pub fn update_sounds(context: &mut UpdateContext<'_, 'gc>) {
pub fn update_sounds(context: &mut UpdateContext<'gc>) {
// We can't use 'context' to construct an event inside the
// 'retain()' closure, so we queue the events up here, and fire
// them after running 'retain()'
@ -731,7 +731,7 @@ impl<'gc> AudioManager<'gc> {
pub fn perform_sound_event(
display_object: DisplayObject<'gc>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
character_id: CharacterId,
sound_info: &SoundInfo,
) {

View File

@ -1021,7 +1021,7 @@ pub fn merge<'gc>(
}
pub fn copy_pixels<'gc>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
target: BitmapDataWrapper<'gc>,
source_bitmap: BitmapDataWrapper<'gc>,
src_rect: (i32, i32, i32, i32),
@ -1060,7 +1060,7 @@ pub fn copy_pixels<'gc>(
#[allow(clippy::too_many_arguments)]
pub fn copy_pixels_with_alpha_source<'gc>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
target: BitmapDataWrapper<'gc>,
source_bitmap: BitmapDataWrapper<'gc>,
src_rect: (i32, i32, i32, i32),
@ -1198,7 +1198,7 @@ pub fn copy_pixels_with_alpha_source<'gc>(
}
pub fn apply_filter<'gc>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
target: BitmapDataWrapper<'gc>,
source: BitmapDataWrapper<'gc>,
source_point: (u32, u32),
@ -1354,7 +1354,7 @@ fn copy_on_cpu<'gc>(
#[allow(clippy::too_many_arguments)]
fn blend_and_transform<'gc>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
source: BitmapDataWrapper<'gc>,
dest: BitmapDataWrapper<'gc>,
source_region: PixelRegion,
@ -1410,7 +1410,7 @@ fn blend_and_transform<'gc>(
#[allow(clippy::too_many_arguments)]
pub fn draw<'gc>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
target: BitmapDataWrapper<'gc>,
mut source: IBitmapDrawable<'gc>,
transform: Transform,

View File

@ -84,9 +84,7 @@ impl<'a, 'gc> GcContext<'a, 'gc> {
/// `UpdateContext` holds shared data that is used by the various subsystems of Ruffle.
/// `Player` creates this when it begins a tick and passes it through the call stack to
/// children and the VM.
pub struct UpdateContext<'unused, 'gc> {
pub _unused: std::marker::PhantomData<&'unused ()>,
pub struct UpdateContext<'gc> {
/// The queue of actions that will be run after the display list updates.
/// Display objects and actions can push actions onto the queue.
pub action_queue: &'gc mut ActionQueue<'gc>,
@ -256,7 +254,7 @@ pub struct UpdateContext<'unused, 'gc> {
}
/// Convenience methods for controlling audio.
impl<'a, 'gc> UpdateContext<'a, 'gc> {
impl<'gc> UpdateContext<'gc> {
pub fn global_sound_transform(&self) -> &SoundTransform {
self.audio_manager.global_sound_transform()
}
@ -377,7 +375,7 @@ impl<'a, 'gc> UpdateContext<'a, 'gc> {
self.stage.set_movie(self.gc_context, self.swf.clone());
let stage_domain = self.avm2.stage_domain();
let mut activation = Avm2Activation::from_domain(self.reborrow(), stage_domain);
let mut activation = Avm2Activation::from_domain(self, stage_domain);
activation
.context
@ -428,10 +426,8 @@ impl<'a, 'gc> UpdateContext<'a, 'gc> {
self.stage.replace_at_depth(self, root, 0);
// Set the version parameter on the root.
let mut activation = Activation::from_stub(
self.reborrow(),
ActivationIdentifier::root("[Version Setter]"),
);
let mut activation =
Activation::from_stub(self, ActivationIdentifier::root("[Version Setter]"));
let object = root.object().coerce_to_object(&mut activation);
let version_string = activation
.context
@ -464,7 +460,7 @@ impl<'a, 'gc> UpdateContext<'a, 'gc> {
}
}
impl<'a, 'gc> UpdateContext<'a, 'gc> {
impl<'a, 'gc> UpdateContext<'gc> {
/// Convenience method to retrieve the current GC context. Note that explicitly writing
/// `self.gc_context` can be sometimes necessary to satisfy the borrow checker.
#[inline(always)]
@ -472,22 +468,6 @@ impl<'a, 'gc> UpdateContext<'a, 'gc> {
self.gc_context
}
/// Transform a borrowed update context into an owned update context with
/// a shorter internal lifetime.
///
/// This is particularly useful for structures that may wish to hold an
/// update context without adding further lifetimes for its borrowing.
/// Please note that you will not be able to use the original update
/// context until this reborrowed copy has fallen out of scope.
#[inline]
pub fn reborrow<'b>(&'b mut self) -> &'b mut UpdateContext<'b, 'gc>
where
'a: 'b,
{
// SAFETY: the first lifetime parameter is unused
unsafe { std::mem::transmute(self) }
}
#[inline]
pub fn borrow_gc<'b>(&'b mut self) -> GcContext<'b, 'gc>
where

View File

@ -52,7 +52,7 @@ impl<'gc> ContextMenuState<'gc> {
pub fn build_builtin_items(
&mut self,
item_flags: BuiltInItemFlags,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) {
let stage = context.stage;
let language = &context.ui.language();
@ -146,7 +146,7 @@ impl<'gc> ContextMenuState<'gc> {
}
}
fn build_text_items(&mut self, text: EditText<'gc>, context: &mut UpdateContext<'_, 'gc>) {
fn build_text_items(&mut self, text: EditText<'gc>, context: &mut UpdateContext<'gc>) {
let language = &context.ui.language();
self.push(
ContextMenuItem {

View File

@ -18,17 +18,14 @@ impl Avm1ObjectWindow {
pub fn show<'gc>(
&mut self,
egui_ctx: &egui::Context,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
object: Object<'gc>,
messages: &mut Vec<Message>,
) -> bool {
let mut keep_open = true;
let base_clip = context.stage.into();
let mut activation = Activation::from_nothing(
context.reborrow(),
ActivationIdentifier::root("Debug"),
base_clip,
);
let mut activation =
Activation::from_nothing(context, ActivationIdentifier::root("Debug"), base_clip);
Window::new(object_name(object))
.id(Id::new(object.as_ptr()))
.open(&mut keep_open)

View File

@ -41,13 +41,13 @@ impl Avm2ObjectWindow {
pub fn show<'gc>(
&mut self,
egui_ctx: &egui::Context,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
object: Object<'gc>,
messages: &mut Vec<Message>,
) -> bool {
let mut keep_open = true;
let domain = context.avm2.stage_domain();
let mut activation = Activation::from_domain(context.reborrow(), domain);
let mut activation = Activation::from_domain(context, domain);
Window::new(object_name(activation.context.gc_context, object))
.id(Id::new(object.as_ptr()))
.open(&mut keep_open)
@ -187,7 +187,7 @@ impl Avm2ObjectWindow {
&mut self,
array: std::cell::Ref<ArrayStorage<'gc>>,
messages: &mut Vec<Message>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
ui: &mut Ui,
) {
TableBuilder::new(ui)
@ -410,7 +410,7 @@ enum ValueWidget {
}
impl ValueWidget {
fn new<'gc>(context: &mut UpdateContext<'_, 'gc>, value: Value<'gc>) -> Self {
fn new<'gc>(context: &mut UpdateContext<'gc>, value: Value<'gc>) -> Self {
match value {
Value::Undefined => ValueWidget::Other(Cow::Borrowed("Undefined")),
Value::Null => ValueWidget::Other(Cow::Borrowed("Null")),
@ -474,7 +474,7 @@ impl ValueResultWidget {
pub fn show_avm2_value<'gc>(
ui: &mut Ui,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
value: Value<'gc>,
messages: &mut Vec<Message>,
) {

View File

@ -117,7 +117,7 @@ impl DisplayObjectWindow {
pub fn show<'gc>(
&mut self,
egui_ctx: &egui::Context,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
object: DisplayObject<'gc>,
messages: &mut Vec<Message>,
) -> bool {
@ -186,7 +186,7 @@ impl DisplayObjectWindow {
pub fn show_interactive<'gc>(
&mut self,
ui: &mut Ui,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
object: InteractiveObject<'gc>,
) {
Grid::new(ui.id().with("interactive"))
@ -296,7 +296,7 @@ impl DisplayObjectWindow {
pub fn show_edit_text<'gc>(
&mut self,
ui: &mut Ui,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
object: EditText<'gc>,
) {
Grid::new(ui.id().with("edittext"))
@ -519,7 +519,7 @@ impl DisplayObjectWindow {
pub fn show_bitmap<'gc>(
&mut self,
ui: &mut Ui,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
object: Bitmap<'gc>,
) {
let bitmap_data = object.bitmap_data(context.renderer);
@ -542,7 +542,7 @@ impl DisplayObjectWindow {
pub fn show_movieclip<'gc>(
&mut self,
ui: &mut Ui,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
object: MovieClip<'gc>,
) {
Grid::new(ui.id().with("movieclip"))
@ -655,7 +655,7 @@ impl DisplayObjectWindow {
pub fn show_stage<'gc>(
&mut self,
ui: &mut Ui,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
object: Stage<'gc>,
messages: &mut Vec<Message>,
) {
@ -756,7 +756,7 @@ impl DisplayObjectWindow {
pub fn show_display<'gc>(
&mut self,
ui: &mut Ui,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
object: DisplayObject<'gc>,
messages: &mut Vec<Message>,
) {
@ -933,7 +933,7 @@ impl DisplayObjectWindow {
pub fn show_position<'gc>(
&mut self,
ui: &mut Ui,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
object: DisplayObject<'gc>,
messages: &mut Vec<Message>,
) {
@ -1042,7 +1042,7 @@ impl DisplayObjectWindow {
pub fn show_children<'gc>(
&mut self,
ui: &mut Ui,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
object: DisplayObject<'gc>,
messages: &mut Vec<Message>,
) {
@ -1062,7 +1062,7 @@ impl DisplayObjectWindow {
pub fn show_display_tree<'gc>(
&mut self,
ui: &mut Ui,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
object: DisplayObject<'gc>,
messages: &mut Vec<Message>,
search: &WStr,
@ -1262,7 +1262,7 @@ fn bounds_label(ui: &mut Ui, bounds: Rectangle<Twips>, hover: &mut Option<Rectan
pub fn open_display_object_button<'gc>(
ui: &mut Ui,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
messages: &mut Vec<Message>,
object: DisplayObject<'gc>,
hover: &mut Option<DisplayObjectHandle>,

View File

@ -123,7 +123,7 @@ impl DisplayObjectSearchWindow {
fn create_result_tree<'gc>(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
cursor: Point<Twips>,
object: DisplayObject<'gc>,
add_to: &mut Vec<DisplayObjectTree>,

View File

@ -42,7 +42,7 @@ impl DomainListWindow {
pub fn show_domain<'gc>(
&mut self,
ui: &mut Ui,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
domain: Domain<'gc>,
messages: &mut Vec<Message>,
search: &str,
@ -87,7 +87,7 @@ impl DomainListWindow {
pub fn open_domain_button<'gc>(
ui: &mut Ui,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
messages: &mut Vec<Message>,
domain: Domain<'gc>,
) {

View File

@ -15,7 +15,7 @@ pub struct DisplayObjectHandle {
impl DisplayObjectHandle {
pub fn new<'gc>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
object: impl Into<DisplayObject<'gc>>,
) -> Self {
let object = object.into();
@ -64,10 +64,7 @@ pub struct AVM1ObjectHandle {
}
impl AVM1ObjectHandle {
pub fn new<'gc>(
context: &mut UpdateContext<'_, 'gc>,
object: crate::avm1::Object<'gc>,
) -> Self {
pub fn new<'gc>(context: &mut UpdateContext<'gc>, object: crate::avm1::Object<'gc>) -> Self {
Self {
root: context.dynamic_root.stash(context.gc_context, object),
ptr: object.as_ptr(),
@ -107,10 +104,7 @@ pub struct AVM2ObjectHandle {
}
impl AVM2ObjectHandle {
pub fn new<'gc>(
context: &mut UpdateContext<'_, 'gc>,
object: crate::avm2::Object<'gc>,
) -> Self {
pub fn new<'gc>(context: &mut UpdateContext<'gc>, object: crate::avm2::Object<'gc>) -> Self {
Self {
root: context.dynamic_root.stash(context.gc_context, object),
ptr: object.as_ptr(),
@ -152,10 +146,7 @@ pub struct DomainHandle {
}
impl DomainHandle {
pub fn new<'gc>(
context: &mut UpdateContext<'_, 'gc>,
domain: crate::avm2::Domain<'gc>,
) -> Self {
pub fn new<'gc>(context: &mut UpdateContext<'gc>, domain: crate::avm2::Domain<'gc>) -> Self {
Self {
root: context.dynamic_root.stash(context.gc_context, domain),
ptr: domain.as_ptr(),

View File

@ -1289,7 +1289,7 @@ pub trait TDisplayObject<'gc>:
/// Converts the mouse position on the stage to a local position on this display object.
/// If the object has zero scale, then the stage `TWIPS_TO_PIXELS` matrix will be used.
/// This matches Flash's behavior for `mouseX`/`mouseY` on an object with zero scale.
fn local_mouse_position(&self, context: &UpdateContext<'_, 'gc>) -> Point<Twips> {
fn local_mouse_position(&self, context: &UpdateContext<'gc>) -> Point<Twips> {
let stage = context.stage;
let pixel_ratio = stage.view_matrix().a;
let virtual_to_device = Matrix::scale(pixel_ratio, pixel_ratio);
@ -1426,7 +1426,7 @@ pub trait TDisplayObject<'gc>:
/// The width is based on the AABB of the object.
/// Set by the ActionScript `_width`/`width` properties.
/// This does odd things on rotated clips to match the behavior of Flash.
fn set_width(&self, context: &mut UpdateContext<'_, 'gc>, value: f64) {
fn set_width(&self, context: &mut UpdateContext<'gc>, value: f64) {
let gc_context = context.gc_context;
let object_bounds = self.bounds();
let object_width = object_bounds.width().to_pixels();
@ -1474,7 +1474,7 @@ pub trait TDisplayObject<'gc>:
/// Sets the pixel height of this display object in local space.
/// Set by the ActionScript `_height`/`height` properties.
/// This does odd things on rotated clips to match the behavior of Flash.
fn set_height(&self, context: &mut UpdateContext<'_, 'gc>, value: f64) {
fn set_height(&self, context: &mut UpdateContext<'gc>, value: f64) {
let gc_context = context.gc_context;
let object_bounds = self.bounds();
let object_width = object_bounds.width().to_pixels();
@ -1610,7 +1610,7 @@ pub trait TDisplayObject<'gc>:
}
/// Set the parent of this display object.
fn set_parent(&self, context: &mut UpdateContext<'_, 'gc>, parent: Option<DisplayObject<'gc>>) {
fn set_parent(&self, context: &mut UpdateContext<'gc>, parent: Option<DisplayObject<'gc>>) {
let had_parent = self.parent().is_some();
self.base_mut(context.gc_context)
.set_parent_ignoring_orphan_list(parent);
@ -1628,7 +1628,7 @@ pub trait TDisplayObject<'gc>:
/// This method is called when the parent is removed.
/// It may be overwritten to inject some implementation-specific behavior.
fn on_parent_removed(&self, _context: &mut UpdateContext<'_, 'gc>) {}
fn on_parent_removed(&self, _context: &mut UpdateContext<'gc>) {}
/// Retrieve the parent of this display object.
///
@ -1750,7 +1750,7 @@ pub trait TDisplayObject<'gc>:
/// Sets whether this display object will be visible.
/// Invisible objects are not rendered, but otherwise continue to exist normally.
/// Returned by the `_visible`/`visible` ActionScript properties.
fn set_visible(&self, context: &mut UpdateContext<'_, 'gc>, value: bool) {
fn set_visible(&self, context: &mut UpdateContext<'gc>, value: bool) {
if self.base_mut(context.gc()).set_visible(value) {
if let Some(parent) = self.parent() {
// We don't need to invalidate ourselves, we're just toggling if the bitmap is rendered.
@ -1831,7 +1831,7 @@ pub trait TDisplayObject<'gc>:
/// The sound transform for sounds played inside this display object.
fn set_sound_transform(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
sound_transform: SoundTransform,
) {
self.base_mut(context.gc_context)
@ -1941,11 +1941,11 @@ pub trait TDisplayObject<'gc>:
fn state(&self) -> Option<ButtonState> {
None
}
fn set_state(self, _context: &mut UpdateContext<'_, 'gc>, _state: ButtonState) {}
fn set_state(self, _context: &mut UpdateContext<'gc>, _state: ButtonState) {}
/// Run any start-of-frame actions for this display object.
///
/// When fired on `Stage`, this also emits the AVM2 `enterFrame` broadcast.
fn enter_frame(&self, _context: &mut UpdateContext<'_, 'gc>) {}
fn enter_frame(&self, _context: &mut UpdateContext<'gc>) {}
/// Construct all display objects that the timeline indicates should exist
/// this frame, and their children.
@ -1956,7 +1956,7 @@ pub trait TDisplayObject<'gc>:
/// 1. That the object itself has been allocated, if not constructed
/// 2. That newly created children have been instantiated and are present
/// as properties on the class
fn construct_frame(&self, _context: &mut UpdateContext<'_, 'gc>) {}
fn construct_frame(&self, _context: &mut UpdateContext<'gc>) {}
/// To be called when an AVM2 display object has finished being constructed.
///
@ -1975,7 +1975,7 @@ pub trait TDisplayObject<'gc>:
/// placed on the render list, these steps have to be done by the child
/// object to signal to its parent that it was added.
#[inline(never)]
fn on_construction_complete(&self, context: &mut UpdateContext<'_, 'gc>) {
fn on_construction_complete(&self, context: &mut UpdateContext<'gc>) {
let placed_by_script = self.placed_by_script();
self.fire_added_events(context);
// Check `self.placed_by_script()` before we fire events, since those
@ -2001,7 +2001,7 @@ pub trait TDisplayObject<'gc>:
}
}
fn fire_added_events(&self, context: &mut UpdateContext<'_, 'gc>) {
fn fire_added_events(&self, context: &mut UpdateContext<'gc>) {
if !self.placed_by_script() {
// Since we construct AVM2 display objects after they are
// allocated and placed on the render list, we have to emit all
@ -2017,7 +2017,7 @@ pub trait TDisplayObject<'gc>:
}
}
fn set_on_parent_field(&self, context: &mut UpdateContext<'_, 'gc>) {
fn set_on_parent_field(&self, context: &mut UpdateContext<'gc>) {
//TODO: Don't report missing property errors.
//TODO: Don't attempt to set properties if object was placed without a name.
if self.has_explicit_name() {
@ -2028,7 +2028,7 @@ pub trait TDisplayObject<'gc>:
.library_for_movie(self.movie())
.unwrap()
.avm2_domain();
let mut activation = Avm2Activation::from_domain(context.reborrow(), domain);
let mut activation = Avm2Activation::from_domain(context, domain);
let name =
Avm2Multiname::new(activation.avm2().find_public_namespace(), self.name());
if let Err(e) = p.init_property(&name, c.into(), &mut activation) {
@ -2044,11 +2044,11 @@ pub trait TDisplayObject<'gc>:
}
/// Execute all other timeline actions on this object.
fn run_frame_avm1(&self, _context: &mut UpdateContext<'_, 'gc>) {}
fn run_frame_avm1(&self, _context: &mut UpdateContext<'gc>) {}
/// Emit a `frameConstructed` event on this DisplayObject and any children it
/// may have.
fn frame_constructed(&self, context: &mut UpdateContext<'_, 'gc>) {
fn frame_constructed(&self, context: &mut UpdateContext<'gc>) {
let frame_constructed_evt =
Avm2EventObject::bare_default_event(context, "frameConstructed");
let dobject_constr = context.avm2.classes().display_object;
@ -2056,7 +2056,7 @@ pub trait TDisplayObject<'gc>:
}
/// Run any frame scripts (if they exist and this object needs to run them).
fn run_frame_scripts(self, context: &mut UpdateContext<'_, 'gc>) {
fn run_frame_scripts(self, context: &mut UpdateContext<'gc>) {
if let Some(container) = self.as_container() {
for child in container.iter_render_list() {
child.run_frame_scripts(context);
@ -2065,7 +2065,7 @@ pub trait TDisplayObject<'gc>:
}
/// Emit an `exitFrame` broadcast event.
fn exit_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn exit_frame(&self, context: &mut UpdateContext<'gc>) {
let exit_frame_evt = Avm2EventObject::bare_default_event(context, "exitFrame");
let dobject_constr = context.avm2.classes().display_object;
Avm2::broadcast_event(context, exit_frame_evt, dobject_constr);
@ -2073,7 +2073,7 @@ pub trait TDisplayObject<'gc>:
self.on_exit_frame(context);
}
fn on_exit_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn on_exit_frame(&self, context: &mut UpdateContext<'gc>) {
if let Some(container) = self.as_container() {
for child in container.iter_render_list() {
child.on_exit_frame(context);
@ -2134,7 +2134,7 @@ pub trait TDisplayObject<'gc>:
}
}
fn avm1_unload(&self, context: &mut UpdateContext<'_, 'gc>) {
fn avm1_unload(&self, context: &mut UpdateContext<'gc>) {
// Unload children.
if let Some(ctr) = self.as_container() {
for child in ctr.iter_render_list() {
@ -2198,7 +2198,7 @@ pub trait TDisplayObject<'gc>:
fn apply_place_object(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
place_object: &swf::PlaceObject,
) {
// PlaceObject tags only apply if this object has not been dynamically moved by AS code.
@ -2259,7 +2259,7 @@ pub trait TDisplayObject<'gc>:
}
/// Called when this object should be replaced by a PlaceObject tag.
fn replace_with(&self, _context: &mut UpdateContext<'_, 'gc>, _id: CharacterId) {
fn replace_with(&self, _context: &mut UpdateContext<'gc>, _id: CharacterId) {
// Noop for most symbols; only shapes can replace their innards with another Graphic.
}
@ -2271,7 +2271,7 @@ pub trait TDisplayObject<'gc>:
Avm2Value::Undefined // TODO: See above. Also, unconstructed objects should return null.
}
fn set_object2(&self, _context: &mut UpdateContext<'_, 'gc>, _to: Avm2Object<'gc>) {}
fn set_object2(&self, _context: &mut UpdateContext<'gc>, _to: Avm2Object<'gc>) {}
/// Tests if a given stage position point intersects with the world bounds of this object.
fn hit_test_bounds(&self, point: Point<Twips>) -> bool {
@ -2287,7 +2287,7 @@ pub trait TDisplayObject<'gc>:
/// Tests if a given stage position point intersects within this object, considering the art.
fn hit_test_shape(
&self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
point: Point<Twips>,
options: HitTestOptions,
) -> bool {
@ -2298,7 +2298,7 @@ pub trait TDisplayObject<'gc>:
fn post_instantiation(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
_init_object: Option<Avm1Object<'gc>>,
_instantiated_by: Instantiator,
run_frame: bool,
@ -2415,7 +2415,7 @@ pub trait TDisplayObject<'gc>:
/// will fail to locate the current player's stage for objects that are not
/// rooted to the DisplayObject hierarchy correctly. If you just want to
/// access the current player's stage, grab it from the context.
fn avm2_stage(&self, _context: &UpdateContext<'_, 'gc>) -> Option<DisplayObject<'gc>> {
fn avm2_stage(&self, _context: &UpdateContext<'gc>) -> Option<DisplayObject<'gc>> {
let mut parent = Some((*self).into());
while let Some(p) = parent {
if p.as_stage().is_some() {
@ -2427,7 +2427,7 @@ pub trait TDisplayObject<'gc>:
}
/// Determine if this display object is currently on the stage.
fn is_on_stage(self, context: &UpdateContext<'_, 'gc>) -> bool {
fn is_on_stage(self, context: &UpdateContext<'gc>) -> bool {
let mut ancestor = self.avm2_parent();
while let Some(parent) = ancestor {
if parent.avm2_parent().is_some() {
@ -2442,7 +2442,7 @@ pub trait TDisplayObject<'gc>:
}
/// Assigns a default instance name `instanceN` to this object.
fn set_default_instance_name(&self, context: &mut UpdateContext<'_, 'gc>) {
fn set_default_instance_name(&self, context: &mut UpdateContext<'gc>) {
if self.base().name().is_none() {
let name = format!("instance{}", *context.instance_counter);
self.set_name(
@ -2457,7 +2457,7 @@ pub trait TDisplayObject<'gc>:
///
/// The default root names change based on the AVM configuration of the
/// clip; AVM2 clips get `rootN` while AVM1 clips get blank strings.
fn set_default_root_name(&self, context: &mut UpdateContext<'_, 'gc>) {
fn set_default_root_name(&self, context: &mut UpdateContext<'gc>) {
if self.movie().is_action_script_3() {
let name = AvmString::new_utf8(context.gc_context, format!("root{}", self.depth() + 1));
self.set_name(context.gc_context, name);
@ -2499,16 +2499,16 @@ pub trait TDisplayObject<'gc>:
/// This is required as some boolean properties in AVM1 can in fact hold any value.
fn get_avm1_boolean_property<F>(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
name: &'static str,
default: F,
) -> bool
where
F: FnOnce(&mut UpdateContext<'_, 'gc>) -> bool,
F: FnOnce(&mut UpdateContext<'gc>) -> bool,
{
if let Avm1Value::Object(object) = self.object() {
let mut activation = Activation::from_nothing(
context.reborrow(),
context,
Avm1ActivationIdentifier::root("[AVM1 Boolean Property]"),
self.avm1_root(),
);
@ -2527,13 +2527,13 @@ pub trait TDisplayObject<'gc>:
fn set_avm1_property(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
name: &'static str,
value: Avm1Value<'gc>,
) {
if let Avm1Value::Object(object) = self.object() {
let mut activation = Activation::from_nothing(
context.reborrow(),
context,
Avm1ActivationIdentifier::root("[AVM1 Property Set]"),
self.avm1_root(),
);

View File

@ -129,7 +129,7 @@ impl<'gc> Avm1Button<'gc> {
///
/// This function instantiates children and thus must not be called whilst
/// the caller is holding a write lock on the button data.
pub fn set_state(mut self, context: &mut UpdateContext<'_, 'gc>, state: ButtonState) {
pub fn set_state(mut self, context: &mut UpdateContext<'gc>, state: ButtonState) {
let mut removed_depths: fnv::FnvHashSet<_> =
self.iter_render_list().map(|o| o.depth()).collect();
@ -208,13 +208,13 @@ impl<'gc> Avm1Button<'gc> {
fn get_boolean_property(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
name: &'static str,
default: bool,
) -> bool {
if let Value::Object(object) = self.object() {
let mut activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[AVM1 Boolean Property]"),
self.avm1_root(),
);
@ -231,11 +231,11 @@ impl<'gc> Avm1Button<'gc> {
}
}
fn enabled(self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn enabled(self, context: &mut UpdateContext<'gc>) -> bool {
self.get_boolean_property(context, "enabled", true)
}
fn use_hand_cursor(self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn use_hand_cursor(self, context: &mut UpdateContext<'gc>) -> bool {
self.get_boolean_property(context, "useHandCursor", true)
}
}
@ -269,7 +269,7 @@ impl<'gc> TDisplayObject<'gc> for Avm1Button<'gc> {
fn post_instantiation(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
_init_object: Option<Object<'gc>>,
_instantiated_by: Instantiator,
run_frame: bool,
@ -297,7 +297,7 @@ impl<'gc> TDisplayObject<'gc> for Avm1Button<'gc> {
}
}
fn run_frame_avm1(&self, context: &mut UpdateContext<'_, 'gc>) {
fn run_frame_avm1(&self, context: &mut UpdateContext<'gc>) {
let self_display_object = (*self).into();
let initialized = self.0.initialized.get();
@ -355,7 +355,7 @@ impl<'gc> TDisplayObject<'gc> for Avm1Button<'gc> {
fn hit_test_shape(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
point: Point<Twips>,
options: HitTestOptions,
) -> bool {
@ -392,7 +392,7 @@ impl<'gc> TDisplayObject<'gc> for Avm1Button<'gc> {
!self.is_empty()
}
fn avm1_unload(&self, context: &mut UpdateContext<'_, 'gc>) {
fn avm1_unload(&self, context: &mut UpdateContext<'gc>) {
self.drop_focus(context);
if let Some(node) = self.maskee() {
node.set_masker(context.gc(), None, true);
@ -433,7 +433,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> {
fn filter_clip_event(
self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
event: ClipEvent,
) -> ClipEventResult {
// An invisible button can still run its `rollOut` or `releaseOutside` event.
@ -457,11 +457,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> {
ClipEventResult::Handled
}
fn event_dispatch(
self,
context: &mut UpdateContext<'_, 'gc>,
event: ClipEvent,
) -> ClipEventResult {
fn event_dispatch(self, context: &mut UpdateContext<'gc>, event: ClipEvent) -> ClipEventResult {
let self_display_object = self.into();
let is_enabled = self.enabled(context);
@ -563,7 +559,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> {
fn mouse_pick_avm1(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
point: Point<Twips>,
require_button_mode: bool,
) -> Option<InteractiveObject<'gc>> {
@ -589,14 +585,14 @@ impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> {
fn mouse_pick_avm2(
&self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
_point: Point<Twips>,
_require_button_mode: bool,
) -> Avm2MousePick<'gc> {
Avm2MousePick::Miss
}
fn mouse_cursor(self, context: &mut UpdateContext<'_, 'gc>) -> MouseCursor {
fn mouse_cursor(self, context: &mut UpdateContext<'gc>) -> MouseCursor {
if self.use_hand_cursor(context) && self.enabled(context) {
MouseCursor::Hand
} else {
@ -604,7 +600,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> {
}
}
fn tab_enabled_default(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
fn tab_enabled_default(&self, _context: &mut UpdateContext<'gc>) -> bool {
true
}
@ -621,7 +617,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> {
impl<'gc> Avm1ButtonData<'gc> {
fn run_actions(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
condition: ButtonActionCondition,
) -> ClipEventResult {
let mut handled = ClipEventResult::NotHandled;

View File

@ -100,7 +100,7 @@ impl<'gc> Avm2Button<'gc> {
pub fn from_swf_tag(
button: &swf::Button,
source_movie: &SwfSlice,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
construct_blank_states: bool,
) -> Self {
Avm2Button(Gc::new(
@ -142,7 +142,7 @@ impl<'gc> Avm2Button<'gc> {
))
}
pub fn empty_button(context: &mut UpdateContext<'_, 'gc>) -> Self {
pub fn empty_button(context: &mut UpdateContext<'gc>) -> Self {
let movie = context.swf.clone();
let button_record = swf::Button {
id: 0,
@ -189,7 +189,7 @@ impl<'gc> Avm2Button<'gc> {
/// should signal events on all children of the returned display object.
fn create_state(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
swf_state: swf::ButtonState,
) -> (DisplayObject<'gc>, bool) {
let movie = self.movie();
@ -278,7 +278,7 @@ impl<'gc> Avm2Button<'gc> {
}
/// Change the rendered state of the button.
pub fn set_state(self, context: &mut UpdateContext<'_, 'gc>, state: ButtonState) {
pub fn set_state(self, context: &mut UpdateContext<'gc>, state: ButtonState) {
self.invalidate_cached_bitmap(context.gc());
self.0.state.set(state);
@ -327,7 +327,7 @@ impl<'gc> Avm2Button<'gc> {
/// Set the display object that represents a particular button state.
pub fn set_state_child(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
state: swf::ButtonState,
child: Option<DisplayObject<'gc>>,
) {
@ -384,7 +384,7 @@ impl<'gc> Avm2Button<'gc> {
self.0.enabled.get()
}
pub fn set_enabled(self, context: &mut UpdateContext<'_, 'gc>, enabled: bool) {
pub fn set_enabled(self, context: &mut UpdateContext<'gc>, enabled: bool) {
self.0.enabled.set(enabled);
if !enabled {
self.set_state(context, ButtonState::Up);
@ -440,7 +440,7 @@ impl<'gc> TDisplayObject<'gc> for Avm2Button<'gc> {
fn post_instantiation(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
_init_object: Option<Avm1Object<'gc>>,
_instantiated_by: Instantiator,
_run_frame: bool,
@ -448,13 +448,13 @@ impl<'gc> TDisplayObject<'gc> for Avm2Button<'gc> {
self.set_default_instance_name(context);
}
fn enter_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn enter_frame(&self, context: &mut UpdateContext<'gc>) {
for state in self.all_state_children(false) {
state.enter_frame(context);
}
}
fn construct_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn construct_frame(&self, context: &mut UpdateContext<'gc>) {
for state in self.all_state_children(false) {
state.construct_frame(context);
}
@ -465,7 +465,7 @@ impl<'gc> TDisplayObject<'gc> for Avm2Button<'gc> {
if self.0.needs_frame_construction.get() {
if needs_avm2_construction {
let object_cell = unlock!(Gc::write(context.gc(), self.0), Avm2ButtonData, object);
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
match Avm2StageObject::for_display_object(&mut activation, (*self).into(), class) {
Ok(object) => object_cell.set(Some(object.into())),
Err(e) => tracing::error!("Got {} when constructing AVM2 side of button", e),
@ -551,7 +551,7 @@ impl<'gc> TDisplayObject<'gc> for Avm2Button<'gc> {
}
if let Some(avm2_object) = self.0.object.get() {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
if let Err(e) = class.call_native_init(avm2_object.into(), &[], &mut activation)
{
tracing::error!("Got {} when constructing AVM2 side of button", e);
@ -565,7 +565,7 @@ impl<'gc> TDisplayObject<'gc> for Avm2Button<'gc> {
}
}
fn run_frame_scripts(self, context: &mut UpdateContext<'_, 'gc>) {
fn run_frame_scripts(self, context: &mut UpdateContext<'gc>) {
for state in self.all_state_children(self.0.weird_framescript_order.take()) {
state.run_frame_scripts(context);
}
@ -636,7 +636,7 @@ impl<'gc> TDisplayObject<'gc> for Avm2Button<'gc> {
fn hit_test_shape(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
point: Point<Twips>,
options: HitTestOptions,
) -> bool {
@ -671,7 +671,7 @@ impl<'gc> TDisplayObject<'gc> for Avm2Button<'gc> {
.unwrap_or(Avm2Value::Null)
}
fn set_object2(&self, context: &mut UpdateContext<'_, 'gc>, to: Avm2Object<'gc>) {
fn set_object2(&self, context: &mut UpdateContext<'gc>, to: Avm2Object<'gc>) {
let write = Gc::write(context.gc(), self.0);
unlock!(write, Avm2ButtonData, object).set(Some(to));
}
@ -710,7 +710,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm2Button<'gc> {
fn filter_clip_event(
self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
event: ClipEvent,
) -> ClipEventResult {
if !self.visible() {
@ -726,7 +726,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm2Button<'gc> {
fn propagate_to_children(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event: ClipEvent<'gc>,
) -> ClipEventResult {
if event.propagates() {
@ -744,7 +744,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm2Button<'gc> {
fn event_dispatch(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event: ClipEvent<'gc>,
) -> ClipEventResult {
// Translate the clip event to a button event, based on how the button state changes.
@ -778,7 +778,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm2Button<'gc> {
fn mouse_pick_avm2(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
mut point: Point<Twips>,
require_button_mode: bool,
) -> Avm2MousePick<'gc> {
@ -816,7 +816,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm2Button<'gc> {
Avm2MousePick::Miss
}
fn mouse_cursor(self, _context: &mut UpdateContext<'_, 'gc>) -> MouseCursor {
fn mouse_cursor(self, _context: &mut UpdateContext<'gc>) -> MouseCursor {
// TODO: Should we also need to check for the `enabled` property like AVM1 buttons?
if self.use_hand_cursor() {
MouseCursor::Hand
@ -825,7 +825,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm2Button<'gc> {
}
}
fn tab_enabled_default(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
fn tab_enabled_default(&self, _context: &mut UpdateContext<'gc>) -> bool {
true
}

View File

@ -62,7 +62,7 @@ pub enum BitmapClass<'gc> {
impl<'gc> BitmapClass<'gc> {
pub fn from_class_object(
class: Avm2ClassObject<'gc>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Option<Self> {
let class_definition = class.inner_class_definition();
if class_definition
@ -243,7 +243,7 @@ impl<'gc> Bitmap<'gc> {
/// if that has not already been done.
pub fn set_bitmap_data(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
bitmap_data: BitmapDataWrapper<'gc>,
) {
let weak_self = DisplayObjectWeak::Bitmap(self.downgrade());
@ -326,13 +326,13 @@ impl<'gc> TDisplayObject<'gc> for Bitmap<'gc> {
fn post_instantiation(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
_init_object: Option<avm1::Object<'gc>>,
instantiated_by: Instantiator,
run_frame: bool,
) {
if self.movie().is_action_script_3() {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
if !instantiated_by.is_avm() {
let bitmap_cls = self
.avm2_bitmap_class()
@ -399,7 +399,7 @@ impl<'gc> TDisplayObject<'gc> for Bitmap<'gc> {
.unwrap_or(Avm2Value::Null)
}
fn set_object2(&self, context: &mut UpdateContext<'_, 'gc>, to: Avm2Object<'gc>) {
fn set_object2(&self, context: &mut UpdateContext<'gc>, to: Avm2Object<'gc>) {
self.0.write(context.gc_context).avm2_object = Some(to);
}

View File

@ -29,7 +29,7 @@ use std::sync::Arc;
/// grandchildren, recursively.
pub fn dispatch_removed_from_stage_event<'gc>(
child: DisplayObject<'gc>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) {
if let Avm2Value::Object(object) = child.object2() {
let removed_evt = Avm2EventObject::bare_default_event(context, "removedFromStage");
@ -45,10 +45,7 @@ pub fn dispatch_removed_from_stage_event<'gc>(
/// Dispatch the `removed` event on a child and log any errors encountered
/// whilst doing so.
pub fn dispatch_removed_event<'gc>(
child: DisplayObject<'gc>,
context: &mut UpdateContext<'_, 'gc>,
) {
pub fn dispatch_removed_event<'gc>(child: DisplayObject<'gc>, context: &mut UpdateContext<'gc>) {
if let Avm2Value::Object(object) = child.object2() {
let removed_evt = Avm2EventObject::bare_event(context, "removed", true, false);
Avm2::dispatch_event(context, removed_evt, object);
@ -62,7 +59,7 @@ pub fn dispatch_removed_event<'gc>(
/// Dispatch the `addedToStage` event on a child, ignoring it's grandchildren.
pub fn dispatch_added_to_stage_event_only<'gc>(
child: DisplayObject<'gc>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) {
if let Avm2Value::Object(object) = child.object2() {
let added_evt = Avm2EventObject::bare_default_event(context, "addedToStage");
@ -74,7 +71,7 @@ pub fn dispatch_added_to_stage_event_only<'gc>(
/// recursively.
pub fn dispatch_added_to_stage_event<'gc>(
child: DisplayObject<'gc>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) {
dispatch_added_to_stage_event_only(child, context);
@ -92,10 +89,7 @@ pub fn dispatch_added_to_stage_event<'gc>(
/// Dispatch an `added` event to one object, and log any errors encountered
/// whilst doing so.
pub fn dispatch_added_event_only<'gc>(
child: DisplayObject<'gc>,
context: &mut UpdateContext<'_, 'gc>,
) {
pub fn dispatch_added_event_only<'gc>(child: DisplayObject<'gc>, context: &mut UpdateContext<'gc>) {
if let Avm2Value::Object(object) = child.object2() {
let added_evt = Avm2EventObject::bare_event(context, "added", true, false);
Avm2::dispatch_event(context, added_evt, object);
@ -112,7 +106,7 @@ pub fn dispatch_added_event<'gc>(
parent: DisplayObject<'gc>,
child: DisplayObject<'gc>,
child_was_on_stage: bool,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) {
dispatch_added_event_only(child, context);
@ -195,7 +189,7 @@ pub trait TDisplayObjectContainer<'gc>:
/// children it modifies. You must do this yourself.
fn replace_at_depth(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
child: DisplayObject<'gc>,
depth: Depth,
) -> Option<DisplayObject<'gc>> {
@ -229,7 +223,7 @@ pub trait TDisplayObjectContainer<'gc>:
/// way as `replace_at_depth`.
fn swap_at_depth(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
child: DisplayObject<'gc>,
depth: Depth,
) {
@ -253,7 +247,7 @@ pub trait TDisplayObjectContainer<'gc>:
/// timeline) produce unusual results.
fn insert_at_index(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
child: DisplayObject<'gc>,
index: usize,
) {
@ -293,12 +287,7 @@ pub trait TDisplayObjectContainer<'gc>:
/// Swap two children in the render list.
///
/// No changes to the depth or render lists are made by this function.
fn swap_at_index(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
index1: usize,
index2: usize,
) {
fn swap_at_index(&mut self, context: &mut UpdateContext<'gc>, index1: usize, index2: usize) {
self.raw_container_mut(context.gc_context)
.swap_at_id(index1, index2);
let this: DisplayObject<'_> = (*self).into();
@ -308,7 +297,7 @@ pub trait TDisplayObjectContainer<'gc>:
/// Remove (and unloads) a child display object from this container's render and depth lists.
///
/// Will also handle AVM1 delayed clip removal, when a unload listener is present
fn remove_child(&mut self, context: &mut UpdateContext<'_, 'gc>, child: DisplayObject<'gc>) {
fn remove_child(&mut self, context: &mut UpdateContext<'gc>, child: DisplayObject<'gc>) {
let this: DisplayObject<'_> = (*self).into();
// We should always be the parent of this child
@ -321,7 +310,7 @@ pub trait TDisplayObjectContainer<'gc>:
if !self.raw_container().movie().is_action_script_3() {
let should_delay_removal = {
let mut activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[Unload Handler Check]"),
this.avm1_root(),
);
@ -355,11 +344,7 @@ pub trait TDisplayObjectContainer<'gc>:
}
/// Remove (and unloads) a child display object from this container's render and depth lists.
fn remove_child_directly(
&self,
context: &mut UpdateContext<'_, 'gc>,
child: DisplayObject<'gc>,
) {
fn remove_child_directly(&self, context: &mut UpdateContext<'gc>, child: DisplayObject<'gc>) {
dispatch_removed_event(child, context);
let this: DisplayObjectContainer<'gc> = (*self).into();
let mut write = self.raw_container_mut(context.gc_context);
@ -387,7 +372,7 @@ pub trait TDisplayObjectContainer<'gc>:
/// Insert a child directly into this container's depth list.
fn insert_child_into_depth_list(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
depth: Depth,
child: DisplayObject<'gc>,
) {
@ -404,7 +389,7 @@ pub trait TDisplayObjectContainer<'gc>:
/// Removes (without unloading) a child display object from this container's depth list.
fn remove_child_from_depth_list(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
child: DisplayObject<'gc>,
) {
debug_assert!(DisplayObject::ptr_eq(
@ -421,7 +406,7 @@ pub trait TDisplayObjectContainer<'gc>:
/// Remove a set of children identified by their render list indices from
/// this container's render and depth lists.
fn remove_range<R>(&mut self, context: &mut UpdateContext<'_, 'gc>, range: R)
fn remove_range<R>(&mut self, context: &mut UpdateContext<'gc>, range: R)
where
R: RangeBounds<usize>,
{
@ -481,7 +466,7 @@ pub trait TDisplayObjectContainer<'gc>:
RenderIter::from_container(self.into())
}
fn is_tab_children_avm1(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_tab_children_avm1(&self, _context: &mut UpdateContext<'gc>) -> bool {
true
}
@ -493,7 +478,7 @@ pub trait TDisplayObjectContainer<'gc>:
/// _NOTE:_
/// According to the AS2 documentation, it should affect only automatic tab ordering.
/// However, that does not seem to be the case, as it also affects custom ordering.
fn is_tab_children(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_tab_children(&self, context: &mut UpdateContext<'gc>) -> bool {
let this: DisplayObject<'_> = (*self).into();
if this.movie().is_action_script_3() {
self.raw_container().tab_children
@ -502,7 +487,7 @@ pub trait TDisplayObjectContainer<'gc>:
}
}
fn set_tab_children(&self, context: &mut UpdateContext<'_, 'gc>, value: bool) {
fn set_tab_children(&self, context: &mut UpdateContext<'gc>, value: bool) {
let this: DisplayObject<'_> = (*self).into();
if this.movie().is_action_script_3() {
self.raw_container_mut(context.gc()).tab_children = value;
@ -511,7 +496,7 @@ pub trait TDisplayObjectContainer<'gc>:
}
}
fn fill_tab_order(&self, tab_order: &mut TabOrder<'gc>, context: &mut UpdateContext<'_, 'gc>) {
fn fill_tab_order(&self, tab_order: &mut TabOrder<'gc>, context: &mut UpdateContext<'gc>) {
if !self.is_tab_children(context) {
// AS3 docs say that objects with custom ordering (tabIndex set)
// are included even when tabChildren is false.
@ -714,7 +699,7 @@ impl<'gc> ChildContainer<'gc> {
fn remove_child_from_render_list(
container: DisplayObjectContainer<'gc>,
child: DisplayObject<'gc>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> bool {
let mut this = container.raw_container_mut(context.gc_context);
@ -734,7 +719,7 @@ impl<'gc> ChildContainer<'gc> {
);
if child.has_explicit_name() {
if let Avm2Value::Object(parent_obj) = parent.object2() {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let name = Avm2Multiname::new(
activation.avm2().find_public_namespace(),
child.name(),
@ -992,7 +977,7 @@ impl<'gc> ChildContainer<'gc> {
/// `parent` should be the display object that owns this container.
fn swap_at_depth(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
parent: DisplayObject<'gc>,
child: DisplayObject<'gc>,
depth: Depth,
@ -1094,7 +1079,7 @@ impl<'gc> ChildContainer<'gc> {
///
/// This just moves the children to a negative depth
/// Will also fire unload events, as they should occur when the removal is queued, not when it actually occurs
fn queue_removal(child: DisplayObject<'gc>, context: &mut UpdateContext<'_, 'gc>) {
fn queue_removal(child: DisplayObject<'gc>, context: &mut UpdateContext<'gc>) {
if let Some(c) = child.as_container() {
for child in c.iter_render_list() {
Self::queue_removal(child, context);

View File

@ -196,7 +196,7 @@ impl<'gc> EditText<'gc> {
/// Creates a new `EditText` from an SWF `DefineEditText` tag.
pub fn from_swf_tag(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
swf_movie: Arc<SwfMovie>,
swf_tag: swf::EditText,
) -> Self {
@ -316,7 +316,7 @@ impl<'gc> EditText<'gc> {
/// Create a new, dynamic `EditText`.
pub fn new(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
swf_movie: Arc<SwfMovie>,
x: f64,
y: f64,
@ -350,7 +350,7 @@ impl<'gc> EditText<'gc> {
/// Create a new, dynamic `EditText` representing an AVM2 TextLine.
pub fn new_tlf(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
swf_movie: Arc<SwfMovie>,
x: f64,
y: f64,
@ -368,7 +368,7 @@ impl<'gc> EditText<'gc> {
self.0.read().text_spans.text().into()
}
pub fn set_text(self, text: &WStr, context: &mut UpdateContext<'_, 'gc>) {
pub fn set_text(self, text: &WStr, context: &mut UpdateContext<'gc>) {
let mut edit_text = self.0.write(context.gc_context);
let default_format = edit_text.text_spans.default_format().clone();
edit_text.text_spans = FormatSpans::from_text(text.into(), default_format);
@ -386,7 +386,7 @@ impl<'gc> EditText<'gc> {
}
}
pub fn set_html_text(self, text: &WStr, context: &mut UpdateContext<'_, 'gc>) {
pub fn set_html_text(self, text: &WStr, context: &mut UpdateContext<'gc>) {
if self.is_html() {
let mut write = self.0.write(context.gc_context);
let default_format = write.text_spans.default_format().clone();
@ -413,7 +413,7 @@ impl<'gc> EditText<'gc> {
self.0.read().text_spans.default_format().clone()
}
pub fn set_new_text_format(self, tf: TextFormat, context: &mut UpdateContext<'_, 'gc>) {
pub fn set_new_text_format(self, tf: TextFormat, context: &mut UpdateContext<'gc>) {
self.0
.write(context.gc_context)
.text_spans
@ -430,7 +430,7 @@ impl<'gc> EditText<'gc> {
from: usize,
to: usize,
tf: TextFormat,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) {
// TODO: Convert to byte indices
self.0
@ -448,7 +448,7 @@ impl<'gc> EditText<'gc> {
self.0.read().flags.contains(EditTextFlag::WAS_STATIC)
}
pub fn set_editable(self, is_editable: bool, context: &mut UpdateContext<'_, 'gc>) {
pub fn set_editable(self, is_editable: bool, context: &mut UpdateContext<'gc>) {
self.0
.write(context.gc_context)
.flags
@ -459,7 +459,7 @@ impl<'gc> EditText<'gc> {
self.0.read().mouse_wheel_enabled
}
pub fn set_mouse_wheel_enabled(self, is_enabled: bool, context: &mut UpdateContext<'_, 'gc>) {
pub fn set_mouse_wheel_enabled(self, is_enabled: bool, context: &mut UpdateContext<'gc>) {
self.0.write(context.gc_context).mouse_wheel_enabled = is_enabled;
}
@ -471,7 +471,7 @@ impl<'gc> EditText<'gc> {
self.0.read().flags.contains(EditTextFlag::PASSWORD)
}
pub fn set_password(self, is_password: bool, context: &mut UpdateContext<'_, 'gc>) {
pub fn set_password(self, is_password: bool, context: &mut UpdateContext<'gc>) {
self.0
.write(context.gc_context)
.flags
@ -483,11 +483,11 @@ impl<'gc> EditText<'gc> {
return self.0.read().restrict.value().map(Into::into);
}
pub fn set_restrict(self, text: Option<&WStr>, context: &mut UpdateContext<'_, 'gc>) {
pub fn set_restrict(self, text: Option<&WStr>, context: &mut UpdateContext<'gc>) {
self.0.write(context.gc_context).restrict = EditTextRestrict::from(text);
}
pub fn set_multiline(self, is_multiline: bool, context: &mut UpdateContext<'_, 'gc>) {
pub fn set_multiline(self, is_multiline: bool, context: &mut UpdateContext<'gc>) {
self.0
.write(context.gc_context)
.flags
@ -499,7 +499,7 @@ impl<'gc> EditText<'gc> {
!self.0.read().flags.contains(EditTextFlag::NO_SELECT)
}
pub fn set_selectable(self, is_selectable: bool, context: &mut UpdateContext<'_, 'gc>) {
pub fn set_selectable(self, is_selectable: bool, context: &mut UpdateContext<'gc>) {
self.0
.write(context.gc_context)
.flags
@ -510,7 +510,7 @@ impl<'gc> EditText<'gc> {
self.0.read().flags.contains(EditTextFlag::WORD_WRAP)
}
pub fn set_word_wrap(self, is_word_wrap: bool, context: &mut UpdateContext<'_, 'gc>) {
pub fn set_word_wrap(self, is_word_wrap: bool, context: &mut UpdateContext<'gc>) {
self.0
.write(context.gc_context)
.flags
@ -522,7 +522,7 @@ impl<'gc> EditText<'gc> {
self.0.read().autosize
}
pub fn set_autosize(self, asm: AutoSizeMode, context: &mut UpdateContext<'_, 'gc>) {
pub fn set_autosize(self, asm: AutoSizeMode, context: &mut UpdateContext<'gc>) {
self.0.write(context.gc_context).autosize = asm;
self.relayout(context);
}
@ -573,7 +573,7 @@ impl<'gc> EditText<'gc> {
self.0.read().flags.contains(EditTextFlag::CONDENSE_WHITE)
}
pub fn set_condense_white(self, context: &mut UpdateContext<'_, 'gc>, condense_white: bool) {
pub fn set_condense_white(self, context: &mut UpdateContext<'gc>, condense_white: bool) {
self.0
.write(context.gc())
.flags
@ -587,7 +587,7 @@ impl<'gc> EditText<'gc> {
.contains(EditTextFlag::ALWAYS_SHOW_SELECTION)
}
pub fn set_always_show_selection(self, context: &mut UpdateContext<'_, 'gc>, value: bool) {
pub fn set_always_show_selection(self, context: &mut UpdateContext<'gc>, value: bool) {
self.0
.write(context.gc())
.flags
@ -598,7 +598,7 @@ impl<'gc> EditText<'gc> {
!self.0.read().flags.contains(EditTextFlag::USE_OUTLINES)
}
pub fn set_is_device_font(self, context: &mut UpdateContext<'_, 'gc>, is_device_font: bool) {
pub fn set_is_device_font(self, context: &mut UpdateContext<'gc>, is_device_font: bool) {
self.0
.write(context.gc_context)
.flags
@ -610,7 +610,7 @@ impl<'gc> EditText<'gc> {
self.0.read().flags.contains(EditTextFlag::HTML)
}
pub fn set_is_html(self, context: &mut UpdateContext<'_, 'gc>, is_html: bool) {
pub fn set_is_html(self, context: &mut UpdateContext<'gc>, is_html: bool) {
self.0
.write(context.gc_context)
.flags
@ -632,7 +632,7 @@ impl<'gc> EditText<'gc> {
.contains(EditTextFlag::DRAW_LAYOUT_BOXES)
}
pub fn set_draw_layout_boxes(self, context: &mut UpdateContext<'_, 'gc>, value: bool) {
pub fn set_draw_layout_boxes(self, context: &mut UpdateContext<'gc>, value: bool) {
self.0
.write(context.gc())
.flags
@ -644,7 +644,7 @@ impl<'gc> EditText<'gc> {
from: usize,
to: usize,
text: &WStr,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) {
self.0
.write(context.gc_context)
@ -742,7 +742,7 @@ impl<'gc> EditText<'gc> {
/// the text, and no higher-level representation. Specifically, CSS should
/// have already been calculated and applied to HTML trees lowered into the
/// text-span representation.
fn relayout(self, context: &mut UpdateContext<'_, 'gc>) {
fn relayout(self, context: &mut UpdateContext<'gc>) {
let mut edit_text = self.0.write(context.gc_context);
let autosize = edit_text.autosize;
let is_word_wrap = edit_text.flags.contains(EditTextFlag::WORD_WRAP);
@ -821,7 +821,7 @@ impl<'gc> EditText<'gc> {
/// Measure the width and height of the `EditText`'s current text load.
///
/// The returned tuple should be interpreted as width, then height.
pub fn measure_text(self, _context: &mut UpdateContext<'_, 'gc>) -> (Twips, Twips) {
pub fn measure_text(self, _context: &mut UpdateContext<'gc>) -> (Twips, Twips) {
let exterior_bounds = self.0.read().layout.exterior_bounds();
(exterior_bounds.width(), exterior_bounds.height())
}
@ -1143,7 +1143,7 @@ impl<'gc> EditText<'gc> {
/// Unsets a bound display object from this text field.
/// Does not change the unbound text field list.
/// Caller is responsible for adding this text field to the unbound list, if necessary.
pub fn clear_bound_stage_object(self, context: &mut UpdateContext<'_, 'gc>) {
pub fn clear_bound_stage_object(self, context: &mut UpdateContext<'gc>) {
self.0.write(context.gc_context).bound_stage_object = None;
}
@ -1250,7 +1250,7 @@ impl<'gc> EditText<'gc> {
self.0.read().hscroll
}
pub fn set_hscroll(self, hscroll: f64, context: &mut UpdateContext<'_, 'gc>) {
pub fn set_hscroll(self, hscroll: f64, context: &mut UpdateContext<'gc>) {
self.0.write(context.gc_context).hscroll = hscroll;
}
@ -1258,7 +1258,7 @@ impl<'gc> EditText<'gc> {
self.0.read().scroll
}
pub fn set_scroll(self, scroll: f64, context: &mut UpdateContext<'_, 'gc>) {
pub fn set_scroll(self, scroll: f64, context: &mut UpdateContext<'gc>) {
// derived experimentally. Not exact: overflows somewhere above 767100486418432.9
// Checked in SWF 6, AVM1. Same in AVM2.
const SCROLL_OVERFLOW_LIMIT: f64 = 767100486418433.0;
@ -1276,7 +1276,7 @@ impl<'gc> EditText<'gc> {
self.0.read().max_chars
}
pub fn set_max_chars(self, value: i32, context: &mut UpdateContext<'_, 'gc>) {
pub fn set_max_chars(self, value: i32, context: &mut UpdateContext<'gc>) {
self.0.write(context.gc_context).max_chars = value;
}
@ -1374,7 +1374,7 @@ impl<'gc> EditText<'gc> {
pub fn is_text_control_applicable(
self,
control_code: TextControlCode,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> bool {
if !self.is_editable() && control_code.is_edit_input() {
return false;
@ -1405,7 +1405,7 @@ impl<'gc> EditText<'gc> {
pub fn text_control_input(
self,
control_code: TextControlCode,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) {
if !self.is_text_control_applicable(control_code, context) {
return;
@ -1580,7 +1580,7 @@ impl<'gc> EditText<'gc> {
}
if changed {
let mut activation = Avm1Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[Propagate Text Binding]"),
self.into(),
);
@ -1699,7 +1699,7 @@ impl<'gc> EditText<'gc> {
self.text().get(pos).unwrap_or(0) == '\n' as u16
}
pub fn text_input(self, character: char, context: &mut UpdateContext<'_, 'gc>) {
pub fn text_input(self, character: char, context: &mut UpdateContext<'gc>) {
if self.0.read().flags.contains(EditTextFlag::READ_ONLY)
|| (character.is_control() && character != Self::INPUT_NEWLINE)
|| self.available_chars() == 0
@ -1722,7 +1722,7 @@ impl<'gc> EditText<'gc> {
if let Avm2Value::Object(target) = self.object2() {
let character_string = AvmString::new_utf8(context.gc_context, character.to_string());
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let text_evt = Avm2EventObject::text_event(
&mut activation,
"textInput",
@ -1750,7 +1750,7 @@ impl<'gc> EditText<'gc> {
);
let mut activation = Avm1Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[Propagate Text Binding]"),
self.into(),
);
@ -1811,7 +1811,7 @@ impl<'gc> EditText<'gc> {
}
/// Construct the text field's AVM1 representation.
fn construct_as_avm1_object(&self, context: &mut UpdateContext<'_, 'gc>, run_frame: bool) {
fn construct_as_avm1_object(&self, context: &mut UpdateContext<'gc>, run_frame: bool) {
let mut text = self.0.write(context.gc_context);
if text.object.is_none() {
let object: Avm1Object<'gc> = Avm1StageObject::for_display_object(
@ -1844,11 +1844,11 @@ impl<'gc> EditText<'gc> {
/// Construct the text field's AVM2 representation.
fn construct_as_avm2_object(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
display_object: DisplayObject<'gc>,
) {
let textfield_constr = context.avm2.classes().textfield;
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
match Avm2StageObject::for_display_object_childless(
&mut activation,
@ -1983,7 +1983,7 @@ impl<'gc> EditText<'gc> {
fn execute_avm1_asfunction(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
address: &WStr,
) -> Result<(), crate::avm1::Error<'gc>> {
let Some(parent) = self.avm1_parent() else {
@ -1991,7 +1991,7 @@ impl<'gc> EditText<'gc> {
};
let mut activation = Avm1Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[EditText URL]"),
parent,
);
@ -2012,14 +2012,14 @@ impl<'gc> EditText<'gc> {
Ok(())
}
fn open_url(self, context: &mut UpdateContext<'_, 'gc>, url: &WStr, target: &WStr) {
fn open_url(self, context: &mut UpdateContext<'gc>, url: &WStr, target: &WStr) {
if let Some(address) = url.strip_prefix(WStr::from_units(b"asfunction:")) {
if let Err(e) = self.execute_avm1_asfunction(context, address) {
error!("Couldn't execute URL \"{url:?}\": {e:?}");
}
} else if let Some(address) = url.strip_prefix(WStr::from_units(b"event:")) {
if let Avm2Value::Object(object) = self.object2() {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let text = AvmString::new(activation.context.gc_context, address);
let event = Avm2EventObject::text_event(&mut activation, "link", text, true, false);
@ -2048,12 +2048,7 @@ impl<'gc> EditText<'gc> {
})
}
fn handle_click(
self,
click_index: usize,
position: usize,
context: &mut UpdateContext<'_, 'gc>,
) {
fn handle_click(self, click_index: usize, position: usize, context: &mut UpdateContext<'gc>) {
if !self.is_selectable() {
return;
}
@ -2070,7 +2065,7 @@ impl<'gc> EditText<'gc> {
self.set_selection(Some(selection), context.gc());
}
fn handle_drag(self, position: usize, context: &mut UpdateContext<'_, 'gc>) {
fn handle_drag(self, position: usize, context: &mut UpdateContext<'gc>) {
if !self.is_selectable() {
return;
}
@ -2121,7 +2116,7 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
}
/// Construct objects placed on this frame.
fn construct_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn construct_frame(&self, context: &mut UpdateContext<'gc>) {
if self.movie().is_action_script_3() && matches!(self.object2(), Avm2Value::Null) {
self.construct_as_avm2_object(context, (*self).into());
self.on_construction_complete(context);
@ -2142,7 +2137,7 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
fn post_instantiation(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
_init_object: Option<Avm1Object<'gc>>,
_instantiated_by: Instantiator,
run_frame: bool,
@ -2175,7 +2170,7 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
.unwrap_or(Avm2Value::Null)
}
fn set_object2(&self, context: &mut UpdateContext<'_, 'gc>, to: Avm2Object<'gc>) {
fn set_object2(&self, context: &mut UpdateContext<'gc>, to: Avm2Object<'gc>) {
self.0.write(context.gc_context).object = Some(to.into());
}
@ -2219,7 +2214,7 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
.to_pixels()
}
fn set_width(&self, context: &mut UpdateContext<'_, 'gc>, value: f64) {
fn set_width(&self, context: &mut UpdateContext<'gc>, value: f64) {
let mut edit_text = self.0.write(context.gc_context);
edit_text.requested_width = Twips::from_pixels(value);
edit_text.base.base.set_transformed_by_script(true);
@ -2234,7 +2229,7 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
.to_pixels()
}
fn set_height(&self, context: &mut UpdateContext<'_, 'gc>, value: f64) {
fn set_height(&self, context: &mut UpdateContext<'gc>, value: f64) {
let mut edit_text = self.0.write(context.gc_context);
edit_text.requested_height = Twips::from_pixels(value);
edit_text.base.base.set_transformed_by_script(true);
@ -2355,7 +2350,7 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
false
}
fn avm1_unload(&self, context: &mut UpdateContext<'_, 'gc>) {
fn avm1_unload(&self, context: &mut UpdateContext<'gc>) {
self.drop_focus(context);
if let Some(node) = self.maskee() {
@ -2534,7 +2529,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
fn filter_clip_event(
self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
event: ClipEvent,
) -> ClipEventResult {
match event {
@ -2547,7 +2542,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
fn event_dispatch(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event: ClipEvent<'gc>,
) -> ClipEventResult {
if let ClipEvent::MouseWheel { delta } = event {
@ -2556,7 +2551,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
self.set_scroll(new_scroll, context);
let mut activation = Avm1Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[On Scroller]"),
self.into(),
);
@ -2617,7 +2612,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
fn mouse_pick_avm1(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
point: Point<Twips>,
_require_button_mode: bool,
) -> Option<InteractiveObject<'gc>> {
@ -2640,7 +2635,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
fn mouse_pick_avm2(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
point: Point<Twips>,
_require_button_mode: bool,
) -> Avm2MousePick<'gc> {
@ -2667,7 +2662,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
}
}
fn mouse_cursor(self, context: &mut UpdateContext<'_, 'gc>) -> MouseCursor {
fn mouse_cursor(self, context: &mut UpdateContext<'gc>) -> MouseCursor {
if self.is_link_at(*context.mouse_position) {
MouseCursor::Hand
} else if self.is_selectable() {
@ -2679,7 +2674,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
fn on_focus_changed(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
focused: bool,
_other: Option<InteractiveObject<'gc>>,
) {
@ -2689,16 +2684,16 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
}
}
fn is_focusable_by_mouse(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_focusable_by_mouse(&self, _context: &mut UpdateContext<'gc>) -> bool {
self.movie().is_action_script_3() || self.is_editable() || self.is_selectable()
}
fn is_highlightable(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_highlightable(&self, _context: &mut UpdateContext<'gc>) -> bool {
// TextField is incapable of rendering a highlight.
false
}
fn is_tabbable(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_tabbable(&self, context: &mut UpdateContext<'gc>) -> bool {
if !self.is_editable() {
// Non-editable text fields are never tabbable.
return false;
@ -2706,7 +2701,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
self.tab_enabled(context)
}
fn tab_enabled_default(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
fn tab_enabled_default(&self, _context: &mut UpdateContext<'gc>) -> bool {
self.is_editable()
}
}

View File

@ -41,7 +41,7 @@ pub struct GraphicData<'gc> {
impl<'gc> Graphic<'gc> {
/// Construct a `Graphic` from it's associated `Shape` tag.
pub fn from_swf_tag(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
swf_shape: swf::Shape,
movie: Arc<SwfMovie>,
) -> Self {
@ -70,7 +70,7 @@ impl<'gc> Graphic<'gc> {
}
/// Construct an empty `Graphic`.
pub fn empty(context: &mut UpdateContext<'_, 'gc>) -> Self {
pub fn empty(context: &mut UpdateContext<'gc>) -> Self {
let static_data = GraphicStatic {
id: 0,
bounds: Default::default(),
@ -138,10 +138,10 @@ impl<'gc> TDisplayObject<'gc> for Graphic<'gc> {
}
}
fn construct_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn construct_frame(&self, context: &mut UpdateContext<'gc>) {
if self.movie().is_action_script_3() && matches!(self.object2(), Avm2Value::Null) {
let shape_constr = context.avm2.classes().shape;
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
match Avm2StageObject::for_display_object_childless(
&mut activation,
@ -160,7 +160,7 @@ impl<'gc> TDisplayObject<'gc> for Graphic<'gc> {
}
}
fn replace_with(&self, context: &mut UpdateContext<'_, 'gc>, id: CharacterId) {
fn replace_with(&self, context: &mut UpdateContext<'gc>, id: CharacterId) {
// Static assets like Graphics can replace themselves via a PlaceObject tag with PlaceObjectAction::Replace.
// This does not create a new instance, but instead swaps out the underlying static data to point to the new art.
if let Some(new_graphic) = context
@ -196,7 +196,7 @@ impl<'gc> TDisplayObject<'gc> for Graphic<'gc> {
fn hit_test_shape(
&self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
point: Point<Twips>,
options: HitTestOptions,
) -> bool {
@ -223,7 +223,7 @@ impl<'gc> TDisplayObject<'gc> for Graphic<'gc> {
fn post_instantiation(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
_init_object: Option<Avm1Object<'gc>>,
_instantiated_by: Instantiator,
run_frame: bool,
@ -253,7 +253,7 @@ impl<'gc> TDisplayObject<'gc> for Graphic<'gc> {
.unwrap_or(Avm2Value::Null)
}
fn set_object2(&self, context: &mut UpdateContext<'_, 'gc>, to: Avm2Object<'gc>) {
fn set_object2(&self, context: &mut UpdateContext<'gc>, to: Avm2Object<'gc>) {
self.0.write(context.gc_context).avm2_object = Some(to);
}

View File

@ -198,7 +198,7 @@ pub trait TInteractiveObject<'gc>:
/// onto other siblings of the display object instead.
fn filter_clip_event(
self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
event: ClipEvent,
) -> ClipEventResult;
@ -208,7 +208,7 @@ pub trait TInteractiveObject<'gc>:
/// terminate, including the event default.
fn propagate_to_children(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event: ClipEvent<'gc>,
) -> ClipEventResult {
if event.propagates() {
@ -235,7 +235,7 @@ pub trait TInteractiveObject<'gc>:
/// if the event will be passed onto siblings and parents.
fn event_dispatch(
self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
_event: ClipEvent<'gc>,
) -> ClipEventResult;
@ -247,7 +247,7 @@ pub trait TInteractiveObject<'gc>:
/// event types should dispatch them in `event_dispatch`.
fn event_dispatch_to_avm2(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event: ClipEvent<'gc>,
) -> ClipEventResult {
if !self.as_displayobject().movie().is_action_script_3() {
@ -270,7 +270,7 @@ pub trait TInteractiveObject<'gc>:
return ClipEventResult::NotHandled;
};
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
match event {
ClipEvent::Press { .. } | ClipEvent::RightPress | ClipEvent::MiddlePress => {
@ -496,7 +496,7 @@ pub trait TInteractiveObject<'gc>:
/// by its parent, and so forth.
fn handle_clip_event(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event: ClipEvent<'gc>,
) -> ClipEventResult {
if !self.mouse_enabled() {
@ -523,7 +523,7 @@ pub trait TInteractiveObject<'gc>:
/// an `InteractiveObject`.
fn mouse_pick_avm1(
&self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
_point: Point<Twips>,
_require_button_mode: bool,
) -> Option<InteractiveObject<'gc>> {
@ -532,7 +532,7 @@ pub trait TInteractiveObject<'gc>:
fn mouse_pick_avm2(
&self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
_point: Point<Twips>,
_require_button_mode: bool,
) -> Avm2MousePick<'gc> {
@ -540,12 +540,12 @@ pub trait TInteractiveObject<'gc>:
}
/// The cursor to use when this object is the hovered element under a mouse.
fn mouse_cursor(self, _context: &mut UpdateContext<'_, 'gc>) -> MouseCursor {
fn mouse_cursor(self, _context: &mut UpdateContext<'gc>) -> MouseCursor {
MouseCursor::Hand
}
/// Whether this object is focusable for keyboard input.
fn is_focusable(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_focusable(&self, _context: &mut UpdateContext<'gc>) -> bool {
// By default, all interactive objects are focusable.
true
}
@ -556,7 +556,7 @@ pub trait TInteractiveObject<'gc>:
/// The default behavior is following:
/// * in AVM1 objects cannot be focused by mouse,
/// * in AVM2 objects can be focused by mouse when they are tab enabled.
fn is_focusable_by_mouse(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_focusable_by_mouse(&self, context: &mut UpdateContext<'gc>) -> bool {
let self_do = self.as_displayobject();
self_do.movie().is_action_script_3() && self.tab_enabled(context)
}
@ -566,14 +566,14 @@ pub trait TInteractiveObject<'gc>:
/// This should only be called by the focus manager. To change a focus, go through that.
fn on_focus_changed(
&self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
_focused: bool,
_other: Option<InteractiveObject<'gc>>,
) {
}
/// If this object has focus, this method drops it.
fn drop_focus(&self, context: &mut UpdateContext<'_, 'gc>) {
fn drop_focus(&self, context: &mut UpdateContext<'gc>) {
if self.has_focus() {
let tracker = context.focus_tracker;
tracker.set(None, context);
@ -582,7 +582,7 @@ pub trait TInteractiveObject<'gc>:
fn call_focus_handler(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
focused: bool,
other: Option<InteractiveObject<'gc>>,
) {
@ -598,7 +598,7 @@ pub trait TInteractiveObject<'gc>:
};
Avm1::run_stack_frame_for_method(self_do, object, context, method_name, &[other]);
} else if let Avm2Value::Object(object) = self_do.object2() {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let event_name = if focused { "focusIn" } else { "focusOut" };
let event = EventObject::focus_event(&mut activation, event_name, false, other, 0);
Avm2::dispatch_event(activation.context, event, object);
@ -606,7 +606,7 @@ pub trait TInteractiveObject<'gc>:
}
/// Whether this object may be highlighted when focused.
fn is_highlightable(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_highlightable(&self, context: &mut UpdateContext<'gc>) -> bool {
self.is_highlight_enabled(context)
}
@ -614,7 +614,7 @@ pub trait TInteractiveObject<'gc>:
///
/// Note: This value does not mean that a highlight should actually be rendered,
/// for that see [`Self::is_highlightable()`].
fn is_highlight_enabled(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_highlight_enabled(&self, context: &mut UpdateContext<'gc>) -> bool {
if self.as_displayobject().movie().version() >= 6 {
self.focus_rect()
.unwrap_or_else(|| context.stage.stage_focus_rect())
@ -629,7 +629,7 @@ pub trait TInteractiveObject<'gc>:
}
/// Whether this object is included in tab ordering.
fn is_tabbable(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_tabbable(&self, context: &mut UpdateContext<'gc>) -> bool {
self.tab_enabled(context)
}
@ -637,7 +637,7 @@ pub trait TInteractiveObject<'gc>:
///
/// Some objects may be excluded from tab ordering
/// even if it's enabled, see [`Self::is_tabbable()`].
fn tab_enabled(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn tab_enabled(&self, context: &mut UpdateContext<'gc>) -> bool {
if self.as_displayobject().movie().is_action_script_3() {
self.raw_interactive()
.tab_enabled
@ -650,11 +650,11 @@ pub trait TInteractiveObject<'gc>:
}
}
fn tab_enabled_default(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
fn tab_enabled_default(&self, _context: &mut UpdateContext<'gc>) -> bool {
false
}
fn set_tab_enabled(&self, context: &mut UpdateContext<'_, 'gc>, value: bool) {
fn set_tab_enabled(&self, context: &mut UpdateContext<'gc>, value: bool) {
if self.as_displayobject().movie().is_action_script_3() {
self.raw_interactive_mut(context.gc()).tab_enabled = Some(value)
} else {
@ -670,7 +670,7 @@ pub trait TInteractiveObject<'gc>:
self.raw_interactive().tab_index
}
fn set_tab_index(&self, context: &mut UpdateContext<'_, 'gc>, value: Option<i32>) {
fn set_tab_index(&self, context: &mut UpdateContext<'gc>, value: Option<i32>) {
// tabIndex = -1 is always equivalent to unset tabIndex
let value = if matches!(value, Some(-1)) {
None
@ -683,7 +683,7 @@ pub trait TInteractiveObject<'gc>:
/// Whether event handlers (e.g. onKeyUp, onPress) should be fired for the given event.
fn should_fire_event_handlers(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event: ClipEvent,
) -> bool {
// Event handlers are supported only by SWF6+.

View File

@ -99,7 +99,7 @@ impl<'gc> TDisplayObject<'gc> for LoaderDisplay<'gc> {
.unwrap_or(Avm2Value::Null)
}
fn set_object2(&self, context: &mut UpdateContext<'_, 'gc>, to: Avm2Object<'gc>) {
fn set_object2(&self, context: &mut UpdateContext<'gc>, to: Avm2Object<'gc>) {
self.0.write(context.gc_context).avm2_object = Some(to);
}
@ -111,7 +111,7 @@ impl<'gc> TDisplayObject<'gc> for LoaderDisplay<'gc> {
Some(self.into())
}
fn enter_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn enter_frame(&self, context: &mut UpdateContext<'gc>) {
let skip_frame = self.base().should_skip_next_enter_frame();
for child in self.iter_render_list() {
// See MovieClip::enter_frame for an explanation of this.
@ -126,7 +126,7 @@ impl<'gc> TDisplayObject<'gc> for LoaderDisplay<'gc> {
.set_skip_next_enter_frame(false);
}
fn construct_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn construct_frame(&self, context: &mut UpdateContext<'gc>) {
for child in self.iter_render_list() {
child.construct_frame(context);
}
@ -136,7 +136,7 @@ impl<'gc> TDisplayObject<'gc> for LoaderDisplay<'gc> {
self.0.read().movie.clone()
}
fn on_parent_removed(&self, context: &mut UpdateContext<'_, 'gc>) {
fn on_parent_removed(&self, context: &mut UpdateContext<'gc>) {
if self.movie().is_action_script_3() {
context.avm2.add_orphan_obj((*self).into())
}
@ -158,7 +158,7 @@ impl<'gc> TInteractiveObject<'gc> for LoaderDisplay<'gc> {
fn filter_clip_event(
self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
_event: ClipEvent,
) -> ClipEventResult {
if !self.visible() {
@ -169,7 +169,7 @@ impl<'gc> TInteractiveObject<'gc> for LoaderDisplay<'gc> {
}
fn event_dispatch(
self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
_event: ClipEvent<'gc>,
) -> ClipEventResult {
ClipEventResult::NotHandled
@ -177,7 +177,7 @@ impl<'gc> TInteractiveObject<'gc> for LoaderDisplay<'gc> {
fn mouse_pick_avm1(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
point: Point<Twips>,
require_button_mode: bool,
) -> Option<InteractiveObject<'gc>> {
@ -206,7 +206,7 @@ impl<'gc> TInteractiveObject<'gc> for LoaderDisplay<'gc> {
fn mouse_pick_avm2(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
point: Point<Twips>,
require_button_mode: bool,
) -> Avm2MousePick<'gc> {

View File

@ -89,7 +89,7 @@ impl<'gc> TDisplayObject<'gc> for MorphShape<'gc> {
Some(*self)
}
fn replace_with(&self, context: &mut UpdateContext<'_, 'gc>, id: CharacterId) {
fn replace_with(&self, context: &mut UpdateContext<'gc>, id: CharacterId) {
if let Some(new_morph_shape) = context
.library
.library_for_movie_mut(self.movie())
@ -114,15 +114,15 @@ impl<'gc> TDisplayObject<'gc> for MorphShape<'gc> {
.unwrap_or(Avm2Value::Null)
}
fn set_object2(&self, context: &mut UpdateContext<'_, 'gc>, to: Avm2Object<'gc>) {
fn set_object2(&self, context: &mut UpdateContext<'gc>, to: Avm2Object<'gc>) {
self.0.write(context.gc_context).object = Some(to);
}
/// Construct objects placed on this frame.
fn construct_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn construct_frame(&self, context: &mut UpdateContext<'gc>) {
if self.movie().is_action_script_3() && matches!(self.object2(), Avm2Value::Null) {
let class = context.avm2.classes().morphshape;
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
match Avm2StageObject::for_display_object_childless(
&mut activation,
(*self).into(),
@ -155,7 +155,7 @@ impl<'gc> TDisplayObject<'gc> for MorphShape<'gc> {
fn hit_test_shape(
&self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
point: Point<Twips>,
options: HitTestOptions,
) -> bool {

View File

@ -323,7 +323,7 @@ impl<'gc> MovieClip<'gc> {
}
pub fn new_import_assets(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
movie: Arc<SwfMovie>,
parent: Arc<SwfMovie>,
) -> Self {
@ -466,7 +466,7 @@ impl<'gc> MovieClip<'gc> {
/// the load boundary.
pub fn replace_with_movie(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
movie: Option<Arc<SwfMovie>>,
is_root: bool,
loader_info: Option<LoaderInfoObject<'gc>>,
@ -517,7 +517,7 @@ impl<'gc> MovieClip<'gc> {
/// `await`, returning to the loop directly, or some other mechanism.
pub fn preload(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
chunk_limit: &mut ExecutionLimit,
) -> bool {
{
@ -840,7 +840,7 @@ impl<'gc> MovieClip<'gc> {
#[inline]
fn do_init_action(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'_>,
tag_len: usize,
) -> Result<(), Error> {
@ -873,7 +873,7 @@ impl<'gc> MovieClip<'gc> {
#[inline]
fn do_abc(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'_>,
) -> Result<Option<Script<'gc>>, Error> {
if !context.swf.is_action_script_3() {
@ -909,7 +909,7 @@ impl<'gc> MovieClip<'gc> {
#[inline]
fn do_abc_2(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'_>,
) -> Result<Option<Script<'gc>>, Error> {
if !context.swf.is_action_script_3() {
@ -1017,17 +1017,17 @@ impl<'gc> MovieClip<'gc> {
self.0.write(mc).set_programmatically_played()
}
pub fn next_frame(self, context: &mut UpdateContext<'_, 'gc>) {
pub fn next_frame(self, context: &mut UpdateContext<'gc>) {
if self.current_frame() < self.total_frames() {
self.goto_frame(context, self.current_frame() + 1, true);
}
}
pub fn play(self, context: &mut UpdateContext<'_, 'gc>) {
pub fn play(self, context: &mut UpdateContext<'gc>) {
self.0.write(context.gc_context).play()
}
pub fn prev_frame(self, context: &mut UpdateContext<'_, 'gc>) {
pub fn prev_frame(self, context: &mut UpdateContext<'gc>) {
if self.current_frame() > 1 {
self.goto_frame(context, self.current_frame() - 1, true);
}
@ -1037,7 +1037,7 @@ impl<'gc> MovieClip<'gc> {
self.0.read().initialized()
}
pub fn stop(self, context: &mut UpdateContext<'_, 'gc>) {
pub fn stop(self, context: &mut UpdateContext<'gc>) {
self.0.write(context.gc_context).stop(context)
}
@ -1055,7 +1055,7 @@ impl<'gc> MovieClip<'gc> {
///
/// This is treated as an 'explicit' goto: frame scripts and other frame
/// lifecycle events will be retriggered.
pub fn goto_frame(self, context: &mut UpdateContext<'_, 'gc>, frame: FrameNumber, stop: bool) {
pub fn goto_frame(self, context: &mut UpdateContext<'gc>, frame: FrameNumber, stop: bool) {
// Stop first, in case we need to kill and restart the stream sound.
if stop {
self.stop(context);
@ -1342,7 +1342,7 @@ impl<'gc> MovieClip<'gc> {
pub fn frame_label_to_number(
self,
frame_label: &WStr,
_context: &UpdateContext<'_, 'gc>,
_context: &UpdateContext<'gc>,
) -> Option<FrameNumber> {
// In AVM1, frame labels are case insensitive (ASCII).
// They are case sensitive in AVM2.
@ -1379,7 +1379,7 @@ impl<'gc> MovieClip<'gc> {
self,
frame_label: &WStr,
scene_label: &WStr,
context: &UpdateContext<'_, 'gc>,
context: &UpdateContext<'gc>,
) -> bool {
let scene = self.scene_label_to_number(scene_label);
let frame = self.frame_label_to_number(frame_label, context);
@ -1430,7 +1430,7 @@ impl<'gc> MovieClip<'gc> {
/// Used by the AVM `Call` action.
pub fn actions_on_frame(
self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
frame: FrameNumber,
) -> impl DoubleEndedIterator<Item = SwfSlice> {
use swf::read::Reader;
@ -1481,7 +1481,7 @@ impl<'gc> MovieClip<'gc> {
fn run_frame_internal(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
run_display_actions: bool,
run_sounds: bool,
is_action_script_3: bool,
@ -1611,7 +1611,7 @@ impl<'gc> MovieClip<'gc> {
/// Instantiate a given child object on the timeline at a given depth.
fn instantiate_child(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
id: CharacterId,
depth: Depth,
place_object: &swf::PlaceObject,
@ -1704,15 +1704,10 @@ impl<'gc> MovieClip<'gc> {
}
#[cfg(not(feature = "timeline_debug"))]
fn assert_expected_tag_end(
self,
_context: &mut UpdateContext<'_, 'gc>,
_hit_target_frame: bool,
) {
}
fn assert_expected_tag_end(self, _context: &mut UpdateContext<'gc>, _hit_target_frame: bool) {}
#[cfg(feature = "timeline_debug")]
fn assert_expected_tag_end(self, context: &mut UpdateContext<'_, 'gc>, hit_target_frame: bool) {
fn assert_expected_tag_end(self, context: &mut UpdateContext<'gc>, hit_target_frame: bool) {
// Gotos that do *not* hit their target frame will not update their tag
// stream position, as they do not run the final frame's tags, and thus
// cannot derive the end position of the clip anyway. This is not
@ -1747,7 +1742,7 @@ impl<'gc> MovieClip<'gc> {
pub fn run_goto(
mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
frame: FrameNumber,
is_implicit: bool,
) {
@ -1908,7 +1903,7 @@ impl<'gc> MovieClip<'gc> {
// Run the list of goto commands to actually create and update the display objects.
let run_goto_command = |clip: MovieClip<'gc>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
params: &GotoPlaceObject<'_>| {
use swf::PlaceObjectAction;
let child_entry = clip.child_by_depth(params.depth());
@ -2024,7 +2019,7 @@ impl<'gc> MovieClip<'gc> {
fn construct_as_avm1_object(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
init_object: Option<Avm1Object<'gc>>,
instantiated_by: Instantiator,
run_frame: bool,
@ -2037,7 +2032,7 @@ impl<'gc> MovieClip<'gc> {
// If we are not, then this must be queued to be ran first-thing
if let Some(constructor) = avm1_constructor.filter(|_| instantiated_by.is_avm()) {
let mut activation = Avm1Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[Construct]"),
self.into(),
);
@ -2091,7 +2086,7 @@ impl<'gc> MovieClip<'gc> {
if let Some(init_object) = init_object {
let mut activation = Avm1Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[Init]"),
self.into(),
);
@ -2151,7 +2146,7 @@ impl<'gc> MovieClip<'gc> {
#[inline(never)]
fn allocate_as_avm2_object(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
display_object: DisplayObject<'gc>,
) {
let class_object = self
@ -2163,7 +2158,7 @@ impl<'gc> MovieClip<'gc> {
.unwrap_or_else(|| context.avm2.classes().movieclip);
let mut constr_thing = || {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let object =
Avm2StageObject::for_display_object(&mut activation, display_object, class_object)?
.into();
@ -2185,7 +2180,7 @@ impl<'gc> MovieClip<'gc> {
/// will allocate the object first before doing so. This function is
/// intended to be called from `post_instantiate`.
#[inline(never)]
fn construct_as_avm2_object(self, context: &mut UpdateContext<'_, 'gc>) {
fn construct_as_avm2_object(self, context: &mut UpdateContext<'gc>) {
let class_object = self
.0
.read()
@ -2196,7 +2191,7 @@ impl<'gc> MovieClip<'gc> {
if let Avm2Value::Object(object) = self.object2() {
let mut constr_thing = || {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
class_object.call_native_init(object.into(), &[], &mut activation)?;
Ok(())
@ -2220,7 +2215,7 @@ impl<'gc> MovieClip<'gc> {
self,
frame_id: FrameNumber,
callable: Option<Avm2Object<'gc>>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) {
let frame_scripts = &mut self.0.write(context.gc_context).frame_scripts;
@ -2242,7 +2237,7 @@ impl<'gc> MovieClip<'gc> {
mut self,
reader: &mut SwfStream<'a>,
version: u8,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
goto_commands: &mut Vec<GotoPlaceObject<'a>>,
is_rewind: bool,
from_frame: FrameNumber,
@ -2284,7 +2279,7 @@ impl<'gc> MovieClip<'gc> {
Ok(())
}
fn enabled(self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn enabled(self, context: &mut UpdateContext<'gc>) -> bool {
if !self.movie().is_action_script_3() {
self.get_avm1_boolean_property(context, "enabled", |_| true)
} else {
@ -2296,11 +2291,11 @@ impl<'gc> MovieClip<'gc> {
self.0.read().avm2_enabled
}
pub fn set_avm2_enabled(self, context: &mut UpdateContext<'_, 'gc>, enabled: bool) {
pub fn set_avm2_enabled(self, context: &mut UpdateContext<'gc>, enabled: bool) {
self.0.write(context.gc_context).avm2_enabled = enabled;
}
fn use_hand_cursor(self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn use_hand_cursor(self, context: &mut UpdateContext<'gc>) -> bool {
if !self.movie().is_action_script_3() {
self.get_avm1_boolean_property(context, "useHandCursor", |_| true)
} else {
@ -2312,11 +2307,7 @@ impl<'gc> MovieClip<'gc> {
self.0.read().avm2_use_hand_cursor
}
pub fn set_avm2_use_hand_cursor(
self,
context: &mut UpdateContext<'_, 'gc>,
use_hand_cursor: bool,
) {
pub fn set_avm2_use_hand_cursor(self, context: &mut UpdateContext<'gc>, use_hand_cursor: bool) {
self.0.write(context.gc_context).avm2_use_hand_cursor = use_hand_cursor;
}
@ -2326,7 +2317,7 @@ impl<'gc> MovieClip<'gc> {
pub fn set_hit_area(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
hit_area: Option<DisplayObject<'gc>>,
) {
self.0.write(context.gc_context).hit_area = hit_area;
@ -2340,7 +2331,7 @@ impl<'gc> MovieClip<'gc> {
self.0.read().button_mode
}
pub fn set_forced_button_mode(self, context: &mut UpdateContext<'_, 'gc>, button_mode: bool) {
pub fn set_forced_button_mode(self, context: &mut UpdateContext<'gc>, button_mode: bool) {
self.0.write(context.gc_context).button_mode = button_mode;
}
@ -2350,7 +2341,7 @@ impl<'gc> MovieClip<'gc> {
RefMut::map(self.0.write(gc_context), |s| &mut s.drawing)
}
pub fn is_button_mode(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
pub fn is_button_mode(&self, context: &mut UpdateContext<'gc>) -> bool {
if self.forced_button_mode()
|| self
.0
@ -2363,7 +2354,7 @@ impl<'gc> MovieClip<'gc> {
let object = self.object();
if let Avm1Value::Object(object) = object {
let mut activation = Avm1Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[Mouse Pick]"),
self.avm1_root(),
);
@ -2379,7 +2370,7 @@ impl<'gc> MovieClip<'gc> {
}
/// Remove all `PlaceObject` tags off the internal tag queue.
fn unqueue_adds(&self, context: &mut UpdateContext<'_, 'gc>) -> Vec<(Depth, QueuedTag)> {
fn unqueue_adds(&self, context: &mut UpdateContext<'gc>) -> Vec<(Depth, QueuedTag)> {
let mut write = self.0.write(context.gc_context);
let mut unqueued: Vec<_> = write
.queued_tags
@ -2399,7 +2390,7 @@ impl<'gc> MovieClip<'gc> {
}
/// Remove all `RemoveObject` tags off the internal tag queue.
fn unqueue_removes(&self, context: &mut UpdateContext<'_, 'gc>) -> Vec<(Depth, QueuedTag)> {
fn unqueue_removes(&self, context: &mut UpdateContext<'gc>) -> Vec<(Depth, QueuedTag)> {
let mut write = self.0.write(context.gc_context);
let mut unqueued: Vec<_> = write
.queued_tags
@ -2427,7 +2418,7 @@ impl<'gc> MovieClip<'gc> {
// calls with one frame delay? Does transform_to_unloaded_state need to get executed
// after one frame if the target is a MovieClip? Test the behaviour and adapt the code
// if necessary.
pub fn avm1_unload_movie(&self, context: &mut UpdateContext<'_, 'gc>) {
pub fn avm1_unload_movie(&self, context: &mut UpdateContext<'gc>) {
// TODO: In Flash player, the MovieClip properties change to the unloaded state
// one frame after the unloadMovie command has been read, even if the MovieClip
// is not a root MovieClip (see the movieclip_library_state_values test).
@ -2484,7 +2475,7 @@ impl<'gc> MovieClip<'gc> {
///
/// This happens if a MovieClip has been unloaded. The state is then changed one
/// frame after the command to unload the MovieClip has been read.
fn transform_to_unloaded_state(&self, context: &mut UpdateContext<'_, 'gc>) {
fn transform_to_unloaded_state(&self, context: &mut UpdateContext<'gc>) {
let movie = if let Some(DisplayObject::MovieClip(parent_mc)) = self.parent() {
let parent_movie = parent_mc.movie();
let parent_version = parent_movie.version();
@ -2500,11 +2491,7 @@ impl<'gc> MovieClip<'gc> {
self.replace_with_movie(context, movie, self.is_root(), None);
}
pub fn attach_audio(
self,
context: &mut UpdateContext<'_, 'gc>,
netstream: Option<NetStream<'gc>>,
) {
pub fn attach_audio(self, context: &mut UpdateContext<'gc>, netstream: Option<NetStream<'gc>>) {
let mut write = self.0.write(context.gc_context);
if netstream != write.attached_audio {
if let Some(old_netstream) = write.attached_audio {
@ -2545,7 +2532,7 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
self.0.read().movie()
}
fn enter_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn enter_frame(&self, context: &mut UpdateContext<'gc>) {
let skip_frame = self.base().should_skip_next_enter_frame();
//Child removals from looping gotos appear to resolve in reverse order.
for child in self.iter_render_list().rev() {
@ -2601,7 +2588,7 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
}
/// Construct objects placed on this frame.
fn construct_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn construct_frame(&self, context: &mut UpdateContext<'gc>) {
// AVM1 code expects to execute in line with timeline instructions, so
// it's exempted from frame construction.
if self.movie().is_action_script_3()
@ -2645,7 +2632,7 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
}
}
fn run_frame_avm1(&self, context: &mut UpdateContext<'_, 'gc>) {
fn run_frame_avm1(&self, context: &mut UpdateContext<'gc>) {
if !self.movie().is_action_script_3() {
// Run my load/enterFrame clip event.
let is_load_frame = !self.0.read().flags.contains(MovieClipFlags::INITIALIZED);
@ -2664,7 +2651,7 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
}
}
fn run_frame_scripts(self, context: &mut UpdateContext<'_, 'gc>) {
fn run_frame_scripts(self, context: &mut UpdateContext<'gc>) {
let mut write = self.0.write(context.gc_context);
let avm2_object = write.object.and_then(|o| o.as_avm2_object());
@ -2738,7 +2725,7 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
}
}
fn on_exit_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn on_exit_frame(&self, context: &mut UpdateContext<'gc>) {
// Attempt to fire an "init" event on our `LoaderInfo`.
// This fires after we've exited our first frame, but before
// but before we enter a new frame. `loader_stream_init`
@ -2770,7 +2757,7 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
fn hit_test_shape(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
point: Point<Twips>,
options: HitTestOptions,
) -> bool {
@ -2842,7 +2829,7 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
fn post_instantiation(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
init_object: Option<Avm1Object<'gc>>,
instantiated_by: Instantiator,
run_frame: bool,
@ -2890,20 +2877,20 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
.unwrap_or(Avm2Value::Null)
}
fn set_object2(&self, context: &mut UpdateContext<'_, 'gc>, to: Avm2Object<'gc>) {
fn set_object2(&self, context: &mut UpdateContext<'gc>, to: Avm2Object<'gc>) {
self.0.write(context.gc_context).object = Some(to.into());
if self.parent().is_none() {
context.avm2.add_orphan_obj((*self).into());
}
}
fn on_parent_removed(&self, context: &mut UpdateContext<'_, 'gc>) {
fn on_parent_removed(&self, context: &mut UpdateContext<'gc>) {
if self.movie().is_action_script_3() {
context.avm2.add_orphan_obj((*self).into())
}
}
fn avm1_unload(&self, context: &mut UpdateContext<'_, 'gc>) {
fn avm1_unload(&self, context: &mut UpdateContext<'gc>) {
for child in self.iter_render_list() {
child.avm1_unload(context);
}
@ -2958,7 +2945,7 @@ impl<'gc> TDisplayObjectContainer<'gc> for MovieClip<'gc> {
RefMut::map(self.0.write(gc_context), |this| &mut this.container)
}
fn is_tab_children_avm1(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_tab_children_avm1(&self, context: &mut UpdateContext<'gc>) -> bool {
self.get_avm1_boolean_property(context, "tabChildren", |_| true)
}
}
@ -2978,7 +2965,7 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> {
fn filter_clip_event(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event: ClipEvent,
) -> ClipEventResult {
if event.is_button_event() {
@ -2996,7 +2983,7 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> {
fn event_dispatch(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event: ClipEvent<'gc>,
) -> ClipEventResult {
let frame_name = match event {
@ -3072,7 +3059,7 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> {
fn mouse_pick_avm1(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
point: Point<Twips>,
require_button_mode: bool,
) -> Option<InteractiveObject<'gc>> {
@ -3173,7 +3160,7 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> {
fn mouse_pick_avm2(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
point: Point<Twips>,
require_button_mode: bool,
) -> Avm2MousePick<'gc> {
@ -3316,7 +3303,7 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> {
Avm2MousePick::Miss
}
fn mouse_cursor(self, context: &mut UpdateContext<'_, 'gc>) -> MouseCursor {
fn mouse_cursor(self, context: &mut UpdateContext<'gc>) -> MouseCursor {
if self.is_button_mode(context) && self.use_hand_cursor(context) && self.enabled(context) {
MouseCursor::Hand
} else {
@ -3324,7 +3311,7 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> {
}
}
fn is_focusable(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_focusable(&self, context: &mut UpdateContext<'gc>) -> bool {
if self.is_root() {
false
} else if self.is_button_mode(context) {
@ -3334,13 +3321,13 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> {
}
}
fn is_highlightable(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_highlightable(&self, context: &mut UpdateContext<'gc>) -> bool {
// Root movie clips are not highlightable.
// This applies only to AVM2, as in AVM1 they are also not focusable.
!self.is_root() && self.is_highlight_enabled(context)
}
fn is_tabbable(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_tabbable(&self, context: &mut UpdateContext<'gc>) -> bool {
if self.is_root() {
// Root movie clips are never tabbable.
return false;
@ -3348,7 +3335,7 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> {
self.tab_enabled(context)
}
fn tab_enabled_default(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
fn tab_enabled_default(&self, context: &mut UpdateContext<'gc>) -> bool {
if self.is_button_mode(context) {
return true;
}
@ -3414,7 +3401,7 @@ impl<'gc> MovieClipData<'gc> {
}
}
fn stop(&mut self, context: &mut UpdateContext<'_, 'gc>) {
fn stop(&mut self, context: &mut UpdateContext<'gc>) {
self.set_playing(false);
self.stop_audio_stream(context);
}
@ -3484,7 +3471,7 @@ impl<'gc> MovieClipData<'gc> {
}
/// Stops the audio stream if one is playing.
fn stop_audio_stream(&mut self, context: &mut UpdateContext<'_, 'gc>) {
fn stop_audio_stream(&mut self, context: &mut UpdateContext<'gc>) {
if let Some(audio_stream) = self.audio_stream.take() {
context.stop_sound(audio_stream);
}
@ -3495,7 +3482,7 @@ impl<'gc> MovieClipData<'gc> {
/// to its symbol name.
fn get_registered_avm1_constructor(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Option<Avm1Object<'gc>> {
let symbol_name = self.static_data.exported_name.read();
let symbol_name = symbol_name.as_ref()?;
@ -3515,7 +3502,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_bits_lossless(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
version: u8,
) -> Result<(), Error> {
@ -3544,7 +3531,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_scaling_grid(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let id = reader.read_u16()?;
@ -3563,7 +3550,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_morph_shape(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
version: u8,
) -> Result<(), Error> {
@ -3581,7 +3568,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_shape(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
version: u8,
) -> Result<(), Error> {
@ -3609,7 +3596,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
fn csm_text_settings(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let settings = reader.read_csm_text_settings()?;
@ -3640,7 +3627,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn preload_video_frame(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream,
) -> Result<(), Error> {
let vframe = reader.read_video_frame()?;
@ -3658,7 +3645,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_bits(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let id = reader.read_u16()?;
@ -3692,7 +3679,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_bits_jpeg_2(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let id = reader.read_u16()?;
@ -3720,7 +3707,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_bits_jpeg_3_or_4(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
version: u8,
) -> Result<(), Error> {
@ -3754,7 +3741,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_button_1(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let swf_button = reader.read_define_button_1()?;
@ -3765,7 +3752,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_button_2(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let swf_button = reader.read_define_button_2()?;
@ -3776,7 +3763,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_button_any(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
swf_button: swf::Button<'a>,
) -> Result<(), Error> {
let movie = self.movie();
@ -3802,7 +3789,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_button_cxform(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let button_colors = reader.read_define_button_cxform()?;
@ -3833,7 +3820,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_button_sound(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let button_sounds = reader.read_define_button_sound()?;
@ -3868,7 +3855,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_edit_text(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let swf_edit_text = reader.read_define_edit_text()?;
@ -3883,7 +3870,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_font_1(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let font = reader.read_define_font_1()?;
@ -3925,7 +3912,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_font_2(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let font = reader.read_define_font_2(2)?;
@ -3947,7 +3934,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_font_3(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let font = reader.read_define_font_2(3)?;
@ -3970,7 +3957,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_font_4(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let font = reader.read_define_font_4()?;
@ -3986,7 +3973,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_sound(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let sound = reader.read_define_sound()?;
@ -4007,7 +3994,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_video_stream(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream,
) -> Result<(), Error> {
let streamdef = reader.read_define_video_stream()?;
@ -4022,7 +4009,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
fn define_sprite(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
tag_len: usize,
chunk_limit: &mut ExecutionLimit,
@ -4071,7 +4058,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_text(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
version: u8,
) -> Result<(), Error> {
@ -4087,7 +4074,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn define_binary_data(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let tag_data = reader.read_define_binary_data()?;
@ -4102,7 +4089,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn get_exported_from_importer(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
importer_movie: Arc<SwfMovie>,
) -> HashMap<AvmString<'gc>, (CharacterId, Character<'gc>)> {
let mut map: HashMap<AvmString<'gc>, (CharacterId, Character<'gc>)> = HashMap::new();
@ -4116,7 +4103,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
}
#[inline]
fn import_exports_of_importer(&mut self, context: &mut UpdateContext<'_, 'gc>) {
fn import_exports_of_importer(&mut self, context: &mut UpdateContext<'gc>) {
if let Some(importer_movie) = self.importer_movie.as_ref() {
let exported_from_importer =
{ self.get_exported_from_importer(context, importer_movie.clone()) };
@ -4138,7 +4125,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn import_assets(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
chunk_limit: &mut ExecutionLimit,
) -> Result<(), Error> {
@ -4155,7 +4142,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn import_assets_2(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
chunk_limit: &mut ExecutionLimit,
) -> Result<(), Error> {
@ -4172,7 +4159,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn import_assets_load(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
url: &swf::SwfStr,
exported_assets: Vec<swf::ExportedAsset>,
@ -4218,7 +4205,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn get_registered_character_by_id(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
id: CharacterId,
) -> Option<Character<'gc>> {
let library_for_movie = context.library.library_for_movie(self.movie());
@ -4233,7 +4220,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
fn register_export(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
id: CharacterId,
name: &AvmString<'gc>,
movie: Arc<SwfMovie>,
@ -4269,7 +4256,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn export_assets(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let exports = reader.read_export_assets()?;
@ -4314,7 +4301,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
reader: &mut SwfStream<'a>,
cur_frame: FrameNumber,
static_data: &mut MovieClipStatic<'gc>,
_context: &UpdateContext<'_, 'gc>,
_context: &UpdateContext<'gc>,
) -> Result<(), Error> {
// This tag is ignored if scene labels exist.
if !static_data.scene_labels.is_empty() {
@ -4343,7 +4330,7 @@ impl<'gc, 'a> MovieClipData<'gc> {
#[inline]
fn jpeg_tables(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let jpeg_data = reader.read_slice_to_end();
@ -4397,7 +4384,7 @@ impl<'gc, 'a> MovieClip<'gc> {
#[inline]
fn do_action(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
tag_len: usize,
) -> Result<(), Error> {
@ -4428,7 +4415,7 @@ impl<'gc, 'a> MovieClip<'gc> {
self,
tag_code: TagCode,
reader: &mut SwfStream<'a>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
cur_frame: FrameNumber,
static_data: &mut MovieClipStatic<'gc>,
) -> Result<(), Error> {
@ -4453,7 +4440,7 @@ impl<'gc, 'a> MovieClip<'gc> {
fn preload_symbol_class(
self,
reader: &mut SwfStream<'a>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
cur_frame: FrameNumber,
static_data: &mut MovieClipStatic<'gc>,
) -> Result<(), Error> {
@ -4493,7 +4480,7 @@ impl<'gc, 'a> MovieClip<'gc> {
// to work correctly.
fn run_abc_and_symbol_tags(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
current_frame: FrameNumber,
) -> Result<(), Error> {
let read = self.0.read();
@ -4524,7 +4511,7 @@ impl<'gc, 'a> MovieClip<'gc> {
.remove(&current_frame)
{
let movie = self.movie();
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
for (name, id) in symbols {
let library = activation
.context
@ -4624,7 +4611,7 @@ impl<'gc, 'a> MovieClip<'gc> {
fn queue_place_object(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
version: u8,
) -> Result<(), Error> {
@ -4653,7 +4640,7 @@ impl<'gc, 'a> MovieClip<'gc> {
fn place_object(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
version: u8,
) -> Result<(), Error> {
@ -4687,7 +4674,7 @@ impl<'gc, 'a> MovieClip<'gc> {
#[inline]
fn remove_object(
mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
version: u8,
) -> Result<(), Error> {
@ -4711,7 +4698,7 @@ impl<'gc, 'a> MovieClip<'gc> {
#[inline]
fn queue_remove_object(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
version: u8,
) -> Result<(), Error> {
@ -4741,7 +4728,7 @@ impl<'gc, 'a> MovieClip<'gc> {
#[inline]
fn set_background_color(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
// Set background color if none set
@ -4760,7 +4747,7 @@ impl<'gc, 'a> MovieClip<'gc> {
#[inline]
fn sound_stream_block(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
_reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let mc = self.0.read();
@ -4784,7 +4771,7 @@ impl<'gc, 'a> MovieClip<'gc> {
#[inline]
fn start_sound_1(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
reader: &mut SwfStream<'a>,
) -> Result<(), Error> {
let start_sound = reader.read_start_sound_1()?;

View File

@ -269,7 +269,7 @@ impl<'gc> Stage<'gc> {
/// In the Flash Player, the quality setting affects anti-aliasing and smoothing of bitmaps.
/// This setting is currently ignored in Ruffle.
/// Used by AVM1 `stage.quality` and AVM2 `Stage.quality` properties.
pub fn set_quality(self, context: &mut UpdateContext<'_, 'gc>, quality: StageQuality) {
pub fn set_quality(self, context: &mut UpdateContext<'gc>, quality: StageQuality) {
let mut this = self.0.write(context.gc_context);
this.quality = quality;
this.use_bitmap_downsampling = matches!(
@ -316,7 +316,7 @@ impl<'gc> Stage<'gc> {
/// Set the stage scale mode.
pub fn set_scale_mode(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
scale_mode: StageScaleMode,
respect_forced: bool,
) {
@ -334,7 +334,7 @@ impl<'gc> Stage<'gc> {
}
/// Set whether movies are prevented from changing the stage scale mode.
pub fn set_forced_scale_mode(self, context: &mut UpdateContext<'_, 'gc>, force: bool) {
pub fn set_forced_scale_mode(self, context: &mut UpdateContext<'gc>, force: bool) {
self.0.write(context.gc_context).forced_scale_mode = force;
}
@ -344,7 +344,7 @@ impl<'gc> Stage<'gc> {
}
/// Set whether the Stage's display state can be changed.
pub fn set_allow_fullscreen(self, context: &mut UpdateContext<'_, 'gc>, allow: bool) {
pub fn set_allow_fullscreen(self, context: &mut UpdateContext<'gc>, allow: bool) {
self.0.write(context.gc_context).allow_fullscreen = allow;
}
@ -366,7 +366,7 @@ impl<'gc> Stage<'gc> {
}
/// Toggles display state between fullscreen and normal
pub fn toggle_display_state(self, context: &mut UpdateContext<'_, 'gc>) {
pub fn toggle_display_state(self, context: &mut UpdateContext<'gc>) {
if self.is_fullscreen() {
self.set_display_state(context, StageDisplayState::Normal);
} else {
@ -377,7 +377,7 @@ impl<'gc> Stage<'gc> {
/// Set the stage display state.
pub fn set_display_state(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
display_state: StageDisplayState,
) {
if display_state == self.display_state()
@ -408,7 +408,7 @@ impl<'gc> Stage<'gc> {
/// Set the stage alignment.
/// This only has an effect if the scale mode is not `StageScaleMode::ExactFit`.
pub fn set_align(self, context: &mut UpdateContext<'_, 'gc>, align: StageAlign) {
pub fn set_align(self, context: &mut UpdateContext<'gc>, align: StageAlign) {
if !self.forced_align() {
self.0.write(context.gc_context).align = align;
self.build_matrices(context);
@ -421,7 +421,7 @@ impl<'gc> Stage<'gc> {
}
/// Set whether movies are prevented from changing the stage alignment.
pub fn set_forced_align(self, context: &mut UpdateContext<'_, 'gc>, force: bool) {
pub fn set_forced_align(self, context: &mut UpdateContext<'gc>, force: bool) {
self.0.write(context.gc_context).forced_align = force;
}
@ -445,7 +445,7 @@ impl<'gc> Stage<'gc> {
}
/// Sets the window mode.
pub fn set_window_mode(self, context: &mut UpdateContext<'_, 'gc>, window_mode: WindowMode) {
pub fn set_window_mode(self, context: &mut UpdateContext<'gc>, window_mode: WindowMode) {
self.0.write(context.gc_context).window_mode = window_mode;
}
@ -457,7 +457,7 @@ impl<'gc> Stage<'gc> {
self.0.read().show_menu
}
pub fn set_show_menu(self, context: &mut UpdateContext<'_, 'gc>, show_menu: bool) {
pub fn set_show_menu(self, context: &mut UpdateContext<'gc>, show_menu: bool) {
let mut write = self.0.write(context.gc_context);
write.show_menu = show_menu;
}
@ -476,7 +476,7 @@ impl<'gc> Stage<'gc> {
}
/// Update the stage's transform matrix in response to a root movie change.
pub fn build_matrices(self, context: &mut UpdateContext<'_, 'gc>) {
pub fn build_matrices(self, context: &mut UpdateContext<'gc>) {
let mut stage = self.0.write(context.gc_context);
let scale_mode = stage.scale_mode;
let align = stage.align;
@ -673,7 +673,7 @@ impl<'gc> Stage<'gc> {
}
/// Fires `Stage.onResize` in AVM1 or `Event.RESIZE` in AVM2.
fn fire_resize_event(self, context: &mut UpdateContext<'_, 'gc>) {
fn fire_resize_event(self, context: &mut UpdateContext<'gc>) {
// This event fires immediately when scaleMode is changed;
// it doesn't queue up.
if !self.movie().is_action_script_3() {
@ -696,7 +696,7 @@ impl<'gc> Stage<'gc> {
///
/// TODO: Need additional check as Flash Player does not
/// broadcast the 'render' event on the first render
pub fn broadcast_render(&self, context: &mut UpdateContext<'_, 'gc>) {
pub fn broadcast_render(&self, context: &mut UpdateContext<'gc>) {
let render_evt = Avm2EventObject::bare_default_event(context, "render");
let dobject_constr = context.avm2.classes().display_object;
Avm2::broadcast_event(context, render_evt, dobject_constr);
@ -705,7 +705,7 @@ impl<'gc> Stage<'gc> {
}
/// Fires `Stage.onFullScreen` in AVM1 or `Event.FULLSCREEN` in AVM2.
pub fn fire_fullscreen_event(self, context: &mut UpdateContext<'_, 'gc>) {
pub fn fire_fullscreen_event(self, context: &mut UpdateContext<'gc>) {
if !self.movie().is_action_script_3() {
if let Some(root_clip) = self.root_clip() {
crate::avm1::Avm1::notify_system_listeners(
@ -718,7 +718,7 @@ impl<'gc> Stage<'gc> {
}
} else if let Avm2Value::Object(stage) = self.object2() {
let full_screen_event_cls = context.avm2.classes().fullscreenevent;
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let full_screen_event = full_screen_event_cls
.construct(
&mut activation,
@ -765,7 +765,7 @@ impl<'gc> TDisplayObject<'gc> for Stage<'gc> {
fn post_instantiation(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
_init_object: Option<Avm1Object<'gc>>,
_instantiated_by: Instantiator,
_run_frame: bool,
@ -776,7 +776,7 @@ impl<'gc> TDisplayObject<'gc> for Stage<'gc> {
// TODO: We should only do this if the movie is actually an AVM2 movie.
// This is necessary for EventDispatcher super-constructor to run.
let global_domain = context.avm2.stage_domain();
let mut activation = Avm2Activation::from_domain(context.reborrow(), global_domain);
let mut activation = Avm2Activation::from_domain(context, global_domain);
let avm2_stage = Avm2StageObject::for_display_object_childless(
&mut activation,
(*self).into(),
@ -854,7 +854,7 @@ impl<'gc> TDisplayObject<'gc> for Stage<'gc> {
context.transform_stack.pop();
}
fn enter_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn enter_frame(&self, context: &mut UpdateContext<'gc>) {
for child in self.iter_render_list() {
child.enter_frame(context);
}
@ -864,7 +864,7 @@ impl<'gc> TDisplayObject<'gc> for Stage<'gc> {
Avm2::broadcast_event(context, enter_frame_evt, dobject_constr);
}
fn construct_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn construct_frame(&self, context: &mut UpdateContext<'gc>) {
for child in self.iter_render_list() {
child.construct_frame(context);
}
@ -912,7 +912,7 @@ impl<'gc> TInteractiveObject<'gc> for Stage<'gc> {
fn filter_clip_event(
self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
_event: ClipEvent,
) -> ClipEventResult {
ClipEventResult::Handled
@ -920,17 +920,17 @@ impl<'gc> TInteractiveObject<'gc> for Stage<'gc> {
fn event_dispatch(
self,
_context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'gc>,
_event: ClipEvent<'gc>,
) -> ClipEventResult {
ClipEventResult::NotHandled
}
fn mouse_cursor(self, _context: &mut UpdateContext<'_, 'gc>) -> MouseCursor {
fn mouse_cursor(self, _context: &mut UpdateContext<'gc>) -> MouseCursor {
MouseCursor::Arrow
}
fn is_highlightable(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
fn is_highlightable(&self, _context: &mut UpdateContext<'gc>) -> bool {
// Stage cannot be highlighted.
false
}

View File

@ -38,7 +38,7 @@ pub struct TextData<'gc> {
impl<'gc> Text<'gc> {
pub fn from_swf_tag(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
swf: Arc<SwfMovie>,
tag: &swf::Text,
) -> Self {
@ -93,7 +93,7 @@ impl<'gc> TDisplayObject<'gc> for Text<'gc> {
self.0.read().static_data.swf.clone()
}
fn replace_with(&self, context: &mut UpdateContext<'_, 'gc>, id: CharacterId) {
fn replace_with(&self, context: &mut UpdateContext<'gc>, id: CharacterId) {
if let Some(new_text) = context
.library
.library_for_movie_mut(self.movie())
@ -171,7 +171,7 @@ impl<'gc> TDisplayObject<'gc> for Text<'gc> {
fn hit_test_shape(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
mut point: Point<Twips>,
options: HitTestOptions,
) -> bool {
@ -238,7 +238,7 @@ impl<'gc> TDisplayObject<'gc> for Text<'gc> {
fn post_instantiation(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
_init_object: Option<crate::avm1::Object<'gc>>,
_instantiated_by: Instantiator,
_run_frame: bool,
@ -249,7 +249,7 @@ impl<'gc> TDisplayObject<'gc> for Text<'gc> {
.library_for_movie(self.movie())
.unwrap()
.avm2_domain();
let mut activation = Avm2Activation::from_domain(context.reborrow(), domain);
let mut activation = Avm2Activation::from_domain(context, domain);
let statictext = activation.avm2().classes().statictext;
match Avm2StageObject::for_display_object_childless(
&mut activation,
@ -274,7 +274,7 @@ impl<'gc> TDisplayObject<'gc> for Text<'gc> {
.unwrap_or(Avm2Value::Null)
}
fn set_object2(&self, context: &mut UpdateContext<'_, 'gc>, to: Avm2Object<'gc>) {
fn set_object2(&self, context: &mut UpdateContext<'gc>, to: Avm2Object<'gc>) {
self.0.write(context.gc_context).avm2_object = Some(to);
}
}

View File

@ -184,7 +184,7 @@ impl<'gc> Video<'gc> {
/// Convert this Video into a NetStream sourced video.
///
/// Existing video state related to the old video stream will be dropped.
pub fn attach_netstream(self, context: &mut UpdateContext<'_, 'gc>, stream: NetStream<'gc>) {
pub fn attach_netstream(self, context: &mut UpdateContext<'gc>, stream: NetStream<'gc>) {
let mut video = self.0.write(context.gc_context);
video.source = GcCell::new(context.gc_context, VideoSource::NetStream { stream });
@ -196,7 +196,7 @@ impl<'gc> Video<'gc> {
///
/// This function yields an error if this video player is not playing an
/// embedded SWF video.
pub fn preload_swf_frame(&mut self, tag: VideoFrame, context: &mut UpdateContext<'_, 'gc>) {
pub fn preload_swf_frame(&mut self, tag: VideoFrame, context: &mut UpdateContext<'gc>) {
let movie = self.0.read().movie.clone();
match (*self
@ -230,7 +230,7 @@ impl<'gc> Video<'gc> {
///
/// `seek` is only called when processing `PlaceObject` tags involving this
/// Video. It is a no-op for Videos that are connected to a `NetStream`.
pub fn seek(self, context: &mut UpdateContext<'_, 'gc>, mut frame_id: u32) {
pub fn seek(self, context: &mut UpdateContext<'gc>, mut frame_id: u32) {
let read = self.0.read();
if let VideoStream::Uninstantiated(_) = &read.stream {
drop(read);
@ -301,7 +301,7 @@ impl<'gc> Video<'gc> {
/// This function makes no attempt to ensure that the proposed seek is
/// valid, hence the fact that it's not `pub`. To do a seek that accounts
/// for keyframes, see `Video.seek`.
fn seek_internal(self, context: &mut UpdateContext<'_, 'gc>, frame_id: u32) {
fn seek_internal(self, context: &mut UpdateContext<'gc>, frame_id: u32) {
let read = self.0.read();
let source = read.source;
let stream = if let VideoStream::Instantiated(stream) = &read.stream {
@ -371,7 +371,7 @@ impl<'gc> TDisplayObject<'gc> for Video<'gc> {
fn post_instantiation(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
_init_object: Option<Avm1Object<'gc>>,
_instantiated_by: Instantiator,
run_frame: bool,
@ -470,10 +470,10 @@ impl<'gc> TDisplayObject<'gc> for Video<'gc> {
}
}
fn construct_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
fn construct_frame(&self, context: &mut UpdateContext<'gc>) {
if self.movie().is_action_script_3() && matches!(self.object2(), Avm2Value::Null) {
let video_constr = context.avm2.classes().video;
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let size = self.0.read().size;
match Avm2StageObject::for_display_object_childless_with_args(
&mut activation,
@ -573,7 +573,7 @@ impl<'gc> TDisplayObject<'gc> for Video<'gc> {
context.transform_stack.pop();
}
fn set_object2(&self, context: &mut UpdateContext<'_, 'gc>, to: Avm2Object<'gc>) {
fn set_object2(&self, context: &mut UpdateContext<'gc>, to: Avm2Object<'gc>) {
self.0.write(context.gc_context).object = Some(to.into());
}

View File

@ -266,7 +266,7 @@ pub enum Callback<'gc> {
impl<'gc> Callback<'gc> {
pub fn call(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
name: &str,
args: impl IntoIterator<Item = Value>,
) -> Value {
@ -274,7 +274,7 @@ impl<'gc> Callback<'gc> {
Callback::Avm1 { this, method } => {
if let Some(base_clip) = context.stage.root_clip() {
let mut activation = Avm1Activation::from_nothing(
context.reborrow(),
context,
Avm1ActivationIdentifier::root("[ExternalInterface]"),
base_clip,
);
@ -299,7 +299,7 @@ impl<'gc> Callback<'gc> {
.library_for_movie(context.swf.clone())
.unwrap()
.avm2_domain();
let mut activation = Avm2Activation::from_domain(context.reborrow(), domain);
let mut activation = Avm2Activation::from_domain(context, domain);
let args: Vec<Avm2Value> = args
.into_iter()
.map(|v| v.into_avm2(&mut activation))
@ -340,14 +340,14 @@ pub trait ExternalInterfaceProvider {
}
pub trait ExternalInterfaceMethod {
fn call(&self, context: &mut UpdateContext<'_, '_>, args: &[Value]) -> Value;
fn call(&self, context: &mut UpdateContext<'_>, args: &[Value]) -> Value;
}
impl<F> ExternalInterfaceMethod for F
where
F: Fn(&mut UpdateContext<'_, '_>, &[Value]) -> Value,
F: Fn(&mut UpdateContext<'_>, &[Value]) -> Value,
{
fn call(&self, context: &mut UpdateContext<'_, '_>, args: &[Value]) -> Value {
fn call(&self, context: &mut UpdateContext<'_>, args: &[Value]) -> Value {
self(context, args)
}
}

View File

@ -87,12 +87,12 @@ impl<'gc> FocusTracker<'gc> {
}
/// Set the focus programmatically.
pub fn set(&self, new: Option<InteractiveObject<'gc>>, context: &mut UpdateContext<'_, 'gc>) {
pub fn set(&self, new: Option<InteractiveObject<'gc>>, context: &mut UpdateContext<'gc>) {
self.set_internal(new, context, false);
}
/// Reset the focus programmatically.
pub fn reset_focus(&self, context: &mut UpdateContext<'_, 'gc>) {
pub fn reset_focus(&self, context: &mut UpdateContext<'gc>) {
self.set_internal(None, context, true);
}
@ -100,7 +100,7 @@ impl<'gc> FocusTracker<'gc> {
pub fn set_by_mouse(
&self,
new: Option<InteractiveObject<'gc>>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) {
let old = self.0.focus.get();
@ -129,7 +129,7 @@ impl<'gc> FocusTracker<'gc> {
&self,
new: Option<InteractiveObject<'gc>>,
key_code: KeyCode,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) {
let old = self.0.focus.get();
if Self::dispatch_focus_change_event(context, "keyFocusChange", old, new, Some(key_code)) {
@ -142,7 +142,7 @@ impl<'gc> FocusTracker<'gc> {
fn set_internal(
&self,
new: Option<InteractiveObject<'gc>>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
run_actions: bool,
) {
Self::roll_over(context, new);
@ -208,7 +208,7 @@ impl<'gc> FocusTracker<'gc> {
self.update_virtual_keyboard(context);
}
fn update_virtual_keyboard(&self, context: &mut UpdateContext<'_, 'gc>) {
fn update_virtual_keyboard(&self, context: &mut UpdateContext<'gc>) {
if let Some(text_field) = self.get_as_edit_text() {
if text_field.is_editable() {
context.ui.open_virtual_keyboard();
@ -224,7 +224,7 @@ impl<'gc> FocusTracker<'gc> {
///
/// Returns `true` if the focus change operation should be canceled.
fn dispatch_focus_change_event(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
event_type: &'static str,
target: Option<InteractiveObject<'gc>>,
related_object: Option<InteractiveObject<'gc>>,
@ -238,7 +238,7 @@ impl<'gc> FocusTracker<'gc> {
return false;
};
let mut activation = Activation::from_nothing(context.reborrow());
let mut activation = Activation::from_nothing(context);
let key_code = key_code.map(|k| k as u8).unwrap_or_default();
let event =
EventObject::focus_event(&mut activation, event_type, true, related_object, key_code);
@ -248,7 +248,7 @@ impl<'gc> FocusTracker<'gc> {
canceled
}
fn roll_over(context: &mut UpdateContext<'_, 'gc>, new: Option<InteractiveObject<'gc>>) {
fn roll_over(context: &mut UpdateContext<'gc>, new: Option<InteractiveObject<'gc>>) {
let old = context.mouse_data.hovered;
// AVM2 does not dispatch roll out/over events here and does not update hovered object.
@ -268,13 +268,13 @@ impl<'gc> FocusTracker<'gc> {
}
}
pub fn tab_order(&self, context: &mut UpdateContext<'_, 'gc>) -> TabOrder<'gc> {
pub fn tab_order(&self, context: &mut UpdateContext<'gc>) -> TabOrder<'gc> {
let mut tab_order = TabOrder::fill(context);
tab_order.sort();
tab_order
}
pub fn cycle(&self, context: &mut UpdateContext<'_, 'gc>, reverse: bool) {
pub fn cycle(&self, context: &mut UpdateContext<'gc>, reverse: bool) {
// Ordering the whole array and finding the next object in it
// is suboptimal, but it's a simple and infrequently performed operation.
// Additionally, we want to display the whole list in the debug UI anyway,
@ -305,7 +305,7 @@ impl<'gc> FocusTracker<'gc> {
}
}
pub fn navigate(&self, context: &mut UpdateContext<'_, 'gc>, direction: NavigationDirection) {
pub fn navigate(&self, context: &mut UpdateContext<'gc>, direction: NavigationDirection) {
let Some(focus) = self.get() else {
return;
};
@ -317,11 +317,11 @@ impl<'gc> FocusTracker<'gc> {
}
}
pub fn update_highlight(&self, context: &mut UpdateContext<'_, 'gc>) {
pub fn update_highlight(&self, context: &mut UpdateContext<'gc>) {
self.0.highlight.replace(self.calculate_highlight(context));
}
fn calculate_highlight(&self, context: &mut UpdateContext<'_, 'gc>) -> Highlight {
fn calculate_highlight(&self, context: &mut UpdateContext<'gc>) -> Highlight {
let Some(focus) = self.get() else {
return Highlight::Inactive;
};
@ -387,7 +387,7 @@ impl<'gc> TabOrder<'gc> {
}
}
fn fill(context: &mut UpdateContext<'_, 'gc>) -> Self {
fn fill(context: &mut UpdateContext<'gc>) -> Self {
let stage = context.stage;
let mut tab_order = Self::empty();
stage.fill_tab_order(&mut tab_order, context);

View File

@ -69,7 +69,7 @@ pub enum FramePhase {
/// still be lurking bugs, but the current code matches Flash's
/// output exactly for two complex test cases (see `avm2/orphan_movie*`)
#[instrument(level = "debug", skip_all)]
pub fn run_all_phases_avm2(context: &mut UpdateContext<'_, '_>) {
pub fn run_all_phases_avm2(context: &mut UpdateContext<'_>) {
let stage = context.stage;
if !stage.movie().is_action_script_3() {
@ -120,7 +120,7 @@ pub fn run_all_phases_avm2(context: &mut UpdateContext<'_, '_>) {
/// cause frame construction to get run for the *current frame* of other objects on the timeline
/// (even if the goto was called from an enterFrame event handler).
pub fn run_inner_goto_frame<'gc>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
removed_frame_scripts: &[DisplayObject<'gc>],
initial_clip: MovieClip<'gc>,
) {
@ -189,7 +189,7 @@ pub fn run_inner_goto_frame<'gc>(
///
/// This is a no-op on AVM1, which has it's own catch-up logic.
pub fn catchup_display_object_to_frame<'gc>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
dobj: DisplayObject<'gc>,
) {
if !dobj.movie().is_action_script_3() {

View File

@ -254,7 +254,7 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {
/// parameter will result in no empty lines being added.
fn fixup_line(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
only_line: bool,
final_line_of_para: bool,
end: usize,
@ -402,7 +402,7 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {
/// the current positions into the text and format spans we are laying out.
fn explicit_newline(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
end: usize,
span: &TextSpan,
font_type: FontType,
@ -431,7 +431,7 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {
/// the current positions into the text and format spans we are laying out.
fn newline(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
end: usize,
span: &TextSpan,
font_type: FontType,
@ -487,7 +487,7 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {
fn resolve_font(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
span: &TextSpan,
font_type: FontType,
) -> Option<Font<'gc>> {
@ -630,7 +630,7 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {
/// cursor is moved down.
fn append_bullet(
&mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
span: &TextSpan,
font_type: FontType,
) {
@ -712,7 +712,7 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {
/// Destroy the layout context, returning the newly constructed layout list.
fn end_layout(
mut self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
fs: &'a FormatSpans,
font_type: FontType,
) -> Layout<'gc> {
@ -1010,7 +1010,7 @@ impl<'gc> LayoutBox<'gc> {
/// Construct a new layout from text spans.
pub fn lower_from_text_spans<'gc>(
fs: &FormatSpans,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
movie: Arc<SwfMovie>,
bounds: Twips,
is_word_wrap: bool,

View File

@ -151,7 +151,7 @@ impl TextFormat {
pub fn from_swf_tag(
et: swf::EditText<'_>,
swf_movie: Arc<SwfMovie>,
context: &mut UpdateContext<'_, '_>,
context: &mut UpdateContext<'_>,
) -> Self {
let encoding = swf_movie.encoding();
let movie_library = context.library.library_for_movie_mut(swf_movie);

View File

@ -71,11 +71,7 @@ impl ExecutionLimit {
/// been breached, this returns `true`. Otherwise, this returns `false`,
/// and if the operation limit was exhausted, it will be returned to the
/// starting maximum.
pub fn did_ops_breach_limit(
&mut self,
context: &mut UpdateContext<'_, '_>,
ops: usize,
) -> bool {
pub fn did_ops_breach_limit(&mut self, context: &mut UpdateContext<'_>, ops: usize) -> bool {
if let Some(oplimit) = &mut self.current_oplimit {
*oplimit = oplimit.saturating_sub(ops);

View File

@ -406,7 +406,7 @@ impl<'gc> LoadManager<'gc> {
///
/// Returns the loader's async process, which you will need to spawn.
pub fn load_movie_into_clip_bytes(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
target_clip: DisplayObject<'gc>,
bytes: Vec<u8>,
vm_data: MovieLoaderVMData<'gc>,
@ -578,7 +578,7 @@ impl<'gc> LoadManager<'gc> {
/// Process tags on all loaders in the Parsing phase.
///
/// Returns true if *all* loaders finished preloading.
pub fn preload_tick(context: &mut UpdateContext<'_, 'gc>, limit: &mut ExecutionLimit) -> bool {
pub fn preload_tick(context: &mut UpdateContext<'gc>, limit: &mut ExecutionLimit) -> bool {
let mut did_finish = true;
let handles: Vec<_> = context.load_manager.0.iter().map(|(h, _)| h).collect();
@ -920,7 +920,7 @@ impl<'gc> Loader<'gc> {
/// Returns any AVM errors encountered while sending events to user code.
fn preload_tick(
handle: LoaderHandle,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
limit: &mut ExecutionLimit,
status: u16,
redirected: bool,
@ -1106,7 +1106,7 @@ impl<'gc> Loader<'gc> {
let clip_value = mc.object();
if let Value::Object(clip_object) = clip_value {
let mut activation = Activation::from_nothing(
uc.reborrow(),
uc,
ActivationIdentifier::root("unknown"),
clip,
);
@ -1136,7 +1136,7 @@ impl<'gc> Loader<'gc> {
let root_val = root.object();
if let Value::Object(root_object) = root_val {
let mut activation = Activation::from_nothing(
uc.reborrow(),
uc,
ActivationIdentifier::root("unknown"),
root,
);
@ -1157,7 +1157,7 @@ impl<'gc> Loader<'gc> {
let val = root.object();
if let Value::Object(clip_object) = val {
let mut activation = Activation::from_nothing(
uc.reborrow(),
uc,
ActivationIdentifier::root("unknown"),
root,
);
@ -1217,7 +1217,7 @@ impl<'gc> Loader<'gc> {
pub fn movie_loader_bytes(
handle: LoaderHandle,
uc: &mut UpdateContext<'_, 'gc>,
uc: &mut UpdateContext<'gc>,
bytes: Vec<u8>,
) -> Result<(), Error> {
let clip = match uc.load_manager.get_loader(handle) {
@ -1286,10 +1286,8 @@ impl<'gc> Loader<'gc> {
_ => return Err(Error::NotFormLoader),
};
let mut activation = Activation::from_stub(
uc.reborrow(),
ActivationIdentifier::root("[Form Loader]"),
);
let mut activation =
Activation::from_stub(uc, ActivationIdentifier::root("[Form Loader]"));
let utf8_string;
let utf8_body = if activation.context.system.use_codepage {
@ -1370,7 +1368,7 @@ impl<'gc> Loader<'gc> {
};
let mut activation =
Activation::from_stub(uc.reborrow(), ActivationIdentifier::root("[Loader]"));
Activation::from_stub(uc, ActivationIdentifier::root("[Loader]"));
match response {
Ok((body, _, status, _)) => {
@ -1470,7 +1468,7 @@ impl<'gc> Loader<'gc> {
};
let mut activation =
Activation::from_stub(uc.reborrow(), ActivationIdentifier::root("[Loader]"));
Activation::from_stub(uc, ActivationIdentifier::root("[Loader]"));
match response {
Ok((body, _, _, _)) => {
@ -1540,7 +1538,7 @@ impl<'gc> Loader<'gc> {
_ => unreachable!(),
};
let mut activation = Avm2Activation::from_nothing(uc.reborrow());
let mut activation = Avm2Activation::from_nothing(uc);
fn set_data<'a, 'gc: 'a>(
body: Vec<u8>,
@ -1759,7 +1757,7 @@ impl<'gc> Loader<'gc> {
.is_ok();
let mut activation =
Activation::from_stub(uc.reborrow(), ActivationIdentifier::root("[Loader]"));
Activation::from_stub(uc, ActivationIdentifier::root("[Loader]"));
let _ = sound_object.call_method(
"onLoad".into(),
&[success.into()],
@ -1820,7 +1818,7 @@ impl<'gc> Loader<'gc> {
let total_len = body.len();
// FIXME - the "open" event should be fired earlier, and not fired in case of ioerror.
let mut activation = Avm2Activation::from_nothing(uc.reborrow());
let mut activation = Avm2Activation::from_nothing(uc);
let open_evt =
Avm2EventObject::bare_default_event(activation.context, "open");
Avm2::dispatch_event(activation.context, open_evt, sound_object);
@ -1856,7 +1854,7 @@ impl<'gc> Loader<'gc> {
}
Err(_err) => {
// FIXME: Match the exact error message generated by Flash.
let mut activation = Avm2Activation::from_nothing(uc.reborrow());
let mut activation = Avm2Activation::from_nothing(uc);
let io_error_evt_cls = activation.avm2().classes().ioerrorevent;
let io_error_evt = io_error_evt_cls
.construct(
@ -1960,10 +1958,7 @@ impl<'gc> Loader<'gc> {
}
/// Report a movie loader start event to script code.
fn movie_loader_start(
handle: LoaderHandle,
uc: &mut UpdateContext<'_, 'gc>,
) -> Result<(), Error> {
fn movie_loader_start(handle: LoaderHandle, uc: &mut UpdateContext<'gc>) -> Result<(), Error> {
let me = uc.load_manager.get_loader_mut(handle);
if me.is_none() {
return Err(Error::Cancelled);
@ -1993,7 +1988,7 @@ impl<'gc> Loader<'gc> {
}
}
MovieLoaderVMData::Avm2 { loader_info, .. } => {
let activation = Avm2Activation::from_nothing(uc.reborrow());
let activation = Avm2Activation::from_nothing(uc);
let open_evt = Avm2EventObject::bare_default_event(activation.context, "open");
Avm2::dispatch_event(uc, open_evt, loader_info);
@ -2006,7 +2001,7 @@ impl<'gc> Loader<'gc> {
/// Load data into a movie loader.
fn movie_loader_data(
handle: LoaderHandle,
uc: &mut UpdateContext<'_, 'gc>,
uc: &mut UpdateContext<'gc>,
data: &[u8],
url: String,
status: u16,
@ -2034,7 +2029,7 @@ impl<'gc> Loader<'gc> {
_ => unreachable!(),
};
let mut activation = Avm2Activation::from_nothing(uc.reborrow());
let mut activation = Avm2Activation::from_nothing(uc);
let domain = if let MovieLoaderVMData::Avm2 {
context,
@ -2347,7 +2342,7 @@ impl<'gc> Loader<'gc> {
/// The current and total length are always reported as compressed lengths.
fn movie_loader_progress(
handle: LoaderHandle,
uc: &mut UpdateContext<'_, 'gc>,
uc: &mut UpdateContext<'gc>,
cur_len: usize,
total_len: usize,
) -> Result<(), Error> {
@ -2385,7 +2380,7 @@ impl<'gc> Loader<'gc> {
}
}
MovieLoaderVMData::Avm2 { loader_info, .. } => {
let mut activation = Avm2Activation::from_nothing(uc.reborrow());
let mut activation = Avm2Activation::from_nothing(uc);
let progress_evt = activation
.avm2()
@ -2413,7 +2408,7 @@ impl<'gc> Loader<'gc> {
/// Report a movie loader completion to script code.
fn movie_loader_complete(
handle: LoaderHandle,
uc: &mut UpdateContext<'_, 'gc>,
uc: &mut UpdateContext<'gc>,
dobj: Option<DisplayObject<'gc>>,
status: u16,
redirected: bool,
@ -2463,11 +2458,8 @@ impl<'gc> Loader<'gc> {
let flashvars = movie.clone().unwrap().parameters().to_owned();
if !flashvars.is_empty() {
let mut activation = Activation::from_nothing(
uc.reborrow(),
ActivationIdentifier::root("[Loader]"),
dobj,
);
let mut activation =
Activation::from_nothing(uc, ActivationIdentifier::root("[Loader]"), dobj);
let object = dobj.object().coerce_to_object(&mut activation);
for (key, value) in flashvars.iter() {
object.define_value(
@ -2487,7 +2479,7 @@ impl<'gc> Loader<'gc> {
.library_for_movie(movie.clone().unwrap())
.unwrap()
.avm2_domain();
let mut activation = Avm2Activation::from_domain(uc.reborrow(), domain);
let mut activation = Avm2Activation::from_domain(uc, domain);
let mut loader = loader_info
.get_public_property("loader", &mut activation)
.map_err(|e| Error::Avm2Error(e.to_string()))?
@ -2582,7 +2574,7 @@ impl<'gc> Loader<'gc> {
/// context and one of it's loaders.
fn movie_loader_error(
handle: LoaderHandle,
uc: &mut UpdateContext<'_, 'gc>,
uc: &mut UpdateContext<'gc>,
msg: AvmString<'gc>,
status: u16,
redirected: bool,
@ -2625,7 +2617,7 @@ impl<'gc> Loader<'gc> {
}
}
MovieLoaderVMData::Avm2 { loader_info, .. } => {
let mut activation = Avm2Activation::from_nothing(uc.reborrow());
let mut activation = Avm2Activation::from_nothing(uc);
let http_status_evt = activation
.avm2()
@ -2679,7 +2671,7 @@ impl<'gc> Loader<'gc> {
/// has been successfully loaded yet.
fn load_initial_loading_swf(
mc: &mut MovieClip<'gc>,
uc: &mut UpdateContext<'_, 'gc>,
uc: &mut UpdateContext<'gc>,
request_url: &str,
resolved_url: Result<Url, ParseError>,
) {
@ -2722,11 +2714,7 @@ impl<'gc> Loader<'gc> {
/// supported content.
///
/// swf_url is always the final URL obtained after any redirects.
fn load_error_swf(
mc: &mut MovieClip<'gc>,
uc: &mut UpdateContext<'_, 'gc>,
mut swf_url: String,
) {
fn load_error_swf(mc: &mut MovieClip<'gc>, uc: &mut UpdateContext<'gc>, mut swf_url: String) {
// If a local URL is fetched using the flash plugin, the _url property
// won't be changed => It keeps being the parent SWF URL.
if cfg!(target_family = "wasm") {
@ -2817,10 +2805,8 @@ impl<'gc> Loader<'gc> {
_ => panic!("NativeObject must be FileReference"),
};
let mut activation = Activation::from_stub(
uc.reborrow(),
ActivationIdentifier::root("[File Dialog]"),
);
let mut activation =
Activation::from_stub(uc, ActivationIdentifier::root("[File Dialog]"));
match dialog_result {
Ok(dialog_result) => {
@ -2858,8 +2844,7 @@ impl<'gc> Loader<'gc> {
if !dialog_result.is_cancelled() {
target_object.init_from_dialog_result(dialog_result);
let activation =
Avm2Activation::from_nothing(uc.reborrow());
let activation = Avm2Activation::from_nothing(uc);
let select_event = Avm2EventObject::bare_default_event(
activation.context,
"select",
@ -2870,8 +2855,7 @@ impl<'gc> Loader<'gc> {
target_object.into(),
);
} else {
let activation =
Avm2Activation::from_nothing(uc.reborrow());
let activation = Avm2Activation::from_nothing(uc);
let cancel_event = Avm2EventObject::bare_default_event(
activation.context,
"cancel",
@ -2936,7 +2920,7 @@ impl<'gc> Loader<'gc> {
dialog_result.write_and_refresh(&data);
target_object.init_from_dialog_result(dialog_result);
let mut activation = Avm2Activation::from_nothing(uc.reborrow());
let mut activation = Avm2Activation::from_nothing(uc);
let select_event =
Avm2EventObject::bare_default_event(activation.context, "select");
@ -2977,11 +2961,9 @@ impl<'gc> Loader<'gc> {
target_object.into(),
);
} else {
let activation = Avm2Activation::from_nothing(uc.reborrow());
let cancel_event = Avm2EventObject::bare_default_event(
activation.context,
"cancel",
);
let activation = Avm2Activation::from_nothing(uc);
let cancel_event =
Avm2EventObject::bare_default_event(activation.context, "cancel");
Avm2::dispatch_event(
activation.context,
cancel_event,
@ -3045,10 +3027,8 @@ impl<'gc> Loader<'gc> {
_ => panic!("NativeObject must be FileReference"),
};
let mut activation = Activation::from_stub(
uc.reborrow(),
ActivationIdentifier::root("[File Dialog]"),
);
let mut activation =
Activation::from_stub(uc, ActivationIdentifier::root("[File Dialog]"));
use crate::avm1::globals::as_broadcaster;
match dialog_result {
@ -3279,10 +3259,8 @@ impl<'gc> Loader<'gc> {
_ => return Err(Error::NotFileUploadLoader),
};
let mut activation = Activation::from_stub(
uc.reborrow(),
ActivationIdentifier::root("[File Dialog]"),
);
let mut activation =
Activation::from_stub(uc, ActivationIdentifier::root("[File Dialog]"));
use crate::avm1::globals::as_broadcaster;
as_broadcaster::broadcast_internal(

View File

@ -30,7 +30,7 @@ impl<'gc> From<Avm1Object<'gc>> for LocalConnectionKind<'gc> {
}
impl<'gc> LocalConnectionKind<'gc> {
pub fn send_status(&self, context: &mut UpdateContext<'_, 'gc>, status: &'static str) {
pub fn send_status(&self, context: &mut UpdateContext<'gc>, status: &'static str) {
match self {
LocalConnectionKind::Avm2(_domain, object) => {
object.send_status(context, status);
@ -45,7 +45,7 @@ impl<'gc> LocalConnectionKind<'gc> {
pub fn run_method(
&self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
method_name: AvmString<'gc>,
arguments: Vec<AmfValue>,
) {
@ -85,7 +85,7 @@ pub enum QueuedMessageKind<'gc> {
}
impl<'gc> QueuedMessageKind<'gc> {
pub fn deliver(self, source: LocalConnectionKind<'gc>, context: &mut UpdateContext<'_, 'gc>) {
pub fn deliver(self, source: LocalConnectionKind<'gc>, context: &mut UpdateContext<'gc>) {
match self {
QueuedMessageKind::Failure => {
source.send_status(context, "error");
@ -207,7 +207,7 @@ impl<'gc> LocalConnections<'gc> {
self.connections.get(name).cloned()
}
pub fn update_connections(context: &mut UpdateContext<'_, 'gc>) {
pub fn update_connections(context: &mut UpdateContext<'gc>) {
if context.local_connections.messages.is_empty() {
return;
}

View File

@ -45,7 +45,7 @@ impl Debug for ResponderHandle {
impl ResponderHandle {
pub fn call(
&self,
context: &mut UpdateContext<'_, '_>,
context: &mut UpdateContext<'_>,
callback: ResponderCallback,
message: Rc<AmfValue>,
) {
@ -125,7 +125,7 @@ impl<'gc> Default for NetConnections<'gc> {
impl<'gc> NetConnections<'gc> {
pub fn connect_to_local<O: Into<NetConnectionObject<'gc>>>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
target: O,
) {
let target = target.into();
@ -141,7 +141,7 @@ impl<'gc> NetConnections<'gc> {
match target {
NetConnectionObject::Avm2(object) => {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let event = Avm2EventObject::net_status_event(
&mut activation,
"netStatus",
@ -165,7 +165,7 @@ impl<'gc> NetConnections<'gc> {
}
pub fn connect_to_flash_remoting<O: Into<NetConnectionObject<'gc>>>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
target: O,
url: String,
) {
@ -187,18 +187,14 @@ impl<'gc> NetConnections<'gc> {
// No open event here
}
pub fn close(
context: &mut UpdateContext<'_, 'gc>,
handle: NetConnectionHandle,
is_explicit: bool,
) {
pub fn close(context: &mut UpdateContext<'gc>, handle: NetConnectionHandle, is_explicit: bool) {
let Some(connection) = context.net_connections.connections.remove(handle) else {
return;
};
match connection.object {
NetConnectionObject::Avm2(object) => {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let event = Avm2EventObject::net_status_event(
&mut activation,
"netStatus",
@ -246,14 +242,14 @@ impl<'gc> NetConnections<'gc> {
}
}
pub fn update_connections(context: &mut UpdateContext<'_, 'gc>) {
pub fn update_connections(context: &mut UpdateContext<'gc>) {
for (handle, connection) in context.net_connections.connections.iter_mut() {
connection.update(handle, context.navigator, context.player.clone());
}
}
pub fn send_without_response(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
handle: NetConnectionHandle,
command: String,
message: AmfValue,
@ -264,7 +260,7 @@ impl<'gc> NetConnections<'gc> {
}
pub fn send_avm2(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
handle: NetConnectionHandle,
command: String,
message: AmfValue,
@ -278,7 +274,7 @@ impl<'gc> NetConnections<'gc> {
}
pub fn send_avm1(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
handle: NetConnectionHandle,
command: String,
message: AmfValue,
@ -546,8 +542,7 @@ impl FlashRemoting {
if let Some(connection) = uc.net_connections.connections.get(self_handle) {
match connection.object {
NetConnectionObject::Avm2(object) => {
let mut activation =
Avm2Activation::from_nothing(uc.reborrow());
let mut activation = Avm2Activation::from_nothing(uc);
let url = AvmString::new_utf8(
activation.context.gc_context,
response.url,

View File

@ -202,7 +202,7 @@ struct GcRootData<'gc> {
pub struct PostFrameCallback<'gc> {
#[collect(require_static)]
#[allow(clippy::type_complexity)]
pub callback: Box<dyn for<'b> FnOnce(&mut UpdateContext<'_, 'b>, DisplayObject<'b>) + 'static>,
pub callback: Box<dyn for<'b> FnOnce(&mut UpdateContext<'b>, DisplayObject<'b>) + 'static>,
pub data: DisplayObject<'gc>,
}
@ -612,10 +612,8 @@ impl Player {
let display_obj = Player::get_context_menu_display_object(context);
let menu = if let Some(Value::Object(obj)) = display_obj.map(|obj| obj.object()) {
let mut activation = Activation::from_stub(
context.reborrow(),
ActivationIdentifier::root("[ContextMenu]"),
);
let mut activation =
Activation::from_stub(context, ActivationIdentifier::root("[ContextMenu]"));
let menu_object = if let Ok(Value::Object(menu)) = obj.get("menu", &mut activation)
{
if let Ok(Value::Object(on_select)) = menu.get("onSelect", &mut activation) {
@ -628,7 +626,7 @@ impl Player {
crate::avm1::make_context_menu_state(menu_object, display_obj, &mut activation)
} else if let Some(Avm2Value::Object(hit_obj)) = display_obj.map(|obj| obj.object2()) {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let menu_object = display_obj
.expect("Root is confirmed to exist here")
@ -693,7 +691,7 @@ impl Player {
ContextMenuCallback::Avm2 { item } => {
if let Some(display_obj) = menu.get_display_object() {
let menu_item = *item;
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let menu_obj = display_obj
.as_interactive()
@ -744,12 +742,12 @@ impl Player {
fn run_context_menu_custom_callback<'gc>(
item: Object<'gc>,
callback: Object<'gc>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) {
if let Some(menu_state) = context.current_context_menu {
if let Some(display_object) = menu_state.get_display_object() {
let mut activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[Context Menu Callback]"),
display_object,
);
@ -768,7 +766,7 @@ impl Player {
///Returns the first display object that the mouse is hovering over that has a custom context menu. Returns root if none is found.
fn get_context_menu_display_object<'gc>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
) -> Option<DisplayObject<'gc>> {
let mut display_object = run_mouse_pick(context, false).map(|obj| obj.as_displayobject());
loop {
@ -780,7 +778,7 @@ impl Player {
) {
if let Some(Value::Object(obj)) = Some(disp_obj).map(|obj| obj.object()) {
let mut activation = Activation::from_stub(
context.reborrow(),
context,
ActivationIdentifier::root("[ContextMenu]"),
);
@ -808,7 +806,7 @@ impl Player {
});
}
fn toggle_play_root_movie(context: &mut UpdateContext<'_, '_>) {
fn toggle_play_root_movie(context: &mut UpdateContext<'_>) {
if let Some(mc) = context
.stage
.root_clip()
@ -821,7 +819,7 @@ impl Player {
}
}
}
fn rewind_root_movie(context: &mut UpdateContext<'_, '_>) {
fn rewind_root_movie(context: &mut UpdateContext<'_>) {
if let Some(mc) = context
.stage
.root_clip()
@ -830,7 +828,7 @@ impl Player {
mc.goto_frame(context, 1, true)
}
}
fn forward_root_movie(context: &mut UpdateContext<'_, '_>) {
fn forward_root_movie(context: &mut UpdateContext<'_>) {
if let Some(mc) = context
.stage
.root_clip()
@ -839,7 +837,7 @@ impl Player {
mc.next_frame(context);
}
}
fn back_root_movie(context: &mut UpdateContext<'_, '_>) {
fn back_root_movie(context: &mut UpdateContext<'_>) {
if let Some(mc) = context
.stage
.root_clip()
@ -1060,7 +1058,7 @@ impl Player {
let mut dumper = VariableDumper::new(" ");
let mut activation = Activation::from_stub(
context.reborrow(),
context,
ActivationIdentifier::root("[Variable Dumper]"),
);
@ -1149,7 +1147,7 @@ impl Player {
let alt_key = context.input.is_key_down(KeyCode::Alt);
let shift_key = context.input.is_key_down(KeyCode::Shift);
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let event_name = match event {
PlayerEvent::KeyDown { .. } => "keyDown",
@ -1432,7 +1430,7 @@ impl Player {
}
/// Update dragged object, if any.
pub fn update_drag(context: &mut UpdateContext<'_, '_>) {
pub fn update_drag(context: &mut UpdateContext<'_>) {
let mouse_position = *context.mouse_position;
if let Some(drag_object) = context.drag_object {
let display_object = drag_object.display_object;
@ -1807,7 +1805,7 @@ impl Player {
}
fn update_focus_on_mouse_press<'gc>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
pressed_object: DisplayObject<'gc>,
) {
let tracker = context.focus_tracker;
@ -1885,7 +1883,7 @@ impl Player {
did_finish = root.preload(context, limit);
if let Some(loader_info) = root.loader_info().filter(|_| !was_root_movie_loaded) {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let progress_evt = activation.avm2().classes().progressevent.construct(
&mut activation,
@ -2067,7 +2065,7 @@ impl Player {
&mut self.ui
}
pub fn run_actions(context: &mut UpdateContext<'_, '_>) {
pub fn run_actions(context: &mut UpdateContext<'_>) {
// Note that actions can queue further actions, so a while loop is necessary here.
while let Some(action) = context.action_queue.pop_action() {
// We don't run frame actions if the clip was removed (or scheduled to be removed) after it queued the action.
@ -2089,7 +2087,7 @@ impl Player {
events,
} => {
let mut activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[Construct]"),
action.clip,
);
@ -2166,7 +2164,7 @@ impl Player {
/// This takes cares of populating the `UpdateContext` struct, avoiding borrow issues.
pub fn mutate_with_update_context<F, R>(&mut self, f: F) -> R
where
F: for<'a, 'gc> FnOnce(&mut UpdateContext<'a, 'gc>) -> R,
F: for<'a, 'gc> FnOnce(&mut UpdateContext<'gc>) -> R,
{
self.enter_arena_mut(|gc_context, gc_root, this| {
#[allow(unused_variables)]
@ -2196,7 +2194,6 @@ impl Player {
) = gc_root.update_context_params();
let mut update_context = UpdateContext {
_unused: std::marker::PhantomData,
player_version: this.player_version,
swf: &mut this.swf,
library,
@ -2298,7 +2295,7 @@ impl Player {
/// hover state up to date, and running garbage collection.
pub fn update<F, R>(&mut self, func: F) -> R
where
F: for<'a, 'gc> FnOnce(&mut UpdateContext<'a, 'gc>) -> R,
F: for<'a, 'gc> FnOnce(&mut UpdateContext<'gc>) -> R,
{
let rval = self.mutate_with_update_context(|context| {
let rval = func(context);
@ -2323,7 +2320,7 @@ impl Player {
pub fn flush_shared_objects(&mut self) {
self.update(|context| {
if let Some(mut avm1_activation) =
Activation::try_from_stub(context.reborrow(), ActivationIdentifier::root("[Flush]"))
Activation::try_from_stub(context, ActivationIdentifier::root("[Flush]"))
{
for so in avm1_activation.context.avm1_shared_objects.clone().values() {
if let Err(e) =
@ -2334,7 +2331,7 @@ impl Player {
}
}
let mut avm2_activation = Avm2Activation::from_nothing(context.reborrow());
let mut avm2_activation = Avm2Activation::from_nothing(context);
for so in avm2_activation.context.avm2_shared_objects.clone().values() {
if let Err(e) = crate::avm2::globals::flash::net::shared_object::flush(
&mut avm2_activation,
@ -2994,7 +2991,7 @@ pub struct DragObject<'gc> {
}
fn run_mouse_pick<'gc>(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
require_button_mode: bool,
) -> Option<InteractiveObject<'gc>> {
context.stage.iter_render_list().rev().find_map(|level| {

View File

@ -205,7 +205,7 @@ impl<'gc> Sockets<'gc> {
}
}
pub fn update_sockets(context: &mut UpdateContext<'_, 'gc>) {
pub fn update_sockets(context: &mut UpdateContext<'gc>) {
let mut actions = vec![];
while let Ok(action) = context.sockets.receiver.try_recv() {
@ -226,7 +226,7 @@ impl<'gc> Sockets<'gc> {
match target {
SocketKind::Avm2(target) => {
let activation = Avm2Activation::from_nothing(context.reborrow());
let activation = Avm2Activation::from_nothing(context);
let connect_evt =
EventObject::bare_default_event(activation.context, "connect");
@ -234,7 +234,7 @@ impl<'gc> Sockets<'gc> {
}
SocketKind::Avm1(target) => {
let mut activation = Avm1Activation::from_stub(
context.reborrow(),
context,
ActivationIdentifier::root("[XMLSocket]"),
);
@ -259,7 +259,7 @@ impl<'gc> Sockets<'gc> {
match target {
SocketKind::Avm2(target) => {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let io_error_evt = activation
.avm2()
@ -282,7 +282,7 @@ impl<'gc> Sockets<'gc> {
// TODO: Not sure if avm1 xmlsocket has a way to notify a error. (Probably should just fire connect event with success as false).
SocketKind::Avm1(target) => {
let mut activation = Avm1Activation::from_stub(
context.reborrow(),
context,
ActivationIdentifier::root("[XMLSocket]"),
);
@ -304,7 +304,7 @@ impl<'gc> Sockets<'gc> {
match target {
SocketKind::Avm2(target) => {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let bytes_loaded = data.len();
target.read_buffer().extend(data);
@ -330,7 +330,7 @@ impl<'gc> Sockets<'gc> {
}
SocketKind::Avm1(target) => {
let mut activation = Avm1Activation::from_stub(
context.reborrow(),
context,
ActivationIdentifier::root("[XMLSocket]"),
);
@ -400,7 +400,7 @@ impl<'gc> Sockets<'gc> {
match target {
SocketKind::Avm2(target) => {
let activation = Avm2Activation::from_nothing(context.reborrow());
let activation = Avm2Activation::from_nothing(context);
// Clear the buffers if the connection was closed.
target.read_buffer().clear();
@ -412,7 +412,7 @@ impl<'gc> Sockets<'gc> {
}
SocketKind::Avm1(target) => {
let mut activation = Avm1Activation::from_stub(
context.reborrow(),
context,
ActivationIdentifier::root("[XMLSocket]"),
);

View File

@ -97,7 +97,7 @@ impl<'gc> StreamManager<'gc> {
/// This can be called at any time to flag that a `NetStream` has work to
/// do, and called multiple times. The `NetStream` will determine what to
/// do at tick time.
pub fn activate(context: &mut UpdateContext<'_, 'gc>, stream: NetStream<'gc>) {
pub fn activate(context: &mut UpdateContext<'gc>, stream: NetStream<'gc>) {
if !context.stream_manager.active_streams.contains(&stream) {
context.stream_manager.active_streams.push(stream);
}
@ -107,7 +107,7 @@ impl<'gc> StreamManager<'gc> {
///
/// This should only ever be called at tick time if the stream itself has
/// determined there is no future work for it to do.
pub fn deactivate(context: &mut UpdateContext<'_, 'gc>, stream: NetStream<'gc>) {
pub fn deactivate(context: &mut UpdateContext<'gc>, stream: NetStream<'gc>) {
let index = context
.stream_manager
.active_streams
@ -125,7 +125,7 @@ impl<'gc> StreamManager<'gc> {
/// support video framerates separate from the Stage frame rate.
///
/// This does not borrow `&mut self` as we need the `UpdateContext`, too.
pub fn tick(context: &mut UpdateContext<'_, 'gc>, dt: f64) {
pub fn tick(context: &mut UpdateContext<'gc>, dt: f64) {
let streams = context.stream_manager.active_streams.clone();
for stream in streams {
stream.tick(context, dt)
@ -301,7 +301,7 @@ impl<'gc> NetStream<'gc> {
///
/// Externally visible AVM state must not be reinitialized here - i.e. the
/// AS3 `client` doesn't go away because you played a new video file.
pub fn reset_buffer(self, context: &mut UpdateContext<'_, 'gc>) {
pub fn reset_buffer(self, context: &mut UpdateContext<'gc>) {
let mut write = self.0.write(context.gc_context);
if let Some(instance) = write.sound_instance {
@ -325,7 +325,7 @@ impl<'gc> NetStream<'gc> {
}
/// Set the total number of bytes expected to be downloaded.
pub fn set_expected_length(self, context: &mut UpdateContext<'_, 'gc>, expected: usize) {
pub fn set_expected_length(self, context: &mut UpdateContext<'gc>, expected: usize) {
let mut write = self.0.write(context.gc_context);
let len = write.buffer.len();
@ -346,7 +346,7 @@ impl<'gc> NetStream<'gc> {
/// Buffer loading can be done in chunks but must be done in such a way
/// that all data is appended in the correct order and that data from
/// separate streams is not mixed together.
pub fn load_buffer(self, context: &mut UpdateContext<'_, 'gc>, data: &mut Vec<u8>) {
pub fn load_buffer(self, context: &mut UpdateContext<'gc>, data: &mut Vec<u8>) {
self.0.write(context.gc_context).buffer.append(data);
StreamManager::activate(context, self);
@ -360,7 +360,7 @@ impl<'gc> NetStream<'gc> {
/// Indicate that the buffer has finished loading and that no further data
/// is expected to be downloaded to it.
pub fn finish_buffer(self, context: &mut UpdateContext<'_, 'gc>) {
pub fn finish_buffer(self, context: &mut UpdateContext<'gc>) {
self.0.write(context.gc_context).expected_length = None;
}
@ -394,7 +394,7 @@ impl<'gc> NetStream<'gc> {
/// Queue a seek to be executed on the next frame tick.
///
/// `offset` is in milliseconds.
pub fn seek(self, context: &mut UpdateContext<'_, 'gc>, offset: f64, notify: bool) {
pub fn seek(self, context: &mut UpdateContext<'gc>, offset: f64, notify: bool) {
self.0.write(context.gc_context).queued_seek_time = Some(offset);
StreamManager::activate(context, self);
@ -430,7 +430,7 @@ impl<'gc> NetStream<'gc> {
///
/// This function should be run during stream ticks and *not* called by AVM
/// code to service seek requests.
pub fn execute_seek(self, context: &mut UpdateContext<'_, 'gc>, offset: f64) {
pub fn execute_seek(self, context: &mut UpdateContext<'gc>, offset: f64) {
self.trigger_status_event(
context,
vec![("code", "NetStream.Seek.Notify"), ("level", "status")],
@ -547,7 +547,7 @@ impl<'gc> NetStream<'gc> {
/// If `name` is specified, this will also trigger streaming download of
/// the given resource. Otherwise, the stream will play whatever data is
/// available in the buffer.
pub fn play(self, context: &mut UpdateContext<'_, 'gc>, name: Option<AvmString<'gc>>) {
pub fn play(self, context: &mut UpdateContext<'gc>, name: Option<AvmString<'gc>>) {
if let Some(name) = name {
let request = if let Ok(stream_url) =
Url::parse(context.swf.url()).and_then(|url| url.join(name.to_string().as_str()))
@ -576,7 +576,7 @@ impl<'gc> NetStream<'gc> {
}
/// Pause stream playback.
pub fn pause(self, context: &mut UpdateContext<'_, 'gc>, notify: bool) {
pub fn pause(self, context: &mut UpdateContext<'gc>, notify: bool) {
// NOTE: We do not deactivate the stream here as there may be other
// work to be done at tick time.
self.0.write(context.gc_context).playing = false;
@ -594,13 +594,13 @@ impl<'gc> NetStream<'gc> {
}
/// Resume stream playback.
pub fn resume(self, context: &mut UpdateContext<'_, 'gc>) {
pub fn resume(self, context: &mut UpdateContext<'gc>) {
self.0.write(context.gc_context).playing = true;
StreamManager::activate(context, self);
}
/// Resume stream playback if paused, pause otherwise.
pub fn toggle_paused(self, context: &mut UpdateContext<'_, 'gc>) {
pub fn toggle_paused(self, context: &mut UpdateContext<'gc>) {
let mut write = self.0.write(context.gc_context);
write.playing = !write.playing;
@ -610,7 +610,7 @@ impl<'gc> NetStream<'gc> {
}
/// Indicates that this `NetStream`'s audio was detached from a `MovieClip` (AVM1)
pub fn was_detached(self, context: &mut UpdateContext<'_, 'gc>) {
pub fn was_detached(self, context: &mut UpdateContext<'gc>) {
let mut write = self.0.write(context.gc_context);
if let Some(sound_instance) = &write.sound_instance {
@ -624,7 +624,7 @@ impl<'gc> NetStream<'gc> {
}
/// Indicates that this `NetStream`'s audio was attached to a `MovieClip` (AVM1)
pub fn was_attached(self, context: &mut UpdateContext<'_, 'gc>, clip: MovieClip<'gc>) {
pub fn was_attached(self, context: &mut UpdateContext<'gc>, clip: MovieClip<'gc>) {
let mut write = self.0.write(context.gc_context);
// A `NetStream` cannot be attached to two `MovieClip`s at once.
@ -731,7 +731,7 @@ impl<'gc> NetStream<'gc> {
/// Determine if the given sound is currently playing.
fn sound_currently_playing(
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
sound: &Option<SoundInstanceHandle>,
) -> bool {
sound
@ -750,7 +750,7 @@ impl<'gc> NetStream<'gc> {
/// audio data has been streamed.
fn cleanup_sound_stream(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
write: &mut NetStreamData<'gc>,
) {
if !Self::sound_currently_playing(context, &write.sound_instance) {
@ -767,7 +767,7 @@ impl<'gc> NetStream<'gc> {
/// avoid audio underruns.
fn commit_sound_stream(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
write: &mut NetStreamData<'gc>,
) -> Result<(), NetstreamError> {
if !Self::sound_currently_playing(context, &write.sound_instance) {
@ -800,7 +800,7 @@ impl<'gc> NetStream<'gc> {
/// indicates that there is either not enough data in the buffer, or the
/// data is of an unrecognized format. This should be used as a signal to
/// stop stream processing until new data has been retrieved.
pub fn sniff_stream_type(self, context: &mut UpdateContext<'_, 'gc>) -> bool {
pub fn sniff_stream_type(self, context: &mut UpdateContext<'gc>) -> bool {
let mut write = self.0.write(context.gc_context);
let slice = write.buffer.to_full_slice();
let buffer = slice.data();
@ -872,7 +872,7 @@ impl<'gc> NetStream<'gc> {
/// encountered before.
fn flv_video_tag(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
write: &mut NetStreamData<'gc>,
slice: &Slice,
video_data: FlvVideoData<'_>,
@ -1055,7 +1055,7 @@ impl<'gc> NetStream<'gc> {
/// encountered before.
fn flv_script_tag(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
script_data: FlvScriptData<'_>,
tag_needs_preloading: bool,
) {
@ -1137,7 +1137,7 @@ impl<'gc> NetStream<'gc> {
/// Process stream data.
///
/// `dt` is in milliseconds.
pub fn tick(self, context: &mut UpdateContext<'_, 'gc>, dt: f64) {
pub fn tick(self, context: &mut UpdateContext<'gc>, dt: f64) {
let seek_offset = self.0.write(context.gc_context).queued_seek_time.take();
if let Some(offset) = seek_offset {
self.execute_seek(context, offset);
@ -1282,7 +1282,7 @@ impl<'gc> NetStream<'gc> {
/// Trigger a status event on the stream.
pub fn trigger_status_event(
self,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
values: Vec<(impl Into<AvmString<'gc>>, impl Into<AvmString<'gc>>)>,
) {
let object = self.0.read().avm_object;
@ -1291,7 +1291,7 @@ impl<'gc> NetStream<'gc> {
let root = context.stage.root_clip().expect("root");
let object_proto = context.avm1.prototypes().object;
let mut activation = Avm1Activation::from_nothing(
context.reborrow(),
context,
Avm1ActivationIdentifier::root("[NetStream Status Event]"),
root,
);
@ -1318,7 +1318,7 @@ impl<'gc> NetStream<'gc> {
}
Some(AvmObject::Avm2(object)) => {
let domain = context.avm2.stage_domain();
let mut activation = Avm2Activation::from_domain(context.reborrow(), domain);
let mut activation = Avm2Activation::from_domain(context, domain);
let net_status_event =
Avm2EventObject::net_status_event(&mut activation, "netStatus", values);
Avm2::dispatch_event(activation.context, net_status_event, object);
@ -1330,7 +1330,7 @@ impl<'gc> NetStream<'gc> {
fn handle_script_data(
self,
avm_object: Option<AvmObject<'gc>>,
context: &mut UpdateContext<'_, 'gc>,
context: &mut UpdateContext<'gc>,
variable_name: &[u8],
variable_data: FlvValue,
) -> Result<(), Avm2Error<'gc>> {
@ -1340,7 +1340,7 @@ impl<'gc> NetStream<'gc> {
let root = context.stage.root_clip().expect("root");
let mut activation = Avm1Activation::from_nothing(
context.reborrow(),
context,
Avm1ActivationIdentifier::root(format!("[FLV {}]", avm_string_name)),
root,
);
@ -1361,7 +1361,7 @@ impl<'gc> NetStream<'gc> {
}
}
Some(AvmObject::Avm2(_object)) => {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let mut activation = Avm2Activation::from_nothing(context);
let client_object = self
.client()
.expect("Client should be initialized if script data is being accessed");

View File

@ -30,7 +30,7 @@ pub struct Timers<'gc> {
impl<'gc> Timers<'gc> {
/// Ticks all timers and runs necessary callbacks.
pub fn update_timers(context: &mut UpdateContext<'_, 'gc>, dt: f64) -> Option<f64> {
pub fn update_timers(context: &mut UpdateContext<'gc>, dt: f64) -> Option<f64> {
context.timers.cur_time = context
.timers
.cur_time
@ -71,7 +71,7 @@ impl<'gc> Timers<'gc> {
TimerCallback::Avm1Function { func, params } => {
if let Some(level0) = level0 {
let mut avm1_activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[Timer Callback]"),
level0,
);
@ -116,7 +116,7 @@ impl<'gc> Timers<'gc> {
if !removed {
if let Some(level0) = level0 {
let mut avm1_activation = Activation::from_nothing(
context.reborrow(),
context,
ActivationIdentifier::root("[Timer Callback]"),
level0,
);
@ -141,8 +141,7 @@ impl<'gc> Timers<'gc> {
}
TimerCallback::Avm2Callback { closure, params } => {
let domain = context.avm2.stage_domain();
let mut avm2_activation =
Avm2Activation::from_domain(context.reborrow(), domain);
let mut avm2_activation = Avm2Activation::from_domain(context, domain);
match closure.call(Avm2Value::Null, &params, &mut avm2_activation) {
Ok(v) => v.coerce_to_boolean(),
Err(e) => {

View File

@ -11,7 +11,7 @@ pub struct DesktopExternalInterfaceProvider {
struct FakeLocationHrefToString(Url);
impl ExternalInterfaceMethod for FakeLocationHrefToString {
fn call(&self, _context: &mut UpdateContext<'_, '_>, _args: &[ExternalValue]) -> ExternalValue {
fn call(&self, _context: &mut UpdateContext<'_>, _args: &[ExternalValue]) -> ExternalValue {
ExternalValue::String(self.0.to_string())
}
}
@ -26,7 +26,7 @@ fn is_location_href(code: &str) -> bool {
struct FakeEval(Option<Url>);
impl ExternalInterfaceMethod for FakeEval {
fn call(&self, _context: &mut UpdateContext<'_, '_>, args: &[ExternalValue]) -> ExternalValue {
fn call(&self, _context: &mut UpdateContext<'_>, args: &[ExternalValue]) -> ExternalValue {
if let Some(ref url) = self.0 {
if let [ExternalValue::String(ref code)] = args {
if is_location_href(code) {

View File

@ -17,17 +17,17 @@ impl ExternalInterfaceTestProvider {
}
}
fn do_trace(context: &mut UpdateContext<'_, '_>, args: &[ExternalValue]) -> ExternalValue {
fn do_trace(context: &mut UpdateContext<'_>, args: &[ExternalValue]) -> ExternalValue {
context.avm_trace(&format!("[ExternalInterface] trace: {args:?}"));
"Traced!".into()
}
fn do_ping(context: &mut UpdateContext<'_, '_>, _args: &[ExternalValue]) -> ExternalValue {
fn do_ping(context: &mut UpdateContext<'_>, _args: &[ExternalValue]) -> ExternalValue {
context.avm_trace("[ExternalInterface] ping");
"Pong!".into()
}
fn do_reentry(context: &mut UpdateContext<'_, '_>, _args: &[ExternalValue]) -> ExternalValue {
fn do_reentry(context: &mut UpdateContext<'_>, _args: &[ExternalValue]) -> ExternalValue {
context.avm_trace("[ExternalInterface] starting reentry");
if let Some(callback) = context.external_interface.get_callback("callWith") {
callback.call(

View File

@ -26,12 +26,10 @@ pub struct JavascriptInterface {
struct JavascriptMethod(String);
impl ExternalInterfaceMethod for JavascriptMethod {
fn call(&self, context: &mut UpdateContext<'_, '_>, args: &[ExternalValue]) -> ExternalValue {
fn call(&self, context: &mut UpdateContext<'_>, args: &[ExternalValue]) -> ExternalValue {
let old_context = CURRENT_CONTEXT.with(|v| {
v.replace(Some(unsafe {
std::mem::transmute::<&mut UpdateContext, &mut UpdateContext<'static, 'static>>(
context,
)
std::mem::transmute::<&mut UpdateContext, &mut UpdateContext<'static>>(context)
} as *mut UpdateContext))
});
let args = args

View File

@ -56,7 +56,7 @@ thread_local! {
/// issues with lifetimes and type parameters (which cannot be exported with wasm-bindgen).
static INSTANCES: RefCell<SlotMap<RuffleHandle, RefCell<RuffleInstance>>> = RefCell::new(SlotMap::with_key());
static CURRENT_CONTEXT: RefCell<Option<*mut UpdateContext<'static, 'static>>> = const { RefCell::new(None) };
static CURRENT_CONTEXT: RefCell<Option<*mut UpdateContext<'static>>> = const { RefCell::new(None) };
}
type AnimationHandler = Closure<dyn FnMut(f64)>;