-
-
Notifications
You must be signed in to change notification settings - Fork 811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: Clean up ExternalInterface a little #18223
base: master
Are you sure you want to change the base?
Conversation
… we never use more than 1
…stead of get-then-call
for arg in &args[1..] { | ||
external_args.push(ExternalValue::from_avm1(activation, arg.to_owned())?); | ||
} | ||
let mut external_args = Vec::with_capacity(external_args_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably write this using an iterator an map.
} else { | ||
Ok(Value::Null) | ||
let mut external_args = Vec::with_capacity(args.len() - 1); | ||
for arg in &args[1..] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
} | ||
|
||
pub fn available(&self) -> bool { | ||
!self.providers.is_empty() | ||
self.provider.is_some() | ||
} | ||
|
||
pub fn any_id(&self) -> Option<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could rename this to get_id
now.
fn is_location_href(code: &str) -> bool { | ||
matches!( | ||
code, | ||
"document.location.href" | "window.location.href" | "top.location.href" | ||
) | ||
} | ||
|
||
struct FakeEval(Option<Url>); | ||
|
||
impl ExternalInterfaceMethod for FakeEval { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup 🎉
Instead of getting a method then calling it, we just call things directly now. We also can now only have one Provider instead of many, but realistically there's no case in which multiple providers can peacefully coexist as they'll be conflicting with methods.