avm2: Allow access to stage properties without a valid root movie clip.
This commit is contained in:
parent
df25d1ca8b
commit
57acf47a10
|
@ -8,7 +8,7 @@ use crate::avm2::names::{Namespace, QName};
|
|||
use crate::avm2::object::{loaderinfo_allocator, DomainObject, LoaderStream, Object, TObject};
|
||||
use crate::avm2::value::Value;
|
||||
use crate::avm2::{AvmString, Error};
|
||||
use crate::display_object::{TDisplayObject, TDisplayObjectContainer};
|
||||
use crate::display_object::TDisplayObject;
|
||||
use gc_arena::{GcCell, MutationContext};
|
||||
use swf::{write_swf, Compression};
|
||||
|
||||
|
@ -243,20 +243,14 @@ pub fn url<'gc>(
|
|||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this.as_loader_stream() {
|
||||
let root = match &*loader_stream {
|
||||
LoaderStream::Stage => activation
|
||||
.context
|
||||
.stage
|
||||
.child_by_index(0)
|
||||
.and_then(|c| c.movie()),
|
||||
LoaderStream::Swf(root, _) => Some(root.clone()),
|
||||
LoaderStream::Stage => activation.context.swf,
|
||||
LoaderStream::Swf(root, _) => root,
|
||||
};
|
||||
|
||||
if let Some(root) = root {
|
||||
let url = root.url().unwrap_or("");
|
||||
return Ok(AvmString::new_utf8(activation.context.gc_context, url).into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
@ -292,15 +286,10 @@ pub fn bytes<'gc>(
|
|||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this.as_loader_stream() {
|
||||
let root = match &*loader_stream {
|
||||
LoaderStream::Stage => activation
|
||||
.context
|
||||
.stage
|
||||
.child_by_index(0)
|
||||
.and_then(|c| c.movie()),
|
||||
LoaderStream::Swf(root, _) => Some(root.clone()),
|
||||
LoaderStream::Stage => activation.context.swf,
|
||||
LoaderStream::Swf(root, _) => root,
|
||||
};
|
||||
|
||||
if let Some(root) = root {
|
||||
let ba_class = activation.context.avm2.classes().bytearray;
|
||||
|
||||
let ba = ba_class.construct(activation, &[])?;
|
||||
|
@ -334,7 +323,6 @@ pub fn bytes<'gc>(
|
|||
return Ok(ba.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
@ -373,15 +361,10 @@ pub fn parameters<'gc>(
|
|||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this.as_loader_stream() {
|
||||
let root = match &*loader_stream {
|
||||
LoaderStream::Stage => activation
|
||||
.context
|
||||
.stage
|
||||
.child_by_index(0)
|
||||
.and_then(|c| c.movie()),
|
||||
LoaderStream::Swf(root, _) => Some(root.clone()),
|
||||
LoaderStream::Stage => activation.context.swf,
|
||||
LoaderStream::Swf(root, _) => root,
|
||||
};
|
||||
|
||||
if let Some(root) = root {
|
||||
let mut params_obj = activation
|
||||
.avm2()
|
||||
.classes()
|
||||
|
@ -402,7 +385,6 @@ pub fn parameters<'gc>(
|
|||
return Ok(params_obj.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue