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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/StyleElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Rob Buis 2 * Copyright (C) 2006, 2007 Rob Buis
3 * Copyright (C) 2008 Apple, Inc. All rights reserved. 3 * Copyright (C) 2008 Apple, Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 25 matching lines...) Expand all
36 namespace WebCore { 36 namespace WebCore {
37 37
38 static bool isCSS(Element* element, const AtomicString& type) 38 static bool isCSS(Element* element, const AtomicString& type)
39 { 39 {
40 return type.isEmpty() || (element->isHTMLElement() ? equalIgnoringCase(type, "text/css") : (type == "text/css")); 40 return type.isEmpty() || (element->isHTMLElement() ? equalIgnoringCase(type, "text/css") : (type == "text/css"));
41 } 41 }
42 42
43 StyleElement::StyleElement(Document* document, bool createdByParser) 43 StyleElement::StyleElement(Document* document, bool createdByParser)
44 : m_createdByParser(createdByParser) 44 : m_createdByParser(createdByParser)
45 , m_loading(false) 45 , m_loading(false)
46 , m_registeredAsCandidate(false)
46 , m_startPosition(TextPosition::belowRangePosition()) 47 , m_startPosition(TextPosition::belowRangePosition())
47 { 48 {
48 if (createdByParser && document && document->scriptableDocumentParser() && ! document->isInDocumentWrite()) 49 if (createdByParser && document && document->scriptableDocumentParser() && ! document->isInDocumentWrite())
49 m_startPosition = document->scriptableDocumentParser()->textPosition(); 50 m_startPosition = document->scriptableDocumentParser()->textPosition();
50 } 51 }
51 52
52 StyleElement::~StyleElement() 53 StyleElement::~StyleElement()
53 { 54 {
54 if (m_sheet) 55 if (m_sheet)
55 clearSheet(); 56 clearSheet();
56 } 57 }
57 58
58 void StyleElement::processStyleSheet(Document& document, Element* element) 59 void StyleElement::processStyleSheet(Document& document, Element* element)
59 { 60 {
60 TRACE_EVENT0("webkit", "StyleElement::processStyleSheet"); 61 TRACE_EVENT0("webkit", "StyleElement::processStyleSheet");
61 ASSERT(element); 62 ASSERT(element);
63
64 m_registeredAsCandidate = true;
62 document.styleEngine()->addStyleSheetCandidateNode(element, m_createdByParse r); 65 document.styleEngine()->addStyleSheetCandidateNode(element, m_createdByParse r);
63 if (m_createdByParser) 66 if (m_createdByParser)
64 return; 67 return;
65 68
66 process(element); 69 process(element);
67 } 70 }
68 71
69 void StyleElement::removedFromDocument(Document& document, Element* element) 72 void StyleElement::removedFromDocument(Document& document, Element* element)
70 { 73 {
71 removedFromDocument(document, element, 0, document); 74 removedFromDocument(document, element, 0, document);
72 } 75 }
73 76
74 void StyleElement::removedFromDocument(Document& document, Element* element, Con tainerNode* scopingNode, TreeScope& treeScope) 77 void StyleElement::removedFromDocument(Document& document, Element* element, Con tainerNode* scopingNode, TreeScope& treeScope)
75 { 78 {
76 ASSERT(element); 79 ASSERT(element);
80
81 if (!m_registeredAsCandidate) {
82 ASSERT(!m_sheet);
83 return;
84 }
85
77 document.styleEngine()->removeStyleSheetCandidateNode(element, scopingNode, treeScope); 86 document.styleEngine()->removeStyleSheetCandidateNode(element, scopingNode, treeScope);
87 m_registeredAsCandidate = false;
78 88
79 RefPtr<StyleSheet> removedSheet = m_sheet; 89 RefPtr<StyleSheet> removedSheet = m_sheet;
80 90
81 if (m_sheet) 91 if (m_sheet)
82 clearSheet(element); 92 clearSheet(element);
83 93
84 document.removedStyleSheet(removedSheet.get(), RecalcStyleDeferred, Analyzed StyleUpdate); 94 document.removedStyleSheet(removedSheet.get(), RecalcStyleDeferred, Analyzed StyleUpdate);
85 } 95 }
86 96
87 void StyleElement::clearDocumentData(Document& document, Element* element) 97 void StyleElement::clearDocumentData(Document& document, Element* element)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 document.styleEngine()->removePendingSheet(m_sheet->ownerNode()); 183 document.styleEngine()->removePendingSheet(m_sheet->ownerNode());
174 return true; 184 return true;
175 } 185 }
176 186
177 void StyleElement::startLoadingDynamicSheet(Document& document) 187 void StyleElement::startLoadingDynamicSheet(Document& document)
178 { 188 {
179 document.styleEngine()->addPendingSheet(); 189 document.styleEngine()->addPendingSheet();
180 } 190 }
181 191
182 } 192 }
OLDNEW
« 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