summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLStyleElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/html/HTMLStyleElement.cpp')
-rw-r--r--Source/WebCore/html/HTMLStyleElement.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/Source/WebCore/html/HTMLStyleElement.cpp b/Source/WebCore/html/HTMLStyleElement.cpp
index 2070d56ce..b91126299 100644
--- a/Source/WebCore/html/HTMLStyleElement.cpp
+++ b/Source/WebCore/html/HTMLStyleElement.cpp
@@ -26,6 +26,8 @@
#include "Attribute.h"
#include "Document.h"
+#include "Event.h"
+#include "EventSender.h"
#include "HTMLNames.h"
#include "RuntimeEnabledFeatures.h"
#include "ScriptEventListener.h"
@@ -36,9 +38,17 @@ namespace WebCore {
using namespace HTMLNames;
+static StyleEventSender& styleLoadEventSender()
+{
+ DEFINE_STATIC_LOCAL(StyleEventSender, sharedLoadEventSender, (eventNames().loadEvent));
+ return sharedLoadEventSender;
+}
+
inline HTMLStyleElement::HTMLStyleElement(const QualifiedName& tagName, Document* document, bool createdByParser)
: HTMLElement(tagName, document)
, StyleElement(document, createdByParser)
+ , m_firedLoad(false)
+ , m_loadedSheet(false)
#if ENABLE(STYLE_SCOPED)
, m_isRegisteredWithScopingNode(false)
#endif
@@ -51,6 +61,8 @@ HTMLStyleElement::~HTMLStyleElement()
// During tear-down, willRemove isn't called, so m_isRegisteredWithScopingNode may still be set here.
// Therefore we can't ASSERT(!m_isRegisteredWithScopingNode).
StyleElement::clearDocumentData(document(), this);
+
+ styleLoadEventSender().cancelEvent(this);
}
PassRefPtr<HTMLStyleElement> HTMLStyleElement::create(const QualifiedName& tagName, Document* document, bool createdByParser)
@@ -62,6 +74,10 @@ void HTMLStyleElement::parseAttribute(Attribute* attr)
{
if (attr->name() == titleAttr && m_sheet)
m_sheet->setTitle(attr->value());
+ else if (attr->name() == onloadAttr)
+ setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
+ else if (attr->name() == onerrorAttr)
+ setAttributeEventListener(eventNames().errorEvent, createAttributeEventListener(this, attr));
#if ENABLE(STYLE_SCOPED)
else if (attr->name() == scopedAttr) {
if (!attr->isNull() && !m_isRegisteredWithScopingNode && inDocument())
@@ -148,7 +164,10 @@ void HTMLStyleElement::insertedIntoDocument()
void HTMLStyleElement::removedFromDocument()
{
#if ENABLE(STYLE_SCOPED)
- ASSERT(!m_isRegisteredWithScopingNode);
+ // In come cases on teardown willRemove is not called - test here for unregistering again
+ // FIXME: Do we need to bother?
+ if (m_isRegisteredWithScopingNode)
+ unregisterWithScopingNode();
#endif
HTMLElement::removedFromDocument();
StyleElement::removedFromDocument(document(), this);
@@ -171,8 +190,8 @@ void HTMLStyleElement::willRemove()
void HTMLStyleElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
{
- StyleElement::childrenChanged(this);
HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+ StyleElement::childrenChanged(this);
}
const AtomicString& HTMLStyleElement::media() const
@@ -212,6 +231,29 @@ Element* HTMLStyleElement::scopingElement() const
}
#endif // ENABLE(STYLE_SCOPED)
+void HTMLStyleElement::dispatchPendingLoadEvents()
+{
+ styleLoadEventSender().dispatchPendingEvents();
+}
+
+void HTMLStyleElement::dispatchPendingEvent(StyleEventSender* eventSender)
+{
+ ASSERT_UNUSED(eventSender, eventSender == &styleLoadEventSender());
+ if (m_loadedSheet)
+ dispatchEvent(Event::create(eventNames().loadEvent, false, false));
+ else
+ dispatchEvent(Event::create(eventNames().errorEvent, false, false));
+}
+
+void HTMLStyleElement::notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred)
+{
+ if (m_firedLoad)
+ return;
+ m_loadedSheet = !errorOccurred;
+ styleLoadEventSender().dispatchEventSoon(this);
+ m_firedLoad = true;
+}
+
void HTMLStyleElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
{
HTMLElement::addSubresourceAttributeURLs(urls);