mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Rename Root<T> to DomRoot<T>
In a later PR, DomRoot<T> will become a type alias of Root<Dom<T>>, where Root<T> will be able to handle all the things that need to be rooted that have a stable traceable address that doesn't move for the whole lifetime of the root. Stay tuned.
This commit is contained in:
parent
577370746e
commit
f87c2a8d76
291 changed files with 1774 additions and 1770 deletions
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
|
use dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::reflector::DomObject;
|
use dom::bindings::reflector::DomObject;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::USVString;
|
use dom::bindings::str::USVString;
|
||||||
use dom::blob::{Blob, BlobImpl};
|
use dom::blob::{Blob, BlobImpl};
|
||||||
use dom::formdata::FormData;
|
use dom::formdata::FormData;
|
||||||
|
@ -33,8 +33,8 @@ pub enum BodyType {
|
||||||
pub enum FetchedData {
|
pub enum FetchedData {
|
||||||
Text(String),
|
Text(String),
|
||||||
Json(JSValue),
|
Json(JSValue),
|
||||||
BlobData(Root<Blob>),
|
BlobData(DomRoot<Blob>),
|
||||||
FormData(Root<FormData>),
|
FormData(DomRoot<FormData>),
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#concept-body-consume-body
|
// https://fetch.spec.whatwg.org/#concept-body-consume-body
|
||||||
|
|
|
@ -14,7 +14,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, jsstring_to_str};
|
use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, jsstring_to_str};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::DomObject;
|
use dom::bindings::reflector::DomObject;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::document::AnimationFrameCallback;
|
use dom::document::AnimationFrameCallback;
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
|
@ -90,7 +90,7 @@ pub fn handle_get_document_element(documents: &Documents,
|
||||||
fn find_node_by_unique_id(documents: &Documents,
|
fn find_node_by_unique_id(documents: &Documents,
|
||||||
pipeline: PipelineId,
|
pipeline: PipelineId,
|
||||||
node_id: &str)
|
node_id: &str)
|
||||||
-> Option<Root<Node>> {
|
-> Option<DomRoot<Node>> {
|
||||||
documents.find_document(pipeline).and_then(|document|
|
documents.find_document(pipeline).and_then(|document|
|
||||||
document.upcast::<Node>().traverse_preorder().find(|candidate| candidate.unique_id() == node_id)
|
document.upcast::<Node>().traverse_preorder().find(|candidate| candidate.unique_id() == node_id)
|
||||||
)
|
)
|
||||||
|
|
|
@ -222,22 +222,22 @@ objects.
|
||||||
[gc-root]: https://en.wikipedia.org/wiki/Tracing_garbage_collection#Reachability_of_an_object
|
[gc-root]: https://en.wikipedia.org/wiki/Tracing_garbage_collection#Reachability_of_an_object
|
||||||
|
|
||||||
Another common situation is creating a stack-local root manually. For this
|
Another common situation is creating a stack-local root manually. For this
|
||||||
purpose, we have a [`Root<T>`][root] struct. When the `Root<T>` is destroyed,
|
purpose, we have a [`DomRoot<T>`][root] struct. When the `DomRoot<T>` is destroyed,
|
||||||
typically at the end of the function (or block) where it was created, its
|
typically at the end of the function (or block) where it was created, its
|
||||||
destructor will un-root the DOM object. This is an example of the
|
destructor will un-root the DOM object. This is an example of the
|
||||||
[RAII idiom][raii], which Rust inherits from C++.
|
[RAII idiom][raii], which Rust inherits from C++.
|
||||||
`Root<T>` structs are primarily returned from [`T::new` functions][new] when
|
`DomRoot<T>` structs are primarily returned from [`T::new` functions][new] when
|
||||||
creating a new DOM object.
|
creating a new DOM object.
|
||||||
In some cases, we need to use a DOM object longer than the reference we
|
In some cases, we need to use a DOM object longer than the reference we
|
||||||
received allows us to; the [`Root::from_ref` associated function][from-ref]
|
received allows us to; the [`DomRoot::from_ref` associated function][from-ref]
|
||||||
allows creating a new `Root<T>` struct in that case.
|
allows creating a new `DomRoot<T>` struct in that case.
|
||||||
|
|
||||||
[root]: http://doc.servo.org/script/dom/bindings/root/struct.Root.html
|
[root]: http://doc.servo.org/script/dom/bindings/root/struct.DomRoot.html
|
||||||
[raii]: https://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
|
[raii]: https://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
|
||||||
[new]: http://doc.servo.org/script/dom/index.html#construction
|
[new]: http://doc.servo.org/script/dom/index.html#construction
|
||||||
[from-ref]: http://doc.servo.org/script/dom/bindings/root/struct.Root.html#method.from_ref
|
[from-ref]: http://doc.servo.org/script/dom/bindings/root/struct.DomRoot.html#method.from_ref
|
||||||
|
|
||||||
We can then obtain a reference from the `Root<T>` through Rust's built-in
|
We can then obtain a reference from the `DomRoot<T>` through Rust's built-in
|
||||||
[`Deref` trait][deref], which exposes a method `deref` with the following
|
[`Deref` trait][deref], which exposes a method `deref` with the following
|
||||||
signature:
|
signature:
|
||||||
|
|
||||||
|
@ -249,11 +249,11 @@ pub fn deref<'a>(&'a self) -> &'a T {
|
||||||
What this syntax means is:
|
What this syntax means is:
|
||||||
|
|
||||||
- **`<'a>`**: 'for any lifetime `'a`',
|
- **`<'a>`**: 'for any lifetime `'a`',
|
||||||
- **`(&'a self)`**: 'take a reference to a `Root` which is valid over lifetime `'a`',
|
- **`(&'a self)`**: 'take a reference to a `DomRoot` which is valid over lifetime `'a`',
|
||||||
- **`-> &'a T`**: 'return a reference whose lifetime is limited to `'a`'.
|
- **`-> &'a T`**: 'return a reference whose lifetime is limited to `'a`'.
|
||||||
|
|
||||||
This allows us to call methods and access fields of the underlying type `T`
|
This allows us to call methods and access fields of the underlying type `T`
|
||||||
through a `Root<T>`.
|
through a `DomRoot<T>`.
|
||||||
|
|
||||||
[deref]: https://doc.rust-lang.org/std/ops/trait.Deref.html
|
[deref]: https://doc.rust-lang.org/std/ops/trait.Deref.html
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ To recapitulate, the safety of our system depends on two major parts:
|
||||||
|
|
||||||
- The auto-generated `trace` methods ensure that SpiderMonkey's garbage
|
- The auto-generated `trace` methods ensure that SpiderMonkey's garbage
|
||||||
collector can see all of the references between DOM objects.
|
collector can see all of the references between DOM objects.
|
||||||
- The implementation of `Root<T>` guarantees that we can't use a DOM object
|
- The implementation of `DomRoot<T>` guarantees that we can't use a DOM object
|
||||||
from Rust without telling SpiderMonkey about our temporary reference.
|
from Rust without telling SpiderMonkey about our temporary reference.
|
||||||
|
|
||||||
But there's a hole in this scheme. We could copy an unrooted pointer — a
|
But there's a hole in this scheme. We could copy an unrooted pointer — a
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::cell::DomRefCell;
|
||||||
use dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods};
|
use dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{LayoutDom, MutNullableDom, Root, RootedReference};
|
use dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom, RootedReference};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::customelementregistry::CallbackReaction;
|
use dom::customelementregistry::CallbackReaction;
|
||||||
use dom::element::{AttributeMutation, Element};
|
use dom::element::{AttributeMutation, Element};
|
||||||
|
@ -63,7 +63,7 @@ impl Attr {
|
||||||
namespace: Namespace,
|
namespace: Namespace,
|
||||||
prefix: Option<Prefix>,
|
prefix: Option<Prefix>,
|
||||||
owner: Option<&Element>)
|
owner: Option<&Element>)
|
||||||
-> Root<Attr> {
|
-> DomRoot<Attr> {
|
||||||
reflect_dom_object(box Attr::new_inherited(local_name,
|
reflect_dom_object(box Attr::new_inherited(local_name,
|
||||||
value,
|
value,
|
||||||
name,
|
name,
|
||||||
|
@ -161,7 +161,7 @@ impl AttrMethods for Attr {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-attr-ownerelement
|
// https://dom.spec.whatwg.org/#dom-attr-ownerelement
|
||||||
fn GetOwnerElement(&self) -> Option<Root<Element>> {
|
fn GetOwnerElement(&self) -> Option<DomRoot<Element>> {
|
||||||
self.owner()
|
self.owner()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ impl Attr {
|
||||||
self.owner.set(owner);
|
self.owner.set(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn owner(&self) -> Option<Root<Element>> {
|
pub fn owner(&self) -> Option<DomRoot<Element>> {
|
||||||
self.owner.get()
|
self.owner.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEven
|
||||||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
@ -32,7 +32,7 @@ impl BeforeUnloadEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(window: &Window) -> Root<BeforeUnloadEvent> {
|
pub fn new_uninitialized(window: &Window) -> DomRoot<BeforeUnloadEvent> {
|
||||||
reflect_dom_object(box BeforeUnloadEvent::new_inherited(),
|
reflect_dom_object(box BeforeUnloadEvent::new_inherited(),
|
||||||
window,
|
window,
|
||||||
BeforeUnloadEventBinding::Wrap)
|
BeforeUnloadEventBinding::Wrap)
|
||||||
|
@ -41,7 +41,7 @@ impl BeforeUnloadEvent {
|
||||||
pub fn new(window: &Window,
|
pub fn new(window: &Window,
|
||||||
type_: Atom,
|
type_: Atom,
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable) -> Root<BeforeUnloadEvent> {
|
cancelable: EventCancelable) -> DomRoot<BeforeUnloadEvent> {
|
||||||
let ev = BeforeUnloadEvent::new_uninitialized(window);
|
let ev = BeforeUnloadEvent::new_uninitialized(window);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
use dom::bindings::error::{Error, Fallible, report_pending_exception};
|
use dom::bindings::error::{Error, Fallible, report_pending_exception};
|
||||||
use dom::bindings::reflector::DomObject;
|
use dom::bindings::reflector::DomObject;
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::settings_stack::{AutoEntryScript, AutoIncumbentScript};
|
use dom::bindings::settings_stack::{AutoEntryScript, AutoIncumbentScript};
|
||||||
use dom::bindings::utils::AsCCharPtrPtr;
|
use dom::bindings::utils::AsCCharPtrPtr;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
|
@ -223,7 +223,7 @@ pub fn wrap_call_this_object<T: DomObject>(cx: *mut JSContext,
|
||||||
pub struct CallSetup {
|
pub struct CallSetup {
|
||||||
/// The global for reporting exceptions. This is the global object of the
|
/// The global for reporting exceptions. This is the global object of the
|
||||||
/// (possibly wrapped) callback object.
|
/// (possibly wrapped) callback object.
|
||||||
exception_global: Root<GlobalScope>,
|
exception_global: DomRoot<GlobalScope>,
|
||||||
/// The `JSContext` used for the call.
|
/// The `JSContext` used for the call.
|
||||||
cx: *mut JSContext,
|
cx: *mut JSContext,
|
||||||
/// The compartment we were in before the call.
|
/// The compartment we were in before the call.
|
||||||
|
|
|
@ -2254,7 +2254,7 @@ def UnionTypes(descriptors, dictionaries, callbacks, typedefs, config):
|
||||||
'dom::bindings::conversions::root_from_handlevalue',
|
'dom::bindings::conversions::root_from_handlevalue',
|
||||||
'dom::bindings::error::throw_not_in_union',
|
'dom::bindings::error::throw_not_in_union',
|
||||||
'dom::bindings::mozmap::MozMap',
|
'dom::bindings::mozmap::MozMap',
|
||||||
'dom::bindings::root::Root',
|
'dom::bindings::root::DomRoot',
|
||||||
'dom::bindings::str::ByteString',
|
'dom::bindings::str::ByteString',
|
||||||
'dom::bindings::str::DOMString',
|
'dom::bindings::str::DOMString',
|
||||||
'dom::bindings::str::USVString',
|
'dom::bindings::str::USVString',
|
||||||
|
@ -2558,7 +2558,7 @@ class CGWrapMethod(CGAbstractMethod):
|
||||||
args = [Argument('*mut JSContext', 'cx'),
|
args = [Argument('*mut JSContext', 'cx'),
|
||||||
Argument('&GlobalScope', 'scope'),
|
Argument('&GlobalScope', 'scope'),
|
||||||
Argument("Box<%s>" % descriptor.concreteType, 'object')]
|
Argument("Box<%s>" % descriptor.concreteType, 'object')]
|
||||||
retval = 'Root<%s>' % descriptor.concreteType
|
retval = 'DomRoot<%s>' % descriptor.concreteType
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
||||||
pub=True, unsafe=True)
|
pub=True, unsafe=True)
|
||||||
|
|
||||||
|
@ -2580,7 +2580,7 @@ assert!(!proto.is_null());
|
||||||
%(copyUnforgeable)s
|
%(copyUnforgeable)s
|
||||||
(*raw).init_reflector(obj.get());
|
(*raw).init_reflector(obj.get());
|
||||||
|
|
||||||
Root::from_ref(&*raw)""" % {'copyUnforgeable': unforgeable, 'createObject': create})
|
DomRoot::from_ref(&*raw)""" % {'copyUnforgeable': unforgeable, 'createObject': create})
|
||||||
|
|
||||||
|
|
||||||
class CGWrapGlobalMethod(CGAbstractMethod):
|
class CGWrapGlobalMethod(CGAbstractMethod):
|
||||||
|
@ -2592,7 +2592,7 @@ class CGWrapGlobalMethod(CGAbstractMethod):
|
||||||
assert descriptor.isGlobal()
|
assert descriptor.isGlobal()
|
||||||
args = [Argument('*mut JSContext', 'cx'),
|
args = [Argument('*mut JSContext', 'cx'),
|
||||||
Argument("Box<%s>" % descriptor.concreteType, 'object')]
|
Argument("Box<%s>" % descriptor.concreteType, 'object')]
|
||||||
retval = 'Root<%s>' % descriptor.concreteType
|
retval = 'DomRoot<%s>' % descriptor.concreteType
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
||||||
pub=True, unsafe=True)
|
pub=True, unsafe=True)
|
||||||
self.properties = properties
|
self.properties = properties
|
||||||
|
@ -2638,7 +2638,7 @@ assert!(immutable);
|
||||||
|
|
||||||
%(unforgeable)s
|
%(unforgeable)s
|
||||||
|
|
||||||
Root::from_ref(&*raw)\
|
DomRoot::from_ref(&*raw)\
|
||||||
""" % values)
|
""" % values)
|
||||||
|
|
||||||
|
|
||||||
|
@ -3421,7 +3421,9 @@ class CGAbstractStaticBindingMethod(CGAbstractMethod):
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
preamble = "let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());\n"
|
preamble = "let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());\n"
|
||||||
if len(self.exposureSet) == 1:
|
if len(self.exposureSet) == 1:
|
||||||
preamble += "let global = Root::downcast::<dom::types::%s>(global).unwrap();\n" % list(self.exposureSet)[0]
|
preamble += """
|
||||||
|
let global = DomRoot::downcast::<dom::types::%s>(global).unwrap();
|
||||||
|
""" % list(self.exposureSet)[0]
|
||||||
return CGList([CGGeneric(preamble), self.generate_code()])
|
return CGList([CGGeneric(preamble), self.generate_code()])
|
||||||
|
|
||||||
def generate_code(self):
|
def generate_code(self):
|
||||||
|
@ -5352,7 +5354,9 @@ class CGClassConstructHook(CGAbstractExternMethod):
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
preamble = """let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());\n"""
|
preamble = """let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());\n"""
|
||||||
if len(self.exposureSet) == 1:
|
if len(self.exposureSet) == 1:
|
||||||
preamble += "let global = Root::downcast::<dom::types::%s>(global).unwrap();\n" % list(self.exposureSet)[0]
|
preamble += """\
|
||||||
|
let global = DomRoot::downcast::<dom::types::%s>(global).unwrap();
|
||||||
|
""" % list(self.exposureSet)[0]
|
||||||
preamble += """let args = CallArgs::from_vp(vp, argc);\n"""
|
preamble += """let args = CallArgs::from_vp(vp, argc);\n"""
|
||||||
preamble = CGGeneric(preamble)
|
preamble = CGGeneric(preamble)
|
||||||
if self.constructor.isHTMLConstructor():
|
if self.constructor.isHTMLConstructor():
|
||||||
|
@ -5408,7 +5412,7 @@ if !JS_WrapObject(cx, prototype.handle_mut()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let result: Result<Root<%s>, Error> = html_constructor(&global, &args);
|
let result: Result<DomRoot<%s>, Error> = html_constructor(&global, &args);
|
||||||
let result = match result {
|
let result = match result {
|
||||||
Ok(result) => result,
|
Ok(result) => result,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -5713,8 +5717,8 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
||||||
'dom::bindings::reflector::MutDomObject',
|
'dom::bindings::reflector::MutDomObject',
|
||||||
'dom::bindings::reflector::DomObject',
|
'dom::bindings::reflector::DomObject',
|
||||||
'dom::bindings::root::Dom',
|
'dom::bindings::root::Dom',
|
||||||
|
'dom::bindings::root::DomRoot',
|
||||||
'dom::bindings::root::OptionalHeapSetter',
|
'dom::bindings::root::OptionalHeapSetter',
|
||||||
'dom::bindings::root::Root',
|
|
||||||
'dom::bindings::root::RootedReference',
|
'dom::bindings::root::RootedReference',
|
||||||
'dom::bindings::utils::AsVoidPtr',
|
'dom::bindings::utils::AsVoidPtr',
|
||||||
'dom::bindings::utils::DOMClass',
|
'dom::bindings::utils::DOMClass',
|
||||||
|
@ -6281,7 +6285,7 @@ class CGRegisterProxyHandlers(CGThing):
|
||||||
|
|
||||||
class CGBindingRoot(CGThing):
|
class CGBindingRoot(CGThing):
|
||||||
"""
|
"""
|
||||||
Root codegen class for binding generation. Instantiate the class, and call
|
DomRoot codegen class for binding generation. Instantiate the class, and call
|
||||||
declare or define to generate header or cpp code (respectively).
|
declare or define to generate header or cpp code (respectively).
|
||||||
"""
|
"""
|
||||||
def __init__(self, config, prefix, webIDLFile):
|
def __init__(self, config, prefix, webIDLFile):
|
||||||
|
@ -7195,7 +7199,7 @@ class GlobalGenRoots():
|
||||||
imports = [CGGeneric("use dom::types::*;\n"),
|
imports = [CGGeneric("use dom::types::*;\n"),
|
||||||
CGGeneric("use dom::bindings::conversions::{DerivedFrom, get_dom_class};\n"),
|
CGGeneric("use dom::bindings::conversions::{DerivedFrom, get_dom_class};\n"),
|
||||||
CGGeneric("use dom::bindings::inheritance::Castable;\n"),
|
CGGeneric("use dom::bindings::inheritance::Castable;\n"),
|
||||||
CGGeneric("use dom::bindings::root::{Dom, LayoutDom, Root};\n"),
|
CGGeneric("use dom::bindings::root::{Dom, DomRoot, LayoutDom};\n"),
|
||||||
CGGeneric("use dom::bindings::trace::JSTraceable;\n"),
|
CGGeneric("use dom::bindings::trace::JSTraceable;\n"),
|
||||||
CGGeneric("use dom::bindings::reflector::DomObject;\n"),
|
CGGeneric("use dom::bindings::reflector::DomObject;\n"),
|
||||||
CGGeneric("use js::jsapi::JSTracer;\n\n"),
|
CGGeneric("use js::jsapi::JSTracer;\n\n"),
|
||||||
|
|
|
@ -212,7 +212,7 @@ class Descriptor(DescriptorProvider):
|
||||||
self.argumentType = "???"
|
self.argumentType = "???"
|
||||||
self.nativeType = ty
|
self.nativeType = ty
|
||||||
else:
|
else:
|
||||||
self.returnType = "Root<%s>" % typeName
|
self.returnType = "DomRoot<%s>" % typeName
|
||||||
self.argumentType = "&%s" % typeName
|
self.argumentType = "&%s" % typeName
|
||||||
self.nativeType = "*const %s" % typeName
|
self.nativeType = "*const %s" % typeName
|
||||||
if self.interface.isIteratorInterface():
|
if self.interface.isIteratorInterface():
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
//! | USVString | `USVString` |
|
//! | USVString | `USVString` |
|
||||||
//! | ByteString | `ByteString` |
|
//! | ByteString | `ByteString` |
|
||||||
//! | object | `*mut JSObject` |
|
//! | object | `*mut JSObject` |
|
||||||
//! | interface types | `&T` | `Root<T>` |
|
//! | interface types | `&T` | `DomRoot<T>` |
|
||||||
//! | dictionary types | `&T` | *unsupported* |
|
//! | dictionary types | `&T` | *unsupported* |
|
||||||
//! | enumeration types | `T` |
|
//! | enumeration types | `T` |
|
||||||
//! | callback function types | `Rc<T>` |
|
//! | callback function types | `Rc<T>` |
|
||||||
|
@ -36,7 +36,7 @@ use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
use dom::bindings::reflector::{DomObject, Reflector};
|
use dom::bindings::reflector::{DomObject, Reflector};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::{ByteString, DOMString, USVString};
|
use dom::bindings::str::{ByteString, DOMString, USVString};
|
||||||
use dom::bindings::trace::{JSTraceable, RootedTraceableBox};
|
use dom::bindings::trace::{JSTraceable, RootedTraceableBox};
|
||||||
use dom::bindings::utils::DOMClass;
|
use dom::bindings::utils::DOMClass;
|
||||||
|
@ -102,13 +102,13 @@ impl<T: Float + FromJSValConvertible<Config=()>> FromJSValConvertible for Finite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <T: DomObject + IDLInterface> FromJSValConvertible for Root<T> {
|
impl <T: DomObject + IDLInterface> FromJSValConvertible for DomRoot<T> {
|
||||||
type Config = ();
|
type Config = ();
|
||||||
|
|
||||||
unsafe fn from_jsval(_cx: *mut JSContext,
|
unsafe fn from_jsval(_cx: *mut JSContext,
|
||||||
value: HandleValue,
|
value: HandleValue,
|
||||||
_config: Self::Config)
|
_config: Self::Config)
|
||||||
-> Result<ConversionResult<Root<T>>, ()> {
|
-> Result<ConversionResult<DomRoot<T>>, ()> {
|
||||||
Ok(match root_from_handlevalue(value) {
|
Ok(match root_from_handlevalue(value) {
|
||||||
Ok(result) => ConversionResult::Success(result),
|
Ok(result) => ConversionResult::Success(result),
|
||||||
Err(()) => ConversionResult::Failure("value is not an object".into()),
|
Err(()) => ConversionResult::Failure("value is not an object".into()),
|
||||||
|
@ -405,16 +405,16 @@ pub fn native_from_object<T>(obj: *mut JSObject) -> Result<*const T, ()>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a `Root<T>` for the given DOM object, unwrapping any wrapper
|
/// Get a `DomRoot<T>` for the given DOM object, unwrapping any wrapper
|
||||||
/// around it first, and checking if the object is of the correct type.
|
/// around it first, and checking if the object is of the correct type.
|
||||||
///
|
///
|
||||||
/// Returns Err(()) if `obj` is an opaque security wrapper or if the object is
|
/// Returns Err(()) if `obj` is an opaque security wrapper or if the object is
|
||||||
/// not a reflector for a DOM object of the given type (as defined by the
|
/// not a reflector for a DOM object of the given type (as defined by the
|
||||||
/// proto_id and proto_depth).
|
/// proto_id and proto_depth).
|
||||||
pub fn root_from_object<T>(obj: *mut JSObject) -> Result<Root<T>, ()>
|
pub fn root_from_object<T>(obj: *mut JSObject) -> Result<DomRoot<T>, ()>
|
||||||
where T: DomObject + IDLInterface
|
where T: DomObject + IDLInterface
|
||||||
{
|
{
|
||||||
native_from_object(obj).map(|ptr| unsafe { Root::from_ref(&*ptr) })
|
native_from_object(obj).map(|ptr| unsafe { DomRoot::from_ref(&*ptr) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a `*const T` for a DOM object accessible from a `HandleValue`.
|
/// Get a `*const T` for a DOM object accessible from a `HandleValue`.
|
||||||
|
@ -428,9 +428,9 @@ pub fn native_from_handlevalue<T>(v: HandleValue) -> Result<*const T, ()>
|
||||||
native_from_object(v.get().to_object())
|
native_from_object(v.get().to_object())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a `Root<T>` for a DOM object accessible from a `HandleValue`.
|
/// Get a `DomRoot<T>` for a DOM object accessible from a `HandleValue`.
|
||||||
/// Caller is responsible for throwing a JS exception if needed in case of error.
|
/// Caller is responsible for throwing a JS exception if needed in case of error.
|
||||||
pub fn root_from_handlevalue<T>(v: HandleValue) -> Result<Root<T>, ()>
|
pub fn root_from_handlevalue<T>(v: HandleValue) -> Result<DomRoot<T>, ()>
|
||||||
where T: DomObject + IDLInterface
|
where T: DomObject + IDLInterface
|
||||||
{
|
{
|
||||||
if !v.get().is_object() {
|
if !v.get().is_object() {
|
||||||
|
@ -439,14 +439,14 @@ pub fn root_from_handlevalue<T>(v: HandleValue) -> Result<Root<T>, ()>
|
||||||
root_from_object(v.get().to_object())
|
root_from_object(v.get().to_object())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a `Root<T>` for a DOM object accessible from a `HandleObject`.
|
/// Get a `DomRoot<T>` for a DOM object accessible from a `HandleObject`.
|
||||||
pub fn root_from_handleobject<T>(obj: HandleObject) -> Result<Root<T>, ()>
|
pub fn root_from_handleobject<T>(obj: HandleObject) -> Result<DomRoot<T>, ()>
|
||||||
where T: DomObject + IDLInterface
|
where T: DomObject + IDLInterface
|
||||||
{
|
{
|
||||||
root_from_object(obj.get())
|
root_from_object(obj.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: DomObject> ToJSValConvertible for Root<T> {
|
impl<T: DomObject> ToJSValConvertible for DomRoot<T> {
|
||||||
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
|
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
|
||||||
self.reflector().to_jsval(cx, rval);
|
self.reflector().to_jsval(cx, rval);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ use dom::bindings::constant::{ConstantSpec, define_constants};
|
||||||
use dom::bindings::conversions::{DOM_OBJECT_SLOT, DerivedFrom, get_dom_class};
|
use dom::bindings::conversions::{DOM_OBJECT_SLOT, DerivedFrom, get_dom_class};
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::guard::Guard;
|
use dom::bindings::guard::Guard;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::utils::{DOM_PROTOTYPE_SLOT, ProtoOrIfaceArray, get_proto_or_iface_array};
|
use dom::bindings::utils::{DOM_PROTOTYPE_SLOT, ProtoOrIfaceArray, get_proto_or_iface_array};
|
||||||
use dom::create::create_native_html_element;
|
use dom::create::create_native_html_element;
|
||||||
use dom::customelementregistry::ConstructionStackEntry;
|
use dom::customelementregistry::ConstructionStackEntry;
|
||||||
|
@ -236,7 +236,7 @@ pub unsafe fn create_global_object(
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#htmlconstructor
|
// https://html.spec.whatwg.org/multipage/#htmlconstructor
|
||||||
pub unsafe fn html_constructor<T>(window: &Window, call_args: &CallArgs) -> Fallible<Root<T>>
|
pub unsafe fn html_constructor<T>(window: &Window, call_args: &CallArgs) -> Fallible<DomRoot<T>>
|
||||||
where T: DerivedFrom<Element> {
|
where T: DerivedFrom<Element> {
|
||||||
let document = window.Document();
|
let document = window.Document();
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ pub unsafe fn html_constructor<T>(window: &Window, call_args: &CallArgs) -> Fall
|
||||||
// Step 8.1
|
// Step 8.1
|
||||||
let name = QualName::new(None, ns!(html), definition.local_name.clone());
|
let name = QualName::new(None, ns!(html), definition.local_name.clone());
|
||||||
let element = if definition.is_autonomous() {
|
let element = if definition.is_autonomous() {
|
||||||
Root::upcast(HTMLElement::new(name.local, None, &*document))
|
DomRoot::upcast(HTMLElement::new(name.local, None, &*document))
|
||||||
} else {
|
} else {
|
||||||
create_native_html_element(name, None, &*document, ElementCreator::ScriptCreated)
|
create_native_html_element(name, None, &*document, ElementCreator::ScriptCreated)
|
||||||
};
|
};
|
||||||
|
@ -303,7 +303,7 @@ pub unsafe fn html_constructor<T>(window: &Window, call_args: &CallArgs) -> Fall
|
||||||
element.set_custom_element_definition(definition.clone());
|
element.set_custom_element_definition(definition.clone());
|
||||||
|
|
||||||
// Step 8.5
|
// Step 8.5
|
||||||
Root::downcast(element).ok_or(Error::InvalidState)
|
DomRoot::downcast(element).ok_or(Error::InvalidState)
|
||||||
},
|
},
|
||||||
// Step 9
|
// Step 9
|
||||||
Some(ConstructionStackEntry::Element(element)) => {
|
Some(ConstructionStackEntry::Element(element)) => {
|
||||||
|
@ -315,7 +315,7 @@ pub unsafe fn html_constructor<T>(window: &Window, call_args: &CallArgs) -> Fall
|
||||||
construction_stack.push(ConstructionStackEntry::AlreadyConstructedMarker);
|
construction_stack.push(ConstructionStackEntry::AlreadyConstructedMarker);
|
||||||
|
|
||||||
// Step 13
|
// Step 13
|
||||||
Root::downcast(element).ok_or(Error::InvalidState)
|
DomRoot::downcast(element).ok_or(Error::InvalidState)
|
||||||
},
|
},
|
||||||
// Step 10
|
// Step 10
|
||||||
Some(ConstructionStackEntry::AlreadyConstructedMarker) => Err(Error::InvalidState),
|
Some(ConstructionStackEntry::AlreadyConstructedMarker) => Err(Error::InvalidState),
|
||||||
|
|
|
@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyAndVal
|
||||||
use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyOrValueResult;
|
use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyOrValueResult;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::trace::JSTraceable;
|
use dom::bindings::trace::JSTraceable;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -61,7 +61,7 @@ impl<T: DomObject + JSTraceable + Iterable> IterableIterator<T> {
|
||||||
pub fn new(iterable: &T,
|
pub fn new(iterable: &T,
|
||||||
type_: IteratorType,
|
type_: IteratorType,
|
||||||
wrap: unsafe fn(*mut JSContext, &GlobalScope, Box<IterableIterator<T>>)
|
wrap: unsafe fn(*mut JSContext, &GlobalScope, Box<IterableIterator<T>>)
|
||||||
-> Root<Self>) -> Root<Self> {
|
-> DomRoot<Self>) -> DomRoot<Self> {
|
||||||
let iterator = box IterableIterator {
|
let iterator = box IterableIterator {
|
||||||
reflector: Reflector::new(),
|
reflector: Reflector::new(),
|
||||||
type_: type_,
|
type_: type_,
|
||||||
|
|
|
@ -26,7 +26,7 @@ use core::nonzero::NonZero;
|
||||||
use dom::bindings::conversions::ToJSValConvertible;
|
use dom::bindings::conversions::ToJSValConvertible;
|
||||||
use dom::bindings::error::Error;
|
use dom::bindings::error::Error;
|
||||||
use dom::bindings::reflector::{DomObject, Reflector};
|
use dom::bindings::reflector::{DomObject, Reflector};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::trace::trace_reflector;
|
use dom::bindings::trace::trace_reflector;
|
||||||
use dom::promise::Promise;
|
use dom::promise::Promise;
|
||||||
use js::jsapi::JSTracer;
|
use js::jsapi::JSTracer;
|
||||||
|
@ -178,14 +178,14 @@ impl<T: DomObject> Trusted<T> {
|
||||||
/// Obtain a usable DOM pointer from a pinned `Trusted<T>` value. Fails if used on
|
/// Obtain a usable DOM pointer from a pinned `Trusted<T>` value. Fails if used on
|
||||||
/// a different thread than the original value from which this `Trusted<T>` was
|
/// a different thread than the original value from which this `Trusted<T>` was
|
||||||
/// obtained.
|
/// obtained.
|
||||||
pub fn root(&self) -> Root<T> {
|
pub fn root(&self) -> DomRoot<T> {
|
||||||
assert!(LIVE_REFERENCES.with(|ref r| {
|
assert!(LIVE_REFERENCES.with(|ref r| {
|
||||||
let r = r.borrow();
|
let r = r.borrow();
|
||||||
let live_references = r.as_ref().unwrap();
|
let live_references = r.as_ref().unwrap();
|
||||||
self.owner_thread == (&*live_references) as *const _ as *const libc::c_void
|
self.owner_thread == (&*live_references) as *const _ as *const libc::c_void
|
||||||
}));
|
}));
|
||||||
unsafe {
|
unsafe {
|
||||||
Root::new(NonZero::new_unchecked(self.refcount.0 as *const T))
|
DomRoot::new(NonZero::new_unchecked(self.refcount.0 as *const T))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
//! The `Reflector` struct.
|
//! The `Reflector` struct.
|
||||||
|
|
||||||
use dom::bindings::conversions::DerivedFrom;
|
use dom::bindings::conversions::DerivedFrom;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use js::jsapi::{HandleObject, JSContext, JSObject, Heap};
|
use js::jsapi::{HandleObject, JSContext, JSObject, Heap};
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
@ -15,8 +15,8 @@ use std::default::Default;
|
||||||
pub fn reflect_dom_object<T, U>(
|
pub fn reflect_dom_object<T, U>(
|
||||||
obj: Box<T>,
|
obj: Box<T>,
|
||||||
global: &U,
|
global: &U,
|
||||||
wrap_fn: unsafe fn(*mut JSContext, &GlobalScope, Box<T>) -> Root<T>)
|
wrap_fn: unsafe fn(*mut JSContext, &GlobalScope, Box<T>) -> DomRoot<T>)
|
||||||
-> Root<T>
|
-> DomRoot<T>
|
||||||
where T: DomObject, U: DerivedFrom<GlobalScope>
|
where T: DomObject, U: DerivedFrom<GlobalScope>
|
||||||
{
|
{
|
||||||
let global_scope = global.upcast();
|
let global_scope = global.upcast();
|
||||||
|
@ -77,7 +77,7 @@ pub trait DomObject {
|
||||||
fn reflector(&self) -> &Reflector;
|
fn reflector(&self) -> &Reflector;
|
||||||
|
|
||||||
/// Returns the global scope of the realm that the DomObject was created in.
|
/// Returns the global scope of the realm that the DomObject was created in.
|
||||||
fn global(&self) -> Root<GlobalScope> where Self: Sized {
|
fn global(&self) -> DomRoot<GlobalScope> where Self: Sized {
|
||||||
GlobalScope::from_reflector(self)
|
GlobalScope::from_reflector(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,16 +11,16 @@
|
||||||
//!
|
//!
|
||||||
//! Here is a brief overview of the important types:
|
//! Here is a brief overview of the important types:
|
||||||
//!
|
//!
|
||||||
//! - `Root<T>`: a stack-based reference to a rooted DOM object.
|
//! - `DomRoot<T>`: a stack-based reference to a rooted DOM object.
|
||||||
//! - `Dom<T>`: a reference to a DOM object that can automatically be traced by
|
//! - `Dom<T>`: a reference to a DOM object that can automatically be traced by
|
||||||
//! the GC when encountered as a field of a Rust structure.
|
//! the GC when encountered as a field of a Rust structure.
|
||||||
//!
|
//!
|
||||||
//! `Dom<T>` does not allow access to their inner value without explicitly
|
//! `Dom<T>` does not allow access to their inner value without explicitly
|
||||||
//! creating a stack-based root via the `root` method. This returns a `Root<T>`,
|
//! creating a stack-based root via the `root` method. This returns a `DomRoot<T>`,
|
||||||
//! which causes the JS-owned value to be uncollectable for the duration of the
|
//! which causes the JS-owned value to be uncollectable for the duration of the
|
||||||
//! `Root` object's lifetime. A reference to the object can then be obtained
|
//! `Root` object's lifetime. A reference to the object can then be obtained
|
||||||
//! from the `Root` object. These references are not allowed to outlive their
|
//! from the `Root` object. These references are not allowed to outlive their
|
||||||
//! originating `Root<T>`.
|
//! originating `DomRoot<T>`.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use core::nonzero::NonZero;
|
use core::nonzero::NonZero;
|
||||||
|
@ -259,10 +259,10 @@ impl<T: DomObject> MutDom<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the value in this `MutDom`.
|
/// Get the value in this `MutDom`.
|
||||||
pub fn get(&self) -> Root<T> {
|
pub fn get(&self) -> DomRoot<T> {
|
||||||
debug_assert!(thread_state::get().is_script());
|
debug_assert!(thread_state::get().is_script());
|
||||||
unsafe {
|
unsafe {
|
||||||
Root::from_ref(&*ptr::read(self.val.get()))
|
DomRoot::from_ref(&*ptr::read(self.val.get()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,8 +313,8 @@ impl<T: DomObject> MutNullableDom<T> {
|
||||||
|
|
||||||
/// Retrieve a copy of the current inner value. If it is `None`, it is
|
/// Retrieve a copy of the current inner value. If it is `None`, it is
|
||||||
/// initialized with the result of `cb` first.
|
/// initialized with the result of `cb` first.
|
||||||
pub fn or_init<F>(&self, cb: F) -> Root<T>
|
pub fn or_init<F>(&self, cb: F) -> DomRoot<T>
|
||||||
where F: FnOnce() -> Root<T>
|
where F: FnOnce() -> DomRoot<T>
|
||||||
{
|
{
|
||||||
debug_assert!(thread_state::get().is_script());
|
debug_assert!(thread_state::get().is_script());
|
||||||
match self.get() {
|
match self.get() {
|
||||||
|
@ -337,10 +337,10 @@ impl<T: DomObject> MutNullableDom<T> {
|
||||||
|
|
||||||
/// Get a rooted value out of this object
|
/// Get a rooted value out of this object
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn get(&self) -> Option<Root<T>> {
|
pub fn get(&self) -> Option<DomRoot<T>> {
|
||||||
debug_assert!(thread_state::get().is_script());
|
debug_assert!(thread_state::get().is_script());
|
||||||
unsafe {
|
unsafe {
|
||||||
ptr::read(self.ptr.get()).map(|o| Root::from_ref(&*o))
|
ptr::read(self.ptr.get()).map(|o| DomRoot::from_ref(&*o))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ impl<T: DomObject> MutNullableDom<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the current value out of this object and sets it to `None`.
|
/// Gets the current value out of this object and sets it to `None`.
|
||||||
pub fn take(&self) -> Option<Root<T>> {
|
pub fn take(&self) -> Option<DomRoot<T>> {
|
||||||
let value = self.get();
|
let value = self.get();
|
||||||
self.set(None);
|
self.set(None);
|
||||||
value
|
value
|
||||||
|
@ -409,7 +409,7 @@ impl<T: DomObject> DomOnceCell<T> {
|
||||||
/// initialized with the result of `cb` first.
|
/// initialized with the result of `cb` first.
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn init_once<F>(&self, cb: F) -> &T
|
pub fn init_once<F>(&self, cb: F) -> &T
|
||||||
where F: FnOnce() -> Root<T>
|
where F: FnOnce() -> DomRoot<T>
|
||||||
{
|
{
|
||||||
debug_assert!(thread_state::get().is_script());
|
debug_assert!(thread_state::get().is_script());
|
||||||
&self.ptr.init_once(|| Dom::from_ref(&cb()))
|
&self.ptr.init_once(|| Dom::from_ref(&cb()))
|
||||||
|
@ -559,16 +559,16 @@ pub unsafe fn trace_roots(tracer: *mut JSTracer) {
|
||||||
/// for the same JS value. `Root`s cannot outlive the associated
|
/// for the same JS value. `Root`s cannot outlive the associated
|
||||||
/// `RootCollection` object.
|
/// `RootCollection` object.
|
||||||
#[allow_unrooted_interior]
|
#[allow_unrooted_interior]
|
||||||
pub struct Root<T: DomObject> {
|
pub struct DomRoot<T: DomObject> {
|
||||||
/// Reference to rooted value that must not outlive this container
|
/// Reference to rooted value that must not outlive this container
|
||||||
ptr: NonZero<*const T>,
|
ptr: NonZero<*const T>,
|
||||||
/// List that ensures correct dynamic root ordering
|
/// List that ensures correct dynamic root ordering
|
||||||
root_list: *const RootCollection,
|
root_list: *const RootCollection,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Castable> Root<T> {
|
impl<T: Castable> DomRoot<T> {
|
||||||
/// Cast a DOM object root upwards to one of the interfaces it derives from.
|
/// Cast a DOM object root upwards to one of the interfaces it derives from.
|
||||||
pub fn upcast<U>(root: Root<T>) -> Root<U>
|
pub fn upcast<U>(root: DomRoot<T>) -> DomRoot<U>
|
||||||
where U: Castable,
|
where U: Castable,
|
||||||
T: DerivedFrom<U>
|
T: DerivedFrom<U>
|
||||||
{
|
{
|
||||||
|
@ -576,7 +576,7 @@ impl<T: Castable> Root<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast a DOM object root downwards to one of the interfaces it might implement.
|
/// Cast a DOM object root downwards to one of the interfaces it might implement.
|
||||||
pub fn downcast<U>(root: Root<T>) -> Option<Root<U>>
|
pub fn downcast<U>(root: DomRoot<T>) -> Option<DomRoot<U>>
|
||||||
where U: DerivedFrom<T>
|
where U: DerivedFrom<T>
|
||||||
{
|
{
|
||||||
if root.is::<U>() {
|
if root.is::<U>() {
|
||||||
|
@ -587,16 +587,16 @@ impl<T: Castable> Root<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: DomObject> Root<T> {
|
impl<T: DomObject> DomRoot<T> {
|
||||||
/// Create a new stack-bounded root for the provided JS-owned value.
|
/// Create a new stack-bounded root for the provided JS-owned value.
|
||||||
/// It cannot outlive its associated `RootCollection`, and it gives
|
/// It cannot outlive its associated `RootCollection`, and it gives
|
||||||
/// out references which cannot outlive this new `Root`.
|
/// out references which cannot outlive this new `Root`.
|
||||||
pub fn new(unrooted: NonZero<*const T>) -> Root<T> {
|
pub fn new(unrooted: NonZero<*const T>) -> DomRoot<T> {
|
||||||
debug_assert!(thread_state::get().is_script());
|
debug_assert!(thread_state::get().is_script());
|
||||||
STACK_ROOTS.with(|ref collection| {
|
STACK_ROOTS.with(|ref collection| {
|
||||||
let RootCollectionPtr(collection) = collection.get().unwrap();
|
let RootCollectionPtr(collection) = collection.get().unwrap();
|
||||||
unsafe { (*collection).root(&*(*unrooted.get()).reflector()) }
|
unsafe { (*collection).root(&*(*unrooted.get()).reflector()) }
|
||||||
Root {
|
DomRoot {
|
||||||
ptr: unrooted,
|
ptr: unrooted,
|
||||||
root_list: collection,
|
root_list: collection,
|
||||||
}
|
}
|
||||||
|
@ -604,19 +604,19 @@ impl<T: DomObject> Root<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate a new root from a reference
|
/// Generate a new root from a reference
|
||||||
pub fn from_ref(unrooted: &T) -> Root<T> {
|
pub fn from_ref(unrooted: &T) -> DomRoot<T> {
|
||||||
Root::new(unsafe { NonZero::new_unchecked(unrooted) })
|
DomRoot::new(unsafe { NonZero::new_unchecked(unrooted) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'root, T: DomObject + 'root> RootedReference<'root> for Root<T> {
|
impl<'root, T: DomObject + 'root> RootedReference<'root> for DomRoot<T> {
|
||||||
type Ref = &'root T;
|
type Ref = &'root T;
|
||||||
fn r(&'root self) -> &'root T {
|
fn r(&'root self) -> &'root T {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: DomObject> Deref for Root<T> {
|
impl<T: DomObject> Deref for DomRoot<T> {
|
||||||
type Target = T;
|
type Target = T;
|
||||||
fn deref(&self) -> &T {
|
fn deref(&self) -> &T {
|
||||||
debug_assert!(thread_state::get().is_script());
|
debug_assert!(thread_state::get().is_script());
|
||||||
|
@ -624,25 +624,25 @@ impl<T: DomObject> Deref for Root<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: DomObject + HeapSizeOf> HeapSizeOf for Root<T> {
|
impl<T: DomObject + HeapSizeOf> HeapSizeOf for DomRoot<T> {
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
(**self).heap_size_of_children()
|
(**self).heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: DomObject> PartialEq for Root<T> {
|
impl<T: DomObject> PartialEq for DomRoot<T> {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.ptr == other.ptr
|
self.ptr == other.ptr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: DomObject> Clone for Root<T> {
|
impl<T: DomObject> Clone for DomRoot<T> {
|
||||||
fn clone(&self) -> Root<T> {
|
fn clone(&self) -> DomRoot<T> {
|
||||||
Root::from_ref(&*self)
|
DomRoot::from_ref(&*self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: DomObject> Drop for Root<T> {
|
impl<T: DomObject> Drop for DomRoot<T> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
(*self.root_list).unroot(self.reflector());
|
(*self.root_list).unroot(self.reflector());
|
||||||
|
@ -650,7 +650,7 @@ impl<T: DomObject> Drop for Root<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<T: DomObject> JSTraceable for Root<T> {
|
unsafe impl<T: DomObject> JSTraceable for DomRoot<T> {
|
||||||
unsafe fn trace(&self, _: *mut JSTracer) {
|
unsafe fn trace(&self, _: *mut JSTracer) {
|
||||||
// Already traced.
|
// Already traced.
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::trace::JSTraceable;
|
use dom::bindings::trace::JSTraceable;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use js::jsapi::GetScriptedCallerGlobal;
|
use js::jsapi::GetScriptedCallerGlobal;
|
||||||
|
@ -37,7 +37,7 @@ pub unsafe fn trace(tracer: *mut JSTracer) {
|
||||||
|
|
||||||
/// RAII struct that pushes and pops entries from the script settings stack.
|
/// RAII struct that pushes and pops entries from the script settings stack.
|
||||||
pub struct AutoEntryScript {
|
pub struct AutoEntryScript {
|
||||||
global: Root<GlobalScope>,
|
global: DomRoot<GlobalScope>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AutoEntryScript {
|
impl AutoEntryScript {
|
||||||
|
@ -51,7 +51,7 @@ impl AutoEntryScript {
|
||||||
kind: StackEntryKind::Entry,
|
kind: StackEntryKind::Entry,
|
||||||
});
|
});
|
||||||
AutoEntryScript {
|
AutoEntryScript {
|
||||||
global: Root::from_ref(global),
|
global: DomRoot::from_ref(global),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -80,13 +80,13 @@ impl Drop for AutoEntryScript {
|
||||||
/// Returns the ["entry"] global object.
|
/// Returns the ["entry"] global object.
|
||||||
///
|
///
|
||||||
/// ["entry"]: https://html.spec.whatwg.org/multipage/#entry
|
/// ["entry"]: https://html.spec.whatwg.org/multipage/#entry
|
||||||
pub fn entry_global() -> Root<GlobalScope> {
|
pub fn entry_global() -> DomRoot<GlobalScope> {
|
||||||
STACK.with(|stack| {
|
STACK.with(|stack| {
|
||||||
stack.borrow()
|
stack.borrow()
|
||||||
.iter()
|
.iter()
|
||||||
.rev()
|
.rev()
|
||||||
.find(|entry| entry.kind == StackEntryKind::Entry)
|
.find(|entry| entry.kind == StackEntryKind::Entry)
|
||||||
.map(|entry| Root::from_ref(&*entry.global))
|
.map(|entry| DomRoot::from_ref(&*entry.global))
|
||||||
}).unwrap()
|
}).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ impl Drop for AutoIncumbentScript {
|
||||||
/// Returns the ["incumbent"] global object.
|
/// Returns the ["incumbent"] global object.
|
||||||
///
|
///
|
||||||
/// ["incumbent"]: https://html.spec.whatwg.org/multipage/#incumbent
|
/// ["incumbent"]: https://html.spec.whatwg.org/multipage/#incumbent
|
||||||
pub fn incumbent_global() -> Option<Root<GlobalScope>> {
|
pub fn incumbent_global() -> Option<DomRoot<GlobalScope>> {
|
||||||
// https://html.spec.whatwg.org/multipage/#incumbent-settings-object
|
// https://html.spec.whatwg.org/multipage/#incumbent-settings-object
|
||||||
|
|
||||||
// Step 1, 3: See what the JS engine has to say. If we've got a scripted
|
// Step 1, 3: See what the JS engine has to say. If we've got a scripted
|
||||||
|
@ -165,6 +165,6 @@ pub fn incumbent_global() -> Option<Root<GlobalScope>> {
|
||||||
STACK.with(|stack| {
|
STACK.with(|stack| {
|
||||||
stack.borrow()
|
stack.borrow()
|
||||||
.last()
|
.last()
|
||||||
.map(|entry| Root::from_ref(&*entry.global))
|
.map(|entry| DomRoot::from_ref(&*entry.global))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
use dom::bindings::conversions::root_from_handleobject;
|
use dom::bindings::conversions::root_from_handleobject;
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::reflector::DomObject;
|
use dom::bindings::reflector::DomObject;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::blob::{Blob, BlobImpl};
|
use dom::blob::{Blob, BlobImpl};
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use js::jsapi::{Handle, HandleObject, HandleValue, MutableHandleValue, JSAutoCompartment, JSContext};
|
use js::jsapi::{Handle, HandleObject, HandleValue, MutableHandleValue, JSAutoCompartment, JSContext};
|
||||||
|
@ -110,7 +110,7 @@ unsafe fn read_blob(cx: *mut JSContext,
|
||||||
return blob.reflector().get_jsobject().get()
|
return blob.reflector().get_jsobject().get()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn write_blob(blob: Root<Blob>,
|
unsafe fn write_blob(blob: DomRoot<Blob>,
|
||||||
w: *mut JSStructuredCloneWriter)
|
w: *mut JSStructuredCloneWriter)
|
||||||
-> Result<(), ()> {
|
-> Result<(), ()> {
|
||||||
let structured_writer = StructuredCloneWriter { w: w };
|
let structured_writer = StructuredCloneWriter { w: w };
|
||||||
|
|
|
@ -42,7 +42,7 @@ use dom::bindings::cell::DomRefCell;
|
||||||
use dom::bindings::error::Error;
|
use dom::bindings::error::Error;
|
||||||
use dom::bindings::refcounted::{Trusted, TrustedPromise};
|
use dom::bindings::refcounted::{Trusted, TrustedPromise};
|
||||||
use dom::bindings::reflector::{DomObject, Reflector};
|
use dom::bindings::reflector::{DomObject, Reflector};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::{DOMString, USVString};
|
use dom::bindings::str::{DOMString, USVString};
|
||||||
use dom::bindings::utils::WindowProxyHandler;
|
use dom::bindings::utils::WindowProxyHandler;
|
||||||
use dom::document::PendingRestyle;
|
use dom::document::PendingRestyle;
|
||||||
|
@ -710,7 +710,7 @@ impl RootedTraceableSet {
|
||||||
|
|
||||||
/// Roots any JSTraceable thing
|
/// Roots any JSTraceable thing
|
||||||
///
|
///
|
||||||
/// If you have a valid DomObject, use Root.
|
/// If you have a valid DomObject, use DomRoot.
|
||||||
/// If you have GC things like *mut JSObject or JSVal, use rooted!.
|
/// If you have GC things like *mut JSObject or JSVal, use rooted!.
|
||||||
/// If you have an arbitrary number of DomObjects to root, use rooted_vec!.
|
/// If you have an arbitrary number of DomObjects to root, use rooted_vec!.
|
||||||
/// If you know what you're doing, use this.
|
/// If you know what you're doing, use this.
|
||||||
|
@ -720,7 +720,7 @@ pub struct RootedTraceable<'a, T: 'static + JSTraceable> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: JSTraceable + 'static> RootedTraceable<'a, T> {
|
impl<'a, T: JSTraceable + 'static> RootedTraceable<'a, T> {
|
||||||
/// Root a JSTraceable thing for the life of this RootedTraceable
|
/// DomRoot a JSTraceable thing for the life of this RootedTraceable
|
||||||
pub fn new(traceable: &'a T) -> RootedTraceable<'a, T> {
|
pub fn new(traceable: &'a T) -> RootedTraceable<'a, T> {
|
||||||
unsafe {
|
unsafe {
|
||||||
RootedTraceableSet::add(traceable);
|
RootedTraceableSet::add(traceable);
|
||||||
|
@ -741,7 +741,7 @@ impl<'a, T: JSTraceable + 'static> Drop for RootedTraceable<'a, T> {
|
||||||
|
|
||||||
/// Roots any JSTraceable thing
|
/// Roots any JSTraceable thing
|
||||||
///
|
///
|
||||||
/// If you have a valid DomObject, use Root.
|
/// If you have a valid DomObject, use DomRoot.
|
||||||
/// If you have GC things like *mut JSObject or JSVal, use rooted!.
|
/// If you have GC things like *mut JSObject or JSVal, use rooted!.
|
||||||
/// If you have an arbitrary number of DomObjects to root, use rooted_vec!.
|
/// If you have an arbitrary number of DomObjects to root, use rooted_vec!.
|
||||||
/// If you know what you're doing, use this.
|
/// If you know what you're doing, use this.
|
||||||
|
@ -757,7 +757,7 @@ unsafe impl<T: JSTraceable + 'static> JSTraceable for RootedTraceableBox<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: JSTraceable + 'static> RootedTraceableBox<T> {
|
impl<T: JSTraceable + 'static> RootedTraceableBox<T> {
|
||||||
/// Root a JSTraceable thing for the life of this RootedTraceable
|
/// DomRoot a JSTraceable thing for the life of this RootedTraceable
|
||||||
pub fn new(traceable: T) -> RootedTraceableBox<T> {
|
pub fn new(traceable: T) -> RootedTraceableBox<T> {
|
||||||
let traceable = Box::into_raw(box traceable);
|
let traceable = Box::into_raw(box traceable);
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -804,7 +804,7 @@ impl<T: JSTraceable + 'static> Drop for RootedTraceableBox<T> {
|
||||||
/// A vector of items to be rooted with `RootedVec`.
|
/// A vector of items to be rooted with `RootedVec`.
|
||||||
/// Guaranteed to be empty when not rooted.
|
/// Guaranteed to be empty when not rooted.
|
||||||
/// Usage: `rooted_vec!(let mut v);` or if you have an
|
/// Usage: `rooted_vec!(let mut v);` or if you have an
|
||||||
/// iterator of `Root`s, `rooted_vec!(let v <- iterator);`.
|
/// iterator of `DomRoot`s, `rooted_vec!(let v <- iterator);`.
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
#[derive(JSTraceable)]
|
#[derive(JSTraceable)]
|
||||||
#[allow_unrooted_interior]
|
#[allow_unrooted_interior]
|
||||||
|
@ -844,7 +844,7 @@ impl<'a, T: 'static + JSTraceable + DomObject> RootedVec<'a, Dom<T>> {
|
||||||
/// Create a vector of items of type Dom<T> that is rooted for
|
/// Create a vector of items of type Dom<T> that is rooted for
|
||||||
/// the lifetime of this struct
|
/// the lifetime of this struct
|
||||||
pub fn from_iter<I>(root: &'a mut RootableVec<Dom<T>>, iter: I) -> Self
|
pub fn from_iter<I>(root: &'a mut RootableVec<Dom<T>>, iter: I) -> Self
|
||||||
where I: Iterator<Item = Root<T>>
|
where I: Iterator<Item = DomRoot<T>>
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
RootedTraceableSet::add(root);
|
RootedTraceableSet::add(root);
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
use core::nonzero::NonZero;
|
use core::nonzero::NonZero;
|
||||||
use dom::bindings::reflector::DomObject;
|
use dom::bindings::reflector::DomObject;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::trace::JSTraceable;
|
use dom::bindings::trace::JSTraceable;
|
||||||
use heapsize::HeapSizeOf;
|
use heapsize::HeapSizeOf;
|
||||||
use js::jsapi::{JSTracer, JS_GetReservedSlot, JS_SetReservedSlot};
|
use js::jsapi::{JSTracer, JS_GetReservedSlot, JS_SetReservedSlot};
|
||||||
|
@ -84,9 +84,9 @@ impl<T: WeakReferenceable> WeakRef<T> {
|
||||||
value.downgrade()
|
value.downgrade()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Root a weak reference. Returns `None` if the object was already collected.
|
/// DomRoot a weak reference. Returns `None` if the object was already collected.
|
||||||
pub fn root(&self) -> Option<Root<T>> {
|
pub fn root(&self) -> Option<DomRoot<T>> {
|
||||||
unsafe { &*self.ptr.get() }.value.get().map(Root::new)
|
unsafe { &*self.ptr.get() }.value.get().map(DomRoot::new)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return whether the weakly-referenced object is still alive.
|
/// Return whether the weakly-referenced object is still alive.
|
||||||
|
@ -179,9 +179,9 @@ impl<T: WeakReferenceable> MutableWeakRef<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Root a mutable weak reference. Returns `None` if the object
|
/// DomRoot a mutable weak reference. Returns `None` if the object
|
||||||
/// was already collected.
|
/// was already collected.
|
||||||
pub fn root(&self) -> Option<Root<T>> {
|
pub fn root(&self) -> Option<DomRoot<T>> {
|
||||||
unsafe { &*self.cell.get() }.as_ref().and_then(WeakRef::root)
|
unsafe { &*self.cell.get() }.as_ref().and_then(WeakRef::root)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
|
||||||
use dom::bindings::codegen::UnionTypes::BlobOrString;
|
use dom::bindings::codegen::UnionTypes::BlobOrString;
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -79,7 +79,7 @@ impl Blob {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
global: &GlobalScope, blob_impl: BlobImpl, typeString: String)
|
global: &GlobalScope, blob_impl: BlobImpl, typeString: String)
|
||||||
-> Root<Blob> {
|
-> DomRoot<Blob> {
|
||||||
let boxed_blob = box Blob::new_inherited(blob_impl, typeString);
|
let boxed_blob = box Blob::new_inherited(blob_impl, typeString);
|
||||||
reflect_dom_object(boxed_blob, global, BlobBinding::Wrap)
|
reflect_dom_object(boxed_blob, global, BlobBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ impl Blob {
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
fn new_sliced(parent: &Blob, rel_pos: RelativePos,
|
fn new_sliced(parent: &Blob, rel_pos: RelativePos,
|
||||||
relative_content_type: DOMString) -> Root<Blob> {
|
relative_content_type: DOMString) -> DomRoot<Blob> {
|
||||||
let blob_impl = match *parent.blob_impl.borrow() {
|
let blob_impl = match *parent.blob_impl.borrow() {
|
||||||
BlobImpl::File(_) => {
|
BlobImpl::File(_) => {
|
||||||
// Create new parent node
|
// Create new parent node
|
||||||
|
@ -120,7 +120,7 @@ impl Blob {
|
||||||
pub fn Constructor(global: &GlobalScope,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
blobParts: Option<Vec<BlobOrString>>,
|
blobParts: Option<Vec<BlobOrString>>,
|
||||||
blobPropertyBag: &BlobBinding::BlobPropertyBag)
|
blobPropertyBag: &BlobBinding::BlobPropertyBag)
|
||||||
-> Fallible<Root<Blob>> {
|
-> Fallible<DomRoot<Blob>> {
|
||||||
// TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView
|
// TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView
|
||||||
let bytes: Vec<u8> = match blobParts {
|
let bytes: Vec<u8> = match blobParts {
|
||||||
None => Vec::new(),
|
None => Vec::new(),
|
||||||
|
@ -369,7 +369,7 @@ impl BlobMethods for Blob {
|
||||||
start: Option<i64>,
|
start: Option<i64>,
|
||||||
end: Option<i64>,
|
end: Option<i64>,
|
||||||
content_type: Option<DOMString>)
|
content_type: Option<DOMString>)
|
||||||
-> Root<Blob> {
|
-> DomRoot<Blob> {
|
||||||
let rel_pos = RelativePos::from_opts(start, end);
|
let rel_pos = RelativePos::from_opts(start, end);
|
||||||
Blob::new_sliced(self, rel_pos, content_type.unwrap_or(DOMString::from("")))
|
Blob::new_sliced(self, rel_pos, content_type.unwrap_or(DOMString::from("")))
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ use dom::bindings::error::Error::{self, Network, Security, Type};
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::refcounted::{Trusted, TrustedPromise};
|
use dom::bindings::refcounted::{Trusted, TrustedPromise};
|
||||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bluetoothdevice::BluetoothDevice;
|
use dom::bluetoothdevice::BluetoothDevice;
|
||||||
use dom::bluetoothpermissionresult::BluetoothPermissionResult;
|
use dom::bluetoothpermissionresult::BluetoothPermissionResult;
|
||||||
|
@ -131,7 +131,7 @@ impl Bluetooth {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope) -> Root<Bluetooth> {
|
pub fn new(global: &GlobalScope) -> DomRoot<Bluetooth> {
|
||||||
reflect_dom_object(box Bluetooth::new_inherited(),
|
reflect_dom_object(box Bluetooth::new_inherited(),
|
||||||
global,
|
global,
|
||||||
BluetoothBinding::Wrap)
|
BluetoothBinding::Wrap)
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::{Dom, Root, RootedReference};
|
use dom::bindings::root::{Dom, DomRoot, RootedReference};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bluetoothdevice::BluetoothDevice;
|
use dom::bluetoothdevice::BluetoothDevice;
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
|
@ -54,7 +54,7 @@ impl BluetoothAdvertisingEvent {
|
||||||
appearance: Option<u16>,
|
appearance: Option<u16>,
|
||||||
txPower: Option<i8>,
|
txPower: Option<i8>,
|
||||||
rssi: Option<i8>)
|
rssi: Option<i8>)
|
||||||
-> Root<BluetoothAdvertisingEvent> {
|
-> DomRoot<BluetoothAdvertisingEvent> {
|
||||||
let ev = reflect_dom_object(box BluetoothAdvertisingEvent::new_inherited(device,
|
let ev = reflect_dom_object(box BluetoothAdvertisingEvent::new_inherited(device,
|
||||||
name,
|
name,
|
||||||
appearance,
|
appearance,
|
||||||
|
@ -73,7 +73,7 @@ impl BluetoothAdvertisingEvent {
|
||||||
pub fn Constructor(window: &Window,
|
pub fn Constructor(window: &Window,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &BluetoothAdvertisingEventInit)
|
init: &BluetoothAdvertisingEventInit)
|
||||||
-> Fallible<Root<BluetoothAdvertisingEvent>> {
|
-> Fallible<DomRoot<BluetoothAdvertisingEvent>> {
|
||||||
let global = window.upcast::<GlobalScope>();
|
let global = window.upcast::<GlobalScope>();
|
||||||
let device = init.device.r();
|
let device = init.device.r();
|
||||||
let name = init.name.clone();
|
let name = init.name.clone();
|
||||||
|
@ -96,8 +96,8 @@ impl BluetoothAdvertisingEvent {
|
||||||
|
|
||||||
impl BluetoothAdvertisingEventMethods for BluetoothAdvertisingEvent {
|
impl BluetoothAdvertisingEventMethods for BluetoothAdvertisingEvent {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothadvertisingevent-device
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothadvertisingevent-device
|
||||||
fn Device(&self) -> Root<BluetoothDevice> {
|
fn Device(&self) -> DomRoot<BluetoothDevice> {
|
||||||
Root::from_ref(&*self.device)
|
DomRoot::from_ref(&*self.device)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothadvertisingevent-name
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothadvertisingevent-name
|
||||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding;
|
||||||
use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::
|
use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::
|
||||||
BluetoothCharacteristicPropertiesMethods;
|
BluetoothCharacteristicPropertiesMethods;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ impl BluetoothCharacteristicProperties {
|
||||||
authenticatedSignedWrites: bool,
|
authenticatedSignedWrites: bool,
|
||||||
reliableWrite: bool,
|
reliableWrite: bool,
|
||||||
writableAuxiliaries: bool)
|
writableAuxiliaries: bool)
|
||||||
-> Root<BluetoothCharacteristicProperties> {
|
-> DomRoot<BluetoothCharacteristicProperties> {
|
||||||
reflect_dom_object(box BluetoothCharacteristicProperties::new_inherited(broadcast,
|
reflect_dom_object(box BluetoothCharacteristicProperties::new_inherited(broadcast,
|
||||||
read,
|
read,
|
||||||
writeWithoutResponse,
|
writeWithoutResponse,
|
||||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::error::Error;
|
||||||
use dom::bindings::error::ErrorResult;
|
use dom::bindings::error::ErrorResult;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, MutNullableDom, Root};
|
use dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bluetooth::{AsyncBluetoothListener, Bluetooth, response_async};
|
use dom::bluetooth::{AsyncBluetoothListener, Bluetooth, response_async};
|
||||||
use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
|
use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
|
||||||
|
@ -65,7 +65,7 @@ impl BluetoothDevice {
|
||||||
id: DOMString,
|
id: DOMString,
|
||||||
name: Option<DOMString>,
|
name: Option<DOMString>,
|
||||||
context: &Bluetooth)
|
context: &Bluetooth)
|
||||||
-> Root<BluetoothDevice> {
|
-> DomRoot<BluetoothDevice> {
|
||||||
reflect_dom_object(box BluetoothDevice::new_inherited(id,
|
reflect_dom_object(box BluetoothDevice::new_inherited(id,
|
||||||
name,
|
name,
|
||||||
context),
|
context),
|
||||||
|
@ -73,24 +73,24 @@ impl BluetoothDevice {
|
||||||
BluetoothDeviceBinding::Wrap)
|
BluetoothDeviceBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_gatt(&self) -> Root<BluetoothRemoteGATTServer> {
|
pub fn get_gatt(&self) -> DomRoot<BluetoothRemoteGATTServer> {
|
||||||
self.gatt.or_init(|| {
|
self.gatt.or_init(|| {
|
||||||
BluetoothRemoteGATTServer::new(&self.global(), self)
|
BluetoothRemoteGATTServer::new(&self.global(), self)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_context(&self) -> Root<Bluetooth> {
|
fn get_context(&self) -> DomRoot<Bluetooth> {
|
||||||
Root::from_ref(&self.context)
|
DomRoot::from_ref(&self.context)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_or_create_service(&self,
|
pub fn get_or_create_service(&self,
|
||||||
service: &BluetoothServiceMsg,
|
service: &BluetoothServiceMsg,
|
||||||
server: &BluetoothRemoteGATTServer)
|
server: &BluetoothRemoteGATTServer)
|
||||||
-> Root<BluetoothRemoteGATTService> {
|
-> DomRoot<BluetoothRemoteGATTService> {
|
||||||
let (ref service_map_ref, _, _) = self.attribute_instance_map;
|
let (ref service_map_ref, _, _) = self.attribute_instance_map;
|
||||||
let mut service_map = service_map_ref.borrow_mut();
|
let mut service_map = service_map_ref.borrow_mut();
|
||||||
if let Some(existing_service) = service_map.get(&service.instance_id) {
|
if let Some(existing_service) = service_map.get(&service.instance_id) {
|
||||||
return Root::from_ref(&existing_service);
|
return DomRoot::from_ref(&existing_service);
|
||||||
}
|
}
|
||||||
let bt_service = BluetoothRemoteGATTService::new(&server.global(),
|
let bt_service = BluetoothRemoteGATTService::new(&server.global(),
|
||||||
&server.Device(),
|
&server.Device(),
|
||||||
|
@ -104,11 +104,11 @@ impl BluetoothDevice {
|
||||||
pub fn get_or_create_characteristic(&self,
|
pub fn get_or_create_characteristic(&self,
|
||||||
characteristic: &BluetoothCharacteristicMsg,
|
characteristic: &BluetoothCharacteristicMsg,
|
||||||
service: &BluetoothRemoteGATTService)
|
service: &BluetoothRemoteGATTService)
|
||||||
-> Root<BluetoothRemoteGATTCharacteristic> {
|
-> DomRoot<BluetoothRemoteGATTCharacteristic> {
|
||||||
let (_, ref characteristic_map_ref, _) = self.attribute_instance_map;
|
let (_, ref characteristic_map_ref, _) = self.attribute_instance_map;
|
||||||
let mut characteristic_map = characteristic_map_ref.borrow_mut();
|
let mut characteristic_map = characteristic_map_ref.borrow_mut();
|
||||||
if let Some(existing_characteristic) = characteristic_map.get(&characteristic.instance_id) {
|
if let Some(existing_characteristic) = characteristic_map.get(&characteristic.instance_id) {
|
||||||
return Root::from_ref(&existing_characteristic);
|
return DomRoot::from_ref(&existing_characteristic);
|
||||||
}
|
}
|
||||||
let properties =
|
let properties =
|
||||||
BluetoothCharacteristicProperties::new(&service.global(),
|
BluetoothCharacteristicProperties::new(&service.global(),
|
||||||
|
@ -140,11 +140,11 @@ impl BluetoothDevice {
|
||||||
pub fn get_or_create_descriptor(&self,
|
pub fn get_or_create_descriptor(&self,
|
||||||
descriptor: &BluetoothDescriptorMsg,
|
descriptor: &BluetoothDescriptorMsg,
|
||||||
characteristic: &BluetoothRemoteGATTCharacteristic)
|
characteristic: &BluetoothRemoteGATTCharacteristic)
|
||||||
-> Root<BluetoothRemoteGATTDescriptor> {
|
-> DomRoot<BluetoothRemoteGATTDescriptor> {
|
||||||
let (_, _, ref descriptor_map_ref) = self.attribute_instance_map;
|
let (_, _, ref descriptor_map_ref) = self.attribute_instance_map;
|
||||||
let mut descriptor_map = descriptor_map_ref.borrow_mut();
|
let mut descriptor_map = descriptor_map_ref.borrow_mut();
|
||||||
if let Some(existing_descriptor) = descriptor_map.get(&descriptor.instance_id) {
|
if let Some(existing_descriptor) = descriptor_map.get(&descriptor.instance_id) {
|
||||||
return Root::from_ref(&existing_descriptor);
|
return DomRoot::from_ref(&existing_descriptor);
|
||||||
}
|
}
|
||||||
let bt_descriptor = BluetoothRemoteGATTDescriptor::new(&characteristic.global(),
|
let bt_descriptor = BluetoothRemoteGATTDescriptor::new(&characteristic.global(),
|
||||||
characteristic,
|
characteristic,
|
||||||
|
@ -225,7 +225,7 @@ impl BluetoothDeviceMethods for BluetoothDevice {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-gatt
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-gatt
|
||||||
fn GetGatt(&self) -> Option<Root<BluetoothRemoteGATTServer>> {
|
fn GetGatt(&self) -> Option<DomRoot<BluetoothRemoteGATTServer>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if self.global().as_window().bluetooth_extra_permission_data()
|
if self.global().as_window().bluetooth_extra_permission_data()
|
||||||
.allowed_devices_contains_id(self.id.clone()) && !self.is_represented_device_null() {
|
.allowed_devices_contains_id(self.id.clone()) && !self.is_represented_device_null() {
|
||||||
|
|
|
@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionStatusB
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::error::Error;
|
use dom::bindings::error::Error;
|
||||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bluetooth::{AsyncBluetoothListener, Bluetooth, AllowedBluetoothDevice};
|
use dom::bluetooth::{AsyncBluetoothListener, Bluetooth, AllowedBluetoothDevice};
|
||||||
use dom::bluetoothdevice::BluetoothDevice;
|
use dom::bluetoothdevice::BluetoothDevice;
|
||||||
|
@ -40,13 +40,13 @@ impl BluetoothPermissionResult {
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, status: &PermissionStatus) -> Root<BluetoothPermissionResult> {
|
pub fn new(global: &GlobalScope, status: &PermissionStatus) -> DomRoot<BluetoothPermissionResult> {
|
||||||
reflect_dom_object(box BluetoothPermissionResult::new_inherited(status),
|
reflect_dom_object(box BluetoothPermissionResult::new_inherited(status),
|
||||||
global,
|
global,
|
||||||
BluetoothPermissionResultBinding::Wrap)
|
BluetoothPermissionResultBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_bluetooth(&self) -> Root<Bluetooth> {
|
pub fn get_bluetooth(&self) -> DomRoot<Bluetooth> {
|
||||||
self.global().as_window().Navigator().Bluetooth()
|
self.global().as_window().Navigator().Bluetooth()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,9 +74,9 @@ impl BluetoothPermissionResult {
|
||||||
|
|
||||||
impl BluetoothPermissionResultMethods for BluetoothPermissionResult {
|
impl BluetoothPermissionResultMethods for BluetoothPermissionResult {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothpermissionresult-devices
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothpermissionresult-devices
|
||||||
fn Devices(&self) -> Vec<Root<BluetoothDevice>> {
|
fn Devices(&self) -> Vec<DomRoot<BluetoothDevice>> {
|
||||||
let device_vec: Vec<Root<BluetoothDevice>> =
|
let device_vec: Vec<DomRoot<BluetoothDevice>> =
|
||||||
self.devices.borrow().iter().map(|d| Root::from_ref(&**d)).collect();
|
self.devices.borrow().iter().map(|d| DomRoot::from_ref(&**d)).collect();
|
||||||
device_vec
|
device_vec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::Bluetoo
|
||||||
use dom::bindings::error::Error::{self, InvalidModification, Network, NotSupported, Security};
|
use dom::bindings::error::Error::{self, InvalidModification, Network, NotSupported, Security};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::{ByteString, DOMString};
|
use dom::bindings::str::{ByteString, DOMString};
|
||||||
use dom::bluetooth::{AsyncBluetoothListener, get_gatt_children, response_async};
|
use dom::bluetooth::{AsyncBluetoothListener, get_gatt_children, response_async};
|
||||||
use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
|
use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
|
||||||
|
@ -64,7 +64,7 @@ impl BluetoothRemoteGATTCharacteristic {
|
||||||
uuid: DOMString,
|
uuid: DOMString,
|
||||||
properties: &BluetoothCharacteristicProperties,
|
properties: &BluetoothCharacteristicProperties,
|
||||||
instanceID: String)
|
instanceID: String)
|
||||||
-> Root<BluetoothRemoteGATTCharacteristic> {
|
-> DomRoot<BluetoothRemoteGATTCharacteristic> {
|
||||||
reflect_dom_object(box BluetoothRemoteGATTCharacteristic::new_inherited(service,
|
reflect_dom_object(box BluetoothRemoteGATTCharacteristic::new_inherited(service,
|
||||||
uuid,
|
uuid,
|
||||||
properties,
|
properties,
|
||||||
|
@ -84,13 +84,13 @@ impl BluetoothRemoteGATTCharacteristic {
|
||||||
|
|
||||||
impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteristic {
|
impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteristic {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-properties
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-properties
|
||||||
fn Properties(&self) -> Root<BluetoothCharacteristicProperties> {
|
fn Properties(&self) -> DomRoot<BluetoothCharacteristicProperties> {
|
||||||
Root::from_ref(&self.properties)
|
DomRoot::from_ref(&self.properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-service
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-service
|
||||||
fn Service(&self) -> Root<BluetoothRemoteGATTService> {
|
fn Service(&self) -> DomRoot<BluetoothRemoteGATTService> {
|
||||||
Root::from_ref(&self.service)
|
DomRoot::from_ref(&self.service)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-uuid
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-uuid
|
||||||
|
|
|
@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::Bluetoot
|
||||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
||||||
use dom::bindings::error::Error::{self, InvalidModification, Network, Security};
|
use dom::bindings::error::Error::{self, InvalidModification, Network, Security};
|
||||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::{ByteString, DOMString};
|
use dom::bindings::str::{ByteString, DOMString};
|
||||||
use dom::bluetooth::{AsyncBluetoothListener, response_async};
|
use dom::bluetooth::{AsyncBluetoothListener, response_async};
|
||||||
use dom::bluetoothremotegattcharacteristic::{BluetoothRemoteGATTCharacteristic, MAXIMUM_ATTRIBUTE_LENGTH};
|
use dom::bluetoothremotegattcharacteristic::{BluetoothRemoteGATTCharacteristic, MAXIMUM_ATTRIBUTE_LENGTH};
|
||||||
|
@ -51,7 +51,7 @@ impl BluetoothRemoteGATTDescriptor {
|
||||||
characteristic: &BluetoothRemoteGATTCharacteristic,
|
characteristic: &BluetoothRemoteGATTCharacteristic,
|
||||||
uuid: DOMString,
|
uuid: DOMString,
|
||||||
instanceID: String)
|
instanceID: String)
|
||||||
-> Root<BluetoothRemoteGATTDescriptor>{
|
-> DomRoot<BluetoothRemoteGATTDescriptor>{
|
||||||
reflect_dom_object(box BluetoothRemoteGATTDescriptor::new_inherited(characteristic,
|
reflect_dom_object(box BluetoothRemoteGATTDescriptor::new_inherited(characteristic,
|
||||||
uuid,
|
uuid,
|
||||||
instanceID),
|
instanceID),
|
||||||
|
@ -70,8 +70,8 @@ impl BluetoothRemoteGATTDescriptor {
|
||||||
|
|
||||||
impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
|
impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-characteristic
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-characteristic
|
||||||
fn Characteristic(&self) -> Root<BluetoothRemoteGATTCharacteristic> {
|
fn Characteristic(&self) -> DomRoot<BluetoothRemoteGATTCharacteristic> {
|
||||||
Root::from_ref(&self.characteristic)
|
DomRoot::from_ref(&self.characteristic)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-uuid
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-uuid
|
||||||
|
|
|
@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::Bluetoot
|
||||||
use dom::bindings::error::Error;
|
use dom::bindings::error::Error;
|
||||||
use dom::bindings::error::ErrorResult;
|
use dom::bindings::error::ErrorResult;
|
||||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bluetooth::{AsyncBluetoothListener, get_gatt_children, response_async};
|
use dom::bluetooth::{AsyncBluetoothListener, get_gatt_children, response_async};
|
||||||
use dom::bluetoothdevice::BluetoothDevice;
|
use dom::bluetoothdevice::BluetoothDevice;
|
||||||
use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
|
use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
|
||||||
|
@ -37,7 +37,7 @@ impl BluetoothRemoteGATTServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, device: &BluetoothDevice) -> Root<BluetoothRemoteGATTServer> {
|
pub fn new(global: &GlobalScope, device: &BluetoothDevice) -> DomRoot<BluetoothRemoteGATTServer> {
|
||||||
reflect_dom_object(box BluetoothRemoteGATTServer::new_inherited(device),
|
reflect_dom_object(box BluetoothRemoteGATTServer::new_inherited(device),
|
||||||
global,
|
global,
|
||||||
BluetoothRemoteGATTServerBinding::Wrap)
|
BluetoothRemoteGATTServerBinding::Wrap)
|
||||||
|
@ -54,8 +54,8 @@ impl BluetoothRemoteGATTServer {
|
||||||
|
|
||||||
impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
|
impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-device
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-device
|
||||||
fn Device(&self) -> Root<BluetoothDevice> {
|
fn Device(&self) -> DomRoot<BluetoothDevice> {
|
||||||
Root::from_ref(&self.device)
|
DomRoot::from_ref(&self.device)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connected
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connected
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding;
|
||||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
||||||
use dom::bindings::error::Error;
|
use dom::bindings::error::Error;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bluetooth::{AsyncBluetoothListener, get_gatt_children};
|
use dom::bluetooth::{AsyncBluetoothListener, get_gatt_children};
|
||||||
use dom::bluetoothdevice::BluetoothDevice;
|
use dom::bluetoothdevice::BluetoothDevice;
|
||||||
|
@ -49,7 +49,7 @@ impl BluetoothRemoteGATTService {
|
||||||
uuid: DOMString,
|
uuid: DOMString,
|
||||||
isPrimary: bool,
|
isPrimary: bool,
|
||||||
instanceID: String)
|
instanceID: String)
|
||||||
-> Root<BluetoothRemoteGATTService> {
|
-> DomRoot<BluetoothRemoteGATTService> {
|
||||||
reflect_dom_object(box BluetoothRemoteGATTService::new_inherited(device,
|
reflect_dom_object(box BluetoothRemoteGATTService::new_inherited(device,
|
||||||
uuid,
|
uuid,
|
||||||
isPrimary,
|
isPrimary,
|
||||||
|
@ -65,8 +65,8 @@ impl BluetoothRemoteGATTService {
|
||||||
|
|
||||||
impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {
|
impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-device
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-device
|
||||||
fn Device(&self) -> Root<BluetoothDevice> {
|
fn Device(&self) -> DomRoot<BluetoothDevice> {
|
||||||
Root::from_ref(&self.device)
|
DomRoot::from_ref(&self.device)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-isprimary
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-isprimary
|
||||||
|
|
|
@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::CanvasGradientBinding::CanvasGradientMetho
|
||||||
use dom::bindings::error::{Error, ErrorResult};
|
use dom::bindings::error::{Error, ErrorResult};
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -39,7 +39,7 @@ impl CanvasGradient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, style: CanvasGradientStyle) -> Root<CanvasGradient> {
|
pub fn new(global: &GlobalScope, style: CanvasGradientStyle) -> DomRoot<CanvasGradient> {
|
||||||
reflect_dom_object(box CanvasGradient::new_inherited(style),
|
reflect_dom_object(box CanvasGradient::new_inherited(style),
|
||||||
global,
|
global,
|
||||||
CanvasGradientBinding::Wrap)
|
CanvasGradientBinding::Wrap)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use canvas_traits::canvas::{FillOrStrokeStyle, RepetitionStyle, SurfaceStyle};
|
use canvas_traits::canvas::{FillOrStrokeStyle, RepetitionStyle, SurfaceStyle};
|
||||||
use dom::bindings::codegen::Bindings::CanvasPatternBinding;
|
use dom::bindings::codegen::Bindings::CanvasPatternBinding;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::canvasgradient::ToFillOrStrokeStyle;
|
use dom::canvasgradient::ToFillOrStrokeStyle;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -49,7 +49,7 @@ impl CanvasPattern {
|
||||||
surface_size: Size2D<i32>,
|
surface_size: Size2D<i32>,
|
||||||
repeat: RepetitionStyle,
|
repeat: RepetitionStyle,
|
||||||
origin_clean: bool)
|
origin_clean: bool)
|
||||||
-> Root<CanvasPattern> {
|
-> DomRoot<CanvasPattern> {
|
||||||
reflect_dom_object(box CanvasPattern::new_inherited(surface_data, surface_size,
|
reflect_dom_object(box CanvasPattern::new_inherited(surface_data, surface_size,
|
||||||
repeat, origin_clean),
|
repeat, origin_clean),
|
||||||
global,
|
global,
|
||||||
|
|
|
@ -23,7 +23,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, LayoutDom, Root};
|
use dom::bindings::root::{Dom, DomRoot, LayoutDom};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::canvasgradient::{CanvasGradient, CanvasGradientStyle, ToFillOrStrokeStyle};
|
use dom::canvasgradient::{CanvasGradient, CanvasGradientStyle, ToFillOrStrokeStyle};
|
||||||
use dom::canvaspattern::CanvasPattern;
|
use dom::canvaspattern::CanvasPattern;
|
||||||
|
@ -151,7 +151,7 @@ impl CanvasRenderingContext2D {
|
||||||
pub fn new(global: &GlobalScope,
|
pub fn new(global: &GlobalScope,
|
||||||
canvas: &HTMLCanvasElement,
|
canvas: &HTMLCanvasElement,
|
||||||
size: Size2D<i32>)
|
size: Size2D<i32>)
|
||||||
-> Root<CanvasRenderingContext2D> {
|
-> DomRoot<CanvasRenderingContext2D> {
|
||||||
let window = window_from_node(canvas);
|
let window = window_from_node(canvas);
|
||||||
let image_cache = window.image_cache();
|
let image_cache = window.image_cache();
|
||||||
let base_url = window.get_url();
|
let base_url = window.get_url();
|
||||||
|
@ -603,10 +603,10 @@ impl LayoutCanvasRenderingContext2DHelpers for LayoutDom<CanvasRenderingContext2
|
||||||
// FIXME: this behavior should might be generated by some annotattions to idl.
|
// FIXME: this behavior should might be generated by some annotattions to idl.
|
||||||
impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-canvas
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-canvas
|
||||||
fn Canvas(&self) -> Root<HTMLCanvasElement> {
|
fn Canvas(&self) -> DomRoot<HTMLCanvasElement> {
|
||||||
// This method is not called from a paint worklet rendering context,
|
// This method is not called from a paint worklet rendering context,
|
||||||
// so it's OK to panic if self.canvas is None.
|
// so it's OK to panic if self.canvas is None.
|
||||||
Root::from_ref(self.canvas.as_ref().expect("No canvas."))
|
DomRoot::from_ref(self.canvas.as_ref().expect("No canvas."))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-save
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-save
|
||||||
|
@ -997,10 +997,10 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
StringOrCanvasGradientOrCanvasPattern::String(DOMString::from(result))
|
StringOrCanvasGradientOrCanvasPattern::String(DOMString::from(result))
|
||||||
},
|
},
|
||||||
CanvasFillOrStrokeStyle::Gradient(ref gradient) => {
|
CanvasFillOrStrokeStyle::Gradient(ref gradient) => {
|
||||||
StringOrCanvasGradientOrCanvasPattern::CanvasGradient(Root::from_ref(&*gradient))
|
StringOrCanvasGradientOrCanvasPattern::CanvasGradient(DomRoot::from_ref(&*gradient))
|
||||||
},
|
},
|
||||||
CanvasFillOrStrokeStyle::Pattern(ref pattern) => {
|
CanvasFillOrStrokeStyle::Pattern(ref pattern) => {
|
||||||
StringOrCanvasGradientOrCanvasPattern::CanvasPattern(Root::from_ref(&*pattern))
|
StringOrCanvasGradientOrCanvasPattern::CanvasPattern(DomRoot::from_ref(&*pattern))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1046,10 +1046,10 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
StringOrCanvasGradientOrCanvasPattern::String(DOMString::from(result))
|
StringOrCanvasGradientOrCanvasPattern::String(DOMString::from(result))
|
||||||
},
|
},
|
||||||
CanvasFillOrStrokeStyle::Gradient(ref gradient) => {
|
CanvasFillOrStrokeStyle::Gradient(ref gradient) => {
|
||||||
StringOrCanvasGradientOrCanvasPattern::CanvasGradient(Root::from_ref(&*gradient))
|
StringOrCanvasGradientOrCanvasPattern::CanvasGradient(DomRoot::from_ref(&*gradient))
|
||||||
},
|
},
|
||||||
CanvasFillOrStrokeStyle::Pattern(ref pattern) => {
|
CanvasFillOrStrokeStyle::Pattern(ref pattern) => {
|
||||||
StringOrCanvasGradientOrCanvasPattern::CanvasPattern(Root::from_ref(&*pattern))
|
StringOrCanvasGradientOrCanvasPattern::CanvasPattern(DomRoot::from_ref(&*pattern))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1087,7 +1087,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
||||||
fn CreateImageData(&self, sw: Finite<f64>, sh: Finite<f64>) -> Fallible<Root<ImageData>> {
|
fn CreateImageData(&self, sw: Finite<f64>, sh: Finite<f64>) -> Fallible<DomRoot<ImageData>> {
|
||||||
if *sw == 0.0 || *sh == 0.0 {
|
if *sw == 0.0 || *sh == 0.0 {
|
||||||
return Err(Error::IndexSize);
|
return Err(Error::IndexSize);
|
||||||
}
|
}
|
||||||
|
@ -1098,7 +1098,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
||||||
fn CreateImageData_(&self, imagedata: &ImageData) -> Fallible<Root<ImageData>> {
|
fn CreateImageData_(&self, imagedata: &ImageData) -> Fallible<DomRoot<ImageData>> {
|
||||||
ImageData::new(&self.global(),
|
ImageData::new(&self.global(),
|
||||||
imagedata.Width(),
|
imagedata.Width(),
|
||||||
imagedata.Height(),
|
imagedata.Height(),
|
||||||
|
@ -1111,7 +1111,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
sy: Finite<f64>,
|
sy: Finite<f64>,
|
||||||
sw: Finite<f64>,
|
sw: Finite<f64>,
|
||||||
sh: Finite<f64>)
|
sh: Finite<f64>)
|
||||||
-> Fallible<Root<ImageData>> {
|
-> Fallible<DomRoot<ImageData>> {
|
||||||
if !self.origin_is_clean() {
|
if !self.origin_is_clean() {
|
||||||
return Err(Error::Security)
|
return Err(Error::Security)
|
||||||
}
|
}
|
||||||
|
@ -1198,7 +1198,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
y0: Finite<f64>,
|
y0: Finite<f64>,
|
||||||
x1: Finite<f64>,
|
x1: Finite<f64>,
|
||||||
y1: Finite<f64>)
|
y1: Finite<f64>)
|
||||||
-> Root<CanvasGradient> {
|
-> DomRoot<CanvasGradient> {
|
||||||
CanvasGradient::new(&self.global(),
|
CanvasGradient::new(&self.global(),
|
||||||
CanvasGradientStyle::Linear(LinearGradientStyle::new(*x0,
|
CanvasGradientStyle::Linear(LinearGradientStyle::new(*x0,
|
||||||
*y0,
|
*y0,
|
||||||
|
@ -1215,7 +1215,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
x1: Finite<f64>,
|
x1: Finite<f64>,
|
||||||
y1: Finite<f64>,
|
y1: Finite<f64>,
|
||||||
r1: Finite<f64>)
|
r1: Finite<f64>)
|
||||||
-> Fallible<Root<CanvasGradient>> {
|
-> Fallible<DomRoot<CanvasGradient>> {
|
||||||
if *r0 < 0. || *r1 < 0. {
|
if *r0 < 0. || *r1 < 0. {
|
||||||
return Err(Error::IndexSize);
|
return Err(Error::IndexSize);
|
||||||
}
|
}
|
||||||
|
@ -1234,7 +1234,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
fn CreatePattern(&self,
|
fn CreatePattern(&self,
|
||||||
image: CanvasImageSource,
|
image: CanvasImageSource,
|
||||||
mut repetition: DOMString)
|
mut repetition: DOMString)
|
||||||
-> Fallible<Root<CanvasPattern>> {
|
-> Fallible<DomRoot<CanvasPattern>> {
|
||||||
let (image_data, image_size) = match image {
|
let (image_data, image_size) = match image {
|
||||||
CanvasImageSource::HTMLImageElement(ref image) => {
|
CanvasImageSource::HTMLImageElement(ref image) => {
|
||||||
// https://html.spec.whatwg.org/multipage/#img-error
|
// https://html.spec.whatwg.org/multipage/#img-error
|
||||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::codegen::InheritTypes::{CharacterDataTypeId, NodeTypeId};
|
||||||
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::root::{LayoutDom, Root};
|
use dom::bindings::root::{DomRoot, LayoutDom};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::comment::Comment;
|
use dom::comment::Comment;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
|
@ -40,17 +40,17 @@ impl CharacterData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clone_with_data(&self, data: DOMString, document: &Document) -> Root<Node> {
|
pub fn clone_with_data(&self, data: DOMString, document: &Document) -> DomRoot<Node> {
|
||||||
match self.upcast::<Node>().type_id() {
|
match self.upcast::<Node>().type_id() {
|
||||||
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => {
|
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => {
|
||||||
Root::upcast(Comment::new(data, &document))
|
DomRoot::upcast(Comment::new(data, &document))
|
||||||
}
|
}
|
||||||
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => {
|
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => {
|
||||||
let pi = self.downcast::<ProcessingInstruction>().unwrap();
|
let pi = self.downcast::<ProcessingInstruction>().unwrap();
|
||||||
Root::upcast(ProcessingInstruction::new(pi.Target(), data, &document))
|
DomRoot::upcast(ProcessingInstruction::new(pi.Target(), data, &document))
|
||||||
},
|
},
|
||||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => {
|
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => {
|
||||||
Root::upcast(Text::new(data, &document))
|
DomRoot::upcast(Text::new(data, &document))
|
||||||
},
|
},
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
@ -237,13 +237,13 @@ impl CharacterDataMethods for CharacterData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-previouselementsibling
|
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-previouselementsibling
|
||||||
fn GetPreviousElementSibling(&self) -> Option<Root<Element>> {
|
fn GetPreviousElementSibling(&self) -> Option<DomRoot<Element>> {
|
||||||
self.upcast::<Node>().preceding_siblings().filter_map(Root::downcast).next()
|
self.upcast::<Node>().preceding_siblings().filter_map(DomRoot::downcast).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-nextelementsibling
|
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-nextelementsibling
|
||||||
fn GetNextElementSibling(&self) -> Option<Root<Element>> {
|
fn GetNextElementSibling(&self) -> Option<DomRoot<Element>> {
|
||||||
self.upcast::<Node>().following_siblings().filter_map(Root::downcast).next()
|
self.upcast::<Node>().following_siblings().filter_map(DomRoot::downcast).next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::ClientBinding::{ClientMethods, Wrap};
|
use dom::bindings::codegen::Bindings::ClientBinding::{ClientMethods, Wrap};
|
||||||
use dom::bindings::codegen::Bindings::ClientBinding::FrameType;
|
use dom::bindings::codegen::Bindings::ClientBinding::FrameType;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Root, MutNullableDom};
|
use dom::bindings::root::{DomRoot, MutNullableDom};
|
||||||
use dom::bindings::str::{DOMString, USVString};
|
use dom::bindings::str::{DOMString, USVString};
|
||||||
use dom::serviceworker::ServiceWorker;
|
use dom::serviceworker::ServiceWorker;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
@ -35,7 +35,7 @@ impl Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(window: &Window) -> Root<Client> {
|
pub fn new(window: &Window) -> DomRoot<Client> {
|
||||||
reflect_dom_object(box Client::new_inherited(window.get_url()),
|
reflect_dom_object(box Client::new_inherited(window.get_url()),
|
||||||
window,
|
window,
|
||||||
Wrap)
|
Wrap)
|
||||||
|
@ -45,7 +45,7 @@ impl Client {
|
||||||
self.url.clone()
|
self.url.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_controller(&self) -> Option<Root<ServiceWorker>> {
|
pub fn get_controller(&self) -> Option<DomRoot<ServiceWorker>> {
|
||||||
self.active_worker.get()
|
self.active_worker.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
|
@ -33,7 +33,7 @@ impl CloseEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<CloseEvent> {
|
pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<CloseEvent> {
|
||||||
reflect_dom_object(box CloseEvent::new_inherited(false, 0, DOMString::new()),
|
reflect_dom_object(box CloseEvent::new_inherited(false, 0, DOMString::new()),
|
||||||
global,
|
global,
|
||||||
CloseEventBinding::Wrap)
|
CloseEventBinding::Wrap)
|
||||||
|
@ -46,7 +46,7 @@ impl CloseEvent {
|
||||||
wasClean: bool,
|
wasClean: bool,
|
||||||
code: u16,
|
code: u16,
|
||||||
reason: DOMString)
|
reason: DOMString)
|
||||||
-> Root<CloseEvent> {
|
-> DomRoot<CloseEvent> {
|
||||||
let event = box CloseEvent::new_inherited(wasClean, code, reason);
|
let event = box CloseEvent::new_inherited(wasClean, code, reason);
|
||||||
let ev = reflect_dom_object(event, global, CloseEventBinding::Wrap);
|
let ev = reflect_dom_object(event, global, CloseEventBinding::Wrap);
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ impl CloseEvent {
|
||||||
pub fn Constructor(global: &GlobalScope,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &CloseEventBinding::CloseEventInit)
|
init: &CloseEventBinding::CloseEventInit)
|
||||||
-> Fallible<Root<CloseEvent>> {
|
-> Fallible<DomRoot<CloseEvent>> {
|
||||||
let bubbles = EventBubbles::from(init.parent.bubbles);
|
let bubbles = EventBubbles::from(init.parent.bubbles);
|
||||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||||
Ok(CloseEvent::new(global,
|
Ok(CloseEvent::new(global,
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::CommentBinding;
|
use dom::bindings::codegen::Bindings::CommentBinding;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::characterdata::CharacterData;
|
use dom::characterdata::CharacterData;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
|
@ -26,13 +26,13 @@ impl Comment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(text: DOMString, document: &Document) -> Root<Comment> {
|
pub fn new(text: DOMString, document: &Document) -> DomRoot<Comment> {
|
||||||
Node::reflect_node(box Comment::new_inherited(text, document),
|
Node::reflect_node(box Comment::new_inherited(text, document),
|
||||||
document,
|
document,
|
||||||
CommentBinding::Wrap)
|
CommentBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(window: &Window, data: DOMString) -> Fallible<Root<Comment>> {
|
pub fn Constructor(window: &Window, data: DOMString) -> Fallible<DomRoot<Comment>> {
|
||||||
let document = window.Document();
|
let document = window.Document();
|
||||||
Ok(Comment::new(data, &document))
|
Ok(Comment::new(data, &document))
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::CompositionEventBinding::{self, Compositio
|
||||||
use dom::bindings::codegen::Bindings::UIEventBinding::UIEventBinding::UIEventMethods;
|
use dom::bindings::codegen::Bindings::UIEventBinding::UIEventBinding::UIEventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::{Root, RootedReference};
|
use dom::bindings::root::{DomRoot, RootedReference};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::uievent::UIEvent;
|
use dom::uievent::UIEvent;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
@ -25,7 +25,7 @@ impl CompositionEvent {
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
view: Option<&Window>,
|
view: Option<&Window>,
|
||||||
detail: i32,
|
detail: i32,
|
||||||
data: DOMString) -> Root<CompositionEvent> {
|
data: DOMString) -> DomRoot<CompositionEvent> {
|
||||||
let ev = reflect_dom_object(box CompositionEvent {
|
let ev = reflect_dom_object(box CompositionEvent {
|
||||||
uievent: UIEvent::new_inherited(),
|
uievent: UIEvent::new_inherited(),
|
||||||
data: data,
|
data: data,
|
||||||
|
@ -39,7 +39,7 @@ impl CompositionEvent {
|
||||||
pub fn Constructor(window: &Window,
|
pub fn Constructor(window: &Window,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &CompositionEventBinding::CompositionEventInit)
|
init: &CompositionEventBinding::CompositionEventInit)
|
||||||
-> Fallible<Root<CompositionEvent>> {
|
-> Fallible<DomRoot<CompositionEvent>> {
|
||||||
let event = CompositionEvent::new(window,
|
let event = CompositionEvent::new(window,
|
||||||
type_,
|
type_,
|
||||||
init.parent.parent.bubbles,
|
init.parent.parent.bubbles,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use dom::bindings::error::{report_pending_exception, throw_dom_exception};
|
use dom::bindings::error::{report_pending_exception, throw_dom_exception};
|
||||||
use dom::bindings::reflector::DomObject;
|
use dom::bindings::reflector::DomObject;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::customelementregistry::{is_valid_custom_element_name, upgrade_element};
|
use dom::customelementregistry::{is_valid_custom_element_name, upgrade_element};
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::element::{CustomElementCreationMode, CustomElementState, Element, ElementCreator};
|
use dom::element::{CustomElementCreationMode, CustomElementState, Element, ElementCreator};
|
||||||
|
@ -87,17 +87,17 @@ use servo_config::prefs::PREFS;
|
||||||
fn create_svg_element(name: QualName,
|
fn create_svg_element(name: QualName,
|
||||||
prefix: Option<Prefix>,
|
prefix: Option<Prefix>,
|
||||||
document: &Document)
|
document: &Document)
|
||||||
-> Root<Element> {
|
-> DomRoot<Element> {
|
||||||
assert!(name.ns == ns!(svg));
|
assert!(name.ns == ns!(svg));
|
||||||
|
|
||||||
macro_rules! make(
|
macro_rules! make(
|
||||||
($ctor:ident) => ({
|
($ctor:ident) => ({
|
||||||
let obj = $ctor::new(name.local, prefix, document);
|
let obj = $ctor::new(name.local, prefix, document);
|
||||||
Root::upcast(obj)
|
DomRoot::upcast(obj)
|
||||||
});
|
});
|
||||||
($ctor:ident, $($arg:expr),+) => ({
|
($ctor:ident, $($arg:expr),+) => ({
|
||||||
let obj = $ctor::new(name.local, prefix, document, $($arg),+);
|
let obj = $ctor::new(name.local, prefix, document, $($arg),+);
|
||||||
Root::upcast(obj)
|
DomRoot::upcast(obj)
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ fn create_html_element(name: QualName,
|
||||||
document: &Document,
|
document: &Document,
|
||||||
creator: ElementCreator,
|
creator: ElementCreator,
|
||||||
mode: CustomElementCreationMode)
|
mode: CustomElementCreationMode)
|
||||||
-> Root<Element> {
|
-> DomRoot<Element> {
|
||||||
assert!(name.ns == ns!(html));
|
assert!(name.ns == ns!(html));
|
||||||
|
|
||||||
// Step 4
|
// Step 4
|
||||||
|
@ -129,7 +129,7 @@ fn create_html_element(name: QualName,
|
||||||
if definition.is_autonomous() {
|
if definition.is_autonomous() {
|
||||||
match mode {
|
match mode {
|
||||||
CustomElementCreationMode::Asynchronous => {
|
CustomElementCreationMode::Asynchronous => {
|
||||||
let result = Root::upcast::<Element>(
|
let result = DomRoot::upcast::<Element>(
|
||||||
HTMLElement::new(name.local.clone(), prefix.clone(), document));
|
HTMLElement::new(name.local.clone(), prefix.clone(), document));
|
||||||
result.set_custom_element_state(CustomElementState::Undefined);
|
result.set_custom_element_state(CustomElementState::Undefined);
|
||||||
ScriptThread::enqueue_upgrade_reaction(&*result, definition);
|
ScriptThread::enqueue_upgrade_reaction(&*result, definition);
|
||||||
|
@ -155,7 +155,7 @@ fn create_html_element(name: QualName,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 6.1.2
|
// Step 6.1.2
|
||||||
let element = Root::upcast::<Element>(
|
let element = DomRoot::upcast::<Element>(
|
||||||
HTMLUnknownElement::new(local_name, prefix, document));
|
HTMLUnknownElement::new(local_name, prefix, document));
|
||||||
element.set_custom_element_state(CustomElementState::Failed);
|
element.set_custom_element_state(CustomElementState::Failed);
|
||||||
element
|
element
|
||||||
|
@ -195,17 +195,17 @@ pub fn create_native_html_element(name: QualName,
|
||||||
prefix: Option<Prefix>,
|
prefix: Option<Prefix>,
|
||||||
document: &Document,
|
document: &Document,
|
||||||
creator: ElementCreator)
|
creator: ElementCreator)
|
||||||
-> Root<Element> {
|
-> DomRoot<Element> {
|
||||||
assert!(name.ns == ns!(html));
|
assert!(name.ns == ns!(html));
|
||||||
|
|
||||||
macro_rules! make(
|
macro_rules! make(
|
||||||
($ctor:ident) => ({
|
($ctor:ident) => ({
|
||||||
let obj = $ctor::new(name.local, prefix, document);
|
let obj = $ctor::new(name.local, prefix, document);
|
||||||
Root::upcast(obj)
|
DomRoot::upcast(obj)
|
||||||
});
|
});
|
||||||
($ctor:ident, $($arg:expr),+) => ({
|
($ctor:ident, $($arg:expr),+) => ({
|
||||||
let obj = $ctor::new(name.local, prefix, document, $($arg),+);
|
let obj = $ctor::new(name.local, prefix, document, $($arg),+);
|
||||||
Root::upcast(obj)
|
DomRoot::upcast(obj)
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ pub fn create_element(name: QualName,
|
||||||
document: &Document,
|
document: &Document,
|
||||||
creator: ElementCreator,
|
creator: ElementCreator,
|
||||||
mode: CustomElementCreationMode)
|
mode: CustomElementCreationMode)
|
||||||
-> Root<Element> {
|
-> DomRoot<Element> {
|
||||||
let prefix = name.prefix.clone();
|
let prefix = name.prefix.clone();
|
||||||
match name.ns {
|
match name.ns {
|
||||||
ns!(html) => create_html_element(name, prefix, is, document, creator, mode),
|
ns!(html) => create_html_element(name, prefix, is, document, creator, mode),
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::CryptoBinding;
|
||||||
use dom::bindings::codegen::Bindings::CryptoBinding::CryptoMethods;
|
use dom::bindings::codegen::Bindings::CryptoBinding::CryptoMethods;
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::jsapi::{JSContext, JSObject};
|
use js::jsapi::{JSContext, JSObject};
|
||||||
|
@ -33,7 +33,7 @@ impl Crypto {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope) -> Root<Crypto> {
|
pub fn new(global: &GlobalScope) -> DomRoot<Crypto> {
|
||||||
reflect_dom_object(box Crypto::new_inherited(), global, CryptoBinding::Wrap)
|
reflect_dom_object(box Crypto::new_inherited(), global, CryptoBinding::Wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::CSSFontFaceRuleBinding;
|
use dom::bindings::codegen::Bindings::CSSFontFaceRuleBinding;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
||||||
use dom::cssstylesheet::CSSStyleSheet;
|
use dom::cssstylesheet::CSSStyleSheet;
|
||||||
|
@ -32,7 +32,7 @@ impl CSSFontFaceRule {
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
fontfacerule: Arc<Locked<FontFaceRule>>) -> Root<CSSFontFaceRule> {
|
fontfacerule: Arc<Locked<FontFaceRule>>) -> DomRoot<CSSFontFaceRule> {
|
||||||
reflect_dom_object(box CSSFontFaceRule::new_inherited(parent_stylesheet, fontfacerule),
|
reflect_dom_object(box CSSFontFaceRule::new_inherited(parent_stylesheet, fontfacerule),
|
||||||
window,
|
window,
|
||||||
CSSFontFaceRuleBinding::Wrap)
|
CSSFontFaceRuleBinding::Wrap)
|
||||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::CSSGroupingRuleBinding::CSSGroupingRuleMet
|
||||||
use dom::bindings::error::{ErrorResult, Fallible};
|
use dom::bindings::error::{ErrorResult, Fallible};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::DomObject;
|
use dom::bindings::reflector::DomObject;
|
||||||
use dom::bindings::root::{MutNullableDom, Root};
|
use dom::bindings::root::{DomRoot, MutNullableDom};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssrule::CSSRule;
|
use dom::cssrule::CSSRule;
|
||||||
use dom::cssrulelist::{CSSRuleList, RulesSource};
|
use dom::cssrulelist::{CSSRuleList, RulesSource};
|
||||||
|
@ -34,7 +34,7 @@ impl CSSGroupingRule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rulelist(&self) -> Root<CSSRuleList> {
|
fn rulelist(&self) -> DomRoot<CSSRuleList> {
|
||||||
let parent_stylesheet = self.upcast::<CSSRule>().parent_stylesheet();
|
let parent_stylesheet = self.upcast::<CSSRule>().parent_stylesheet();
|
||||||
self.rulelist.or_init(|| CSSRuleList::new(self.global().as_window(),
|
self.rulelist.or_init(|| CSSRuleList::new(self.global().as_window(),
|
||||||
parent_stylesheet,
|
parent_stylesheet,
|
||||||
|
@ -52,7 +52,7 @@ impl CSSGroupingRule {
|
||||||
|
|
||||||
impl CSSGroupingRuleMethods for CSSGroupingRule {
|
impl CSSGroupingRuleMethods for CSSGroupingRule {
|
||||||
// https://drafts.csswg.org/cssom/#dom-cssgroupingrule-cssrules
|
// https://drafts.csswg.org/cssom/#dom-cssgroupingrule-cssrules
|
||||||
fn CssRules(&self) -> Root<CSSRuleList> {
|
fn CssRules(&self) -> DomRoot<CSSRuleList> {
|
||||||
// XXXManishearth check origin clean flag
|
// XXXManishearth check origin clean flag
|
||||||
self.rulelist()
|
self.rulelist()
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::CSSImportRuleBinding;
|
use dom::bindings::codegen::Bindings::CSSImportRuleBinding;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
||||||
use dom::cssstylesheet::CSSStyleSheet;
|
use dom::cssstylesheet::CSSStyleSheet;
|
||||||
|
@ -34,7 +34,7 @@ impl CSSImportRule {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window,
|
pub fn new(window: &Window,
|
||||||
parent_stylesheet: &CSSStyleSheet,
|
parent_stylesheet: &CSSStyleSheet,
|
||||||
import_rule: Arc<Locked<ImportRule>>) -> Root<Self> {
|
import_rule: Arc<Locked<ImportRule>>) -> DomRoot<Self> {
|
||||||
reflect_dom_object(box Self::new_inherited(parent_stylesheet, import_rule),
|
reflect_dom_object(box Self::new_inherited(parent_stylesheet, import_rule),
|
||||||
window,
|
window,
|
||||||
CSSImportRuleBinding::Wrap)
|
CSSImportRuleBinding::Wrap)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::CSSKeyframeRuleBinding::{self, CSSKeyframeRuleMethods};
|
use dom::bindings::codegen::Bindings::CSSKeyframeRuleBinding::{self, CSSKeyframeRuleMethods};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, MutNullableDom, Root};
|
use dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
||||||
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
|
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
|
||||||
|
@ -36,7 +36,7 @@ impl CSSKeyframeRule {
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
keyframerule: Arc<Locked<Keyframe>>) -> Root<CSSKeyframeRule> {
|
keyframerule: Arc<Locked<Keyframe>>) -> DomRoot<CSSKeyframeRule> {
|
||||||
reflect_dom_object(box CSSKeyframeRule::new_inherited(parent_stylesheet, keyframerule),
|
reflect_dom_object(box CSSKeyframeRule::new_inherited(parent_stylesheet, keyframerule),
|
||||||
window,
|
window,
|
||||||
CSSKeyframeRuleBinding::Wrap)
|
CSSKeyframeRuleBinding::Wrap)
|
||||||
|
@ -45,7 +45,7 @@ impl CSSKeyframeRule {
|
||||||
|
|
||||||
impl CSSKeyframeRuleMethods for CSSKeyframeRule {
|
impl CSSKeyframeRuleMethods for CSSKeyframeRule {
|
||||||
// https://drafts.csswg.org/css-animations/#dom-csskeyframerule-style
|
// https://drafts.csswg.org/css-animations/#dom-csskeyframerule-style
|
||||||
fn Style(&self) -> Root<CSSStyleDeclaration> {
|
fn Style(&self) -> DomRoot<CSSStyleDeclaration> {
|
||||||
self.style_decl.or_init(|| {
|
self.style_decl.or_init(|| {
|
||||||
let guard = self.cssrule.shared_lock().read();
|
let guard = self.cssrule.shared_lock().read();
|
||||||
CSSStyleDeclaration::new(
|
CSSStyleDeclaration::new(
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding::CSSKeyframesRuleM
|
||||||
use dom::bindings::error::ErrorResult;
|
use dom::bindings::error::ErrorResult;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
use dom::bindings::root::{MutNullableDom, Root};
|
use dom::bindings::root::{DomRoot, MutNullableDom};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::csskeyframerule::CSSKeyframeRule;
|
use dom::csskeyframerule::CSSKeyframeRule;
|
||||||
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
||||||
|
@ -41,13 +41,13 @@ impl CSSKeyframesRule {
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
keyframesrule: Arc<Locked<KeyframesRule>>) -> Root<CSSKeyframesRule> {
|
keyframesrule: Arc<Locked<KeyframesRule>>) -> DomRoot<CSSKeyframesRule> {
|
||||||
reflect_dom_object(box CSSKeyframesRule::new_inherited(parent_stylesheet, keyframesrule),
|
reflect_dom_object(box CSSKeyframesRule::new_inherited(parent_stylesheet, keyframesrule),
|
||||||
window,
|
window,
|
||||||
CSSKeyframesRuleBinding::Wrap)
|
CSSKeyframesRuleBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rulelist(&self) -> Root<CSSRuleList> {
|
fn rulelist(&self) -> DomRoot<CSSRuleList> {
|
||||||
self.rulelist.or_init(|| {
|
self.rulelist.or_init(|| {
|
||||||
let parent_stylesheet = &self.upcast::<CSSRule>().parent_stylesheet();
|
let parent_stylesheet = &self.upcast::<CSSRule>().parent_stylesheet();
|
||||||
CSSRuleList::new(self.global().as_window(),
|
CSSRuleList::new(self.global().as_window(),
|
||||||
|
@ -76,7 +76,7 @@ impl CSSKeyframesRule {
|
||||||
|
|
||||||
impl CSSKeyframesRuleMethods for CSSKeyframesRule {
|
impl CSSKeyframesRuleMethods for CSSKeyframesRule {
|
||||||
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-cssrules
|
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-cssrules
|
||||||
fn CssRules(&self) -> Root<CSSRuleList> {
|
fn CssRules(&self) -> DomRoot<CSSRuleList> {
|
||||||
self.rulelist()
|
self.rulelist()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,10 +104,10 @@ impl CSSKeyframesRuleMethods for CSSKeyframesRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-findrule
|
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-findrule
|
||||||
fn FindRule(&self, selector: DOMString) -> Option<Root<CSSKeyframeRule>> {
|
fn FindRule(&self, selector: DOMString) -> Option<DomRoot<CSSKeyframeRule>> {
|
||||||
self.find_rule(&selector).and_then(|idx| {
|
self.find_rule(&selector).and_then(|idx| {
|
||||||
self.rulelist().item(idx as u32)
|
self.rulelist().item(idx as u32)
|
||||||
}).and_then(Root::downcast)
|
}).and_then(DomRoot::downcast)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-name
|
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-name
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::CSSMediaRuleBinding;
|
||||||
use dom::bindings::codegen::Bindings::CSSMediaRuleBinding::CSSMediaRuleMethods;
|
use dom::bindings::codegen::Bindings::CSSMediaRuleBinding::CSSMediaRuleMethods;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
use dom::bindings::root::{MutNullableDom, Root};
|
use dom::bindings::root::{DomRoot, MutNullableDom};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssconditionrule::CSSConditionRule;
|
use dom::cssconditionrule::CSSConditionRule;
|
||||||
use dom::cssrule::SpecificCSSRule;
|
use dom::cssrule::SpecificCSSRule;
|
||||||
|
@ -44,13 +44,13 @@ impl CSSMediaRule {
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
mediarule: Arc<Locked<MediaRule>>) -> Root<CSSMediaRule> {
|
mediarule: Arc<Locked<MediaRule>>) -> DomRoot<CSSMediaRule> {
|
||||||
reflect_dom_object(box CSSMediaRule::new_inherited(parent_stylesheet, mediarule),
|
reflect_dom_object(box CSSMediaRule::new_inherited(parent_stylesheet, mediarule),
|
||||||
window,
|
window,
|
||||||
CSSMediaRuleBinding::Wrap)
|
CSSMediaRuleBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn medialist(&self) -> Root<MediaList> {
|
fn medialist(&self) -> DomRoot<MediaList> {
|
||||||
self.medialist.or_init(|| {
|
self.medialist.or_init(|| {
|
||||||
let guard = self.cssconditionrule.shared_lock().read();
|
let guard = self.cssconditionrule.shared_lock().read();
|
||||||
MediaList::new(self.global().as_window(),
|
MediaList::new(self.global().as_window(),
|
||||||
|
@ -108,7 +108,7 @@ impl SpecificCSSRule for CSSMediaRule {
|
||||||
|
|
||||||
impl CSSMediaRuleMethods for CSSMediaRule {
|
impl CSSMediaRuleMethods for CSSMediaRule {
|
||||||
// https://drafts.csswg.org/cssom/#dom-cssgroupingrule-media
|
// https://drafts.csswg.org/cssom/#dom-cssgroupingrule-media
|
||||||
fn Media(&self) -> Root<MediaList> {
|
fn Media(&self) -> DomRoot<MediaList> {
|
||||||
self.medialist()
|
self.medialist()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding;
|
use dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding;
|
||||||
use dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding::CSSNamespaceRuleMethods;
|
use dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding::CSSNamespaceRuleMethods;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
||||||
use dom::cssstylesheet::CSSStyleSheet;
|
use dom::cssstylesheet::CSSStyleSheet;
|
||||||
|
@ -33,7 +33,7 @@ impl CSSNamespaceRule {
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
namespacerule: Arc<Locked<NamespaceRule>>) -> Root<CSSNamespaceRule> {
|
namespacerule: Arc<Locked<NamespaceRule>>) -> DomRoot<CSSNamespaceRule> {
|
||||||
reflect_dom_object(box CSSNamespaceRule::new_inherited(parent_stylesheet, namespacerule),
|
reflect_dom_object(box CSSNamespaceRule::new_inherited(parent_stylesheet, namespacerule),
|
||||||
window,
|
window,
|
||||||
CSSNamespaceRuleBinding::Wrap)
|
CSSNamespaceRuleBinding::Wrap)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods;
|
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::Reflector;
|
use dom::bindings::reflector::Reflector;
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssfontfacerule::CSSFontFaceRule;
|
use dom::cssfontfacerule::CSSFontFaceRule;
|
||||||
use dom::cssimportrule::CSSImportRule;
|
use dom::cssimportrule::CSSImportRule;
|
||||||
|
@ -72,19 +72,19 @@ impl CSSRule {
|
||||||
// Given a StyleCssRule, create a new instance of a derived class of
|
// Given a StyleCssRule, create a new instance of a derived class of
|
||||||
// CSSRule based on which rule it is
|
// CSSRule based on which rule it is
|
||||||
pub fn new_specific(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
pub fn new_specific(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
rule: StyleCssRule) -> Root<CSSRule> {
|
rule: StyleCssRule) -> DomRoot<CSSRule> {
|
||||||
// be sure to update the match in as_specific when this is updated
|
// be sure to update the match in as_specific when this is updated
|
||||||
match rule {
|
match rule {
|
||||||
StyleCssRule::Import(s) => Root::upcast(CSSImportRule::new(window, parent_stylesheet, s)),
|
StyleCssRule::Import(s) => DomRoot::upcast(CSSImportRule::new(window, parent_stylesheet, s)),
|
||||||
StyleCssRule::Style(s) => Root::upcast(CSSStyleRule::new(window, parent_stylesheet, s)),
|
StyleCssRule::Style(s) => DomRoot::upcast(CSSStyleRule::new(window, parent_stylesheet, s)),
|
||||||
StyleCssRule::FontFace(s) => Root::upcast(CSSFontFaceRule::new(window, parent_stylesheet, s)),
|
StyleCssRule::FontFace(s) => DomRoot::upcast(CSSFontFaceRule::new(window, parent_stylesheet, s)),
|
||||||
StyleCssRule::FontFeatureValues(_) => unimplemented!(),
|
StyleCssRule::FontFeatureValues(_) => unimplemented!(),
|
||||||
StyleCssRule::CounterStyle(_) => unimplemented!(),
|
StyleCssRule::CounterStyle(_) => unimplemented!(),
|
||||||
StyleCssRule::Keyframes(s) => Root::upcast(CSSKeyframesRule::new(window, parent_stylesheet, s)),
|
StyleCssRule::Keyframes(s) => DomRoot::upcast(CSSKeyframesRule::new(window, parent_stylesheet, s)),
|
||||||
StyleCssRule::Media(s) => Root::upcast(CSSMediaRule::new(window, parent_stylesheet, s)),
|
StyleCssRule::Media(s) => DomRoot::upcast(CSSMediaRule::new(window, parent_stylesheet, s)),
|
||||||
StyleCssRule::Namespace(s) => Root::upcast(CSSNamespaceRule::new(window, parent_stylesheet, s)),
|
StyleCssRule::Namespace(s) => DomRoot::upcast(CSSNamespaceRule::new(window, parent_stylesheet, s)),
|
||||||
StyleCssRule::Viewport(s) => Root::upcast(CSSViewportRule::new(window, parent_stylesheet, s)),
|
StyleCssRule::Viewport(s) => DomRoot::upcast(CSSViewportRule::new(window, parent_stylesheet, s)),
|
||||||
StyleCssRule::Supports(s) => Root::upcast(CSSSupportsRule::new(window, parent_stylesheet, s)),
|
StyleCssRule::Supports(s) => DomRoot::upcast(CSSSupportsRule::new(window, parent_stylesheet, s)),
|
||||||
StyleCssRule::Page(_) => unreachable!(),
|
StyleCssRule::Page(_) => unreachable!(),
|
||||||
StyleCssRule::Document(_) => unimplemented!(), // TODO
|
StyleCssRule::Document(_) => unimplemented!(), // TODO
|
||||||
}
|
}
|
||||||
|
@ -121,11 +121,11 @@ impl CSSRuleMethods for CSSRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom/#dom-cssrule-parentstylesheet
|
// https://drafts.csswg.org/cssom/#dom-cssrule-parentstylesheet
|
||||||
fn GetParentStyleSheet(&self) -> Option<Root<CSSStyleSheet>> {
|
fn GetParentStyleSheet(&self) -> Option<DomRoot<CSSStyleSheet>> {
|
||||||
if self.parent_stylesheet_removed.get() {
|
if self.parent_stylesheet_removed.get() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(Root::from_ref(&*self.parent_stylesheet))
|
Some(DomRoot::from_ref(&*self.parent_stylesheet))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::CSSRuleListBinding;
|
||||||
use dom::bindings::codegen::Bindings::CSSRuleListBinding::CSSRuleListMethods;
|
use dom::bindings::codegen::Bindings::CSSRuleListBinding::CSSRuleListMethods;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, MutNullableDom, Root};
|
use dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||||
use dom::csskeyframerule::CSSKeyframeRule;
|
use dom::csskeyframerule::CSSKeyframeRule;
|
||||||
use dom::cssrule::CSSRule;
|
use dom::cssrule::CSSRule;
|
||||||
use dom::cssstylesheet::CSSStyleSheet;
|
use dom::cssstylesheet::CSSStyleSheet;
|
||||||
|
@ -70,7 +70,7 @@ impl CSSRuleList {
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
rules: RulesSource) -> Root<CSSRuleList> {
|
rules: RulesSource) -> DomRoot<CSSRuleList> {
|
||||||
reflect_dom_object(box CSSRuleList::new_inherited(parent_stylesheet, rules),
|
reflect_dom_object(box CSSRuleList::new_inherited(parent_stylesheet, rules),
|
||||||
window,
|
window,
|
||||||
CSSRuleListBinding::Wrap)
|
CSSRuleListBinding::Wrap)
|
||||||
|
@ -133,11 +133,11 @@ impl CSSRuleList {
|
||||||
// Remove parent stylesheets from all children
|
// Remove parent stylesheets from all children
|
||||||
pub fn deparent_all(&self) {
|
pub fn deparent_all(&self) {
|
||||||
for rule in self.dom_rules.borrow().iter() {
|
for rule in self.dom_rules.borrow().iter() {
|
||||||
rule.get().map(|r| Root::upcast(r).deparent());
|
rule.get().map(|r| DomRoot::upcast(r).deparent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn item(&self, idx: u32) -> Option<Root<CSSRule>> {
|
pub fn item(&self, idx: u32) -> Option<DomRoot<CSSRule>> {
|
||||||
self.dom_rules.borrow().get(idx as usize).map(|rule| {
|
self.dom_rules.borrow().get(idx as usize).map(|rule| {
|
||||||
rule.or_init(|| {
|
rule.or_init(|| {
|
||||||
let parent_stylesheet = &self.parent_stylesheet;
|
let parent_stylesheet = &self.parent_stylesheet;
|
||||||
|
@ -149,7 +149,7 @@ impl CSSRuleList {
|
||||||
rules.read_with(&guard).0[idx as usize].clone())
|
rules.read_with(&guard).0[idx as usize].clone())
|
||||||
}
|
}
|
||||||
RulesSource::Keyframes(ref rules) => {
|
RulesSource::Keyframes(ref rules) => {
|
||||||
Root::upcast(CSSKeyframeRule::new(self.global().as_window(),
|
DomRoot::upcast(CSSKeyframeRule::new(self.global().as_window(),
|
||||||
parent_stylesheet,
|
parent_stylesheet,
|
||||||
rules.read_with(&guard)
|
rules.read_with(&guard)
|
||||||
.keyframes[idx as usize]
|
.keyframes[idx as usize]
|
||||||
|
@ -176,7 +176,7 @@ impl CSSRuleList {
|
||||||
|
|
||||||
impl CSSRuleListMethods for CSSRuleList {
|
impl CSSRuleListMethods for CSSRuleList {
|
||||||
// https://drafts.csswg.org/cssom/#ref-for-dom-cssrulelist-item-1
|
// https://drafts.csswg.org/cssom/#ref-for-dom-cssrulelist-item-1
|
||||||
fn Item(&self, idx: u32) -> Option<Root<CSSRule>> {
|
fn Item(&self, idx: u32) -> Option<DomRoot<CSSRule>> {
|
||||||
self.item(idx)
|
self.item(idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ impl CSSRuleListMethods for CSSRuleList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check-tidy: no specs after this line
|
// check-tidy: no specs after this line
|
||||||
fn IndexedGetter(&self, index: u32) -> Option<Root<CSSRule>> {
|
fn IndexedGetter(&self, index: u32) -> Option<DomRoot<CSSRule>> {
|
||||||
self.Item(index)
|
self.Item(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssrule::CSSRule;
|
use dom::cssrule::CSSRule;
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
|
@ -137,10 +137,10 @@ impl CSSStyleOwner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn window(&self) -> Root<Window> {
|
fn window(&self) -> DomRoot<Window> {
|
||||||
match *self {
|
match *self {
|
||||||
CSSStyleOwner::Element(ref el) => window_from_node(&**el),
|
CSSStyleOwner::Element(ref el) => window_from_node(&**el),
|
||||||
CSSStyleOwner::CSSRule(ref rule, _) => Root::from_ref(rule.global().as_window()),
|
CSSStyleOwner::CSSRule(ref rule, _) => DomRoot::from_ref(rule.global().as_window()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ impl CSSStyleDeclaration {
|
||||||
owner: CSSStyleOwner,
|
owner: CSSStyleOwner,
|
||||||
pseudo: Option<PseudoElement>,
|
pseudo: Option<PseudoElement>,
|
||||||
modification_access: CSSModificationAccess)
|
modification_access: CSSModificationAccess)
|
||||||
-> Root<CSSStyleDeclaration> {
|
-> DomRoot<CSSStyleDeclaration> {
|
||||||
reflect_dom_object(box CSSStyleDeclaration::new_inherited(owner,
|
reflect_dom_object(box CSSStyleDeclaration::new_inherited(owner,
|
||||||
pseudo,
|
pseudo,
|
||||||
modification_access),
|
modification_access),
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::CSSStyleRuleBinding::{self, CSSStyleRuleMe
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, MutNullableDom, Root};
|
use dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
||||||
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
|
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
|
||||||
|
@ -42,7 +42,7 @@ impl CSSStyleRule {
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
stylerule: Arc<Locked<StyleRule>>) -> Root<CSSStyleRule> {
|
stylerule: Arc<Locked<StyleRule>>) -> DomRoot<CSSStyleRule> {
|
||||||
reflect_dom_object(box CSSStyleRule::new_inherited(parent_stylesheet, stylerule),
|
reflect_dom_object(box CSSStyleRule::new_inherited(parent_stylesheet, stylerule),
|
||||||
window,
|
window,
|
||||||
CSSStyleRuleBinding::Wrap)
|
CSSStyleRuleBinding::Wrap)
|
||||||
|
@ -63,7 +63,7 @@ impl SpecificCSSRule for CSSStyleRule {
|
||||||
|
|
||||||
impl CSSStyleRuleMethods for CSSStyleRule {
|
impl CSSStyleRuleMethods for CSSStyleRule {
|
||||||
// https://drafts.csswg.org/cssom/#dom-cssstylerule-style
|
// https://drafts.csswg.org/cssom/#dom-cssstylerule-style
|
||||||
fn Style(&self) -> Root<CSSStyleDeclaration> {
|
fn Style(&self) -> DomRoot<CSSStyleDeclaration> {
|
||||||
self.style_decl.or_init(|| {
|
self.style_decl.or_init(|| {
|
||||||
let guard = self.cssrule.shared_lock().read();
|
let guard = self.cssrule.shared_lock().read();
|
||||||
CSSStyleDeclaration::new(
|
CSSStyleDeclaration::new(
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::CSSStyleSheetBinding::CSSStyleSheetMethods
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::reflector::{reflect_dom_object, DomObject};
|
use dom::bindings::reflector::{reflect_dom_object, DomObject};
|
||||||
use dom::bindings::root::{Dom, MutNullableDom, Root};
|
use dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssrulelist::{CSSRuleList, RulesSource};
|
use dom::cssrulelist::{CSSRuleList, RulesSource};
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
|
@ -50,13 +50,13 @@ impl CSSStyleSheet {
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
href: Option<DOMString>,
|
href: Option<DOMString>,
|
||||||
title: Option<DOMString>,
|
title: Option<DOMString>,
|
||||||
stylesheet: Arc<StyleStyleSheet>) -> Root<CSSStyleSheet> {
|
stylesheet: Arc<StyleStyleSheet>) -> DomRoot<CSSStyleSheet> {
|
||||||
reflect_dom_object(box CSSStyleSheet::new_inherited(owner, type_, href, title, stylesheet),
|
reflect_dom_object(box CSSStyleSheet::new_inherited(owner, type_, href, title, stylesheet),
|
||||||
window,
|
window,
|
||||||
CSSStyleSheetBinding::Wrap)
|
CSSStyleSheetBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rulelist(&self) -> Root<CSSRuleList> {
|
fn rulelist(&self) -> DomRoot<CSSRuleList> {
|
||||||
self.rulelist.or_init(|| {
|
self.rulelist.or_init(|| {
|
||||||
let rules = self.style_stylesheet.contents.rules.clone();
|
let rules = self.style_stylesheet.contents.rules.clone();
|
||||||
CSSRuleList::new(
|
CSSRuleList::new(
|
||||||
|
@ -92,7 +92,7 @@ impl CSSStyleSheet {
|
||||||
|
|
||||||
impl CSSStyleSheetMethods for CSSStyleSheet {
|
impl CSSStyleSheetMethods for CSSStyleSheet {
|
||||||
// https://drafts.csswg.org/cssom/#dom-cssstylesheet-cssrules
|
// https://drafts.csswg.org/cssom/#dom-cssstylesheet-cssrules
|
||||||
fn GetCssRules(&self) -> Fallible<Root<CSSRuleList>> {
|
fn GetCssRules(&self) -> Fallible<DomRoot<CSSRuleList>> {
|
||||||
if !self.origin_clean.get() {
|
if !self.origin_clean.get() {
|
||||||
return Err(Error::Security);
|
return Err(Error::Security);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::CSSStyleValueBinding::CSSStyleValueMethods
|
||||||
use dom::bindings::codegen::Bindings::CSSStyleValueBinding::Wrap;
|
use dom::bindings::codegen::Bindings::CSSStyleValueBinding::Wrap;
|
||||||
use dom::bindings::reflector::Reflector;
|
use dom::bindings::reflector::Reflector;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -28,7 +28,7 @@ impl CSSStyleValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, value: String) -> Root<CSSStyleValue> {
|
pub fn new(global: &GlobalScope, value: String) -> DomRoot<CSSStyleValue> {
|
||||||
reflect_dom_object(box CSSStyleValue::new_inherited(value), global, Wrap)
|
reflect_dom_object(box CSSStyleValue::new_inherited(value), global, Wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use cssparser::{Parser, ParserInput};
|
||||||
use dom::bindings::codegen::Bindings::CSSSupportsRuleBinding;
|
use dom::bindings::codegen::Bindings::CSSSupportsRuleBinding;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssconditionrule::CSSConditionRule;
|
use dom::cssconditionrule::CSSConditionRule;
|
||||||
use dom::cssrule::SpecificCSSRule;
|
use dom::cssrule::SpecificCSSRule;
|
||||||
|
@ -40,7 +40,7 @@ impl CSSSupportsRule {
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
supportsrule: Arc<Locked<SupportsRule>>) -> Root<CSSSupportsRule> {
|
supportsrule: Arc<Locked<SupportsRule>>) -> DomRoot<CSSSupportsRule> {
|
||||||
reflect_dom_object(box CSSSupportsRule::new_inherited(parent_stylesheet, supportsrule),
|
reflect_dom_object(box CSSSupportsRule::new_inherited(parent_stylesheet, supportsrule),
|
||||||
window,
|
window,
|
||||||
CSSSupportsRuleBinding::Wrap)
|
CSSSupportsRuleBinding::Wrap)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::CSSViewportRuleBinding;
|
use dom::bindings::codegen::Bindings::CSSViewportRuleBinding;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
||||||
use dom::cssstylesheet::CSSStyleSheet;
|
use dom::cssstylesheet::CSSStyleSheet;
|
||||||
|
@ -31,7 +31,7 @@ impl CSSViewportRule {
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||||
viewportrule: Arc<Locked<ViewportRule>>) -> Root<CSSViewportRule> {
|
viewportrule: Arc<Locked<ViewportRule>>) -> DomRoot<CSSViewportRule> {
|
||||||
reflect_dom_object(box CSSViewportRule::new_inherited(parent_stylesheet, viewportrule),
|
reflect_dom_object(box CSSViewportRule::new_inherited(parent_stylesheet, viewportrule),
|
||||||
window,
|
window,
|
||||||
CSSViewportRuleBinding::Wrap)
|
CSSViewportRuleBinding::Wrap)
|
||||||
|
|
|
@ -14,7 +14,7 @@ use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, Stringi
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible, report_pending_exception, throw_dom_exception};
|
use dom::bindings::error::{Error, ErrorResult, Fallible, report_pending_exception, throw_dom_exception};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::domexception::{DOMErrorName, DOMException};
|
use dom::domexception::{DOMErrorName, DOMException};
|
||||||
|
@ -67,7 +67,7 @@ impl CustomElementRegistry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(window: &Window) -> Root<CustomElementRegistry> {
|
pub fn new(window: &Window) -> DomRoot<CustomElementRegistry> {
|
||||||
reflect_dom_object(box CustomElementRegistry::new_inherited(window),
|
reflect_dom_object(box CustomElementRegistry::new_inherited(window),
|
||||||
window,
|
window,
|
||||||
CustomElementRegistryBinding::Wrap)
|
CustomElementRegistryBinding::Wrap)
|
||||||
|
@ -304,7 +304,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
|
||||||
let document = self.window.Document();
|
let document = self.window.Document();
|
||||||
|
|
||||||
// Steps 14-15
|
// Steps 14-15
|
||||||
for candidate in document.upcast::<Node>().traverse_preorder().filter_map(Root::downcast::<Element>) {
|
for candidate in document.upcast::<Node>().traverse_preorder().filter_map(DomRoot::downcast::<Element>) {
|
||||||
let is = candidate.get_is();
|
let is = candidate.get_is();
|
||||||
if *candidate.local_name() == local_name &&
|
if *candidate.local_name() == local_name &&
|
||||||
*candidate.namespace() == ns!(html) &&
|
*candidate.namespace() == ns!(html) &&
|
||||||
|
@ -386,7 +386,7 @@ pub struct LifecycleCallbacks {
|
||||||
|
|
||||||
#[derive(Clone, HeapSizeOf, JSTraceable)]
|
#[derive(Clone, HeapSizeOf, JSTraceable)]
|
||||||
pub enum ConstructionStackEntry {
|
pub enum ConstructionStackEntry {
|
||||||
Element(Root<Element>),
|
Element(DomRoot<Element>),
|
||||||
AlreadyConstructedMarker,
|
AlreadyConstructedMarker,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ impl CustomElementDefinition {
|
||||||
|
|
||||||
/// https://dom.spec.whatwg.org/#concept-create-element Step 6.1
|
/// https://dom.spec.whatwg.org/#concept-create-element Step 6.1
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn create_element(&self, document: &Document, prefix: Option<Prefix>) -> Fallible<Root<Element>> {
|
pub fn create_element(&self, document: &Document, prefix: Option<Prefix>) -> Fallible<DomRoot<Element>> {
|
||||||
let window = document.window();
|
let window = document.window();
|
||||||
let cx = window.get_cx();
|
let cx = window.get_cx();
|
||||||
// Step 2
|
// Step 2
|
||||||
|
@ -447,7 +447,7 @@ impl CustomElementDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
rooted!(in(cx) let element_val = ObjectValue(element.get()));
|
rooted!(in(cx) let element_val = ObjectValue(element.get()));
|
||||||
let element: Root<Element> = match unsafe { Root::from_jsval(cx, element_val.handle(), ()) } {
|
let element: DomRoot<Element> = match unsafe { DomRoot::from_jsval(cx, element_val.handle(), ()) } {
|
||||||
Ok(ConversionResult::Success(element)) => element,
|
Ok(ConversionResult::Success(element)) => element,
|
||||||
Ok(ConversionResult::Failure(..)) =>
|
Ok(ConversionResult::Failure(..)) =>
|
||||||
return Err(Error::Type("Constructor did not return a DOM node".to_owned())),
|
return Err(Error::Type("Constructor did not return a DOM node".to_owned())),
|
||||||
|
@ -504,7 +504,7 @@ pub fn upgrade_element(definition: Rc<CustomElementDefinition>, element: &Elemen
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 5
|
// Step 5
|
||||||
definition.construction_stack.borrow_mut().push(ConstructionStackEntry::Element(Root::from_ref(element)));
|
definition.construction_stack.borrow_mut().push(ConstructionStackEntry::Element(DomRoot::from_ref(element)));
|
||||||
|
|
||||||
// Step 7
|
// Step 7
|
||||||
let result = run_upgrade_constructor(&definition.constructor, element);
|
let result = run_upgrade_constructor(&definition.constructor, element);
|
||||||
|
@ -612,7 +612,7 @@ impl CustomElementReaction {
|
||||||
pub enum CallbackReaction {
|
pub enum CallbackReaction {
|
||||||
Connected,
|
Connected,
|
||||||
Disconnected,
|
Disconnected,
|
||||||
Adopted(Root<Document>, Root<Document>),
|
Adopted(DomRoot<Document>, DomRoot<Document>),
|
||||||
AttributeChanged(LocalName, Option<DOMString>, Option<DOMString>, Namespace),
|
AttributeChanged(LocalName, Option<DOMString>, Option<DOMString>, Namespace),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -795,8 +795,8 @@ impl ElementQueue {
|
||||||
self.queue.borrow_mut().clear();
|
self.queue.borrow_mut().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_element(&self) -> Option<Root<Element>> {
|
fn next_element(&self) -> Option<DomRoot<Element>> {
|
||||||
self.queue.borrow_mut().pop_front().as_ref().map(Dom::deref).map(Root::from_ref)
|
self.queue.borrow_mut().pop_front().as_ref().map(Dom::deref).map(DomRoot::from_ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn append_element(&self, element: &Element) {
|
fn append_element(&self, element: &Element) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bindings::trace::RootedTraceableBox;
|
use dom::bindings::trace::RootedTraceableBox;
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
|
@ -34,7 +34,7 @@ impl CustomEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<CustomEvent> {
|
pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<CustomEvent> {
|
||||||
reflect_dom_object(box CustomEvent::new_inherited(),
|
reflect_dom_object(box CustomEvent::new_inherited(),
|
||||||
global,
|
global,
|
||||||
CustomEventBinding::Wrap)
|
CustomEventBinding::Wrap)
|
||||||
|
@ -44,7 +44,7 @@ impl CustomEvent {
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
detail: HandleValue)
|
detail: HandleValue)
|
||||||
-> Root<CustomEvent> {
|
-> DomRoot<CustomEvent> {
|
||||||
let ev = CustomEvent::new_uninitialized(global);
|
let ev = CustomEvent::new_uninitialized(global);
|
||||||
ev.init_custom_event(type_, bubbles, cancelable, detail);
|
ev.init_custom_event(type_, bubbles, cancelable, detail);
|
||||||
ev
|
ev
|
||||||
|
@ -54,7 +54,7 @@ impl CustomEvent {
|
||||||
pub fn Constructor(global: &GlobalScope,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: RootedTraceableBox<CustomEventBinding::CustomEventInit>)
|
init: RootedTraceableBox<CustomEventBinding::CustomEventInit>)
|
||||||
-> Fallible<Root<CustomEvent>> {
|
-> Fallible<DomRoot<CustomEvent>> {
|
||||||
Ok(CustomEvent::new(global,
|
Ok(CustomEvent::new(global,
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding::Dedicat
|
||||||
use dom::bindings::error::{ErrorInfo, ErrorResult};
|
use dom::bindings::error::{ErrorInfo, ErrorResult};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::DomObject;
|
use dom::bindings::reflector::DomObject;
|
||||||
use dom::bindings::root::{Root, RootCollection};
|
use dom::bindings::root::{DomRoot, RootCollection};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bindings::structuredclone::StructuredCloneData;
|
use dom::bindings::structuredclone::StructuredCloneData;
|
||||||
use dom::errorevent::ErrorEvent;
|
use dom::errorevent::ErrorEvent;
|
||||||
|
@ -131,7 +131,7 @@ impl DedicatedWorkerGlobalScope {
|
||||||
timer_event_chan: IpcSender<TimerEvent>,
|
timer_event_chan: IpcSender<TimerEvent>,
|
||||||
timer_event_port: Receiver<(TrustedWorkerAddress, TimerEvent)>,
|
timer_event_port: Receiver<(TrustedWorkerAddress, TimerEvent)>,
|
||||||
closing: Arc<AtomicBool>)
|
closing: Arc<AtomicBool>)
|
||||||
-> Root<DedicatedWorkerGlobalScope> {
|
-> DomRoot<DedicatedWorkerGlobalScope> {
|
||||||
let cx = runtime.cx();
|
let cx = runtime.cx();
|
||||||
let scope = box DedicatedWorkerGlobalScope::new_inherited(init,
|
let scope = box DedicatedWorkerGlobalScope::new_inherited(init,
|
||||||
worker_url,
|
worker_url,
|
||||||
|
@ -387,7 +387,7 @@ impl DedicatedWorkerGlobalScope {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool {
|
unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool {
|
||||||
let worker =
|
let worker =
|
||||||
Root::downcast::<WorkerGlobalScope>(GlobalScope::from_context(cx))
|
DomRoot::downcast::<WorkerGlobalScope>(GlobalScope::from_context(cx))
|
||||||
.expect("global is not a worker scope");
|
.expect("global is not a worker scope");
|
||||||
assert!(worker.is::<DedicatedWorkerGlobalScope>());
|
assert!(worker.is::<DedicatedWorkerGlobalScope>());
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DissimilarOriginLocationBinding::Dissimila
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::reflector::Reflector;
|
use dom::bindings::reflector::Reflector;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bindings::str::USVString;
|
use dom::bindings::str::USVString;
|
||||||
use dom::dissimilaroriginwindow::DissimilarOriginWindow;
|
use dom::dissimilaroriginwindow::DissimilarOriginWindow;
|
||||||
|
@ -39,7 +39,7 @@ impl DissimilarOriginLocation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(window: &DissimilarOriginWindow) -> Root<DissimilarOriginLocation> {
|
pub fn new(window: &DissimilarOriginWindow) -> DomRoot<DissimilarOriginLocation> {
|
||||||
reflect_dom_object(box DissimilarOriginLocation::new_inherited(window),
|
reflect_dom_object(box DissimilarOriginLocation::new_inherited(window),
|
||||||
window,
|
window,
|
||||||
DissimilarOriginLocationBinding::Wrap)
|
DissimilarOriginLocationBinding::Wrap)
|
||||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding;
|
||||||
use dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding::DissimilarOriginWindowMethods;
|
use dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding::DissimilarOriginWindowMethods;
|
||||||
use dom::bindings::error::{Error, ErrorResult};
|
use dom::bindings::error::{Error, ErrorResult};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::root::{Dom, MutNullableDom, Root};
|
use dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bindings::structuredclone::StructuredCloneData;
|
use dom::bindings::structuredclone::StructuredCloneData;
|
||||||
use dom::dissimilaroriginlocation::DissimilarOriginLocation;
|
use dom::dissimilaroriginlocation::DissimilarOriginLocation;
|
||||||
|
@ -48,7 +48,7 @@ impl DissimilarOriginWindow {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
global_to_clone_from: &GlobalScope,
|
global_to_clone_from: &GlobalScope,
|
||||||
window_proxy: &WindowProxy,
|
window_proxy: &WindowProxy,
|
||||||
) -> Root<Self> {
|
) -> DomRoot<Self> {
|
||||||
let cx = global_to_clone_from.get_cx();
|
let cx = global_to_clone_from.get_cx();
|
||||||
// Any timer events fired on this window are ignored.
|
// Any timer events fired on this window are ignored.
|
||||||
let (timer_event_chan, _) = ipc::channel().unwrap();
|
let (timer_event_chan, _) = ipc::channel().unwrap();
|
||||||
|
@ -80,42 +80,42 @@ impl DissimilarOriginWindow {
|
||||||
|
|
||||||
impl DissimilarOriginWindowMethods for DissimilarOriginWindow {
|
impl DissimilarOriginWindowMethods for DissimilarOriginWindow {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-window
|
// https://html.spec.whatwg.org/multipage/#dom-window
|
||||||
fn Window(&self) -> Root<WindowProxy> {
|
fn Window(&self) -> DomRoot<WindowProxy> {
|
||||||
Root::from_ref(&*self.window_proxy)
|
DomRoot::from_ref(&*self.window_proxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-self
|
// https://html.spec.whatwg.org/multipage/#dom-self
|
||||||
fn Self_(&self) -> Root<WindowProxy> {
|
fn Self_(&self) -> DomRoot<WindowProxy> {
|
||||||
Root::from_ref(&*self.window_proxy)
|
DomRoot::from_ref(&*self.window_proxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-frames
|
// https://html.spec.whatwg.org/multipage/#dom-frames
|
||||||
fn Frames(&self) -> Root<WindowProxy> {
|
fn Frames(&self) -> DomRoot<WindowProxy> {
|
||||||
Root::from_ref(&*self.window_proxy)
|
DomRoot::from_ref(&*self.window_proxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-parent
|
// https://html.spec.whatwg.org/multipage/#dom-parent
|
||||||
fn GetParent(&self) -> Option<Root<WindowProxy>> {
|
fn GetParent(&self) -> Option<DomRoot<WindowProxy>> {
|
||||||
// Steps 1-3.
|
// Steps 1-3.
|
||||||
if self.window_proxy.is_browsing_context_discarded() {
|
if self.window_proxy.is_browsing_context_discarded() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
// Step 4.
|
// Step 4.
|
||||||
if let Some(parent) = self.window_proxy.parent() {
|
if let Some(parent) = self.window_proxy.parent() {
|
||||||
return Some(Root::from_ref(parent));
|
return Some(DomRoot::from_ref(parent));
|
||||||
}
|
}
|
||||||
// Step 5.
|
// Step 5.
|
||||||
Some(Root::from_ref(&*self.window_proxy))
|
Some(DomRoot::from_ref(&*self.window_proxy))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-top
|
// https://html.spec.whatwg.org/multipage/#dom-top
|
||||||
fn GetTop(&self) -> Option<Root<WindowProxy>> {
|
fn GetTop(&self) -> Option<DomRoot<WindowProxy>> {
|
||||||
// Steps 1-3.
|
// Steps 1-3.
|
||||||
if self.window_proxy.is_browsing_context_discarded() {
|
if self.window_proxy.is_browsing_context_discarded() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
// Steps 4-5.
|
// Steps 4-5.
|
||||||
Some(Root::from_ref(self.window_proxy.top()))
|
Some(DomRoot::from_ref(self.window_proxy.top()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-length
|
// https://html.spec.whatwg.org/multipage/#dom-length
|
||||||
|
@ -184,7 +184,7 @@ impl DissimilarOriginWindowMethods for DissimilarOriginWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-location
|
// https://html.spec.whatwg.org/multipage/#dom-location
|
||||||
fn Location(&self) -> Root<DissimilarOriginLocation> {
|
fn Location(&self) -> DomRoot<DissimilarOriginLocation> {
|
||||||
self.location.or_init(|| DissimilarOriginLocation::new(self))
|
self.location.or_init(|| DissimilarOriginLocation::new(self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, Nod
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
use dom::bindings::refcounted::{Trusted, TrustedPromise};
|
use dom::bindings::refcounted::{Trusted, TrustedPromise};
|
||||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, LayoutDom, MutNullableDom, Root, RootedReference};
|
use dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference};
|
||||||
use dom::bindings::str::{DOMString, USVString};
|
use dom::bindings::str::{DOMString, USVString};
|
||||||
use dom::bindings::xmlname::{namespace_from_domstring, validate_and_extract, xml_name_type};
|
use dom::bindings::xmlname::{namespace_from_domstring, validate_and_extract, xml_name_type};
|
||||||
use dom::bindings::xmlname::XMLName::InvalidXMLName;
|
use dom::bindings::xmlname::XMLName::InvalidXMLName;
|
||||||
|
@ -423,7 +423,7 @@ impl Document {
|
||||||
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#concept-document-bc
|
/// https://html.spec.whatwg.org/multipage/#concept-document-bc
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn browsing_context(&self) -> Option<Root<WindowProxy>> {
|
pub fn browsing_context(&self) -> Option<DomRoot<WindowProxy>> {
|
||||||
if self.has_browsing_context {
|
if self.has_browsing_context {
|
||||||
self.window.undiscarded_window_proxy()
|
self.window.undiscarded_window_proxy()
|
||||||
} else {
|
} else {
|
||||||
|
@ -523,7 +523,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the first `base` element in the DOM that has an `href` attribute.
|
/// Returns the first `base` element in the DOM that has an `href` attribute.
|
||||||
pub fn base_element(&self) -> Option<Root<HTMLBaseElement>> {
|
pub fn base_element(&self) -> Option<DomRoot<HTMLBaseElement>> {
|
||||||
self.base_element.get()
|
self.base_element.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ impl Document {
|
||||||
pub fn refresh_base_element(&self) {
|
pub fn refresh_base_element(&self) {
|
||||||
let base = self.upcast::<Node>()
|
let base = self.upcast::<Node>()
|
||||||
.traverse_preorder()
|
.traverse_preorder()
|
||||||
.filter_map(Root::downcast::<HTMLBaseElement>)
|
.filter_map(DomRoot::downcast::<HTMLBaseElement>)
|
||||||
.find(|element| element.upcast::<Element>().has_attribute(&local_name!("href")));
|
.find(|element| element.upcast::<Element>().has_attribute(&local_name!("href")));
|
||||||
self.base_element.set(base.r());
|
self.base_element.set(base.r());
|
||||||
}
|
}
|
||||||
|
@ -674,7 +674,7 @@ impl Document {
|
||||||
|
|
||||||
/// Attempt to find a named element in this page's document.
|
/// Attempt to find a named element in this page's document.
|
||||||
/// https://html.spec.whatwg.org/multipage/#the-indicated-part-of-the-document
|
/// https://html.spec.whatwg.org/multipage/#the-indicated-part-of-the-document
|
||||||
pub fn find_fragment_node(&self, fragid: &str) -> Option<Root<Element>> {
|
pub fn find_fragment_node(&self, fragid: &str) -> Option<DomRoot<Element>> {
|
||||||
// Step 1 is not handled here; the fragid is already obtained by the calling function
|
// Step 1 is not handled here; the fragid is already obtained by the calling function
|
||||||
// Step 2: Simply use None to indicate the top of the document.
|
// Step 2: Simply use None to indicate the top of the document.
|
||||||
// Step 3 & 4
|
// Step 3 & 4
|
||||||
|
@ -730,7 +730,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_anchor_by_name(&self, name: &str) -> Option<Root<Element>> {
|
fn get_anchor_by_name(&self, name: &str) -> Option<DomRoot<Element>> {
|
||||||
let check_anchor = |node: &HTMLAnchorElement| {
|
let check_anchor = |node: &HTMLAnchorElement| {
|
||||||
let elem = node.upcast::<Element>();
|
let elem = node.upcast::<Element>();
|
||||||
elem.get_attribute(&ns!(), &local_name!("name"))
|
elem.get_attribute(&ns!(), &local_name!("name"))
|
||||||
|
@ -738,9 +738,9 @@ impl Document {
|
||||||
};
|
};
|
||||||
let doc_node = self.upcast::<Node>();
|
let doc_node = self.upcast::<Node>();
|
||||||
doc_node.traverse_preorder()
|
doc_node.traverse_preorder()
|
||||||
.filter_map(Root::downcast)
|
.filter_map(DomRoot::downcast)
|
||||||
.find(|node| check_anchor(&node))
|
.find(|node| check_anchor(&node))
|
||||||
.map(Root::upcast)
|
.map(DomRoot::upcast)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#current-document-readiness
|
// https://html.spec.whatwg.org/multipage/#current-document-readiness
|
||||||
|
@ -771,7 +771,7 @@ impl Document {
|
||||||
|
|
||||||
/// Return the element that currently has focus.
|
/// Return the element that currently has focus.
|
||||||
// https://w3c.github.io/uievents/#events-focusevent-doc-focus
|
// https://w3c.github.io/uievents/#events-focusevent-doc-focus
|
||||||
pub fn get_focused_element(&self) -> Option<Root<Element>> {
|
pub fn get_focused_element(&self) -> Option<DomRoot<Element>> {
|
||||||
self.focused.get()
|
self.focused.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,10 +863,10 @@ impl Document {
|
||||||
};
|
};
|
||||||
|
|
||||||
let el = match node.downcast::<Element>() {
|
let el = match node.downcast::<Element>() {
|
||||||
Some(el) => Root::from_ref(el),
|
Some(el) => DomRoot::from_ref(el),
|
||||||
None => {
|
None => {
|
||||||
let parent = node.GetParentNode();
|
let parent = node.GetParentNode();
|
||||||
match parent.and_then(Root::downcast::<Element>) {
|
match parent.and_then(DomRoot::downcast::<Element>) {
|
||||||
Some(parent) => parent,
|
Some(parent) => parent,
|
||||||
None => return,
|
None => return,
|
||||||
}
|
}
|
||||||
|
@ -1018,10 +1018,10 @@ impl Document {
|
||||||
};
|
};
|
||||||
|
|
||||||
let el = match node.downcast::<Element>() {
|
let el = match node.downcast::<Element>() {
|
||||||
Some(el) => Root::from_ref(el),
|
Some(el) => DomRoot::from_ref(el),
|
||||||
None => {
|
None => {
|
||||||
let parent = node.GetParentNode();
|
let parent = node.GetParentNode();
|
||||||
match parent.and_then(Root::downcast::<Element>) {
|
match parent.and_then(DomRoot::downcast::<Element>) {
|
||||||
Some(parent) => parent,
|
Some(parent) => parent,
|
||||||
None => return
|
None => return
|
||||||
}
|
}
|
||||||
|
@ -1126,7 +1126,7 @@ impl Document {
|
||||||
let maybe_new_target = self.window.hit_test_query(client_point, true).and_then(|address| {
|
let maybe_new_target = self.window.hit_test_query(client_point, true).and_then(|address| {
|
||||||
let node = unsafe { node::from_untrusted_node_address(js_runtime, address) };
|
let node = unsafe { node::from_untrusted_node_address(js_runtime, address) };
|
||||||
node.inclusive_ancestors()
|
node.inclusive_ancestors()
|
||||||
.filter_map(Root::downcast::<Element>)
|
.filter_map(DomRoot::downcast::<Element>)
|
||||||
.next()
|
.next()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1169,7 +1169,7 @@ impl Document {
|
||||||
if !old_target_is_ancestor_of_new_target {
|
if !old_target_is_ancestor_of_new_target {
|
||||||
for element in old_target.upcast::<Node>()
|
for element in old_target.upcast::<Node>()
|
||||||
.inclusive_ancestors()
|
.inclusive_ancestors()
|
||||||
.filter_map(Root::downcast::<Element>) {
|
.filter_map(DomRoot::downcast::<Element>) {
|
||||||
element.set_hover_state(false);
|
element.set_hover_state(false);
|
||||||
element.set_active_state(false);
|
element.set_active_state(false);
|
||||||
}
|
}
|
||||||
|
@ -1185,7 +1185,7 @@ impl Document {
|
||||||
if let Some(ref new_target) = maybe_new_target {
|
if let Some(ref new_target) = maybe_new_target {
|
||||||
for element in new_target.upcast::<Node>()
|
for element in new_target.upcast::<Node>()
|
||||||
.inclusive_ancestors()
|
.inclusive_ancestors()
|
||||||
.filter_map(Root::downcast::<Element>) {
|
.filter_map(DomRoot::downcast::<Element>) {
|
||||||
if element.hover_state() {
|
if element.hover_state() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1229,10 +1229,10 @@ impl Document {
|
||||||
None => return TouchEventResult::Processed(false),
|
None => return TouchEventResult::Processed(false),
|
||||||
};
|
};
|
||||||
let el = match node.downcast::<Element>() {
|
let el = match node.downcast::<Element>() {
|
||||||
Some(el) => Root::from_ref(el),
|
Some(el) => DomRoot::from_ref(el),
|
||||||
None => {
|
None => {
|
||||||
let parent = node.GetParentNode();
|
let parent = node.GetParentNode();
|
||||||
match parent.and_then(Root::downcast::<Element>) {
|
match parent.and_then(DomRoot::downcast::<Element>) {
|
||||||
Some(parent) => parent,
|
Some(parent) => parent,
|
||||||
None => return TouchEventResult::Processed(false),
|
None => return TouchEventResult::Processed(false),
|
||||||
}
|
}
|
||||||
|
@ -1253,7 +1253,7 @@ impl Document {
|
||||||
return TouchEventResult::Forwarded;
|
return TouchEventResult::Forwarded;
|
||||||
}
|
}
|
||||||
|
|
||||||
let target = Root::upcast::<EventTarget>(el);
|
let target = DomRoot::upcast::<EventTarget>(el);
|
||||||
let window = &*self.window;
|
let window = &*self.window;
|
||||||
|
|
||||||
let client_x = Finite::wrap(point.x as f64);
|
let client_x = Finite::wrap(point.x as f64);
|
||||||
|
@ -1455,21 +1455,21 @@ impl Document {
|
||||||
// https://dom.spec.whatwg.org/#converting-nodes-into-a-node
|
// https://dom.spec.whatwg.org/#converting-nodes-into-a-node
|
||||||
pub fn node_from_nodes_and_strings(&self,
|
pub fn node_from_nodes_and_strings(&self,
|
||||||
mut nodes: Vec<NodeOrString>)
|
mut nodes: Vec<NodeOrString>)
|
||||||
-> Fallible<Root<Node>> {
|
-> Fallible<DomRoot<Node>> {
|
||||||
if nodes.len() == 1 {
|
if nodes.len() == 1 {
|
||||||
Ok(match nodes.pop().unwrap() {
|
Ok(match nodes.pop().unwrap() {
|
||||||
NodeOrString::Node(node) => node,
|
NodeOrString::Node(node) => node,
|
||||||
NodeOrString::String(string) => Root::upcast(self.CreateTextNode(string)),
|
NodeOrString::String(string) => DomRoot::upcast(self.CreateTextNode(string)),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
let fragment = Root::upcast::<Node>(self.CreateDocumentFragment());
|
let fragment = DomRoot::upcast::<Node>(self.CreateDocumentFragment());
|
||||||
for node in nodes {
|
for node in nodes {
|
||||||
match node {
|
match node {
|
||||||
NodeOrString::Node(node) => {
|
NodeOrString::Node(node) => {
|
||||||
fragment.AppendChild(&node)?;
|
fragment.AppendChild(&node)?;
|
||||||
},
|
},
|
||||||
NodeOrString::String(string) => {
|
NodeOrString::String(string) => {
|
||||||
let node = Root::upcast::<Node>(self.CreateTextNode(string));
|
let node = DomRoot::upcast::<Node>(self.CreateTextNode(string));
|
||||||
// No try!() here because appending a text node
|
// No try!() here because appending a text node
|
||||||
// should not fail.
|
// should not fail.
|
||||||
fragment.AppendChild(&node).unwrap();
|
fragment.AppendChild(&node).unwrap();
|
||||||
|
@ -1481,7 +1481,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_body_attribute(&self, local_name: &LocalName) -> DOMString {
|
pub fn get_body_attribute(&self, local_name: &LocalName) -> DOMString {
|
||||||
match self.GetBody().and_then(Root::downcast::<HTMLBodyElement>) {
|
match self.GetBody().and_then(DomRoot::downcast::<HTMLBodyElement>) {
|
||||||
Some(ref body) => {
|
Some(ref body) => {
|
||||||
body.upcast::<Element>().get_string_attribute(local_name)
|
body.upcast::<Element>().get_string_attribute(local_name)
|
||||||
},
|
},
|
||||||
|
@ -1490,7 +1490,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_body_attribute(&self, local_name: &LocalName, value: DOMString) {
|
pub fn set_body_attribute(&self, local_name: &LocalName, value: DOMString) {
|
||||||
if let Some(ref body) = self.GetBody().and_then(Root::downcast::<HTMLBodyElement>) {
|
if let Some(ref body) = self.GetBody().and_then(DomRoot::downcast::<HTMLBodyElement>) {
|
||||||
let body = body.upcast::<Element>();
|
let body = body.upcast::<Element>();
|
||||||
let value = body.parse_attribute(&ns!(), &local_name, value);
|
let value = body.parse_attribute(&ns!(), &local_name, value);
|
||||||
body.set_attribute(local_name, value);
|
body.set_attribute(local_name, value);
|
||||||
|
@ -1948,19 +1948,19 @@ impl Document {
|
||||||
self.current_parser.set(script);
|
self.current_parser.set(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_current_parser(&self) -> Option<Root<ServoParser>> {
|
pub fn get_current_parser(&self) -> Option<DomRoot<ServoParser>> {
|
||||||
self.current_parser.get()
|
self.current_parser.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterate over all iframes in the document.
|
/// Iterate over all iframes in the document.
|
||||||
pub fn iter_iframes(&self) -> impl Iterator<Item=Root<HTMLIFrameElement>> {
|
pub fn iter_iframes(&self) -> impl Iterator<Item=DomRoot<HTMLIFrameElement>> {
|
||||||
self.upcast::<Node>()
|
self.upcast::<Node>()
|
||||||
.traverse_preorder()
|
.traverse_preorder()
|
||||||
.filter_map(Root::downcast::<HTMLIFrameElement>)
|
.filter_map(DomRoot::downcast::<HTMLIFrameElement>)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find an iframe element in the document.
|
/// Find an iframe element in the document.
|
||||||
pub fn find_iframe(&self, browsing_context_id: BrowsingContextId) -> Option<Root<HTMLIFrameElement>> {
|
pub fn find_iframe(&self, browsing_context_id: BrowsingContextId) -> Option<DomRoot<HTMLIFrameElement>> {
|
||||||
self.iter_iframes()
|
self.iter_iframes()
|
||||||
.find(|node| node.browsing_context_id() == Some(browsing_context_id))
|
.find(|node| node.browsing_context_id() == Some(browsing_context_id))
|
||||||
}
|
}
|
||||||
|
@ -1968,7 +1968,7 @@ impl Document {
|
||||||
/// Find a mozbrowser iframe element in the document.
|
/// Find a mozbrowser iframe element in the document.
|
||||||
pub fn find_mozbrowser_iframe(&self,
|
pub fn find_mozbrowser_iframe(&self,
|
||||||
top_level_browsing_context_id: TopLevelBrowsingContextId)
|
top_level_browsing_context_id: TopLevelBrowsingContextId)
|
||||||
-> Option<Root<HTMLIFrameElement>>
|
-> Option<DomRoot<HTMLIFrameElement>>
|
||||||
{
|
{
|
||||||
match self.find_iframe(BrowsingContextId::from(top_level_browsing_context_id)) {
|
match self.find_iframe(BrowsingContextId::from(top_level_browsing_context_id)) {
|
||||||
None => None,
|
None => None,
|
||||||
|
@ -2310,7 +2310,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-document
|
// https://dom.spec.whatwg.org/#dom-document-document
|
||||||
pub fn Constructor(window: &Window) -> Fallible<Root<Document>> {
|
pub fn Constructor(window: &Window) -> Fallible<DomRoot<Document>> {
|
||||||
let doc = window.Document();
|
let doc = window.Document();
|
||||||
let docloader = DocumentLoader::new(&*doc.loader());
|
let docloader = DocumentLoader::new(&*doc.loader());
|
||||||
Ok(Document::new(window,
|
Ok(Document::new(window,
|
||||||
|
@ -2339,7 +2339,7 @@ impl Document {
|
||||||
doc_loader: DocumentLoader,
|
doc_loader: DocumentLoader,
|
||||||
referrer: Option<String>,
|
referrer: Option<String>,
|
||||||
referrer_policy: Option<ReferrerPolicy>)
|
referrer_policy: Option<ReferrerPolicy>)
|
||||||
-> Root<Document> {
|
-> DomRoot<Document> {
|
||||||
let document = reflect_dom_object(box Document::new_inherited(window,
|
let document = reflect_dom_object(box Document::new_inherited(window,
|
||||||
has_browsing_context,
|
has_browsing_context,
|
||||||
url,
|
url,
|
||||||
|
@ -2361,7 +2361,7 @@ impl Document {
|
||||||
document
|
document
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_node_list<F: Fn(&Node) -> bool>(&self, callback: F) -> Root<NodeList> {
|
fn create_node_list<F: Fn(&Node) -> bool>(&self, callback: F) -> DomRoot<NodeList> {
|
||||||
let doc = self.GetDocumentElement();
|
let doc = self.GetDocumentElement();
|
||||||
let maybe_node = doc.r().map(Castable::upcast::<Node>);
|
let maybe_node = doc.r().map(Castable::upcast::<Node>);
|
||||||
let iter = maybe_node.iter()
|
let iter = maybe_node.iter()
|
||||||
|
@ -2370,8 +2370,8 @@ impl Document {
|
||||||
NodeList::new_simple_list(&self.window, iter)
|
NodeList::new_simple_list(&self.window, iter)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_html_element(&self) -> Option<Root<HTMLHtmlElement>> {
|
fn get_html_element(&self) -> Option<DomRoot<HTMLHtmlElement>> {
|
||||||
self.GetDocumentElement().and_then(Root::downcast)
|
self.GetDocumentElement().and_then(DomRoot::downcast)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return a reference to the per-document shared lock used in stylesheets.
|
/// Return a reference to the per-document shared lock used in stylesheets.
|
||||||
|
@ -2482,7 +2482,7 @@ impl Document {
|
||||||
self.stylesheets.borrow().len()
|
self.stylesheets.borrow().len()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stylesheet_at(&self, index: usize) -> Option<Root<CSSStyleSheet>> {
|
pub fn stylesheet_at(&self, index: usize) -> Option<DomRoot<CSSStyleSheet>> {
|
||||||
let stylesheets = self.stylesheets.borrow();
|
let stylesheets = self.stylesheets.borrow();
|
||||||
|
|
||||||
stylesheets.get(Origin::Author, index).and_then(|s| {
|
stylesheets.get(Origin::Author, index).and_then(|s| {
|
||||||
|
@ -2491,7 +2491,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#appropriate-template-contents-owner-document
|
/// https://html.spec.whatwg.org/multipage/#appropriate-template-contents-owner-document
|
||||||
pub fn appropriate_template_contents_owner_document(&self) -> Root<Document> {
|
pub fn appropriate_template_contents_owner_document(&self) -> DomRoot<Document> {
|
||||||
self.appropriate_template_contents_owner_document.or_init(|| {
|
self.appropriate_template_contents_owner_document.or_init(|| {
|
||||||
let doctype = if self.is_html_document {
|
let doctype = if self.is_html_document {
|
||||||
IsHTMLDocument::HTMLDocument
|
IsHTMLDocument::HTMLDocument
|
||||||
|
@ -2516,8 +2516,8 @@ impl Document {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_element_by_id(&self, id: &Atom) -> Option<Root<Element>> {
|
pub fn get_element_by_id(&self, id: &Atom) -> Option<DomRoot<Element>> {
|
||||||
self.id_map.borrow().get(&id).map(|ref elements| Root::from_ref(&*(*elements)[0]))
|
self.id_map.borrow().get(&id).map(|ref elements| DomRoot::from_ref(&*(*elements)[0]))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ensure_pending_restyle(&self, el: &Element) -> RefMut<PendingRestyle> {
|
pub fn ensure_pending_restyle(&self, el: &Element) -> RefMut<PendingRestyle> {
|
||||||
|
@ -2747,12 +2747,12 @@ impl Element {
|
||||||
|
|
||||||
impl DocumentMethods for Document {
|
impl DocumentMethods for Document {
|
||||||
// https://drafts.csswg.org/cssom/#dom-document-stylesheets
|
// https://drafts.csswg.org/cssom/#dom-document-stylesheets
|
||||||
fn StyleSheets(&self) -> Root<StyleSheetList> {
|
fn StyleSheets(&self) -> DomRoot<StyleSheetList> {
|
||||||
self.stylesheet_list.or_init(|| StyleSheetList::new(&self.window, Dom::from_ref(&self)))
|
self.stylesheet_list.or_init(|| StyleSheetList::new(&self.window, Dom::from_ref(&self)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-implementation
|
// https://dom.spec.whatwg.org/#dom-document-implementation
|
||||||
fn Implementation(&self) -> Root<DOMImplementation> {
|
fn Implementation(&self) -> DomRoot<DOMImplementation> {
|
||||||
self.implementation.or_init(|| DOMImplementation::new(self))
|
self.implementation.or_init(|| DOMImplementation::new(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2762,13 +2762,13 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-activeelement
|
// https://html.spec.whatwg.org/multipage/#dom-document-activeelement
|
||||||
fn GetActiveElement(&self) -> Option<Root<Element>> {
|
fn GetActiveElement(&self) -> Option<DomRoot<Element>> {
|
||||||
// TODO: Step 2.
|
// TODO: Step 2.
|
||||||
|
|
||||||
match self.get_focused_element() {
|
match self.get_focused_element() {
|
||||||
Some(element) => Some(element), // Step 3. and 4.
|
Some(element) => Some(element), // Step 3. and 4.
|
||||||
None => match self.GetBody() { // Step 5.
|
None => match self.GetBody() { // Step 5.
|
||||||
Some(body) => Some(Root::upcast(body)),
|
Some(body) => Some(DomRoot::upcast(body)),
|
||||||
None => self.GetDocumentElement(),
|
None => self.GetDocumentElement(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -2899,20 +2899,20 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-doctype
|
// https://dom.spec.whatwg.org/#dom-document-doctype
|
||||||
fn GetDoctype(&self) -> Option<Root<DocumentType>> {
|
fn GetDoctype(&self) -> Option<DomRoot<DocumentType>> {
|
||||||
self.upcast::<Node>().children().filter_map(Root::downcast).next()
|
self.upcast::<Node>().children().filter_map(DomRoot::downcast).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-documentelement
|
// https://dom.spec.whatwg.org/#dom-document-documentelement
|
||||||
fn GetDocumentElement(&self) -> Option<Root<Element>> {
|
fn GetDocumentElement(&self) -> Option<DomRoot<Element>> {
|
||||||
self.upcast::<Node>().child_elements().next()
|
self.upcast::<Node>().child_elements().next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-getelementsbytagname
|
// https://dom.spec.whatwg.org/#dom-document-getelementsbytagname
|
||||||
fn GetElementsByTagName(&self, qualified_name: DOMString) -> Root<HTMLCollection> {
|
fn GetElementsByTagName(&self, qualified_name: DOMString) -> DomRoot<HTMLCollection> {
|
||||||
let qualified_name = LocalName::from(&*qualified_name);
|
let qualified_name = LocalName::from(&*qualified_name);
|
||||||
match self.tag_map.borrow_mut().entry(qualified_name.clone()) {
|
match self.tag_map.borrow_mut().entry(qualified_name.clone()) {
|
||||||
Occupied(entry) => Root::from_ref(entry.get()),
|
Occupied(entry) => DomRoot::from_ref(entry.get()),
|
||||||
Vacant(entry) => {
|
Vacant(entry) => {
|
||||||
let result = HTMLCollection::by_qualified_name(
|
let result = HTMLCollection::by_qualified_name(
|
||||||
&self.window, self.upcast(), qualified_name);
|
&self.window, self.upcast(), qualified_name);
|
||||||
|
@ -2926,12 +2926,12 @@ impl DocumentMethods for Document {
|
||||||
fn GetElementsByTagNameNS(&self,
|
fn GetElementsByTagNameNS(&self,
|
||||||
maybe_ns: Option<DOMString>,
|
maybe_ns: Option<DOMString>,
|
||||||
tag_name: DOMString)
|
tag_name: DOMString)
|
||||||
-> Root<HTMLCollection> {
|
-> DomRoot<HTMLCollection> {
|
||||||
let ns = namespace_from_domstring(maybe_ns);
|
let ns = namespace_from_domstring(maybe_ns);
|
||||||
let local = LocalName::from(tag_name);
|
let local = LocalName::from(tag_name);
|
||||||
let qname = QualName::new(None, ns, local);
|
let qname = QualName::new(None, ns, local);
|
||||||
match self.tagns_map.borrow_mut().entry(qname.clone()) {
|
match self.tagns_map.borrow_mut().entry(qname.clone()) {
|
||||||
Occupied(entry) => Root::from_ref(entry.get()),
|
Occupied(entry) => DomRoot::from_ref(entry.get()),
|
||||||
Vacant(entry) => {
|
Vacant(entry) => {
|
||||||
let result = HTMLCollection::by_qual_tag_name(&self.window, self.upcast(), qname);
|
let result = HTMLCollection::by_qual_tag_name(&self.window, self.upcast(), qname);
|
||||||
entry.insert(Dom::from_ref(&*result));
|
entry.insert(Dom::from_ref(&*result));
|
||||||
|
@ -2941,12 +2941,12 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-getelementsbyclassname
|
// https://dom.spec.whatwg.org/#dom-document-getelementsbyclassname
|
||||||
fn GetElementsByClassName(&self, classes: DOMString) -> Root<HTMLCollection> {
|
fn GetElementsByClassName(&self, classes: DOMString) -> DomRoot<HTMLCollection> {
|
||||||
let class_atoms: Vec<Atom> = split_html_space_chars(&classes)
|
let class_atoms: Vec<Atom> = split_html_space_chars(&classes)
|
||||||
.map(Atom::from)
|
.map(Atom::from)
|
||||||
.collect();
|
.collect();
|
||||||
match self.classes_map.borrow_mut().entry(class_atoms.clone()) {
|
match self.classes_map.borrow_mut().entry(class_atoms.clone()) {
|
||||||
Occupied(entry) => Root::from_ref(entry.get()),
|
Occupied(entry) => DomRoot::from_ref(entry.get()),
|
||||||
Vacant(entry) => {
|
Vacant(entry) => {
|
||||||
let result = HTMLCollection::by_atomic_class_name(&self.window,
|
let result = HTMLCollection::by_atomic_class_name(&self.window,
|
||||||
self.upcast(),
|
self.upcast(),
|
||||||
|
@ -2958,7 +2958,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
// https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
||||||
fn GetElementById(&self, id: DOMString) -> Option<Root<Element>> {
|
fn GetElementById(&self, id: DOMString) -> Option<DomRoot<Element>> {
|
||||||
self.get_element_by_id(&Atom::from(id))
|
self.get_element_by_id(&Atom::from(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2966,7 +2966,7 @@ impl DocumentMethods for Document {
|
||||||
fn CreateElement(&self,
|
fn CreateElement(&self,
|
||||||
mut local_name: DOMString,
|
mut local_name: DOMString,
|
||||||
options: &ElementCreationOptions)
|
options: &ElementCreationOptions)
|
||||||
-> Fallible<Root<Element>> {
|
-> Fallible<DomRoot<Element>> {
|
||||||
if xml_name_type(&local_name) == InvalidXMLName {
|
if xml_name_type(&local_name) == InvalidXMLName {
|
||||||
debug!("Not a valid element name");
|
debug!("Not a valid element name");
|
||||||
return Err(Error::InvalidCharacter);
|
return Err(Error::InvalidCharacter);
|
||||||
|
@ -2991,7 +2991,7 @@ impl DocumentMethods for Document {
|
||||||
namespace: Option<DOMString>,
|
namespace: Option<DOMString>,
|
||||||
qualified_name: DOMString,
|
qualified_name: DOMString,
|
||||||
options: &ElementCreationOptions)
|
options: &ElementCreationOptions)
|
||||||
-> Fallible<Root<Element>> {
|
-> Fallible<DomRoot<Element>> {
|
||||||
let (namespace, prefix, local_name) = validate_and_extract(namespace,
|
let (namespace, prefix, local_name) = validate_and_extract(namespace,
|
||||||
&qualified_name)?;
|
&qualified_name)?;
|
||||||
let name = QualName::new(prefix, namespace, local_name);
|
let name = QualName::new(prefix, namespace, local_name);
|
||||||
|
@ -3000,7 +3000,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createattribute
|
// https://dom.spec.whatwg.org/#dom-document-createattribute
|
||||||
fn CreateAttribute(&self, mut local_name: DOMString) -> Fallible<Root<Attr>> {
|
fn CreateAttribute(&self, mut local_name: DOMString) -> Fallible<DomRoot<Attr>> {
|
||||||
if xml_name_type(&local_name) == InvalidXMLName {
|
if xml_name_type(&local_name) == InvalidXMLName {
|
||||||
debug!("Not a valid element name");
|
debug!("Not a valid element name");
|
||||||
return Err(Error::InvalidCharacter);
|
return Err(Error::InvalidCharacter);
|
||||||
|
@ -3018,7 +3018,7 @@ impl DocumentMethods for Document {
|
||||||
fn CreateAttributeNS(&self,
|
fn CreateAttributeNS(&self,
|
||||||
namespace: Option<DOMString>,
|
namespace: Option<DOMString>,
|
||||||
qualified_name: DOMString)
|
qualified_name: DOMString)
|
||||||
-> Fallible<Root<Attr>> {
|
-> Fallible<DomRoot<Attr>> {
|
||||||
let (namespace, prefix, local_name) = validate_and_extract(namespace,
|
let (namespace, prefix, local_name) = validate_and_extract(namespace,
|
||||||
&qualified_name)?;
|
&qualified_name)?;
|
||||||
let value = AttrValue::String("".to_owned());
|
let value = AttrValue::String("".to_owned());
|
||||||
|
@ -3033,17 +3033,17 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createdocumentfragment
|
// https://dom.spec.whatwg.org/#dom-document-createdocumentfragment
|
||||||
fn CreateDocumentFragment(&self) -> Root<DocumentFragment> {
|
fn CreateDocumentFragment(&self) -> DomRoot<DocumentFragment> {
|
||||||
DocumentFragment::new(self)
|
DocumentFragment::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createtextnode
|
// https://dom.spec.whatwg.org/#dom-document-createtextnode
|
||||||
fn CreateTextNode(&self, data: DOMString) -> Root<Text> {
|
fn CreateTextNode(&self, data: DOMString) -> DomRoot<Text> {
|
||||||
Text::new(data, self)
|
Text::new(data, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createcomment
|
// https://dom.spec.whatwg.org/#dom-document-createcomment
|
||||||
fn CreateComment(&self, data: DOMString) -> Root<Comment> {
|
fn CreateComment(&self, data: DOMString) -> DomRoot<Comment> {
|
||||||
Comment::new(data, self)
|
Comment::new(data, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3051,7 +3051,7 @@ impl DocumentMethods for Document {
|
||||||
fn CreateProcessingInstruction(&self,
|
fn CreateProcessingInstruction(&self,
|
||||||
target: DOMString,
|
target: DOMString,
|
||||||
data: DOMString)
|
data: DOMString)
|
||||||
-> Fallible<Root<ProcessingInstruction>> {
|
-> Fallible<DomRoot<ProcessingInstruction>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if xml_name_type(&target) == InvalidXMLName {
|
if xml_name_type(&target) == InvalidXMLName {
|
||||||
return Err(Error::InvalidCharacter);
|
return Err(Error::InvalidCharacter);
|
||||||
|
@ -3067,7 +3067,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-importnode
|
// https://dom.spec.whatwg.org/#dom-document-importnode
|
||||||
fn ImportNode(&self, node: &Node, deep: bool) -> Fallible<Root<Node>> {
|
fn ImportNode(&self, node: &Node, deep: bool) -> Fallible<DomRoot<Node>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if node.is::<Document>() {
|
if node.is::<Document>() {
|
||||||
return Err(Error::NotSupported);
|
return Err(Error::NotSupported);
|
||||||
|
@ -3084,7 +3084,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-adoptnode
|
// https://dom.spec.whatwg.org/#dom-document-adoptnode
|
||||||
fn AdoptNode(&self, node: &Node) -> Fallible<Root<Node>> {
|
fn AdoptNode(&self, node: &Node) -> Fallible<DomRoot<Node>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if node.is::<Document>() {
|
if node.is::<Document>() {
|
||||||
return Err(Error::NotSupported);
|
return Err(Error::NotSupported);
|
||||||
|
@ -3094,44 +3094,44 @@ impl DocumentMethods for Document {
|
||||||
Node::adopt(node, self);
|
Node::adopt(node, self);
|
||||||
|
|
||||||
// Step 3.
|
// Step 3.
|
||||||
Ok(Root::from_ref(node))
|
Ok(DomRoot::from_ref(node))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createevent
|
// https://dom.spec.whatwg.org/#dom-document-createevent
|
||||||
fn CreateEvent(&self, mut interface: DOMString) -> Fallible<Root<Event>> {
|
fn CreateEvent(&self, mut interface: DOMString) -> Fallible<DomRoot<Event>> {
|
||||||
interface.make_ascii_lowercase();
|
interface.make_ascii_lowercase();
|
||||||
match &*interface {
|
match &*interface {
|
||||||
"beforeunloadevent" =>
|
"beforeunloadevent" =>
|
||||||
Ok(Root::upcast(BeforeUnloadEvent::new_uninitialized(&self.window))),
|
Ok(DomRoot::upcast(BeforeUnloadEvent::new_uninitialized(&self.window))),
|
||||||
"closeevent" =>
|
"closeevent" =>
|
||||||
Ok(Root::upcast(CloseEvent::new_uninitialized(self.window.upcast()))),
|
Ok(DomRoot::upcast(CloseEvent::new_uninitialized(self.window.upcast()))),
|
||||||
"customevent" =>
|
"customevent" =>
|
||||||
Ok(Root::upcast(CustomEvent::new_uninitialized(self.window.upcast()))),
|
Ok(DomRoot::upcast(CustomEvent::new_uninitialized(self.window.upcast()))),
|
||||||
"errorevent" =>
|
"errorevent" =>
|
||||||
Ok(Root::upcast(ErrorEvent::new_uninitialized(self.window.upcast()))),
|
Ok(DomRoot::upcast(ErrorEvent::new_uninitialized(self.window.upcast()))),
|
||||||
"events" | "event" | "htmlevents" | "svgevents" =>
|
"events" | "event" | "htmlevents" | "svgevents" =>
|
||||||
Ok(Event::new_uninitialized(&self.window.upcast())),
|
Ok(Event::new_uninitialized(&self.window.upcast())),
|
||||||
"focusevent" =>
|
"focusevent" =>
|
||||||
Ok(Root::upcast(FocusEvent::new_uninitialized(&self.window))),
|
Ok(DomRoot::upcast(FocusEvent::new_uninitialized(&self.window))),
|
||||||
"hashchangeevent" =>
|
"hashchangeevent" =>
|
||||||
Ok(Root::upcast(HashChangeEvent::new_uninitialized(&self.window))),
|
Ok(DomRoot::upcast(HashChangeEvent::new_uninitialized(&self.window))),
|
||||||
"keyboardevent" =>
|
"keyboardevent" =>
|
||||||
Ok(Root::upcast(KeyboardEvent::new_uninitialized(&self.window))),
|
Ok(DomRoot::upcast(KeyboardEvent::new_uninitialized(&self.window))),
|
||||||
"messageevent" =>
|
"messageevent" =>
|
||||||
Ok(Root::upcast(MessageEvent::new_uninitialized(self.window.upcast()))),
|
Ok(DomRoot::upcast(MessageEvent::new_uninitialized(self.window.upcast()))),
|
||||||
"mouseevent" | "mouseevents" =>
|
"mouseevent" | "mouseevents" =>
|
||||||
Ok(Root::upcast(MouseEvent::new_uninitialized(&self.window))),
|
Ok(DomRoot::upcast(MouseEvent::new_uninitialized(&self.window))),
|
||||||
"pagetransitionevent" =>
|
"pagetransitionevent" =>
|
||||||
Ok(Root::upcast(PageTransitionEvent::new_uninitialized(&self.window))),
|
Ok(DomRoot::upcast(PageTransitionEvent::new_uninitialized(&self.window))),
|
||||||
"popstateevent" =>
|
"popstateevent" =>
|
||||||
Ok(Root::upcast(PopStateEvent::new_uninitialized(&self.window))),
|
Ok(DomRoot::upcast(PopStateEvent::new_uninitialized(&self.window))),
|
||||||
"progressevent" =>
|
"progressevent" =>
|
||||||
Ok(Root::upcast(ProgressEvent::new_uninitialized(self.window.upcast()))),
|
Ok(DomRoot::upcast(ProgressEvent::new_uninitialized(self.window.upcast()))),
|
||||||
"storageevent" => {
|
"storageevent" => {
|
||||||
Ok(Root::upcast(StorageEvent::new_uninitialized(&self.window, "".into())))
|
Ok(DomRoot::upcast(StorageEvent::new_uninitialized(&self.window, "".into())))
|
||||||
},
|
},
|
||||||
"touchevent" =>
|
"touchevent" =>
|
||||||
Ok(Root::upcast(
|
Ok(DomRoot::upcast(
|
||||||
TouchEvent::new_uninitialized(&self.window,
|
TouchEvent::new_uninitialized(&self.window,
|
||||||
&TouchList::new(&self.window, &[]),
|
&TouchList::new(&self.window, &[]),
|
||||||
&TouchList::new(&self.window, &[]),
|
&TouchList::new(&self.window, &[]),
|
||||||
|
@ -3139,9 +3139,9 @@ impl DocumentMethods for Document {
|
||||||
)
|
)
|
||||||
)),
|
)),
|
||||||
"uievent" | "uievents" =>
|
"uievent" | "uievents" =>
|
||||||
Ok(Root::upcast(UIEvent::new_uninitialized(&self.window))),
|
Ok(DomRoot::upcast(UIEvent::new_uninitialized(&self.window))),
|
||||||
"webglcontextevent" =>
|
"webglcontextevent" =>
|
||||||
Ok(Root::upcast(WebGLContextEvent::new_uninitialized(&self.window))),
|
Ok(DomRoot::upcast(WebGLContextEvent::new_uninitialized(&self.window))),
|
||||||
_ =>
|
_ =>
|
||||||
Err(Error::NotSupported),
|
Err(Error::NotSupported),
|
||||||
}
|
}
|
||||||
|
@ -3156,7 +3156,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createrange
|
// https://dom.spec.whatwg.org/#dom-document-createrange
|
||||||
fn CreateRange(&self) -> Root<Range> {
|
fn CreateRange(&self) -> DomRoot<Range> {
|
||||||
Range::new_with_doc(self)
|
Range::new_with_doc(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3165,7 +3165,7 @@ impl DocumentMethods for Document {
|
||||||
root: &Node,
|
root: &Node,
|
||||||
what_to_show: u32,
|
what_to_show: u32,
|
||||||
filter: Option<Rc<NodeFilter>>)
|
filter: Option<Rc<NodeFilter>>)
|
||||||
-> Root<NodeIterator> {
|
-> DomRoot<NodeIterator> {
|
||||||
NodeIterator::new(self, root, what_to_show, filter)
|
NodeIterator::new(self, root, what_to_show, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3178,7 +3178,7 @@ impl DocumentMethods for Document {
|
||||||
page_y: Finite<f64>,
|
page_y: Finite<f64>,
|
||||||
screen_x: Finite<f64>,
|
screen_x: Finite<f64>,
|
||||||
screen_y: Finite<f64>)
|
screen_y: Finite<f64>)
|
||||||
-> Root<Touch> {
|
-> DomRoot<Touch> {
|
||||||
let client_x = Finite::wrap(*page_x - window.PageXOffset() as f64);
|
let client_x = Finite::wrap(*page_x - window.PageXOffset() as f64);
|
||||||
let client_y = Finite::wrap(*page_y - window.PageYOffset() as f64);
|
let client_y = Finite::wrap(*page_y - window.PageYOffset() as f64);
|
||||||
Touch::new(window,
|
Touch::new(window,
|
||||||
|
@ -3193,7 +3193,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/touch-events/#idl-def-document-createtouchlist(touch...)
|
// https://w3c.github.io/touch-events/#idl-def-document-createtouchlist(touch...)
|
||||||
fn CreateTouchList(&self, touches: &[&Touch]) -> Root<TouchList> {
|
fn CreateTouchList(&self, touches: &[&Touch]) -> DomRoot<TouchList> {
|
||||||
TouchList::new(&self.window, &touches)
|
TouchList::new(&self.window, &touches)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3202,7 +3202,7 @@ impl DocumentMethods for Document {
|
||||||
root: &Node,
|
root: &Node,
|
||||||
what_to_show: u32,
|
what_to_show: u32,
|
||||||
filter: Option<Rc<NodeFilter>>)
|
filter: Option<Rc<NodeFilter>>)
|
||||||
-> Root<TreeWalker> {
|
-> DomRoot<TreeWalker> {
|
||||||
TreeWalker::new(self, root, what_to_show, filter)
|
TreeWalker::new(self, root, what_to_show, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3216,7 +3216,7 @@ impl DocumentMethods for Document {
|
||||||
.find(|node| {
|
.find(|node| {
|
||||||
node.namespace() == &ns!(svg) && node.local_name() == &local_name!("title")
|
node.namespace() == &ns!(svg) && node.local_name() == &local_name!("title")
|
||||||
})
|
})
|
||||||
.map(Root::upcast::<Node>)
|
.map(DomRoot::upcast::<Node>)
|
||||||
} else {
|
} else {
|
||||||
// Step 2.
|
// Step 2.
|
||||||
root.upcast::<Node>()
|
root.upcast::<Node>()
|
||||||
|
@ -3247,7 +3247,7 @@ impl DocumentMethods for Document {
|
||||||
node.namespace() == &ns!(svg) && node.local_name() == &local_name!("title")
|
node.namespace() == &ns!(svg) && node.local_name() == &local_name!("title")
|
||||||
});
|
});
|
||||||
match elem {
|
match elem {
|
||||||
Some(elem) => Root::upcast::<Node>(elem),
|
Some(elem) => DomRoot::upcast::<Node>(elem),
|
||||||
None => {
|
None => {
|
||||||
let name = QualName::new(None, ns!(svg), local_name!("title"));
|
let name = QualName::new(None, ns!(svg), local_name!("title"));
|
||||||
let elem = Element::create(name,
|
let elem = Element::create(name,
|
||||||
|
@ -3292,18 +3292,18 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-head
|
// https://html.spec.whatwg.org/multipage/#dom-document-head
|
||||||
fn GetHead(&self) -> Option<Root<HTMLHeadElement>> {
|
fn GetHead(&self) -> Option<DomRoot<HTMLHeadElement>> {
|
||||||
self.get_html_element()
|
self.get_html_element()
|
||||||
.and_then(|root| root.upcast::<Node>().children().filter_map(Root::downcast).next())
|
.and_then(|root| root.upcast::<Node>().children().filter_map(DomRoot::downcast).next())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-currentscript
|
// https://html.spec.whatwg.org/multipage/#dom-document-currentscript
|
||||||
fn GetCurrentScript(&self) -> Option<Root<HTMLScriptElement>> {
|
fn GetCurrentScript(&self) -> Option<DomRoot<HTMLScriptElement>> {
|
||||||
self.current_script.get()
|
self.current_script.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-body
|
// https://html.spec.whatwg.org/multipage/#dom-document-body
|
||||||
fn GetBody(&self) -> Option<Root<HTMLElement>> {
|
fn GetBody(&self) -> Option<DomRoot<HTMLElement>> {
|
||||||
self.get_html_element().and_then(|root| {
|
self.get_html_element().and_then(|root| {
|
||||||
let node = root.upcast::<Node>();
|
let node = root.upcast::<Node>();
|
||||||
node.children().find(|child| {
|
node.children().find(|child| {
|
||||||
|
@ -3312,7 +3312,7 @@ impl DocumentMethods for Document {
|
||||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFrameSetElement)) => true,
|
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFrameSetElement)) => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}).map(|node| Root::downcast(node).unwrap())
|
}).map(|node| DomRoot::downcast(node).unwrap())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3357,7 +3357,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname
|
// https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname
|
||||||
fn GetElementsByName(&self, name: DOMString) -> Root<NodeList> {
|
fn GetElementsByName(&self, name: DOMString) -> DomRoot<NodeList> {
|
||||||
self.create_node_list(|node| {
|
self.create_node_list(|node| {
|
||||||
let element = match node.downcast::<Element>() {
|
let element = match node.downcast::<Element>() {
|
||||||
Some(element) => element,
|
Some(element) => element,
|
||||||
|
@ -3372,7 +3372,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-images
|
// https://html.spec.whatwg.org/multipage/#dom-document-images
|
||||||
fn Images(&self) -> Root<HTMLCollection> {
|
fn Images(&self) -> DomRoot<HTMLCollection> {
|
||||||
self.images.or_init(|| {
|
self.images.or_init(|| {
|
||||||
let filter = box ImagesFilter;
|
let filter = box ImagesFilter;
|
||||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||||
|
@ -3380,7 +3380,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-embeds
|
// https://html.spec.whatwg.org/multipage/#dom-document-embeds
|
||||||
fn Embeds(&self) -> Root<HTMLCollection> {
|
fn Embeds(&self) -> DomRoot<HTMLCollection> {
|
||||||
self.embeds.or_init(|| {
|
self.embeds.or_init(|| {
|
||||||
let filter = box EmbedsFilter;
|
let filter = box EmbedsFilter;
|
||||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||||
|
@ -3388,12 +3388,12 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-plugins
|
// https://html.spec.whatwg.org/multipage/#dom-document-plugins
|
||||||
fn Plugins(&self) -> Root<HTMLCollection> {
|
fn Plugins(&self) -> DomRoot<HTMLCollection> {
|
||||||
self.Embeds()
|
self.Embeds()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-links
|
// https://html.spec.whatwg.org/multipage/#dom-document-links
|
||||||
fn Links(&self) -> Root<HTMLCollection> {
|
fn Links(&self) -> DomRoot<HTMLCollection> {
|
||||||
self.links.or_init(|| {
|
self.links.or_init(|| {
|
||||||
let filter = box LinksFilter;
|
let filter = box LinksFilter;
|
||||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||||
|
@ -3401,7 +3401,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-forms
|
// https://html.spec.whatwg.org/multipage/#dom-document-forms
|
||||||
fn Forms(&self) -> Root<HTMLCollection> {
|
fn Forms(&self) -> DomRoot<HTMLCollection> {
|
||||||
self.forms.or_init(|| {
|
self.forms.or_init(|| {
|
||||||
let filter = box FormsFilter;
|
let filter = box FormsFilter;
|
||||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||||
|
@ -3409,7 +3409,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-scripts
|
// https://html.spec.whatwg.org/multipage/#dom-document-scripts
|
||||||
fn Scripts(&self) -> Root<HTMLCollection> {
|
fn Scripts(&self) -> DomRoot<HTMLCollection> {
|
||||||
self.scripts.or_init(|| {
|
self.scripts.or_init(|| {
|
||||||
let filter = box ScriptsFilter;
|
let filter = box ScriptsFilter;
|
||||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||||
|
@ -3417,7 +3417,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-anchors
|
// https://html.spec.whatwg.org/multipage/#dom-document-anchors
|
||||||
fn Anchors(&self) -> Root<HTMLCollection> {
|
fn Anchors(&self) -> DomRoot<HTMLCollection> {
|
||||||
self.anchors.or_init(|| {
|
self.anchors.or_init(|| {
|
||||||
let filter = box AnchorsFilter;
|
let filter = box AnchorsFilter;
|
||||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||||
|
@ -3425,7 +3425,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-applets
|
// https://html.spec.whatwg.org/multipage/#dom-document-applets
|
||||||
fn Applets(&self) -> Root<HTMLCollection> {
|
fn Applets(&self) -> DomRoot<HTMLCollection> {
|
||||||
// FIXME: This should be return OBJECT elements containing applets.
|
// FIXME: This should be return OBJECT elements containing applets.
|
||||||
self.applets.or_init(|| {
|
self.applets.or_init(|| {
|
||||||
let filter = box AppletsFilter;
|
let filter = box AppletsFilter;
|
||||||
|
@ -3434,7 +3434,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-location
|
// https://html.spec.whatwg.org/multipage/#dom-document-location
|
||||||
fn GetLocation(&self) -> Option<Root<Location>> {
|
fn GetLocation(&self) -> Option<DomRoot<Location>> {
|
||||||
if self.is_fully_active() {
|
if self.is_fully_active() {
|
||||||
Some(self.window.Location())
|
Some(self.window.Location())
|
||||||
} else {
|
} else {
|
||||||
|
@ -3443,18 +3443,18 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
||||||
fn Children(&self) -> Root<HTMLCollection> {
|
fn Children(&self) -> DomRoot<HTMLCollection> {
|
||||||
HTMLCollection::children(&self.window, self.upcast())
|
HTMLCollection::children(&self.window, self.upcast())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
|
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
|
||||||
fn GetFirstElementChild(&self) -> Option<Root<Element>> {
|
fn GetFirstElementChild(&self) -> Option<DomRoot<Element>> {
|
||||||
self.upcast::<Node>().child_elements().next()
|
self.upcast::<Node>().child_elements().next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
||||||
fn GetLastElementChild(&self) -> Option<Root<Element>> {
|
fn GetLastElementChild(&self) -> Option<DomRoot<Element>> {
|
||||||
self.upcast::<Node>().rev_children().filter_map(Root::downcast).next()
|
self.upcast::<Node>().rev_children().filter_map(DomRoot::downcast).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
||||||
|
@ -3473,13 +3473,13 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
||||||
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<Root<Element>>> {
|
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<DomRoot<Element>>> {
|
||||||
let root = self.upcast::<Node>();
|
let root = self.upcast::<Node>();
|
||||||
root.query_selector(selectors)
|
root.query_selector(selectors)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
// https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
||||||
fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<Root<NodeList>> {
|
fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<DomRoot<NodeList>> {
|
||||||
let root = self.upcast::<Node>();
|
let root = self.upcast::<Node>();
|
||||||
root.query_selector_all(selectors)
|
root.query_selector_all(selectors)
|
||||||
}
|
}
|
||||||
|
@ -3490,9 +3490,9 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-defaultview
|
// https://html.spec.whatwg.org/multipage/#dom-document-defaultview
|
||||||
fn GetDefaultView(&self) -> Option<Root<Window>> {
|
fn GetDefaultView(&self) -> Option<DomRoot<Window>> {
|
||||||
if self.has_browsing_context {
|
if self.has_browsing_context {
|
||||||
Some(Root::from_ref(&*self.window))
|
Some(DomRoot::from_ref(&*self.window))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -3673,7 +3673,7 @@ impl DocumentMethods for Document {
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-document-elementfrompoint
|
// https://drafts.csswg.org/cssom-view/#dom-document-elementfrompoint
|
||||||
fn ElementFromPoint(&self, x: Finite<f64>, y: Finite<f64>) -> Option<Root<Element>> {
|
fn ElementFromPoint(&self, x: Finite<f64>, y: Finite<f64>) -> Option<DomRoot<Element>> {
|
||||||
let x = *x as f32;
|
let x = *x as f32;
|
||||||
let y = *y as f32;
|
let y = *y as f32;
|
||||||
let point = &Point2D::new(x, y);
|
let point = &Point2D::new(x, y);
|
||||||
|
@ -3700,7 +3700,7 @@ impl DocumentMethods for Document {
|
||||||
parent_node.downcast::<Element>().unwrap()
|
parent_node.downcast::<Element>().unwrap()
|
||||||
});
|
});
|
||||||
|
|
||||||
Some(Root::from_ref(element_ref))
|
Some(DomRoot::from_ref(element_ref))
|
||||||
},
|
},
|
||||||
None => self.GetDocumentElement()
|
None => self.GetDocumentElement()
|
||||||
}
|
}
|
||||||
|
@ -3708,7 +3708,7 @@ impl DocumentMethods for Document {
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-document-elementsfrompoint
|
// https://drafts.csswg.org/cssom-view/#dom-document-elementsfrompoint
|
||||||
fn ElementsFromPoint(&self, x: Finite<f64>, y: Finite<f64>) -> Vec<Root<Element>> {
|
fn ElementsFromPoint(&self, x: Finite<f64>, y: Finite<f64>) -> Vec<DomRoot<Element>> {
|
||||||
let x = *x as f32;
|
let x = *x as f32;
|
||||||
let y = *y as f32;
|
let y = *y as f32;
|
||||||
let point = &Point2D::new(x, y);
|
let point = &Point2D::new(x, y);
|
||||||
|
@ -3727,12 +3727,12 @@ impl DocumentMethods for Document {
|
||||||
let js_runtime = unsafe { JS_GetRuntime(window.get_cx()) };
|
let js_runtime = unsafe { JS_GetRuntime(window.get_cx()) };
|
||||||
|
|
||||||
// Step 1 and Step 3
|
// Step 1 and Step 3
|
||||||
let mut elements: Vec<Root<Element>> = self.nodes_from_point(point).iter()
|
let mut elements: Vec<DomRoot<Element>> = self.nodes_from_point(point).iter()
|
||||||
.flat_map(|&untrusted_node_address| {
|
.flat_map(|&untrusted_node_address| {
|
||||||
let node = unsafe {
|
let node = unsafe {
|
||||||
node::from_untrusted_node_address(js_runtime, untrusted_node_address)
|
node::from_untrusted_node_address(js_runtime, untrusted_node_address)
|
||||||
};
|
};
|
||||||
Root::downcast::<Element>(node)
|
DomRoot::downcast::<Element>(node)
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
// Step 4
|
// Step 4
|
||||||
|
@ -3747,7 +3747,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-open
|
// https://html.spec.whatwg.org/multipage/#dom-document-open
|
||||||
fn Open(&self, type_: DOMString, replace: DOMString) -> Fallible<Root<Document>> {
|
fn Open(&self, type_: DOMString, replace: DOMString) -> Fallible<DomRoot<Document>> {
|
||||||
if !self.is_html_document() {
|
if !self.is_html_document() {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState);
|
||||||
|
@ -3758,7 +3758,7 @@ impl DocumentMethods for Document {
|
||||||
|
|
||||||
if !self.is_active() {
|
if !self.is_active() {
|
||||||
// Step 3.
|
// Step 3.
|
||||||
return Ok(Root::from_ref(self));
|
return Ok(DomRoot::from_ref(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
let entry_responsible_document = GlobalScope::entry().as_window().Document();
|
let entry_responsible_document = GlobalScope::entry().as_window().Document();
|
||||||
|
@ -3773,7 +3773,7 @@ impl DocumentMethods for Document {
|
||||||
|
|
||||||
if self.get_current_parser().map_or(false, |parser| parser.script_nesting_level() > 0) {
|
if self.get_current_parser().map_or(false, |parser| parser.script_nesting_level() > 0) {
|
||||||
// Step 5.
|
// Step 5.
|
||||||
return Ok(Root::from_ref(self));
|
return Ok(DomRoot::from_ref(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 6.
|
// Step 6.
|
||||||
|
@ -3889,7 +3889,7 @@ impl DocumentMethods for Document {
|
||||||
// Step 34 is handled when creating the parser in step 25.
|
// Step 34 is handled when creating the parser in step 25.
|
||||||
|
|
||||||
// Step 35.
|
// Step 35.
|
||||||
Ok(Root::from_ref(self))
|
Ok(DomRoot::from_ref(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-write
|
// https://html.spec.whatwg.org/multipage/#dom-document-write
|
||||||
|
@ -3907,7 +3907,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
let parser = match self.get_current_parser() {
|
let parser = match self.get_current_parser() {
|
||||||
Some(ref parser) if parser.can_write() => Root::from_ref(&**parser),
|
Some(ref parser) if parser.can_write() => DomRoot::from_ref(&**parser),
|
||||||
_ => {
|
_ => {
|
||||||
// Either there is no parser, which means the parsing ended;
|
// Either there is no parser, which means the parsing ended;
|
||||||
// or script nesting level is 0, which means the method was
|
// or script nesting level is 0, which means the method was
|
||||||
|
@ -3950,7 +3950,7 @@ impl DocumentMethods for Document {
|
||||||
// TODO: handle throw-on-dynamic-markup-insertion counter.
|
// TODO: handle throw-on-dynamic-markup-insertion counter.
|
||||||
|
|
||||||
let parser = match self.get_current_parser() {
|
let parser = match self.get_current_parser() {
|
||||||
Some(ref parser) if parser.is_script_created() => Root::from_ref(&**parser),
|
Some(ref parser) if parser.is_script_created() => DomRoot::from_ref(&**parser),
|
||||||
_ => {
|
_ => {
|
||||||
// Step 3.
|
// Step 3.
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -3983,7 +3983,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://fullscreen.spec.whatwg.org/#dom-document-fullscreenelement
|
// https://fullscreen.spec.whatwg.org/#dom-document-fullscreenelement
|
||||||
fn GetFullscreenElement(&self) -> Option<Root<Element>> {
|
fn GetFullscreenElement(&self) -> Option<DomRoot<Element>> {
|
||||||
// TODO ShadowRoot
|
// TODO ShadowRoot
|
||||||
self.fullscreen_element.get()
|
self.fullscreen_element.get()
|
||||||
}
|
}
|
||||||
|
@ -4099,7 +4099,7 @@ impl PendingInOrderScriptVec {
|
||||||
entry.loaded(result);
|
entry.loaded(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn take_next_ready_to_be_executed(&self) -> Option<(Root<HTMLScriptElement>, ScriptResult)> {
|
fn take_next_ready_to_be_executed(&self) -> Option<(DomRoot<HTMLScriptElement>, ScriptResult)> {
|
||||||
let mut scripts = self.scripts.borrow_mut();
|
let mut scripts = self.scripts.borrow_mut();
|
||||||
let pair = scripts.front_mut().and_then(PendingScript::take_result);
|
let pair = scripts.front_mut().and_then(PendingScript::take_result);
|
||||||
if pair.is_none() {
|
if pair.is_none() {
|
||||||
|
@ -4135,7 +4135,7 @@ impl PendingScript {
|
||||||
self.load = Some(result);
|
self.load = Some(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn take_result(&mut self) -> Option<(Root<HTMLScriptElement>, ScriptResult)> {
|
fn take_result(&mut self) -> Option<(DomRoot<HTMLScriptElement>, ScriptResult)> {
|
||||||
self.load.take().map(|result| (Root::from_ref(&*self.element), result))
|
self.load.take().map(|result| (DomRoot::from_ref(&*self.element), result))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
||||||
use dom::bindings::error::{ErrorResult, Fallible};
|
use dom::bindings::error::{ErrorResult, Fallible};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
|
@ -33,13 +33,13 @@ impl DocumentFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(document: &Document) -> Root<DocumentFragment> {
|
pub fn new(document: &Document) -> DomRoot<DocumentFragment> {
|
||||||
Node::reflect_node(box DocumentFragment::new_inherited(document),
|
Node::reflect_node(box DocumentFragment::new_inherited(document),
|
||||||
document,
|
document,
|
||||||
DocumentFragmentBinding::Wrap)
|
DocumentFragmentBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(window: &Window) -> Fallible<Root<DocumentFragment>> {
|
pub fn Constructor(window: &Window) -> Fallible<DomRoot<DocumentFragment>> {
|
||||||
let document = window.Document();
|
let document = window.Document();
|
||||||
|
|
||||||
Ok(DocumentFragment::new(&document))
|
Ok(DocumentFragment::new(&document))
|
||||||
|
@ -48,16 +48,16 @@ impl DocumentFragment {
|
||||||
|
|
||||||
impl DocumentFragmentMethods for DocumentFragment {
|
impl DocumentFragmentMethods for DocumentFragment {
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
||||||
fn Children(&self) -> Root<HTMLCollection> {
|
fn Children(&self) -> DomRoot<HTMLCollection> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
HTMLCollection::children(&window, self.upcast())
|
HTMLCollection::children(&window, self.upcast())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
// https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
||||||
fn GetElementById(&self, id: DOMString) -> Option<Root<Element>> {
|
fn GetElementById(&self, id: DOMString) -> Option<DomRoot<Element>> {
|
||||||
let node = self.upcast::<Node>();
|
let node = self.upcast::<Node>();
|
||||||
let id = Atom::from(id);
|
let id = Atom::from(id);
|
||||||
node.traverse_preorder().filter_map(Root::downcast::<Element>).find(|descendant| {
|
node.traverse_preorder().filter_map(DomRoot::downcast::<Element>).find(|descendant| {
|
||||||
match descendant.get_attribute(&ns!(), &local_name!("id")) {
|
match descendant.get_attribute(&ns!(), &local_name!("id")) {
|
||||||
None => false,
|
None => false,
|
||||||
Some(attr) => *attr.value().as_atom() == id,
|
Some(attr) => *attr.value().as_atom() == id,
|
||||||
|
@ -66,13 +66,13 @@ impl DocumentFragmentMethods for DocumentFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
|
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
|
||||||
fn GetFirstElementChild(&self) -> Option<Root<Element>> {
|
fn GetFirstElementChild(&self) -> Option<DomRoot<Element>> {
|
||||||
self.upcast::<Node>().child_elements().next()
|
self.upcast::<Node>().child_elements().next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
||||||
fn GetLastElementChild(&self) -> Option<Root<Element>> {
|
fn GetLastElementChild(&self) -> Option<DomRoot<Element>> {
|
||||||
self.upcast::<Node>().rev_children().filter_map(Root::downcast::<Element>).next()
|
self.upcast::<Node>().rev_children().filter_map(DomRoot::downcast::<Element>).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
||||||
|
@ -91,12 +91,12 @@ impl DocumentFragmentMethods for DocumentFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
||||||
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<Root<Element>>> {
|
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<DomRoot<Element>>> {
|
||||||
self.upcast::<Node>().query_selector(selectors)
|
self.upcast::<Node>().query_selector(selectors)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
// https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
||||||
fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<Root<NodeList>> {
|
fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<DomRoot<NodeList>> {
|
||||||
self.upcast::<Node>().query_selector_all(selectors)
|
self.upcast::<Node>().query_selector_all(selectors)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DocumentTypeBinding::DocumentTypeMethods;
|
||||||
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
||||||
use dom::bindings::error::ErrorResult;
|
use dom::bindings::error::ErrorResult;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::node::Node;
|
use dom::node::Node;
|
||||||
|
@ -41,7 +41,7 @@ impl DocumentType {
|
||||||
public_id: Option<DOMString>,
|
public_id: Option<DOMString>,
|
||||||
system_id: Option<DOMString>,
|
system_id: Option<DOMString>,
|
||||||
document: &Document)
|
document: &Document)
|
||||||
-> Root<DocumentType> {
|
-> DomRoot<DocumentType> {
|
||||||
Node::reflect_node(box DocumentType::new_inherited(name, public_id, system_id, document),
|
Node::reflect_node(box DocumentType::new_inherited(name, public_id, system_id, document),
|
||||||
document,
|
document,
|
||||||
DocumentTypeBinding::Wrap)
|
DocumentTypeBinding::Wrap)
|
||||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::DOMExceptionBinding;
|
||||||
use dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionConstants;
|
use dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionConstants;
|
||||||
use dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionMethods;
|
use dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionMethods;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -51,7 +51,7 @@ impl DOMException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, code: DOMErrorName) -> Root<DOMException> {
|
pub fn new(global: &GlobalScope, code: DOMErrorName) -> DomRoot<DOMException> {
|
||||||
reflect_dom_object(box DOMException::new_inherited(code),
|
reflect_dom_object(box DOMException::new_inherited(code),
|
||||||
global,
|
global,
|
||||||
DOMExceptionBinding::Wrap)
|
DOMExceptionBinding::Wrap)
|
||||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bindings::xmlname::{namespace_from_domstring, validate_qualified_name};
|
use dom::bindings::xmlname::{namespace_from_domstring, validate_qualified_name};
|
||||||
use dom::document::{Document, HasBrowsingContext, IsHTMLDocument};
|
use dom::document::{Document, HasBrowsingContext, IsHTMLDocument};
|
||||||
|
@ -41,7 +41,7 @@ impl DOMImplementation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(document: &Document) -> Root<DOMImplementation> {
|
pub fn new(document: &Document) -> DomRoot<DOMImplementation> {
|
||||||
let window = document.window();
|
let window = document.window();
|
||||||
reflect_dom_object(box DOMImplementation::new_inherited(document),
|
reflect_dom_object(box DOMImplementation::new_inherited(document),
|
||||||
window,
|
window,
|
||||||
|
@ -56,7 +56,7 @@ impl DOMImplementationMethods for DOMImplementation {
|
||||||
qualified_name: DOMString,
|
qualified_name: DOMString,
|
||||||
pubid: DOMString,
|
pubid: DOMString,
|
||||||
sysid: DOMString)
|
sysid: DOMString)
|
||||||
-> Fallible<Root<DocumentType>> {
|
-> Fallible<DomRoot<DocumentType>> {
|
||||||
validate_qualified_name(&qualified_name)?;
|
validate_qualified_name(&qualified_name)?;
|
||||||
Ok(DocumentType::new(qualified_name, Some(pubid), Some(sysid), &self.document))
|
Ok(DocumentType::new(qualified_name, Some(pubid), Some(sysid), &self.document))
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ impl DOMImplementationMethods for DOMImplementation {
|
||||||
maybe_namespace: Option<DOMString>,
|
maybe_namespace: Option<DOMString>,
|
||||||
qname: DOMString,
|
qname: DOMString,
|
||||||
maybe_doctype: Option<&DocumentType>)
|
maybe_doctype: Option<&DocumentType>)
|
||||||
-> Fallible<Root<XMLDocument>> {
|
-> Fallible<DomRoot<XMLDocument>> {
|
||||||
let win = self.document.window();
|
let win = self.document.window();
|
||||||
let loader = DocumentLoader::new(&self.document.loader());
|
let loader = DocumentLoader::new(&self.document.loader());
|
||||||
let namespace = namespace_from_domstring(maybe_namespace.to_owned());
|
let namespace = namespace_from_domstring(maybe_namespace.to_owned());
|
||||||
|
@ -121,7 +121,7 @@ impl DOMImplementationMethods for DOMImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
// https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
||||||
fn CreateHTMLDocument(&self, title: Option<DOMString>) -> Root<Document> {
|
fn CreateHTMLDocument(&self, title: Option<DOMString>) -> DomRoot<Document> {
|
||||||
let win = self.document.window();
|
let win = self.document.window();
|
||||||
let loader = DocumentLoader::new(&self.document.loader());
|
let loader = DocumentLoader::new(&self.document.loader());
|
||||||
|
|
||||||
|
@ -149,14 +149,14 @@ impl DOMImplementationMethods for DOMImplementation {
|
||||||
{
|
{
|
||||||
// Step 4.
|
// Step 4.
|
||||||
let doc_node = doc.upcast::<Node>();
|
let doc_node = doc.upcast::<Node>();
|
||||||
let doc_html = Root::upcast::<Node>(HTMLHtmlElement::new(local_name!("html"),
|
let doc_html = DomRoot::upcast::<Node>(HTMLHtmlElement::new(local_name!("html"),
|
||||||
None,
|
None,
|
||||||
&doc));
|
&doc));
|
||||||
doc_node.AppendChild(&doc_html).expect("Appending failed");
|
doc_node.AppendChild(&doc_html).expect("Appending failed");
|
||||||
|
|
||||||
{
|
{
|
||||||
// Step 5.
|
// Step 5.
|
||||||
let doc_head = Root::upcast::<Node>(HTMLHeadElement::new(local_name!("head"),
|
let doc_head = DomRoot::upcast::<Node>(HTMLHeadElement::new(local_name!("head"),
|
||||||
None,
|
None,
|
||||||
&doc));
|
&doc));
|
||||||
doc_html.AppendChild(&doc_head).unwrap();
|
doc_html.AppendChild(&doc_head).unwrap();
|
||||||
|
@ -165,7 +165,7 @@ impl DOMImplementationMethods for DOMImplementation {
|
||||||
if let Some(title_str) = title {
|
if let Some(title_str) = title {
|
||||||
// Step 6.1.
|
// Step 6.1.
|
||||||
let doc_title =
|
let doc_title =
|
||||||
Root::upcast::<Node>(HTMLTitleElement::new(local_name!("title"),
|
DomRoot::upcast::<Node>(HTMLTitleElement::new(local_name!("title"),
|
||||||
None,
|
None,
|
||||||
&doc));
|
&doc));
|
||||||
doc_head.AppendChild(&doc_title).unwrap();
|
doc_head.AppendChild(&doc_title).unwrap();
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::DOMMatrixReadOnl
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::dommatrixreadonly::{dommatrixinit_to_matrix, DOMMatrixReadOnly, entries_to_matrix};
|
use dom::dommatrixreadonly::{dommatrixinit_to_matrix, DOMMatrixReadOnly, entries_to_matrix};
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -21,7 +21,7 @@ pub struct DOMMatrix {
|
||||||
|
|
||||||
impl DOMMatrix {
|
impl DOMMatrix {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> Root<Self> {
|
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> {
|
||||||
let dommatrix = Self::new_inherited(is2D, matrix);
|
let dommatrix = Self::new_inherited(is2D, matrix);
|
||||||
reflect_dom_object(box dommatrix, global, Wrap)
|
reflect_dom_object(box dommatrix, global, Wrap)
|
||||||
}
|
}
|
||||||
|
@ -33,12 +33,12 @@ impl DOMMatrix {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-dommatrix
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-dommatrix
|
||||||
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Self>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<DomRoot<Self>> {
|
||||||
Self::Constructor_(global, vec![1.0, 0.0, 0.0, 1.0, 0.0, 0.0])
|
Self::Constructor_(global, vec![1.0, 0.0, 0.0, 1.0, 0.0, 0.0])
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-dommatrix-numbersequence
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-dommatrix-numbersequence
|
||||||
pub fn Constructor_(global: &GlobalScope, entries: Vec<f64>) -> Fallible<Root<Self>> {
|
pub fn Constructor_(global: &GlobalScope, entries: Vec<f64>) -> Fallible<DomRoot<Self>> {
|
||||||
entries_to_matrix(&entries[..])
|
entries_to_matrix(&entries[..])
|
||||||
.map(|(is2D, matrix)| {
|
.map(|(is2D, matrix)| {
|
||||||
Self::new(global, is2D, matrix)
|
Self::new(global, is2D, matrix)
|
||||||
|
@ -46,14 +46,14 @@ impl DOMMatrix {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-frommatrix
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-frommatrix
|
||||||
pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible<Root<Self>> {
|
pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible<DomRoot<Self>> {
|
||||||
dommatrixinit_to_matrix(&other)
|
dommatrixinit_to_matrix(&other)
|
||||||
.map(|(is2D, matrix)| {
|
.map(|(is2D, matrix)| {
|
||||||
Self::new(global, is2D, matrix)
|
Self::new(global, is2D, matrix)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_readonly(global: &GlobalScope, ro: &DOMMatrixReadOnly) -> Root<Self> {
|
pub fn from_readonly(global: &GlobalScope, ro: &DOMMatrixReadOnly) -> DomRoot<Self> {
|
||||||
Self::new(global, ro.is_2d(), ro.matrix().clone())
|
Self::new(global, ro.is_2d(), ro.matrix().clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -280,91 +280,91 @@ impl DOMMatrixMethods for DOMMatrix {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-multiplyself
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-multiplyself
|
||||||
fn MultiplySelf(&self, other:&DOMMatrixInit) -> Fallible<Root<DOMMatrix>> {
|
fn MultiplySelf(&self, other:&DOMMatrixInit) -> Fallible<DomRoot<DOMMatrix>> {
|
||||||
// Steps 1-3.
|
// Steps 1-3.
|
||||||
self.upcast::<DOMMatrixReadOnly>().multiply_self(other)
|
self.upcast::<DOMMatrixReadOnly>().multiply_self(other)
|
||||||
// Step 4.
|
// Step 4.
|
||||||
.and(Ok(Root::from_ref(&self)))
|
.and(Ok(DomRoot::from_ref(&self)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-premultiplyself
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-premultiplyself
|
||||||
fn PreMultiplySelf(&self, other:&DOMMatrixInit) -> Fallible<Root<DOMMatrix>> {
|
fn PreMultiplySelf(&self, other:&DOMMatrixInit) -> Fallible<DomRoot<DOMMatrix>> {
|
||||||
// Steps 1-3.
|
// Steps 1-3.
|
||||||
self.upcast::<DOMMatrixReadOnly>().pre_multiply_self(other)
|
self.upcast::<DOMMatrixReadOnly>().pre_multiply_self(other)
|
||||||
// Step 4.
|
// Step 4.
|
||||||
.and(Ok(Root::from_ref(&self)))
|
.and(Ok(DomRoot::from_ref(&self)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-translateself
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-translateself
|
||||||
fn TranslateSelf(&self, tx: f64, ty: f64, tz: f64) -> Root<DOMMatrix> {
|
fn TranslateSelf(&self, tx: f64, ty: f64, tz: f64) -> DomRoot<DOMMatrix> {
|
||||||
// Steps 1-2.
|
// Steps 1-2.
|
||||||
self.upcast::<DOMMatrixReadOnly>().translate_self(tx, ty, tz);
|
self.upcast::<DOMMatrixReadOnly>().translate_self(tx, ty, tz);
|
||||||
// Step 3.
|
// Step 3.
|
||||||
Root::from_ref(&self)
|
DomRoot::from_ref(&self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scaleself
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scaleself
|
||||||
fn ScaleSelf(&self, scaleX: f64, scaleY: Option<f64>, scaleZ: f64,
|
fn ScaleSelf(&self, scaleX: f64, scaleY: Option<f64>, scaleZ: f64,
|
||||||
originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
|
originX: f64, originY: f64, originZ: f64) -> DomRoot<DOMMatrix> {
|
||||||
// Steps 1-6.
|
// Steps 1-6.
|
||||||
self.upcast::<DOMMatrixReadOnly>().scale_self(scaleX, scaleY, scaleZ, originX, originY, originZ);
|
self.upcast::<DOMMatrixReadOnly>().scale_self(scaleX, scaleY, scaleZ, originX, originY, originZ);
|
||||||
// Step 7.
|
// Step 7.
|
||||||
Root::from_ref(&self)
|
DomRoot::from_ref(&self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scale3dself
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scale3dself
|
||||||
fn Scale3dSelf(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
|
fn Scale3dSelf(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> DomRoot<DOMMatrix> {
|
||||||
// Steps 1-4.
|
// Steps 1-4.
|
||||||
self.upcast::<DOMMatrixReadOnly>().scale_3d_self(scale, originX, originY, originZ);
|
self.upcast::<DOMMatrixReadOnly>().scale_3d_self(scale, originX, originY, originZ);
|
||||||
// Step 5.
|
// Step 5.
|
||||||
Root::from_ref(&self)
|
DomRoot::from_ref(&self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateself
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateself
|
||||||
fn RotateSelf(&self, rotX: f64, rotY: Option<f64>, rotZ: Option<f64>) -> Root<DOMMatrix> {
|
fn RotateSelf(&self, rotX: f64, rotY: Option<f64>, rotZ: Option<f64>) -> DomRoot<DOMMatrix> {
|
||||||
// Steps 1-7.
|
// Steps 1-7.
|
||||||
self.upcast::<DOMMatrixReadOnly>().rotate_self(rotX, rotY, rotZ);
|
self.upcast::<DOMMatrixReadOnly>().rotate_self(rotX, rotY, rotZ);
|
||||||
// Step 8.
|
// Step 8.
|
||||||
Root::from_ref(&self)
|
DomRoot::from_ref(&self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotatefromvectorself
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotatefromvectorself
|
||||||
fn RotateFromVectorSelf(&self, x: f64, y: f64) -> Root<DOMMatrix> {
|
fn RotateFromVectorSelf(&self, x: f64, y: f64) -> DomRoot<DOMMatrix> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
self.upcast::<DOMMatrixReadOnly>().rotate_from_vector_self(x, y);
|
self.upcast::<DOMMatrixReadOnly>().rotate_from_vector_self(x, y);
|
||||||
// Step 2.
|
// Step 2.
|
||||||
Root::from_ref(&self)
|
DomRoot::from_ref(&self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateaxisangleself
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateaxisangleself
|
||||||
fn RotateAxisAngleSelf(&self, x: f64, y: f64, z: f64, angle: f64) -> Root<DOMMatrix> {
|
fn RotateAxisAngleSelf(&self, x: f64, y: f64, z: f64, angle: f64) -> DomRoot<DOMMatrix> {
|
||||||
// Steps 1-2.
|
// Steps 1-2.
|
||||||
self.upcast::<DOMMatrixReadOnly>().rotate_axis_angle_self(x, y, z, angle);
|
self.upcast::<DOMMatrixReadOnly>().rotate_axis_angle_self(x, y, z, angle);
|
||||||
// Step 3.
|
// Step 3.
|
||||||
Root::from_ref(&self)
|
DomRoot::from_ref(&self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewxself
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewxself
|
||||||
fn SkewXSelf(&self, sx: f64) -> Root<DOMMatrix> {
|
fn SkewXSelf(&self, sx: f64) -> DomRoot<DOMMatrix> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
self.upcast::<DOMMatrixReadOnly>().skew_x_self(sx);
|
self.upcast::<DOMMatrixReadOnly>().skew_x_self(sx);
|
||||||
// Step 2.
|
// Step 2.
|
||||||
Root::from_ref(&self)
|
DomRoot::from_ref(&self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewyself
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewyself
|
||||||
fn SkewYSelf(&self, sy: f64) -> Root<DOMMatrix> {
|
fn SkewYSelf(&self, sy: f64) -> DomRoot<DOMMatrix> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
self.upcast::<DOMMatrixReadOnly>().skew_y_self(sy);
|
self.upcast::<DOMMatrixReadOnly>().skew_y_self(sy);
|
||||||
// Step 2.
|
// Step 2.
|
||||||
Root::from_ref(&self)
|
DomRoot::from_ref(&self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-invertself
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-invertself
|
||||||
fn InvertSelf(&self) -> Root<DOMMatrix> {
|
fn InvertSelf(&self) -> DomRoot<DOMMatrix> {
|
||||||
// Steps 1-2.
|
// Steps 1-2.
|
||||||
self.upcast::<DOMMatrixReadOnly>().invert_self();
|
self.upcast::<DOMMatrixReadOnly>().invert_self();
|
||||||
// Step 3.
|
// Step 3.
|
||||||
Root::from_ref(&self)
|
DomRoot::from_ref(&self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
||||||
use dom::bindings::error;
|
use dom::bindings::error;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
use dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::dommatrix::DOMMatrix;
|
use dom::dommatrix::DOMMatrix;
|
||||||
use dom::dompoint::DOMPoint;
|
use dom::dompoint::DOMPoint;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
|
@ -27,7 +27,7 @@ pub struct DOMMatrixReadOnly {
|
||||||
|
|
||||||
impl DOMMatrixReadOnly {
|
impl DOMMatrixReadOnly {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> Root<Self> {
|
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> {
|
||||||
let dommatrix = Self::new_inherited(is2D, matrix);
|
let dommatrix = Self::new_inherited(is2D, matrix);
|
||||||
reflect_dom_object(box dommatrix, global, Wrap)
|
reflect_dom_object(box dommatrix, global, Wrap)
|
||||||
}
|
}
|
||||||
|
@ -41,12 +41,12 @@ impl DOMMatrixReadOnly {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly
|
||||||
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Self>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<DomRoot<Self>> {
|
||||||
Ok(Self::new(global, true, Transform3D::identity()))
|
Ok(Self::new(global, true, Transform3D::identity()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly-numbersequence
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly-numbersequence
|
||||||
pub fn Constructor_(global: &GlobalScope, entries: Vec<f64>) -> Fallible<Root<Self>> {
|
pub fn Constructor_(global: &GlobalScope, entries: Vec<f64>) -> Fallible<DomRoot<Self>> {
|
||||||
entries_to_matrix(&entries[..])
|
entries_to_matrix(&entries[..])
|
||||||
.map(|(is2D, matrix)| {
|
.map(|(is2D, matrix)| {
|
||||||
Self::new(global, is2D, matrix)
|
Self::new(global, is2D, matrix)
|
||||||
|
@ -54,7 +54,7 @@ impl DOMMatrixReadOnly {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-frommatrix
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-frommatrix
|
||||||
pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible<Root<Self>> {
|
pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible<DomRoot<Self>> {
|
||||||
dommatrixinit_to_matrix(&other)
|
dommatrixinit_to_matrix(&other)
|
||||||
.map(|(is2D, matrix)| {
|
.map(|(is2D, matrix)| {
|
||||||
Self::new(global, is2D, matrix)
|
Self::new(global, is2D, matrix)
|
||||||
|
@ -463,55 +463,55 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-translate
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-translate
|
||||||
fn Translate(&self, tx: f64, ty: f64, tz: f64) -> Root<DOMMatrix> {
|
fn Translate(&self, tx: f64, ty: f64, tz: f64) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).TranslateSelf(tx, ty, tz)
|
DOMMatrix::from_readonly(&self.global(), self).TranslateSelf(tx, ty, tz)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale
|
||||||
fn Scale(&self, scaleX: f64, scaleY: Option<f64>, scaleZ: f64,
|
fn Scale(&self, scaleX: f64, scaleY: Option<f64>, scaleZ: f64,
|
||||||
originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
|
originX: f64, originY: f64, originZ: f64) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self)
|
DOMMatrix::from_readonly(&self.global(), self)
|
||||||
.ScaleSelf(scaleX, scaleY, scaleZ, originX, originY, originZ)
|
.ScaleSelf(scaleX, scaleY, scaleZ, originX, originY, originZ)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale3d
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale3d
|
||||||
fn Scale3d(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
|
fn Scale3d(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self)
|
DOMMatrix::from_readonly(&self.global(), self)
|
||||||
.Scale3dSelf(scale, originX, originY, originZ)
|
.Scale3dSelf(scale, originX, originY, originZ)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotate
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotate
|
||||||
fn Rotate(&self, rotX: f64, rotY: Option<f64>, rotZ: Option<f64>) -> Root<DOMMatrix> {
|
fn Rotate(&self, rotX: f64, rotY: Option<f64>, rotZ: Option<f64>) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).RotateSelf(rotX, rotY, rotZ)
|
DOMMatrix::from_readonly(&self.global(), self).RotateSelf(rotX, rotY, rotZ)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotatefromvector
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotatefromvector
|
||||||
fn RotateFromVector(&self, x: f64, y: f64) -> Root<DOMMatrix> {
|
fn RotateFromVector(&self, x: f64, y: f64) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).RotateFromVectorSelf(x, y)
|
DOMMatrix::from_readonly(&self.global(), self).RotateFromVectorSelf(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotateaxisangle
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotateaxisangle
|
||||||
fn RotateAxisAngle(&self, x: f64, y: f64, z: f64, angle: f64) -> Root<DOMMatrix> {
|
fn RotateAxisAngle(&self, x: f64, y: f64, z: f64, angle: f64) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).RotateAxisAngleSelf(x, y, z, angle)
|
DOMMatrix::from_readonly(&self.global(), self).RotateAxisAngleSelf(x, y, z, angle)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewx
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewx
|
||||||
fn SkewX(&self, sx: f64) -> Root<DOMMatrix> {
|
fn SkewX(&self, sx: f64) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).SkewXSelf(sx)
|
DOMMatrix::from_readonly(&self.global(), self).SkewXSelf(sx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewy
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewy
|
||||||
fn SkewY(&self, sy: f64) -> Root<DOMMatrix> {
|
fn SkewY(&self, sy: f64) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).SkewYSelf(sy)
|
DOMMatrix::from_readonly(&self.global(), self).SkewYSelf(sy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-multiply
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-multiply
|
||||||
fn Multiply(&self, other: &DOMMatrixInit) -> Fallible<Root<DOMMatrix>> {
|
fn Multiply(&self, other: &DOMMatrixInit) -> Fallible<DomRoot<DOMMatrix>> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).MultiplySelf(&other)
|
DOMMatrix::from_readonly(&self.global(), self).MultiplySelf(&other)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx
|
||||||
fn FlipX(&self) -> Root<DOMMatrix> {
|
fn FlipX(&self) -> DomRoot<DOMMatrix> {
|
||||||
let is2D = self.is2D.get();
|
let is2D = self.is2D.get();
|
||||||
let flip = Transform3D::row_major(-1.0, 0.0, 0.0, 0.0,
|
let flip = Transform3D::row_major(-1.0, 0.0, 0.0, 0.0,
|
||||||
0.0, 1.0, 0.0, 0.0,
|
0.0, 1.0, 0.0, 0.0,
|
||||||
|
@ -522,7 +522,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipy
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipy
|
||||||
fn FlipY(&self) -> Root<DOMMatrix> {
|
fn FlipY(&self) -> DomRoot<DOMMatrix> {
|
||||||
let is2D = self.is2D.get();
|
let is2D = self.is2D.get();
|
||||||
let flip = Transform3D::row_major(1.0, 0.0, 0.0, 0.0,
|
let flip = Transform3D::row_major(1.0, 0.0, 0.0, 0.0,
|
||||||
0.0, -1.0, 0.0, 0.0,
|
0.0, -1.0, 0.0, 0.0,
|
||||||
|
@ -533,12 +533,12 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-inverse
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-inverse
|
||||||
fn Inverse(&self) -> Root<DOMMatrix> {
|
fn Inverse(&self) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).InvertSelf()
|
DOMMatrix::from_readonly(&self.global(), self).InvertSelf()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-transformpoint
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-transformpoint
|
||||||
fn TransformPoint(&self, point: &DOMPointInit) -> Root<DOMPoint> {
|
fn TransformPoint(&self, point: &DOMPointInit) -> DomRoot<DOMPoint> {
|
||||||
// Euclid always normalizes the homogeneous coordinate which is usually the right
|
// Euclid always normalizes the homogeneous coordinate which is usually the right
|
||||||
// thing but may (?) not be compliant with the CSS matrix spec (or at least is
|
// thing but may (?) not be compliant with the CSS matrix spec (or at least is
|
||||||
// probably not the behavior web authors will expect even if it is mathematically
|
// probably not the behavior web authors will expect even if it is mathematically
|
||||||
|
|
|
@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::DocumentBinding::DocumentReadyState;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::document::{Document, HasBrowsingContext, IsHTMLDocument};
|
use dom::document::{Document, HasBrowsingContext, IsHTMLDocument};
|
||||||
use dom::document::DocumentSource;
|
use dom::document::DocumentSource;
|
||||||
|
@ -36,13 +36,13 @@ impl DOMParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(window: &Window) -> Root<DOMParser> {
|
pub fn new(window: &Window) -> DomRoot<DOMParser> {
|
||||||
reflect_dom_object(box DOMParser::new_inherited(window),
|
reflect_dom_object(box DOMParser::new_inherited(window),
|
||||||
window,
|
window,
|
||||||
DOMParserBinding::Wrap)
|
DOMParserBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(window: &Window) -> Fallible<Root<DOMParser>> {
|
pub fn Constructor(window: &Window) -> Fallible<DomRoot<DOMParser>> {
|
||||||
Ok(DOMParser::new(window))
|
Ok(DOMParser::new(window))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ impl DOMParserMethods for DOMParser {
|
||||||
fn ParseFromString(&self,
|
fn ParseFromString(&self,
|
||||||
s: DOMString,
|
s: DOMString,
|
||||||
ty: DOMParserBinding::SupportedType)
|
ty: DOMParserBinding::SupportedType)
|
||||||
-> Fallible<Root<Document>> {
|
-> Fallible<DomRoot<Document>> {
|
||||||
let url = self.window.get_url();
|
let url = self.window.get_url();
|
||||||
let content_type = DOMString::from(ty.as_str());
|
let content_type = DOMString::from(ty.as_str());
|
||||||
let doc = self.window.Document();
|
let doc = self.window.Document();
|
||||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMe
|
||||||
use dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::DOMPointReadOnlyMethods;
|
use dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::DOMPointReadOnlyMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::dompointreadonly::{DOMPointReadOnly, DOMPointWriteMethods};
|
use dom::dompointreadonly::{DOMPointReadOnly, DOMPointWriteMethods};
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -24,7 +24,7 @@ impl DOMPoint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> Root<DOMPoint> {
|
pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> DomRoot<DOMPoint> {
|
||||||
reflect_dom_object(box DOMPoint::new_inherited(x, y, z, w), global, Wrap)
|
reflect_dom_object(box DOMPoint::new_inherited(x, y, z, w), global, Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,11 +33,11 @@ impl DOMPoint {
|
||||||
y: f64,
|
y: f64,
|
||||||
z: f64,
|
z: f64,
|
||||||
w: f64)
|
w: f64)
|
||||||
-> Fallible<Root<DOMPoint>> {
|
-> Fallible<DomRoot<DOMPoint>> {
|
||||||
Ok(DOMPoint::new(global, x, y, z, w))
|
Ok(DOMPoint::new(global, x, y, z, w))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_from_init(global: &GlobalScope, p: &DOMPointInit) -> Root<DOMPoint> {
|
pub fn new_from_init(global: &GlobalScope, p: &DOMPointInit) -> DomRoot<DOMPoint> {
|
||||||
DOMPoint::new(global, p.x, p.y, p.z, p.w)
|
DOMPoint::new(global, p.x, p.y, p.z, p.w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::{DOMPointReadOnlyMethods, Wrap};
|
use dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::{DOMPointReadOnlyMethods, Wrap};
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
@ -31,7 +31,7 @@ impl DOMPointReadOnly {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> Root<DOMPointReadOnly> {
|
pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> DomRoot<DOMPointReadOnly> {
|
||||||
reflect_dom_object(box DOMPointReadOnly::new_inherited(x, y, z, w),
|
reflect_dom_object(box DOMPointReadOnly::new_inherited(x, y, z, w),
|
||||||
global,
|
global,
|
||||||
Wrap)
|
Wrap)
|
||||||
|
@ -42,7 +42,7 @@ impl DOMPointReadOnly {
|
||||||
y: f64,
|
y: f64,
|
||||||
z: f64,
|
z: f64,
|
||||||
w: f64)
|
w: f64)
|
||||||
-> Fallible<Root<DOMPointReadOnly>> {
|
-> Fallible<DomRoot<DOMPointReadOnly>> {
|
||||||
Ok(DOMPointReadOnly::new(global, x, y, z, w))
|
Ok(DOMPointReadOnly::new(global, x, y, z, w))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DOMQuadBinding::{DOMQuadInit, DOMQuadMetho
|
||||||
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectInit;
|
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectInit;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Root, Dom};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::dompoint::DOMPoint;
|
use dom::dompoint::DOMPoint;
|
||||||
use dom::domrect::DOMRect;
|
use dom::domrect::DOMRect;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
|
@ -42,7 +42,7 @@ impl DOMQuad {
|
||||||
p1: &DOMPoint,
|
p1: &DOMPoint,
|
||||||
p2: &DOMPoint,
|
p2: &DOMPoint,
|
||||||
p3: &DOMPoint,
|
p3: &DOMPoint,
|
||||||
p4: &DOMPoint) -> Root<DOMQuad> {
|
p4: &DOMPoint) -> DomRoot<DOMQuad> {
|
||||||
reflect_dom_object(box DOMQuad::new_inherited(p1, p2, p3, p4),
|
reflect_dom_object(box DOMQuad::new_inherited(p1, p2, p3, p4),
|
||||||
global,
|
global,
|
||||||
Wrap)
|
Wrap)
|
||||||
|
@ -53,7 +53,7 @@ impl DOMQuad {
|
||||||
p2: &DOMPointInit,
|
p2: &DOMPointInit,
|
||||||
p3: &DOMPointInit,
|
p3: &DOMPointInit,
|
||||||
p4: &DOMPointInit)
|
p4: &DOMPointInit)
|
||||||
-> Fallible<Root<DOMQuad>> {
|
-> Fallible<DomRoot<DOMQuad>> {
|
||||||
Ok(DOMQuad::new(global,
|
Ok(DOMQuad::new(global,
|
||||||
&*DOMPoint::new_from_init(global, p1),
|
&*DOMPoint::new_from_init(global, p1),
|
||||||
&*DOMPoint::new_from_init(global, p2),
|
&*DOMPoint::new_from_init(global, p2),
|
||||||
|
@ -62,7 +62,7 @@ impl DOMQuad {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domquad-fromrect
|
// https://drafts.fxtf.org/geometry/#dom-domquad-fromrect
|
||||||
pub fn FromRect(global: &GlobalScope, other: &DOMRectInit) -> Root<DOMQuad> {
|
pub fn FromRect(global: &GlobalScope, other: &DOMRectInit) -> DomRoot<DOMQuad> {
|
||||||
DOMQuad::new(global,
|
DOMQuad::new(global,
|
||||||
&*DOMPoint::new(global, other.x, other.y, 0f64, 1f64),
|
&*DOMPoint::new(global, other.x, other.y, 0f64, 1f64),
|
||||||
&*DOMPoint::new(global, other.x + other.width, other.y, 0f64, 1f64),
|
&*DOMPoint::new(global, other.x + other.width, other.y, 0f64, 1f64),
|
||||||
|
@ -71,7 +71,7 @@ impl DOMQuad {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domquad-fromquad
|
// https://drafts.fxtf.org/geometry/#dom-domquad-fromquad
|
||||||
pub fn FromQuad(global: &GlobalScope, other: &DOMQuadInit) -> Root<DOMQuad> {
|
pub fn FromQuad(global: &GlobalScope, other: &DOMQuadInit) -> DomRoot<DOMQuad> {
|
||||||
DOMQuad::new(global,
|
DOMQuad::new(global,
|
||||||
&DOMPoint::new_from_init(global, &other.p1),
|
&DOMPoint::new_from_init(global, &other.p1),
|
||||||
&DOMPoint::new_from_init(global, &other.p2),
|
&DOMPoint::new_from_init(global, &other.p2),
|
||||||
|
@ -82,27 +82,27 @@ impl DOMQuad {
|
||||||
|
|
||||||
impl DOMQuadMethods for DOMQuad {
|
impl DOMQuadMethods for DOMQuad {
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domquad-p1
|
// https://drafts.fxtf.org/geometry/#dom-domquad-p1
|
||||||
fn P1(&self) -> Root<DOMPoint> {
|
fn P1(&self) -> DomRoot<DOMPoint> {
|
||||||
Root::from_ref(&self.p1)
|
DomRoot::from_ref(&self.p1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domquad-p2
|
// https://drafts.fxtf.org/geometry/#dom-domquad-p2
|
||||||
fn P2(&self) -> Root<DOMPoint> {
|
fn P2(&self) -> DomRoot<DOMPoint> {
|
||||||
Root::from_ref(&self.p2)
|
DomRoot::from_ref(&self.p2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domquad-p3
|
// https://drafts.fxtf.org/geometry/#dom-domquad-p3
|
||||||
fn P3(&self) -> Root<DOMPoint> {
|
fn P3(&self) -> DomRoot<DOMPoint> {
|
||||||
Root::from_ref(&self.p3)
|
DomRoot::from_ref(&self.p3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domquad-p4
|
// https://drafts.fxtf.org/geometry/#dom-domquad-p4
|
||||||
fn P4(&self) -> Root<DOMPoint> {
|
fn P4(&self) -> DomRoot<DOMPoint> {
|
||||||
Root::from_ref(&self.p4)
|
DomRoot::from_ref(&self.p4)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domquad-getbounds
|
// https://drafts.fxtf.org/geometry/#dom-domquad-getbounds
|
||||||
fn GetBounds(&self) -> Root<DOMRect> {
|
fn GetBounds(&self) -> DomRoot<DOMRect> {
|
||||||
let left = self.p1.X().min(self.p2.X()).min(self.p3.X()).min(self.p4.X());
|
let left = self.p1.X().min(self.p2.X()).min(self.p3.X()).min(self.p4.X());
|
||||||
let top = self.p1.Y().min(self.p2.Y()).min(self.p3.Y()).min(self.p4.Y());
|
let top = self.p1.Y().min(self.p2.Y()).min(self.p3.Y()).min(self.p4.Y());
|
||||||
let right = self.p1.X().max(self.p2.X()).max(self.p3.X()).max(self.p4.X());
|
let right = self.p1.X().max(self.p2.X()).max(self.p3.X()).max(self.p4.X());
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
|
||||||
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectReadOnlyMethods;
|
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectReadOnlyMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::domrectreadonly::DOMRectReadOnly;
|
use dom::domrectreadonly::DOMRectReadOnly;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -24,7 +24,7 @@ impl DOMRect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, x: f64, y: f64, width: f64, height: f64) -> Root<DOMRect> {
|
pub fn new(global: &GlobalScope, x: f64, y: f64, width: f64, height: f64) -> DomRoot<DOMRect> {
|
||||||
reflect_dom_object(box DOMRect::new_inherited(x, y, width, height),
|
reflect_dom_object(box DOMRect::new_inherited(x, y, width, height),
|
||||||
global,
|
global,
|
||||||
DOMRectBinding::Wrap)
|
DOMRectBinding::Wrap)
|
||||||
|
@ -35,7 +35,7 @@ impl DOMRect {
|
||||||
y: f64,
|
y: f64,
|
||||||
width: f64,
|
width: f64,
|
||||||
height: f64)
|
height: f64)
|
||||||
-> Fallible<Root<DOMRect>> {
|
-> Fallible<DomRoot<DOMRect>> {
|
||||||
Ok(DOMRect::new(global, x, y, width, height))
|
Ok(DOMRect::new(global, x, y, width, height))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::{DOMRectReadOnlyMethods, Wrap};
|
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::{DOMRectReadOnlyMethods, Wrap};
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
@ -35,7 +35,7 @@ impl DOMRectReadOnly {
|
||||||
y: f64,
|
y: f64,
|
||||||
width: f64,
|
width: f64,
|
||||||
height: f64)
|
height: f64)
|
||||||
-> Root<DOMRectReadOnly> {
|
-> DomRoot<DOMRectReadOnly> {
|
||||||
reflect_dom_object(box DOMRectReadOnly::new_inherited(x, y, width, height),
|
reflect_dom_object(box DOMRectReadOnly::new_inherited(x, y, width, height),
|
||||||
global,
|
global,
|
||||||
Wrap)
|
Wrap)
|
||||||
|
@ -46,7 +46,7 @@ impl DOMRectReadOnly {
|
||||||
y: f64,
|
y: f64,
|
||||||
width: f64,
|
width: f64,
|
||||||
height: f64)
|
height: f64)
|
||||||
-> Fallible<Root<DOMRectReadOnly>> {
|
-> Fallible<DomRoot<DOMRectReadOnly>> {
|
||||||
Ok(DOMRectReadOnly::new(global, x, y, width, height))
|
Ok(DOMRectReadOnly::new(global, x, y, width, height))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::DOMStringMapBinding;
|
||||||
use dom::bindings::codegen::Bindings::DOMStringMapBinding::DOMStringMapMethods;
|
use dom::bindings::codegen::Bindings::DOMStringMapBinding::DOMStringMapMethods;
|
||||||
use dom::bindings::error::ErrorResult;
|
use dom::bindings::error::ErrorResult;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::node::window_from_node;
|
use dom::node::window_from_node;
|
||||||
|
@ -26,7 +26,7 @@ impl DOMStringMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(element: &HTMLElement) -> Root<DOMStringMap> {
|
pub fn new(element: &HTMLElement) -> DomRoot<DOMStringMap> {
|
||||||
let window = window_from_node(element);
|
let window = window_from_node(element);
|
||||||
reflect_dom_object(box DOMStringMap::new_inherited(element),
|
reflect_dom_object(box DOMStringMap::new_inherited(element),
|
||||||
&*window,
|
&*window,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DOMTokenListBinding;
|
||||||
use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods;
|
use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
use dom::node::window_from_node;
|
use dom::node::window_from_node;
|
||||||
|
@ -32,14 +32,14 @@ impl DOMTokenList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(element: &Element, local_name: &LocalName) -> Root<DOMTokenList> {
|
pub fn new(element: &Element, local_name: &LocalName) -> DomRoot<DOMTokenList> {
|
||||||
let window = window_from_node(element);
|
let window = window_from_node(element);
|
||||||
reflect_dom_object(box DOMTokenList::new_inherited(element, local_name.clone()),
|
reflect_dom_object(box DOMTokenList::new_inherited(element, local_name.clone()),
|
||||||
&*window,
|
&*window,
|
||||||
DOMTokenListBinding::Wrap)
|
DOMTokenListBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn attribute(&self) -> Option<Root<Attr>> {
|
fn attribute(&self) -> Option<DomRoot<Attr>> {
|
||||||
self.element.get_attribute(&ns!(), &self.local_name)
|
self.element.get_attribute(&ns!(), &self.local_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
||||||
use dom::bindings::refcounted::{Trusted, TrustedPromise};
|
use dom::bindings::refcounted::{Trusted, TrustedPromise};
|
||||||
use dom::bindings::reflector::DomObject;
|
use dom::bindings::reflector::DomObject;
|
||||||
use dom::bindings::root::{Dom, LayoutDom, MutNullableDom, Root, RootedReference};
|
use dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bindings::xmlname::{namespace_from_domstring, validate_and_extract, xml_name_type};
|
use dom::bindings::xmlname::{namespace_from_domstring, validate_and_extract, xml_name_type};
|
||||||
use dom::bindings::xmlname::XMLName::InvalidXMLName;
|
use dom::bindings::xmlname::XMLName::InvalidXMLName;
|
||||||
|
@ -164,7 +164,7 @@ impl fmt::Debug for Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Root<Element> {
|
impl fmt::Debug for DomRoot<Element> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
(**self).fmt(f)
|
(**self).fmt(f)
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ impl Element {
|
||||||
document: &Document,
|
document: &Document,
|
||||||
creator: ElementCreator,
|
creator: ElementCreator,
|
||||||
mode: CustomElementCreationMode)
|
mode: CustomElementCreationMode)
|
||||||
-> Root<Element> {
|
-> DomRoot<Element> {
|
||||||
create_element(name, is, document, creator, mode)
|
create_element(name, is, document, creator, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ impl Element {
|
||||||
pub fn new(local_name: LocalName,
|
pub fn new(local_name: LocalName,
|
||||||
namespace: Namespace,
|
namespace: Namespace,
|
||||||
prefix: Option<Prefix>,
|
prefix: Option<Prefix>,
|
||||||
document: &Document) -> Root<Element> {
|
document: &Document) -> DomRoot<Element> {
|
||||||
Node::reflect_node(
|
Node::reflect_node(
|
||||||
box Element::new_inherited(local_name, namespace, prefix, document),
|
box Element::new_inherited(local_name, namespace, prefix, document),
|
||||||
document,
|
document,
|
||||||
|
@ -923,7 +923,7 @@ impl Element {
|
||||||
let inclusive_ancestor_elements =
|
let inclusive_ancestor_elements =
|
||||||
self.upcast::<Node>()
|
self.upcast::<Node>()
|
||||||
.inclusive_ancestors()
|
.inclusive_ancestors()
|
||||||
.filter_map(Root::downcast::<Self>);
|
.filter_map(DomRoot::downcast::<Self>);
|
||||||
|
|
||||||
// Steps 3-4.
|
// Steps 3-4.
|
||||||
for element in inclusive_ancestor_elements {
|
for element in inclusive_ancestor_elements {
|
||||||
|
@ -1002,7 +1002,7 @@ impl Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn root_element(&self) -> Root<Element> {
|
pub fn root_element(&self) -> DomRoot<Element> {
|
||||||
if self.node.is_in_doc() {
|
if self.node.is_in_doc() {
|
||||||
self.upcast::<Node>()
|
self.upcast::<Node>()
|
||||||
.owner_doc()
|
.owner_doc()
|
||||||
|
@ -1011,7 +1011,7 @@ impl Element {
|
||||||
} else {
|
} else {
|
||||||
self.upcast::<Node>()
|
self.upcast::<Node>()
|
||||||
.inclusive_ancestors()
|
.inclusive_ancestors()
|
||||||
.filter_map(Root::downcast)
|
.filter_map(DomRoot::downcast)
|
||||||
.last()
|
.last()
|
||||||
.expect("We know inclusive_ancestors will return `self` which is an element")
|
.expect("We know inclusive_ancestors will return `self` which is an element")
|
||||||
}
|
}
|
||||||
|
@ -1124,18 +1124,18 @@ impl Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_attribute(&self, namespace: &Namespace, local_name: &LocalName) -> Option<Root<Attr>> {
|
pub fn get_attribute(&self, namespace: &Namespace, local_name: &LocalName) -> Option<DomRoot<Attr>> {
|
||||||
self.attrs
|
self.attrs
|
||||||
.borrow()
|
.borrow()
|
||||||
.iter()
|
.iter()
|
||||||
.find(|attr| attr.local_name() == local_name && attr.namespace() == namespace)
|
.find(|attr| attr.local_name() == local_name && attr.namespace() == namespace)
|
||||||
.map(|js| Root::from_ref(&**js))
|
.map(|js| DomRoot::from_ref(&**js))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
|
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
|
||||||
pub fn get_attribute_by_name(&self, name: DOMString) -> Option<Root<Attr>> {
|
pub fn get_attribute_by_name(&self, name: DOMString) -> Option<DomRoot<Attr>> {
|
||||||
let name = &self.parsed_name(name);
|
let name = &self.parsed_name(name);
|
||||||
self.attrs.borrow().iter().find(|a| a.name() == name).map(|js| Root::from_ref(&**js))
|
self.attrs.borrow().iter().find(|a| a.name() == name).map(|js| DomRoot::from_ref(&**js))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_attribute_from_parser(&self,
|
pub fn set_attribute_from_parser(&self,
|
||||||
|
@ -1207,7 +1207,7 @@ impl Element {
|
||||||
.borrow()
|
.borrow()
|
||||||
.iter()
|
.iter()
|
||||||
.find(|attr| find(&attr))
|
.find(|attr| find(&attr))
|
||||||
.map(|js| Root::from_ref(&**js));
|
.map(|js| DomRoot::from_ref(&**js));
|
||||||
if let Some(attr) = attr {
|
if let Some(attr) = attr {
|
||||||
attr.set_value(value, self);
|
attr.set_value(value, self);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1227,21 +1227,21 @@ impl Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_attribute(&self, namespace: &Namespace, local_name: &LocalName) -> Option<Root<Attr>> {
|
pub fn remove_attribute(&self, namespace: &Namespace, local_name: &LocalName) -> Option<DomRoot<Attr>> {
|
||||||
self.remove_first_matching_attribute(|attr| {
|
self.remove_first_matching_attribute(|attr| {
|
||||||
attr.namespace() == namespace && attr.local_name() == local_name
|
attr.namespace() == namespace && attr.local_name() == local_name
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_attribute_by_name(&self, name: &LocalName) -> Option<Root<Attr>> {
|
pub fn remove_attribute_by_name(&self, name: &LocalName) -> Option<DomRoot<Attr>> {
|
||||||
self.remove_first_matching_attribute(|attr| attr.name() == name)
|
self.remove_first_matching_attribute(|attr| attr.name() == name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_first_matching_attribute<F>(&self, find: F) -> Option<Root<Attr>>
|
fn remove_first_matching_attribute<F>(&self, find: F) -> Option<DomRoot<Attr>>
|
||||||
where F: Fn(&Attr) -> bool {
|
where F: Fn(&Attr) -> bool {
|
||||||
let idx = self.attrs.borrow().iter().position(|attr| find(&attr));
|
let idx = self.attrs.borrow().iter().position(|attr| find(&attr));
|
||||||
idx.map(|idx| {
|
idx.map(|idx| {
|
||||||
let attr = Root::from_ref(&*(*self.attrs.borrow())[idx]);
|
let attr = DomRoot::from_ref(&*(*self.attrs.borrow())[idx]);
|
||||||
self.will_mutate_attr(&attr);
|
self.will_mutate_attr(&attr);
|
||||||
|
|
||||||
let name = attr.local_name().clone();
|
let name = attr.local_name().clone();
|
||||||
|
@ -1396,7 +1396,7 @@ impl Element {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#insert-adjacent
|
// https://dom.spec.whatwg.org/#insert-adjacent
|
||||||
pub fn insert_adjacent(&self, where_: AdjacentPosition, node: &Node)
|
pub fn insert_adjacent(&self, where_: AdjacentPosition, node: &Node)
|
||||||
-> Fallible<Option<Root<Node>>> {
|
-> Fallible<Option<DomRoot<Node>>> {
|
||||||
let self_node = self.upcast::<Node>();
|
let self_node = self.upcast::<Node>();
|
||||||
match where_ {
|
match where_ {
|
||||||
AdjacentPosition::BeforeBegin => {
|
AdjacentPosition::BeforeBegin => {
|
||||||
|
@ -1468,7 +1468,7 @@ impl Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/DOM-Parsing/#parsing
|
// https://w3c.github.io/DOM-Parsing/#parsing
|
||||||
pub fn parse_fragment(&self, markup: DOMString) -> Fallible<Root<DocumentFragment>> {
|
pub fn parse_fragment(&self, markup: DOMString) -> Fallible<DomRoot<DocumentFragment>> {
|
||||||
// Steps 1-2.
|
// Steps 1-2.
|
||||||
let context_document = document_from_node(self);
|
let context_document = document_from_node(self);
|
||||||
// TODO(#11995): XML case.
|
// TODO(#11995): XML case.
|
||||||
|
@ -1483,13 +1483,13 @@ impl Element {
|
||||||
Ok(fragment)
|
Ok(fragment)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fragment_parsing_context(owner_doc: &Document, element: Option<&Self>) -> Root<Self> {
|
pub fn fragment_parsing_context(owner_doc: &Document, element: Option<&Self>) -> DomRoot<Self> {
|
||||||
match element {
|
match element {
|
||||||
Some(elem) if elem.local_name() != &local_name!("html") || !elem.html_element_in_html_document() => {
|
Some(elem) if elem.local_name() != &local_name!("html") || !elem.html_element_in_html_document() => {
|
||||||
Root::from_ref(elem)
|
DomRoot::from_ref(elem)
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
Root::upcast(HTMLBodyElement::new(local_name!("body"), None, owner_doc))
|
DomRoot::upcast(HTMLBodyElement::new(local_name!("body"), None, owner_doc))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1568,12 +1568,12 @@ impl ElementMethods for Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-classlist
|
// https://dom.spec.whatwg.org/#dom-element-classlist
|
||||||
fn ClassList(&self) -> Root<DOMTokenList> {
|
fn ClassList(&self) -> DomRoot<DOMTokenList> {
|
||||||
self.class_list.or_init(|| DOMTokenList::new(self, &local_name!("class")))
|
self.class_list.or_init(|| DOMTokenList::new(self, &local_name!("class")))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-attributes
|
// https://dom.spec.whatwg.org/#dom-element-attributes
|
||||||
fn Attributes(&self) -> Root<NamedNodeMap> {
|
fn Attributes(&self) -> DomRoot<NamedNodeMap> {
|
||||||
self.attr_list.or_init(|| NamedNodeMap::new(&window_from_node(self), self))
|
self.attr_list.or_init(|| NamedNodeMap::new(&window_from_node(self), self))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1603,7 +1603,7 @@ impl ElementMethods for Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-getattributenode
|
// https://dom.spec.whatwg.org/#dom-element-getattributenode
|
||||||
fn GetAttributeNode(&self, name: DOMString) -> Option<Root<Attr>> {
|
fn GetAttributeNode(&self, name: DOMString) -> Option<DomRoot<Attr>> {
|
||||||
self.get_attribute_by_name(name)
|
self.get_attribute_by_name(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1611,7 +1611,7 @@ impl ElementMethods for Element {
|
||||||
fn GetAttributeNodeNS(&self,
|
fn GetAttributeNodeNS(&self,
|
||||||
namespace: Option<DOMString>,
|
namespace: Option<DOMString>,
|
||||||
local_name: DOMString)
|
local_name: DOMString)
|
||||||
-> Option<Root<Attr>> {
|
-> Option<DomRoot<Attr>> {
|
||||||
let namespace = &namespace_from_domstring(namespace);
|
let namespace = &namespace_from_domstring(namespace);
|
||||||
self.get_attribute(namespace, &LocalName::from(local_name))
|
self.get_attribute(namespace, &LocalName::from(local_name))
|
||||||
}
|
}
|
||||||
|
@ -1650,7 +1650,7 @@ impl ElementMethods for Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-setattributenode
|
// https://dom.spec.whatwg.org/#dom-element-setattributenode
|
||||||
fn SetAttributeNode(&self, attr: &Attr) -> Fallible<Option<Root<Attr>>> {
|
fn SetAttributeNode(&self, attr: &Attr) -> Fallible<Option<DomRoot<Attr>>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if let Some(owner) = attr.GetOwnerElement() {
|
if let Some(owner) = attr.GetOwnerElement() {
|
||||||
if &*owner != self {
|
if &*owner != self {
|
||||||
|
@ -1673,11 +1673,11 @@ impl ElementMethods for Element {
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(position) = position {
|
if let Some(position) = position {
|
||||||
let old_attr = Root::from_ref(&*self.attrs.borrow()[position]);
|
let old_attr = DomRoot::from_ref(&*self.attrs.borrow()[position]);
|
||||||
|
|
||||||
// Step 3.
|
// Step 3.
|
||||||
if &*old_attr == attr {
|
if &*old_attr == attr {
|
||||||
return Ok(Some(Root::from_ref(attr)));
|
return Ok(Some(DomRoot::from_ref(attr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 4.
|
// Step 4.
|
||||||
|
@ -1712,7 +1712,7 @@ impl ElementMethods for Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-setattributenodens
|
// https://dom.spec.whatwg.org/#dom-element-setattributenodens
|
||||||
fn SetAttributeNodeNS(&self, attr: &Attr) -> Fallible<Option<Root<Attr>>> {
|
fn SetAttributeNodeNS(&self, attr: &Attr) -> Fallible<Option<DomRoot<Attr>>> {
|
||||||
self.SetAttributeNode(attr)
|
self.SetAttributeNode(attr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1730,7 +1730,7 @@ impl ElementMethods for Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-removeattributenode
|
// https://dom.spec.whatwg.org/#dom-element-removeattributenode
|
||||||
fn RemoveAttributeNode(&self, attr: &Attr) -> Fallible<Root<Attr>> {
|
fn RemoveAttributeNode(&self, attr: &Attr) -> Fallible<DomRoot<Attr>> {
|
||||||
self.remove_first_matching_attribute(|a| a == attr)
|
self.remove_first_matching_attribute(|a| a == attr)
|
||||||
.ok_or(Error::NotFound)
|
.ok_or(Error::NotFound)
|
||||||
}
|
}
|
||||||
|
@ -1746,7 +1746,7 @@ impl ElementMethods for Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-getelementsbytagname
|
// https://dom.spec.whatwg.org/#dom-element-getelementsbytagname
|
||||||
fn GetElementsByTagName(&self, localname: DOMString) -> Root<HTMLCollection> {
|
fn GetElementsByTagName(&self, localname: DOMString) -> DomRoot<HTMLCollection> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
HTMLCollection::by_qualified_name(&window, self.upcast(), LocalName::from(&*localname))
|
HTMLCollection::by_qualified_name(&window, self.upcast(), LocalName::from(&*localname))
|
||||||
}
|
}
|
||||||
|
@ -1755,19 +1755,19 @@ impl ElementMethods for Element {
|
||||||
fn GetElementsByTagNameNS(&self,
|
fn GetElementsByTagNameNS(&self,
|
||||||
maybe_ns: Option<DOMString>,
|
maybe_ns: Option<DOMString>,
|
||||||
localname: DOMString)
|
localname: DOMString)
|
||||||
-> Root<HTMLCollection> {
|
-> DomRoot<HTMLCollection> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
HTMLCollection::by_tag_name_ns(&window, self.upcast(), localname, maybe_ns)
|
HTMLCollection::by_tag_name_ns(&window, self.upcast(), localname, maybe_ns)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-getelementsbyclassname
|
// https://dom.spec.whatwg.org/#dom-element-getelementsbyclassname
|
||||||
fn GetElementsByClassName(&self, classes: DOMString) -> Root<HTMLCollection> {
|
fn GetElementsByClassName(&self, classes: DOMString) -> DomRoot<HTMLCollection> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
HTMLCollection::by_class_name(&window, self.upcast(), classes)
|
HTMLCollection::by_class_name(&window, self.upcast(), classes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects
|
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects
|
||||||
fn GetClientRects(&self) -> Vec<Root<DOMRect>> {
|
fn GetClientRects(&self) -> Vec<DomRoot<DOMRect>> {
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
let raw_rects = self.upcast::<Node>().content_boxes();
|
let raw_rects = self.upcast::<Node>().content_boxes();
|
||||||
raw_rects.iter().map(|rect| {
|
raw_rects.iter().map(|rect| {
|
||||||
|
@ -1780,7 +1780,7 @@ impl ElementMethods for Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect
|
// https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect
|
||||||
fn GetBoundingClientRect(&self) -> Root<DOMRect> {
|
fn GetBoundingClientRect(&self) -> DomRoot<DOMRect> {
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
let rect = self.upcast::<Node>().bounding_content_box_or_zero();
|
let rect = self.upcast::<Node>().bounding_content_box_or_zero();
|
||||||
DOMRect::new(win.upcast(),
|
DOMRect::new(win.upcast(),
|
||||||
|
@ -2059,9 +2059,9 @@ impl ElementMethods for Element {
|
||||||
// Step 2.
|
// Step 2.
|
||||||
// https://github.com/w3c/DOM-Parsing/issues/1
|
// https://github.com/w3c/DOM-Parsing/issues/1
|
||||||
let target = if let Some(template) = self.downcast::<HTMLTemplateElement>() {
|
let target = if let Some(template) = self.downcast::<HTMLTemplateElement>() {
|
||||||
Root::upcast(template.Content())
|
DomRoot::upcast(template.Content())
|
||||||
} else {
|
} else {
|
||||||
Root::from_ref(self.upcast())
|
DomRoot::from_ref(self.upcast())
|
||||||
};
|
};
|
||||||
Node::replace_all(Some(frag.upcast()), &target);
|
Node::replace_all(Some(frag.upcast()), &target);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -2096,7 +2096,7 @@ impl ElementMethods for Element {
|
||||||
&context_document,
|
&context_document,
|
||||||
ElementCreator::ScriptCreated,
|
ElementCreator::ScriptCreated,
|
||||||
CustomElementCreationMode::Synchronous);
|
CustomElementCreationMode::Synchronous);
|
||||||
Root::upcast(body_elem)
|
DomRoot::upcast(body_elem)
|
||||||
},
|
},
|
||||||
_ => context_node.GetParentElement().unwrap()
|
_ => context_node.GetParentElement().unwrap()
|
||||||
};
|
};
|
||||||
|
@ -2109,29 +2109,29 @@ impl ElementMethods for Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-previouselementsibling
|
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-previouselementsibling
|
||||||
fn GetPreviousElementSibling(&self) -> Option<Root<Element>> {
|
fn GetPreviousElementSibling(&self) -> Option<DomRoot<Element>> {
|
||||||
self.upcast::<Node>().preceding_siblings().filter_map(Root::downcast).next()
|
self.upcast::<Node>().preceding_siblings().filter_map(DomRoot::downcast).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-nextelementsibling
|
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-nextelementsibling
|
||||||
fn GetNextElementSibling(&self) -> Option<Root<Element>> {
|
fn GetNextElementSibling(&self) -> Option<DomRoot<Element>> {
|
||||||
self.upcast::<Node>().following_siblings().filter_map(Root::downcast).next()
|
self.upcast::<Node>().following_siblings().filter_map(DomRoot::downcast).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
||||||
fn Children(&self) -> Root<HTMLCollection> {
|
fn Children(&self) -> DomRoot<HTMLCollection> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
HTMLCollection::children(&window, self.upcast())
|
HTMLCollection::children(&window, self.upcast())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
|
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
|
||||||
fn GetFirstElementChild(&self) -> Option<Root<Element>> {
|
fn GetFirstElementChild(&self) -> Option<DomRoot<Element>> {
|
||||||
self.upcast::<Node>().child_elements().next()
|
self.upcast::<Node>().child_elements().next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
||||||
fn GetLastElementChild(&self) -> Option<Root<Element>> {
|
fn GetLastElementChild(&self) -> Option<DomRoot<Element>> {
|
||||||
self.upcast::<Node>().rev_children().filter_map(Root::downcast::<Element>).next()
|
self.upcast::<Node>().rev_children().filter_map(DomRoot::downcast::<Element>).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
||||||
|
@ -2150,13 +2150,13 @@ impl ElementMethods for Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
||||||
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<Root<Element>>> {
|
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<DomRoot<Element>>> {
|
||||||
let root = self.upcast::<Node>();
|
let root = self.upcast::<Node>();
|
||||||
root.query_selector(selectors)
|
root.query_selector(selectors)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
// https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
||||||
fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<Root<NodeList>> {
|
fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<DomRoot<NodeList>> {
|
||||||
let root = self.upcast::<Node>();
|
let root = self.upcast::<Node>();
|
||||||
root.query_selector_all(selectors)
|
root.query_selector_all(selectors)
|
||||||
}
|
}
|
||||||
|
@ -2190,7 +2190,7 @@ impl ElementMethods for Element {
|
||||||
// FIXME(bholley): Consider an nth-index cache here.
|
// FIXME(bholley): Consider an nth-index cache here.
|
||||||
let mut ctx = MatchingContext::new(MatchingMode::Normal, None, None,
|
let mut ctx = MatchingContext::new(MatchingMode::Normal, None, None,
|
||||||
quirks_mode);
|
quirks_mode);
|
||||||
Ok(matches_selector_list(&selectors, &Root::from_ref(self), &mut ctx))
|
Ok(matches_selector_list(&selectors, &DomRoot::from_ref(self), &mut ctx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2201,13 +2201,13 @@ impl ElementMethods for Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-closest
|
// https://dom.spec.whatwg.org/#dom-element-closest
|
||||||
fn Closest(&self, selectors: DOMString) -> Fallible<Option<Root<Element>>> {
|
fn Closest(&self, selectors: DOMString) -> Fallible<Option<DomRoot<Element>>> {
|
||||||
match SelectorParser::parse_author_origin_no_namespace(&selectors) {
|
match SelectorParser::parse_author_origin_no_namespace(&selectors) {
|
||||||
Err(_) => Err(Error::Syntax),
|
Err(_) => Err(Error::Syntax),
|
||||||
Ok(selectors) => {
|
Ok(selectors) => {
|
||||||
let root = self.upcast::<Node>();
|
let root = self.upcast::<Node>();
|
||||||
for element in root.inclusive_ancestors() {
|
for element in root.inclusive_ancestors() {
|
||||||
if let Some(element) = Root::downcast::<Element>(element) {
|
if let Some(element) = DomRoot::downcast::<Element>(element) {
|
||||||
let quirks_mode = document_from_node(self).quirks_mode();
|
let quirks_mode = document_from_node(self).quirks_mode();
|
||||||
// FIXME(bholley): Consider an nth-index cache here.
|
// FIXME(bholley): Consider an nth-index cache here.
|
||||||
let mut ctx = MatchingContext::new(MatchingMode::Normal, None, None,
|
let mut ctx = MatchingContext::new(MatchingMode::Normal, None, None,
|
||||||
|
@ -2224,10 +2224,10 @@ impl ElementMethods for Element {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-insertadjacentelement
|
// https://dom.spec.whatwg.org/#dom-element-insertadjacentelement
|
||||||
fn InsertAdjacentElement(&self, where_: DOMString, element: &Element)
|
fn InsertAdjacentElement(&self, where_: DOMString, element: &Element)
|
||||||
-> Fallible<Option<Root<Element>>> {
|
-> Fallible<Option<DomRoot<Element>>> {
|
||||||
let where_ = AdjacentPosition::try_from(&*where_)?;
|
let where_ = AdjacentPosition::try_from(&*where_)?;
|
||||||
let inserted_node = self.insert_adjacent(where_, element.upcast())?;
|
let inserted_node = self.insert_adjacent(where_, element.upcast())?;
|
||||||
Ok(inserted_node.map(|node| Root::downcast(node).unwrap()))
|
Ok(inserted_node.map(|node| DomRoot::downcast(node).unwrap()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-insertadjacenttext
|
// https://dom.spec.whatwg.org/#dom-element-insertadjacenttext
|
||||||
|
@ -2258,7 +2258,7 @@ impl ElementMethods for Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AdjacentPosition::AfterBegin | AdjacentPosition::BeforeEnd => {
|
AdjacentPosition::AfterBegin | AdjacentPosition::BeforeEnd => {
|
||||||
Root::from_ref(self.upcast::<Node>())
|
DomRoot::from_ref(self.upcast::<Node>())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2496,14 +2496,14 @@ impl VirtualMethods for Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::selectors::Element for Root<Element> {
|
impl<'a> ::selectors::Element for DomRoot<Element> {
|
||||||
type Impl = SelectorImpl;
|
type Impl = SelectorImpl;
|
||||||
|
|
||||||
fn opaque(&self) -> ::selectors::OpaqueElement {
|
fn opaque(&self) -> ::selectors::OpaqueElement {
|
||||||
::selectors::OpaqueElement::new(self.reflector().get_jsobject().get())
|
::selectors::OpaqueElement::new(self.reflector().get_jsobject().get())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_element(&self) -> Option<Root<Element>> {
|
fn parent_element(&self) -> Option<DomRoot<Element>> {
|
||||||
self.upcast::<Node>().GetParentElement()
|
self.upcast::<Node>().GetParentElement()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2516,20 +2516,20 @@ impl<'a> ::selectors::Element for Root<Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn first_child_element(&self) -> Option<Root<Element>> {
|
fn first_child_element(&self) -> Option<DomRoot<Element>> {
|
||||||
self.node.child_elements().next()
|
self.node.child_elements().next()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn last_child_element(&self) -> Option<Root<Element>> {
|
fn last_child_element(&self) -> Option<DomRoot<Element>> {
|
||||||
self.node.rev_children().filter_map(Root::downcast).next()
|
self.node.rev_children().filter_map(DomRoot::downcast).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prev_sibling_element(&self) -> Option<Root<Element>> {
|
fn prev_sibling_element(&self) -> Option<DomRoot<Element>> {
|
||||||
self.node.preceding_siblings().filter_map(Root::downcast).next()
|
self.node.preceding_siblings().filter_map(DomRoot::downcast).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_sibling_element(&self) -> Option<Root<Element>> {
|
fn next_sibling_element(&self) -> Option<DomRoot<Element>> {
|
||||||
self.node.following_siblings().filter_map(Root::downcast).next()
|
self.node.following_siblings().filter_map(DomRoot::downcast).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn attr_matches(&self,
|
fn attr_matches(&self,
|
||||||
|
@ -2739,15 +2739,15 @@ impl Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#nearest-activatable-element
|
// https://html.spec.whatwg.org/multipage/#nearest-activatable-element
|
||||||
pub fn nearest_activable_element(&self) -> Option<Root<Element>> {
|
pub fn nearest_activable_element(&self) -> Option<DomRoot<Element>> {
|
||||||
match self.as_maybe_activatable() {
|
match self.as_maybe_activatable() {
|
||||||
Some(el) => Some(Root::from_ref(el.as_element())),
|
Some(el) => Some(DomRoot::from_ref(el.as_element())),
|
||||||
None => {
|
None => {
|
||||||
let node = self.upcast::<Node>();
|
let node = self.upcast::<Node>();
|
||||||
for node in node.ancestors() {
|
for node in node.ancestors() {
|
||||||
if let Some(node) = node.downcast::<Element>() {
|
if let Some(node) = node.downcast::<Element>() {
|
||||||
if node.as_maybe_activatable().is_some() {
|
if node.as_maybe_activatable().is_some() {
|
||||||
return Some(Root::from_ref(node));
|
return Some(DomRoot::from_ref(node));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bindings::trace::RootedTraceableBox;
|
use dom::bindings::trace::RootedTraceableBox;
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
|
@ -43,7 +43,7 @@ impl ErrorEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<ErrorEvent> {
|
pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<ErrorEvent> {
|
||||||
reflect_dom_object(box ErrorEvent::new_inherited(),
|
reflect_dom_object(box ErrorEvent::new_inherited(),
|
||||||
global,
|
global,
|
||||||
ErrorEventBinding::Wrap)
|
ErrorEventBinding::Wrap)
|
||||||
|
@ -57,7 +57,7 @@ impl ErrorEvent {
|
||||||
filename: DOMString,
|
filename: DOMString,
|
||||||
lineno: u32,
|
lineno: u32,
|
||||||
colno: u32,
|
colno: u32,
|
||||||
error: HandleValue) -> Root<ErrorEvent> {
|
error: HandleValue) -> DomRoot<ErrorEvent> {
|
||||||
let ev = ErrorEvent::new_uninitialized(global);
|
let ev = ErrorEvent::new_uninitialized(global);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
|
@ -75,7 +75,7 @@ impl ErrorEvent {
|
||||||
pub fn Constructor(global: &GlobalScope,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: RootedTraceableBox<ErrorEventBinding::ErrorEventInit>)
|
init: RootedTraceableBox<ErrorEventBinding::ErrorEventInit>)
|
||||||
-> Fallible<Root<ErrorEvent>>{
|
-> Fallible<DomRoot<ErrorEvent>>{
|
||||||
let msg = match init.message.as_ref() {
|
let msg = match init.message.as_ref() {
|
||||||
Some(message) => message.clone(),
|
Some(message) => message.clone(),
|
||||||
None => DOMString::new(),
|
None => DOMString::new(),
|
||||||
|
|
|
@ -11,7 +11,7 @@ use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, MutNullableDom, Root, RootedReference};
|
use dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootedReference};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::eventtarget::{CompiledEventListener, EventTarget, ListenerPhase};
|
use dom::eventtarget::{CompiledEventListener, EventTarget, ListenerPhase};
|
||||||
|
@ -64,7 +64,7 @@ impl Event {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<Event> {
|
pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<Event> {
|
||||||
reflect_dom_object(box Event::new_inherited(),
|
reflect_dom_object(box Event::new_inherited(),
|
||||||
global,
|
global,
|
||||||
EventBinding::Wrap)
|
EventBinding::Wrap)
|
||||||
|
@ -73,7 +73,7 @@ impl Event {
|
||||||
pub fn new(global: &GlobalScope,
|
pub fn new(global: &GlobalScope,
|
||||||
type_: Atom,
|
type_: Atom,
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable) -> Root<Event> {
|
cancelable: EventCancelable) -> DomRoot<Event> {
|
||||||
let event = Event::new_uninitialized(global);
|
let event = Event::new_uninitialized(global);
|
||||||
event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
|
event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
|
||||||
event
|
event
|
||||||
|
@ -81,7 +81,7 @@ impl Event {
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalScope,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &EventBinding::EventInit) -> Fallible<Root<Event>> {
|
init: &EventBinding::EventInit) -> Fallible<DomRoot<Event>> {
|
||||||
let bubbles = EventBubbles::from(init.bubbles);
|
let bubbles = EventBubbles::from(init.bubbles);
|
||||||
let cancelable = EventCancelable::from(init.cancelable);
|
let cancelable = EventCancelable::from(init.cancelable);
|
||||||
Ok(Event::new(global, Atom::from(type_), bubbles, cancelable))
|
Ok(Event::new(global, Atom::from(type_), bubbles, cancelable))
|
||||||
|
@ -140,8 +140,8 @@ impl Event {
|
||||||
event_path.push(Dom::from_ref(ancestor.upcast::<EventTarget>()));
|
event_path.push(Dom::from_ref(ancestor.upcast::<EventTarget>()));
|
||||||
}
|
}
|
||||||
let top_most_ancestor_or_target =
|
let top_most_ancestor_or_target =
|
||||||
Root::from_ref(event_path.r().last().cloned().unwrap_or(target));
|
DomRoot::from_ref(event_path.r().last().cloned().unwrap_or(target));
|
||||||
if let Some(document) = Root::downcast::<Document>(top_most_ancestor_or_target) {
|
if let Some(document) = DomRoot::downcast::<Document>(top_most_ancestor_or_target) {
|
||||||
if self.type_() != atom!("load") && document.browsing_context().is_some() {
|
if self.type_() != atom!("load") && document.browsing_context().is_some() {
|
||||||
event_path.push(Dom::from_ref(document.window().upcast()));
|
event_path.push(Dom::from_ref(document.window().upcast()));
|
||||||
}
|
}
|
||||||
|
@ -233,12 +233,12 @@ impl EventMethods for Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-target
|
// https://dom.spec.whatwg.org/#dom-event-target
|
||||||
fn GetTarget(&self) -> Option<Root<EventTarget>> {
|
fn GetTarget(&self) -> Option<DomRoot<EventTarget>> {
|
||||||
self.target.get()
|
self.target.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-currenttarget
|
// https://dom.spec.whatwg.org/#dom-event-currenttarget
|
||||||
fn GetCurrentTarget(&self) -> Option<Root<EventTarget>> {
|
fn GetCurrentTarget(&self) -> Option<DomRoot<EventTarget>> {
|
||||||
self.current_target.get()
|
self.current_target.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, event_path: &[&Eve
|
||||||
assert!(!event.stop_propagation.get());
|
assert!(!event.stop_propagation.get());
|
||||||
assert!(!event.stop_immediate.get());
|
assert!(!event.stop_immediate.get());
|
||||||
|
|
||||||
let window = match Root::downcast::<Window>(target.global()) {
|
let window = match DomRoot::downcast::<Window>(target.global()) {
|
||||||
Some(window) => {
|
Some(window) => {
|
||||||
if window.need_emit_timeline_marker(TimelineMarkerType::DOMEvent) {
|
if window.need_emit_timeline_marker(TimelineMarkerType::DOMEvent) {
|
||||||
Some(window)
|
Some(window)
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
@ -412,7 +412,7 @@ impl EventSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(global: &GlobalScope, url: ServoUrl, with_credentials: bool) -> Root<EventSource> {
|
fn new(global: &GlobalScope, url: ServoUrl, with_credentials: bool) -> DomRoot<EventSource> {
|
||||||
reflect_dom_object(box EventSource::new_inherited(url, with_credentials),
|
reflect_dom_object(box EventSource::new_inherited(url, with_credentials),
|
||||||
global,
|
global,
|
||||||
Wrap)
|
Wrap)
|
||||||
|
@ -424,7 +424,7 @@ impl EventSource {
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalScope,
|
pub fn Constructor(global: &GlobalScope,
|
||||||
url: DOMString,
|
url: DOMString,
|
||||||
event_source_init: &EventSourceInit) -> Fallible<Root<EventSource>> {
|
event_source_init: &EventSourceInit) -> Fallible<DomRoot<EventSource>> {
|
||||||
// TODO: Step 2 relevant settings object
|
// TODO: Step 2 relevant settings object
|
||||||
// Step 3
|
// Step 3
|
||||||
let base_url = global.api_base_url();
|
let base_url = global.api_base_url();
|
||||||
|
|
|
@ -18,7 +18,7 @@ use dom::bindings::codegen::UnionTypes::EventOrString;
|
||||||
use dom::bindings::error::{Error, Fallible, report_pending_exception};
|
use dom::bindings::error::{Error, Fallible, report_pending_exception};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::{DomObject, Reflector};
|
use dom::bindings::reflector::{DomObject, Reflector};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
use dom::errorevent::ErrorEvent;
|
use dom::errorevent::ErrorEvent;
|
||||||
|
@ -174,7 +174,7 @@ impl CompiledEventListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = handler.Call_(object, EventOrString::Event(Root::from_ref(event)),
|
let _ = handler.Call_(object, EventOrString::Event(DomRoot::from_ref(event)),
|
||||||
None, None, None, None, exception_handle);
|
None, None, None, None, exception_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,28 +506,28 @@ impl EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#concept-event-fire
|
// https://dom.spec.whatwg.org/#concept-event-fire
|
||||||
pub fn fire_event(&self, name: Atom) -> Root<Event> {
|
pub fn fire_event(&self, name: Atom) -> DomRoot<Event> {
|
||||||
self.fire_event_with_params(name,
|
self.fire_event_with_params(name,
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
EventCancelable::NotCancelable)
|
EventCancelable::NotCancelable)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#concept-event-fire
|
// https://dom.spec.whatwg.org/#concept-event-fire
|
||||||
pub fn fire_bubbling_event(&self, name: Atom) -> Root<Event> {
|
pub fn fire_bubbling_event(&self, name: Atom) -> DomRoot<Event> {
|
||||||
self.fire_event_with_params(name,
|
self.fire_event_with_params(name,
|
||||||
EventBubbles::Bubbles,
|
EventBubbles::Bubbles,
|
||||||
EventCancelable::NotCancelable)
|
EventCancelable::NotCancelable)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#concept-event-fire
|
// https://dom.spec.whatwg.org/#concept-event-fire
|
||||||
pub fn fire_cancelable_event(&self, name: Atom) -> Root<Event> {
|
pub fn fire_cancelable_event(&self, name: Atom) -> DomRoot<Event> {
|
||||||
self.fire_event_with_params(name,
|
self.fire_event_with_params(name,
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
EventCancelable::Cancelable)
|
EventCancelable::Cancelable)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#concept-event-fire
|
// https://dom.spec.whatwg.org/#concept-event-fire
|
||||||
pub fn fire_bubbling_cancelable_event(&self, name: Atom) -> Root<Event> {
|
pub fn fire_bubbling_cancelable_event(&self, name: Atom) -> DomRoot<Event> {
|
||||||
self.fire_event_with_params(name,
|
self.fire_event_with_params(name,
|
||||||
EventBubbles::Bubbles,
|
EventBubbles::Bubbles,
|
||||||
EventCancelable::Cancelable)
|
EventCancelable::Cancelable)
|
||||||
|
@ -538,7 +538,7 @@ impl EventTarget {
|
||||||
name: Atom,
|
name: Atom,
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable)
|
cancelable: EventCancelable)
|
||||||
-> Root<Event> {
|
-> DomRoot<Event> {
|
||||||
let event = Event::new(&self.global(), name, bubbles, cancelable);
|
let event = Event::new(&self.global(), name, bubbles, cancelable);
|
||||||
event.fire(self);
|
event.fire(self);
|
||||||
event
|
event
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::ExtendableEventBinding;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
use dom::serviceworkerglobalscope::ServiceWorkerGlobalScope;
|
use dom::serviceworkerglobalscope::ServiceWorkerGlobalScope;
|
||||||
|
@ -33,7 +33,7 @@ impl ExtendableEvent {
|
||||||
type_: Atom,
|
type_: Atom,
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool)
|
cancelable: bool)
|
||||||
-> Root<ExtendableEvent> {
|
-> DomRoot<ExtendableEvent> {
|
||||||
let ev = reflect_dom_object(box ExtendableEvent::new_inherited(), worker, ExtendableEventBinding::Wrap);
|
let ev = reflect_dom_object(box ExtendableEvent::new_inherited(), worker, ExtendableEventBinding::Wrap);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
|
@ -44,7 +44,7 @@ impl ExtendableEvent {
|
||||||
|
|
||||||
pub fn Constructor(worker: &ServiceWorkerGlobalScope,
|
pub fn Constructor(worker: &ServiceWorkerGlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible<Root<ExtendableEvent>> {
|
init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible<DomRoot<ExtendableEvent>> {
|
||||||
Ok(ExtendableEvent::new(worker,
|
Ok(ExtendableEvent::new(worker,
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::ExtendableMessageEventBinding::ExtendableM
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bindings::trace::RootedTraceableBox;
|
use dom::bindings::trace::RootedTraceableBox;
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
|
@ -32,7 +32,7 @@ impl ExtendableMessageEvent {
|
||||||
pub fn new(global: &GlobalScope, type_: Atom,
|
pub fn new(global: &GlobalScope, type_: Atom,
|
||||||
bubbles: bool, cancelable: bool,
|
bubbles: bool, cancelable: bool,
|
||||||
data: HandleValue, origin: DOMString, lastEventId: DOMString)
|
data: HandleValue, origin: DOMString, lastEventId: DOMString)
|
||||||
-> Root<ExtendableMessageEvent> {
|
-> DomRoot<ExtendableMessageEvent> {
|
||||||
let ev = box ExtendableMessageEvent {
|
let ev = box ExtendableMessageEvent {
|
||||||
event: ExtendableEvent::new_inherited(),
|
event: ExtendableEvent::new_inherited(),
|
||||||
data: Heap::default(),
|
data: Heap::default(),
|
||||||
|
@ -52,7 +52,7 @@ impl ExtendableMessageEvent {
|
||||||
pub fn Constructor(worker: &ServiceWorkerGlobalScope,
|
pub fn Constructor(worker: &ServiceWorkerGlobalScope,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: RootedTraceableBox<ExtendableMessageEventBinding::ExtendableMessageEventInit>)
|
init: RootedTraceableBox<ExtendableMessageEventBinding::ExtendableMessageEventInit>)
|
||||||
-> Fallible<Root<ExtendableMessageEvent>> {
|
-> Fallible<DomRoot<ExtendableMessageEvent>> {
|
||||||
let global = worker.upcast::<GlobalScope>();
|
let global = worker.upcast::<GlobalScope>();
|
||||||
let ev = ExtendableMessageEvent::new(global,
|
let ev = ExtendableMessageEvent::new(global,
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::UnionTypes::BlobOrString;
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::blob::{Blob, BlobImpl, blob_parts_to_bytes};
|
use dom::blob::{Blob, BlobImpl, blob_parts_to_bytes};
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
|
@ -44,14 +44,14 @@ impl File {
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(global: &GlobalScope, blob_impl: BlobImpl,
|
pub fn new(global: &GlobalScope, blob_impl: BlobImpl,
|
||||||
name: DOMString, modified: Option<i64>, typeString: &str) -> Root<File> {
|
name: DOMString, modified: Option<i64>, typeString: &str) -> DomRoot<File> {
|
||||||
reflect_dom_object(box File::new_inherited(blob_impl, name, modified, typeString),
|
reflect_dom_object(box File::new_inherited(blob_impl, name, modified, typeString),
|
||||||
global,
|
global,
|
||||||
FileBinding::Wrap)
|
FileBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct from selected file message from file manager thread
|
// Construct from selected file message from file manager thread
|
||||||
pub fn new_from_selected(window: &Window, selected: SelectedFile) -> Root<File> {
|
pub fn new_from_selected(window: &Window, selected: SelectedFile) -> DomRoot<File> {
|
||||||
let name = DOMString::from(selected.filename.to_str().expect("File name encoding error"));
|
let name = DOMString::from(selected.filename.to_str().expect("File name encoding error"));
|
||||||
|
|
||||||
File::new(window.upcast(), BlobImpl::new_from_file(selected.id, selected.filename, selected.size),
|
File::new(window.upcast(), BlobImpl::new_from_file(selected.id, selected.filename, selected.size),
|
||||||
|
@ -63,7 +63,7 @@ impl File {
|
||||||
fileBits: Vec<BlobOrString>,
|
fileBits: Vec<BlobOrString>,
|
||||||
filename: DOMString,
|
filename: DOMString,
|
||||||
filePropertyBag: &FileBinding::FilePropertyBag)
|
filePropertyBag: &FileBinding::FilePropertyBag)
|
||||||
-> Fallible<Root<File>> {
|
-> Fallible<DomRoot<File>> {
|
||||||
let bytes: Vec<u8> = match blob_parts_to_bytes(fileBits) {
|
let bytes: Vec<u8> = match blob_parts_to_bytes(fileBits) {
|
||||||
Ok(bytes) => bytes,
|
Ok(bytes) => bytes,
|
||||||
Err(_) => return Err(Error::InvalidCharacter),
|
Err(_) => return Err(Error::InvalidCharacter),
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::FileListBinding;
|
use dom::bindings::codegen::Bindings::FileListBinding;
|
||||||
use dom::bindings::codegen::Bindings::FileListBinding::FileListMethods;
|
use dom::bindings::codegen::Bindings::FileListBinding::FileListMethods;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::file::File;
|
use dom::file::File;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -28,7 +28,7 @@ impl FileList {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, files: Vec<Root<File>>) -> Root<FileList> {
|
pub fn new(window: &Window, files: Vec<DomRoot<File>>) -> DomRoot<FileList> {
|
||||||
reflect_dom_object(box FileList::new_inherited(files.iter().map(|r| Dom::from_ref(&**r)).collect()),
|
reflect_dom_object(box FileList::new_inherited(files.iter().map(|r| Dom::from_ref(&**r)).collect()),
|
||||||
window,
|
window,
|
||||||
FileListBinding::Wrap)
|
FileListBinding::Wrap)
|
||||||
|
@ -46,16 +46,16 @@ impl FileListMethods for FileList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#dfn-item
|
// https://w3c.github.io/FileAPI/#dfn-item
|
||||||
fn Item(&self, index: u32) -> Option<Root<File>> {
|
fn Item(&self, index: u32) -> Option<DomRoot<File>> {
|
||||||
if (index as usize) < self.list.len() {
|
if (index as usize) < self.list.len() {
|
||||||
Some(Root::from_ref(&*(self.list[index as usize])))
|
Some(DomRoot::from_ref(&*(self.list[index as usize])))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check-tidy: no specs after this line
|
// check-tidy: no specs after this line
|
||||||
fn IndexedGetter(&self, index: u32) -> Option<Root<File>> {
|
fn IndexedGetter(&self, index: u32) -> Option<DomRoot<File>> {
|
||||||
self.Item(index)
|
self.Item(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
use dom::bindings::root::{MutNullableDom, Root};
|
use dom::bindings::root::{DomRoot, MutNullableDom};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::bindings::trace::RootedTraceableBox;
|
use dom::bindings::trace::RootedTraceableBox;
|
||||||
use dom::blob::Blob;
|
use dom::blob::Blob;
|
||||||
|
@ -103,12 +103,12 @@ impl FileReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope) -> Root<FileReader> {
|
pub fn new(global: &GlobalScope) -> DomRoot<FileReader> {
|
||||||
reflect_dom_object(box FileReader::new_inherited(),
|
reflect_dom_object(box FileReader::new_inherited(),
|
||||||
global, FileReaderBinding::Wrap)
|
global, FileReaderBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<FileReader>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<DomRoot<FileReader>> {
|
||||||
Ok(FileReader::new(global))
|
Ok(FileReader::new(global))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ impl FileReaderMethods for FileReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#dfn-error
|
// https://w3c.github.io/FileAPI/#dfn-error
|
||||||
fn GetError(&self) -> Option<Root<DOMException>> {
|
fn GetError(&self) -> Option<DomRoot<DOMException>> {
|
||||||
self.error.get()
|
self.error.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::FileReaderSyncBinding;
|
use dom::bindings::codegen::Bindings::FileReaderSyncBinding;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -22,12 +22,12 @@ impl FileReaderSync {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope) -> Root<FileReaderSync> {
|
pub fn new(global: &GlobalScope) -> DomRoot<FileReaderSync> {
|
||||||
reflect_dom_object(box FileReaderSync::new_inherited(),
|
reflect_dom_object(box FileReaderSync::new_inherited(),
|
||||||
global, FileReaderSyncBinding::Wrap)
|
global, FileReaderSyncBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<FileReaderSync>> {
|
pub fn Constructor(global: &GlobalScope) -> Fallible<DomRoot<FileReaderSync>> {
|
||||||
Ok(FileReaderSync::new(global))
|
Ok(FileReaderSync::new(global))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::{MutNullableDom, Root, RootedReference};
|
use dom::bindings::root::{DomRoot, MutNullableDom, RootedReference};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::{EventBubbles, EventCancelable};
|
use dom::event::{EventBubbles, EventCancelable};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
@ -31,7 +31,7 @@ impl FocusEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(window: &Window) -> Root<FocusEvent> {
|
pub fn new_uninitialized(window: &Window) -> DomRoot<FocusEvent> {
|
||||||
reflect_dom_object(box FocusEvent::new_inherited(),
|
reflect_dom_object(box FocusEvent::new_inherited(),
|
||||||
window,
|
window,
|
||||||
FocusEventBinding::Wrap)
|
FocusEventBinding::Wrap)
|
||||||
|
@ -43,7 +43,7 @@ impl FocusEvent {
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
view: Option<&Window>,
|
view: Option<&Window>,
|
||||||
detail: i32,
|
detail: i32,
|
||||||
related_target: Option<&EventTarget>) -> Root<FocusEvent> {
|
related_target: Option<&EventTarget>) -> DomRoot<FocusEvent> {
|
||||||
let ev = FocusEvent::new_uninitialized(window);
|
let ev = FocusEvent::new_uninitialized(window);
|
||||||
ev.upcast::<UIEvent>().InitUIEvent(type_,
|
ev.upcast::<UIEvent>().InitUIEvent(type_,
|
||||||
bool::from(can_bubble),
|
bool::from(can_bubble),
|
||||||
|
@ -55,7 +55,7 @@ impl FocusEvent {
|
||||||
|
|
||||||
pub fn Constructor(window: &Window,
|
pub fn Constructor(window: &Window,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &FocusEventBinding::FocusEventInit) -> Fallible<Root<FocusEvent>> {
|
init: &FocusEventBinding::FocusEventInit) -> Fallible<DomRoot<FocusEvent>> {
|
||||||
let bubbles = EventBubbles::from(init.parent.parent.bubbles);
|
let bubbles = EventBubbles::from(init.parent.parent.bubbles);
|
||||||
let cancelable = EventCancelable::from(init.parent.parent.cancelable);
|
let cancelable = EventCancelable::from(init.parent.parent.cancelable);
|
||||||
let event = FocusEvent::new(window,
|
let event = FocusEvent::new(window,
|
||||||
|
@ -71,7 +71,7 @@ impl FocusEvent {
|
||||||
|
|
||||||
impl FocusEventMethods for FocusEvent {
|
impl FocusEventMethods for FocusEvent {
|
||||||
// https://w3c.github.io/uievents/#widl-FocusEvent-relatedTarget
|
// https://w3c.github.io/uievents/#widl-FocusEvent-relatedTarget
|
||||||
fn GetRelatedTarget(&self) -> Option<Root<EventTarget>> {
|
fn GetRelatedTarget(&self) -> Option<DomRoot<EventTarget>> {
|
||||||
self.related_target.get()
|
self.related_target.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::uievent::UIEvent;
|
use dom::uievent::UIEvent;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
@ -30,7 +30,7 @@ impl ForceTouchEvent {
|
||||||
|
|
||||||
pub fn new(window: &Window,
|
pub fn new(window: &Window,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
force: f32) -> Root<ForceTouchEvent> {
|
force: f32) -> DomRoot<ForceTouchEvent> {
|
||||||
let event = box ForceTouchEvent::new_inherited(force);
|
let event = box ForceTouchEvent::new_inherited(force);
|
||||||
let ev = reflect_dom_object(event, window, ForceTouchEventBinding::Wrap);
|
let ev = reflect_dom_object(event, window, ForceTouchEventBinding::Wrap);
|
||||||
ev.upcast::<UIEvent>().InitUIEvent(type_, true, true, Some(window), 0);
|
ev.upcast::<UIEvent>().InitUIEvent(type_, true, true, Some(window), 0);
|
||||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::iterable::Iterable;
|
use dom::bindings::iterable::Iterable;
|
||||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::{DOMString, USVString};
|
use dom::bindings::str::{DOMString, USVString};
|
||||||
use dom::blob::{Blob, BlobImpl};
|
use dom::blob::{Blob, BlobImpl};
|
||||||
use dom::file::File;
|
use dom::file::File;
|
||||||
|
@ -47,12 +47,12 @@ impl FormData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(form: Option<&HTMLFormElement>, global: &GlobalScope) -> Root<FormData> {
|
pub fn new(form: Option<&HTMLFormElement>, global: &GlobalScope) -> DomRoot<FormData> {
|
||||||
reflect_dom_object(box FormData::new_inherited(form),
|
reflect_dom_object(box FormData::new_inherited(form),
|
||||||
global, FormDataWrap)
|
global, FormDataWrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalScope, form: Option<&HTMLFormElement>) -> Fallible<Root<FormData>> {
|
pub fn Constructor(global: &GlobalScope, form: Option<&HTMLFormElement>) -> Fallible<DomRoot<FormData>> {
|
||||||
// TODO: Construct form data set for form if it is supplied
|
// TODO: Construct form data set for form if it is supplied
|
||||||
Ok(FormData::new(form, global))
|
Ok(FormData::new(form, global))
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ impl FormDataMethods for FormData {
|
||||||
let datum = FormDatum {
|
let datum = FormDatum {
|
||||||
ty: DOMString::from("file"),
|
ty: DOMString::from("file"),
|
||||||
name: DOMString::from(name.0.clone()),
|
name: DOMString::from(name.0.clone()),
|
||||||
value: FormDatumValue::File(Root::from_ref(&*self.create_an_entry(blob, filename))),
|
value: FormDatumValue::File(DomRoot::from_ref(&*self.create_an_entry(blob, filename))),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut data = self.data.borrow_mut();
|
let mut data = self.data.borrow_mut();
|
||||||
|
@ -102,7 +102,7 @@ impl FormDataMethods for FormData {
|
||||||
.get(&LocalName::from(name.0))
|
.get(&LocalName::from(name.0))
|
||||||
.map(|entry| match entry[0].value {
|
.map(|entry| match entry[0].value {
|
||||||
FormDatumValue::String(ref s) => FileOrUSVString::USVString(USVString(s.to_string())),
|
FormDatumValue::String(ref s) => FileOrUSVString::USVString(USVString(s.to_string())),
|
||||||
FormDatumValue::File(ref b) => FileOrUSVString::File(Root::from_ref(&*b)),
|
FormDatumValue::File(ref b) => FileOrUSVString::File(DomRoot::from_ref(&*b)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ impl FormDataMethods for FormData {
|
||||||
.map_or(vec![], |data|
|
.map_or(vec![], |data|
|
||||||
data.iter().map(|item| match item.value {
|
data.iter().map(|item| match item.value {
|
||||||
FormDatumValue::String(ref s) => FileOrUSVString::USVString(USVString(s.to_string())),
|
FormDatumValue::String(ref s) => FileOrUSVString::USVString(USVString(s.to_string())),
|
||||||
FormDatumValue::File(ref b) => FileOrUSVString::File(Root::from_ref(&*b)),
|
FormDatumValue::File(ref b) => FileOrUSVString::File(DomRoot::from_ref(&*b)),
|
||||||
}).collect()
|
}).collect()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ impl FormDataMethods for FormData {
|
||||||
self.data.borrow_mut().insert(LocalName::from(name.0.clone()), vec![FormDatum {
|
self.data.borrow_mut().insert(LocalName::from(name.0.clone()), vec![FormDatum {
|
||||||
ty: DOMString::from("file"),
|
ty: DOMString::from("file"),
|
||||||
name: DOMString::from(name.0),
|
name: DOMString::from(name.0),
|
||||||
value: FormDatumValue::File(Root::from_ref(&*self.create_an_entry(blob, filename))),
|
value: FormDatumValue::File(DomRoot::from_ref(&*self.create_an_entry(blob, filename))),
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ impl FormDataMethods for FormData {
|
||||||
impl FormData {
|
impl FormData {
|
||||||
// https://xhr.spec.whatwg.org/#create-an-entry
|
// https://xhr.spec.whatwg.org/#create-an-entry
|
||||||
// Steps 3-4.
|
// Steps 3-4.
|
||||||
fn create_an_entry(&self, blob: &Blob, opt_filename: Option<USVString>) -> Root<File> {
|
fn create_an_entry(&self, blob: &Blob, opt_filename: Option<USVString>) -> DomRoot<File> {
|
||||||
let name = match opt_filename {
|
let name = match opt_filename {
|
||||||
Some(filename) => DOMString::from(filename.0),
|
Some(filename) => DOMString::from(filename.0),
|
||||||
None if blob.downcast::<File>().is_none() => DOMString::from("blob"),
|
None if blob.downcast::<File>().is_none() => DOMString::from("blob"),
|
||||||
|
@ -185,7 +185,7 @@ impl Iterable for FormData {
|
||||||
.value;
|
.value;
|
||||||
match *value {
|
match *value {
|
||||||
FormDatumValue::String(ref s) => FileOrUSVString::USVString(USVString(s.to_string())),
|
FormDatumValue::String(ref s) => FileOrUSVString::USVString(USVString(s.to_string())),
|
||||||
FormDatumValue::File(ref b) => FileOrUSVString::File(Root::from_ref(&*b)),
|
FormDatumValue::File(ref b) => FileOrUSVString::File(DomRoot::from_ref(&*b)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::GamepadBinding::GamepadMethods;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
@ -71,7 +71,7 @@ impl Gamepad {
|
||||||
pub fn new_from_vr(global: &GlobalScope,
|
pub fn new_from_vr(global: &GlobalScope,
|
||||||
index: i32,
|
index: i32,
|
||||||
data: &WebVRGamepadData,
|
data: &WebVRGamepadData,
|
||||||
state: &WebVRGamepadState) -> Root<Gamepad> {
|
state: &WebVRGamepadState) -> DomRoot<Gamepad> {
|
||||||
let buttons = GamepadButtonList::new_from_vr(&global, &state.buttons);
|
let buttons = GamepadButtonList::new_from_vr(&global, &state.buttons);
|
||||||
let pose = VRPose::new(&global, &state.pose);
|
let pose = VRPose::new(&global, &state.pose);
|
||||||
|
|
||||||
|
@ -132,8 +132,8 @@ impl GamepadMethods for Gamepad {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/gamepad/#dom-gamepad-buttons
|
// https://w3c.github.io/gamepad/#dom-gamepad-buttons
|
||||||
fn Buttons(&self) -> Root<GamepadButtonList> {
|
fn Buttons(&self) -> DomRoot<GamepadButtonList> {
|
||||||
Root::from_ref(&*self.buttons)
|
DomRoot::from_ref(&*self.buttons)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
|
// https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
|
||||||
|
@ -147,8 +147,8 @@ impl GamepadMethods for Gamepad {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/gamepad/extensions.html#dom-gamepad-pose
|
// https://w3c.github.io/gamepad/extensions.html#dom-gamepad-pose
|
||||||
fn GetPose(&self) -> Option<Root<VRPose>> {
|
fn GetPose(&self) -> Option<DomRoot<VRPose>> {
|
||||||
self.pose.as_ref().map(|p| Root::from_ref(&**p))
|
self.pose.as_ref().map(|p| DomRoot::from_ref(&**p))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/webvr/spec/1.1/#gamepad-getvrdisplays-attribute
|
// https://w3c.github.io/webvr/spec/1.1/#gamepad-getvrdisplays-attribute
|
||||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::GamepadButtonBinding;
|
||||||
use dom::bindings::codegen::Bindings::GamepadButtonBinding::GamepadButtonMethods;
|
use dom::bindings::codegen::Bindings::GamepadButtonBinding::GamepadButtonMethods;
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
@ -29,7 +29,7 @@ impl GamepadButton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, pressed: bool, touched: bool) -> Root<GamepadButton> {
|
pub fn new(global: &GlobalScope, pressed: bool, touched: bool) -> DomRoot<GamepadButton> {
|
||||||
reflect_dom_object(box GamepadButton::new_inherited(pressed, touched),
|
reflect_dom_object(box GamepadButton::new_inherited(pressed, touched),
|
||||||
global,
|
global,
|
||||||
GamepadButtonBinding::Wrap)
|
GamepadButtonBinding::Wrap)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::GamepadButtonListBinding;
|
use dom::bindings::codegen::Bindings::GamepadButtonListBinding;
|
||||||
use dom::bindings::codegen::Bindings::GamepadButtonListBinding::GamepadButtonListMethods;
|
use dom::bindings::codegen::Bindings::GamepadButtonListBinding::GamepadButtonListMethods;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root, RootedReference};
|
use dom::bindings::root::{Dom, DomRoot, RootedReference};
|
||||||
use dom::gamepadbutton::GamepadButton;
|
use dom::gamepadbutton::GamepadButton;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -27,7 +27,7 @@ impl GamepadButtonList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_from_vr(global: &GlobalScope, buttons: &[WebVRGamepadButton]) -> Root<GamepadButtonList> {
|
pub fn new_from_vr(global: &GlobalScope, buttons: &[WebVRGamepadButton]) -> DomRoot<GamepadButtonList> {
|
||||||
rooted_vec!(let list <- buttons.iter()
|
rooted_vec!(let list <- buttons.iter()
|
||||||
.map(|btn| GamepadButton::new(&global, btn.pressed, btn.touched)));
|
.map(|btn| GamepadButton::new(&global, btn.pressed, btn.touched)));
|
||||||
|
|
||||||
|
@ -52,12 +52,12 @@ impl GamepadButtonListMethods for GamepadButtonList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/gamepad/#dom-gamepad-buttons
|
// https://w3c.github.io/gamepad/#dom-gamepad-buttons
|
||||||
fn Item(&self, index: u32) -> Option<Root<GamepadButton>> {
|
fn Item(&self, index: u32) -> Option<DomRoot<GamepadButton>> {
|
||||||
self.list.get(index as usize).map(|button| Root::from_ref(&**button))
|
self.list.get(index as usize).map(|button| DomRoot::from_ref(&**button))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/gamepad/#dom-gamepad-buttons
|
// https://w3c.github.io/gamepad/#dom-gamepad-buttons
|
||||||
fn IndexedGetter(&self, index: u32) -> Option<Root<GamepadButton>> {
|
fn IndexedGetter(&self, index: u32) -> Option<DomRoot<GamepadButton>> {
|
||||||
self.Item(index)
|
self.Item(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::GamepadEventBinding::GamepadEventMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
use dom::gamepad::Gamepad;
|
use dom::gamepad::Gamepad;
|
||||||
|
@ -41,7 +41,7 @@ impl GamepadEvent {
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
gamepad: &Gamepad)
|
gamepad: &Gamepad)
|
||||||
-> Root<GamepadEvent> {
|
-> DomRoot<GamepadEvent> {
|
||||||
let ev = reflect_dom_object(box GamepadEvent::new_inherited(&gamepad),
|
let ev = reflect_dom_object(box GamepadEvent::new_inherited(&gamepad),
|
||||||
global,
|
global,
|
||||||
GamepadEventBinding::Wrap);
|
GamepadEventBinding::Wrap);
|
||||||
|
@ -53,7 +53,7 @@ impl GamepadEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_with_type(global: &GlobalScope, event_type: GamepadEventType, gamepad: &Gamepad)
|
pub fn new_with_type(global: &GlobalScope, event_type: GamepadEventType, gamepad: &Gamepad)
|
||||||
-> Root<GamepadEvent> {
|
-> DomRoot<GamepadEvent> {
|
||||||
let name = match event_type {
|
let name = match event_type {
|
||||||
GamepadEventType::Connected => "gamepadconnected",
|
GamepadEventType::Connected => "gamepadconnected",
|
||||||
GamepadEventType::Disconnected => "gamepaddisconnected"
|
GamepadEventType::Disconnected => "gamepaddisconnected"
|
||||||
|
@ -70,7 +70,7 @@ impl GamepadEvent {
|
||||||
pub fn Constructor(window: &Window,
|
pub fn Constructor(window: &Window,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &GamepadEventBinding::GamepadEventInit)
|
init: &GamepadEventBinding::GamepadEventInit)
|
||||||
-> Fallible<Root<GamepadEvent>> {
|
-> Fallible<DomRoot<GamepadEvent>> {
|
||||||
Ok(GamepadEvent::new(&window.global(),
|
Ok(GamepadEvent::new(&window.global(),
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
|
@ -81,8 +81,8 @@ impl GamepadEvent {
|
||||||
|
|
||||||
impl GamepadEventMethods for GamepadEvent {
|
impl GamepadEventMethods for GamepadEvent {
|
||||||
// https://w3c.github.io/gamepad/#gamepadevent-interface
|
// https://w3c.github.io/gamepad/#gamepadevent-interface
|
||||||
fn Gamepad(&self) -> Root<Gamepad> {
|
fn Gamepad(&self) -> DomRoot<Gamepad> {
|
||||||
Root::from_ref(&*self.gamepad)
|
DomRoot::from_ref(&*self.gamepad)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-istrusted
|
// https://dom.spec.whatwg.org/#dom-event-istrusted
|
||||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::cell::DomRefCell;
|
||||||
use dom::bindings::codegen::Bindings::GamepadListBinding;
|
use dom::bindings::codegen::Bindings::GamepadListBinding;
|
||||||
use dom::bindings::codegen::Bindings::GamepadListBinding::GamepadListMethods;
|
use dom::bindings::codegen::Bindings::GamepadListBinding::GamepadListMethods;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::gamepad::Gamepad;
|
use dom::gamepad::Gamepad;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -26,13 +26,13 @@ impl GamepadList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, list: &[&Gamepad]) -> Root<GamepadList> {
|
pub fn new(global: &GlobalScope, list: &[&Gamepad]) -> DomRoot<GamepadList> {
|
||||||
reflect_dom_object(box GamepadList::new_inherited(list),
|
reflect_dom_object(box GamepadList::new_inherited(list),
|
||||||
global,
|
global,
|
||||||
GamepadListBinding::Wrap)
|
GamepadListBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_if_not_exists(&self, gamepads: &[Root<Gamepad>]) {
|
pub fn add_if_not_exists(&self, gamepads: &[DomRoot<Gamepad>]) {
|
||||||
for gamepad in gamepads {
|
for gamepad in gamepads {
|
||||||
if !self.list.borrow().iter().any(|g| g.gamepad_id() == gamepad.gamepad_id()) {
|
if !self.list.borrow().iter().any(|g| g.gamepad_id() == gamepad.gamepad_id()) {
|
||||||
self.list.borrow_mut().push(Dom::from_ref(&*gamepad));
|
self.list.borrow_mut().push(Dom::from_ref(&*gamepad));
|
||||||
|
@ -50,12 +50,12 @@ impl GamepadListMethods for GamepadList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/gamepad/#dom-navigator-getgamepads
|
// https://w3c.github.io/gamepad/#dom-navigator-getgamepads
|
||||||
fn Item(&self, index: u32) -> Option<Root<Gamepad>> {
|
fn Item(&self, index: u32) -> Option<DomRoot<Gamepad>> {
|
||||||
self.list.borrow().get(index as usize).map(|gamepad| Root::from_ref(&**gamepad))
|
self.list.borrow().get(index as usize).map(|gamepad| DomRoot::from_ref(&**gamepad))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/gamepad/#dom-navigator-getgamepads
|
// https://w3c.github.io/gamepad/#dom-navigator-getgamepads
|
||||||
fn IndexedGetter(&self, index: u32) -> Option<Root<Gamepad>> {
|
fn IndexedGetter(&self, index: u32) -> Option<DomRoot<Gamepad>> {
|
||||||
self.Item(index)
|
self.Item(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::conversions::root_from_object;
|
||||||
use dom::bindings::error::{ErrorInfo, report_pending_exception};
|
use dom::bindings::error::{ErrorInfo, report_pending_exception};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::DomObject;
|
use dom::bindings::reflector::DomObject;
|
||||||
use dom::bindings::root::{MutNullableDom, Root};
|
use dom::bindings::root::{DomRoot, MutNullableDom};
|
||||||
use dom::bindings::settings_stack::{AutoEntryScript, entry_global, incumbent_global};
|
use dom::bindings::settings_stack::{AutoEntryScript, entry_global, incumbent_global};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::crypto::Crypto;
|
use dom::crypto::Crypto;
|
||||||
|
@ -148,13 +148,13 @@ impl GlobalScope {
|
||||||
/// Returns the global scope of the realm that the given DOM object's reflector
|
/// Returns the global scope of the realm that the given DOM object's reflector
|
||||||
/// was created in.
|
/// was created in.
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn from_reflector<T: DomObject>(reflector: &T) -> Root<Self> {
|
pub fn from_reflector<T: DomObject>(reflector: &T) -> DomRoot<Self> {
|
||||||
unsafe { GlobalScope::from_object(*reflector.reflector().get_jsobject()) }
|
unsafe { GlobalScope::from_object(*reflector.reflector().get_jsobject()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the global scope of the realm that the given JS object was created in.
|
/// Returns the global scope of the realm that the given JS object was created in.
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub unsafe fn from_object(obj: *mut JSObject) -> Root<Self> {
|
pub unsafe fn from_object(obj: *mut JSObject) -> DomRoot<Self> {
|
||||||
assert!(!obj.is_null());
|
assert!(!obj.is_null());
|
||||||
let global = GetGlobalForObjectCrossCompartment(obj);
|
let global = GetGlobalForObjectCrossCompartment(obj);
|
||||||
global_scope_from_global(global)
|
global_scope_from_global(global)
|
||||||
|
@ -162,7 +162,7 @@ impl GlobalScope {
|
||||||
|
|
||||||
/// Returns the global scope for the given JSContext
|
/// Returns the global scope for the given JSContext
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub unsafe fn from_context(cx: *mut JSContext) -> Root<Self> {
|
pub unsafe fn from_context(cx: *mut JSContext) -> DomRoot<Self> {
|
||||||
let global = CurrentGlobalOrNull(cx);
|
let global = CurrentGlobalOrNull(cx);
|
||||||
global_scope_from_global(global)
|
global_scope_from_global(global)
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ impl GlobalScope {
|
||||||
/// Returns the global object of the realm that the given JS object
|
/// Returns the global object of the realm that the given JS object
|
||||||
/// was created in, after unwrapping any wrappers.
|
/// was created in, after unwrapping any wrappers.
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub unsafe fn from_object_maybe_wrapped(mut obj: *mut JSObject) -> Root<Self> {
|
pub unsafe fn from_object_maybe_wrapped(mut obj: *mut JSObject) -> DomRoot<Self> {
|
||||||
if IsWrapper(obj) {
|
if IsWrapper(obj) {
|
||||||
obj = UnwrapObject(obj, /* stopAtWindowProxy = */ 0);
|
obj = UnwrapObject(obj, /* stopAtWindowProxy = */ 0);
|
||||||
assert!(!obj.is_null());
|
assert!(!obj.is_null());
|
||||||
|
@ -190,7 +190,7 @@ impl GlobalScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn crypto(&self) -> Root<Crypto> {
|
pub fn crypto(&self) -> DomRoot<Crypto> {
|
||||||
self.crypto.or_init(|| Crypto::new(self))
|
self.crypto.or_init(|| Crypto::new(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ impl GlobalScope {
|
||||||
|
|
||||||
/// Perform a microtask checkpoint.
|
/// Perform a microtask checkpoint.
|
||||||
pub fn perform_a_microtask_checkpoint(&self) {
|
pub fn perform_a_microtask_checkpoint(&self) {
|
||||||
self.microtask_queue.checkpoint(|_| Some(Root::from_ref(self)));
|
self.microtask_queue.checkpoint(|_| Some(DomRoot::from_ref(self)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enqueue a microtask for subsequent execution.
|
/// Enqueue a microtask for subsequent execution.
|
||||||
|
@ -550,7 +550,7 @@ impl GlobalScope {
|
||||||
///
|
///
|
||||||
/// ["current"]: https://html.spec.whatwg.org/multipage/#current
|
/// ["current"]: https://html.spec.whatwg.org/multipage/#current
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn current() -> Option<Root<Self>> {
|
pub fn current() -> Option<DomRoot<Self>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let cx = Runtime::get();
|
let cx = Runtime::get();
|
||||||
assert!(!cx.is_null());
|
assert!(!cx.is_null());
|
||||||
|
@ -566,18 +566,18 @@ impl GlobalScope {
|
||||||
/// Returns the ["entry"] global object.
|
/// Returns the ["entry"] global object.
|
||||||
///
|
///
|
||||||
/// ["entry"]: https://html.spec.whatwg.org/multipage/#entry
|
/// ["entry"]: https://html.spec.whatwg.org/multipage/#entry
|
||||||
pub fn entry() -> Root<Self> {
|
pub fn entry() -> DomRoot<Self> {
|
||||||
entry_global()
|
entry_global()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the ["incumbent"] global object.
|
/// Returns the ["incumbent"] global object.
|
||||||
///
|
///
|
||||||
/// ["incumbent"]: https://html.spec.whatwg.org/multipage/#incumbent
|
/// ["incumbent"]: https://html.spec.whatwg.org/multipage/#incumbent
|
||||||
pub fn incumbent() -> Option<Root<Self>> {
|
pub fn incumbent() -> Option<DomRoot<Self>> {
|
||||||
incumbent_global()
|
incumbent_global()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn performance(&self) -> Root<Performance> {
|
pub fn performance(&self) -> DomRoot<Performance> {
|
||||||
if let Some(window) = self.downcast::<Window>() {
|
if let Some(window) = self.downcast::<Window>() {
|
||||||
return window.Performance();
|
return window.Performance();
|
||||||
}
|
}
|
||||||
|
@ -607,7 +607,7 @@ fn timestamp_in_ms(time: Timespec) -> u64 {
|
||||||
|
|
||||||
/// Returns the Rust global scope from a JS global object.
|
/// Returns the Rust global scope from a JS global object.
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn global_scope_from_global(global: *mut JSObject) -> Root<GlobalScope> {
|
unsafe fn global_scope_from_global(global: *mut JSObject) -> DomRoot<GlobalScope> {
|
||||||
assert!(!global.is_null());
|
assert!(!global.is_null());
|
||||||
let clasp = get_object_class(global);
|
let clasp = get_object_class(global);
|
||||||
assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL)) != 0);
|
assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL)) != 0);
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::HashChangeEventBinding::HashChangeEventMet
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::reflect_dom_object;
|
use dom::bindings::reflector::reflect_dom_object;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::{DOMString, USVString};
|
use dom::bindings::str::{DOMString, USVString};
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
@ -32,7 +32,7 @@ impl HashChangeEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(window: &Window) -> Root<HashChangeEvent> {
|
pub fn new_uninitialized(window: &Window) -> DomRoot<HashChangeEvent> {
|
||||||
reflect_dom_object(box HashChangeEvent::new_inherited(String::new(), String::new()),
|
reflect_dom_object(box HashChangeEvent::new_inherited(String::new(), String::new()),
|
||||||
window,
|
window,
|
||||||
HashChangeEventBinding::Wrap)
|
HashChangeEventBinding::Wrap)
|
||||||
|
@ -44,7 +44,7 @@ impl HashChangeEvent {
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
old_url: String,
|
old_url: String,
|
||||||
new_url: String)
|
new_url: String)
|
||||||
-> Root<HashChangeEvent> {
|
-> DomRoot<HashChangeEvent> {
|
||||||
let ev = reflect_dom_object(box HashChangeEvent::new_inherited(old_url, new_url),
|
let ev = reflect_dom_object(box HashChangeEvent::new_inherited(old_url, new_url),
|
||||||
window,
|
window,
|
||||||
HashChangeEventBinding::Wrap);
|
HashChangeEventBinding::Wrap);
|
||||||
|
@ -58,7 +58,7 @@ impl HashChangeEvent {
|
||||||
pub fn Constructor(window: &Window,
|
pub fn Constructor(window: &Window,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &HashChangeEventBinding::HashChangeEventInit)
|
init: &HashChangeEventBinding::HashChangeEventInit)
|
||||||
-> Fallible<Root<HashChangeEvent>> {
|
-> Fallible<DomRoot<HashChangeEvent>> {
|
||||||
Ok(HashChangeEvent::new(window,
|
Ok(HashChangeEvent::new(window,
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMetho
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::iterable::Iterable;
|
use dom::bindings::iterable::Iterable;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::{ByteString, is_token};
|
use dom::bindings::str::{ByteString, is_token};
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -44,13 +44,13 @@ impl Headers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope) -> Root<Headers> {
|
pub fn new(global: &GlobalScope) -> DomRoot<Headers> {
|
||||||
reflect_dom_object(box Headers::new_inherited(), global, HeadersWrap)
|
reflect_dom_object(box Headers::new_inherited(), global, HeadersWrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#dom-headers
|
// https://fetch.spec.whatwg.org/#dom-headers
|
||||||
pub fn Constructor(global: &GlobalScope, init: Option<HeadersInit>)
|
pub fn Constructor(global: &GlobalScope, init: Option<HeadersInit>)
|
||||||
-> Fallible<Root<Headers>> {
|
-> Fallible<DomRoot<Headers>> {
|
||||||
let dom_headers_new = Headers::new(global);
|
let dom_headers_new = Headers::new(global);
|
||||||
dom_headers_new.fill(init)?;
|
dom_headers_new.fill(init)?;
|
||||||
Ok(dom_headers_new)
|
Ok(dom_headers_new)
|
||||||
|
@ -206,13 +206,13 @@ impl Headers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn for_request(global: &GlobalScope) -> Root<Headers> {
|
pub fn for_request(global: &GlobalScope) -> DomRoot<Headers> {
|
||||||
let headers_for_request = Headers::new(global);
|
let headers_for_request = Headers::new(global);
|
||||||
headers_for_request.guard.set(Guard::Request);
|
headers_for_request.guard.set(Guard::Request);
|
||||||
headers_for_request
|
headers_for_request
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn for_response(global: &GlobalScope) -> Root<Headers> {
|
pub fn for_response(global: &GlobalScope) -> DomRoot<Headers> {
|
||||||
let headers_for_response = Headers::new(global);
|
let headers_for_response = Headers::new(global);
|
||||||
headers_for_response.guard.set(Guard::Response);
|
headers_for_response.guard.set(Guard::Response);
|
||||||
headers_for_response
|
headers_for_response
|
||||||
|
|
|
@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::root::{Dom, Root};
|
use dom::bindings::root::{Dom, DomRoot};
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -32,7 +32,7 @@ impl History {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(window: &Window) -> Root<History> {
|
pub fn new(window: &Window) -> DomRoot<History> {
|
||||||
reflect_dom_object(box History::new_inherited(window),
|
reflect_dom_object(box History::new_inherited(window),
|
||||||
window,
|
window,
|
||||||
HistoryBinding::Wrap)
|
HistoryBinding::Wrap)
|
||||||
|
|
|
@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::HTMLAnchorElementBinding::HTMLAnchorElemen
|
||||||
use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods;
|
use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods;
|
||||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::root::{MutNullableDom, Root};
|
use dom::bindings::root::{DomRoot, MutNullableDom};
|
||||||
use dom::bindings::str::{DOMString, USVString};
|
use dom::bindings::str::{DOMString, USVString};
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::domtokenlist::DOMTokenList;
|
use dom::domtokenlist::DOMTokenList;
|
||||||
|
@ -56,7 +56,7 @@ impl HTMLAnchorElement {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(local_name: LocalName,
|
pub fn new(local_name: LocalName,
|
||||||
prefix: Option<Prefix>,
|
prefix: Option<Prefix>,
|
||||||
document: &Document) -> Root<HTMLAnchorElement> {
|
document: &Document) -> DomRoot<HTMLAnchorElement> {
|
||||||
Node::reflect_node(box HTMLAnchorElement::new_inherited(local_name, prefix, document),
|
Node::reflect_node(box HTMLAnchorElement::new_inherited(local_name, prefix, document),
|
||||||
document,
|
document,
|
||||||
HTMLAnchorElementBinding::Wrap)
|
HTMLAnchorElementBinding::Wrap)
|
||||||
|
@ -122,7 +122,7 @@ impl HTMLAnchorElementMethods for HTMLAnchorElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-a-rellist
|
// https://html.spec.whatwg.org/multipage/#dom-a-rellist
|
||||||
fn RelList(&self) -> Root<DOMTokenList> {
|
fn RelList(&self) -> DomRoot<DOMTokenList> {
|
||||||
self.rel_list.or_init(|| DOMTokenList::new(self.upcast(), &local_name!("rel")))
|
self.rel_list.or_init(|| DOMTokenList::new(self.upcast(), &local_name!("rel")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::HTMLAppletElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLAppletElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLAppletElementBinding::HTMLAppletElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLAppletElementBinding::HTMLAppletElementMethods;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
|
@ -33,7 +33,7 @@ impl HTMLAppletElement {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(local_name: LocalName,
|
pub fn new(local_name: LocalName,
|
||||||
prefix: Option<Prefix>,
|
prefix: Option<Prefix>,
|
||||||
document: &Document) -> Root<HTMLAppletElement> {
|
document: &Document) -> DomRoot<HTMLAppletElement> {
|
||||||
Node::reflect_node(box HTMLAppletElement::new_inherited(local_name, prefix, document),
|
Node::reflect_node(box HTMLAppletElement::new_inherited(local_name, prefix, document),
|
||||||
document,
|
document,
|
||||||
HTMLAppletElementBinding::Wrap)
|
HTMLAppletElementBinding::Wrap)
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods;
|
||||||
use dom::bindings::codegen::Bindings::HTMLAreaElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLAreaElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLAreaElementBinding::HTMLAreaElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLAreaElementBinding::HTMLAreaElementMethods;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::root::{MutNullableDom, Root};
|
use dom::bindings::root::{DomRoot, MutNullableDom};
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::domtokenlist::DOMTokenList;
|
use dom::domtokenlist::DOMTokenList;
|
||||||
|
@ -231,7 +231,7 @@ impl HTMLAreaElement {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(local_name: LocalName,
|
pub fn new(local_name: LocalName,
|
||||||
prefix: Option<Prefix>,
|
prefix: Option<Prefix>,
|
||||||
document: &Document) -> Root<HTMLAreaElement> {
|
document: &Document) -> DomRoot<HTMLAreaElement> {
|
||||||
Node::reflect_node(box HTMLAreaElement::new_inherited(local_name, prefix, document),
|
Node::reflect_node(box HTMLAreaElement::new_inherited(local_name, prefix, document),
|
||||||
document,
|
document,
|
||||||
HTMLAreaElementBinding::Wrap)
|
HTMLAreaElementBinding::Wrap)
|
||||||
|
@ -273,7 +273,7 @@ impl VirtualMethods for HTMLAreaElement {
|
||||||
|
|
||||||
impl HTMLAreaElementMethods for HTMLAreaElement {
|
impl HTMLAreaElementMethods for HTMLAreaElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-area-rellist
|
// https://html.spec.whatwg.org/multipage/#dom-area-rellist
|
||||||
fn RelList(&self) -> Root<DOMTokenList> {
|
fn RelList(&self) -> DomRoot<DOMTokenList> {
|
||||||
self.rel_list.or_init(|| {
|
self.rel_list.or_init(|| {
|
||||||
DOMTokenList::new(self.upcast(), &local_name!("rel"))
|
DOMTokenList::new(self.upcast(), &local_name!("rel"))
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::HTMLAudioElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLAudioElementBinding;
|
||||||
use dom::bindings::root::Root;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::htmlmediaelement::HTMLMediaElement;
|
use dom::htmlmediaelement::HTMLMediaElement;
|
||||||
use dom::node::Node;
|
use dom::node::Node;
|
||||||
|
@ -28,7 +28,7 @@ impl HTMLAudioElement {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(local_name: LocalName,
|
pub fn new(local_name: LocalName,
|
||||||
prefix: Option<Prefix>,
|
prefix: Option<Prefix>,
|
||||||
document: &Document) -> Root<HTMLAudioElement> {
|
document: &Document) -> DomRoot<HTMLAudioElement> {
|
||||||
Node::reflect_node(box HTMLAudioElement::new_inherited(local_name, prefix, document),
|
Node::reflect_node(box HTMLAudioElement::new_inherited(local_name, prefix, document),
|
||||||
document,
|
document,
|
||||||
HTMLAudioElementBinding::Wrap)
|
HTMLAudioElementBinding::Wrap)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue