aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/customelementregistry.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2023-02-16 23:09:50 -0500
committerJosh Matthews <josh@joshmatthews.net>2023-05-20 11:05:09 -0400
commitf79e1e327dfdf047cab9652e1cc3e67a7667faa1 (patch)
tree43c1cf48c9a6448264722780e38315dafacf4a24 /components/script/dom/customelementregistry.rs
parent4998c65c423f995149f4b314d8ff68024c24cc72 (diff)
downloadservo-f79e1e327dfdf047cab9652e1cc3e67a7667faa1.tar.gz
servo-f79e1e327dfdf047cab9652e1cc3e67a7667faa1.zip
Make GlobalScope.get_cx a static method.
Diffstat (limited to 'components/script/dom/customelementregistry.rs')
-rw-r--r--components/script/dom/customelementregistry.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs
index dfba75a2028..ddbefaf6783 100644
--- a/components/script/dom/customelementregistry.rs
+++ b/components/script/dom/customelementregistry.rs
@@ -140,11 +140,10 @@ impl CustomElementRegistry {
constructor: HandleObject,
prototype: MutableHandleValue,
) -> ErrorResult {
- let global_scope = self.window.upcast::<GlobalScope>();
unsafe {
// Step 10.1
if !JS_GetProperty(
- *global_scope.get_cx(),
+ *GlobalScope::get_cx(),
constructor,
b"prototype\0".as_ptr() as *const _,
prototype,
@@ -166,7 +165,7 @@ impl CustomElementRegistry {
/// Steps 10.3, 10.4
#[allow(unsafe_code)]
unsafe fn get_callbacks(&self, prototype: HandleObject) -> Fallible<LifecycleCallbacks> {
- let cx = self.window.get_cx();
+ let cx = GlobalScope::get_cx();
// Step 4
Ok(LifecycleCallbacks {
@@ -181,7 +180,7 @@ impl CustomElementRegistry {
/// Step 10.6
#[allow(unsafe_code)]
fn get_observed_attributes(&self, constructor: HandleObject) -> Fallible<Vec<DOMString>> {
- let cx = self.window.get_cx();
+ let cx = GlobalScope::get_cx();
rooted!(in(*cx) let mut observed_attributes = UndefinedValue());
if unsafe {
!JS_GetProperty(
@@ -254,7 +253,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
constructor_: Rc<CustomElementConstructor>,
options: &ElementDefinitionOptions,
) -> ErrorResult {
- let cx = self.window.get_cx();
+ let cx = GlobalScope::get_cx();
rooted!(in(*cx) let constructor = constructor_.callback());
let name = LocalName::from(&*name);
@@ -437,7 +436,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
// Step 2
if let Some(definition) = self.definitions.borrow().get(&LocalName::from(&*name)) {
unsafe {
- let cx = global_scope.get_cx();
+ let cx = GlobalScope::get_cx();
rooted!(in(*cx) let mut constructor = UndefinedValue());
definition
.constructor
@@ -543,7 +542,7 @@ impl CustomElementDefinition {
prefix: Option<Prefix>,
) -> Fallible<DomRoot<Element>> {
let window = document.window();
- let cx = window.get_cx();
+ let cx = GlobalScope::get_cx();
// Step 2
rooted!(in(*cx) let constructor = ObjectValue(self.constructor.callback()));
rooted!(in(*cx) let mut element = ptr::null_mut::<JSObject>());
@@ -662,7 +661,7 @@ pub fn upgrade_element(definition: Rc<CustomElementDefinition>, element: &Elemen
// Step 8.exception.3
let global = GlobalScope::current().expect("No current global");
- let cx = global.get_cx();
+ let cx = GlobalScope::get_cx();
unsafe {
let ar = enter_realm(&*global);
throw_dom_exception(cx, &global, error);
@@ -686,7 +685,7 @@ fn run_upgrade_constructor(
element: &Element,
) -> ErrorResult {
let window = window_from_node(element);
- let cx = window.get_cx();
+ let cx = GlobalScope::get_cx();
rooted!(in(*cx) let constructor_val = ObjectValue(constructor.callback()));
rooted!(in(*cx) let mut element_val = UndefinedValue());
unsafe {
@@ -909,7 +908,7 @@ impl CustomElementReactionStack {
return;
}
- let cx = element.global().get_cx();
+ let cx = GlobalScope::get_cx();
// We might be here during HTML parsing, rather than
// during Javscript execution, and so we typically aren't
// already in a realm here.