aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/document.rs
diff options
context:
space:
mode:
authorNupur Baghel <nupurbaghel@gmail.com>2018-02-07 16:41:19 +0530
committerNupur Baghel <nupurbaghel@gmail.com>2018-02-09 09:32:56 +0530
commitd02422408e43ee279da81c091dd295e199d6b842 (patch)
treeea047bb3a0599856c3018e478953edd78b5d1d28 /components/script/dom/document.rs
parent1662fd735731fcdd6184b4b89f8eb704357fd102 (diff)
downloadservo-d02422408e43ee279da81c091dd295e199d6b842.tar.gz
servo-d02422408e43ee279da81c091dd295e199d6b842.zip
Updated content_type of Document and XMLDocument from DOCString to Mime
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r--components/script/dom/document.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 436d4e71d1a..d51af513c4c 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -98,6 +98,7 @@ use ipc_channel::ipc::{self, IpcSender};
use js::jsapi::{JSContext, JSObject, JSRuntime};
use js::jsapi::JS_GetRuntime;
use metrics::{InteractiveFlag, InteractiveMetrics, InteractiveWindow, ProfilerMetadataFactory, ProgressiveWebMetric};
+use mime::{Mime, TopLevel, SubLevel};
use msg::constellation_msg::{BrowsingContextId, Key, KeyModifiers, KeyState, TopLevelBrowsingContextId};
use net_traits::{FetchResponseMsg, IpcSend, ReferrerPolicy};
use net_traits::CookieSource::NonHTTP;
@@ -236,7 +237,8 @@ pub struct Document {
node: Node,
window: Dom<Window>,
implementation: MutNullableDom<DOMImplementation>,
- content_type: DOMString,
+ #[ignore_malloc_size_of = "type from external crate"]
+ content_type: Mime,
last_modified: Option<String>,
encoding: Cell<&'static Encoding>,
has_browsing_context: bool,
@@ -2197,7 +2199,7 @@ impl Document {
url: Option<ServoUrl>,
origin: MutableOrigin,
is_html_document: IsHTMLDocument,
- content_type: Option<DOMString>,
+ content_type: Option<Mime>,
last_modified: Option<String>,
activity: DocumentActivity,
source: DocumentSource,
@@ -2222,12 +2224,12 @@ impl Document {
has_browsing_context: has_browsing_context == HasBrowsingContext::Yes,
implementation: Default::default(),
content_type: match content_type {
- Some(string) => string,
- None => DOMString::from(match is_html_document {
+ Some(mime_data) => mime_data,
+ None => Mime::from(match is_html_document {
// https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
- IsHTMLDocument::HTMLDocument => "text/html",
+ IsHTMLDocument::HTMLDocument => Mime(TopLevel::Text, SubLevel::Html, vec![]),
// https://dom.spec.whatwg.org/#concept-document-content-type
- IsHTMLDocument::NonHTMLDocument => "application/xml",
+ IsHTMLDocument::NonHTMLDocument => Mime(TopLevel::Application, SubLevel::Xml, vec![]),
}),
},
last_modified: last_modified,
@@ -2339,7 +2341,7 @@ impl Document {
url: Option<ServoUrl>,
origin: MutableOrigin,
doctype: IsHTMLDocument,
- content_type: Option<DOMString>,
+ content_type: Option<Mime>,
last_modified: Option<String>,
activity: DocumentActivity,
source: DocumentSource,
@@ -2889,7 +2891,7 @@ impl DocumentMethods for Document {
// https://dom.spec.whatwg.org/#dom-document-content_type
fn ContentType(&self) -> DOMString {
- self.content_type.clone()
+ DOMString::from(self.content_type.to_string())
}
// https://dom.spec.whatwg.org/#dom-document-doctype
@@ -2969,7 +2971,8 @@ impl DocumentMethods for Document {
local_name.make_ascii_lowercase();
}
- let ns = if self.is_html_document || self.content_type == "application/xhtml+xml" {
+ let is_xhtml = self.content_type.0 == TopLevel::Application && self.content_type.1.as_str() == "xhtml+xml";
+ let ns = if self.is_html_document || is_xhtml {
ns!(html)
} else {
ns!()