mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Format script component
This commit is contained in:
parent
2ca7a13473
commit
c37a345dc9
357 changed files with 25485 additions and 18076 deletions
|
@ -37,9 +37,11 @@ impl DOMParser {
|
|||
}
|
||||
|
||||
pub fn new(window: &Window) -> DomRoot<DOMParser> {
|
||||
reflect_dom_object(Box::new(DOMParser::new_inherited(window)),
|
||||
window,
|
||||
DOMParserBinding::Wrap)
|
||||
reflect_dom_object(
|
||||
Box::new(DOMParser::new_inherited(window)),
|
||||
window,
|
||||
DOMParserBinding::Wrap,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn Constructor(window: &Window) -> Fallible<DomRoot<DOMParser>> {
|
||||
|
@ -49,51 +51,59 @@ impl DOMParser {
|
|||
|
||||
impl DOMParserMethods for DOMParser {
|
||||
// https://w3c.github.io/DOM-Parsing/#the-domparser-interface
|
||||
fn ParseFromString(&self,
|
||||
s: DOMString,
|
||||
ty: DOMParserBinding::SupportedType)
|
||||
-> Fallible<DomRoot<Document>> {
|
||||
fn ParseFromString(
|
||||
&self,
|
||||
s: DOMString,
|
||||
ty: DOMParserBinding::SupportedType,
|
||||
) -> Fallible<DomRoot<Document>> {
|
||||
let url = self.window.get_url();
|
||||
let content_type = ty.as_str().parse().expect("Supported type is not a MIME type");
|
||||
let content_type = ty
|
||||
.as_str()
|
||||
.parse()
|
||||
.expect("Supported type is not a MIME type");
|
||||
let doc = self.window.Document();
|
||||
let loader = DocumentLoader::new(&*doc.loader());
|
||||
match ty {
|
||||
Text_html => {
|
||||
let document = Document::new(&self.window,
|
||||
HasBrowsingContext::No,
|
||||
Some(url.clone()),
|
||||
doc.origin().clone(),
|
||||
IsHTMLDocument::HTMLDocument,
|
||||
Some(content_type),
|
||||
None,
|
||||
DocumentActivity::Inactive,
|
||||
DocumentSource::FromParser,
|
||||
loader,
|
||||
None,
|
||||
None,
|
||||
Default::default());
|
||||
let document = Document::new(
|
||||
&self.window,
|
||||
HasBrowsingContext::No,
|
||||
Some(url.clone()),
|
||||
doc.origin().clone(),
|
||||
IsHTMLDocument::HTMLDocument,
|
||||
Some(content_type),
|
||||
None,
|
||||
DocumentActivity::Inactive,
|
||||
DocumentSource::FromParser,
|
||||
loader,
|
||||
None,
|
||||
None,
|
||||
Default::default(),
|
||||
);
|
||||
ServoParser::parse_html_document(&document, s, url);
|
||||
document.set_ready_state(DocumentReadyState::Complete);
|
||||
Ok(document)
|
||||
}
|
||||
},
|
||||
Text_xml | Application_xml | Application_xhtml_xml => {
|
||||
let document = Document::new(&self.window,
|
||||
HasBrowsingContext::No,
|
||||
Some(url.clone()),
|
||||
doc.origin().clone(),
|
||||
IsHTMLDocument::NonHTMLDocument,
|
||||
Some(content_type),
|
||||
None,
|
||||
DocumentActivity::Inactive,
|
||||
DocumentSource::FromParser,
|
||||
loader,
|
||||
None,
|
||||
None,
|
||||
Default::default());
|
||||
let document = Document::new(
|
||||
&self.window,
|
||||
HasBrowsingContext::No,
|
||||
Some(url.clone()),
|
||||
doc.origin().clone(),
|
||||
IsHTMLDocument::NonHTMLDocument,
|
||||
Some(content_type),
|
||||
None,
|
||||
DocumentActivity::Inactive,
|
||||
DocumentSource::FromParser,
|
||||
loader,
|
||||
None,
|
||||
None,
|
||||
Default::default(),
|
||||
);
|
||||
ServoParser::parse_xml_document(&document, s, url);
|
||||
document.set_ready_state(DocumentReadyState::Complete);
|
||||
Ok(document)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue