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

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

Issue 332573003: Add missing null check in PageSerializer::serializeCSSStyleSheet() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | « Source/core/page/PageSerializer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/PageSerializer.cpp
diff --git a/Source/core/page/PageSerializer.cpp b/Source/core/page/PageSerializer.cpp
index 31549449cf3cdf357dd93512cc09a9bae731148d..d9c503590cc4b43184d401e4073e33c41069c0dd 100644
--- a/Source/core/page/PageSerializer.cpp
+++ b/Source/core/page/PageSerializer.cpp
@@ -242,13 +242,13 @@ void PageSerializer::serializeFrame(LocalFrame* frame)
HTMLLinkElement& linkElement = toHTMLLinkElement(element);
if (CSSStyleSheet* sheet = linkElement.sheet()) {
KURL url = document.completeURL(linkElement.getAttribute(HTMLNames::hrefAttr));
- serializeCSSStyleSheet(sheet, url);
+ serializeCSSStyleSheet(*sheet, url);
ASSERT(m_resourceURLs.contains(url));
}
} else if (isHTMLStyleElement(element)) {
HTMLStyleElement& styleElement = toHTMLStyleElement(element);
if (CSSStyleSheet* sheet = styleElement.sheet())
- serializeCSSStyleSheet(sheet, KURL());
+ serializeCSSStyleSheet(*sheet, KURL());
}
}
@@ -258,26 +258,27 @@ void PageSerializer::serializeFrame(LocalFrame* frame)
}
}
-void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet* styleSheet, const KURL& url)
+void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet& styleSheet, const KURL& url)
{
StringBuilder cssText;
- for (unsigned i = 0; i < styleSheet->length(); ++i) {
- CSSRule* rule = styleSheet->item(i);
+ 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)
+ if (i < styleSheet.length() - 1)
cssText.append("\n\n");
}
- ASSERT(styleSheet->ownerDocument());
- Document& document = *styleSheet->ownerDocument();
+ ASSERT(styleSheet.ownerDocument());
+ Document& document = *styleSheet.ownerDocument();
// Some rules have resources associated with them that we need to retrieve.
if (rule->type() == CSSRule::IMPORT_RULE) {
CSSImportRule* importRule = toCSSImportRule(rule);
KURL importURL = document.completeURL(importRule->href());
if (m_resourceURLs.contains(importURL))
continue;
- serializeCSSStyleSheet(importRule->styleSheet(), importURL);
+ if (importRule->styleSheet())
+ serializeCSSStyleSheet(*importRule->styleSheet(), importURL);
} else if (rule->type() == CSSRule::FONT_FACE_RULE) {
retrieveResourcesForProperties(&toCSSFontFaceRule(rule)->styleRule()->properties(), document);
} else if (rule->type() == CSSRule::STYLE_RULE) {
@@ -287,7 +288,7 @@ 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());
+ WTF::TextEncoding textEncoding(styleSheet.contents()->charset());
ASSERT(textEncoding.isValid());
String textString = cssText.toString();
CString text = textEncoding.normalizeAndEncode(textString, WTF::EntitiesForUnencodables);
« no previous file with comments | « Source/core/page/PageSerializer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698