diff options
Diffstat (limited to 'components')
-rw-r--r-- | components/script/dom/bindings/reflector.rs | 14 | ||||
-rw-r--r-- | components/script/dom/stylesheet.rs | 4 | ||||
-rw-r--r-- | components/script_bindings/codegen/CodegenRust.py | 67 | ||||
-rw-r--r-- | components/script_bindings/reflector.rs | 13 | ||||
-rw-r--r-- | components/script_bindings/webidls/StyleSheet.webidl | 2 |
5 files changed, 75 insertions, 25 deletions
diff --git a/components/script/dom/bindings/reflector.rs b/components/script/dom/bindings/reflector.rs index 0a5afbce487..c888686974e 100644 --- a/components/script/dom/bindings/reflector.rs +++ b/components/script/dom/bindings/reflector.rs @@ -11,7 +11,7 @@ use crate::DomTypes; use crate::dom::bindings::conversions::DerivedFrom; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; -use crate::realms::InRealm; +use crate::realms::{InRealm, enter_realm}; use crate::script_runtime::CanGc; /// Create the reflector for a new DOM object and yield ownership to the @@ -42,7 +42,16 @@ where } pub(crate) trait DomGlobal { + /// Returns the [relevant global] in whatever realm is currently active. + /// + /// [relevant global]: https://html.spec.whatwg.org/multipage/#concept-relevant-global fn global_(&self, realm: InRealm) -> DomRoot<GlobalScope>; + + /// Returns the [relevant global] in the same realm as the callee object. + /// If you know the callee's realm is already the current realm, it is + /// more efficient to call [DomGlobal::global_] instead. + /// + /// [relevant global]: https://html.spec.whatwg.org/multipage/#concept-relevant-global fn global(&self) -> DomRoot<GlobalScope>; } @@ -51,7 +60,8 @@ impl<T: DomGlobalGeneric<crate::DomTypeHolder>> DomGlobal for T { <Self as DomGlobalGeneric<crate::DomTypeHolder>>::global_(self, realm) } fn global(&self) -> DomRoot<GlobalScope> { - <Self as DomGlobalGeneric<crate::DomTypeHolder>>::global(self) + let realm = enter_realm(self); + <Self as DomGlobalGeneric<crate::DomTypeHolder>>::global_(self, InRealm::entered(&realm)) } } diff --git a/components/script/dom/stylesheet.rs b/components/script/dom/stylesheet.rs index bf708685426..8bb6faa0c90 100644 --- a/components/script/dom/stylesheet.rs +++ b/components/script/dom/stylesheet.rs @@ -39,8 +39,8 @@ impl StyleSheet { } impl StyleSheetMethods<crate::DomTypeHolder> for StyleSheet { - // https://drafts.csswg.org/cssom/#dom-stylesheet-type - fn Type_(&self) -> DOMString { + /// <https://drafts.csswg.org/cssom/#dom-stylesheet-type> + fn Type(&self) -> DOMString { self.type_.clone() } diff --git a/components/script_bindings/codegen/CodegenRust.py b/components/script_bindings/codegen/CodegenRust.py index 37d62ff2e1b..c9dba552bd7 100644 --- a/components/script_bindings/codegen/CodegenRust.py +++ b/components/script_bindings/codegen/CodegenRust.py @@ -62,12 +62,64 @@ TRACE_HOOK_NAME = '_trace' CONSTRUCT_HOOK_NAME = '_constructor' HASINSTANCE_HOOK_NAME = '_hasInstance' -RUST_KEYWORDS = {"abstract", "alignof", "as", "become", "box", "break", "const", "continue", - "else", "enum", "extern", "false", "final", "fn", "for", "if", "impl", "in", - "let", "loop", "macro", "match", "mod", "move", "mut", "offsetof", "override", - "priv", "proc", "pub", "pure", "ref", "return", "static", "self", "sizeof", - "struct", "super", "true", "trait", "type", "typeof", "unsafe", "unsized", - "use", "virtual", "where", "while", "yield"} +RUST_KEYWORDS = { + "abstract", + "alignof", + "as", + "async", + "await", + "become", + "box", + "break", + "const", + "continue", + "crate", + "do", + "dyn", + "else", + "enum", + "extern", + "false", + "final", + "fn", + "for", + "gen", + "if", + "impl", + "in", + "let", + "loop", + "macro", + "match", + "mod", + "move", + "mut", + "offsetof", + "override", + "priv", + "proc", + "pub", + "pure", + "ref", + "return", + "static", + "self", + "sizeof", + "struct", + "super", + "true", + "trait", + "try", + "type", + "typeof", + "unsafe", + "unsized", + "use", + "virtual", + "where", + "while", + "yield", +} def genericsForType(t): @@ -6709,10 +6761,9 @@ class CGInterfaceTrait(CGThing): yield name, arguments, rettype, False def fmt(arguments, leadingComma=True): - keywords = {"async"} prefix = "" if not leadingComma else ", " return prefix + ", ".join( - f"{name if name not in keywords else f'r#{name}'}: {type_}" + f"r#{name}: {type_}" for name, type_ in arguments ) diff --git a/components/script_bindings/reflector.rs b/components/script_bindings/reflector.rs index 6b6ae03cb69..4b91b0536fc 100644 --- a/components/script_bindings/reflector.rs +++ b/components/script_bindings/reflector.rs @@ -8,7 +8,7 @@ use malloc_size_of_derive::MallocSizeOf; use crate::interfaces::GlobalScopeHelpers; use crate::iterable::{Iterable, IterableIterator}; -use crate::realms::{AlreadyInRealm, InRealm}; +use crate::realms::InRealm; use crate::root::{Dom, DomRoot, Root}; use crate::script_runtime::{CanGc, JSContext}; use crate::{DomTypes, JSTraceable}; @@ -108,17 +108,6 @@ pub trait DomGlobalGeneric<D: DomTypes>: DomObject { { D::GlobalScope::from_reflector(self, realm) } - - /// Returns the [`GlobalScope`] of the realm that the [`DomObject`] was created in. If this - /// object is a `Node`, this will be different from it's owning `Document` if adopted by. For - /// `Node`s it's almost always better to use `NodeTraits::owning_global`. - fn global(&self) -> DomRoot<D::GlobalScope> - where - Self: Sized, - { - let realm = AlreadyInRealm::assert_for_cx(D::GlobalScope::get_cx()); - D::GlobalScope::from_reflector(self, InRealm::already(&realm)) - } } impl<D: DomTypes, T: DomObject> DomGlobalGeneric<D> for T {} diff --git a/components/script_bindings/webidls/StyleSheet.webidl b/components/script_bindings/webidls/StyleSheet.webidl index cb8290cc30b..7e0636cf7c0 100644 --- a/components/script_bindings/webidls/StyleSheet.webidl +++ b/components/script_bindings/webidls/StyleSheet.webidl @@ -5,7 +5,7 @@ // https://drafts.csswg.org/cssom/#the-stylesheet-interface [Exposed=Window] interface StyleSheet { - readonly attribute DOMString type_; + readonly attribute DOMString type; readonly attribute DOMString? href; readonly attribute Element? ownerNode; |