mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
return Option from GlobalScope::current
handles the case where GlobalScope::current calls CurrentGlobalOrNull and the result is null
This commit is contained in:
parent
dfc44a0d35
commit
433cd90bc3
4 changed files with 10 additions and 6 deletions
|
@ -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>> {
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue