Skip to content
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

return Option from GlobalScope::current #17472

Merged
merged 1 commit into from Jun 23, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -543,12 +543,16 @@ impl GlobalScope {
///
/// ["current"]: https://html.spec.whatwg.org/multipage/#current
#[allow(unsafe_code)]
pub fn current() -> Root<Self> {
pub fn current() -> Option<Root<Self>> {

This comment has been minimized.

unsafe {
let cx = Runtime::get();
assert!(!cx.is_null());
let global = CurrentGlobalOrNull(cx);
global_scope_from_global(global)
if global.is_null() {
None
} else {
Some(global_scope_from_global(global))
}
}
}

@@ -590,7 +590,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
Some(document) => document,
};
// Step 4.
let current = GlobalScope::current().as_window().Document();
let current = GlobalScope::current().expect("No current global object").as_window().Document();
if !current.origin().same_origin_domain(document.origin()) {
return None;
}
@@ -241,7 +241,7 @@ impl PermissionAlgorithm for Permissions {
let state =
prompt_user(&format!("{} {} ?", REQUEST_DIALOG_MESSAGE, perm_name.clone()));

let globalscope = GlobalScope::current();
let globalscope = GlobalScope::current().expect("No current global object");
globalscope.as_window()
.permission_state_invocation_results()
.borrow_mut()
@@ -266,7 +266,7 @@ pub fn get_descriptor_permission_state(permission_name: PermissionName,
// Step 1.
let settings = match env_settings_obj {
Some(env_settings_obj) => Root::from_ref(env_settings_obj),
None => GlobalScope::current(),
None => GlobalScope::current().expect("No current global object"),
};

// Step 2.
@@ -586,7 +586,7 @@ impl WindowMethods for Window {
};
// Step 6.
let container_doc = document_from_node(container);
let current_doc = GlobalScope::current().as_window().Document();
let current_doc = GlobalScope::current().expect("No current global object").as_window().Document();
if !current_doc.origin().same_origin_domain(container_doc.origin()) {
return None;
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.