mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Remove some duplication in XMLHttpRequest methods
This commit is contained in:
parent
99b346ac52
commit
2f54022761
1 changed files with 6 additions and 8 deletions
|
@ -1197,29 +1197,27 @@ impl XMLHttpRequest {
|
||||||
|
|
||||||
fn document_text_html(&self) -> Root<Document>{
|
fn document_text_html(&self) -> Root<Document>{
|
||||||
let charset = self.final_charset().unwrap_or(UTF_8);
|
let charset = self.final_charset().unwrap_or(UTF_8);
|
||||||
let wr = self.global();
|
let wr = self.global_scope();
|
||||||
let wr = wr.r();
|
|
||||||
let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap();
|
let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap();
|
||||||
let document = self.new_doc(IsHTMLDocument::HTMLDocument);
|
let document = self.new_doc(IsHTMLDocument::HTMLDocument);
|
||||||
// TODO: Disable scripting while parsing
|
// TODO: Disable scripting while parsing
|
||||||
parse_html(document.r(),
|
parse_html(document.r(),
|
||||||
DOMString::from(decoded),
|
DOMString::from(decoded),
|
||||||
wr.as_global_scope().get_url(),
|
wr.get_url(),
|
||||||
ParseContext::Owner(Some(wr.as_global_scope().pipeline_id())));
|
ParseContext::Owner(Some(wr.pipeline_id())));
|
||||||
document
|
document
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_xml(&self) -> Root<Document> {
|
fn handle_xml(&self) -> Root<Document> {
|
||||||
let charset = self.final_charset().unwrap_or(UTF_8);
|
let charset = self.final_charset().unwrap_or(UTF_8);
|
||||||
let wr = self.global();
|
let wr = self.global_scope();
|
||||||
let wr = wr.r();
|
|
||||||
let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap();
|
let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap();
|
||||||
let document = self.new_doc(IsHTMLDocument::NonHTMLDocument);
|
let document = self.new_doc(IsHTMLDocument::NonHTMLDocument);
|
||||||
// TODO: Disable scripting while parsing
|
// TODO: Disable scripting while parsing
|
||||||
parse_xml(document.r(),
|
parse_xml(document.r(),
|
||||||
DOMString::from(decoded),
|
DOMString::from(decoded),
|
||||||
wr.as_global_scope().get_url(),
|
wr.get_url(),
|
||||||
xml::ParseContext::Owner(Some(wr.as_global_scope().pipeline_id())));
|
xml::ParseContext::Owner(Some(wr.pipeline_id())));
|
||||||
document
|
document
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue