servo: Merge #5169 - Refactored optional argument "last_modified" for Document (from mschroeder:issue-4981); r=saneyuki

Fixes #4981

Source-Repo: https://github.com/servo/servo
Source-Revision: ccc6faa14787765485dae7ccd0976cd7e1764185
This commit is contained in:
Martin Schröder
2015-03-16 11:03:58 -06:00
parent 9d54446033
commit 5f93d37240
5 changed files with 23 additions and 22 deletions

View File

@@ -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()),