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

Side by Side Diff: Source/core/dom/TreeScopeStyleSheetCollection.cpp

Issue 839303003: Adding stylesheet candidates should not crash when the parser reorders the tree (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add a test Created 5 years, 11 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
« no previous file with comments | « LayoutTests/fast/dom/css-stylesheet-candidate-ordering-expected.txt ('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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9 * Copyright (C) 2013 Google Inc. All rights reserved. 9 * Copyright (C) 2013 Google Inc. All rights reserved.
10 * 10 *
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 void TreeScopeStyleSheetCollection::addStyleSheetCandidateNode(Node* node, bool createdByParser) 49 void TreeScopeStyleSheetCollection::addStyleSheetCandidateNode(Node* node, bool createdByParser)
50 { 50 {
51 if (!node->inDocument()) 51 if (!node->inDocument())
52 return; 52 return;
53 53
54 // Until the <body> exists, we have no choice but to compare document positi ons, 54 // Until the <body> exists, we have no choice but to compare document positi ons,
55 // since styles outside of the body and head continue to be shunted into the head 55 // since styles outside of the body and head continue to be shunted into the head
56 // (and thus can shift to end up before dynamically added DOM content that i s also 56 // (and thus can shift to end up before dynamically added DOM content that i s also
57 // outside the body). 57 // outside the body).
58 if (createdByParser && document().body()) 58 if (createdByParser && document().body() && !node->nextSibling())
esprehn 2015/01/10 01:50:44 I suspect this is wrong if there's mutation events
59 m_styleSheetCandidateNodes.parserAdd(node); 59 m_styleSheetCandidateNodes.parserAdd(node);
60 else 60 else
61 m_styleSheetCandidateNodes.add(node); 61 m_styleSheetCandidateNodes.add(node);
62 } 62 }
63 63
64 TreeScopeStyleSheetCollection::StyleResolverUpdateType TreeScopeStyleSheetCollec tion::compareStyleSheets(const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet > >& oldStyleSheets, const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& newStylesheets, WillBeHeapVector<RawPtrWillBeMember<StyleSheetContents> >& adde dSheets) 64 TreeScopeStyleSheetCollection::StyleResolverUpdateType TreeScopeStyleSheetCollec tion::compareStyleSheets(const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet > >& oldStyleSheets, const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& newStylesheets, WillBeHeapVector<RawPtrWillBeMember<StyleSheetContents> >& adde dSheets)
65 { 65 {
66 unsigned newStyleSheetCount = newStylesheets.size(); 66 unsigned newStyleSheetCount = newStylesheets.size();
67 unsigned oldStyleSheetCount = oldStyleSheets.size(); 67 unsigned oldStyleSheetCount = oldStyleSheets.size();
68 ASSERT(newStyleSheetCount >= oldStyleSheetCount); 68 ASSERT(newStyleSheetCount >= oldStyleSheetCount);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 203
204 void TreeScopeStyleSheetCollection::trace(Visitor* visitor) 204 void TreeScopeStyleSheetCollection::trace(Visitor* visitor)
205 { 205 {
206 visitor->trace(m_treeScope); 206 visitor->trace(m_treeScope);
207 visitor->trace(m_styleSheetCandidateNodes); 207 visitor->trace(m_styleSheetCandidateNodes);
208 StyleSheetCollection::trace(visitor); 208 StyleSheetCollection::trace(visitor);
209 } 209 }
210 210
211 } 211 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/css-stylesheet-candidate-ordering-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698