Chromium Code Reviews| 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 c4fc7a9abb2c2a5ca6e493314d72089f4b227459..c7c27a9593893fee04b9ad50b69fe6c95202a382 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 \""); |
|
jsbell
2015/10/27 17:52:43
We could skip this if the encoding is the default
yosin_UTC9
2015/10/28 00:14:57
Really? I think default charset depends of Chrome'
jsbell
2015/10/28 18:16:55
Oh, good point. Always outputting seems sensible t
jsbell
2015/11/02 23:55:38
Done.
|
| + 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(); |
| @@ -414,7 +418,6 @@ void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet& styleSheet, const KUR |
| // FIXME: We should check whether a charset has been specified and if none was found add one. |
|
jsbell
2015/10/27 17:52:43
Not sure if the FIXME here is referring to the lac
yosin_UTC9
2015/10/30 01:57:01
Agree. This patch always adds @charset.
jsbell
2015/11/02 23:55:38
Done.
|
| 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()))); |