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

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

Issue 2755493004: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in core/css/ (Closed)
Patch Set: All windows error are Resolved now. Created 3 years, 8 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
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 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
6 * reserved. 6 * reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
10 * (http://www.torchmobile.com/) 10 * (http://www.torchmobile.com/)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 DCHECK(classNames[i].impl()); 57 DCHECK(classNames[i].impl());
58 // Speculative fix for https://crbug.com/646026 58 // Speculative fix for https://crbug.com/646026
59 if (classNames[i].impl()) 59 if (classNames[i].impl())
60 identifierHashes.push_back(classNames[i].impl()->existingHash() * 60 identifierHashes.push_back(classNames[i].impl()->existingHash() *
61 ClassAttributeSalt); 61 ClassAttributeSalt);
62 } 62 }
63 } 63 }
64 } 64 }
65 65
66 void SelectorFilter::pushParentStackFrame(Element& parent) { 66 void SelectorFilter::pushParentStackFrame(Element& parent) {
67 ASSERT(m_ancestorIdentifierFilter); 67 DCHECK(m_ancestorIdentifierFilter);
68 ASSERT(m_parentStack.isEmpty() || 68 DCHECK(m_parentStack.isEmpty() ||
69 m_parentStack.back().element == parent.parentOrShadowHostElement()); 69 m_parentStack.back().element == parent.parentOrShadowHostElement());
70 ASSERT(!m_parentStack.isEmpty() || !parent.parentOrShadowHostElement()); 70 DCHECK(!m_parentStack.isEmpty() || !parent.parentOrShadowHostElement());
71 m_parentStack.push_back(ParentStackFrame(parent)); 71 m_parentStack.push_back(ParentStackFrame(parent));
72 ParentStackFrame& parentFrame = m_parentStack.back(); 72 ParentStackFrame& parentFrame = m_parentStack.back();
73 // Mix tags, class names and ids into some sort of weird bouillabaisse. 73 // Mix tags, class names and ids into some sort of weird bouillabaisse.
74 // The filter is used for fast rejection of child and descendant selectors. 74 // The filter is used for fast rejection of child and descendant selectors.
75 collectElementIdentifierHashes(parent, parentFrame.identifierHashes); 75 collectElementIdentifierHashes(parent, parentFrame.identifierHashes);
76 size_t count = parentFrame.identifierHashes.size(); 76 size_t count = parentFrame.identifierHashes.size();
77 for (size_t i = 0; i < count; ++i) 77 for (size_t i = 0; i < count; ++i)
78 m_ancestorIdentifierFilter->add(parentFrame.identifierHashes[i]); 78 m_ancestorIdentifierFilter->add(parentFrame.identifierHashes[i]);
79 } 79 }
80 80
81 void SelectorFilter::popParentStackFrame() { 81 void SelectorFilter::popParentStackFrame() {
82 ASSERT(!m_parentStack.isEmpty()); 82 DCHECK(!m_parentStack.isEmpty());
83 ASSERT(m_ancestorIdentifierFilter); 83 DCHECK(m_ancestorIdentifierFilter);
84 const ParentStackFrame& parentFrame = m_parentStack.back(); 84 const ParentStackFrame& parentFrame = m_parentStack.back();
85 size_t count = parentFrame.identifierHashes.size(); 85 size_t count = parentFrame.identifierHashes.size();
86 for (size_t i = 0; i < count; ++i) 86 for (size_t i = 0; i < count; ++i)
87 m_ancestorIdentifierFilter->remove(parentFrame.identifierHashes[i]); 87 m_ancestorIdentifierFilter->remove(parentFrame.identifierHashes[i]);
88 m_parentStack.pop_back(); 88 m_parentStack.pop_back();
89 if (m_parentStack.isEmpty()) { 89 if (m_parentStack.isEmpty()) {
90 ASSERT(m_ancestorIdentifierFilter->likelyEmpty()); 90 ASSERT(m_ancestorIdentifierFilter->likelyEmpty());
91 m_ancestorIdentifierFilter.reset(); 91 m_ancestorIdentifierFilter.reset();
92 } 92 }
93 } 93 }
94 94
95 void SelectorFilter::pushParent(Element& parent) { 95 void SelectorFilter::pushParent(Element& parent) {
96 ASSERT(parent.document().inStyleRecalc()); 96 DCHECK(parent.document().inStyleRecalc());
97 ASSERT(parent.inActiveDocument()); 97 DCHECK(parent.inActiveDocument());
98 if (m_parentStack.isEmpty()) { 98 if (m_parentStack.isEmpty()) {
99 ASSERT(parent == parent.document().documentElement()); 99 DCHECK_EQ(parent, parent.document().documentElement());
100 ASSERT(!m_ancestorIdentifierFilter); 100 DCHECK(!m_ancestorIdentifierFilter);
101 m_ancestorIdentifierFilter = WTF::wrapUnique(new IdentifierFilter); 101 m_ancestorIdentifierFilter = WTF::wrapUnique(new IdentifierFilter);
102 pushParentStackFrame(parent); 102 pushParentStackFrame(parent);
103 return; 103 return;
104 } 104 }
105 ASSERT(m_ancestorIdentifierFilter); 105 DCHECK(m_ancestorIdentifierFilter);
106 // We may get invoked for some random elements in some wacky cases during 106 // We may get invoked for some random elements in some wacky cases during
107 // style resolve. Pause maintaining the stack in this case. 107 // style resolve. Pause maintaining the stack in this case.
108 if (m_parentStack.back().element != parent.parentOrShadowHostElement()) 108 if (m_parentStack.back().element != parent.parentOrShadowHostElement())
109 return; 109 return;
110 pushParentStackFrame(parent); 110 pushParentStackFrame(parent);
111 } 111 }
112 112
113 void SelectorFilter::popParent(Element& parent) { 113 void SelectorFilter::popParent(Element& parent) {
114 ASSERT(parent.document().inStyleRecalc()); 114 DCHECK(parent.document().inStyleRecalc());
115 ASSERT(parent.inActiveDocument()); 115 DCHECK(parent.inActiveDocument());
116 // Note that we may get invoked for some random elements in some wacky cases 116 // Note that we may get invoked for some random elements in some wacky cases
117 // during style resolve. Pause maintaining the stack in this case. 117 // during style resolve. Pause maintaining the stack in this case.
118 if (!parentStackIsConsistent(&parent)) 118 if (!parentStackIsConsistent(&parent))
119 return; 119 return;
120 popParentStackFrame(); 120 popParentStackFrame();
121 } 121 }
122 122
123 static inline void collectDescendantSelectorIdentifierHashes( 123 static inline void collectDescendantSelectorIdentifierHashes(
124 const CSSSelector& selector, 124 const CSSSelector& selector,
125 unsigned*& hash) { 125 unsigned*& hash) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 DEFINE_TRACE(SelectorFilter::ParentStackFrame) { 198 DEFINE_TRACE(SelectorFilter::ParentStackFrame) {
199 visitor->trace(element); 199 visitor->trace(element);
200 } 200 }
201 201
202 DEFINE_TRACE(SelectorFilter) { 202 DEFINE_TRACE(SelectorFilter) {
203 visitor->trace(m_parentStack); 203 visitor->trace(m_parentStack);
204 } 204 }
205 205
206 } // namespace blink 206 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/SelectorFilter.h ('k') | third_party/WebKit/Source/core/css/StyleColor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698