mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +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::error::{Error, Fallible};
|
||||
use dom::bindings::reflector::DomObject;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::USVString;
|
||||
use dom::blob::{Blob, BlobImpl};
|
||||
use dom::formdata::FormData;
|
||||
|
@ -33,8 +33,8 @@ pub enum BodyType {
|
|||
pub enum FetchedData {
|
||||
Text(String),
|
||||
Json(JSValue),
|
||||
BlobData(Root<Blob>),
|
||||
FormData(Root<FormData>),
|
||||
BlobData(DomRoot<Blob>),
|
||||
FormData(DomRoot<FormData>),
|
||||
}
|
||||
|
||||
// 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::inheritance::Castable;
|
||||
use dom::bindings::reflector::DomObject;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::document::AnimationFrameCallback;
|
||||
use dom::element::Element;
|
||||
|
@ -90,7 +90,7 @@ pub fn handle_get_document_element(documents: &Documents,
|
|||
fn find_node_by_unique_id(documents: &Documents,
|
||||
pipeline: PipelineId,
|
||||
node_id: &str)
|
||||
-> Option<Root<Node>> {
|
||||
-> Option<DomRoot<Node>> {
|
||||
documents.find_document(pipeline).and_then(|document|
|
||||
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
|
||||
|
||||
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
|
||||
destructor will un-root the DOM object. This is an example of the
|
||||
[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.
|
||||
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]
|
||||
allows creating a new `Root<T>` struct in that case.
|
||||
received allows us to; the [`DomRoot::from_ref` associated function][from-ref]
|
||||
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
|
||||
[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
|
||||
signature:
|
||||
|
||||
|
@ -249,11 +249,11 @@ pub fn deref<'a>(&'a self) -> &'a T {
|
|||
What this syntax means is:
|
||||
|
||||
- **`<'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`'.
|
||||
|
||||
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
|
||||
|
||||
|
@ -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
|
||||
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.
|
||||
|
||||
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::inheritance::Castable;
|
||||
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::customelementregistry::CallbackReaction;
|
||||
use dom::element::{AttributeMutation, Element};
|
||||
|
@ -63,7 +63,7 @@ impl Attr {
|
|||
namespace: Namespace,
|
||||
prefix: Option<Prefix>,
|
||||
owner: Option<&Element>)
|
||||
-> Root<Attr> {
|
||||
-> DomRoot<Attr> {
|
||||
reflect_dom_object(box Attr::new_inherited(local_name,
|
||||
value,
|
||||
name,
|
||||
|
@ -161,7 +161,7 @@ impl AttrMethods for Attr {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-attr-ownerelement
|
||||
fn GetOwnerElement(&self) -> Option<Root<Element>> {
|
||||
fn GetOwnerElement(&self) -> Option<DomRoot<Element>> {
|
||||
self.owner()
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ impl Attr {
|
|||
self.owner.set(owner);
|
||||
}
|
||||
|
||||
pub fn owner(&self) -> Option<Root<Element>> {
|
||||
pub fn owner(&self) -> Option<DomRoot<Element>> {
|
||||
self.owner.get()
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEven
|
|||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
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(),
|
||||
window,
|
||||
BeforeUnloadEventBinding::Wrap)
|
||||
|
@ -41,7 +41,7 @@ impl BeforeUnloadEvent {
|
|||
pub fn new(window: &Window,
|
||||
type_: Atom,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable) -> Root<BeforeUnloadEvent> {
|
||||
cancelable: EventCancelable) -> DomRoot<BeforeUnloadEvent> {
|
||||
let ev = BeforeUnloadEvent::new_uninitialized(window);
|
||||
{
|
||||
let event = ev.upcast::<Event>();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use dom::bindings::error::{Error, Fallible, report_pending_exception};
|
||||
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::utils::AsCCharPtrPtr;
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
@ -223,7 +223,7 @@ pub fn wrap_call_this_object<T: DomObject>(cx: *mut JSContext,
|
|||
pub struct CallSetup {
|
||||
/// The global for reporting exceptions. This is the global object of the
|
||||
/// (possibly wrapped) callback object.
|
||||
exception_global: Root<GlobalScope>,
|
||||
exception_global: DomRoot<GlobalScope>,
|
||||
/// The `JSContext` used for the call.
|
||||
cx: *mut JSContext,
|
||||
/// 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::error::throw_not_in_union',
|
||||
'dom::bindings::mozmap::MozMap',
|
||||
'dom::bindings::root::Root',
|
||||
'dom::bindings::root::DomRoot',
|
||||
'dom::bindings::str::ByteString',
|
||||
'dom::bindings::str::DOMString',
|
||||
'dom::bindings::str::USVString',
|
||||
|
@ -2558,7 +2558,7 @@ class CGWrapMethod(CGAbstractMethod):
|
|||
args = [Argument('*mut JSContext', 'cx'),
|
||||
Argument('&GlobalScope', 'scope'),
|
||||
Argument("Box<%s>" % descriptor.concreteType, 'object')]
|
||||
retval = 'Root<%s>' % descriptor.concreteType
|
||||
retval = 'DomRoot<%s>' % descriptor.concreteType
|
||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
||||
pub=True, unsafe=True)
|
||||
|
||||
|
@ -2580,7 +2580,7 @@ assert!(!proto.is_null());
|
|||
%(copyUnforgeable)s
|
||||
(*raw).init_reflector(obj.get());
|
||||
|
||||
Root::from_ref(&*raw)""" % {'copyUnforgeable': unforgeable, 'createObject': create})
|
||||
DomRoot::from_ref(&*raw)""" % {'copyUnforgeable': unforgeable, 'createObject': create})
|
||||
|
||||
|
||||
class CGWrapGlobalMethod(CGAbstractMethod):
|
||||
|
@ -2592,7 +2592,7 @@ class CGWrapGlobalMethod(CGAbstractMethod):
|
|||
assert descriptor.isGlobal()
|
||||
args = [Argument('*mut JSContext', 'cx'),
|
||||
Argument("Box<%s>" % descriptor.concreteType, 'object')]
|
||||
retval = 'Root<%s>' % descriptor.concreteType
|
||||
retval = 'DomRoot<%s>' % descriptor.concreteType
|
||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
||||
pub=True, unsafe=True)
|
||||
self.properties = properties
|
||||
|
@ -2638,7 +2638,7 @@ assert!(immutable);
|
|||
|
||||
%(unforgeable)s
|
||||
|
||||
Root::from_ref(&*raw)\
|
||||
DomRoot::from_ref(&*raw)\
|
||||
""" % values)
|
||||
|
||||
|
||||
|
@ -3421,7 +3421,9 @@ class CGAbstractStaticBindingMethod(CGAbstractMethod):
|
|||
def definition_body(self):
|
||||
preamble = "let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());\n"
|
||||
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()])
|
||||
|
||||
def generate_code(self):
|
||||
|
@ -5352,7 +5354,9 @@ class CGClassConstructHook(CGAbstractExternMethod):
|
|||
def definition_body(self):
|
||||
preamble = """let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());\n"""
|
||||
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 = CGGeneric(preamble)
|
||||
if self.constructor.isHTMLConstructor():
|
||||
|
@ -5408,7 +5412,7 @@ if !JS_WrapObject(cx, prototype.handle_mut()) {
|
|||
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 {
|
||||
Ok(result) => result,
|
||||
Err(e) => {
|
||||
|
@ -5713,8 +5717,8 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'dom::bindings::reflector::MutDomObject',
|
||||
'dom::bindings::reflector::DomObject',
|
||||
'dom::bindings::root::Dom',
|
||||
'dom::bindings::root::DomRoot',
|
||||
'dom::bindings::root::OptionalHeapSetter',
|
||||
'dom::bindings::root::Root',
|
||||
'dom::bindings::root::RootedReference',
|
||||
'dom::bindings::utils::AsVoidPtr',
|
||||
'dom::bindings::utils::DOMClass',
|
||||
|
@ -6281,7 +6285,7 @@ class CGRegisterProxyHandlers(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).
|
||||
"""
|
||||
def __init__(self, config, prefix, webIDLFile):
|
||||
|
@ -7195,7 +7199,7 @@ class GlobalGenRoots():
|
|||
imports = [CGGeneric("use dom::types::*;\n"),
|
||||
CGGeneric("use dom::bindings::conversions::{DerivedFrom, get_dom_class};\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::reflector::DomObject;\n"),
|
||||
CGGeneric("use js::jsapi::JSTracer;\n\n"),
|
||||
|
|
|
@ -212,7 +212,7 @@ class Descriptor(DescriptorProvider):
|
|||
self.argumentType = "???"
|
||||
self.nativeType = ty
|
||||
else:
|
||||
self.returnType = "Root<%s>" % typeName
|
||||
self.returnType = "DomRoot<%s>" % typeName
|
||||
self.argumentType = "&%s" % typeName
|
||||
self.nativeType = "*const %s" % typeName
|
||||
if self.interface.isIteratorInterface():
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
//! | USVString | `USVString` |
|
||||
//! | ByteString | `ByteString` |
|
||||
//! | object | `*mut JSObject` |
|
||||
//! | interface types | `&T` | `Root<T>` |
|
||||
//! | interface types | `&T` | `DomRoot<T>` |
|
||||
//! | dictionary types | `&T` | *unsupported* |
|
||||
//! | enumeration types | `T` |
|
||||
//! | callback function types | `Rc<T>` |
|
||||
|
@ -36,7 +36,7 @@ use dom::bindings::error::{Error, Fallible};
|
|||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::num::Finite;
|
||||
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::trace::{JSTraceable, RootedTraceableBox};
|
||||
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 = ();
|
||||
|
||||
unsafe fn from_jsval(_cx: *mut JSContext,
|
||||
value: HandleValue,
|
||||
_config: Self::Config)
|
||||
-> Result<ConversionResult<Root<T>>, ()> {
|
||||
-> Result<ConversionResult<DomRoot<T>>, ()> {
|
||||
Ok(match root_from_handlevalue(value) {
|
||||
Ok(result) => ConversionResult::Success(result),
|
||||
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.
|
||||
///
|
||||
/// 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
|
||||
/// 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
|
||||
{
|
||||
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`.
|
||||
|
@ -428,9 +428,9 @@ pub fn native_from_handlevalue<T>(v: HandleValue) -> Result<*const T, ()>
|
|||
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.
|
||||
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
|
||||
{
|
||||
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())
|
||||
}
|
||||
|
||||
/// Get a `Root<T>` for a DOM object accessible from a `HandleObject`.
|
||||
pub fn root_from_handleobject<T>(obj: HandleObject) -> Result<Root<T>, ()>
|
||||
/// Get a `DomRoot<T>` for a DOM object accessible from a `HandleObject`.
|
||||
pub fn root_from_handleobject<T>(obj: HandleObject) -> Result<DomRoot<T>, ()>
|
||||
where T: DomObject + IDLInterface
|
||||
{
|
||||
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) {
|
||||
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::error::{Error, Fallible};
|
||||
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::create::create_native_html_element;
|
||||
use dom::customelementregistry::ConstructionStackEntry;
|
||||
|
@ -236,7 +236,7 @@ pub unsafe fn create_global_object(
|
|||
}
|
||||
|
||||
// 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> {
|
||||
let document = window.Document();
|
||||
|
||||
|
@ -289,7 +289,7 @@ pub unsafe fn html_constructor<T>(window: &Window, call_args: &CallArgs) -> Fall
|
|||
// Step 8.1
|
||||
let name = QualName::new(None, ns!(html), definition.local_name.clone());
|
||||
let element = if definition.is_autonomous() {
|
||||
Root::upcast(HTMLElement::new(name.local, None, &*document))
|
||||
DomRoot::upcast(HTMLElement::new(name.local, None, &*document))
|
||||
} else {
|
||||
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());
|
||||
|
||||
// Step 8.5
|
||||
Root::downcast(element).ok_or(Error::InvalidState)
|
||||
DomRoot::downcast(element).ok_or(Error::InvalidState)
|
||||
},
|
||||
// Step 9
|
||||
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);
|
||||
|
||||
// Step 13
|
||||
Root::downcast(element).ok_or(Error::InvalidState)
|
||||
DomRoot::downcast(element).ok_or(Error::InvalidState)
|
||||
},
|
||||
// Step 10
|
||||
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::error::Fallible;
|
||||
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::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
|
@ -61,7 +61,7 @@ impl<T: DomObject + JSTraceable + Iterable> IterableIterator<T> {
|
|||
pub fn new(iterable: &T,
|
||||
type_: IteratorType,
|
||||
wrap: unsafe fn(*mut JSContext, &GlobalScope, Box<IterableIterator<T>>)
|
||||
-> Root<Self>) -> Root<Self> {
|
||||
-> DomRoot<Self>) -> DomRoot<Self> {
|
||||
let iterator = box IterableIterator {
|
||||
reflector: Reflector::new(),
|
||||
type_: type_,
|
||||
|
|
|
@ -26,7 +26,7 @@ use core::nonzero::NonZero;
|
|||
use dom::bindings::conversions::ToJSValConvertible;
|
||||
use dom::bindings::error::Error;
|
||||
use dom::bindings::reflector::{DomObject, Reflector};
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::trace::trace_reflector;
|
||||
use dom::promise::Promise;
|
||||
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
|
||||
/// a different thread than the original value from which this `Trusted<T>` was
|
||||
/// obtained.
|
||||
pub fn root(&self) -> Root<T> {
|
||||
pub fn root(&self) -> DomRoot<T> {
|
||||
assert!(LIVE_REFERENCES.with(|ref r| {
|
||||
let r = r.borrow();
|
||||
let live_references = r.as_ref().unwrap();
|
||||
self.owner_thread == (&*live_references) as *const _ as *const libc::c_void
|
||||
}));
|
||||
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.
|
||||
|
||||
use dom::bindings::conversions::DerivedFrom;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{HandleObject, JSContext, JSObject, Heap};
|
||||
use std::default::Default;
|
||||
|
@ -15,8 +15,8 @@ use std::default::Default;
|
|||
pub fn reflect_dom_object<T, U>(
|
||||
obj: Box<T>,
|
||||
global: &U,
|
||||
wrap_fn: unsafe fn(*mut JSContext, &GlobalScope, Box<T>) -> Root<T>)
|
||||
-> Root<T>
|
||||
wrap_fn: unsafe fn(*mut JSContext, &GlobalScope, Box<T>) -> DomRoot<T>)
|
||||
-> DomRoot<T>
|
||||
where T: DomObject, U: DerivedFrom<GlobalScope>
|
||||
{
|
||||
let global_scope = global.upcast();
|
||||
|
@ -77,7 +77,7 @@ pub trait DomObject {
|
|||
fn reflector(&self) -> &Reflector;
|
||||
|
||||
/// 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,16 +11,16 @@
|
|||
//!
|
||||
//! 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
|
||||
//! the GC when encountered as a field of a Rust structure.
|
||||
//!
|
||||
//! `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
|
||||
//! `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
|
||||
//! originating `Root<T>`.
|
||||
//! originating `DomRoot<T>`.
|
||||
//!
|
||||
|
||||
use core::nonzero::NonZero;
|
||||
|
@ -259,10 +259,10 @@ impl<T: DomObject> MutDom<T> {
|
|||
}
|
||||
|
||||
/// 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());
|
||||
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
|
||||
/// initialized with the result of `cb` first.
|
||||
pub fn or_init<F>(&self, cb: F) -> Root<T>
|
||||
where F: FnOnce() -> Root<T>
|
||||
pub fn or_init<F>(&self, cb: F) -> DomRoot<T>
|
||||
where F: FnOnce() -> DomRoot<T>
|
||||
{
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
match self.get() {
|
||||
|
@ -337,10 +337,10 @@ impl<T: DomObject> MutNullableDom<T> {
|
|||
|
||||
/// Get a rooted value out of this object
|
||||
#[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());
|
||||
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`.
|
||||
pub fn take(&self) -> Option<Root<T>> {
|
||||
pub fn take(&self) -> Option<DomRoot<T>> {
|
||||
let value = self.get();
|
||||
self.set(None);
|
||||
value
|
||||
|
@ -409,7 +409,7 @@ impl<T: DomObject> DomOnceCell<T> {
|
|||
/// initialized with the result of `cb` first.
|
||||
#[allow(unrooted_must_root)]
|
||||
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());
|
||||
&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
|
||||
/// `RootCollection` object.
|
||||
#[allow_unrooted_interior]
|
||||
pub struct Root<T: DomObject> {
|
||||
pub struct DomRoot<T: DomObject> {
|
||||
/// Reference to rooted value that must not outlive this container
|
||||
ptr: NonZero<*const T>,
|
||||
/// List that ensures correct dynamic root ordering
|
||||
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.
|
||||
pub fn upcast<U>(root: Root<T>) -> Root<U>
|
||||
pub fn upcast<U>(root: DomRoot<T>) -> DomRoot<U>
|
||||
where U: Castable,
|
||||
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.
|
||||
pub fn downcast<U>(root: Root<T>) -> Option<Root<U>>
|
||||
pub fn downcast<U>(root: DomRoot<T>) -> Option<DomRoot<U>>
|
||||
where U: DerivedFrom<T>
|
||||
{
|
||||
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.
|
||||
/// It cannot outlive its associated `RootCollection`, and it gives
|
||||
/// 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());
|
||||
STACK_ROOTS.with(|ref collection| {
|
||||
let RootCollectionPtr(collection) = collection.get().unwrap();
|
||||
unsafe { (*collection).root(&*(*unrooted.get()).reflector()) }
|
||||
Root {
|
||||
DomRoot {
|
||||
ptr: unrooted,
|
||||
root_list: collection,
|
||||
}
|
||||
|
@ -604,19 +604,19 @@ impl<T: DomObject> Root<T> {
|
|||
}
|
||||
|
||||
/// Generate a new root from a reference
|
||||
pub fn from_ref(unrooted: &T) -> Root<T> {
|
||||
Root::new(unsafe { NonZero::new_unchecked(unrooted) })
|
||||
pub fn from_ref(unrooted: &T) -> DomRoot<T> {
|
||||
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;
|
||||
fn r(&'root self) -> &'root T {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: DomObject> Deref for Root<T> {
|
||||
impl<T: DomObject> Deref for DomRoot<T> {
|
||||
type Target = T;
|
||||
fn deref(&self) -> &T {
|
||||
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 {
|
||||
(**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 {
|
||||
self.ptr == other.ptr
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: DomObject> Clone for Root<T> {
|
||||
fn clone(&self) -> Root<T> {
|
||||
Root::from_ref(&*self)
|
||||
impl<T: DomObject> Clone for DomRoot<T> {
|
||||
fn clone(&self) -> DomRoot<T> {
|
||||
DomRoot::from_ref(&*self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: DomObject> Drop for Root<T> {
|
||||
impl<T: DomObject> Drop for DomRoot<T> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
(*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) {
|
||||
// Already traced.
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
use dom::bindings::root::{Dom, Root};
|
||||
use dom::bindings::root::{Dom, DomRoot};
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
use dom::globalscope::GlobalScope;
|
||||
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.
|
||||
pub struct AutoEntryScript {
|
||||
global: Root<GlobalScope>,
|
||||
global: DomRoot<GlobalScope>,
|
||||
}
|
||||
|
||||
impl AutoEntryScript {
|
||||
|
@ -51,7 +51,7 @@ impl AutoEntryScript {
|
|||
kind: StackEntryKind::Entry,
|
||||
});
|
||||
AutoEntryScript {
|
||||
global: Root::from_ref(global),
|
||||
global: DomRoot::from_ref(global),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -80,13 +80,13 @@ impl Drop for AutoEntryScript {
|
|||
/// Returns the ["entry"] global object.
|
||||
///
|
||||
/// ["entry"]: https://html.spec.whatwg.org/multipage/#entry
|
||||
pub fn entry_global() -> Root<GlobalScope> {
|
||||
pub fn entry_global() -> DomRoot<GlobalScope> {
|
||||
STACK.with(|stack| {
|
||||
stack.borrow()
|
||||
.iter()
|
||||
.rev()
|
||||
.find(|entry| entry.kind == StackEntryKind::Entry)
|
||||
.map(|entry| Root::from_ref(&*entry.global))
|
||||
.map(|entry| DomRoot::from_ref(&*entry.global))
|
||||
}).unwrap()
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ impl Drop for AutoIncumbentScript {
|
|||
/// Returns the ["incumbent"] global object.
|
||||
///
|
||||
/// ["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
|
||||
|
||||
// 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.borrow()
|
||||
.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::error::{Error, Fallible};
|
||||
use dom::bindings::reflector::DomObject;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::blob::{Blob, BlobImpl};
|
||||
use dom::globalscope::GlobalScope;
|
||||
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()
|
||||
}
|
||||
|
||||
unsafe fn write_blob(blob: Root<Blob>,
|
||||
unsafe fn write_blob(blob: DomRoot<Blob>,
|
||||
w: *mut JSStructuredCloneWriter)
|
||||
-> Result<(), ()> {
|
||||
let structured_writer = StructuredCloneWriter { w: w };
|
||||
|
|
|
@ -42,7 +42,7 @@ use dom::bindings::cell::DomRefCell;
|
|||
use dom::bindings::error::Error;
|
||||
use dom::bindings::refcounted::{Trusted, TrustedPromise};
|
||||
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::utils::WindowProxyHandler;
|
||||
use dom::document::PendingRestyle;
|
||||
|
@ -710,7 +710,7 @@ impl RootedTraceableSet {
|
|||
|
||||
/// 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 an arbitrary number of DomObjects to root, use rooted_vec!.
|
||||
/// 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> {
|
||||
/// 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> {
|
||||
unsafe {
|
||||
RootedTraceableSet::add(traceable);
|
||||
|
@ -741,7 +741,7 @@ impl<'a, T: JSTraceable + 'static> Drop for RootedTraceable<'a, T> {
|
|||
|
||||
/// 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 an arbitrary number of DomObjects to root, use rooted_vec!.
|
||||
/// 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> {
|
||||
/// 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> {
|
||||
let traceable = Box::into_raw(box traceable);
|
||||
unsafe {
|
||||
|
@ -804,7 +804,7 @@ impl<T: JSTraceable + 'static> Drop for RootedTraceableBox<T> {
|
|||
/// A vector of items to be rooted with `RootedVec`.
|
||||
/// Guaranteed to be empty when not rooted.
|
||||
/// 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)]
|
||||
#[derive(JSTraceable)]
|
||||
#[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
|
||||
/// the lifetime of this struct
|
||||
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 {
|
||||
RootedTraceableSet::add(root);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
use core::nonzero::NonZero;
|
||||
use dom::bindings::reflector::DomObject;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
use heapsize::HeapSizeOf;
|
||||
use js::jsapi::{JSTracer, JS_GetReservedSlot, JS_SetReservedSlot};
|
||||
|
@ -84,9 +84,9 @@ impl<T: WeakReferenceable> WeakRef<T> {
|
|||
value.downgrade()
|
||||
}
|
||||
|
||||
/// Root a weak reference. Returns `None` if the object was already collected.
|
||||
pub fn root(&self) -> Option<Root<T>> {
|
||||
unsafe { &*self.ptr.get() }.value.get().map(Root::new)
|
||||
/// DomRoot a weak reference. Returns `None` if the object was already collected.
|
||||
pub fn root(&self) -> Option<DomRoot<T>> {
|
||||
unsafe { &*self.ptr.get() }.value.get().map(DomRoot::new)
|
||||
}
|
||||
|
||||
/// 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.
|
||||
pub fn root(&self) -> Option<Root<T>> {
|
||||
pub fn root(&self) -> Option<DomRoot<T>> {
|
||||
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::error::{Error, Fallible};
|
||||
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::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
|
@ -79,7 +79,7 @@ impl Blob {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn new(
|
||||
global: &GlobalScope, blob_impl: BlobImpl, typeString: String)
|
||||
-> Root<Blob> {
|
||||
-> DomRoot<Blob> {
|
||||
let boxed_blob = box Blob::new_inherited(blob_impl, typeString);
|
||||
reflect_dom_object(boxed_blob, global, BlobBinding::Wrap)
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ impl Blob {
|
|||
|
||||
#[allow(unrooted_must_root)]
|
||||
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() {
|
||||
BlobImpl::File(_) => {
|
||||
// Create new parent node
|
||||
|
@ -120,7 +120,7 @@ impl Blob {
|
|||
pub fn Constructor(global: &GlobalScope,
|
||||
blobParts: Option<Vec<BlobOrString>>,
|
||||
blobPropertyBag: &BlobBinding::BlobPropertyBag)
|
||||
-> Fallible<Root<Blob>> {
|
||||
-> Fallible<DomRoot<Blob>> {
|
||||
// TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView
|
||||
let bytes: Vec<u8> = match blobParts {
|
||||
None => Vec::new(),
|
||||
|
@ -369,7 +369,7 @@ impl BlobMethods for Blob {
|
|||
start: Option<i64>,
|
||||
end: Option<i64>,
|
||||
content_type: Option<DOMString>)
|
||||
-> Root<Blob> {
|
||||
-> DomRoot<Blob> {
|
||||
let rel_pos = RelativePos::from_opts(start, end);
|
||||
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::refcounted::{Trusted, TrustedPromise};
|
||||
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::bluetoothdevice::BluetoothDevice;
|
||||
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(),
|
||||
global,
|
||||
BluetoothBinding::Wrap)
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods;
|
|||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
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::bluetoothdevice::BluetoothDevice;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
|
@ -54,7 +54,7 @@ impl BluetoothAdvertisingEvent {
|
|||
appearance: Option<u16>,
|
||||
txPower: Option<i8>,
|
||||
rssi: Option<i8>)
|
||||
-> Root<BluetoothAdvertisingEvent> {
|
||||
-> DomRoot<BluetoothAdvertisingEvent> {
|
||||
let ev = reflect_dom_object(box BluetoothAdvertisingEvent::new_inherited(device,
|
||||
name,
|
||||
appearance,
|
||||
|
@ -73,7 +73,7 @@ impl BluetoothAdvertisingEvent {
|
|||
pub fn Constructor(window: &Window,
|
||||
type_: DOMString,
|
||||
init: &BluetoothAdvertisingEventInit)
|
||||
-> Fallible<Root<BluetoothAdvertisingEvent>> {
|
||||
-> Fallible<DomRoot<BluetoothAdvertisingEvent>> {
|
||||
let global = window.upcast::<GlobalScope>();
|
||||
let device = init.device.r();
|
||||
let name = init.name.clone();
|
||||
|
@ -96,8 +96,8 @@ impl BluetoothAdvertisingEvent {
|
|||
|
||||
impl BluetoothAdvertisingEventMethods for BluetoothAdvertisingEvent {
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothadvertisingevent-device
|
||||
fn Device(&self) -> Root<BluetoothDevice> {
|
||||
Root::from_ref(&*self.device)
|
||||
fn Device(&self) -> DomRoot<BluetoothDevice> {
|
||||
DomRoot::from_ref(&*self.device)
|
||||
}
|
||||
|
||||
// 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::
|
||||
BluetoothCharacteristicPropertiesMethods;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
|
||||
|
@ -60,7 +60,7 @@ impl BluetoothCharacteristicProperties {
|
|||
authenticatedSignedWrites: bool,
|
||||
reliableWrite: bool,
|
||||
writableAuxiliaries: bool)
|
||||
-> Root<BluetoothCharacteristicProperties> {
|
||||
-> DomRoot<BluetoothCharacteristicProperties> {
|
||||
reflect_dom_object(box BluetoothCharacteristicProperties::new_inherited(broadcast,
|
||||
read,
|
||||
writeWithoutResponse,
|
||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::error::Error;
|
|||
use dom::bindings::error::ErrorResult;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
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::bluetooth::{AsyncBluetoothListener, Bluetooth, response_async};
|
||||
use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
|
||||
|
@ -65,7 +65,7 @@ impl BluetoothDevice {
|
|||
id: DOMString,
|
||||
name: Option<DOMString>,
|
||||
context: &Bluetooth)
|
||||
-> Root<BluetoothDevice> {
|
||||
-> DomRoot<BluetoothDevice> {
|
||||
reflect_dom_object(box BluetoothDevice::new_inherited(id,
|
||||
name,
|
||||
context),
|
||||
|
@ -73,24 +73,24 @@ impl BluetoothDevice {
|
|||
BluetoothDeviceBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn get_gatt(&self) -> Root<BluetoothRemoteGATTServer> {
|
||||
pub fn get_gatt(&self) -> DomRoot<BluetoothRemoteGATTServer> {
|
||||
self.gatt.or_init(|| {
|
||||
BluetoothRemoteGATTServer::new(&self.global(), self)
|
||||
})
|
||||
}
|
||||
|
||||
fn get_context(&self) -> Root<Bluetooth> {
|
||||
Root::from_ref(&self.context)
|
||||
fn get_context(&self) -> DomRoot<Bluetooth> {
|
||||
DomRoot::from_ref(&self.context)
|
||||
}
|
||||
|
||||
pub fn get_or_create_service(&self,
|
||||
service: &BluetoothServiceMsg,
|
||||
server: &BluetoothRemoteGATTServer)
|
||||
-> Root<BluetoothRemoteGATTService> {
|
||||
-> DomRoot<BluetoothRemoteGATTService> {
|
||||
let (ref service_map_ref, _, _) = self.attribute_instance_map;
|
||||
let mut service_map = service_map_ref.borrow_mut();
|
||||
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(),
|
||||
&server.Device(),
|
||||
|
@ -104,11 +104,11 @@ impl BluetoothDevice {
|
|||
pub fn get_or_create_characteristic(&self,
|
||||
characteristic: &BluetoothCharacteristicMsg,
|
||||
service: &BluetoothRemoteGATTService)
|
||||
-> Root<BluetoothRemoteGATTCharacteristic> {
|
||||
-> DomRoot<BluetoothRemoteGATTCharacteristic> {
|
||||
let (_, ref characteristic_map_ref, _) = self.attribute_instance_map;
|
||||
let mut characteristic_map = characteristic_map_ref.borrow_mut();
|
||||
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 =
|
||||
BluetoothCharacteristicProperties::new(&service.global(),
|
||||
|
@ -140,11 +140,11 @@ impl BluetoothDevice {
|
|||
pub fn get_or_create_descriptor(&self,
|
||||
descriptor: &BluetoothDescriptorMsg,
|
||||
characteristic: &BluetoothRemoteGATTCharacteristic)
|
||||
-> Root<BluetoothRemoteGATTDescriptor> {
|
||||
-> DomRoot<BluetoothRemoteGATTDescriptor> {
|
||||
let (_, _, ref descriptor_map_ref) = self.attribute_instance_map;
|
||||
let mut descriptor_map = descriptor_map_ref.borrow_mut();
|
||||
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(),
|
||||
characteristic,
|
||||
|
@ -225,7 +225,7 @@ impl BluetoothDeviceMethods for BluetoothDevice {
|
|||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-gatt
|
||||
fn GetGatt(&self) -> Option<Root<BluetoothRemoteGATTServer>> {
|
||||
fn GetGatt(&self) -> Option<DomRoot<BluetoothRemoteGATTServer>> {
|
||||
// Step 1.
|
||||
if self.global().as_window().bluetooth_extra_permission_data()
|
||||
.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::error::Error;
|
||||
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::bluetooth::{AsyncBluetoothListener, Bluetooth, AllowedBluetoothDevice};
|
||||
use dom::bluetoothdevice::BluetoothDevice;
|
||||
|
@ -40,13 +40,13 @@ impl BluetoothPermissionResult {
|
|||
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),
|
||||
global,
|
||||
BluetoothPermissionResultBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn get_bluetooth(&self) -> Root<Bluetooth> {
|
||||
pub fn get_bluetooth(&self) -> DomRoot<Bluetooth> {
|
||||
self.global().as_window().Navigator().Bluetooth()
|
||||
}
|
||||
|
||||
|
@ -74,9 +74,9 @@ impl BluetoothPermissionResult {
|
|||
|
||||
impl BluetoothPermissionResultMethods for BluetoothPermissionResult {
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothpermissionresult-devices
|
||||
fn Devices(&self) -> Vec<Root<BluetoothDevice>> {
|
||||
let device_vec: Vec<Root<BluetoothDevice>> =
|
||||
self.devices.borrow().iter().map(|d| Root::from_ref(&**d)).collect();
|
||||
fn Devices(&self) -> Vec<DomRoot<BluetoothDevice>> {
|
||||
let device_vec: Vec<DomRoot<BluetoothDevice>> =
|
||||
self.devices.borrow().iter().map(|d| DomRoot::from_ref(&**d)).collect();
|
||||
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::inheritance::Castable;
|
||||
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::bluetooth::{AsyncBluetoothListener, get_gatt_children, response_async};
|
||||
use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
|
||||
|
@ -64,7 +64,7 @@ impl BluetoothRemoteGATTCharacteristic {
|
|||
uuid: DOMString,
|
||||
properties: &BluetoothCharacteristicProperties,
|
||||
instanceID: String)
|
||||
-> Root<BluetoothRemoteGATTCharacteristic> {
|
||||
-> DomRoot<BluetoothRemoteGATTCharacteristic> {
|
||||
reflect_dom_object(box BluetoothRemoteGATTCharacteristic::new_inherited(service,
|
||||
uuid,
|
||||
properties,
|
||||
|
@ -84,13 +84,13 @@ impl BluetoothRemoteGATTCharacteristic {
|
|||
|
||||
impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteristic {
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-properties
|
||||
fn Properties(&self) -> Root<BluetoothCharacteristicProperties> {
|
||||
Root::from_ref(&self.properties)
|
||||
fn Properties(&self) -> DomRoot<BluetoothCharacteristicProperties> {
|
||||
DomRoot::from_ref(&self.properties)
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-service
|
||||
fn Service(&self) -> Root<BluetoothRemoteGATTService> {
|
||||
Root::from_ref(&self.service)
|
||||
fn Service(&self) -> DomRoot<BluetoothRemoteGATTService> {
|
||||
DomRoot::from_ref(&self.service)
|
||||
}
|
||||
|
||||
// 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::error::Error::{self, InvalidModification, Network, Security};
|
||||
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::bluetooth::{AsyncBluetoothListener, response_async};
|
||||
use dom::bluetoothremotegattcharacteristic::{BluetoothRemoteGATTCharacteristic, MAXIMUM_ATTRIBUTE_LENGTH};
|
||||
|
@ -51,7 +51,7 @@ impl BluetoothRemoteGATTDescriptor {
|
|||
characteristic: &BluetoothRemoteGATTCharacteristic,
|
||||
uuid: DOMString,
|
||||
instanceID: String)
|
||||
-> Root<BluetoothRemoteGATTDescriptor>{
|
||||
-> DomRoot<BluetoothRemoteGATTDescriptor>{
|
||||
reflect_dom_object(box BluetoothRemoteGATTDescriptor::new_inherited(characteristic,
|
||||
uuid,
|
||||
instanceID),
|
||||
|
@ -70,8 +70,8 @@ impl BluetoothRemoteGATTDescriptor {
|
|||
|
||||
impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-characteristic
|
||||
fn Characteristic(&self) -> Root<BluetoothRemoteGATTCharacteristic> {
|
||||
Root::from_ref(&self.characteristic)
|
||||
fn Characteristic(&self) -> DomRoot<BluetoothRemoteGATTCharacteristic> {
|
||||
DomRoot::from_ref(&self.characteristic)
|
||||
}
|
||||
|
||||
// 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::ErrorResult;
|
||||
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::bluetoothdevice::BluetoothDevice;
|
||||
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),
|
||||
global,
|
||||
BluetoothRemoteGATTServerBinding::Wrap)
|
||||
|
@ -54,8 +54,8 @@ impl BluetoothRemoteGATTServer {
|
|||
|
||||
impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-device
|
||||
fn Device(&self) -> Root<BluetoothDevice> {
|
||||
Root::from_ref(&self.device)
|
||||
fn Device(&self) -> DomRoot<BluetoothDevice> {
|
||||
DomRoot::from_ref(&self.device)
|
||||
}
|
||||
|
||||
// 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::error::Error;
|
||||
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::bluetooth::{AsyncBluetoothListener, get_gatt_children};
|
||||
use dom::bluetoothdevice::BluetoothDevice;
|
||||
|
@ -49,7 +49,7 @@ impl BluetoothRemoteGATTService {
|
|||
uuid: DOMString,
|
||||
isPrimary: bool,
|
||||
instanceID: String)
|
||||
-> Root<BluetoothRemoteGATTService> {
|
||||
-> DomRoot<BluetoothRemoteGATTService> {
|
||||
reflect_dom_object(box BluetoothRemoteGATTService::new_inherited(device,
|
||||
uuid,
|
||||
isPrimary,
|
||||
|
@ -65,8 +65,8 @@ impl BluetoothRemoteGATTService {
|
|||
|
||||
impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-device
|
||||
fn Device(&self) -> Root<BluetoothDevice> {
|
||||
Root::from_ref(&self.device)
|
||||
fn Device(&self) -> DomRoot<BluetoothDevice> {
|
||||
DomRoot::from_ref(&self.device)
|
||||
}
|
||||
|
||||
// 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::num::Finite;
|
||||
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::globalscope::GlobalScope;
|
||||
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),
|
||||
global,
|
||||
CanvasGradientBinding::Wrap)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use canvas_traits::canvas::{FillOrStrokeStyle, RepetitionStyle, SurfaceStyle};
|
||||
use dom::bindings::codegen::Bindings::CanvasPatternBinding;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::canvasgradient::ToFillOrStrokeStyle;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
|
@ -49,7 +49,7 @@ impl CanvasPattern {
|
|||
surface_size: Size2D<i32>,
|
||||
repeat: RepetitionStyle,
|
||||
origin_clean: bool)
|
||||
-> Root<CanvasPattern> {
|
||||
-> DomRoot<CanvasPattern> {
|
||||
reflect_dom_object(box CanvasPattern::new_inherited(surface_data, surface_size,
|
||||
repeat, origin_clean),
|
||||
global,
|
||||
|
|
|
@ -23,7 +23,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
|
|||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::num::Finite;
|
||||
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::canvasgradient::{CanvasGradient, CanvasGradientStyle, ToFillOrStrokeStyle};
|
||||
use dom::canvaspattern::CanvasPattern;
|
||||
|
@ -151,7 +151,7 @@ impl CanvasRenderingContext2D {
|
|||
pub fn new(global: &GlobalScope,
|
||||
canvas: &HTMLCanvasElement,
|
||||
size: Size2D<i32>)
|
||||
-> Root<CanvasRenderingContext2D> {
|
||||
-> DomRoot<CanvasRenderingContext2D> {
|
||||
let window = window_from_node(canvas);
|
||||
let image_cache = window.image_cache();
|
||||
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.
|
||||
impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||
// 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,
|
||||
// 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
|
||||
|
@ -997,10 +997,10 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
StringOrCanvasGradientOrCanvasPattern::String(DOMString::from(result))
|
||||
},
|
||||
CanvasFillOrStrokeStyle::Gradient(ref gradient) => {
|
||||
StringOrCanvasGradientOrCanvasPattern::CanvasGradient(Root::from_ref(&*gradient))
|
||||
StringOrCanvasGradientOrCanvasPattern::CanvasGradient(DomRoot::from_ref(&*gradient))
|
||||
},
|
||||
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))
|
||||
},
|
||||
CanvasFillOrStrokeStyle::Gradient(ref gradient) => {
|
||||
StringOrCanvasGradientOrCanvasPattern::CanvasGradient(Root::from_ref(&*gradient))
|
||||
StringOrCanvasGradientOrCanvasPattern::CanvasGradient(DomRoot::from_ref(&*gradient))
|
||||
},
|
||||
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
|
||||
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 {
|
||||
return Err(Error::IndexSize);
|
||||
}
|
||||
|
@ -1098,7 +1098,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
}
|
||||
|
||||
// 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.Width(),
|
||||
imagedata.Height(),
|
||||
|
@ -1111,7 +1111,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
sy: Finite<f64>,
|
||||
sw: Finite<f64>,
|
||||
sh: Finite<f64>)
|
||||
-> Fallible<Root<ImageData>> {
|
||||
-> Fallible<DomRoot<ImageData>> {
|
||||
if !self.origin_is_clean() {
|
||||
return Err(Error::Security)
|
||||
}
|
||||
|
@ -1198,7 +1198,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
y0: Finite<f64>,
|
||||
x1: Finite<f64>,
|
||||
y1: Finite<f64>)
|
||||
-> Root<CanvasGradient> {
|
||||
-> DomRoot<CanvasGradient> {
|
||||
CanvasGradient::new(&self.global(),
|
||||
CanvasGradientStyle::Linear(LinearGradientStyle::new(*x0,
|
||||
*y0,
|
||||
|
@ -1215,7 +1215,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
x1: Finite<f64>,
|
||||
y1: Finite<f64>,
|
||||
r1: Finite<f64>)
|
||||
-> Fallible<Root<CanvasGradient>> {
|
||||
-> Fallible<DomRoot<CanvasGradient>> {
|
||||
if *r0 < 0. || *r1 < 0. {
|
||||
return Err(Error::IndexSize);
|
||||
}
|
||||
|
@ -1234,7 +1234,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
fn CreatePattern(&self,
|
||||
image: CanvasImageSource,
|
||||
mut repetition: DOMString)
|
||||
-> Fallible<Root<CanvasPattern>> {
|
||||
-> Fallible<DomRoot<CanvasPattern>> {
|
||||
let (image_data, image_size) = match image {
|
||||
CanvasImageSource::HTMLImageElement(ref image) => {
|
||||
// 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::error::{Error, ErrorResult, Fallible};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::root::{LayoutDom, Root};
|
||||
use dom::bindings::root::{DomRoot, LayoutDom};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::comment::Comment;
|
||||
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() {
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => {
|
||||
Root::upcast(Comment::new(data, &document))
|
||||
DomRoot::upcast(Comment::new(data, &document))
|
||||
}
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => {
|
||||
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) => {
|
||||
Root::upcast(Text::new(data, &document))
|
||||
DomRoot::upcast(Text::new(data, &document))
|
||||
},
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
@ -237,13 +237,13 @@ impl CharacterDataMethods for CharacterData {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-previouselementsibling
|
||||
fn GetPreviousElementSibling(&self) -> Option<Root<Element>> {
|
||||
self.upcast::<Node>().preceding_siblings().filter_map(Root::downcast).next()
|
||||
fn GetPreviousElementSibling(&self) -> Option<DomRoot<Element>> {
|
||||
self.upcast::<Node>().preceding_siblings().filter_map(DomRoot::downcast).next()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-nextelementsibling
|
||||
fn GetNextElementSibling(&self) -> Option<Root<Element>> {
|
||||
self.upcast::<Node>().following_siblings().filter_map(Root::downcast).next()
|
||||
fn GetNextElementSibling(&self) -> Option<DomRoot<Element>> {
|
||||
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::FrameType;
|
||||
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::serviceworker::ServiceWorker;
|
||||
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()),
|
||||
window,
|
||||
Wrap)
|
||||
|
@ -45,7 +45,7 @@ impl Client {
|
|||
self.url.clone()
|
||||
}
|
||||
|
||||
pub fn get_controller(&self) -> Option<Root<ServiceWorker>> {
|
||||
pub fn get_controller(&self) -> Option<DomRoot<ServiceWorker>> {
|
||||
self.active_worker.get()
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
|||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
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()),
|
||||
global,
|
||||
CloseEventBinding::Wrap)
|
||||
|
@ -46,7 +46,7 @@ impl CloseEvent {
|
|||
wasClean: bool,
|
||||
code: u16,
|
||||
reason: DOMString)
|
||||
-> Root<CloseEvent> {
|
||||
-> DomRoot<CloseEvent> {
|
||||
let event = box CloseEvent::new_inherited(wasClean, code, reason);
|
||||
let ev = reflect_dom_object(event, global, CloseEventBinding::Wrap);
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ impl CloseEvent {
|
|||
pub fn Constructor(global: &GlobalScope,
|
||||
type_: DOMString,
|
||||
init: &CloseEventBinding::CloseEventInit)
|
||||
-> Fallible<Root<CloseEvent>> {
|
||||
-> Fallible<DomRoot<CloseEvent>> {
|
||||
let bubbles = EventBubbles::from(init.parent.bubbles);
|
||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||
Ok(CloseEvent::new(global,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use dom::bindings::codegen::Bindings::CommentBinding;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::characterdata::CharacterData;
|
||||
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),
|
||||
document,
|
||||
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();
|
||||
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::error::Fallible;
|
||||
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::uievent::UIEvent;
|
||||
use dom::window::Window;
|
||||
|
@ -25,7 +25,7 @@ impl CompositionEvent {
|
|||
cancelable: bool,
|
||||
view: Option<&Window>,
|
||||
detail: i32,
|
||||
data: DOMString) -> Root<CompositionEvent> {
|
||||
data: DOMString) -> DomRoot<CompositionEvent> {
|
||||
let ev = reflect_dom_object(box CompositionEvent {
|
||||
uievent: UIEvent::new_inherited(),
|
||||
data: data,
|
||||
|
@ -39,7 +39,7 @@ impl CompositionEvent {
|
|||
pub fn Constructor(window: &Window,
|
||||
type_: DOMString,
|
||||
init: &CompositionEventBinding::CompositionEventInit)
|
||||
-> Fallible<Root<CompositionEvent>> {
|
||||
-> Fallible<DomRoot<CompositionEvent>> {
|
||||
let event = CompositionEvent::new(window,
|
||||
type_,
|
||||
init.parent.parent.bubbles,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use dom::bindings::error::{report_pending_exception, throw_dom_exception};
|
||||
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::document::Document;
|
||||
use dom::element::{CustomElementCreationMode, CustomElementState, Element, ElementCreator};
|
||||
|
@ -87,17 +87,17 @@ use servo_config::prefs::PREFS;
|
|||
fn create_svg_element(name: QualName,
|
||||
prefix: Option<Prefix>,
|
||||
document: &Document)
|
||||
-> Root<Element> {
|
||||
-> DomRoot<Element> {
|
||||
assert!(name.ns == ns!(svg));
|
||||
|
||||
macro_rules! make(
|
||||
($ctor:ident) => ({
|
||||
let obj = $ctor::new(name.local, prefix, document);
|
||||
Root::upcast(obj)
|
||||
DomRoot::upcast(obj)
|
||||
});
|
||||
($ctor:ident, $($arg:expr),+) => ({
|
||||
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,
|
||||
creator: ElementCreator,
|
||||
mode: CustomElementCreationMode)
|
||||
-> Root<Element> {
|
||||
-> DomRoot<Element> {
|
||||
assert!(name.ns == ns!(html));
|
||||
|
||||
// Step 4
|
||||
|
@ -129,7 +129,7 @@ fn create_html_element(name: QualName,
|
|||
if definition.is_autonomous() {
|
||||
match mode {
|
||||
CustomElementCreationMode::Asynchronous => {
|
||||
let result = Root::upcast::<Element>(
|
||||
let result = DomRoot::upcast::<Element>(
|
||||
HTMLElement::new(name.local.clone(), prefix.clone(), document));
|
||||
result.set_custom_element_state(CustomElementState::Undefined);
|
||||
ScriptThread::enqueue_upgrade_reaction(&*result, definition);
|
||||
|
@ -155,7 +155,7 @@ fn create_html_element(name: QualName,
|
|||
}
|
||||
|
||||
// Step 6.1.2
|
||||
let element = Root::upcast::<Element>(
|
||||
let element = DomRoot::upcast::<Element>(
|
||||
HTMLUnknownElement::new(local_name, prefix, document));
|
||||
element.set_custom_element_state(CustomElementState::Failed);
|
||||
element
|
||||
|
@ -195,17 +195,17 @@ pub fn create_native_html_element(name: QualName,
|
|||
prefix: Option<Prefix>,
|
||||
document: &Document,
|
||||
creator: ElementCreator)
|
||||
-> Root<Element> {
|
||||
-> DomRoot<Element> {
|
||||
assert!(name.ns == ns!(html));
|
||||
|
||||
macro_rules! make(
|
||||
($ctor:ident) => ({
|
||||
let obj = $ctor::new(name.local, prefix, document);
|
||||
Root::upcast(obj)
|
||||
DomRoot::upcast(obj)
|
||||
});
|
||||
($ctor:ident, $($arg:expr),+) => ({
|
||||
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,
|
||||
creator: ElementCreator,
|
||||
mode: CustomElementCreationMode)
|
||||
-> Root<Element> {
|
||||
-> DomRoot<Element> {
|
||||
let prefix = name.prefix.clone();
|
||||
match name.ns {
|
||||
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::error::{Error, Fallible};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::CSSFontFaceRuleBinding;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
||||
use dom::cssstylesheet::CSSStyleSheet;
|
||||
|
@ -32,7 +32,7 @@ impl CSSFontFaceRule {
|
|||
|
||||
#[allow(unrooted_must_root)]
|
||||
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),
|
||||
window,
|
||||
CSSFontFaceRuleBinding::Wrap)
|
||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::CSSGroupingRuleBinding::CSSGroupingRuleMet
|
|||
use dom::bindings::error::{ErrorResult, Fallible};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::reflector::DomObject;
|
||||
use dom::bindings::root::{MutNullableDom, Root};
|
||||
use dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::cssrule::CSSRule;
|
||||
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();
|
||||
self.rulelist.or_init(|| CSSRuleList::new(self.global().as_window(),
|
||||
parent_stylesheet,
|
||||
|
@ -52,7 +52,7 @@ impl CSSGroupingRule {
|
|||
|
||||
impl CSSGroupingRuleMethods for CSSGroupingRule {
|
||||
// https://drafts.csswg.org/cssom/#dom-cssgroupingrule-cssrules
|
||||
fn CssRules(&self) -> Root<CSSRuleList> {
|
||||
fn CssRules(&self) -> DomRoot<CSSRuleList> {
|
||||
// XXXManishearth check origin clean flag
|
||||
self.rulelist()
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::CSSImportRuleBinding;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
||||
use dom::cssstylesheet::CSSStyleSheet;
|
||||
|
@ -34,7 +34,7 @@ impl CSSImportRule {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn new(window: &Window,
|
||||
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),
|
||||
window,
|
||||
CSSImportRuleBinding::Wrap)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use dom::bindings::codegen::Bindings::CSSKeyframeRuleBinding::{self, CSSKeyframeRuleMethods};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
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::cssrule::{CSSRule, SpecificCSSRule};
|
||||
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
|
||||
|
@ -36,7 +36,7 @@ impl CSSKeyframeRule {
|
|||
|
||||
#[allow(unrooted_must_root)]
|
||||
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),
|
||||
window,
|
||||
CSSKeyframeRuleBinding::Wrap)
|
||||
|
@ -45,7 +45,7 @@ impl CSSKeyframeRule {
|
|||
|
||||
impl CSSKeyframeRuleMethods for CSSKeyframeRule {
|
||||
// https://drafts.csswg.org/css-animations/#dom-csskeyframerule-style
|
||||
fn Style(&self) -> Root<CSSStyleDeclaration> {
|
||||
fn Style(&self) -> DomRoot<CSSStyleDeclaration> {
|
||||
self.style_decl.or_init(|| {
|
||||
let guard = self.cssrule.shared_lock().read();
|
||||
CSSStyleDeclaration::new(
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding::CSSKeyframesRuleM
|
|||
use dom::bindings::error::ErrorResult;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
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::csskeyframerule::CSSKeyframeRule;
|
||||
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
||||
|
@ -41,13 +41,13 @@ impl CSSKeyframesRule {
|
|||
|
||||
#[allow(unrooted_must_root)]
|
||||
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),
|
||||
window,
|
||||
CSSKeyframesRuleBinding::Wrap)
|
||||
}
|
||||
|
||||
fn rulelist(&self) -> Root<CSSRuleList> {
|
||||
fn rulelist(&self) -> DomRoot<CSSRuleList> {
|
||||
self.rulelist.or_init(|| {
|
||||
let parent_stylesheet = &self.upcast::<CSSRule>().parent_stylesheet();
|
||||
CSSRuleList::new(self.global().as_window(),
|
||||
|
@ -76,7 +76,7 @@ impl CSSKeyframesRule {
|
|||
|
||||
impl CSSKeyframesRuleMethods for CSSKeyframesRule {
|
||||
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-cssrules
|
||||
fn CssRules(&self) -> Root<CSSRuleList> {
|
||||
fn CssRules(&self) -> DomRoot<CSSRuleList> {
|
||||
self.rulelist()
|
||||
}
|
||||
|
||||
|
@ -104,10 +104,10 @@ impl CSSKeyframesRuleMethods for CSSKeyframesRule {
|
|||
}
|
||||
|
||||
// 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.rulelist().item(idx as u32)
|
||||
}).and_then(Root::downcast)
|
||||
}).and_then(DomRoot::downcast)
|
||||
}
|
||||
|
||||
// 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::WindowBinding::WindowBinding::WindowMethods;
|
||||
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::cssconditionrule::CSSConditionRule;
|
||||
use dom::cssrule::SpecificCSSRule;
|
||||
|
@ -44,13 +44,13 @@ impl CSSMediaRule {
|
|||
|
||||
#[allow(unrooted_must_root)]
|
||||
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),
|
||||
window,
|
||||
CSSMediaRuleBinding::Wrap)
|
||||
}
|
||||
|
||||
fn medialist(&self) -> Root<MediaList> {
|
||||
fn medialist(&self) -> DomRoot<MediaList> {
|
||||
self.medialist.or_init(|| {
|
||||
let guard = self.cssconditionrule.shared_lock().read();
|
||||
MediaList::new(self.global().as_window(),
|
||||
|
@ -108,7 +108,7 @@ impl SpecificCSSRule for CSSMediaRule {
|
|||
|
||||
impl CSSMediaRuleMethods for CSSMediaRule {
|
||||
// https://drafts.csswg.org/cssom/#dom-cssgroupingrule-media
|
||||
fn Media(&self) -> Root<MediaList> {
|
||||
fn Media(&self) -> DomRoot<MediaList> {
|
||||
self.medialist()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding;
|
||||
use dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding::CSSNamespaceRuleMethods;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
||||
use dom::cssstylesheet::CSSStyleSheet;
|
||||
|
@ -33,7 +33,7 @@ impl CSSNamespaceRule {
|
|||
|
||||
#[allow(unrooted_must_root)]
|
||||
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),
|
||||
window,
|
||||
CSSNamespaceRuleBinding::Wrap)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::reflector::Reflector;
|
||||
use dom::bindings::root::{Dom, Root};
|
||||
use dom::bindings::root::{Dom, DomRoot};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::cssfontfacerule::CSSFontFaceRule;
|
||||
use dom::cssimportrule::CSSImportRule;
|
||||
|
@ -72,19 +72,19 @@ impl CSSRule {
|
|||
// Given a StyleCssRule, create a new instance of a derived class of
|
||||
// CSSRule based on which rule it is
|
||||
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
|
||||
match rule {
|
||||
StyleCssRule::Import(s) => Root::upcast(CSSImportRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::Style(s) => Root::upcast(CSSStyleRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::FontFace(s) => Root::upcast(CSSFontFaceRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::Import(s) => DomRoot::upcast(CSSImportRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::Style(s) => DomRoot::upcast(CSSStyleRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::FontFace(s) => DomRoot::upcast(CSSFontFaceRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::FontFeatureValues(_) => unimplemented!(),
|
||||
StyleCssRule::CounterStyle(_) => unimplemented!(),
|
||||
StyleCssRule::Keyframes(s) => Root::upcast(CSSKeyframesRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::Media(s) => Root::upcast(CSSMediaRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::Namespace(s) => Root::upcast(CSSNamespaceRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::Viewport(s) => Root::upcast(CSSViewportRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::Supports(s) => Root::upcast(CSSSupportsRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::Keyframes(s) => DomRoot::upcast(CSSKeyframesRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::Media(s) => DomRoot::upcast(CSSMediaRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::Namespace(s) => DomRoot::upcast(CSSNamespaceRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::Viewport(s) => DomRoot::upcast(CSSViewportRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::Supports(s) => DomRoot::upcast(CSSSupportsRule::new(window, parent_stylesheet, s)),
|
||||
StyleCssRule::Page(_) => unreachable!(),
|
||||
StyleCssRule::Document(_) => unimplemented!(), // TODO
|
||||
}
|
||||
|
@ -121,11 +121,11 @@ impl CSSRuleMethods for CSSRule {
|
|||
}
|
||||
|
||||
// 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() {
|
||||
None
|
||||
} 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::error::{Error, ErrorResult, Fallible};
|
||||
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::cssrule::CSSRule;
|
||||
use dom::cssstylesheet::CSSStyleSheet;
|
||||
|
@ -70,7 +70,7 @@ impl CSSRuleList {
|
|||
|
||||
#[allow(unrooted_must_root)]
|
||||
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),
|
||||
window,
|
||||
CSSRuleListBinding::Wrap)
|
||||
|
@ -133,11 +133,11 @@ impl CSSRuleList {
|
|||
// Remove parent stylesheets from all children
|
||||
pub fn deparent_all(&self) {
|
||||
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| {
|
||||
rule.or_init(|| {
|
||||
let parent_stylesheet = &self.parent_stylesheet;
|
||||
|
@ -149,7 +149,7 @@ impl CSSRuleList {
|
|||
rules.read_with(&guard).0[idx as usize].clone())
|
||||
}
|
||||
RulesSource::Keyframes(ref rules) => {
|
||||
Root::upcast(CSSKeyframeRule::new(self.global().as_window(),
|
||||
DomRoot::upcast(CSSKeyframeRule::new(self.global().as_window(),
|
||||
parent_stylesheet,
|
||||
rules.read_with(&guard)
|
||||
.keyframes[idx as usize]
|
||||
|
@ -176,7 +176,7 @@ impl CSSRuleList {
|
|||
|
||||
impl CSSRuleListMethods for CSSRuleList {
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ impl CSSRuleListMethods for CSSRuleList {
|
|||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
|||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
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::cssrule::CSSRule;
|
||||
use dom::element::Element;
|
||||
|
@ -137,10 +137,10 @@ impl CSSStyleOwner {
|
|||
}
|
||||
}
|
||||
|
||||
fn window(&self) -> Root<Window> {
|
||||
fn window(&self) -> DomRoot<Window> {
|
||||
match *self {
|
||||
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,
|
||||
pseudo: Option<PseudoElement>,
|
||||
modification_access: CSSModificationAccess)
|
||||
-> Root<CSSStyleDeclaration> {
|
||||
-> DomRoot<CSSStyleDeclaration> {
|
||||
reflect_dom_object(box CSSStyleDeclaration::new_inherited(owner,
|
||||
pseudo,
|
||||
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::inheritance::Castable;
|
||||
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::cssrule::{CSSRule, SpecificCSSRule};
|
||||
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
|
||||
|
@ -42,7 +42,7 @@ impl CSSStyleRule {
|
|||
|
||||
#[allow(unrooted_must_root)]
|
||||
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),
|
||||
window,
|
||||
CSSStyleRuleBinding::Wrap)
|
||||
|
@ -63,7 +63,7 @@ impl SpecificCSSRule for CSSStyleRule {
|
|||
|
||||
impl CSSStyleRuleMethods for CSSStyleRule {
|
||||
// https://drafts.csswg.org/cssom/#dom-cssstylerule-style
|
||||
fn Style(&self) -> Root<CSSStyleDeclaration> {
|
||||
fn Style(&self) -> DomRoot<CSSStyleDeclaration> {
|
||||
self.style_decl.or_init(|| {
|
||||
let guard = self.cssrule.shared_lock().read();
|
||||
CSSStyleDeclaration::new(
|
||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::CSSStyleSheetBinding::CSSStyleSheetMethods
|
|||
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
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::cssrulelist::{CSSRuleList, RulesSource};
|
||||
use dom::element::Element;
|
||||
|
@ -50,13 +50,13 @@ impl CSSStyleSheet {
|
|||
type_: DOMString,
|
||||
href: 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),
|
||||
window,
|
||||
CSSStyleSheetBinding::Wrap)
|
||||
}
|
||||
|
||||
fn rulelist(&self) -> Root<CSSRuleList> {
|
||||
fn rulelist(&self) -> DomRoot<CSSRuleList> {
|
||||
self.rulelist.or_init(|| {
|
||||
let rules = self.style_stylesheet.contents.rules.clone();
|
||||
CSSRuleList::new(
|
||||
|
@ -92,7 +92,7 @@ impl CSSStyleSheet {
|
|||
|
||||
impl CSSStyleSheetMethods for CSSStyleSheet {
|
||||
// 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() {
|
||||
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::reflector::Reflector;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::globalscope::GlobalScope;
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use cssparser::{Parser, ParserInput};
|
|||
use dom::bindings::codegen::Bindings::CSSSupportsRuleBinding;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
||||
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::cssconditionrule::CSSConditionRule;
|
||||
use dom::cssrule::SpecificCSSRule;
|
||||
|
@ -40,7 +40,7 @@ impl CSSSupportsRule {
|
|||
|
||||
#[allow(unrooted_must_root)]
|
||||
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),
|
||||
window,
|
||||
CSSSupportsRuleBinding::Wrap)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::CSSViewportRuleBinding;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::cssrule::{CSSRule, SpecificCSSRule};
|
||||
use dom::cssstylesheet::CSSStyleSheet;
|
||||
|
@ -31,7 +31,7 @@ impl CSSViewportRule {
|
|||
|
||||
#[allow(unrooted_must_root)]
|
||||
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),
|
||||
window,
|
||||
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::inheritance::Castable;
|
||||
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::document::Document;
|
||||
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),
|
||||
window,
|
||||
CustomElementRegistryBinding::Wrap)
|
||||
|
@ -304,7 +304,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
|
|||
let document = self.window.Document();
|
||||
|
||||
// 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();
|
||||
if *candidate.local_name() == local_name &&
|
||||
*candidate.namespace() == ns!(html) &&
|
||||
|
@ -386,7 +386,7 @@ pub struct LifecycleCallbacks {
|
|||
|
||||
#[derive(Clone, HeapSizeOf, JSTraceable)]
|
||||
pub enum ConstructionStackEntry {
|
||||
Element(Root<Element>),
|
||||
Element(DomRoot<Element>),
|
||||
AlreadyConstructedMarker,
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,7 @@ impl CustomElementDefinition {
|
|||
|
||||
/// https://dom.spec.whatwg.org/#concept-create-element Step 6.1
|
||||
#[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 cx = window.get_cx();
|
||||
// Step 2
|
||||
|
@ -447,7 +447,7 @@ impl CustomElementDefinition {
|
|||
}
|
||||
|
||||
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::Failure(..)) =>
|
||||
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
|
||||
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
|
||||
let result = run_upgrade_constructor(&definition.constructor, element);
|
||||
|
@ -612,7 +612,7 @@ impl CustomElementReaction {
|
|||
pub enum CallbackReaction {
|
||||
Connected,
|
||||
Disconnected,
|
||||
Adopted(Root<Document>, Root<Document>),
|
||||
Adopted(DomRoot<Document>, DomRoot<Document>),
|
||||
AttributeChanged(LocalName, Option<DOMString>, Option<DOMString>, Namespace),
|
||||
}
|
||||
|
||||
|
@ -795,8 +795,8 @@ impl ElementQueue {
|
|||
self.queue.borrow_mut().clear();
|
||||
}
|
||||
|
||||
fn next_element(&self) -> Option<Root<Element>> {
|
||||
self.queue.borrow_mut().pop_front().as_ref().map(Dom::deref).map(Root::from_ref)
|
||||
fn next_element(&self) -> Option<DomRoot<Element>> {
|
||||
self.queue.borrow_mut().pop_front().as_ref().map(Dom::deref).map(DomRoot::from_ref)
|
||||
}
|
||||
|
||||
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::inheritance::Castable;
|
||||
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::trace::RootedTraceableBox;
|
||||
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(),
|
||||
global,
|
||||
CustomEventBinding::Wrap)
|
||||
|
@ -44,7 +44,7 @@ impl CustomEvent {
|
|||
bubbles: bool,
|
||||
cancelable: bool,
|
||||
detail: HandleValue)
|
||||
-> Root<CustomEvent> {
|
||||
-> DomRoot<CustomEvent> {
|
||||
let ev = CustomEvent::new_uninitialized(global);
|
||||
ev.init_custom_event(type_, bubbles, cancelable, detail);
|
||||
ev
|
||||
|
@ -54,7 +54,7 @@ impl CustomEvent {
|
|||
pub fn Constructor(global: &GlobalScope,
|
||||
type_: DOMString,
|
||||
init: RootedTraceableBox<CustomEventBinding::CustomEventInit>)
|
||||
-> Fallible<Root<CustomEvent>> {
|
||||
-> Fallible<DomRoot<CustomEvent>> {
|
||||
Ok(CustomEvent::new(global,
|
||||
Atom::from(type_),
|
||||
init.parent.bubbles,
|
||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding::Dedicat
|
|||
use dom::bindings::error::{ErrorInfo, ErrorResult};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
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::structuredclone::StructuredCloneData;
|
||||
use dom::errorevent::ErrorEvent;
|
||||
|
@ -131,7 +131,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
timer_event_chan: IpcSender<TimerEvent>,
|
||||
timer_event_port: Receiver<(TrustedWorkerAddress, TimerEvent)>,
|
||||
closing: Arc<AtomicBool>)
|
||||
-> Root<DedicatedWorkerGlobalScope> {
|
||||
-> DomRoot<DedicatedWorkerGlobalScope> {
|
||||
let cx = runtime.cx();
|
||||
let scope = box DedicatedWorkerGlobalScope::new_inherited(init,
|
||||
worker_url,
|
||||
|
@ -387,7 +387,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool {
|
||||
let worker =
|
||||
Root::downcast::<WorkerGlobalScope>(GlobalScope::from_context(cx))
|
||||
DomRoot::downcast::<WorkerGlobalScope>(GlobalScope::from_context(cx))
|
||||
.expect("global is not a worker scope");
|
||||
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::reflector::Reflector;
|
||||
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::USVString;
|
||||
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),
|
||||
window,
|
||||
DissimilarOriginLocationBinding::Wrap)
|
||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding;
|
|||
use dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding::DissimilarOriginWindowMethods;
|
||||
use dom::bindings::error::{Error, ErrorResult};
|
||||
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::structuredclone::StructuredCloneData;
|
||||
use dom::dissimilaroriginlocation::DissimilarOriginLocation;
|
||||
|
@ -48,7 +48,7 @@ impl DissimilarOriginWindow {
|
|||
pub fn new(
|
||||
global_to_clone_from: &GlobalScope,
|
||||
window_proxy: &WindowProxy,
|
||||
) -> Root<Self> {
|
||||
) -> DomRoot<Self> {
|
||||
let cx = global_to_clone_from.get_cx();
|
||||
// Any timer events fired on this window are ignored.
|
||||
let (timer_event_chan, _) = ipc::channel().unwrap();
|
||||
|
@ -80,42 +80,42 @@ impl DissimilarOriginWindow {
|
|||
|
||||
impl DissimilarOriginWindowMethods for DissimilarOriginWindow {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-window
|
||||
fn Window(&self) -> Root<WindowProxy> {
|
||||
Root::from_ref(&*self.window_proxy)
|
||||
fn Window(&self) -> DomRoot<WindowProxy> {
|
||||
DomRoot::from_ref(&*self.window_proxy)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-self
|
||||
fn Self_(&self) -> Root<WindowProxy> {
|
||||
Root::from_ref(&*self.window_proxy)
|
||||
fn Self_(&self) -> DomRoot<WindowProxy> {
|
||||
DomRoot::from_ref(&*self.window_proxy)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-frames
|
||||
fn Frames(&self) -> Root<WindowProxy> {
|
||||
Root::from_ref(&*self.window_proxy)
|
||||
fn Frames(&self) -> DomRoot<WindowProxy> {
|
||||
DomRoot::from_ref(&*self.window_proxy)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-parent
|
||||
fn GetParent(&self) -> Option<Root<WindowProxy>> {
|
||||
fn GetParent(&self) -> Option<DomRoot<WindowProxy>> {
|
||||
// Steps 1-3.
|
||||
if self.window_proxy.is_browsing_context_discarded() {
|
||||
return None;
|
||||
}
|
||||
// Step 4.
|
||||
if let Some(parent) = self.window_proxy.parent() {
|
||||
return Some(Root::from_ref(parent));
|
||||
return Some(DomRoot::from_ref(parent));
|
||||
}
|
||||
// Step 5.
|
||||
Some(Root::from_ref(&*self.window_proxy))
|
||||
Some(DomRoot::from_ref(&*self.window_proxy))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-top
|
||||
fn GetTop(&self) -> Option<Root<WindowProxy>> {
|
||||
fn GetTop(&self) -> Option<DomRoot<WindowProxy>> {
|
||||
// Steps 1-3.
|
||||
if self.window_proxy.is_browsing_context_discarded() {
|
||||
return None;
|
||||
}
|
||||
// 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
|
||||
|
@ -184,7 +184,7 @@ impl DissimilarOriginWindowMethods for DissimilarOriginWindow {
|
|||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, Nod
|
|||
use dom::bindings::num::Finite;
|
||||
use dom::bindings::refcounted::{Trusted, TrustedPromise};
|
||||
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::xmlname::{namespace_from_domstring, validate_and_extract, xml_name_type};
|
||||
use dom::bindings::xmlname::XMLName::InvalidXMLName;
|
||||
|
@ -423,7 +423,7 @@ impl Document {
|
|||
|
||||
/// https://html.spec.whatwg.org/multipage/#concept-document-bc
|
||||
#[inline]
|
||||
pub fn browsing_context(&self) -> Option<Root<WindowProxy>> {
|
||||
pub fn browsing_context(&self) -> Option<DomRoot<WindowProxy>> {
|
||||
if self.has_browsing_context {
|
||||
self.window.undiscarded_window_proxy()
|
||||
} else {
|
||||
|
@ -523,7 +523,7 @@ impl Document {
|
|||
}
|
||||
|
||||
/// 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()
|
||||
}
|
||||
|
||||
|
@ -532,7 +532,7 @@ impl Document {
|
|||
pub fn refresh_base_element(&self) {
|
||||
let base = self.upcast::<Node>()
|
||||
.traverse_preorder()
|
||||
.filter_map(Root::downcast::<HTMLBaseElement>)
|
||||
.filter_map(DomRoot::downcast::<HTMLBaseElement>)
|
||||
.find(|element| element.upcast::<Element>().has_attribute(&local_name!("href")));
|
||||
self.base_element.set(base.r());
|
||||
}
|
||||
|
@ -674,7 +674,7 @@ impl Document {
|
|||
|
||||
/// Attempt to find a named element in this page's 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 2: Simply use None to indicate the top of the document.
|
||||
// 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 elem = node.upcast::<Element>();
|
||||
elem.get_attribute(&ns!(), &local_name!("name"))
|
||||
|
@ -738,9 +738,9 @@ impl Document {
|
|||
};
|
||||
let doc_node = self.upcast::<Node>();
|
||||
doc_node.traverse_preorder()
|
||||
.filter_map(Root::downcast)
|
||||
.filter_map(DomRoot::downcast)
|
||||
.find(|node| check_anchor(&node))
|
||||
.map(Root::upcast)
|
||||
.map(DomRoot::upcast)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#current-document-readiness
|
||||
|
@ -771,7 +771,7 @@ impl Document {
|
|||
|
||||
/// Return the element that currently has 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()
|
||||
}
|
||||
|
||||
|
@ -863,10 +863,10 @@ impl Document {
|
|||
};
|
||||
|
||||
let el = match node.downcast::<Element>() {
|
||||
Some(el) => Root::from_ref(el),
|
||||
Some(el) => DomRoot::from_ref(el),
|
||||
None => {
|
||||
let parent = node.GetParentNode();
|
||||
match parent.and_then(Root::downcast::<Element>) {
|
||||
match parent.and_then(DomRoot::downcast::<Element>) {
|
||||
Some(parent) => parent,
|
||||
None => return,
|
||||
}
|
||||
|
@ -1018,10 +1018,10 @@ impl Document {
|
|||
};
|
||||
|
||||
let el = match node.downcast::<Element>() {
|
||||
Some(el) => Root::from_ref(el),
|
||||
Some(el) => DomRoot::from_ref(el),
|
||||
None => {
|
||||
let parent = node.GetParentNode();
|
||||
match parent.and_then(Root::downcast::<Element>) {
|
||||
match parent.and_then(DomRoot::downcast::<Element>) {
|
||||
Some(parent) => parent,
|
||||
None => return
|
||||
}
|
||||
|
@ -1126,7 +1126,7 @@ impl Document {
|
|||
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) };
|
||||
node.inclusive_ancestors()
|
||||
.filter_map(Root::downcast::<Element>)
|
||||
.filter_map(DomRoot::downcast::<Element>)
|
||||
.next()
|
||||
});
|
||||
|
||||
|
@ -1169,7 +1169,7 @@ impl Document {
|
|||
if !old_target_is_ancestor_of_new_target {
|
||||
for element in old_target.upcast::<Node>()
|
||||
.inclusive_ancestors()
|
||||
.filter_map(Root::downcast::<Element>) {
|
||||
.filter_map(DomRoot::downcast::<Element>) {
|
||||
element.set_hover_state(false);
|
||||
element.set_active_state(false);
|
||||
}
|
||||
|
@ -1185,7 +1185,7 @@ impl Document {
|
|||
if let Some(ref new_target) = maybe_new_target {
|
||||
for element in new_target.upcast::<Node>()
|
||||
.inclusive_ancestors()
|
||||
.filter_map(Root::downcast::<Element>) {
|
||||
.filter_map(DomRoot::downcast::<Element>) {
|
||||
if element.hover_state() {
|
||||
break;
|
||||
}
|
||||
|
@ -1229,10 +1229,10 @@ impl Document {
|
|||
None => return TouchEventResult::Processed(false),
|
||||
};
|
||||
let el = match node.downcast::<Element>() {
|
||||
Some(el) => Root::from_ref(el),
|
||||
Some(el) => DomRoot::from_ref(el),
|
||||
None => {
|
||||
let parent = node.GetParentNode();
|
||||
match parent.and_then(Root::downcast::<Element>) {
|
||||
match parent.and_then(DomRoot::downcast::<Element>) {
|
||||
Some(parent) => parent,
|
||||
None => return TouchEventResult::Processed(false),
|
||||
}
|
||||
|
@ -1253,7 +1253,7 @@ impl Document {
|
|||
return TouchEventResult::Forwarded;
|
||||
}
|
||||
|
||||
let target = Root::upcast::<EventTarget>(el);
|
||||
let target = DomRoot::upcast::<EventTarget>(el);
|
||||
let window = &*self.window;
|
||||
|
||||
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
|
||||
pub fn node_from_nodes_and_strings(&self,
|
||||
mut nodes: Vec<NodeOrString>)
|
||||
-> Fallible<Root<Node>> {
|
||||
-> Fallible<DomRoot<Node>> {
|
||||
if nodes.len() == 1 {
|
||||
Ok(match nodes.pop().unwrap() {
|
||||
NodeOrString::Node(node) => node,
|
||||
NodeOrString::String(string) => Root::upcast(self.CreateTextNode(string)),
|
||||
NodeOrString::String(string) => DomRoot::upcast(self.CreateTextNode(string)),
|
||||
})
|
||||
} else {
|
||||
let fragment = Root::upcast::<Node>(self.CreateDocumentFragment());
|
||||
let fragment = DomRoot::upcast::<Node>(self.CreateDocumentFragment());
|
||||
for node in nodes {
|
||||
match node {
|
||||
NodeOrString::Node(node) => {
|
||||
fragment.AppendChild(&node)?;
|
||||
},
|
||||
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
|
||||
// should not fail.
|
||||
fragment.AppendChild(&node).unwrap();
|
||||
|
@ -1481,7 +1481,7 @@ impl Document {
|
|||
}
|
||||
|
||||
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) => {
|
||||
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) {
|
||||
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 value = body.parse_attribute(&ns!(), &local_name, value);
|
||||
body.set_attribute(local_name, value);
|
||||
|
@ -1948,19 +1948,19 @@ impl Document {
|
|||
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()
|
||||
}
|
||||
|
||||
/// 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>()
|
||||
.traverse_preorder()
|
||||
.filter_map(Root::downcast::<HTMLIFrameElement>)
|
||||
.filter_map(DomRoot::downcast::<HTMLIFrameElement>)
|
||||
}
|
||||
|
||||
/// 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()
|
||||
.find(|node| node.browsing_context_id() == Some(browsing_context_id))
|
||||
}
|
||||
|
@ -1968,7 +1968,7 @@ impl Document {
|
|||
/// Find a mozbrowser iframe element in the document.
|
||||
pub fn find_mozbrowser_iframe(&self,
|
||||
top_level_browsing_context_id: TopLevelBrowsingContextId)
|
||||
-> Option<Root<HTMLIFrameElement>>
|
||||
-> Option<DomRoot<HTMLIFrameElement>>
|
||||
{
|
||||
match self.find_iframe(BrowsingContextId::from(top_level_browsing_context_id)) {
|
||||
None => None,
|
||||
|
@ -2310,7 +2310,7 @@ impl 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 docloader = DocumentLoader::new(&*doc.loader());
|
||||
Ok(Document::new(window,
|
||||
|
@ -2339,7 +2339,7 @@ impl Document {
|
|||
doc_loader: DocumentLoader,
|
||||
referrer: Option<String>,
|
||||
referrer_policy: Option<ReferrerPolicy>)
|
||||
-> Root<Document> {
|
||||
-> DomRoot<Document> {
|
||||
let document = reflect_dom_object(box Document::new_inherited(window,
|
||||
has_browsing_context,
|
||||
url,
|
||||
|
@ -2361,7 +2361,7 @@ impl 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 maybe_node = doc.r().map(Castable::upcast::<Node>);
|
||||
let iter = maybe_node.iter()
|
||||
|
@ -2370,8 +2370,8 @@ impl Document {
|
|||
NodeList::new_simple_list(&self.window, iter)
|
||||
}
|
||||
|
||||
fn get_html_element(&self) -> Option<Root<HTMLHtmlElement>> {
|
||||
self.GetDocumentElement().and_then(Root::downcast)
|
||||
fn get_html_element(&self) -> Option<DomRoot<HTMLHtmlElement>> {
|
||||
self.GetDocumentElement().and_then(DomRoot::downcast)
|
||||
}
|
||||
|
||||
/// Return a reference to the per-document shared lock used in stylesheets.
|
||||
|
@ -2482,7 +2482,7 @@ impl Document {
|
|||
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();
|
||||
|
||||
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
|
||||
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(|| {
|
||||
let doctype = if self.is_html_document {
|
||||
IsHTMLDocument::HTMLDocument
|
||||
|
@ -2516,8 +2516,8 @@ impl Document {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn get_element_by_id(&self, id: &Atom) -> Option<Root<Element>> {
|
||||
self.id_map.borrow().get(&id).map(|ref elements| Root::from_ref(&*(*elements)[0]))
|
||||
pub fn get_element_by_id(&self, id: &Atom) -> Option<DomRoot<Element>> {
|
||||
self.id_map.borrow().get(&id).map(|ref elements| DomRoot::from_ref(&*(*elements)[0]))
|
||||
}
|
||||
|
||||
pub fn ensure_pending_restyle(&self, el: &Element) -> RefMut<PendingRestyle> {
|
||||
|
@ -2747,12 +2747,12 @@ impl Element {
|
|||
|
||||
impl DocumentMethods for Document {
|
||||
// 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)))
|
||||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
|
||||
|
@ -2762,13 +2762,13 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-activeelement
|
||||
fn GetActiveElement(&self) -> Option<Root<Element>> {
|
||||
fn GetActiveElement(&self) -> Option<DomRoot<Element>> {
|
||||
// TODO: Step 2.
|
||||
|
||||
match self.get_focused_element() {
|
||||
Some(element) => Some(element), // Step 3. and 4.
|
||||
None => match self.GetBody() { // Step 5.
|
||||
Some(body) => Some(Root::upcast(body)),
|
||||
Some(body) => Some(DomRoot::upcast(body)),
|
||||
None => self.GetDocumentElement(),
|
||||
},
|
||||
}
|
||||
|
@ -2899,20 +2899,20 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-doctype
|
||||
fn GetDoctype(&self) -> Option<Root<DocumentType>> {
|
||||
self.upcast::<Node>().children().filter_map(Root::downcast).next()
|
||||
fn GetDoctype(&self) -> Option<DomRoot<DocumentType>> {
|
||||
self.upcast::<Node>().children().filter_map(DomRoot::downcast).next()
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
|
||||
// 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);
|
||||
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) => {
|
||||
let result = HTMLCollection::by_qualified_name(
|
||||
&self.window, self.upcast(), qualified_name);
|
||||
|
@ -2926,12 +2926,12 @@ impl DocumentMethods for Document {
|
|||
fn GetElementsByTagNameNS(&self,
|
||||
maybe_ns: Option<DOMString>,
|
||||
tag_name: DOMString)
|
||||
-> Root<HTMLCollection> {
|
||||
-> DomRoot<HTMLCollection> {
|
||||
let ns = namespace_from_domstring(maybe_ns);
|
||||
let local = LocalName::from(tag_name);
|
||||
let qname = QualName::new(None, ns, local);
|
||||
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) => {
|
||||
let result = HTMLCollection::by_qual_tag_name(&self.window, self.upcast(), qname);
|
||||
entry.insert(Dom::from_ref(&*result));
|
||||
|
@ -2941,12 +2941,12 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// 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)
|
||||
.map(Atom::from)
|
||||
.collect();
|
||||
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) => {
|
||||
let result = HTMLCollection::by_atomic_class_name(&self.window,
|
||||
self.upcast(),
|
||||
|
@ -2958,7 +2958,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
|
||||
|
@ -2966,7 +2966,7 @@ impl DocumentMethods for Document {
|
|||
fn CreateElement(&self,
|
||||
mut local_name: DOMString,
|
||||
options: &ElementCreationOptions)
|
||||
-> Fallible<Root<Element>> {
|
||||
-> Fallible<DomRoot<Element>> {
|
||||
if xml_name_type(&local_name) == InvalidXMLName {
|
||||
debug!("Not a valid element name");
|
||||
return Err(Error::InvalidCharacter);
|
||||
|
@ -2991,7 +2991,7 @@ impl DocumentMethods for Document {
|
|||
namespace: Option<DOMString>,
|
||||
qualified_name: DOMString,
|
||||
options: &ElementCreationOptions)
|
||||
-> Fallible<Root<Element>> {
|
||||
-> Fallible<DomRoot<Element>> {
|
||||
let (namespace, prefix, local_name) = validate_and_extract(namespace,
|
||||
&qualified_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
|
||||
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 {
|
||||
debug!("Not a valid element name");
|
||||
return Err(Error::InvalidCharacter);
|
||||
|
@ -3018,7 +3018,7 @@ impl DocumentMethods for Document {
|
|||
fn CreateAttributeNS(&self,
|
||||
namespace: Option<DOMString>,
|
||||
qualified_name: DOMString)
|
||||
-> Fallible<Root<Attr>> {
|
||||
-> Fallible<DomRoot<Attr>> {
|
||||
let (namespace, prefix, local_name) = validate_and_extract(namespace,
|
||||
&qualified_name)?;
|
||||
let value = AttrValue::String("".to_owned());
|
||||
|
@ -3033,17 +3033,17 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-createdocumentfragment
|
||||
fn CreateDocumentFragment(&self) -> Root<DocumentFragment> {
|
||||
fn CreateDocumentFragment(&self) -> DomRoot<DocumentFragment> {
|
||||
DocumentFragment::new(self)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
@ -3051,7 +3051,7 @@ impl DocumentMethods for Document {
|
|||
fn CreateProcessingInstruction(&self,
|
||||
target: DOMString,
|
||||
data: DOMString)
|
||||
-> Fallible<Root<ProcessingInstruction>> {
|
||||
-> Fallible<DomRoot<ProcessingInstruction>> {
|
||||
// Step 1.
|
||||
if xml_name_type(&target) == InvalidXMLName {
|
||||
return Err(Error::InvalidCharacter);
|
||||
|
@ -3067,7 +3067,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// 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.
|
||||
if node.is::<Document>() {
|
||||
return Err(Error::NotSupported);
|
||||
|
@ -3084,7 +3084,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// 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.
|
||||
if node.is::<Document>() {
|
||||
return Err(Error::NotSupported);
|
||||
|
@ -3094,44 +3094,44 @@ impl DocumentMethods for Document {
|
|||
Node::adopt(node, self);
|
||||
|
||||
// Step 3.
|
||||
Ok(Root::from_ref(node))
|
||||
Ok(DomRoot::from_ref(node))
|
||||
}
|
||||
|
||||
// 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();
|
||||
match &*interface {
|
||||
"beforeunloadevent" =>
|
||||
Ok(Root::upcast(BeforeUnloadEvent::new_uninitialized(&self.window))),
|
||||
Ok(DomRoot::upcast(BeforeUnloadEvent::new_uninitialized(&self.window))),
|
||||
"closeevent" =>
|
||||
Ok(Root::upcast(CloseEvent::new_uninitialized(self.window.upcast()))),
|
||||
Ok(DomRoot::upcast(CloseEvent::new_uninitialized(self.window.upcast()))),
|
||||
"customevent" =>
|
||||
Ok(Root::upcast(CustomEvent::new_uninitialized(self.window.upcast()))),
|
||||
Ok(DomRoot::upcast(CustomEvent::new_uninitialized(self.window.upcast()))),
|
||||
"errorevent" =>
|
||||
Ok(Root::upcast(ErrorEvent::new_uninitialized(self.window.upcast()))),
|
||||
Ok(DomRoot::upcast(ErrorEvent::new_uninitialized(self.window.upcast()))),
|
||||
"events" | "event" | "htmlevents" | "svgevents" =>
|
||||
Ok(Event::new_uninitialized(&self.window.upcast())),
|
||||
"focusevent" =>
|
||||
Ok(Root::upcast(FocusEvent::new_uninitialized(&self.window))),
|
||||
Ok(DomRoot::upcast(FocusEvent::new_uninitialized(&self.window))),
|
||||
"hashchangeevent" =>
|
||||
Ok(Root::upcast(HashChangeEvent::new_uninitialized(&self.window))),
|
||||
Ok(DomRoot::upcast(HashChangeEvent::new_uninitialized(&self.window))),
|
||||
"keyboardevent" =>
|
||||
Ok(Root::upcast(KeyboardEvent::new_uninitialized(&self.window))),
|
||||
Ok(DomRoot::upcast(KeyboardEvent::new_uninitialized(&self.window))),
|
||||
"messageevent" =>
|
||||
Ok(Root::upcast(MessageEvent::new_uninitialized(self.window.upcast()))),
|
||||
Ok(DomRoot::upcast(MessageEvent::new_uninitialized(self.window.upcast()))),
|
||||
"mouseevent" | "mouseevents" =>
|
||||
Ok(Root::upcast(MouseEvent::new_uninitialized(&self.window))),
|
||||
Ok(DomRoot::upcast(MouseEvent::new_uninitialized(&self.window))),
|
||||
"pagetransitionevent" =>
|
||||
Ok(Root::upcast(PageTransitionEvent::new_uninitialized(&self.window))),
|
||||
Ok(DomRoot::upcast(PageTransitionEvent::new_uninitialized(&self.window))),
|
||||
"popstateevent" =>
|
||||
Ok(Root::upcast(PopStateEvent::new_uninitialized(&self.window))),
|
||||
Ok(DomRoot::upcast(PopStateEvent::new_uninitialized(&self.window))),
|
||||
"progressevent" =>
|
||||
Ok(Root::upcast(ProgressEvent::new_uninitialized(self.window.upcast()))),
|
||||
Ok(DomRoot::upcast(ProgressEvent::new_uninitialized(self.window.upcast()))),
|
||||
"storageevent" => {
|
||||
Ok(Root::upcast(StorageEvent::new_uninitialized(&self.window, "".into())))
|
||||
Ok(DomRoot::upcast(StorageEvent::new_uninitialized(&self.window, "".into())))
|
||||
},
|
||||
"touchevent" =>
|
||||
Ok(Root::upcast(
|
||||
Ok(DomRoot::upcast(
|
||||
TouchEvent::new_uninitialized(&self.window,
|
||||
&TouchList::new(&self.window, &[]),
|
||||
&TouchList::new(&self.window, &[]),
|
||||
|
@ -3139,9 +3139,9 @@ impl DocumentMethods for Document {
|
|||
)
|
||||
)),
|
||||
"uievent" | "uievents" =>
|
||||
Ok(Root::upcast(UIEvent::new_uninitialized(&self.window))),
|
||||
Ok(DomRoot::upcast(UIEvent::new_uninitialized(&self.window))),
|
||||
"webglcontextevent" =>
|
||||
Ok(Root::upcast(WebGLContextEvent::new_uninitialized(&self.window))),
|
||||
Ok(DomRoot::upcast(WebGLContextEvent::new_uninitialized(&self.window))),
|
||||
_ =>
|
||||
Err(Error::NotSupported),
|
||||
}
|
||||
|
@ -3156,7 +3156,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-createrange
|
||||
fn CreateRange(&self) -> Root<Range> {
|
||||
fn CreateRange(&self) -> DomRoot<Range> {
|
||||
Range::new_with_doc(self)
|
||||
}
|
||||
|
||||
|
@ -3165,7 +3165,7 @@ impl DocumentMethods for Document {
|
|||
root: &Node,
|
||||
what_to_show: u32,
|
||||
filter: Option<Rc<NodeFilter>>)
|
||||
-> Root<NodeIterator> {
|
||||
-> DomRoot<NodeIterator> {
|
||||
NodeIterator::new(self, root, what_to_show, filter)
|
||||
}
|
||||
|
||||
|
@ -3178,7 +3178,7 @@ impl DocumentMethods for Document {
|
|||
page_y: Finite<f64>,
|
||||
screen_x: Finite<f64>,
|
||||
screen_y: Finite<f64>)
|
||||
-> Root<Touch> {
|
||||
-> DomRoot<Touch> {
|
||||
let client_x = Finite::wrap(*page_x - window.PageXOffset() as f64);
|
||||
let client_y = Finite::wrap(*page_y - window.PageYOffset() as f64);
|
||||
Touch::new(window,
|
||||
|
@ -3193,7 +3193,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
@ -3202,7 +3202,7 @@ impl DocumentMethods for Document {
|
|||
root: &Node,
|
||||
what_to_show: u32,
|
||||
filter: Option<Rc<NodeFilter>>)
|
||||
-> Root<TreeWalker> {
|
||||
-> DomRoot<TreeWalker> {
|
||||
TreeWalker::new(self, root, what_to_show, filter)
|
||||
}
|
||||
|
||||
|
@ -3216,7 +3216,7 @@ impl DocumentMethods for Document {
|
|||
.find(|node| {
|
||||
node.namespace() == &ns!(svg) && node.local_name() == &local_name!("title")
|
||||
})
|
||||
.map(Root::upcast::<Node>)
|
||||
.map(DomRoot::upcast::<Node>)
|
||||
} else {
|
||||
// Step 2.
|
||||
root.upcast::<Node>()
|
||||
|
@ -3247,7 +3247,7 @@ impl DocumentMethods for Document {
|
|||
node.namespace() == &ns!(svg) && node.local_name() == &local_name!("title")
|
||||
});
|
||||
match elem {
|
||||
Some(elem) => Root::upcast::<Node>(elem),
|
||||
Some(elem) => DomRoot::upcast::<Node>(elem),
|
||||
None => {
|
||||
let name = QualName::new(None, ns!(svg), local_name!("title"));
|
||||
let elem = Element::create(name,
|
||||
|
@ -3292,18 +3292,18 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// 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()
|
||||
.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
|
||||
fn GetCurrentScript(&self) -> Option<Root<HTMLScriptElement>> {
|
||||
fn GetCurrentScript(&self) -> Option<DomRoot<HTMLScriptElement>> {
|
||||
self.current_script.get()
|
||||
}
|
||||
|
||||
// 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| {
|
||||
let node = root.upcast::<Node>();
|
||||
node.children().find(|child| {
|
||||
|
@ -3312,7 +3312,7 @@ impl DocumentMethods for Document {
|
|||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFrameSetElement)) => true,
|
||||
_ => 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
|
||||
fn GetElementsByName(&self, name: DOMString) -> Root<NodeList> {
|
||||
fn GetElementsByName(&self, name: DOMString) -> DomRoot<NodeList> {
|
||||
self.create_node_list(|node| {
|
||||
let element = match node.downcast::<Element>() {
|
||||
Some(element) => element,
|
||||
|
@ -3372,7 +3372,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-images
|
||||
fn Images(&self) -> Root<HTMLCollection> {
|
||||
fn Images(&self) -> DomRoot<HTMLCollection> {
|
||||
self.images.or_init(|| {
|
||||
let filter = box ImagesFilter;
|
||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||
|
@ -3380,7 +3380,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-embeds
|
||||
fn Embeds(&self) -> Root<HTMLCollection> {
|
||||
fn Embeds(&self) -> DomRoot<HTMLCollection> {
|
||||
self.embeds.or_init(|| {
|
||||
let filter = box EmbedsFilter;
|
||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||
|
@ -3388,12 +3388,12 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-plugins
|
||||
fn Plugins(&self) -> Root<HTMLCollection> {
|
||||
fn Plugins(&self) -> DomRoot<HTMLCollection> {
|
||||
self.Embeds()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-links
|
||||
fn Links(&self) -> Root<HTMLCollection> {
|
||||
fn Links(&self) -> DomRoot<HTMLCollection> {
|
||||
self.links.or_init(|| {
|
||||
let filter = box LinksFilter;
|
||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||
|
@ -3401,7 +3401,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-forms
|
||||
fn Forms(&self) -> Root<HTMLCollection> {
|
||||
fn Forms(&self) -> DomRoot<HTMLCollection> {
|
||||
self.forms.or_init(|| {
|
||||
let filter = box FormsFilter;
|
||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||
|
@ -3409,7 +3409,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-scripts
|
||||
fn Scripts(&self) -> Root<HTMLCollection> {
|
||||
fn Scripts(&self) -> DomRoot<HTMLCollection> {
|
||||
self.scripts.or_init(|| {
|
||||
let filter = box ScriptsFilter;
|
||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||
|
@ -3417,7 +3417,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-anchors
|
||||
fn Anchors(&self) -> Root<HTMLCollection> {
|
||||
fn Anchors(&self) -> DomRoot<HTMLCollection> {
|
||||
self.anchors.or_init(|| {
|
||||
let filter = box AnchorsFilter;
|
||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||
|
@ -3425,7 +3425,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// 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.
|
||||
self.applets.or_init(|| {
|
||||
let filter = box AppletsFilter;
|
||||
|
@ -3434,7 +3434,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// 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() {
|
||||
Some(self.window.Location())
|
||||
} else {
|
||||
|
@ -3443,18 +3443,18 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
||||
fn Children(&self) -> Root<HTMLCollection> {
|
||||
fn Children(&self) -> DomRoot<HTMLCollection> {
|
||||
HTMLCollection::children(&self.window, self.upcast())
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
||||
fn GetLastElementChild(&self) -> Option<Root<Element>> {
|
||||
self.upcast::<Node>().rev_children().filter_map(Root::downcast).next()
|
||||
fn GetLastElementChild(&self) -> Option<DomRoot<Element>> {
|
||||
self.upcast::<Node>().rev_children().filter_map(DomRoot::downcast).next()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
||||
|
@ -3473,13 +3473,13 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// 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>();
|
||||
root.query_selector(selectors)
|
||||
}
|
||||
|
||||
// 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>();
|
||||
root.query_selector_all(selectors)
|
||||
}
|
||||
|
@ -3490,9 +3490,9 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// 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 {
|
||||
Some(Root::from_ref(&*self.window))
|
||||
Some(DomRoot::from_ref(&*self.window))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -3673,7 +3673,7 @@ impl DocumentMethods for Document {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
// 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 y = *y as f32;
|
||||
let point = &Point2D::new(x, y);
|
||||
|
@ -3700,7 +3700,7 @@ impl DocumentMethods for Document {
|
|||
parent_node.downcast::<Element>().unwrap()
|
||||
});
|
||||
|
||||
Some(Root::from_ref(element_ref))
|
||||
Some(DomRoot::from_ref(element_ref))
|
||||
},
|
||||
None => self.GetDocumentElement()
|
||||
}
|
||||
|
@ -3708,7 +3708,7 @@ impl DocumentMethods for Document {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
// 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 y = *y as f32;
|
||||
let point = &Point2D::new(x, y);
|
||||
|
@ -3727,12 +3727,12 @@ impl DocumentMethods for Document {
|
|||
let js_runtime = unsafe { JS_GetRuntime(window.get_cx()) };
|
||||
|
||||
// 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| {
|
||||
let node = unsafe {
|
||||
node::from_untrusted_node_address(js_runtime, untrusted_node_address)
|
||||
};
|
||||
Root::downcast::<Element>(node)
|
||||
DomRoot::downcast::<Element>(node)
|
||||
}).collect();
|
||||
|
||||
// Step 4
|
||||
|
@ -3747,7 +3747,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// 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() {
|
||||
// Step 1.
|
||||
return Err(Error::InvalidState);
|
||||
|
@ -3758,7 +3758,7 @@ impl DocumentMethods for Document {
|
|||
|
||||
if !self.is_active() {
|
||||
// Step 3.
|
||||
return Ok(Root::from_ref(self));
|
||||
return Ok(DomRoot::from_ref(self));
|
||||
}
|
||||
|
||||
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) {
|
||||
// Step 5.
|
||||
return Ok(Root::from_ref(self));
|
||||
return Ok(DomRoot::from_ref(self));
|
||||
}
|
||||
|
||||
// Step 6.
|
||||
|
@ -3889,7 +3889,7 @@ impl DocumentMethods for Document {
|
|||
// Step 34 is handled when creating the parser in step 25.
|
||||
|
||||
// Step 35.
|
||||
Ok(Root::from_ref(self))
|
||||
Ok(DomRoot::from_ref(self))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-write
|
||||
|
@ -3907,7 +3907,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
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;
|
||||
// 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.
|
||||
|
||||
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.
|
||||
return Ok(());
|
||||
|
@ -3983,7 +3983,7 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// https://fullscreen.spec.whatwg.org/#dom-document-fullscreenelement
|
||||
fn GetFullscreenElement(&self) -> Option<Root<Element>> {
|
||||
fn GetFullscreenElement(&self) -> Option<DomRoot<Element>> {
|
||||
// TODO ShadowRoot
|
||||
self.fullscreen_element.get()
|
||||
}
|
||||
|
@ -4099,7 +4099,7 @@ impl PendingInOrderScriptVec {
|
|||
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 pair = scripts.front_mut().and_then(PendingScript::take_result);
|
||||
if pair.is_none() {
|
||||
|
@ -4135,7 +4135,7 @@ impl PendingScript {
|
|||
self.load = Some(result);
|
||||
}
|
||||
|
||||
fn take_result(&mut self) -> Option<(Root<HTMLScriptElement>, ScriptResult)> {
|
||||
self.load.take().map(|result| (Root::from_ref(&*self.element), result))
|
||||
fn take_result(&mut self) -> Option<(DomRoot<HTMLScriptElement>, ScriptResult)> {
|
||||
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::error::{ErrorResult, Fallible};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::document::Document;
|
||||
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),
|
||||
document,
|
||||
DocumentFragmentBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn Constructor(window: &Window) -> Fallible<Root<DocumentFragment>> {
|
||||
pub fn Constructor(window: &Window) -> Fallible<DomRoot<DocumentFragment>> {
|
||||
let document = window.Document();
|
||||
|
||||
Ok(DocumentFragment::new(&document))
|
||||
|
@ -48,16 +48,16 @@ impl DocumentFragment {
|
|||
|
||||
impl DocumentFragmentMethods for DocumentFragment {
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
||||
fn Children(&self) -> Root<HTMLCollection> {
|
||||
fn Children(&self) -> DomRoot<HTMLCollection> {
|
||||
let window = window_from_node(self);
|
||||
HTMLCollection::children(&window, self.upcast())
|
||||
}
|
||||
|
||||
// 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 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")) {
|
||||
None => false,
|
||||
Some(attr) => *attr.value().as_atom() == id,
|
||||
|
@ -66,13 +66,13 @@ impl DocumentFragmentMethods for DocumentFragment {
|
|||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
||||
fn GetLastElementChild(&self) -> Option<Root<Element>> {
|
||||
self.upcast::<Node>().rev_children().filter_map(Root::downcast::<Element>).next()
|
||||
fn GetLastElementChild(&self) -> Option<DomRoot<Element>> {
|
||||
self.upcast::<Node>().rev_children().filter_map(DomRoot::downcast::<Element>).next()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
||||
|
@ -91,12 +91,12 @@ impl DocumentFragmentMethods for DocumentFragment {
|
|||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DocumentTypeBinding::DocumentTypeMethods;
|
|||
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
||||
use dom::bindings::error::ErrorResult;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::document::Document;
|
||||
use dom::node::Node;
|
||||
|
@ -41,7 +41,7 @@ impl DocumentType {
|
|||
public_id: Option<DOMString>,
|
||||
system_id: Option<DOMString>,
|
||||
document: &Document)
|
||||
-> Root<DocumentType> {
|
||||
-> DomRoot<DocumentType> {
|
||||
Node::reflect_node(box DocumentType::new_inherited(name, public_id, system_id, document),
|
||||
document,
|
||||
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::DOMExceptionMethods;
|
||||
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::globalscope::GlobalScope;
|
||||
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),
|
||||
global,
|
||||
DOMExceptionBinding::Wrap)
|
||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
|||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
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::xmlname::{namespace_from_domstring, validate_qualified_name};
|
||||
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();
|
||||
reflect_dom_object(box DOMImplementation::new_inherited(document),
|
||||
window,
|
||||
|
@ -56,7 +56,7 @@ impl DOMImplementationMethods for DOMImplementation {
|
|||
qualified_name: DOMString,
|
||||
pubid: DOMString,
|
||||
sysid: DOMString)
|
||||
-> Fallible<Root<DocumentType>> {
|
||||
-> Fallible<DomRoot<DocumentType>> {
|
||||
validate_qualified_name(&qualified_name)?;
|
||||
Ok(DocumentType::new(qualified_name, Some(pubid), Some(sysid), &self.document))
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ impl DOMImplementationMethods for DOMImplementation {
|
|||
maybe_namespace: Option<DOMString>,
|
||||
qname: DOMString,
|
||||
maybe_doctype: Option<&DocumentType>)
|
||||
-> Fallible<Root<XMLDocument>> {
|
||||
-> Fallible<DomRoot<XMLDocument>> {
|
||||
let win = self.document.window();
|
||||
let loader = DocumentLoader::new(&self.document.loader());
|
||||
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
|
||||
fn CreateHTMLDocument(&self, title: Option<DOMString>) -> Root<Document> {
|
||||
fn CreateHTMLDocument(&self, title: Option<DOMString>) -> DomRoot<Document> {
|
||||
let win = self.document.window();
|
||||
let loader = DocumentLoader::new(&self.document.loader());
|
||||
|
||||
|
@ -149,14 +149,14 @@ impl DOMImplementationMethods for DOMImplementation {
|
|||
{
|
||||
// Step 4.
|
||||
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,
|
||||
&doc));
|
||||
doc_node.AppendChild(&doc_html).expect("Appending failed");
|
||||
|
||||
{
|
||||
// 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,
|
||||
&doc));
|
||||
doc_html.AppendChild(&doc_head).unwrap();
|
||||
|
@ -165,7 +165,7 @@ impl DOMImplementationMethods for DOMImplementation {
|
|||
if let Some(title_str) = title {
|
||||
// Step 6.1.
|
||||
let doc_title =
|
||||
Root::upcast::<Node>(HTMLTitleElement::new(local_name!("title"),
|
||||
DomRoot::upcast::<Node>(HTMLTitleElement::new(local_name!("title"),
|
||||
None,
|
||||
&doc));
|
||||
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::inheritance::Castable;
|
||||
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::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
|
@ -21,7 +21,7 @@ pub struct DOMMatrix {
|
|||
|
||||
impl DOMMatrix {
|
||||
#[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);
|
||||
reflect_dom_object(box dommatrix, global, Wrap)
|
||||
}
|
||||
|
@ -33,12 +33,12 @@ impl 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])
|
||||
}
|
||||
|
||||
// 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[..])
|
||||
.map(|(is2D, matrix)| {
|
||||
Self::new(global, is2D, matrix)
|
||||
|
@ -46,14 +46,14 @@ impl DOMMatrix {
|
|||
}
|
||||
|
||||
// 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)
|
||||
.map(|(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())
|
||||
}
|
||||
}
|
||||
|
@ -280,91 +280,91 @@ impl DOMMatrixMethods for DOMMatrix {
|
|||
}
|
||||
|
||||
// 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.
|
||||
self.upcast::<DOMMatrixReadOnly>().multiply_self(other)
|
||||
// Step 4.
|
||||
.and(Ok(Root::from_ref(&self)))
|
||||
.and(Ok(DomRoot::from_ref(&self)))
|
||||
}
|
||||
|
||||
// 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.
|
||||
self.upcast::<DOMMatrixReadOnly>().pre_multiply_self(other)
|
||||
// Step 4.
|
||||
.and(Ok(Root::from_ref(&self)))
|
||||
.and(Ok(DomRoot::from_ref(&self)))
|
||||
}
|
||||
|
||||
// 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.
|
||||
self.upcast::<DOMMatrixReadOnly>().translate_self(tx, ty, tz);
|
||||
// Step 3.
|
||||
Root::from_ref(&self)
|
||||
DomRoot::from_ref(&self)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scaleself
|
||||
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.
|
||||
self.upcast::<DOMMatrixReadOnly>().scale_self(scaleX, scaleY, scaleZ, originX, originY, originZ);
|
||||
// Step 7.
|
||||
Root::from_ref(&self)
|
||||
DomRoot::from_ref(&self)
|
||||
}
|
||||
|
||||
// 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.
|
||||
self.upcast::<DOMMatrixReadOnly>().scale_3d_self(scale, originX, originY, originZ);
|
||||
// Step 5.
|
||||
Root::from_ref(&self)
|
||||
DomRoot::from_ref(&self)
|
||||
}
|
||||
|
||||
// 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.
|
||||
self.upcast::<DOMMatrixReadOnly>().rotate_self(rotX, rotY, rotZ);
|
||||
// Step 8.
|
||||
Root::from_ref(&self)
|
||||
DomRoot::from_ref(&self)
|
||||
}
|
||||
|
||||
// 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.
|
||||
self.upcast::<DOMMatrixReadOnly>().rotate_from_vector_self(x, y);
|
||||
// Step 2.
|
||||
Root::from_ref(&self)
|
||||
DomRoot::from_ref(&self)
|
||||
}
|
||||
|
||||
// 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.
|
||||
self.upcast::<DOMMatrixReadOnly>().rotate_axis_angle_self(x, y, z, angle);
|
||||
// Step 3.
|
||||
Root::from_ref(&self)
|
||||
DomRoot::from_ref(&self)
|
||||
}
|
||||
|
||||
// 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.
|
||||
self.upcast::<DOMMatrixReadOnly>().skew_x_self(sx);
|
||||
// Step 2.
|
||||
Root::from_ref(&self)
|
||||
DomRoot::from_ref(&self)
|
||||
}
|
||||
|
||||
// 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.
|
||||
self.upcast::<DOMMatrixReadOnly>().skew_y_self(sy);
|
||||
// Step 2.
|
||||
Root::from_ref(&self)
|
||||
DomRoot::from_ref(&self)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-invertself
|
||||
fn InvertSelf(&self) -> Root<DOMMatrix> {
|
||||
fn InvertSelf(&self) -> DomRoot<DOMMatrix> {
|
||||
// Steps 1-2.
|
||||
self.upcast::<DOMMatrixReadOnly>().invert_self();
|
||||
// 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::Fallible;
|
||||
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::dompoint::DOMPoint;
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
@ -27,7 +27,7 @@ pub struct DOMMatrixReadOnly {
|
|||
|
||||
impl DOMMatrixReadOnly {
|
||||
#[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);
|
||||
reflect_dom_object(box dommatrix, global, Wrap)
|
||||
}
|
||||
|
@ -41,12 +41,12 @@ impl 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()))
|
||||
}
|
||||
|
||||
// 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[..])
|
||||
.map(|(is2D, matrix)| {
|
||||
Self::new(global, is2D, matrix)
|
||||
|
@ -54,7 +54,7 @@ impl DOMMatrixReadOnly {
|
|||
}
|
||||
|
||||
// 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)
|
||||
.map(|(is2D, matrix)| {
|
||||
Self::new(global, is2D, matrix)
|
||||
|
@ -463,55 +463,55 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
|||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale
|
||||
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)
|
||||
.ScaleSelf(scaleX, scaleY, scaleZ, originX, originY, originZ)
|
||||
}
|
||||
|
||||
// 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)
|
||||
.Scale3dSelf(scale, originX, originY, originZ)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 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 flip = Transform3D::row_major(-1.0, 0.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
|
||||
fn FlipY(&self) -> Root<DOMMatrix> {
|
||||
fn FlipY(&self) -> DomRoot<DOMMatrix> {
|
||||
let is2D = self.is2D.get();
|
||||
let flip = Transform3D::row_major(1.0, 0.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
|
||||
fn Inverse(&self) -> Root<DOMMatrix> {
|
||||
fn Inverse(&self) -> DomRoot<DOMMatrix> {
|
||||
DOMMatrix::from_readonly(&self.global(), self).InvertSelf()
|
||||
}
|
||||
|
||||
// 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
|
||||
// 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
|
||||
|
|
|
@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::DocumentBinding::DocumentReadyState;
|
|||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::error::Fallible;
|
||||
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::document::{Document, HasBrowsingContext, IsHTMLDocument};
|
||||
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),
|
||||
window,
|
||||
DOMParserBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn Constructor(window: &Window) -> Fallible<Root<DOMParser>> {
|
||||
pub fn Constructor(window: &Window) -> Fallible<DomRoot<DOMParser>> {
|
||||
Ok(DOMParser::new(window))
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ impl DOMParserMethods for DOMParser {
|
|||
fn ParseFromString(&self,
|
||||
s: DOMString,
|
||||
ty: DOMParserBinding::SupportedType)
|
||||
-> Fallible<Root<Document>> {
|
||||
-> Fallible<DomRoot<Document>> {
|
||||
let url = self.window.get_url();
|
||||
let content_type = DOMString::from(ty.as_str());
|
||||
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::error::Fallible;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::dompointreadonly::{DOMPointReadOnly, DOMPointWriteMethods};
|
||||
use dom::globalscope::GlobalScope;
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -33,11 +33,11 @@ impl DOMPoint {
|
|||
y: f64,
|
||||
z: f64,
|
||||
w: f64)
|
||||
-> Fallible<Root<DOMPoint>> {
|
||||
-> Fallible<DomRoot<DOMPoint>> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::{DOMPointReadOnlyMethods, Wrap};
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
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),
|
||||
global,
|
||||
Wrap)
|
||||
|
@ -42,7 +42,7 @@ impl DOMPointReadOnly {
|
|||
y: f64,
|
||||
z: f64,
|
||||
w: f64)
|
||||
-> Fallible<Root<DOMPointReadOnly>> {
|
||||
-> Fallible<DomRoot<DOMPointReadOnly>> {
|
||||
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::error::Fallible;
|
||||
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::domrect::DOMRect;
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
@ -42,7 +42,7 @@ impl DOMQuad {
|
|||
p1: &DOMPoint,
|
||||
p2: &DOMPoint,
|
||||
p3: &DOMPoint,
|
||||
p4: &DOMPoint) -> Root<DOMQuad> {
|
||||
p4: &DOMPoint) -> DomRoot<DOMQuad> {
|
||||
reflect_dom_object(box DOMQuad::new_inherited(p1, p2, p3, p4),
|
||||
global,
|
||||
Wrap)
|
||||
|
@ -53,7 +53,7 @@ impl DOMQuad {
|
|||
p2: &DOMPointInit,
|
||||
p3: &DOMPointInit,
|
||||
p4: &DOMPointInit)
|
||||
-> Fallible<Root<DOMQuad>> {
|
||||
-> Fallible<DomRoot<DOMQuad>> {
|
||||
Ok(DOMQuad::new(global,
|
||||
&*DOMPoint::new_from_init(global, p1),
|
||||
&*DOMPoint::new_from_init(global, p2),
|
||||
|
@ -62,7 +62,7 @@ impl DOMQuad {
|
|||
}
|
||||
|
||||
// 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,
|
||||
&*DOMPoint::new(global, other.x, 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
|
||||
pub fn FromQuad(global: &GlobalScope, other: &DOMQuadInit) -> Root<DOMQuad> {
|
||||
pub fn FromQuad(global: &GlobalScope, other: &DOMQuadInit) -> DomRoot<DOMQuad> {
|
||||
DOMQuad::new(global,
|
||||
&DOMPoint::new_from_init(global, &other.p1),
|
||||
&DOMPoint::new_from_init(global, &other.p2),
|
||||
|
@ -82,27 +82,27 @@ impl DOMQuad {
|
|||
|
||||
impl DOMQuadMethods for DOMQuad {
|
||||
// https://drafts.fxtf.org/geometry/#dom-domquad-p1
|
||||
fn P1(&self) -> Root<DOMPoint> {
|
||||
Root::from_ref(&self.p1)
|
||||
fn P1(&self) -> DomRoot<DOMPoint> {
|
||||
DomRoot::from_ref(&self.p1)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry/#dom-domquad-p2
|
||||
fn P2(&self) -> Root<DOMPoint> {
|
||||
Root::from_ref(&self.p2)
|
||||
fn P2(&self) -> DomRoot<DOMPoint> {
|
||||
DomRoot::from_ref(&self.p2)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry/#dom-domquad-p3
|
||||
fn P3(&self) -> Root<DOMPoint> {
|
||||
Root::from_ref(&self.p3)
|
||||
fn P3(&self) -> DomRoot<DOMPoint> {
|
||||
DomRoot::from_ref(&self.p3)
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry/#dom-domquad-p4
|
||||
fn P4(&self) -> Root<DOMPoint> {
|
||||
Root::from_ref(&self.p4)
|
||||
fn P4(&self) -> DomRoot<DOMPoint> {
|
||||
DomRoot::from_ref(&self.p4)
|
||||
}
|
||||
|
||||
// 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 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());
|
||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
|
|||
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectReadOnlyMethods;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::domrectreadonly::DOMRectReadOnly;
|
||||
use dom::globalscope::GlobalScope;
|
||||
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),
|
||||
global,
|
||||
DOMRectBinding::Wrap)
|
||||
|
@ -35,7 +35,7 @@ impl DOMRect {
|
|||
y: f64,
|
||||
width: f64,
|
||||
height: f64)
|
||||
-> Fallible<Root<DOMRect>> {
|
||||
-> Fallible<DomRoot<DOMRect>> {
|
||||
Ok(DOMRect::new(global, x, y, width, height))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::{DOMRectReadOnlyMethods, Wrap};
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use std::cell::Cell;
|
||||
|
@ -35,7 +35,7 @@ impl DOMRectReadOnly {
|
|||
y: f64,
|
||||
width: f64,
|
||||
height: f64)
|
||||
-> Root<DOMRectReadOnly> {
|
||||
-> DomRoot<DOMRectReadOnly> {
|
||||
reflect_dom_object(box DOMRectReadOnly::new_inherited(x, y, width, height),
|
||||
global,
|
||||
Wrap)
|
||||
|
@ -46,7 +46,7 @@ impl DOMRectReadOnly {
|
|||
y: f64,
|
||||
width: f64,
|
||||
height: f64)
|
||||
-> Fallible<Root<DOMRectReadOnly>> {
|
||||
-> Fallible<DomRoot<DOMRectReadOnly>> {
|
||||
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::error::ErrorResult;
|
||||
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::htmlelement::HTMLElement;
|
||||
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);
|
||||
reflect_dom_object(box DOMStringMap::new_inherited(element),
|
||||
&*window,
|
||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DOMTokenListBinding;
|
|||
use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods;
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
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::element::Element;
|
||||
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);
|
||||
reflect_dom_object(box DOMTokenList::new_inherited(element, local_name.clone()),
|
||||
&*window,
|
||||
DOMTokenListBinding::Wrap)
|
||||
}
|
||||
|
||||
fn attribute(&self) -> Option<Root<Attr>> {
|
||||
fn attribute(&self) -> Option<DomRoot<Attr>> {
|
||||
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::refcounted::{Trusted, TrustedPromise};
|
||||
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::xmlname::{namespace_from_domstring, validate_and_extract, xml_name_type};
|
||||
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 {
|
||||
(**self).fmt(f)
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ impl Element {
|
|||
document: &Document,
|
||||
creator: ElementCreator,
|
||||
mode: CustomElementCreationMode)
|
||||
-> Root<Element> {
|
||||
-> DomRoot<Element> {
|
||||
create_element(name, is, document, creator, mode)
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ impl Element {
|
|||
pub fn new(local_name: LocalName,
|
||||
namespace: Namespace,
|
||||
prefix: Option<Prefix>,
|
||||
document: &Document) -> Root<Element> {
|
||||
document: &Document) -> DomRoot<Element> {
|
||||
Node::reflect_node(
|
||||
box Element::new_inherited(local_name, namespace, prefix, document),
|
||||
document,
|
||||
|
@ -923,7 +923,7 @@ impl Element {
|
|||
let inclusive_ancestor_elements =
|
||||
self.upcast::<Node>()
|
||||
.inclusive_ancestors()
|
||||
.filter_map(Root::downcast::<Self>);
|
||||
.filter_map(DomRoot::downcast::<Self>);
|
||||
|
||||
// Steps 3-4.
|
||||
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() {
|
||||
self.upcast::<Node>()
|
||||
.owner_doc()
|
||||
|
@ -1011,7 +1011,7 @@ impl Element {
|
|||
} else {
|
||||
self.upcast::<Node>()
|
||||
.inclusive_ancestors()
|
||||
.filter_map(Root::downcast)
|
||||
.filter_map(DomRoot::downcast)
|
||||
.last()
|
||||
.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
|
||||
.borrow()
|
||||
.iter()
|
||||
.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
|
||||
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);
|
||||
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,
|
||||
|
@ -1207,7 +1207,7 @@ impl Element {
|
|||
.borrow()
|
||||
.iter()
|
||||
.find(|attr| find(&attr))
|
||||
.map(|js| Root::from_ref(&**js));
|
||||
.map(|js| DomRoot::from_ref(&**js));
|
||||
if let Some(attr) = attr {
|
||||
attr.set_value(value, self);
|
||||
} 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| {
|
||||
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)
|
||||
}
|
||||
|
||||
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 {
|
||||
let idx = self.attrs.borrow().iter().position(|attr| find(&attr));
|
||||
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);
|
||||
|
||||
let name = attr.local_name().clone();
|
||||
|
@ -1396,7 +1396,7 @@ impl Element {
|
|||
|
||||
// https://dom.spec.whatwg.org/#insert-adjacent
|
||||
pub fn insert_adjacent(&self, where_: AdjacentPosition, node: &Node)
|
||||
-> Fallible<Option<Root<Node>>> {
|
||||
-> Fallible<Option<DomRoot<Node>>> {
|
||||
let self_node = self.upcast::<Node>();
|
||||
match where_ {
|
||||
AdjacentPosition::BeforeBegin => {
|
||||
|
@ -1468,7 +1468,7 @@ impl Element {
|
|||
}
|
||||
|
||||
// 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.
|
||||
let context_document = document_from_node(self);
|
||||
// TODO(#11995): XML case.
|
||||
|
@ -1483,13 +1483,13 @@ impl Element {
|
|||
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 {
|
||||
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
|
||||
fn ClassList(&self) -> Root<DOMTokenList> {
|
||||
fn ClassList(&self) -> DomRoot<DOMTokenList> {
|
||||
self.class_list.or_init(|| DOMTokenList::new(self, &local_name!("class")))
|
||||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
|
||||
|
@ -1603,7 +1603,7 @@ impl ElementMethods for Element {
|
|||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
@ -1611,7 +1611,7 @@ impl ElementMethods for Element {
|
|||
fn GetAttributeNodeNS(&self,
|
||||
namespace: Option<DOMString>,
|
||||
local_name: DOMString)
|
||||
-> Option<Root<Attr>> {
|
||||
-> Option<DomRoot<Attr>> {
|
||||
let namespace = &namespace_from_domstring(namespace);
|
||||
self.get_attribute(namespace, &LocalName::from(local_name))
|
||||
}
|
||||
|
@ -1650,7 +1650,7 @@ impl ElementMethods for Element {
|
|||
}
|
||||
|
||||
// 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.
|
||||
if let Some(owner) = attr.GetOwnerElement() {
|
||||
if &*owner != self {
|
||||
|
@ -1673,11 +1673,11 @@ impl ElementMethods for Element {
|
|||
});
|
||||
|
||||
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.
|
||||
if &*old_attr == attr {
|
||||
return Ok(Some(Root::from_ref(attr)));
|
||||
return Ok(Some(DomRoot::from_ref(attr)));
|
||||
}
|
||||
|
||||
// Step 4.
|
||||
|
@ -1712,7 +1712,7 @@ impl ElementMethods for Element {
|
|||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
@ -1730,7 +1730,7 @@ impl ElementMethods for Element {
|
|||
}
|
||||
|
||||
// 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)
|
||||
.ok_or(Error::NotFound)
|
||||
}
|
||||
|
@ -1746,7 +1746,7 @@ impl ElementMethods for Element {
|
|||
}
|
||||
|
||||
// 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);
|
||||
HTMLCollection::by_qualified_name(&window, self.upcast(), LocalName::from(&*localname))
|
||||
}
|
||||
|
@ -1755,19 +1755,19 @@ impl ElementMethods for Element {
|
|||
fn GetElementsByTagNameNS(&self,
|
||||
maybe_ns: Option<DOMString>,
|
||||
localname: DOMString)
|
||||
-> Root<HTMLCollection> {
|
||||
-> DomRoot<HTMLCollection> {
|
||||
let window = window_from_node(self);
|
||||
HTMLCollection::by_tag_name_ns(&window, self.upcast(), localname, maybe_ns)
|
||||
}
|
||||
|
||||
// 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);
|
||||
HTMLCollection::by_class_name(&window, self.upcast(), classes)
|
||||
}
|
||||
|
||||
// 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 raw_rects = self.upcast::<Node>().content_boxes();
|
||||
raw_rects.iter().map(|rect| {
|
||||
|
@ -1780,7 +1780,7 @@ impl ElementMethods for Element {
|
|||
}
|
||||
|
||||
// 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 rect = self.upcast::<Node>().bounding_content_box_or_zero();
|
||||
DOMRect::new(win.upcast(),
|
||||
|
@ -2059,9 +2059,9 @@ impl ElementMethods for Element {
|
|||
// Step 2.
|
||||
// https://github.com/w3c/DOM-Parsing/issues/1
|
||||
let target = if let Some(template) = self.downcast::<HTMLTemplateElement>() {
|
||||
Root::upcast(template.Content())
|
||||
DomRoot::upcast(template.Content())
|
||||
} else {
|
||||
Root::from_ref(self.upcast())
|
||||
DomRoot::from_ref(self.upcast())
|
||||
};
|
||||
Node::replace_all(Some(frag.upcast()), &target);
|
||||
Ok(())
|
||||
|
@ -2096,7 +2096,7 @@ impl ElementMethods for Element {
|
|||
&context_document,
|
||||
ElementCreator::ScriptCreated,
|
||||
CustomElementCreationMode::Synchronous);
|
||||
Root::upcast(body_elem)
|
||||
DomRoot::upcast(body_elem)
|
||||
},
|
||||
_ => context_node.GetParentElement().unwrap()
|
||||
};
|
||||
|
@ -2109,29 +2109,29 @@ impl ElementMethods for Element {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-previouselementsibling
|
||||
fn GetPreviousElementSibling(&self) -> Option<Root<Element>> {
|
||||
self.upcast::<Node>().preceding_siblings().filter_map(Root::downcast).next()
|
||||
fn GetPreviousElementSibling(&self) -> Option<DomRoot<Element>> {
|
||||
self.upcast::<Node>().preceding_siblings().filter_map(DomRoot::downcast).next()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-nextelementsibling
|
||||
fn GetNextElementSibling(&self) -> Option<Root<Element>> {
|
||||
self.upcast::<Node>().following_siblings().filter_map(Root::downcast).next()
|
||||
fn GetNextElementSibling(&self) -> Option<DomRoot<Element>> {
|
||||
self.upcast::<Node>().following_siblings().filter_map(DomRoot::downcast).next()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
||||
fn Children(&self) -> Root<HTMLCollection> {
|
||||
fn Children(&self) -> DomRoot<HTMLCollection> {
|
||||
let window = window_from_node(self);
|
||||
HTMLCollection::children(&window, self.upcast())
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
||||
fn GetLastElementChild(&self) -> Option<Root<Element>> {
|
||||
self.upcast::<Node>().rev_children().filter_map(Root::downcast::<Element>).next()
|
||||
fn GetLastElementChild(&self) -> Option<DomRoot<Element>> {
|
||||
self.upcast::<Node>().rev_children().filter_map(DomRoot::downcast::<Element>).next()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
||||
|
@ -2150,13 +2150,13 @@ impl ElementMethods for Element {
|
|||
}
|
||||
|
||||
// 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>();
|
||||
root.query_selector(selectors)
|
||||
}
|
||||
|
||||
// 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>();
|
||||
root.query_selector_all(selectors)
|
||||
}
|
||||
|
@ -2190,7 +2190,7 @@ impl ElementMethods for Element {
|
|||
// FIXME(bholley): Consider an nth-index cache here.
|
||||
let mut ctx = MatchingContext::new(MatchingMode::Normal, None, None,
|
||||
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
|
||||
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) {
|
||||
Err(_) => Err(Error::Syntax),
|
||||
Ok(selectors) => {
|
||||
let root = self.upcast::<Node>();
|
||||
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();
|
||||
// FIXME(bholley): Consider an nth-index cache here.
|
||||
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
|
||||
fn InsertAdjacentElement(&self, where_: DOMString, element: &Element)
|
||||
-> Fallible<Option<Root<Element>>> {
|
||||
-> Fallible<Option<DomRoot<Element>>> {
|
||||
let where_ = AdjacentPosition::try_from(&*where_)?;
|
||||
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
|
||||
|
@ -2258,7 +2258,7 @@ impl ElementMethods for Element {
|
|||
}
|
||||
}
|
||||
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;
|
||||
|
||||
fn opaque(&self) -> ::selectors::OpaqueElement {
|
||||
::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()
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
}
|
||||
|
||||
fn last_child_element(&self) -> Option<Root<Element>> {
|
||||
self.node.rev_children().filter_map(Root::downcast).next()
|
||||
fn last_child_element(&self) -> Option<DomRoot<Element>> {
|
||||
self.node.rev_children().filter_map(DomRoot::downcast).next()
|
||||
}
|
||||
|
||||
fn prev_sibling_element(&self) -> Option<Root<Element>> {
|
||||
self.node.preceding_siblings().filter_map(Root::downcast).next()
|
||||
fn prev_sibling_element(&self) -> Option<DomRoot<Element>> {
|
||||
self.node.preceding_siblings().filter_map(DomRoot::downcast).next()
|
||||
}
|
||||
|
||||
fn next_sibling_element(&self) -> Option<Root<Element>> {
|
||||
self.node.following_siblings().filter_map(Root::downcast).next()
|
||||
fn next_sibling_element(&self) -> Option<DomRoot<Element>> {
|
||||
self.node.following_siblings().filter_map(DomRoot::downcast).next()
|
||||
}
|
||||
|
||||
fn attr_matches(&self,
|
||||
|
@ -2739,15 +2739,15 @@ impl 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() {
|
||||
Some(el) => Some(Root::from_ref(el.as_element())),
|
||||
Some(el) => Some(DomRoot::from_ref(el.as_element())),
|
||||
None => {
|
||||
let node = self.upcast::<Node>();
|
||||
for node in node.ancestors() {
|
||||
if let Some(node) = node.downcast::<Element>() {
|
||||
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::inheritance::Castable;
|
||||
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::trace::RootedTraceableBox;
|
||||
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(),
|
||||
global,
|
||||
ErrorEventBinding::Wrap)
|
||||
|
@ -57,7 +57,7 @@ impl ErrorEvent {
|
|||
filename: DOMString,
|
||||
lineno: u32,
|
||||
colno: u32,
|
||||
error: HandleValue) -> Root<ErrorEvent> {
|
||||
error: HandleValue) -> DomRoot<ErrorEvent> {
|
||||
let ev = ErrorEvent::new_uninitialized(global);
|
||||
{
|
||||
let event = ev.upcast::<Event>();
|
||||
|
@ -75,7 +75,7 @@ impl ErrorEvent {
|
|||
pub fn Constructor(global: &GlobalScope,
|
||||
type_: DOMString,
|
||||
init: RootedTraceableBox<ErrorEventBinding::ErrorEventInit>)
|
||||
-> Fallible<Root<ErrorEvent>>{
|
||||
-> Fallible<DomRoot<ErrorEvent>>{
|
||||
let msg = match init.message.as_ref() {
|
||||
Some(message) => message.clone(),
|
||||
None => DOMString::new(),
|
||||
|
|
|
@ -11,7 +11,7 @@ use dom::bindings::error::Fallible;
|
|||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
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::document::Document;
|
||||
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(),
|
||||
global,
|
||||
EventBinding::Wrap)
|
||||
|
@ -73,7 +73,7 @@ impl Event {
|
|||
pub fn new(global: &GlobalScope,
|
||||
type_: Atom,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable) -> Root<Event> {
|
||||
cancelable: EventCancelable) -> DomRoot<Event> {
|
||||
let event = Event::new_uninitialized(global);
|
||||
event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
|
||||
event
|
||||
|
@ -81,7 +81,7 @@ impl Event {
|
|||
|
||||
pub fn Constructor(global: &GlobalScope,
|
||||
type_: DOMString,
|
||||
init: &EventBinding::EventInit) -> Fallible<Root<Event>> {
|
||||
init: &EventBinding::EventInit) -> Fallible<DomRoot<Event>> {
|
||||
let bubbles = EventBubbles::from(init.bubbles);
|
||||
let cancelable = EventCancelable::from(init.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>()));
|
||||
}
|
||||
let top_most_ancestor_or_target =
|
||||
Root::from_ref(event_path.r().last().cloned().unwrap_or(target));
|
||||
if let Some(document) = Root::downcast::<Document>(top_most_ancestor_or_target) {
|
||||
DomRoot::from_ref(event_path.r().last().cloned().unwrap_or(target));
|
||||
if let Some(document) = DomRoot::downcast::<Document>(top_most_ancestor_or_target) {
|
||||
if self.type_() != atom!("load") && document.browsing_context().is_some() {
|
||||
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
|
||||
fn GetTarget(&self) -> Option<Root<EventTarget>> {
|
||||
fn GetTarget(&self) -> Option<DomRoot<EventTarget>> {
|
||||
self.target.get()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-currenttarget
|
||||
fn GetCurrentTarget(&self) -> Option<Root<EventTarget>> {
|
||||
fn GetCurrentTarget(&self) -> Option<DomRoot<EventTarget>> {
|
||||
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_immediate.get());
|
||||
|
||||
let window = match Root::downcast::<Window>(target.global()) {
|
||||
let window = match DomRoot::downcast::<Window>(target.global()) {
|
||||
Some(window) => {
|
||||
if window.need_emit_timeline_marker(TimelineMarkerType::DOMEvent) {
|
||||
Some(window)
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::error::{Error, Fallible};
|
|||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
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::event::Event;
|
||||
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),
|
||||
global,
|
||||
Wrap)
|
||||
|
@ -424,7 +424,7 @@ impl EventSource {
|
|||
|
||||
pub fn Constructor(global: &GlobalScope,
|
||||
url: DOMString,
|
||||
event_source_init: &EventSourceInit) -> Fallible<Root<EventSource>> {
|
||||
event_source_init: &EventSourceInit) -> Fallible<DomRoot<EventSource>> {
|
||||
// TODO: Step 2 relevant settings object
|
||||
// Step 3
|
||||
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::inheritance::Castable;
|
||||
use dom::bindings::reflector::{DomObject, Reflector};
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::element::Element;
|
||||
use dom::errorevent::ErrorEvent;
|
||||
|
@ -174,7 +174,7 @@ impl CompiledEventListener {
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -506,28 +506,28 @@ impl EventTarget {
|
|||
}
|
||||
|
||||
// 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,
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable)
|
||||
}
|
||||
|
||||
// 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,
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable)
|
||||
}
|
||||
|
||||
// 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,
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::Cancelable)
|
||||
}
|
||||
|
||||
// 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,
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::Cancelable)
|
||||
|
@ -538,7 +538,7 @@ impl EventTarget {
|
|||
name: Atom,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable)
|
||||
-> Root<Event> {
|
||||
-> DomRoot<Event> {
|
||||
let event = Event::new(&self.global(), name, bubbles, cancelable);
|
||||
event.fire(self);
|
||||
event
|
||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::ExtendableEventBinding;
|
|||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::event::Event;
|
||||
use dom::serviceworkerglobalscope::ServiceWorkerGlobalScope;
|
||||
|
@ -33,7 +33,7 @@ impl ExtendableEvent {
|
|||
type_: Atom,
|
||||
bubbles: bool,
|
||||
cancelable: bool)
|
||||
-> Root<ExtendableEvent> {
|
||||
-> DomRoot<ExtendableEvent> {
|
||||
let ev = reflect_dom_object(box ExtendableEvent::new_inherited(), worker, ExtendableEventBinding::Wrap);
|
||||
{
|
||||
let event = ev.upcast::<Event>();
|
||||
|
@ -44,7 +44,7 @@ impl ExtendableEvent {
|
|||
|
||||
pub fn Constructor(worker: &ServiceWorkerGlobalScope,
|
||||
type_: DOMString,
|
||||
init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible<Root<ExtendableEvent>> {
|
||||
init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible<DomRoot<ExtendableEvent>> {
|
||||
Ok(ExtendableEvent::new(worker,
|
||||
Atom::from(type_),
|
||||
init.parent.bubbles,
|
||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::ExtendableMessageEventBinding::ExtendableM
|
|||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
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::trace::RootedTraceableBox;
|
||||
use dom::event::Event;
|
||||
|
@ -32,7 +32,7 @@ impl ExtendableMessageEvent {
|
|||
pub fn new(global: &GlobalScope, type_: Atom,
|
||||
bubbles: bool, cancelable: bool,
|
||||
data: HandleValue, origin: DOMString, lastEventId: DOMString)
|
||||
-> Root<ExtendableMessageEvent> {
|
||||
-> DomRoot<ExtendableMessageEvent> {
|
||||
let ev = box ExtendableMessageEvent {
|
||||
event: ExtendableEvent::new_inherited(),
|
||||
data: Heap::default(),
|
||||
|
@ -52,7 +52,7 @@ impl ExtendableMessageEvent {
|
|||
pub fn Constructor(worker: &ServiceWorkerGlobalScope,
|
||||
type_: DOMString,
|
||||
init: RootedTraceableBox<ExtendableMessageEventBinding::ExtendableMessageEventInit>)
|
||||
-> Fallible<Root<ExtendableMessageEvent>> {
|
||||
-> Fallible<DomRoot<ExtendableMessageEvent>> {
|
||||
let global = worker.upcast::<GlobalScope>();
|
||||
let ev = ExtendableMessageEvent::new(global,
|
||||
Atom::from(type_),
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::UnionTypes::BlobOrString;
|
|||
use dom::bindings::error::{Error, Fallible};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::blob::{Blob, BlobImpl, blob_parts_to_bytes};
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
@ -44,14 +44,14 @@ impl File {
|
|||
|
||||
#[allow(unrooted_must_root)]
|
||||
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),
|
||||
global,
|
||||
FileBinding::Wrap)
|
||||
}
|
||||
|
||||
// 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"));
|
||||
|
||||
File::new(window.upcast(), BlobImpl::new_from_file(selected.id, selected.filename, selected.size),
|
||||
|
@ -63,7 +63,7 @@ impl File {
|
|||
fileBits: Vec<BlobOrString>,
|
||||
filename: DOMString,
|
||||
filePropertyBag: &FileBinding::FilePropertyBag)
|
||||
-> Fallible<Root<File>> {
|
||||
-> Fallible<DomRoot<File>> {
|
||||
let bytes: Vec<u8> = match blob_parts_to_bytes(fileBits) {
|
||||
Ok(bytes) => bytes,
|
||||
Err(_) => return Err(Error::InvalidCharacter),
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use dom::bindings::codegen::Bindings::FileListBinding;
|
||||
use dom::bindings::codegen::Bindings::FileListBinding::FileListMethods;
|
||||
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::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
|
@ -28,7 +28,7 @@ impl FileList {
|
|||
}
|
||||
|
||||
#[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()),
|
||||
window,
|
||||
FileListBinding::Wrap)
|
||||
|
@ -46,16 +46,16 @@ impl FileListMethods for FileList {
|
|||
}
|
||||
|
||||
// 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() {
|
||||
Some(Root::from_ref(&*(self.list[index as usize])))
|
||||
Some(DomRoot::from_ref(&*(self.list[index as usize])))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
|
|||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
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::trace::RootedTraceableBox;
|
||||
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(),
|
||||
global, FileReaderBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<FileReader>> {
|
||||
pub fn Constructor(global: &GlobalScope) -> Fallible<DomRoot<FileReader>> {
|
||||
Ok(FileReader::new(global))
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,7 @@ impl FileReaderMethods for FileReader {
|
|||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#dfn-error
|
||||
fn GetError(&self) -> Option<Root<DOMException>> {
|
||||
fn GetError(&self) -> Option<DomRoot<DOMException>> {
|
||||
self.error.get()
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use dom::bindings::codegen::Bindings::FileReaderSyncBinding;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::globalscope::GlobalScope;
|
||||
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(),
|
||||
global, FileReaderSyncBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<FileReaderSync>> {
|
||||
pub fn Constructor(global: &GlobalScope) -> Fallible<DomRoot<FileReaderSync>> {
|
||||
Ok(FileReaderSync::new(global))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
|||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
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::event::{EventBubbles, EventCancelable};
|
||||
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(),
|
||||
window,
|
||||
FocusEventBinding::Wrap)
|
||||
|
@ -43,7 +43,7 @@ impl FocusEvent {
|
|||
cancelable: EventCancelable,
|
||||
view: Option<&Window>,
|
||||
detail: i32,
|
||||
related_target: Option<&EventTarget>) -> Root<FocusEvent> {
|
||||
related_target: Option<&EventTarget>) -> DomRoot<FocusEvent> {
|
||||
let ev = FocusEvent::new_uninitialized(window);
|
||||
ev.upcast::<UIEvent>().InitUIEvent(type_,
|
||||
bool::from(can_bubble),
|
||||
|
@ -55,7 +55,7 @@ impl FocusEvent {
|
|||
|
||||
pub fn Constructor(window: &Window,
|
||||
type_: DOMString,
|
||||
init: &FocusEventBinding::FocusEventInit) -> Fallible<Root<FocusEvent>> {
|
||||
init: &FocusEventBinding::FocusEventInit) -> Fallible<DomRoot<FocusEvent>> {
|
||||
let bubbles = EventBubbles::from(init.parent.parent.bubbles);
|
||||
let cancelable = EventCancelable::from(init.parent.parent.cancelable);
|
||||
let event = FocusEvent::new(window,
|
||||
|
@ -71,7 +71,7 @@ impl FocusEvent {
|
|||
|
||||
impl FocusEventMethods for FocusEvent {
|
||||
// https://w3c.github.io/uievents/#widl-FocusEvent-relatedTarget
|
||||
fn GetRelatedTarget(&self) -> Option<Root<EventTarget>> {
|
||||
fn GetRelatedTarget(&self) -> Option<DomRoot<EventTarget>> {
|
||||
self.related_target.get()
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
|||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::num::Finite;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::uievent::UIEvent;
|
||||
use dom::window::Window;
|
||||
|
@ -30,7 +30,7 @@ impl ForceTouchEvent {
|
|||
|
||||
pub fn new(window: &Window,
|
||||
type_: DOMString,
|
||||
force: f32) -> Root<ForceTouchEvent> {
|
||||
force: f32) -> DomRoot<ForceTouchEvent> {
|
||||
let event = box ForceTouchEvent::new_inherited(force);
|
||||
let ev = reflect_dom_object(event, window, ForceTouchEventBinding::Wrap);
|
||||
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::iterable::Iterable;
|
||||
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::blob::{Blob, BlobImpl};
|
||||
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),
|
||||
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
|
||||
Ok(FormData::new(form, global))
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ impl FormDataMethods for FormData {
|
|||
let datum = FormDatum {
|
||||
ty: DOMString::from("file"),
|
||||
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();
|
||||
|
@ -102,7 +102,7 @@ impl FormDataMethods for FormData {
|
|||
.get(&LocalName::from(name.0))
|
||||
.map(|entry| match entry[0].value {
|
||||
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|
|
||||
data.iter().map(|item| match item.value {
|
||||
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()
|
||||
)
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ impl FormDataMethods for FormData {
|
|||
self.data.borrow_mut().insert(LocalName::from(name.0.clone()), vec![FormDatum {
|
||||
ty: DOMString::from("file"),
|
||||
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 {
|
||||
// https://xhr.spec.whatwg.org/#create-an-entry
|
||||
// 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 {
|
||||
Some(filename) => DOMString::from(filename.0),
|
||||
None if blob.downcast::<File>().is_none() => DOMString::from("blob"),
|
||||
|
@ -185,7 +185,7 @@ impl Iterable for FormData {
|
|||
.value;
|
||||
match *value {
|
||||
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::num::Finite;
|
||||
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::event::Event;
|
||||
use dom::eventtarget::EventTarget;
|
||||
|
@ -71,7 +71,7 @@ impl Gamepad {
|
|||
pub fn new_from_vr(global: &GlobalScope,
|
||||
index: i32,
|
||||
data: &WebVRGamepadData,
|
||||
state: &WebVRGamepadState) -> Root<Gamepad> {
|
||||
state: &WebVRGamepadState) -> DomRoot<Gamepad> {
|
||||
let buttons = GamepadButtonList::new_from_vr(&global, &state.buttons);
|
||||
let pose = VRPose::new(&global, &state.pose);
|
||||
|
||||
|
@ -132,8 +132,8 @@ impl GamepadMethods for Gamepad {
|
|||
}
|
||||
|
||||
// https://w3c.github.io/gamepad/#dom-gamepad-buttons
|
||||
fn Buttons(&self) -> Root<GamepadButtonList> {
|
||||
Root::from_ref(&*self.buttons)
|
||||
fn Buttons(&self) -> DomRoot<GamepadButtonList> {
|
||||
DomRoot::from_ref(&*self.buttons)
|
||||
}
|
||||
|
||||
// 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
|
||||
fn GetPose(&self) -> Option<Root<VRPose>> {
|
||||
self.pose.as_ref().map(|p| Root::from_ref(&**p))
|
||||
fn GetPose(&self) -> Option<DomRoot<VRPose>> {
|
||||
self.pose.as_ref().map(|p| DomRoot::from_ref(&**p))
|
||||
}
|
||||
|
||||
// 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::num::Finite;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
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),
|
||||
global,
|
||||
GamepadButtonBinding::Wrap)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use dom::bindings::codegen::Bindings::GamepadButtonListBinding;
|
||||
use dom::bindings::codegen::Bindings::GamepadButtonListBinding::GamepadButtonListMethods;
|
||||
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::globalscope::GlobalScope;
|
||||
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()
|
||||
.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
|
||||
fn Item(&self, index: u32) -> Option<Root<GamepadButton>> {
|
||||
self.list.get(index as usize).map(|button| Root::from_ref(&**button))
|
||||
fn Item(&self, index: u32) -> Option<DomRoot<GamepadButton>> {
|
||||
self.list.get(index as usize).map(|button| DomRoot::from_ref(&**button))
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::GamepadEventBinding::GamepadEventMethods;
|
|||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
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::event::Event;
|
||||
use dom::gamepad::Gamepad;
|
||||
|
@ -41,7 +41,7 @@ impl GamepadEvent {
|
|||
bubbles: bool,
|
||||
cancelable: bool,
|
||||
gamepad: &Gamepad)
|
||||
-> Root<GamepadEvent> {
|
||||
-> DomRoot<GamepadEvent> {
|
||||
let ev = reflect_dom_object(box GamepadEvent::new_inherited(&gamepad),
|
||||
global,
|
||||
GamepadEventBinding::Wrap);
|
||||
|
@ -53,7 +53,7 @@ impl GamepadEvent {
|
|||
}
|
||||
|
||||
pub fn new_with_type(global: &GlobalScope, event_type: GamepadEventType, gamepad: &Gamepad)
|
||||
-> Root<GamepadEvent> {
|
||||
-> DomRoot<GamepadEvent> {
|
||||
let name = match event_type {
|
||||
GamepadEventType::Connected => "gamepadconnected",
|
||||
GamepadEventType::Disconnected => "gamepaddisconnected"
|
||||
|
@ -70,7 +70,7 @@ impl GamepadEvent {
|
|||
pub fn Constructor(window: &Window,
|
||||
type_: DOMString,
|
||||
init: &GamepadEventBinding::GamepadEventInit)
|
||||
-> Fallible<Root<GamepadEvent>> {
|
||||
-> Fallible<DomRoot<GamepadEvent>> {
|
||||
Ok(GamepadEvent::new(&window.global(),
|
||||
Atom::from(type_),
|
||||
init.parent.bubbles,
|
||||
|
@ -81,8 +81,8 @@ impl GamepadEvent {
|
|||
|
||||
impl GamepadEventMethods for GamepadEvent {
|
||||
// https://w3c.github.io/gamepad/#gamepadevent-interface
|
||||
fn Gamepad(&self) -> Root<Gamepad> {
|
||||
Root::from_ref(&*self.gamepad)
|
||||
fn Gamepad(&self) -> DomRoot<Gamepad> {
|
||||
DomRoot::from_ref(&*self.gamepad)
|
||||
}
|
||||
|
||||
// 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::GamepadListMethods;
|
||||
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::globalscope::GlobalScope;
|
||||
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),
|
||||
global,
|
||||
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 {
|
||||
if !self.list.borrow().iter().any(|g| g.gamepad_id() == gamepad.gamepad_id()) {
|
||||
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
|
||||
fn Item(&self, index: u32) -> Option<Root<Gamepad>> {
|
||||
self.list.borrow().get(index as usize).map(|gamepad| Root::from_ref(&**gamepad))
|
||||
fn Item(&self, index: u32) -> Option<DomRoot<Gamepad>> {
|
||||
self.list.borrow().get(index as usize).map(|gamepad| DomRoot::from_ref(&**gamepad))
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::conversions::root_from_object;
|
|||
use dom::bindings::error::{ErrorInfo, report_pending_exception};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
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::str::DOMString;
|
||||
use dom::crypto::Crypto;
|
||||
|
@ -148,13 +148,13 @@ impl GlobalScope {
|
|||
/// Returns the global scope of the realm that the given DOM object's reflector
|
||||
/// was created in.
|
||||
#[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()) }
|
||||
}
|
||||
|
||||
/// Returns the global scope of the realm that the given JS object was created in.
|
||||
#[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());
|
||||
let global = GetGlobalForObjectCrossCompartment(obj);
|
||||
global_scope_from_global(global)
|
||||
|
@ -162,7 +162,7 @@ impl GlobalScope {
|
|||
|
||||
/// Returns the global scope for the given JSContext
|
||||
#[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);
|
||||
global_scope_from_global(global)
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ impl GlobalScope {
|
|||
/// Returns the global object of the realm that the given JS object
|
||||
/// was created in, after unwrapping any wrappers.
|
||||
#[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) {
|
||||
obj = UnwrapObject(obj, /* stopAtWindowProxy = */ 0);
|
||||
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))
|
||||
}
|
||||
|
||||
|
@ -496,7 +496,7 @@ impl GlobalScope {
|
|||
|
||||
/// Perform a microtask checkpoint.
|
||||
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.
|
||||
|
@ -550,7 +550,7 @@ impl GlobalScope {
|
|||
///
|
||||
/// ["current"]: https://html.spec.whatwg.org/multipage/#current
|
||||
#[allow(unsafe_code)]
|
||||
pub fn current() -> Option<Root<Self>> {
|
||||
pub fn current() -> Option<DomRoot<Self>> {
|
||||
unsafe {
|
||||
let cx = Runtime::get();
|
||||
assert!(!cx.is_null());
|
||||
|
@ -566,18 +566,18 @@ impl GlobalScope {
|
|||
/// Returns the ["entry"] global object.
|
||||
///
|
||||
/// ["entry"]: https://html.spec.whatwg.org/multipage/#entry
|
||||
pub fn entry() -> Root<Self> {
|
||||
pub fn entry() -> DomRoot<Self> {
|
||||
entry_global()
|
||||
}
|
||||
|
||||
/// Returns the ["incumbent"] global object.
|
||||
///
|
||||
/// ["incumbent"]: https://html.spec.whatwg.org/multipage/#incumbent
|
||||
pub fn incumbent() -> Option<Root<Self>> {
|
||||
pub fn incumbent() -> Option<DomRoot<Self>> {
|
||||
incumbent_global()
|
||||
}
|
||||
|
||||
pub fn performance(&self) -> Root<Performance> {
|
||||
pub fn performance(&self) -> DomRoot<Performance> {
|
||||
if let Some(window) = self.downcast::<Window>() {
|
||||
return window.Performance();
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ fn timestamp_in_ms(time: Timespec) -> u64 {
|
|||
|
||||
/// Returns the Rust global scope from a JS global object.
|
||||
#[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());
|
||||
let clasp = get_object_class(global);
|
||||
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::inheritance::Castable;
|
||||
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::event::Event;
|
||||
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()),
|
||||
window,
|
||||
HashChangeEventBinding::Wrap)
|
||||
|
@ -44,7 +44,7 @@ impl HashChangeEvent {
|
|||
cancelable: bool,
|
||||
old_url: String,
|
||||
new_url: String)
|
||||
-> Root<HashChangeEvent> {
|
||||
-> DomRoot<HashChangeEvent> {
|
||||
let ev = reflect_dom_object(box HashChangeEvent::new_inherited(old_url, new_url),
|
||||
window,
|
||||
HashChangeEventBinding::Wrap);
|
||||
|
@ -58,7 +58,7 @@ impl HashChangeEvent {
|
|||
pub fn Constructor(window: &Window,
|
||||
type_: DOMString,
|
||||
init: &HashChangeEventBinding::HashChangeEventInit)
|
||||
-> Fallible<Root<HashChangeEvent>> {
|
||||
-> Fallible<DomRoot<HashChangeEvent>> {
|
||||
Ok(HashChangeEvent::new(window,
|
||||
Atom::from(type_),
|
||||
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::iterable::Iterable;
|
||||
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::globalscope::GlobalScope;
|
||||
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)
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#dom-headers
|
||||
pub fn Constructor(global: &GlobalScope, init: Option<HeadersInit>)
|
||||
-> Fallible<Root<Headers>> {
|
||||
-> Fallible<DomRoot<Headers>> {
|
||||
let dom_headers_new = Headers::new(global);
|
||||
dom_headers_new.fill(init)?;
|
||||
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);
|
||||
headers_for_request.guard.set(Guard::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);
|
||||
headers_for_response.guard.set(Guard::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::inheritance::Castable;
|
||||
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::window::Window;
|
||||
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),
|
||||
window,
|
||||
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::NodeBinding::NodeMethods;
|
||||
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::document::Document;
|
||||
use dom::domtokenlist::DOMTokenList;
|
||||
|
@ -56,7 +56,7 @@ impl HTMLAnchorElement {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn new(local_name: LocalName,
|
||||
prefix: Option<Prefix>,
|
||||
document: &Document) -> Root<HTMLAnchorElement> {
|
||||
document: &Document) -> DomRoot<HTMLAnchorElement> {
|
||||
Node::reflect_node(box HTMLAnchorElement::new_inherited(local_name, prefix, document),
|
||||
document,
|
||||
HTMLAnchorElementBinding::Wrap)
|
||||
|
@ -122,7 +122,7 @@ impl HTMLAnchorElementMethods for HTMLAnchorElement {
|
|||
}
|
||||
|
||||
// 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")))
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use dom::bindings::codegen::Bindings::HTMLAppletElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLAppletElementBinding::HTMLAppletElementMethods;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::document::Document;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
|
@ -33,7 +33,7 @@ impl HTMLAppletElement {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn new(local_name: LocalName,
|
||||
prefix: Option<Prefix>,
|
||||
document: &Document) -> Root<HTMLAppletElement> {
|
||||
document: &Document) -> DomRoot<HTMLAppletElement> {
|
||||
Node::reflect_node(box HTMLAppletElement::new_inherited(local_name, prefix, document),
|
||||
document,
|
||||
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::HTMLAreaElementMethods;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::root::{MutNullableDom, Root};
|
||||
use dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::document::Document;
|
||||
use dom::domtokenlist::DOMTokenList;
|
||||
|
@ -231,7 +231,7 @@ impl HTMLAreaElement {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn new(local_name: LocalName,
|
||||
prefix: Option<Prefix>,
|
||||
document: &Document) -> Root<HTMLAreaElement> {
|
||||
document: &Document) -> DomRoot<HTMLAreaElement> {
|
||||
Node::reflect_node(box HTMLAreaElement::new_inherited(local_name, prefix, document),
|
||||
document,
|
||||
HTMLAreaElementBinding::Wrap)
|
||||
|
@ -273,7 +273,7 @@ impl VirtualMethods for HTMLAreaElement {
|
|||
|
||||
impl HTMLAreaElementMethods for HTMLAreaElement {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-area-rellist
|
||||
fn RelList(&self) -> Root<DOMTokenList> {
|
||||
fn RelList(&self) -> DomRoot<DOMTokenList> {
|
||||
self.rel_list.or_init(|| {
|
||||
DOMTokenList::new(self.upcast(), &local_name!("rel"))
|
||||
})
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::HTMLAudioElementBinding;
|
||||
use dom::bindings::root::Root;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::document::Document;
|
||||
use dom::htmlmediaelement::HTMLMediaElement;
|
||||
use dom::node::Node;
|
||||
|
@ -28,7 +28,7 @@ impl HTMLAudioElement {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn new(local_name: LocalName,
|
||||
prefix: Option<Prefix>,
|
||||
document: &Document) -> Root<HTMLAudioElement> {
|
||||
document: &Document) -> DomRoot<HTMLAudioElement> {
|
||||
Node::reflect_node(box HTMLAudioElement::new_inherited(local_name, prefix, document),
|
||||
document,
|
||||
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