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

Unified Diff: third_party/WebKit/Source/core/frame/FrameSerializer.cpp

Issue 2397983002: MHTML saving optimization: don't generate CSS code that will be discarded. (Closed)
Patch Set: Initial upload Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/frame/FrameSerializer.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameSerializer.cpp b/third_party/WebKit/Source/core/frame/FrameSerializer.cpp
index d1bf4cba20e6f4314bd41c492e9f2a175b5d358f..a028cf652fbf8eec3cdacd420f5ecdb5a60350a9 100644
--- a/third_party/WebKit/Source/core/frame/FrameSerializer.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameSerializer.cpp
@@ -336,26 +336,28 @@ void FrameSerializer::serializeCSSStyleSheet(CSSStyleSheet& styleSheet,
m_isSerializingCss = true;
cssStartTime = monotonicallyIncreasingTime();
}
+ bool willAppendResource = shouldAddURL(url);
+
+ if (willAppendResource) {
+ StringBuilder cssText;
+ cssText.append("@charset \"");
+ cssText.append(styleSheet.contents()->charset().lower());
+ cssText.append("\";\n\n");
+
+ for (unsigned i = 0; i < styleSheet.length(); ++i) {
+ CSSRule* rule = styleSheet.item(i);
+ String itemText = rule->cssText();
+ if (!itemText.isEmpty()) {
+ cssText.append(itemText);
+ if (i < styleSheet.length() - 1)
+ cssText.append("\n\n");
+ }
- StringBuilder cssText;
- cssText.append("@charset \"");
- cssText.append(styleSheet.contents()->charset().lower());
- cssText.append("\";\n\n");
-
- for (unsigned i = 0; i < styleSheet.length(); ++i) {
- CSSRule* rule = styleSheet.item(i);
- String itemText = rule->cssText();
- if (!itemText.isEmpty()) {
- cssText.append(itemText);
- if (i < styleSheet.length() - 1)
- cssText.append("\n\n");
+ // Some rules have resources associated with them that we need to
+ // retrieve.
+ serializeCSSRule(rule);
}
- // Some rules have resources associated with them that we need to retrieve.
- serializeCSSRule(rule);
- }
-
- if (shouldAddURL(url)) {
WTF::TextEncoding textEncoding(styleSheet.contents()->charset());
ASSERT(textEncoding.isValid());
String textString = cssText.toString();
@@ -365,6 +367,10 @@ void FrameSerializer::serializeCSSStyleSheet(CSSStyleSheet& styleSheet,
SerializedResource(url, String("text/css"),
SharedBuffer::create(text.data(), text.length())));
m_resourceURLs.add(url);
+ } else {
+ // Even if no text is needed, associated resources must be fetched.
Łukasz Anforowicz 2016/10/06 17:21:55 Today if 2 frames serialize CSS with the same URIs
carlosk 2016/10/06 18:07:24 I think the process you are describing is the comb
carlosk 2016/10/07 18:47:29 After an offline talk I understood lukasza@'s sugg
+ for (unsigned i = 0; i < styleSheet.length(); ++i)
+ serializeCSSRule(styleSheet.item(i));
}
if (cssStartTime != 0) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698