summaryrefslogtreecommitdiffstats
path: root/WebCore/css/StyleSheet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/css/StyleSheet.cpp')
-rw-r--r--WebCore/css/StyleSheet.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/WebCore/css/StyleSheet.cpp b/WebCore/css/StyleSheet.cpp
index 4f20a20..854b63c 100644
--- a/WebCore/css/StyleSheet.cpp
+++ b/WebCore/css/StyleSheet.cpp
@@ -20,10 +20,29 @@
#include "config.h"
#include "StyleSheet.h"
+#include "HTMLNames.h"
#include "MediaList.h"
+#include "Node.h"
+#include "SVGNames.h"
namespace WebCore {
+#if !ASSERT_DISABLED
+static bool isAcceptableStyleSheetParent(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)
+ || parentNode->nodeType() == Node::PROCESSING_INSTRUCTION_NODE
+#if ENABLE(SVG)
+ || parentNode->hasTagName(SVGNames::styleTag)
+#endif
+ ;
+}
+#endif
+
StyleSheet::StyleSheet(StyleSheet* parentSheet, const String& originalURL, const KURL& finalURL)
: StyleList(parentSheet)
, m_parentNode(0)
@@ -40,6 +59,7 @@ StyleSheet::StyleSheet(Node* parentNode, const String& originalURL, const KURL&
, m_finalURL(finalURL)
, m_disabled(false)
{
+ ASSERT(isAcceptableStyleSheetParent(parentNode));
}
StyleSheet::StyleSheet(StyleBase* owner, const String& originalURL, const KURL& finalURL)