diff options
author | MechaXL <mechaxl@gmail.com> | 2014-08-20 15:09:01 -0500 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2014-09-04 13:44:02 +0200 |
commit | e2bfdb30a071069eca1658f755992ab9ca03bb26 (patch) | |
tree | 930f076f64c111763e2c3de647597bf66cf77398 /src/components/script/dom/document.rs | |
parent | f7877008d25fe3dad23430bbf108d0440079fa34 (diff) | |
download | servo-e2bfdb30a071069eca1658f755992ab9ca03bb26.tar.gz servo-e2bfdb30a071069eca1658f755992ab9ca03bb26.zip |
Implement document.lastModified (fixes #2972, #3127).
Diffstat (limited to 'src/components/script/dom/document.rs')
-rw-r--r-- | src/components/script/dom/document.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index 81fc5c62fbd..503f618384d 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -59,6 +59,7 @@ use std::collections::hashmap::HashMap; use std::ascii::StrAsciiExt; use std::cell::{Cell, RefCell}; use url::Url; +use time; #[deriving(PartialEq,Encodable)] pub enum IsHTMLDocument { @@ -74,6 +75,7 @@ pub struct Document { idmap: Traceable<RefCell<HashMap<DOMString, Vec<JS<Element>>>>>, implementation: Cell<Option<JS<DOMImplementation>>>, content_type: DOMString, + last_modified: Traceable<RefCell<Option<DOMString>>>, pub encoding_name: Traceable<RefCell<DOMString>>, pub is_html_document: bool, url: Untraceable<Url>, @@ -146,6 +148,7 @@ pub trait DocumentHelpers { fn url<'a>(&'a self) -> &'a 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); fn damage_and_reflow(&self, damage: DocumentDamageLevel); @@ -168,6 +171,10 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> { self.quirks_mode.deref().set(mode); } + fn set_last_modified(&self, value: DOMString) { + *self.last_modified.deref().borrow_mut() = Some(value); + } + fn set_encoding_name(&self, name: DOMString) { *self.encoding_name.deref().borrow_mut() = name; } @@ -278,6 +285,7 @@ impl Document { NonHTMLDocument => "application/xml".to_string() } }, + last_modified: Traceable::new(RefCell::new(None)), url: Untraceable::new(url), // http://dom.spec.whatwg.org/#concept-document-quirks quirks_mode: Untraceable::new(Cell::new(NoQuirks)), @@ -569,6 +577,14 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } } + // http://www.whatwg.org/html/#dom-document-lastmodified + fn LastModified(&self) -> DOMString { + match *self.last_modified.borrow() { + Some(ref t) => t.clone(), + None => time::now().strftime("%m/%d/%Y %H:%M:%S"), + } + } + // http://dom.spec.whatwg.org/#dom-document-createrange fn CreateRange(&self) -> Temporary<Range> { Range::new(self) |