From 49233e234e5c787396cadb2cea33b31ae0cd65c1 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 20 Jun 2012 13:01:08 +0200 Subject: Imported WebKit commit 3a8c29f35d00659d2ce7a0ccdfa8304f14e82327 (http://svn.webkit.org/repository/webkit/trunk@120813) New snapshot with Windows build fixes --- Source/WebCore/html/HTMLStyleElement.cpp | 78 ++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 24 deletions(-) (limited to 'Source/WebCore/html/HTMLStyleElement.cpp') diff --git a/Source/WebCore/html/HTMLStyleElement.cpp b/Source/WebCore/html/HTMLStyleElement.cpp index 67ddceb4f..e2189e96b 100644 --- a/Source/WebCore/html/HTMLStyleElement.cpp +++ b/Source/WebCore/html/HTMLStyleElement.cpp @@ -25,13 +25,14 @@ #include "HTMLStyleElement.h" #include "Attribute.h" -#include "ContextEnabledFeatures.h" +#include "ContextFeatures.h" #include "Document.h" #include "Event.h" #include "EventSender.h" #include "HTMLNames.h" #include "ScriptEventListener.h" #include "ScriptableDocumentParser.h" +#include "ShadowRoot.h" #include "StyleSheetContents.h" namespace WebCore { @@ -50,7 +51,7 @@ inline HTMLStyleElement::HTMLStyleElement(const QualifiedName& tagName, Document , m_firedLoad(false) , m_loadedSheet(false) #if ENABLE(STYLE_SCOPED) - , m_isRegisteredWithScopingNode(false) + , m_scopedStyleRegistrationState(NotRegistered) #endif { ASSERT(hasTagName(styleTag)); @@ -58,8 +59,8 @@ inline HTMLStyleElement::HTMLStyleElement(const QualifiedName& tagName, Document HTMLStyleElement::~HTMLStyleElement() { - // During tear-down, willRemove isn't called, so m_isRegisteredWithScopingNode may still be set here. - // Therefore we can't ASSERT(!m_isRegisteredWithScopingNode). + // During tear-down, willRemove isn't called, so m_scopedStyleRegistrationState may still be RegisteredAsScoped or RegisteredInShadowRoot here. + // Therefore we can't ASSERT(m_scopedStyleRegistrationState == NotRegistered). StyleElement::clearDocumentData(document(), this); styleLoadEventSender().cancelEvent(this); @@ -79,17 +80,42 @@ void HTMLStyleElement::parseAttribute(const Attribute& attribute) else if (attribute.name() == onerrorAttr) setAttributeEventListener(eventNames().errorEvent, createAttributeEventListener(this, attribute)); #if ENABLE(STYLE_SCOPED) - else if (attribute.name() == scopedAttr) { - if (!attribute.isNull() && !m_isRegisteredWithScopingNode && inDocument()) - registerWithScopingNode(); - else if (attribute.isNull() && m_isRegisteredWithScopingNode) - unregisterWithScopingNode(); - } + else if (attribute.name() == scopedAttr) + scopedAttributeChanged(!attribute.isNull()); #endif else HTMLElement::parseAttribute(attribute); } +#if ENABLE(STYLE_SCOPED) +void HTMLStyleElement::scopedAttributeChanged(bool scoped) +{ + if (!inDocument()) + return; + + if (scoped) { + // As any