Skip to content

Commit 31c0e1c

Browse files
committed
core: Rename UpdateContext::swf to root_swf
The name "swf" was ambiguous, because in case of a child SWF file, it won't reference that file, but the root SWF, even if the update context is passed to objects from the child SWF.
1 parent 9511756 commit 31c0e1c

25 files changed

+54
-50
lines changed

core/src/avm1/globals/local_connection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'gc> LocalConnection<'gc> {
4949
}
5050

5151
let connection_handle = activation.context.local_connections.connect(
52-
&LocalConnections::get_domain(activation.context.swf.url()),
52+
&LocalConnections::get_domain(activation.context.root_swf.url()),
5353
this,
5454
&name,
5555
);
@@ -202,7 +202,7 @@ pub fn send<'gc>(
202202
}
203203

204204
activation.context.local_connections.send(
205-
&LocalConnections::get_domain(activation.context.swf.url()),
205+
&LocalConnections::get_domain(activation.context.root_swf.url()),
206206
this,
207207
*connection_name,
208208
*method_name,

core/src/avm1/globals/movie_clip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ fn get_bounds<'gc>(
14271427
if !activation.context.avm1.get_use_new_invalid_bounds_value() {
14281428
// The value is set to true if the activation SWF version is >= 8 or if the SWF
14291429
// version of the root movie is >= 8.
1430-
if activation.swf_version() >= 8 || activation.context.swf.version() >= 8 {
1430+
if activation.swf_version() >= 8 || activation.context.root_swf.version() >= 8 {
14311431
// If only the activation SWF version (and not the root movie SWF version)
14321432
// is >= 8 and the movie clip equals the target, the value sometimes isn't set
14331433
// in Flash Player 10.

core/src/avm2/activation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
562562
/// Like `caller_movie()`, but returns the root movie if `caller_movie`
563563
/// is `None`. This matches what FP does in most cases.
564564
pub fn caller_movie_or_root(&self) -> Arc<SwfMovie> {
565-
self.caller_movie().unwrap_or(self.context.swf.clone())
565+
self.caller_movie().unwrap_or(self.context.root_swf.clone())
566566
}
567567

568568
/// Returns the global scope of this activation.

core/src/avm2/e4x.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,7 @@ pub fn maybe_escape_child<'gc>(
17181718
child: Value<'gc>,
17191719
) -> Result<Value<'gc>, Error<'gc>> {
17201720
// NOTE: This depends on root SWF version, not caller movie version.
1721-
if activation.context.swf.version() <= 9 {
1721+
if activation.context.root_swf.version() <= 9 {
17221722
if child
17231723
.as_object()
17241724
.is_some_and(|x| x.as_xml_object().is_some() || x.as_xml_list_object().is_some())

core/src/avm2/globals/flash/display/bitmap_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub fn init<'gc>(
137137
let transparency = args.get_bool(2);
138138
let fill_color = args.get_u32(activation, 3)?;
139139

140-
if !is_size_valid(activation.context.swf.version(), width, height) {
140+
if !is_size_valid(activation.context.root_swf.version(), width, height) {
141141
return Err(Error::avm_error(argument_error(
142142
activation,
143143
"Error #2015: Invalid BitmapData.",

core/src/avm2/globals/flash/display/loader.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ pub fn loader_allocator<'gc>(
3030
) -> Result<Object<'gc>, Error<'gc>> {
3131
// Loader does not have an associated `Character` variant, and can never be
3232
// instantiated from the timeline.
33-
let display_object = LoaderDisplay::empty(activation, activation.context.swf.clone()).into();
33+
let display_object =
34+
LoaderDisplay::empty(activation, activation.context.root_swf.clone()).into();
3435
let loader = initialize_for_allocator(activation, display_object, class)?;
3536

3637
// Note that the initialization of `_contentLoaderInfo` is intentionally done here,
@@ -40,7 +41,7 @@ pub fn loader_allocator<'gc>(
4041
// Some LoaderInfo properties (such as 'bytesLoaded' and 'bytesTotal') are always
4142
// accessible, even before the 'init' event has fired. Using an empty movie gives
4243
// us the correct value (0) for them.
43-
let movie = &activation.context.swf;
44+
let movie = &activation.context.root_swf;
4445
let loader_info = LoaderInfoObject::not_yet_loaded(
4546
activation,
4647
Arc::new(SwfMovie::empty(movie.version(), Some(movie.url().into()))),
@@ -88,7 +89,7 @@ pub fn load<'gc>(
8889
loader_info.unload(activation);
8990

9091
// This is a dummy MovieClip, which will get overwritten in `Loader`
91-
let movie = &activation.context.swf;
92+
let movie = &activation.context.root_swf;
9293
let content = MovieClip::new(
9394
Arc::new(SwfMovie::empty(movie.version(), Some(movie.url().into()))),
9495
activation.gc(),
@@ -259,7 +260,7 @@ pub fn load_bytes<'gc>(
259260
loader_info.unload(activation);
260261

261262
// This is a dummy MovieClip, which will get overwritten in `Loader`
262-
let movie = &activation.context.swf;
263+
let movie = &activation.context.root_swf;
263264
let content = MovieClip::new(
264265
Arc::new(SwfMovie::empty(movie.version(), Some(movie.url().into()))),
265266
activation.gc(),

core/src/avm2/globals/flash/display/loader_info.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ pub fn get_child_allows_parent<'gc>(
296296
// Only the root movie is LoaderStream::Swf but missing a loader.
297297
// In that case, return true.
298298
assert!(
299-
Arc::ptr_eq(root, activation.context.swf) && dobj.as_movie_clip().is_some()
299+
Arc::ptr_eq(root, activation.context.root_swf)
300+
&& dobj.as_movie_clip().is_some()
300301
);
301302
Ok(true.into())
302303
}
@@ -337,7 +338,8 @@ pub fn get_parent_allows_child<'gc>(
337338
} else {
338339
// See comment on childAllowsParent
339340
assert!(
340-
Arc::ptr_eq(root, activation.context.swf) && dobj.as_movie_clip().is_some()
341+
Arc::ptr_eq(root, activation.context.root_swf)
342+
&& dobj.as_movie_clip().is_some()
341343
);
342344
Ok(true.into())
343345
}

core/src/avm2/globals/flash/display3D/context_3d.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn configure_back_buffer<'gc>(
9090
let anti_alias = args.get_u32(activation, 2)?;
9191
let enable_depth_and_stencil = args.get_bool(3);
9292

93-
let old_swf = activation.context.swf.version() < 30;
93+
let old_swf = activation.context.root_swf.version() < 30;
9494

9595
if old_swf && width == 0 && height == 0 && anti_alias == 0 && !enable_depth_and_stencil {
9696
return Ok(Value::Undefined);

core/src/avm2/globals/flash/net/local_connection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn get_domain<'gc>(
1515
_this: Value<'gc>,
1616
_args: &[Value<'gc>],
1717
) -> Result<Value<'gc>, Error<'gc>> {
18-
let movie = &activation.context.swf;
18+
let movie = &activation.context.root_swf;
1919
let domain = LocalConnections::get_domain(movie.url());
2020

2121
Ok(Value::String(AvmString::new_utf8(activation.gc(), domain)))
@@ -58,7 +58,7 @@ pub fn send<'gc>(
5858

5959
if let Some(local_connection) = this.as_local_connection_object() {
6060
activation.context.local_connections.send(
61-
&LocalConnections::get_domain(activation.context.swf.url()),
61+
&LocalConnections::get_domain(activation.context.root_swf.url()),
6262
(activation.domain(), local_connection),
6363
connection_name,
6464
method_name,

core/src/avm2/globals/flash/net/shared_object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn get_local<'gc>(
5353
return Ok(Value::Null);
5454
}
5555

56-
let mut movie_url = if let Ok(url) = url::Url::parse(activation.context.swf.url()) {
56+
let mut movie_url = if let Ok(url) = url::Url::parse(activation.context.root_swf.url()) {
5757
url
5858
} else {
5959
tracing::error!("SharedObject::get_local: Unable to parse movie URL");

0 commit comments

Comments
 (0)