OLD | NEW |
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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 CSSSelector::PseudoType key, | 243 CSSSelector::PseudoType key, |
244 InvalidationType type) { | 244 InvalidationType type) { |
245 RefPtr<InvalidationSet>& invalidationSet = | 245 RefPtr<InvalidationSet>& invalidationSet = |
246 map.insert(key, nullptr).storedValue->value; | 246 map.insert(key, nullptr).storedValue->value; |
247 return storedInvalidationSet(invalidationSet, type); | 247 return storedInvalidationSet(invalidationSet, type); |
248 } | 248 } |
249 | 249 |
250 void extractInvalidationSets(InvalidationSet* invalidationSet, | 250 void extractInvalidationSets(InvalidationSet* invalidationSet, |
251 DescendantInvalidationSet*& descendants, | 251 DescendantInvalidationSet*& descendants, |
252 SiblingInvalidationSet*& siblings) { | 252 SiblingInvalidationSet*& siblings) { |
253 RELEASE_ASSERT(invalidationSet->isAlive()); | 253 CHECK(invalidationSet->isAlive()); |
254 if (invalidationSet->type() == InvalidateDescendants) { | 254 if (invalidationSet->type() == InvalidateDescendants) { |
255 descendants = toDescendantInvalidationSet(invalidationSet); | 255 descendants = toDescendantInvalidationSet(invalidationSet); |
256 siblings = nullptr; | 256 siblings = nullptr; |
257 return; | 257 return; |
258 } | 258 } |
259 | 259 |
260 siblings = toSiblingInvalidationSet(invalidationSet); | 260 siblings = toSiblingInvalidationSet(invalidationSet); |
261 descendants = siblings->descendants(); | 261 descendants = siblings->descendants(); |
262 } | 262 } |
263 | 263 |
264 } // anonymous namespace | 264 } // anonymous namespace |
265 | 265 |
266 RuleFeature::RuleFeature(StyleRule* rule, | 266 RuleFeature::RuleFeature(StyleRule* rule, |
267 unsigned selectorIndex, | 267 unsigned selectorIndex, |
268 bool hasDocumentSecurityOrigin) | 268 bool hasDocumentSecurityOrigin) |
269 : rule(rule), | 269 : rule(rule), |
270 selectorIndex(selectorIndex), | 270 selectorIndex(selectorIndex), |
271 hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) {} | 271 hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) {} |
272 | 272 |
273 DEFINE_TRACE(RuleFeature) { | 273 DEFINE_TRACE(RuleFeature) { |
274 visitor->trace(rule); | 274 visitor->trace(rule); |
275 } | 275 } |
276 | 276 |
277 RuleFeatureSet::RuleFeatureSet() : m_isAlive(true) {} | 277 RuleFeatureSet::RuleFeatureSet() : m_isAlive(true) {} |
278 | 278 |
279 RuleFeatureSet::~RuleFeatureSet() { | 279 RuleFeatureSet::~RuleFeatureSet() { |
280 RELEASE_ASSERT(m_isAlive); | 280 CHECK(m_isAlive); |
281 | 281 |
282 m_metadata.clear(); | 282 m_metadata.clear(); |
283 m_classInvalidationSets.clear(); | 283 m_classInvalidationSets.clear(); |
284 m_attributeInvalidationSets.clear(); | 284 m_attributeInvalidationSets.clear(); |
285 m_idInvalidationSets.clear(); | 285 m_idInvalidationSets.clear(); |
286 m_pseudoInvalidationSets.clear(); | 286 m_pseudoInvalidationSets.clear(); |
287 m_universalSiblingInvalidationSet.clear(); | 287 m_universalSiblingInvalidationSet.clear(); |
288 m_nthInvalidationSet.clear(); | 288 m_nthInvalidationSet.clear(); |
289 | 289 |
290 m_isAlive = false; | 290 m_isAlive = false; |
291 } | 291 } |
292 | 292 |
293 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureClassInvalidationSet( | 293 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureClassInvalidationSet( |
294 const AtomicString& className, | 294 const AtomicString& className, |
295 InvalidationType type) { | 295 InvalidationType type) { |
296 RELEASE_ASSERT(!className.isEmpty()); | 296 CHECK(!className.isEmpty()); |
297 return ensureInvalidationSet(m_classInvalidationSets, className, type); | 297 return ensureInvalidationSet(m_classInvalidationSets, className, type); |
298 } | 298 } |
299 | 299 |
300 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureAttributeInvalidationSet( | 300 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureAttributeInvalidationSet( |
301 const AtomicString& attributeName, | 301 const AtomicString& attributeName, |
302 InvalidationType type) { | 302 InvalidationType type) { |
303 RELEASE_ASSERT(!attributeName.isEmpty()); | 303 CHECK(!attributeName.isEmpty()); |
304 return ensureInvalidationSet(m_attributeInvalidationSets, attributeName, | 304 return ensureInvalidationSet(m_attributeInvalidationSets, attributeName, |
305 type); | 305 type); |
306 } | 306 } |
307 | 307 |
308 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureIdInvalidationSet( | 308 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensureIdInvalidationSet( |
309 const AtomicString& id, | 309 const AtomicString& id, |
310 InvalidationType type) { | 310 InvalidationType type) { |
311 RELEASE_ASSERT(!id.isEmpty()); | 311 CHECK(!id.isEmpty()); |
312 return ensureInvalidationSet(m_idInvalidationSets, id, type); | 312 return ensureInvalidationSet(m_idInvalidationSets, id, type); |
313 } | 313 } |
314 | 314 |
315 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensurePseudoInvalidationSet( | 315 ALWAYS_INLINE InvalidationSet& RuleFeatureSet::ensurePseudoInvalidationSet( |
316 CSSSelector::PseudoType pseudoType, | 316 CSSSelector::PseudoType pseudoType, |
317 InvalidationType type) { | 317 InvalidationType type) { |
318 RELEASE_ASSERT(pseudoType != CSSSelector::PseudoUnknown); | 318 CHECK_NE(pseudoType, CSSSelector::PseudoUnknown); |
319 return ensureInvalidationSet(m_pseudoInvalidationSets, pseudoType, type); | 319 return ensureInvalidationSet(m_pseudoInvalidationSets, pseudoType, type); |
320 } | 320 } |
321 | 321 |
322 void RuleFeatureSet::updateFeaturesFromCombinator( | 322 void RuleFeatureSet::updateFeaturesFromCombinator( |
323 const CSSSelector& lastInCompound, | 323 const CSSSelector& lastInCompound, |
324 const CSSSelector* lastCompoundInAdjacentChain, | 324 const CSSSelector* lastCompoundInAdjacentChain, |
325 InvalidationSetFeatures& lastCompoundInAdjacentChainFeatures, | 325 InvalidationSetFeatures& lastCompoundInAdjacentChainFeatures, |
326 InvalidationSetFeatures*& siblingFeatures, | 326 InvalidationSetFeatures*& siblingFeatures, |
327 InvalidationSetFeatures& descendantFeatures) { | 327 InvalidationSetFeatures& descendantFeatures) { |
328 if (lastInCompound.isAdjacentSelector()) { | 328 if (lastInCompound.isAdjacentSelector()) { |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 DCHECK(lastInCompound); | 799 DCHECK(lastInCompound); |
800 updateFeaturesFromCombinator(*lastInCompound, compound, | 800 updateFeaturesFromCombinator(*lastInCompound, compound, |
801 lastCompoundInSiblingChainFeatures, | 801 lastCompoundInSiblingChainFeatures, |
802 siblingFeatures, descendantFeatures); | 802 siblingFeatures, descendantFeatures); |
803 compound = lastInCompound->tagHistory(); | 803 compound = lastInCompound->tagHistory(); |
804 } | 804 } |
805 } | 805 } |
806 | 806 |
807 RuleFeatureSet::SelectorPreMatch RuleFeatureSet::collectFeaturesFromRuleData( | 807 RuleFeatureSet::SelectorPreMatch RuleFeatureSet::collectFeaturesFromRuleData( |
808 const RuleData& ruleData) { | 808 const RuleData& ruleData) { |
809 RELEASE_ASSERT(m_isAlive); | 809 CHECK(m_isAlive); |
810 FeatureMetadata metadata; | 810 FeatureMetadata metadata; |
811 if (collectFeaturesFromSelector(ruleData.selector(), metadata) == | 811 if (collectFeaturesFromSelector(ruleData.selector(), metadata) == |
812 SelectorNeverMatches) | 812 SelectorNeverMatches) |
813 return SelectorNeverMatches; | 813 return SelectorNeverMatches; |
814 | 814 |
815 m_metadata.add(metadata); | 815 m_metadata.add(metadata); |
816 | 816 |
817 if (metadata.foundSiblingSelector) { | 817 if (metadata.foundSiblingSelector) { |
818 m_siblingRules.push_back(RuleFeature(ruleData.rule(), | 818 m_siblingRules.push_back(RuleFeature(ruleData.rule(), |
819 ruleData.selectorIndex(), | 819 ruleData.selectorIndex(), |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 void RuleFeatureSet::FeatureMetadata::clear() { | 916 void RuleFeatureSet::FeatureMetadata::clear() { |
917 usesFirstLineRules = false; | 917 usesFirstLineRules = false; |
918 usesWindowInactiveSelector = false; | 918 usesWindowInactiveSelector = false; |
919 foundSiblingSelector = false; | 919 foundSiblingSelector = false; |
920 foundInsertionPointCrossing = false; | 920 foundInsertionPointCrossing = false; |
921 needsFullRecalcForRuleSetInvalidation = false; | 921 needsFullRecalcForRuleSetInvalidation = false; |
922 maxDirectAdjacentSelectors = 0; | 922 maxDirectAdjacentSelectors = 0; |
923 } | 923 } |
924 | 924 |
925 void RuleFeatureSet::add(const RuleFeatureSet& other) { | 925 void RuleFeatureSet::add(const RuleFeatureSet& other) { |
926 RELEASE_ASSERT(m_isAlive); | 926 CHECK(m_isAlive); |
927 RELEASE_ASSERT(other.m_isAlive); | 927 CHECK(other.m_isAlive); |
928 RELEASE_ASSERT(&other != this); | 928 CHECK_NE(&other, this); |
929 for (const auto& entry : other.m_classInvalidationSets) | 929 for (const auto& entry : other.m_classInvalidationSets) |
930 ensureInvalidationSet(m_classInvalidationSets, entry.key, | 930 ensureInvalidationSet(m_classInvalidationSets, 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_attributeInvalidationSets) | 933 for (const auto& entry : other.m_attributeInvalidationSets) |
934 ensureInvalidationSet(m_attributeInvalidationSets, entry.key, | 934 ensureInvalidationSet(m_attributeInvalidationSets, entry.key, |
935 entry.value->type()) | 935 entry.value->type()) |
936 .combine(*entry.value); | 936 .combine(*entry.value); |
937 for (const auto& entry : other.m_idInvalidationSets) | 937 for (const auto& entry : other.m_idInvalidationSets) |
938 ensureInvalidationSet(m_idInvalidationSets, entry.key, entry.value->type()) | 938 ensureInvalidationSet(m_idInvalidationSets, entry.key, entry.value->type()) |
(...skipping 13 matching lines...) Expand all Loading... |
952 | 952 |
953 m_siblingRules.appendVector(other.m_siblingRules); | 953 m_siblingRules.appendVector(other.m_siblingRules); |
954 m_uncommonAttributeRules.appendVector(other.m_uncommonAttributeRules); | 954 m_uncommonAttributeRules.appendVector(other.m_uncommonAttributeRules); |
955 m_viewportDependentMediaQueryResults.appendVector( | 955 m_viewportDependentMediaQueryResults.appendVector( |
956 other.m_viewportDependentMediaQueryResults); | 956 other.m_viewportDependentMediaQueryResults); |
957 m_deviceDependentMediaQueryResults.appendVector( | 957 m_deviceDependentMediaQueryResults.appendVector( |
958 other.m_deviceDependentMediaQueryResults); | 958 other.m_deviceDependentMediaQueryResults); |
959 } | 959 } |
960 | 960 |
961 void RuleFeatureSet::clear() { | 961 void RuleFeatureSet::clear() { |
962 RELEASE_ASSERT(m_isAlive); | 962 CHECK(m_isAlive); |
963 m_siblingRules.clear(); | 963 m_siblingRules.clear(); |
964 m_uncommonAttributeRules.clear(); | 964 m_uncommonAttributeRules.clear(); |
965 m_metadata.clear(); | 965 m_metadata.clear(); |
966 m_classInvalidationSets.clear(); | 966 m_classInvalidationSets.clear(); |
967 m_attributeInvalidationSets.clear(); | 967 m_attributeInvalidationSets.clear(); |
968 m_idInvalidationSets.clear(); | 968 m_idInvalidationSets.clear(); |
969 m_pseudoInvalidationSets.clear(); | 969 m_pseudoInvalidationSets.clear(); |
970 m_universalSiblingInvalidationSet.clear(); | 970 m_universalSiblingInvalidationSet.clear(); |
971 m_nthInvalidationSet.clear(); | 971 m_nthInvalidationSet.clear(); |
972 m_viewportDependentMediaQueryResults.clear(); | 972 m_viewportDependentMediaQueryResults.clear(); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 bool RuleFeatureSet::InvalidationSetFeatures::hasFeatures() const { | 1231 bool RuleFeatureSet::InvalidationSetFeatures::hasFeatures() const { |
1232 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty() || | 1232 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty() || |
1233 !tagNames.isEmpty() || customPseudoElement; | 1233 !tagNames.isEmpty() || customPseudoElement; |
1234 } | 1234 } |
1235 | 1235 |
1236 bool RuleFeatureSet::InvalidationSetFeatures::hasIdClassOrAttribute() const { | 1236 bool RuleFeatureSet::InvalidationSetFeatures::hasIdClassOrAttribute() const { |
1237 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty(); | 1237 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty(); |
1238 } | 1238 } |
1239 | 1239 |
1240 } // namespace blink | 1240 } // namespace blink |
OLD | NEW |