diff options
Diffstat (limited to 'components/script_bindings')
-rw-r--r-- | components/script_bindings/codegen/CodegenRust.py | 67 | ||||
-rw-r--r-- | components/script_bindings/interface.rs | 18 | ||||
-rw-r--r-- | components/script_bindings/record.rs | 10 | ||||
-rw-r--r-- | components/script_bindings/reflector.rs | 13 | ||||
-rw-r--r-- | components/script_bindings/webidls/StyleSheet.webidl | 2 | ||||
-rw-r--r-- | components/script_bindings/webidls/URLPattern.webidl | 40 |
6 files changed, 100 insertions, 50 deletions
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/interface.rs b/components/script_bindings/interface.rs index 08ee0a4f420..e185cfe9cfd 100644 --- a/components/script_bindings/interface.rs +++ b/components/script_bindings/interface.rs @@ -16,11 +16,11 @@ use js::jsapi::{ GetFunctionRealm, GetNonCCWObjectGlobal, GetRealmGlobalOrNull, GetWellKnownSymbol, HandleObject as RawHandleObject, IsSharableCompartment, IsSystemCompartment, JS_AtomizeAndPinString, JS_GetFunctionObject, JS_GetProperty, JS_IterateCompartments, - JS_NewFunction, JS_NewGlobalObject, JS_NewObject, JS_NewPlainObject, JS_NewStringCopyN, - JS_SetReservedSlot, JS_WrapObject, JSAutoRealm, JSClass, JSClassOps, JSContext, - JSFUN_CONSTRUCTOR, JSFunctionSpec, JSObject, JSPROP_PERMANENT, JSPROP_READONLY, - JSPROP_RESOLVING, JSPropertySpec, JSString, JSTracer, ObjectOps, OnNewGlobalHookOption, - SymbolCode, TrueHandleValue, Value, jsid, + JS_NewFunction, JS_NewGlobalObject, JS_NewObject, JS_NewStringCopyN, JS_SetReservedSlot, + JS_WrapObject, JSAutoRealm, JSClass, JSClassOps, JSContext, JSFUN_CONSTRUCTOR, JSFunctionSpec, + JSObject, JSPROP_ENUMERATE, JSPROP_PERMANENT, JSPROP_READONLY, JSPROP_RESOLVING, + JSPropertySpec, JSString, JSTracer, ObjectOps, OnNewGlobalHookOption, SymbolCode, + TrueHandleValue, Value, jsid, }; use js::jsval::{JSVal, NullValue, PrivateValue}; use js::rust::wrappers::{ @@ -473,7 +473,11 @@ fn create_unscopable_object(cx: SafeJSContext, names: &[&CStr], mut rval: Mutabl assert!(!names.is_empty()); assert!(rval.is_null()); unsafe { - rval.set(JS_NewPlainObject(*cx)); + rval.set(JS_NewObjectWithGivenProto( + *cx, + ptr::null(), + HandleObject::null(), + )); assert!(!rval.is_null()); for &name in names { assert!(JS_DefineProperty( @@ -481,7 +485,7 @@ fn create_unscopable_object(cx: SafeJSContext, names: &[&CStr], mut rval: Mutabl rval.handle(), name.as_ptr(), HandleValue::from_raw(TrueHandleValue), - JSPROP_READONLY as u32, + JSPROP_ENUMERATE as u32, )); } } diff --git a/components/script_bindings/record.rs b/components/script_bindings/record.rs index 2668a84f42c..d469faefaf2 100644 --- a/components/script_bindings/record.rs +++ b/components/script_bindings/record.rs @@ -7,7 +7,7 @@ use std::cmp::Eq; use std::hash::Hash; use std::marker::Sized; -use std::ops::Deref; +use std::ops::{Deref, DerefMut}; use indexmap::IndexMap; use js::conversions::{ConversionResult, FromJSValConvertible, ToJSValConvertible}; @@ -94,11 +94,17 @@ impl<K: RecordKey, V> Record<K, V> { impl<K: RecordKey, V> Deref for Record<K, V> { type Target = IndexMap<K, V>; - fn deref(&self) -> &IndexMap<K, V> { + fn deref(&self) -> &Self::Target { &self.map } } +impl<K: RecordKey, V> DerefMut for Record<K, V> { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.map + } +} + impl<K, V, C> FromJSValConvertible for Record<K, V> where K: RecordKey, 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; diff --git a/components/script_bindings/webidls/URLPattern.webidl b/components/script_bindings/webidls/URLPattern.webidl index f61b65702bc..a29cb650c23 100644 --- a/components/script_bindings/webidls/URLPattern.webidl +++ b/components/script_bindings/webidls/URLPattern.webidl @@ -6,14 +6,14 @@ typedef (USVString or URLPatternInit) URLPatternInput; -[Exposed=(Window,Worker), Pref="dom_urlpattern_enabled"] +[Exposed=(Window,Worker)] interface URLPattern { [Throws] constructor(URLPatternInput input, USVString baseURL, optional URLPatternOptions options = {}); [Throws] constructor(optional URLPatternInput input = {}, optional URLPatternOptions options = {}); - // [Throws] boolean test(optional URLPatternInput input = {}, optional USVString baseURL); + [Throws] boolean test(optional URLPatternInput input = {}, optional USVString baseURL); - // [Throws] URLPatternResult? exec(optional URLPatternInput input = {}, optional USVString baseURL); + [Throws] URLPatternResult? exec(optional URLPatternInput input = {}, optional USVString baseURL); readonly attribute USVString protocol; readonly attribute USVString username; @@ -43,20 +43,20 @@ dictionary URLPatternOptions { boolean ignoreCase = false; }; -// dictionary URLPatternResult { -// sequence<URLPatternInput> inputs; - -// URLPatternComponentResult protocol; -// URLPatternComponentResult username; -// URLPatternComponentResult password; -// URLPatternComponentResult hostname; -// URLPatternComponentResult port; -// URLPatternComponentResult pathname; -// URLPatternComponentResult search; -// URLPatternComponentResult hash; -// }; - -// dictionary URLPatternComponentResult { -// USVString input; -// record<USVString, (USVString or undefined)> groups; -// }; +dictionary URLPatternResult { + sequence<URLPatternInput> inputs; + + URLPatternComponentResult protocol; + URLPatternComponentResult username; + URLPatternComponentResult password; + URLPatternComponentResult hostname; + URLPatternComponentResult port; + URLPatternComponentResult pathname; + URLPatternComponentResult search; + URLPatternComponentResult hash; +}; + +dictionary URLPatternComponentResult { + USVString input; + record<USVString, (USVString or undefined)> groups; +}; |