Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Unified Diff: Source/core/dom/Document.cpp

Issue 151653004: Implemented Document.contentType (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: review comments Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 137ece01796830ffc0f0e1e5167997dbfafef7c6..af63ac2d13a1ff509a4ce80810c31cff471c9d8f 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -1221,6 +1221,26 @@ String Document::suggestedMIMEType() const
return String();
}
+void Document::setMimeType(const AtomicString& mimeType)
+{
+ m_mimeType = mimeType;
+}
+
+AtomicString Document::contentType() const
+{
+ if (!m_mimeType.isEmpty())
+ return m_mimeType;
+
+ if (DocumentLoader* documentLoader = loader())
+ return documentLoader->mimeType();
+
+ String mimeType = suggestedMIMEType();
+ if (!mimeType.isEmpty())
+ return AtomicString(mimeType);
+
+ return AtomicString("application/xml");
+}
+
Element* Document::elementFromPoint(int x, int y) const
{
if (!renderView())
@@ -3221,6 +3241,7 @@ void Document::cloneDataFromDocument(const Document& other)
setEncodingData(other.m_encodingData);
setContextFeatures(other.contextFeatures());
setSecurityOrigin(other.securityOrigin()->isolatedCopy());
+ setMimeType(other.contentType());
}
StyleSheetList* Document::styleSheets()

Powered by Google App Engine
This is Rietveld 408576698