Chromium Code Reviews| 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) { |