mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
auto merge of #2354 : glennw/servo/issue-2332, r=metajack
This commit is contained in:
commit
27bdc580ed
5 changed files with 16 additions and 16 deletions
|
@ -5281,7 +5281,7 @@ class GlobalGenRoots():
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn from_unrooted<T: ${fromBound}+Reflectable>(derived: Temporary<T>) -> Temporary<Self> {
|
fn from_temporary<T: ${fromBound}+Reflectable>(derived: Temporary<T>) -> Temporary<Self> {
|
||||||
unsafe { derived.transmute() }
|
unsafe { derived.transmute() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -535,8 +535,8 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
|
|
||||||
match interface.to_ascii_lower().as_slice() {
|
match interface.to_ascii_lower().as_slice() {
|
||||||
// FIXME: Implement CustomEvent (http://dom.spec.whatwg.org/#customevent)
|
// FIXME: Implement CustomEvent (http://dom.spec.whatwg.org/#customevent)
|
||||||
"uievents" | "uievent" => Ok(EventCast::from_unrooted(UIEvent::new(&*window))),
|
"uievents" | "uievent" => Ok(EventCast::from_temporary(UIEvent::new(&*window))),
|
||||||
"mouseevents" | "mouseevent" => Ok(EventCast::from_unrooted(MouseEvent::new(&*window))),
|
"mouseevents" | "mouseevent" => Ok(EventCast::from_temporary(MouseEvent::new(&*window))),
|
||||||
"htmlevents" | "events" | "event" => Ok(Event::new(&*window)),
|
"htmlevents" | "events" | "event" => Ok(Event::new(&*window)),
|
||||||
_ => Err(NotSupported)
|
_ => Err(NotSupported)
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,12 +135,12 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
|
||||||
|
|
||||||
{
|
{
|
||||||
// Step 4.
|
// Step 4.
|
||||||
let mut doc_html = NodeCast::from_unrooted(HTMLHtmlElement::new("html".to_owned(), &*doc)).root();
|
let mut doc_html = NodeCast::from_temporary(HTMLHtmlElement::new("html".to_owned(), &*doc)).root();
|
||||||
assert!(doc_node.AppendChild(&mut *doc_html).is_ok());
|
assert!(doc_node.AppendChild(&mut *doc_html).is_ok());
|
||||||
|
|
||||||
{
|
{
|
||||||
// Step 5.
|
// Step 5.
|
||||||
let mut doc_head = NodeCast::from_unrooted(HTMLHeadElement::new("head".to_owned(), &*doc)).root();
|
let mut doc_head = NodeCast::from_temporary(HTMLHeadElement::new("head".to_owned(), &*doc)).root();
|
||||||
assert!(doc_html.AppendChild(&mut *doc_head).is_ok());
|
assert!(doc_html.AppendChild(&mut *doc_head).is_ok());
|
||||||
|
|
||||||
// Step 6.
|
// Step 6.
|
||||||
|
@ -148,7 +148,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
|
||||||
None => (),
|
None => (),
|
||||||
Some(title_str) => {
|
Some(title_str) => {
|
||||||
// Step 6.1.
|
// Step 6.1.
|
||||||
let mut doc_title = NodeCast::from_unrooted(HTMLTitleElement::new("title".to_owned(), &*doc)).root();
|
let mut doc_title = NodeCast::from_temporary(HTMLTitleElement::new("title".to_owned(), &*doc)).root();
|
||||||
assert!(doc_head.AppendChild(&mut *doc_title).is_ok());
|
assert!(doc_head.AppendChild(&mut *doc_title).is_ok());
|
||||||
|
|
||||||
// Step 6.2.
|
// Step 6.2.
|
||||||
|
|
|
@ -1229,17 +1229,17 @@ impl Node {
|
||||||
let doctype = DocumentType::new(doctype.name.clone(),
|
let doctype = DocumentType::new(doctype.name.clone(),
|
||||||
Some(doctype.public_id.clone()),
|
Some(doctype.public_id.clone()),
|
||||||
Some(doctype.system_id.clone()), &*document);
|
Some(doctype.system_id.clone()), &*document);
|
||||||
NodeCast::from_unrooted(doctype)
|
NodeCast::from_temporary(doctype)
|
||||||
},
|
},
|
||||||
DocumentFragmentNodeTypeId => {
|
DocumentFragmentNodeTypeId => {
|
||||||
let doc_fragment = DocumentFragment::new(&*document);
|
let doc_fragment = DocumentFragment::new(&*document);
|
||||||
NodeCast::from_unrooted(doc_fragment)
|
NodeCast::from_temporary(doc_fragment)
|
||||||
},
|
},
|
||||||
CommentNodeTypeId => {
|
CommentNodeTypeId => {
|
||||||
let comment: &JSRef<Comment> = CommentCast::to_ref(node).unwrap();
|
let comment: &JSRef<Comment> = CommentCast::to_ref(node).unwrap();
|
||||||
let comment = comment.deref();
|
let comment = comment.deref();
|
||||||
let comment = Comment::new(comment.characterdata.data.clone(), &*document);
|
let comment = Comment::new(comment.characterdata.data.clone(), &*document);
|
||||||
NodeCast::from_unrooted(comment)
|
NodeCast::from_temporary(comment)
|
||||||
},
|
},
|
||||||
DocumentNodeTypeId => {
|
DocumentNodeTypeId => {
|
||||||
let document: &JSRef<Document> = DocumentCast::to_ref(node).unwrap();
|
let document: &JSRef<Document> = DocumentCast::to_ref(node).unwrap();
|
||||||
|
@ -1250,26 +1250,26 @@ impl Node {
|
||||||
let window = document.window.root();
|
let window = document.window.root();
|
||||||
let document = Document::new(&*window, Some(document.url().clone()),
|
let document = Document::new(&*window, Some(document.url().clone()),
|
||||||
is_html_doc, None);
|
is_html_doc, None);
|
||||||
NodeCast::from_unrooted(document)
|
NodeCast::from_temporary(document)
|
||||||
},
|
},
|
||||||
ElementNodeTypeId(..) => {
|
ElementNodeTypeId(..) => {
|
||||||
let element: &JSRef<Element> = ElementCast::to_ref(node).unwrap();
|
let element: &JSRef<Element> = ElementCast::to_ref(node).unwrap();
|
||||||
let element = element.deref();
|
let element = element.deref();
|
||||||
let element = build_element_from_tag(element.local_name.clone(), &*document);
|
let element = build_element_from_tag(element.local_name.clone(), &*document);
|
||||||
NodeCast::from_unrooted(element)
|
NodeCast::from_temporary(element)
|
||||||
},
|
},
|
||||||
TextNodeTypeId => {
|
TextNodeTypeId => {
|
||||||
let text: &JSRef<Text> = TextCast::to_ref(node).unwrap();
|
let text: &JSRef<Text> = TextCast::to_ref(node).unwrap();
|
||||||
let text = text.deref();
|
let text = text.deref();
|
||||||
let text = Text::new(text.characterdata.data.clone(), &*document);
|
let text = Text::new(text.characterdata.data.clone(), &*document);
|
||||||
NodeCast::from_unrooted(text)
|
NodeCast::from_temporary(text)
|
||||||
},
|
},
|
||||||
ProcessingInstructionNodeTypeId => {
|
ProcessingInstructionNodeTypeId => {
|
||||||
let pi: &JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(node).unwrap();
|
let pi: &JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(node).unwrap();
|
||||||
let pi = pi.deref();
|
let pi = pi.deref();
|
||||||
let pi = ProcessingInstruction::new(pi.target.clone(),
|
let pi = ProcessingInstruction::new(pi.target.clone(),
|
||||||
pi.characterdata.data.clone(), &*document);
|
pi.characterdata.data.clone(), &*document);
|
||||||
NodeCast::from_unrooted(pi)
|
NodeCast::from_temporary(pi)
|
||||||
},
|
},
|
||||||
}.root();
|
}.root();
|
||||||
|
|
||||||
|
@ -1552,7 +1552,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let document = self.owner_doc().root();
|
let document = self.owner_doc().root();
|
||||||
Some(NodeCast::from_unrooted(document.deref().CreateTextNode(value)))
|
Some(NodeCast::from_temporary(document.deref().CreateTextNode(value)))
|
||||||
}.root();
|
}.root();
|
||||||
|
|
||||||
// Step 3.
|
// Step 3.
|
||||||
|
|
|
@ -40,7 +40,7 @@ macro_rules! handle_element(
|
||||||
$ctor: ident
|
$ctor: ident
|
||||||
$(, $arg:expr )*) => (
|
$(, $arg:expr )*) => (
|
||||||
if $string == $localName {
|
if $string == $localName {
|
||||||
return ElementCast::from_unrooted($ctor::new($localName, $document $(, $arg)*));
|
return ElementCast::from_temporary($ctor::new($localName, $document $(, $arg)*));
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -243,7 +243,7 @@ pub fn build_element_from_tag(tag: DOMString, document: &JSRef<Document>) -> Tem
|
||||||
handle_element!(document, tag, "ul", HTMLUListElement);
|
handle_element!(document, tag, "ul", HTMLUListElement);
|
||||||
handle_element!(document, tag, "video", HTMLVideoElement);
|
handle_element!(document, tag, "video", HTMLVideoElement);
|
||||||
|
|
||||||
return ElementCast::from_unrooted(HTMLUnknownElement::new(tag, document));
|
return ElementCast::from_temporary(HTMLUnknownElement::new(tag, document));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_html(page: &Page,
|
pub fn parse_html(page: &Page,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue