mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
auto merge of #5169 : mschroeder/servo/issue-4981, r=saneyuki
Fixes #4981
This commit is contained in:
commit
ccc6faa147
5 changed files with 23 additions and 22 deletions
|
@ -102,7 +102,7 @@ pub struct Document {
|
|||
implementation: MutNullableJS<DOMImplementation>,
|
||||
location: MutNullableJS<Location>,
|
||||
content_type: DOMString,
|
||||
last_modified: DOMRefCell<Option<DOMString>>,
|
||||
last_modified: Option<DOMString>,
|
||||
encoding_name: DOMRefCell<DOMString>,
|
||||
is_html_document: bool,
|
||||
url: Url,
|
||||
|
@ -197,7 +197,6 @@ pub trait DocumentHelpers<'a> {
|
|||
fn url(self) -> Url;
|
||||
fn quirks_mode(self) -> QuirksMode;
|
||||
fn set_quirks_mode(self, mode: QuirksMode);
|
||||
fn set_last_modified(self, value: DOMString);
|
||||
fn set_encoding_name(self, name: DOMString);
|
||||
fn content_changed(self, node: JSRef<Node>, damage: NodeDamage);
|
||||
fn content_and_heritage_changed(self, node: JSRef<Node>, damage: NodeDamage);
|
||||
|
@ -278,10 +277,6 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_last_modified(self, value: DOMString) {
|
||||
*self.last_modified.borrow_mut() = Some(value);
|
||||
}
|
||||
|
||||
fn set_encoding_name(self, name: DOMString) {
|
||||
*self.encoding_name.borrow_mut() = name;
|
||||
}
|
||||
|
@ -704,6 +699,7 @@ impl Document {
|
|||
url: Option<Url>,
|
||||
is_html_document: IsHTMLDocument,
|
||||
content_type: Option<DOMString>,
|
||||
last_modified: Option<DOMString>,
|
||||
source: DocumentSource) -> Document {
|
||||
let url = url.unwrap_or_else(|| Url::parse("about:blank").unwrap());
|
||||
|
||||
|
@ -728,7 +724,7 @@ impl Document {
|
|||
IsHTMLDocument::NonHTMLDocument => "application/xml".to_owned()
|
||||
}
|
||||
},
|
||||
last_modified: DOMRefCell::new(None),
|
||||
last_modified: last_modified,
|
||||
url: url,
|
||||
// http://dom.spec.whatwg.org/#concept-document-quirks
|
||||
quirks_mode: Cell::new(NoQuirks),
|
||||
|
@ -754,16 +750,18 @@ impl Document {
|
|||
pub fn Constructor(global: GlobalRef) -> Fallible<Temporary<Document>> {
|
||||
Ok(Document::new(global.as_window(), None,
|
||||
IsHTMLDocument::NonHTMLDocument, None,
|
||||
DocumentSource::NotFromParser))
|
||||
None, DocumentSource::NotFromParser))
|
||||
}
|
||||
|
||||
pub fn new(window: JSRef<Window>,
|
||||
url: Option<Url>,
|
||||
doctype: IsHTMLDocument,
|
||||
content_type: Option<DOMString>,
|
||||
last_modified: Option<DOMString>,
|
||||
source: DocumentSource) -> Temporary<Document> {
|
||||
let document = reflect_dom_object(box Document::new_inherited(window, url, doctype,
|
||||
content_type, source),
|
||||
content_type, last_modified,
|
||||
source),
|
||||
GlobalRef::Window(window),
|
||||
DocumentBinding::Wrap).root();
|
||||
|
||||
|
@ -1063,7 +1061,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
|
||||
// http://www.whatwg.org/html/#dom-document-lastmodified
|
||||
fn LastModified(self) -> DOMString {
|
||||
match *self.last_modified.borrow() {
|
||||
match self.last_modified {
|
||||
Some(ref t) => t.clone(),
|
||||
None => format!("{}", time::now().strftime("%m/%d/%Y %H:%M:%S").unwrap()),
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
|
|||
|
||||
// Step 1.
|
||||
let doc = Document::new(win.r(), None, IsHTMLDocument::NonHTMLDocument,
|
||||
None, DocumentSource::NotFromParser).root();
|
||||
None, None, DocumentSource::NotFromParser).root();
|
||||
// Step 2-3.
|
||||
let maybe_elem = if qname.is_empty() {
|
||||
None
|
||||
|
@ -119,7 +119,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
|
|||
let win = document.r().window().root();
|
||||
|
||||
// Step 1-2.
|
||||
let doc = Document::new(win.r(), None, IsHTMLDocument::HTMLDocument, None,
|
||||
let doc = Document::new(win.r(), None, IsHTMLDocument::HTMLDocument, None, None,
|
||||
DocumentSource::NotFromParser).root();
|
||||
let doc_node: JSRef<Node> = NodeCast::from_ref(doc.r());
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ impl<'a> DOMParserMethods for JSRef<'a, DOMParser> {
|
|||
let document = Document::new(window.r(), Some(url.clone()),
|
||||
IsHTMLDocument::HTMLDocument,
|
||||
Some(content_type),
|
||||
None,
|
||||
DocumentSource::FromParser).root();
|
||||
parse_html(document.r(), HTMLInput::InputString(s), &url);
|
||||
document.r().set_ready_state(DocumentReadyState::Complete);
|
||||
|
@ -66,6 +67,7 @@ impl<'a> DOMParserMethods for JSRef<'a, DOMParser> {
|
|||
Ok(Document::new(window.r(), Some(url.clone()),
|
||||
IsHTMLDocument::NonHTMLDocument,
|
||||
Some(content_type),
|
||||
None,
|
||||
DocumentSource::NotFromParser))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1576,7 +1576,7 @@ impl Node {
|
|||
let window = document.window().root();
|
||||
let document = Document::new(window.r(), Some(document.url()),
|
||||
is_html_doc, None,
|
||||
DocumentSource::NotFromParser);
|
||||
None, DocumentSource::NotFromParser);
|
||||
NodeCast::from_temporary(document)
|
||||
},
|
||||
NodeTypeId::Element(..) => {
|
||||
|
|
|
@ -66,6 +66,7 @@ use net::storage_task::StorageTask;
|
|||
use string_cache::Atom;
|
||||
use util::geometry::to_frac_px;
|
||||
use util::smallvec::SmallVec;
|
||||
use util::str::DOMString;
|
||||
use util::task::{spawn_named, spawn_named_with_send_on_failure};
|
||||
use util::task_state;
|
||||
|
||||
|
@ -979,19 +980,19 @@ impl ScriptTask {
|
|||
incomplete.subpage_id.map(|s| s.1),
|
||||
incomplete.window_size).root();
|
||||
|
||||
let document = Document::new(window.r(), Some(final_url.clone()),
|
||||
IsHTMLDocument::HTMLDocument, None,
|
||||
let last_modified: Option<DOMString> = response.metadata.headers.as_ref().and_then(|headers| {
|
||||
headers.get().map(|&LastModified(ref tm)| dom_last_modified(tm))
|
||||
});
|
||||
|
||||
let document = Document::new(window.r(),
|
||||
Some(final_url.clone()),
|
||||
IsHTMLDocument::HTMLDocument,
|
||||
None,
|
||||
last_modified,
|
||||
DocumentSource::FromParser).root();
|
||||
|
||||
window.r().init_browser_context(document.r(), frame_element.r());
|
||||
|
||||
let last_modified = response.metadata.headers.as_ref().and_then(|headers| {
|
||||
headers.get().map(|&LastModified(ref tm)| tm.clone())
|
||||
});
|
||||
if let Some(tm) = last_modified {
|
||||
document.r().set_last_modified(dom_last_modified(&tm));
|
||||
}
|
||||
|
||||
// Create the root frame
|
||||
page.set_frame(Some(Frame {
|
||||
document: JS::from_rooted(document.r()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue