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