Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(551)

Unified Diff: Source/core/dom/StyleElement.cpp

Issue 203253006: Don't call ill-balanced removeStyleSheetCandidateNode() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/StyleElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/StyleElement.cpp
diff --git a/Source/core/dom/StyleElement.cpp b/Source/core/dom/StyleElement.cpp
index c16c57fb3399988fe8c957af152d4fb0c8ed173b..bf5767f92e428864604c702d64438ef0d5bc381a 100644
--- a/Source/core/dom/StyleElement.cpp
+++ b/Source/core/dom/StyleElement.cpp
@@ -43,6 +43,7 @@ static bool isCSS(Element* element, const AtomicString& type)
StyleElement::StyleElement(Document* document, bool createdByParser)
: m_createdByParser(createdByParser)
, m_loading(false)
+ , m_registeredAsCandidate(false)
, m_startPosition(TextPosition::belowRangePosition())
{
if (createdByParser && document && document->scriptableDocumentParser() && !document->isInDocumentWrite())
@@ -59,6 +60,8 @@ void StyleElement::processStyleSheet(Document& document, Element* element)
{
TRACE_EVENT0("webkit", "StyleElement::processStyleSheet");
ASSERT(element);
+
+ m_registeredAsCandidate = true;
document.styleEngine()->addStyleSheetCandidateNode(element, m_createdByParser);
if (m_createdByParser)
return;
@@ -74,7 +77,14 @@ void StyleElement::removedFromDocument(Document& document, Element* element)
void StyleElement::removedFromDocument(Document& document, Element* element, ContainerNode* scopingNode, TreeScope& treeScope)
{
ASSERT(element);
+
+ if (!m_registeredAsCandidate) {
+ ASSERT(!m_sheet);
+ return;
+ }
+
document.styleEngine()->removeStyleSheetCandidateNode(element, scopingNode, treeScope);
+ m_registeredAsCandidate = false;
RefPtr<StyleSheet> removedSheet = m_sheet;
« no previous file with comments | « Source/core/dom/StyleElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698