mirror of
https://github.com/servo/servo.git
synced 2025-06-25 01:24:37 +01:00
Implement Document::head()
Implementation details according to the specification below: http://www.whatwg.org/specs/web-apps/current-work/#dom-document-head This patch is for: https://github.com/mozilla/servo/issues/1465
This commit is contained in:
parent
608ee006ab
commit
17b35d52ff
4 changed files with 48 additions and 5 deletions
|
@ -101,7 +101,7 @@ partial interface Document {
|
|||
attribute DOMString title;
|
||||
// attribute DOMString dir;
|
||||
attribute HTMLElement? body;
|
||||
//(HTML only)readonly attribute HTMLHeadElement? head;
|
||||
readonly attribute HTMLHeadElement? head;
|
||||
//(HTML only)readonly attribute HTMLCollection images;
|
||||
//(HTML only)readonly attribute HTMLCollection embeds;
|
||||
//(HTML only)readonly attribute HTMLCollection plugins;
|
||||
|
|
|
@ -303,6 +303,15 @@ impl Document {
|
|||
}
|
||||
}
|
||||
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#dom-document-head
|
||||
pub fn GetHead(&self) -> Option<AbstractNode> {
|
||||
self.get_html_element().and_then(|root| {
|
||||
root.traverse_preorder().find(|child| {
|
||||
child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn GetBody(&self, _: AbstractDocument) -> Option<AbstractNode> {
|
||||
match self.get_html_element() {
|
||||
None => None,
|
||||
|
|
|
@ -34,12 +34,11 @@ impl HTMLDocument {
|
|||
|
||||
impl HTMLDocument {
|
||||
pub fn GetHead(&self) -> Option<AbstractNode> {
|
||||
match self.parent.GetDocumentElement() {
|
||||
None => None,
|
||||
Some(root) => root.traverse_preorder().find(|child| {
|
||||
self.parent.GetDocumentElement().and_then(|root| {
|
||||
root.traverse_preorder().find(|child| {
|
||||
child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn Images(&self) -> @mut HTMLCollection {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue