diff options
Diffstat (limited to 'WebCore/css/CSSStyleSheet.cpp')
-rw-r--r-- | WebCore/css/CSSStyleSheet.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/WebCore/css/CSSStyleSheet.cpp b/WebCore/css/CSSStyleSheet.cpp index 9bbcb8b..04df693 100644 --- a/WebCore/css/CSSStyleSheet.cpp +++ b/WebCore/css/CSSStyleSheet.cpp @@ -27,13 +27,30 @@ #include "CSSRuleList.h" #include "Document.h" #include "ExceptionCode.h" +#include "HTMLNames.h" #include "Node.h" +#include "SVGNames.h" #include "SecurityOrigin.h" #include "TextEncoding.h" #include <wtf/Deque.h> namespace WebCore { +#if !ASSERT_DISABLED +static bool isAcceptableCSSStyleSheetParent(Node* parentNode) +{ + // Only these nodes can be parents of StyleSheets, and they need to call clearOwnerNode() when moved out of document. + return !parentNode + || parentNode->isDocumentNode() + || parentNode->hasTagName(HTMLNames::linkTag) + || parentNode->hasTagName(HTMLNames::styleTag) +#if ENABLE(SVG) + || parentNode->hasTagName(SVGNames::styleTag) +#endif + || parentNode->nodeType() == Node::PROCESSING_INSTRUCTION_NODE; +} +#endif + CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const KURL& baseURL, const String& charset) : StyleSheet(parentSheet, href, baseURL) , m_document(parentSheet ? parentSheet->document() : 0) @@ -54,6 +71,7 @@ CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const KURL& b , m_isUserStyleSheet(false) , m_hasSyntacticallyValidCSSHeader(true) { + ASSERT(isAcceptableCSSStyleSheetParent(parentNode)); } CSSStyleSheet::CSSStyleSheet(CSSRule* ownerRule, const String& href, const KURL& baseURL, const String& charset) |