mirror of
https://github.com/servo/servo.git
synced 2025-10-08 12:39:30 +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
|
@ -4,7 +4,7 @@
|
|||
|
||||
use dom::bindings::codegen::BindingDeclarations::HTMLFieldSetElementBinding;
|
||||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLFieldSetElementDerived, NodeCast};
|
||||
use dom::bindings::js::{JS, JSRef, RootCollection};
|
||||
use dom::bindings::js::{JS, JSRef, RootCollection, Unrooted};
|
||||
use dom::bindings::error::ErrorResult;
|
||||
use dom::document::Document;
|
||||
use dom::element::{Element, HTMLFieldSetElementTypeId};
|
||||
|
@ -37,7 +37,7 @@ impl HTMLFieldSetElement {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(localName: DOMString, document: &JSRef<Document>) -> JS<HTMLFieldSetElement> {
|
||||
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Unrooted<HTMLFieldSetElement> {
|
||||
let element = HTMLFieldSetElement::new_inherited(localName, document.unrooted());
|
||||
Node::reflect_node(~element, document, HTMLFieldSetElementBinding::Wrap)
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ impl HTMLFieldSetElement {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn GetForm(&self) -> Option<JS<HTMLFormElement>> {
|
||||
pub fn GetForm(&self) -> Option<Unrooted<HTMLFormElement>> {
|
||||
None
|
||||
}
|
||||
|
||||
|
@ -69,33 +69,32 @@ impl HTMLFieldSetElement {
|
|||
}
|
||||
|
||||
// http://www.whatwg.org/html/#dom-fieldset-elements
|
||||
pub fn Elements(&self, abstract_self: &JSRef<HTMLFieldSetElement>) -> JS<HTMLCollection> {
|
||||
pub fn Elements(&self, abstract_self: &JSRef<HTMLFieldSetElement>) -> Unrooted<HTMLCollection> {
|
||||
struct ElementsFilter;
|
||||
impl CollectionFilter for ElementsFilter {
|
||||
fn filter(&self, elem: &JSRef<Element>, root: &JSRef<Node>) -> bool {
|
||||
static tag_names: StaticStringVec = &["button", "fieldset", "input",
|
||||
"keygen", "object", "output", "select", "textarea"];
|
||||
let root: &JS<Element> = &ElementCast::to(&root.unrooted()).unwrap();
|
||||
&elem.unrooted() != root && tag_names.iter().any(|&tag_name| tag_name == elem.get().local_name)
|
||||
let root: &JSRef<Element> = ElementCast::to_ref(root).unwrap();
|
||||
elem != root && tag_names.iter().any(|&tag_name| tag_name == elem.get().local_name)
|
||||
}
|
||||
}
|
||||
let roots = RootCollection::new();
|
||||
let node: &JSRef<Node> = NodeCast::from_ref(abstract_self);
|
||||
let filter = ~ElementsFilter;
|
||||
let window = window_from_node(&node.unrooted()).root(&roots);
|
||||
HTMLCollection::create(&window.root_ref(), node, filter)
|
||||
let window = window_from_node(node).root(&roots);
|
||||
HTMLCollection::create(&*window, node, filter)
|
||||
}
|
||||
|
||||
pub fn WillValidate(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn Validity(&self) -> JS<ValidityState> {
|
||||
pub fn Validity(&self) -> Unrooted<ValidityState> {
|
||||
let roots = RootCollection::new();
|
||||
let doc = self.htmlelement.element.node.owner_doc();
|
||||
let doc = doc.get();
|
||||
let window = doc.window.root(&roots);
|
||||
ValidityState::new(&window.root_ref())
|
||||
let doc = self.htmlelement.element.node.owner_doc().root(&roots);
|
||||
let window = doc.deref().window.root(&roots);
|
||||
ValidityState::new(&*window)
|
||||
}
|
||||
|
||||
pub fn ValidationMessage(&self) -> DOMString {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue