diff options
Diffstat (limited to 'WebCore/html/HTMLLinkElement.cpp')
-rw-r--r-- | WebCore/html/HTMLLinkElement.cpp | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/WebCore/html/HTMLLinkElement.cpp b/WebCore/html/HTMLLinkElement.cpp index a687852..b3a1c89 100644 --- a/WebCore/html/HTMLLinkElement.cpp +++ b/WebCore/html/HTMLLinkElement.cpp @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com) * * This library is free software; you can redistribute it and/or @@ -54,14 +54,18 @@ inline HTMLLinkElement::HTMLLinkElement(const QualifiedName& tagName, Document* , m_disabledState(Unset) , m_loading(false) , m_createdByParser(createdByParser) +<<<<<<< HEAD , m_timer(this, &HTMLLinkElement::timerFired) +======= + , m_shouldProcessAfterAttach(false) +>>>>>>> webkit.org at r61871 { ASSERT(hasTagName(linkTag)); } PassRefPtr<HTMLLinkElement> HTMLLinkElement::create(const QualifiedName& tagName, Document* document, bool createdByParser) { - return new HTMLLinkElement(tagName, document, createdByParser); + return adoptRef(new HTMLLinkElement(tagName, document, createdByParser)); } HTMLLinkElement::~HTMLLinkElement() @@ -270,12 +274,24 @@ void HTMLLinkElement::process() document()->updateStyleSelector(); } } + +void HTMLLinkElement::processCallback(Node* node) +{ + ASSERT_ARG(node, node && node->hasTagName(linkTag)); + static_cast<HTMLLinkElement*>(node)->process(); +} void HTMLLinkElement::insertedIntoDocument() { HTMLElement::insertedIntoDocument(); document()->addStyleSheetCandidateNode(this, m_createdByParser); - process(); + + // Since processing a stylesheet link causes a beforeload event + // to fire, it is possible for JavaScript to remove the element in the midst + // of it being inserted into the DOM, which can lead to assertion failures + // and crashes. Avoid this by postponing the beforeload/load until after + // attach. + m_shouldProcessAfterAttach = true; } void HTMLLinkElement::removedFromDocument() @@ -287,8 +303,20 @@ void HTMLLinkElement::removedFromDocument() // FIXME: It's terrible to do a synchronous update of the style selector just because a <style> or <link> element got removed. if (document()->renderer()) document()->updateStyleSelector(); + + m_shouldProcessAfterAttach = false; } +void HTMLLinkElement::attach() +{ + if (m_shouldProcessAfterAttach) { + m_shouldProcessAfterAttach = false; + queuePostAttachCallback(&HTMLLinkElement::processCallback, this); + } + + HTMLElement::attach(); +} + void HTMLLinkElement::finishParsingChildren() { m_createdByParser = false; |