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

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

Issue 149513011: Pass around CSSSelector by reference instead of pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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 | « Source/core/css/SelectorFilter.h ('k') | Source/core/css/StyleInvalidationAnalysis.cpp » ('j') | 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 void SelectorFilter::pushParent(Element& parent) 101 void SelectorFilter::pushParent(Element& parent)
102 { 102 {
103 ASSERT(m_ancestorIdentifierFilter); 103 ASSERT(m_ancestorIdentifierFilter);
104 // We may get invoked for some random elements in some wacky cases during st yle resolve. 104 // We may get invoked for some random elements in some wacky cases during st yle resolve.
105 // Pause maintaining the stack in this case. 105 // Pause maintaining the stack in this case.
106 if (m_parentStack.last().element != parent.parentOrShadowHostElement()) 106 if (m_parentStack.last().element != parent.parentOrShadowHostElement())
107 return; 107 return;
108 pushParentStackFrame(parent); 108 pushParentStackFrame(parent);
109 } 109 }
110 110
111 static inline void collectDescendantSelectorIdentifierHashes(const CSSSelector* selector, unsigned*& hash) 111 static inline void collectDescendantSelectorIdentifierHashes(const CSSSelector& selector, unsigned*& hash)
112 { 112 {
113 switch (selector->m_match) { 113 switch (selector.m_match) {
114 case CSSSelector::Id: 114 case CSSSelector::Id:
115 if (!selector->value().isEmpty()) 115 if (!selector.value().isEmpty())
116 (*hash++) = selector->value().impl()->existingHash() * IdAttributeSa lt; 116 (*hash++) = selector.value().impl()->existingHash() * IdAttributeSal t;
117 break; 117 break;
118 case CSSSelector::Class: 118 case CSSSelector::Class:
119 if (!selector->value().isEmpty()) 119 if (!selector.value().isEmpty())
120 (*hash++) = selector->value().impl()->existingHash() * ClassAttribut eSalt; 120 (*hash++) = selector.value().impl()->existingHash() * ClassAttribute Salt;
121 break; 121 break;
122 case CSSSelector::Tag: 122 case CSSSelector::Tag:
123 if (selector->tagQName().localName() != starAtom) 123 if (selector.tagQName().localName() != starAtom)
124 (*hash++) = selector->tagQName().localName().impl()->existingHash() * TagNameSalt; 124 (*hash++) = selector.tagQName().localName().impl()->existingHash() * TagNameSalt;
125 break; 125 break;
126 default: 126 default:
127 break; 127 break;
128 } 128 }
129 } 129 }
130 130
131 void SelectorFilter::collectIdentifierHashes(const CSSSelector* selector, unsign ed* identifierHashes, unsigned maximumIdentifierCount) 131 void SelectorFilter::collectIdentifierHashes(const CSSSelector& selector, unsign ed* identifierHashes, unsigned maximumIdentifierCount)
132 { 132 {
133 unsigned* hash = identifierHashes; 133 unsigned* hash = identifierHashes;
134 unsigned* end = identifierHashes + maximumIdentifierCount; 134 unsigned* end = identifierHashes + maximumIdentifierCount;
135 CSSSelector::Relation relation = selector->relation(); 135 CSSSelector::Relation relation = selector.relation();
136 bool relationIsAffectedByPseudoContent = selector->relationIsAffectedByPseud oContent(); 136 bool relationIsAffectedByPseudoContent = selector.relationIsAffectedByPseudo Content();
137 137
138 // Skip the topmost selector. It is handled quickly by the rule hashes. 138 // Skip the topmost selector. It is handled quickly by the rule hashes.
139 bool skipOverSubselectors = true; 139 bool skipOverSubselectors = true;
140 for (selector = selector->tagHistory(); selector; selector = selector->tagHi story()) { 140 for (const CSSSelector* current = selector.tagHistory(); current; current = current->tagHistory()) {
141 // Only collect identifiers that match ancestors. 141 // Only collect identifiers that match ancestors.
142 switch (relation) { 142 switch (relation) {
143 case CSSSelector::SubSelector: 143 case CSSSelector::SubSelector:
144 if (!skipOverSubselectors) 144 if (!skipOverSubselectors)
145 collectDescendantSelectorIdentifierHashes(selector, hash); 145 collectDescendantSelectorIdentifierHashes(*current, hash);
146 break; 146 break;
147 case CSSSelector::DirectAdjacent: 147 case CSSSelector::DirectAdjacent:
148 case CSSSelector::IndirectAdjacent: 148 case CSSSelector::IndirectAdjacent:
149 case CSSSelector::ShadowPseudo: 149 case CSSSelector::ShadowPseudo:
150 skipOverSubselectors = true; 150 skipOverSubselectors = true;
151 break; 151 break;
152 case CSSSelector::Descendant: 152 case CSSSelector::Descendant:
153 case CSSSelector::Child: 153 case CSSSelector::Child:
154 if (relationIsAffectedByPseudoContent) { 154 if (relationIsAffectedByPseudoContent) {
155 // Disable fastRejectSelector. 155 // Disable fastRejectSelector.
156 *identifierHashes = 0; 156 *identifierHashes = 0;
157 return; 157 return;
158 } 158 }
159 // Fall through. 159 // Fall through.
160 case CSSSelector::ChildTree: 160 case CSSSelector::ChildTree:
161 case CSSSelector::DescendantTree: 161 case CSSSelector::DescendantTree:
162 skipOverSubselectors = false; 162 skipOverSubselectors = false;
163 collectDescendantSelectorIdentifierHashes(selector, hash); 163 collectDescendantSelectorIdentifierHashes(*current, hash);
164 break; 164 break;
165 } 165 }
166 if (hash == end) 166 if (hash == end)
167 return; 167 return;
168 relation = selector->relation(); 168 relation = current->relation();
169 relationIsAffectedByPseudoContent = selector->relationIsAffectedByPseudo Content(); 169 relationIsAffectedByPseudoContent = current->relationIsAffectedByPseudoC ontent();
170 } 170 }
171 *hash = 0; 171 *hash = 0;
172 } 172 }
173 173
174 } 174 }
OLDNEW
« no previous file with comments | « Source/core/css/SelectorFilter.h ('k') | Source/core/css/StyleInvalidationAnalysis.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698