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

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

Issue 2303443003: CSS: Additional asserts for style invalidation (Closed)
Patch Set: key not empty Created 4 years, 3 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 | third_party/WebKit/Source/core/css/invalidation/InvalidationSet.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, 2012 Apple Inc. All r ights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 else 216 else
217 addResult.storedValue->value = SiblingInvalidationSet::create(nullpt r); 217 addResult.storedValue->value = SiblingInvalidationSet::create(nullpt r);
218 return *addResult.storedValue->value; 218 return *addResult.storedValue->value;
219 } 219 }
220 if (addResult.storedValue->value->type() == type) 220 if (addResult.storedValue->value->type() == type)
221 return *addResult.storedValue->value; 221 return *addResult.storedValue->value;
222 222
223 if (type == InvalidateDescendants) 223 if (type == InvalidateDescendants)
224 return toSiblingInvalidationSet(addResult.storedValue->value.get())->ens ureDescendants(); 224 return toSiblingInvalidationSet(addResult.storedValue->value.get())->ens ureDescendants();
225 225
226 addResult.storedValue->value = SiblingInvalidationSet::create(toDescendantIn validationSet(addResult.storedValue->value.get())); 226 RefPtr<InvalidationSet> descendants = addResult.storedValue->value;
227 RefPtr<InvalidationSet> siblings = SiblingInvalidationSet::create(toDescenda ntInvalidationSet(descendants.get()));
228 addResult.storedValue->value = siblings;
227 return *addResult.storedValue->value; 229 return *addResult.storedValue->value;
228 } 230 }
229 231
230 void extractInvalidationSets(InvalidationSet* invalidationSet, DescendantInvalid ationSet*& descendants, SiblingInvalidationSet*& siblings) 232 void extractInvalidationSets(InvalidationSet* invalidationSet, DescendantInvalid ationSet*& descendants, SiblingInvalidationSet*& siblings)
231 { 233 {
232 RELEASE_ASSERT(invalidationSet->isAlive()); 234 RELEASE_ASSERT(invalidationSet->isAlive());
233 if (invalidationSet->type() == InvalidateDescendants) { 235 if (invalidationSet->type() == InvalidateDescendants) {
234 descendants = toDescendantInvalidationSet(invalidationSet); 236 descendants = toDescendantInvalidationSet(invalidationSet);
235 siblings = nullptr; 237 siblings = nullptr;
236 return; 238 return;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 m_idInvalidationSets.clear(); 271 m_idInvalidationSets.clear();
270 m_pseudoInvalidationSets.clear(); 272 m_pseudoInvalidationSets.clear();
271 m_universalSiblingInvalidationSet.clear(); 273 m_universalSiblingInvalidationSet.clear();
272 m_nthInvalidationSet.clear(); 274 m_nthInvalidationSet.clear();
273 275
274 m_isAlive = false; 276 m_isAlive = false;
275 } 277 }
276 278
277 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureClassInvalidationSet(const AtomicString& className, InvalidationType type) 279 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureClassInvalidationSet(const AtomicString& className, InvalidationType type)
278 { 280 {
281 RELEASE_ASSERT(!className.isEmpty());
279 return ensureInvalidationSet(m_classInvalidationSets, className, type); 282 return ensureInvalidationSet(m_classInvalidationSets, className, type);
280 } 283 }
281 284
282 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureAttributeInvalidationSet(co nst AtomicString& attributeName, InvalidationType type) 285 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureAttributeInvalidationSet(co nst AtomicString& attributeName, InvalidationType type)
283 { 286 {
287 RELEASE_ASSERT(!attributeName.isEmpty());
284 return ensureInvalidationSet(m_attributeInvalidationSets, attributeName, typ e); 288 return ensureInvalidationSet(m_attributeInvalidationSets, attributeName, typ e);
285 } 289 }
286 290
287 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureIdInvalidationSet(const Ato micString& id, InvalidationType type) 291 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureIdInvalidationSet(const Ato micString& id, InvalidationType type)
288 { 292 {
293 RELEASE_ASSERT(!id.isEmpty());
289 return ensureInvalidationSet(m_idInvalidationSets, id, type); 294 return ensureInvalidationSet(m_idInvalidationSets, id, type);
290 } 295 }
291 296
292 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensurePseudoInvalidationSet(CSSSe lector::PseudoType pseudoType, InvalidationType type) 297 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensurePseudoInvalidationSet(CSSSe lector::PseudoType pseudoType, InvalidationType type)
293 { 298 {
299 RELEASE_ASSERT(pseudoType != CSSSelector::PseudoUnknown);
294 return ensureInvalidationSet(m_pseudoInvalidationSets, pseudoType, type); 300 return ensureInvalidationSet(m_pseudoInvalidationSets, pseudoType, type);
295 } 301 }
296 302
297 bool RuleFeatureSet::extractInvalidationSetFeature(const CSSSelector& selector, InvalidationSetFeatures& features) 303 bool RuleFeatureSet::extractInvalidationSetFeature(const CSSSelector& selector, InvalidationSetFeatures& features)
298 { 304 {
299 if (selector.match() == CSSSelector::Tag && selector.tagQName().localName() != starAtom) { 305 if (selector.match() == CSSSelector::Tag && selector.tagQName().localName() != starAtom) {
300 features.tagNames.append(selector.tagQName().localName()); 306 features.tagNames.append(selector.tagQName().localName());
301 return true; 307 return true;
302 } 308 }
303 if (selector.match() == CSSSelector::Id) { 309 if (selector.match() == CSSSelector::Id) {
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 usesWindowInactiveSelector = false; 729 usesWindowInactiveSelector = false;
724 foundSiblingSelector = false; 730 foundSiblingSelector = false;
725 foundInsertionPointCrossing = false; 731 foundInsertionPointCrossing = false;
726 maxDirectAdjacentSelectors = 0; 732 maxDirectAdjacentSelectors = 0;
727 } 733 }
728 734
729 void RuleFeatureSet::add(const RuleFeatureSet& other) 735 void RuleFeatureSet::add(const RuleFeatureSet& other)
730 { 736 {
731 RELEASE_ASSERT(m_isAlive); 737 RELEASE_ASSERT(m_isAlive);
732 RELEASE_ASSERT(other.m_isAlive); 738 RELEASE_ASSERT(other.m_isAlive);
739 RELEASE_ASSERT(&other != this);
733 for (const auto& entry : other.m_classInvalidationSets) 740 for (const auto& entry : other.m_classInvalidationSets)
734 ensureInvalidationSet(m_classInvalidationSets, entry.key, entry.value->t ype()).combine(*entry.value); 741 ensureInvalidationSet(m_classInvalidationSets, entry.key, entry.value->t ype()).combine(*entry.value);
735 for (const auto& entry : other.m_attributeInvalidationSets) 742 for (const auto& entry : other.m_attributeInvalidationSets)
736 ensureInvalidationSet(m_attributeInvalidationSets, entry.key, entry.valu e->type()).combine(*entry.value); 743 ensureInvalidationSet(m_attributeInvalidationSets, entry.key, entry.valu e->type()).combine(*entry.value);
737 for (const auto& entry : other.m_idInvalidationSets) 744 for (const auto& entry : other.m_idInvalidationSets)
738 ensureInvalidationSet(m_idInvalidationSets, entry.key, entry.value->type ()).combine(*entry.value); 745 ensureInvalidationSet(m_idInvalidationSets, entry.key, entry.value->type ()).combine(*entry.value);
739 for (const auto& entry : other.m_pseudoInvalidationSets) 746 for (const auto& entry : other.m_pseudoInvalidationSets)
740 ensureInvalidationSet(m_pseudoInvalidationSets, static_cast<CSSSelector: :PseudoType>(entry.key), entry.value->type()).combine(*entry.value); 747 ensureInvalidationSet(m_pseudoInvalidationSets, static_cast<CSSSelector: :PseudoType>(entry.key), entry.value->type()).combine(*entry.value);
741 if (other.m_universalSiblingInvalidationSet) 748 if (other.m_universalSiblingInvalidationSet)
742 ensureUniversalSiblingInvalidationSet().combine(*other.m_universalSiblin gInvalidationSet); 749 ensureUniversalSiblingInvalidationSet().combine(*other.m_universalSiblin gInvalidationSet);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 addFeaturesToInvalidationSet(universalSet.ensureSiblingDescendants(), de scendantFeatures); 946 addFeaturesToInvalidationSet(universalSet.ensureSiblingDescendants(), de scendantFeatures);
940 } 947 }
941 948
942 DEFINE_TRACE(RuleFeatureSet) 949 DEFINE_TRACE(RuleFeatureSet)
943 { 950 {
944 visitor->trace(siblingRules); 951 visitor->trace(siblingRules);
945 visitor->trace(uncommonAttributeRules); 952 visitor->trace(uncommonAttributeRules);
946 } 953 }
947 954
948 } // namespace blink 955 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/invalidation/InvalidationSet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698