mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Implement safe rooting strategy via Unrooted, Root, JSRef, and JS.
This commit is contained in:
parent
ffdc3f5b32
commit
d7b96db33c
109 changed files with 1568 additions and 1326 deletions
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::InheritTypes::HTMLIFrameElementCast;
|
|||
use dom::bindings::codegen::InheritTypes::HTMLImageElementCast;
|
||||
use dom::bindings::codegen::InheritTypes::HTMLObjectElementCast;
|
||||
use dom::bindings::codegen::InheritTypes::HTMLStyleElementCast;
|
||||
use dom::bindings::js::JS;
|
||||
use dom::bindings::js::JSRef;
|
||||
use dom::element::Element;
|
||||
use dom::element::{ElementTypeId, HTMLImageElementTypeId};
|
||||
use dom::element::{HTMLIFrameElementTypeId, HTMLObjectElementTypeId, HTMLStyleElementTypeId};
|
||||
|
@ -62,7 +62,7 @@ pub trait VirtualMethods {
|
|||
}
|
||||
|
||||
/// Called on the parent when a node is added to its child list.
|
||||
fn child_inserted(&mut self, child: &JS<Node>) {
|
||||
fn child_inserted(&mut self, child: &JSRef<Node>) {
|
||||
match self.super_type() {
|
||||
Some(ref mut s) => s.child_inserted(child),
|
||||
_ => (),
|
||||
|
@ -74,31 +74,31 @@ pub trait VirtualMethods {
|
|||
/// method call on the trait object will invoke the corresponding method on the
|
||||
/// concrete type, propagating up the parent hierarchy unless otherwise
|
||||
/// interrupted.
|
||||
pub fn vtable_for<'a>(node: &JS<Node>) -> ~VirtualMethods: {
|
||||
pub fn vtable_for<'a>(node: &JSRef<Node>) -> ~VirtualMethods: {
|
||||
match node.get().type_id {
|
||||
ElementNodeTypeId(HTMLImageElementTypeId) => {
|
||||
let element: JS<HTMLImageElement> = HTMLImageElementCast::to(node).unwrap();
|
||||
~element as ~VirtualMethods:
|
||||
let element: &JSRef<HTMLImageElement> = HTMLImageElementCast::to_ref(node).unwrap();
|
||||
~element.clone() as ~VirtualMethods:
|
||||
}
|
||||
ElementNodeTypeId(HTMLIFrameElementTypeId) => {
|
||||
let element: JS<HTMLIFrameElement> = HTMLIFrameElementCast::to(node).unwrap();
|
||||
~element as ~VirtualMethods:
|
||||
let element: &JSRef<HTMLIFrameElement> = HTMLIFrameElementCast::to_ref(node).unwrap();
|
||||
~element.clone() as ~VirtualMethods:
|
||||
}
|
||||
ElementNodeTypeId(HTMLObjectElementTypeId) => {
|
||||
let element: JS<HTMLObjectElement> = HTMLObjectElementCast::to(node).unwrap();
|
||||
~element as ~VirtualMethods:
|
||||
let element: &JSRef<HTMLObjectElement> = HTMLObjectElementCast::to_ref(node).unwrap();
|
||||
~element.clone() as ~VirtualMethods:
|
||||
}
|
||||
ElementNodeTypeId(HTMLStyleElementTypeId) => {
|
||||
let element: JS<HTMLStyleElement> = HTMLStyleElementCast::to(node).unwrap();
|
||||
~element as ~VirtualMethods:
|
||||
let element: &JSRef<HTMLStyleElement> = HTMLStyleElementCast::to_ref(node).unwrap();
|
||||
~element.clone() as ~VirtualMethods:
|
||||
}
|
||||
ElementNodeTypeId(ElementTypeId) => {
|
||||
let element: JS<Element> = ElementCast::to(node).unwrap();
|
||||
~element as ~VirtualMethods:
|
||||
let element: &JSRef<Element> = ElementCast::to_ref(node).unwrap();
|
||||
~element.clone() as ~VirtualMethods:
|
||||
}
|
||||
ElementNodeTypeId(_) => {
|
||||
let element: JS<HTMLElement> = HTMLElementCast::to(node).unwrap();
|
||||
~element as ~VirtualMethods:
|
||||
let element: &JSRef<HTMLElement> = HTMLElementCast::to_ref(node).unwrap();
|
||||
~element.clone() as ~VirtualMethods:
|
||||
}
|
||||
_ => {
|
||||
~node.clone() as ~VirtualMethods:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue