Chromium Code Reviews

Unified Diff: third_party/WebKit/Source/core/page/PageSerializer.cpp

Issue 1424503006: Page Serializer: Specify encoding for serialized CSS files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nfc-css
Patch Set: Review feedback Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/tests/PageSerializerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/page/PageSerializer.cpp
diff --git a/third_party/WebKit/Source/core/page/PageSerializer.cpp b/third_party/WebKit/Source/core/page/PageSerializer.cpp
index 2c395efe5cb3fe8639465467bddf775269af8d69..28ac4e0564ee129c437ae60281354dd5e06b5697 100644
--- a/third_party/WebKit/Source/core/page/PageSerializer.cpp
+++ b/third_party/WebKit/Source/core/page/PageSerializer.cpp
@@ -397,6 +397,10 @@ void PageSerializer::serializeFrame(LocalFrame* frame)
void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet& styleSheet, const KURL& url)
{
StringBuilder cssText;
+ cssText.appendLiteral("@charset \"");
+ cssText.append(styleSheet.contents()->charset().lower());
+ cssText.appendLiteral("\";\n\n");
+
for (unsigned i = 0; i < styleSheet.length(); ++i) {
CSSRule* rule = styleSheet.item(i);
String itemText = rule->cssText();
@@ -411,10 +415,8 @@ void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet& styleSheet, const KUR
}
if (url.isValid() && !m_resourceURLs.contains(url)) {
- // FIXME: We should check whether a charset has been specified and if none was found add one.
WTF::TextEncoding textEncoding(styleSheet.contents()->charset());
ASSERT(textEncoding.isValid());
- // TODO(jsbell): Ensure @charset is written out if non-UTF-8.
String textString = cssText.toString();
CString text = textEncoding.encode(textString, WTF::EntitiesForUnencodables);
m_resources->append(SerializedResource(url, String("text/css"), SharedBuffer::create(text.data(), text.length())));
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/tests/PageSerializerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine