mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Bump html5ever to 0.2.4, <template> support!
The failing <img> test comes from the now-correct parsing of <font face> elements in SVG.
This commit is contained in:
parent
880364b56d
commit
a7476a758e
17 changed files with 117 additions and 55 deletions
|
@ -155,6 +155,9 @@ pub struct Document {
|
|||
reflow_timeout: Cell<Option<u64>>,
|
||||
/// The cached first `base` element with an `href` attribute.
|
||||
base_element: MutNullableHeap<JS<HTMLBaseElement>>,
|
||||
/// This field is set to the document itself for inert documents.
|
||||
/// https://html.spec.whatwg.org/multipage/#appropriate-template-contents-owner-document
|
||||
appropriate_template_contents_owner_document: MutNullableHeap<JS<Document>>,
|
||||
}
|
||||
|
||||
impl PartialEq for Document {
|
||||
|
@ -1058,6 +1061,7 @@ impl Document {
|
|||
current_parser: Default::default(),
|
||||
reflow_timeout: Cell::new(None),
|
||||
base_element: Default::default(),
|
||||
appropriate_template_contents_owner_document: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1106,6 +1110,23 @@ impl Document {
|
|||
.and_then(HTMLHtmlElementCast::to_ref)
|
||||
.map(Root::from_ref)
|
||||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#appropriate-template-contents-owner-document
|
||||
pub fn appropriate_template_contents_owner_document(&self) -> Root<Document> {
|
||||
self.appropriate_template_contents_owner_document.or_init(|| {
|
||||
let doctype = if self.is_html_document {
|
||||
IsHTMLDocument::HTMLDocument
|
||||
} else {
|
||||
IsHTMLDocument::NonHTMLDocument
|
||||
};
|
||||
let new_doc = Document::new(
|
||||
&*self.window(), None, doctype, None, None,
|
||||
DocumentSource::NotFromParser, DocumentLoader::new(&self.loader()));
|
||||
new_doc.appropriate_template_contents_owner_document.set(
|
||||
Some(JS::from_ref(&*new_doc)));
|
||||
new_doc
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,19 +2,25 @@
|
|||
* 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::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||
use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods;
|
||||
use dom::bindings::codegen::InheritTypes::HTMLTemplateElementDerived;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||
use dom::document::Document;
|
||||
use dom::documentfragment::DocumentFragment;
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{Node, NodeTypeId};
|
||||
use dom::node::{Node, NodeTypeId, document_from_node};
|
||||
use util::str::DOMString;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct HTMLTemplateElement {
|
||||
htmlelement: HTMLElement,
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#template-contents
|
||||
contents: MutNullableHeap<JS<DocumentFragment>>,
|
||||
}
|
||||
|
||||
impl HTMLTemplateElementDerived for EventTarget {
|
||||
|
@ -31,7 +37,8 @@ impl HTMLTemplateElement {
|
|||
document: &Document) -> HTMLTemplateElement {
|
||||
HTMLTemplateElement {
|
||||
htmlelement:
|
||||
HTMLElement::new_inherited(HTMLElementTypeId::HTMLTemplateElement, localName, prefix, document)
|
||||
HTMLElement::new_inherited(HTMLElementTypeId::HTMLTemplateElement, localName, prefix, document),
|
||||
contents: MutNullableHeap::new(None),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,3 +50,13 @@ impl HTMLTemplateElement {
|
|||
Node::reflect_node(box element, document, HTMLTemplateElementBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
impl HTMLTemplateElementMethods for HTMLTemplateElement {
|
||||
/// https://html.spec.whatwg.org/multipage/#dom-template-content
|
||||
fn Content(&self) -> Root<DocumentFragment> {
|
||||
self.contents.or_init(|| {
|
||||
let doc = document_from_node(self);
|
||||
doc.appropriate_template_contents_owner_document().CreateDocumentFragment()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,5 +5,5 @@
|
|||
|
||||
// https://www.whatwg.org/html/#htmltemplateelement
|
||||
interface HTMLTemplateElement : HTMLElement {
|
||||
//readonly attribute DocumentFragment content;
|
||||
readonly attribute DocumentFragment content;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue