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

Side by Side Diff: third_party/WebKit/Source/core/css/SelectorFilter.cpp

Issue 2376703002: Speculative fix for SelectorFilter crash. (Closed)
Patch Set: Added DCHECK + comment Created 4 years, 2 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 | « no previous file | 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) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 27 matching lines...) Expand all
38 enum { TagNameSalt = 13, IdAttributeSalt = 17, ClassAttributeSalt = 19 }; 38 enum { TagNameSalt = 13, IdAttributeSalt = 17, ClassAttributeSalt = 19 };
39 39
40 static inline void collectElementIdentifierHashes(const Element& element, Vector <unsigned, 4>& identifierHashes) 40 static inline void collectElementIdentifierHashes(const Element& element, Vector <unsigned, 4>& identifierHashes)
41 { 41 {
42 identifierHashes.append(element.localNameForSelectorMatching().impl()->exist ingHash() * TagNameSalt); 42 identifierHashes.append(element.localNameForSelectorMatching().impl()->exist ingHash() * TagNameSalt);
43 if (element.hasID()) 43 if (element.hasID())
44 identifierHashes.append(element.idForStyleResolution().impl()->existingH ash() * IdAttributeSalt); 44 identifierHashes.append(element.idForStyleResolution().impl()->existingH ash() * IdAttributeSalt);
45 if (element.isStyledElement() && element.hasClass()) { 45 if (element.isStyledElement() && element.hasClass()) {
46 const SpaceSplitString& classNames = element.classNames(); 46 const SpaceSplitString& classNames = element.classNames();
47 size_t count = classNames.size(); 47 size_t count = classNames.size();
48 for (size_t i = 0; i < count; ++i) 48 for (size_t i = 0; i < count; ++i) {
49 identifierHashes.append(classNames[i].impl()->existingHash() * Class AttributeSalt); 49 DCHECK(classNames[i].impl());
50 // Speculative fix for https://crbug.com/646026
51 if (classNames[i].impl())
52 identifierHashes.append(classNames[i].impl()->existingHash() * C lassAttributeSalt);
53 }
50 } 54 }
51 } 55 }
52 56
53 void SelectorFilter::pushParentStackFrame(Element& parent) 57 void SelectorFilter::pushParentStackFrame(Element& parent)
54 { 58 {
55 ASSERT(m_ancestorIdentifierFilter); 59 ASSERT(m_ancestorIdentifierFilter);
56 ASSERT(m_parentStack.isEmpty() || m_parentStack.last().element == parent.par entOrShadowHostElement()); 60 ASSERT(m_parentStack.isEmpty() || m_parentStack.last().element == parent.par entOrShadowHostElement());
57 ASSERT(!m_parentStack.isEmpty() || !parent.parentOrShadowHostElement()); 61 ASSERT(!m_parentStack.isEmpty() || !parent.parentOrShadowHostElement());
58 m_parentStack.append(ParentStackFrame(parent)); 62 m_parentStack.append(ParentStackFrame(parent));
59 ParentStackFrame& parentFrame = m_parentStack.last(); 63 ParentStackFrame& parentFrame = m_parentStack.last();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 { 187 {
184 visitor->trace(element); 188 visitor->trace(element);
185 } 189 }
186 190
187 DEFINE_TRACE(SelectorFilter) 191 DEFINE_TRACE(SelectorFilter)
188 { 192 {
189 visitor->trace(m_parentStack); 193 visitor->trace(m_parentStack);
190 } 194 }
191 195
192 } // namespace blink 196 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698