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

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

Issue 2755493004: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in core/css/ (Closed)
Patch Set: Worked on Review Comments done Created 3 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
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, 2012 Apple Inc. All 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All
6 * rights reserved. 6 * rights 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 CSSSelector::PseudoType key, 241 CSSSelector::PseudoType key,
242 InvalidationType type) { 242 InvalidationType type) {
243 RefPtr<InvalidationSet>& invalidationSet = 243 RefPtr<InvalidationSet>& invalidationSet =
244 map.insert(key, nullptr).storedValue->value; 244 map.insert(key, nullptr).storedValue->value;
245 return storedInvalidationSet(invalidationSet, type); 245 return storedInvalidationSet(invalidationSet, type);
246 } 246 }
247 247
248 void extractInvalidationSets(InvalidationSet* invalidationSet, 248 void extractInvalidationSets(InvalidationSet* invalidationSet,
249 DescendantInvalidationSet*& descendants, 249 DescendantInvalidationSet*& descendants,
250 SiblingInvalidationSet*& siblings) { 250 SiblingInvalidationSet*& siblings) {
251 RELEASE_ASSERT(invalidationSet->isAlive()); 251 CHECK(invalidationSet->isAlive());
252 if (invalidationSet->type() == InvalidateDescendants) { 252 if (invalidationSet->type() == InvalidateDescendants) {
253 descendants = toDescendantInvalidationSet(invalidationSet); 253 descendants = toDescendantInvalidationSet(invalidationSet);
254 siblings = nullptr; 254 siblings = nullptr;
255 return; 255 return;
256 } 256 }
257 257
258 siblings = toSiblingInvalidationSet(invalidationSet); 258 siblings = toSiblingInvalidationSet(invalidationSet);
259 descendants = siblings->descendants(); 259 descendants = siblings->descendants();
260 } 260 }
261 261
262 } // anonymous namespace 262 } // anonymous namespace
263 263
264 RuleFeature::RuleFeature(StyleRule* rule, 264 RuleFeature::RuleFeature(StyleRule* rule,
265 unsigned selectorIndex, 265 unsigned selectorIndex,
266 bool hasDocumentSecurityOrigin) 266 bool hasDocumentSecurityOrigin)
267 : rule(rule), 267 : rule(rule),
268 selectorIndex(selectorIndex), 268 selectorIndex(selectorIndex),
269 hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) {} 269 hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) {}
270 270
271 DEFINE_TRACE(RuleFeature) { 271 DEFINE_TRACE(RuleFeature) {
272 visitor->trace(rule); 272 visitor->trace(rule);
273 } 273 }
274 274
275 RuleFeatureSet::RuleFeatureSet() : m_isAlive(true) {} 275 RuleFeatureSet::RuleFeatureSet() : m_isAlive(true) {}
276 276
277 RuleFeatureSet::~RuleFeatureSet() { 277 RuleFeatureSet::~RuleFeatureSet() {
278 RELEASE_ASSERT(m_isAlive); 278 CHECK(m_isAlive);
279 279
280 m_metadata.clear(); 280 m_metadata.clear();
281 m_classInvalidationSets.clear(); 281 m_classInvalidationSets.clear();
282 m_attributeInvalidationSets.clear(); 282 m_attributeInvalidationSets.clear();
283 m_idInvalidationSets.clear(); 283 m_idInvalidationSets.clear();
284 m_pseudoInvalidationSets.clear(); 284 m_pseudoInvalidationSets.clear();
285 m_universalSiblingInvalidationSet.clear(); 285 m_universalSiblingInvalidationSet.clear();
286 m_nthInvalidationSet.clear(); 286 m_nthInvalidationSet.clear();
287 287
288 m_isAlive = false; 288 m_isAlive = false;
289 } 289 }
290 290
291 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureClassInvalidationSet( 291 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureClassInvalidationSet(
292 const AtomicString& className, 292 const AtomicString& className,
293 InvalidationType type) { 293 InvalidationType type) {
294 RELEASE_ASSERT(!className.isEmpty()); 294 CHECK(!className.isEmpty());
295 return ensureInvalidationSet(m_classInvalidationSets, className, type); 295 return ensureInvalidationSet(m_classInvalidationSets, className, type);
296 } 296 }
297 297
298 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureAttributeInvalidationSet( 298 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureAttributeInvalidationSet(
299 const AtomicString& attributeName, 299 const AtomicString& attributeName,
300 InvalidationType type) { 300 InvalidationType type) {
301 RELEASE_ASSERT(!attributeName.isEmpty()); 301 CHECK(!attributeName.isEmpty());
302 return ensureInvalidationSet(m_attributeInvalidationSets, attributeName, 302 return ensureInvalidationSet(m_attributeInvalidationSets, attributeName,
303 type); 303 type);
304 } 304 }
305 305
306 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureIdInvalidationSet( 306 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureIdInvalidationSet(
307 const AtomicString& id, 307 const AtomicString& id,
308 InvalidationType type) { 308 InvalidationType type) {
309 RELEASE_ASSERT(!id.isEmpty()); 309 CHECK(!id.isEmpty());
310 return ensureInvalidationSet(m_idInvalidationSets, id, type); 310 return ensureInvalidationSet(m_idInvalidationSets, id, type);
311 } 311 }
312 312
313 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensurePseudoInvalidationSet( 313 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensurePseudoInvalidationSet(
314 CSSSelector::PseudoType pseudoType, 314 CSSSelector::PseudoType pseudoType,
315 InvalidationType type) { 315 InvalidationType type) {
316 RELEASE_ASSERT(pseudoType != CSSSelector::PseudoUnknown); 316 CHECK(pseudoType != CSSSelector::PseudoUnknown);
tkent 2017/03/28 14:44:56 Use CHECK_NE
nikhil.sahni 2017/03/30 12:17:58 Done.
317 return ensureInvalidationSet(m_pseudoInvalidationSets, pseudoType, type); 317 return ensureInvalidationSet(m_pseudoInvalidationSets, pseudoType, type);
318 } 318 }
319 319
320 void RuleFeatureSet::updateFeaturesFromCombinator( 320 void RuleFeatureSet::updateFeaturesFromCombinator(
321 const CSSSelector& lastInCompound, 321 const CSSSelector& lastInCompound,
322 const CSSSelector* lastCompoundInAdjacentChain, 322 const CSSSelector* lastCompoundInAdjacentChain,
323 InvalidationSetFeatures& lastCompoundInAdjacentChainFeatures, 323 InvalidationSetFeatures& lastCompoundInAdjacentChainFeatures,
324 InvalidationSetFeatures*& siblingFeatures, 324 InvalidationSetFeatures*& siblingFeatures,
325 InvalidationSetFeatures& descendantFeatures) { 325 InvalidationSetFeatures& descendantFeatures) {
326 if (lastInCompound.isAdjacentSelector()) { 326 if (lastInCompound.isAdjacentSelector()) {
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 DCHECK(lastInCompound); 795 DCHECK(lastInCompound);
796 updateFeaturesFromCombinator(*lastInCompound, compound, 796 updateFeaturesFromCombinator(*lastInCompound, compound,
797 lastCompoundInSiblingChainFeatures, 797 lastCompoundInSiblingChainFeatures,
798 siblingFeatures, descendantFeatures); 798 siblingFeatures, descendantFeatures);
799 compound = lastInCompound->tagHistory(); 799 compound = lastInCompound->tagHistory();
800 } 800 }
801 } 801 }
802 802
803 RuleFeatureSet::SelectorPreMatch RuleFeatureSet::collectFeaturesFromRuleData( 803 RuleFeatureSet::SelectorPreMatch RuleFeatureSet::collectFeaturesFromRuleData(
804 const RuleData& ruleData) { 804 const RuleData& ruleData) {
805 RELEASE_ASSERT(m_isAlive); 805 CHECK(m_isAlive);
806 FeatureMetadata metadata; 806 FeatureMetadata metadata;
807 if (collectFeaturesFromSelector(ruleData.selector(), metadata) == 807 if (collectFeaturesFromSelector(ruleData.selector(), metadata) ==
808 SelectorNeverMatches) 808 SelectorNeverMatches)
809 return SelectorNeverMatches; 809 return SelectorNeverMatches;
810 810
811 m_metadata.add(metadata); 811 m_metadata.add(metadata);
812 812
813 if (metadata.foundSiblingSelector) { 813 if (metadata.foundSiblingSelector) {
814 m_siblingRules.push_back(RuleFeature(ruleData.rule(), 814 m_siblingRules.push_back(RuleFeature(ruleData.rule(),
815 ruleData.selectorIndex(), 815 ruleData.selectorIndex(),
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 void RuleFeatureSet::FeatureMetadata::clear() { 912 void RuleFeatureSet::FeatureMetadata::clear() {
913 usesFirstLineRules = false; 913 usesFirstLineRules = false;
914 usesWindowInactiveSelector = false; 914 usesWindowInactiveSelector = false;
915 foundSiblingSelector = false; 915 foundSiblingSelector = false;
916 foundInsertionPointCrossing = false; 916 foundInsertionPointCrossing = false;
917 needsFullRecalcForRuleSetInvalidation = false; 917 needsFullRecalcForRuleSetInvalidation = false;
918 maxDirectAdjacentSelectors = 0; 918 maxDirectAdjacentSelectors = 0;
919 } 919 }
920 920
921 void RuleFeatureSet::add(const RuleFeatureSet& other) { 921 void RuleFeatureSet::add(const RuleFeatureSet& other) {
922 RELEASE_ASSERT(m_isAlive); 922 CHECK(m_isAlive);
923 RELEASE_ASSERT(other.m_isAlive); 923 CHECK(other.m_isAlive);
924 RELEASE_ASSERT(&other != this); 924 CHECK_NE(&other, this);
925 for (const auto& entry : other.m_classInvalidationSets) 925 for (const auto& entry : other.m_classInvalidationSets)
926 ensureInvalidationSet(m_classInvalidationSets, entry.key, 926 ensureInvalidationSet(m_classInvalidationSets, entry.key,
927 entry.value->type()) 927 entry.value->type())
928 .combine(*entry.value); 928 .combine(*entry.value);
929 for (const auto& entry : other.m_attributeInvalidationSets) 929 for (const auto& entry : other.m_attributeInvalidationSets)
930 ensureInvalidationSet(m_attributeInvalidationSets, entry.key, 930 ensureInvalidationSet(m_attributeInvalidationSets, entry.key,
931 entry.value->type()) 931 entry.value->type())
932 .combine(*entry.value); 932 .combine(*entry.value);
933 for (const auto& entry : other.m_idInvalidationSets) 933 for (const auto& entry : other.m_idInvalidationSets)
934 ensureInvalidationSet(m_idInvalidationSets, entry.key, entry.value->type()) 934 ensureInvalidationSet(m_idInvalidationSets, entry.key, entry.value->type())
(...skipping 13 matching lines...) Expand all
948 948
949 m_siblingRules.appendVector(other.m_siblingRules); 949 m_siblingRules.appendVector(other.m_siblingRules);
950 m_uncommonAttributeRules.appendVector(other.m_uncommonAttributeRules); 950 m_uncommonAttributeRules.appendVector(other.m_uncommonAttributeRules);
951 m_viewportDependentMediaQueryResults.appendVector( 951 m_viewportDependentMediaQueryResults.appendVector(
952 other.m_viewportDependentMediaQueryResults); 952 other.m_viewportDependentMediaQueryResults);
953 m_deviceDependentMediaQueryResults.appendVector( 953 m_deviceDependentMediaQueryResults.appendVector(
954 other.m_deviceDependentMediaQueryResults); 954 other.m_deviceDependentMediaQueryResults);
955 } 955 }
956 956
957 void RuleFeatureSet::clear() { 957 void RuleFeatureSet::clear() {
958 RELEASE_ASSERT(m_isAlive); 958 CHECK(m_isAlive);
959 m_siblingRules.clear(); 959 m_siblingRules.clear();
960 m_uncommonAttributeRules.clear(); 960 m_uncommonAttributeRules.clear();
961 m_metadata.clear(); 961 m_metadata.clear();
962 m_classInvalidationSets.clear(); 962 m_classInvalidationSets.clear();
963 m_attributeInvalidationSets.clear(); 963 m_attributeInvalidationSets.clear();
964 m_idInvalidationSets.clear(); 964 m_idInvalidationSets.clear();
965 m_pseudoInvalidationSets.clear(); 965 m_pseudoInvalidationSets.clear();
966 m_universalSiblingInvalidationSet.clear(); 966 m_universalSiblingInvalidationSet.clear();
967 m_nthInvalidationSet.clear(); 967 m_nthInvalidationSet.clear();
968 m_viewportDependentMediaQueryResults.clear(); 968 m_viewportDependentMediaQueryResults.clear();
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 bool RuleFeatureSet::InvalidationSetFeatures::hasFeatures() const { 1227 bool RuleFeatureSet::InvalidationSetFeatures::hasFeatures() const {
1228 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty() || 1228 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty() ||
1229 !tagNames.isEmpty() || customPseudoElement; 1229 !tagNames.isEmpty() || customPseudoElement;
1230 } 1230 }
1231 1231
1232 bool RuleFeatureSet::InvalidationSetFeatures::hasIdClassOrAttribute() const { 1232 bool RuleFeatureSet::InvalidationSetFeatures::hasIdClassOrAttribute() const {
1233 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty(); 1233 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty();
1234 } 1234 }
1235 1235
1236 } // namespace blink 1236 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698