Chromium Code Reviews| 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 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 14 matching lines...) Expand all Loading... | |
| 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 26 * Boston, MA 02110-1301, USA. | 26 * Boston, MA 02110-1301, USA. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "core/css/RuleFeature.h" | 30 #include "core/css/RuleFeature.h" |
| 31 | 31 |
| 32 #include "core/HTMLNames.h" | 32 #include "core/HTMLNames.h" |
| 33 #include "core/css/CSSSelector.h" | 33 #include "core/css/CSSSelector.h" |
| 34 #include "core/css/CSSSelectorList.h" | 34 #include "core/css/CSSSelectorList.h" |
| 35 #include "core/css/CSSValueList.h" | |
| 35 #include "core/css/RuleSet.h" | 36 #include "core/css/RuleSet.h" |
| 37 #include "core/css/StylePropertySet.h" | |
| 36 #include "core/css/StyleRule.h" | 38 #include "core/css/StyleRule.h" |
| 37 #include "core/css/invalidation/DescendantInvalidationSet.h" | 39 #include "core/css/invalidation/DescendantInvalidationSet.h" |
| 38 #include "core/dom/Element.h" | 40 #include "core/dom/Element.h" |
| 39 #include "core/dom/Node.h" | 41 #include "core/dom/Node.h" |
| 40 #include "core/inspector/InspectorTraceEvents.h" | 42 #include "core/inspector/InspectorTraceEvents.h" |
| 41 #include "wtf/BitVector.h" | 43 #include "wtf/BitVector.h" |
| 42 | 44 |
| 43 namespace blink { | 45 namespace blink { |
| 44 | 46 |
| 45 #if ENABLE(ASSERT) | 47 #if ENABLE(ASSERT) |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 void RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector) | 281 void RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector) |
| 280 { | 282 { |
| 281 InvalidationSetFeatures features; | 283 InvalidationSetFeatures features; |
| 282 auto result = extractInvalidationSetFeatures(selector, features, false); | 284 auto result = extractInvalidationSetFeatures(selector, features, false); |
| 283 if (result.first) { | 285 if (result.first) { |
| 284 features.forceSubtree = result.second == ForceSubtree; | 286 features.forceSubtree = result.second == ForceSubtree; |
| 285 addFeaturesToInvalidationSets(*result.first, features); | 287 addFeaturesToInvalidationSets(*result.first, features); |
| 286 } | 288 } |
| 287 } | 289 } |
| 288 | 290 |
| 291 void RuleFeatureSet::updateInvalidationSetsForContentAttribute(StyleRule* styleR ule) | |
| 292 { | |
| 293 const StylePropertySet& propertySet = styleRule->properties(); | |
| 294 | |
| 295 int propertyIndex = propertySet.findPropertyIndex(CSSPropertyContent); | |
| 296 | |
| 297 if (propertyIndex == -1) | |
| 298 return; | |
| 299 | |
| 300 StylePropertySet::PropertyReference contentProperty = propertySet.propertyAt (propertyIndex); | |
| 301 CSSValue* contentValue = contentProperty.value(); | |
| 302 | |
| 303 if (!contentValue->isValueList()) | |
| 304 return; | |
| 305 | |
| 306 for (CSSValueListIterator i = contentValue; i.hasMore(); i.advance()) { | |
| 307 CSSValue* item = i.value(); | |
| 308 if (!item->isPrimitiveValue()) | |
| 309 continue; | |
| 310 CSSPrimitiveValue* primitiveItem = toCSSPrimitiveValue(item); | |
| 311 if (!primitiveItem->isAttr()) | |
| 312 continue; | |
| 313 ensureAttributeInvalidationSet(AtomicString(primitiveItem->getStringValu e())); | |
| 314 } | |
| 315 } | |
| 316 | |
| 289 std::pair<const CSSSelector*, RuleFeatureSet::UseFeaturesType> | 317 std::pair<const CSSSelector*, RuleFeatureSet::UseFeaturesType> |
| 290 RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelector& selector, Inva lidationSetFeatures& features, bool negated) | 318 RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelector& selector, Inva lidationSetFeatures& features, bool negated) |
| 291 { | 319 { |
| 292 bool foundFeatures = false; | 320 bool foundFeatures = false; |
| 293 for (const CSSSelector* current = &selector; current; current = current->tag History()) { | 321 for (const CSSSelector* current = &selector; current; current = current->tag History()) { |
| 294 if (!negated) | 322 if (!negated) |
| 295 foundFeatures |= extractInvalidationSetFeature(*current, features); | 323 foundFeatures |= extractInvalidationSetFeature(*current, features); |
| 296 // Initialize the entry in the invalidation set map, if supported. | 324 // Initialize the entry in the invalidation set map, if supported. |
| 297 if (!invalidationSetForSelector(*current)) { | 325 if (!invalidationSetForSelector(*current)) { |
| 298 if (requiresSubtreeInvalidation(*current)) { | 326 if (requiresSubtreeInvalidation(*current)) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 if (current->relation() == CSSSelector::SubSelector) | 413 if (current->relation() == CSSSelector::SubSelector) |
| 386 continue; | 414 continue; |
| 387 | 415 |
| 388 if (current->isShadowSelector()) | 416 if (current->isShadowSelector()) |
| 389 features.treeBoundaryCrossing = true; | 417 features.treeBoundaryCrossing = true; |
| 390 | 418 |
| 391 features.adjacent = current->isAdjacentSelector(); | 419 features.adjacent = current->isAdjacentSelector(); |
| 392 } | 420 } |
| 393 } | 421 } |
| 394 | 422 |
| 395 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) | |
| 396 { | |
| 397 ensureAttributeInvalidationSet(attributeName); | |
| 398 } | |
| 399 | |
| 400 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) | 423 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) |
| 401 { | 424 { |
| 402 updateInvalidationSets(ruleData.selector()); | 425 updateInvalidationSets(ruleData.selector()); |
| 426 updateInvalidationSetsForContentAttribute(ruleData.rule()); | |
|
rune
2014/12/10 13:03:55
There's one RuleData per selector in the selector
| |
| 403 | 427 |
| 404 FeatureMetadata metadata; | 428 FeatureMetadata metadata; |
| 405 collectFeaturesFromSelector(ruleData.selector(), metadata); | 429 collectFeaturesFromSelector(ruleData.selector(), metadata); |
| 406 m_metadata.add(metadata); | 430 m_metadata.add(metadata); |
| 407 | 431 |
| 408 if (metadata.foundSiblingSelector) | 432 if (metadata.foundSiblingSelector) |
| 409 siblingRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex( ), ruleData.hasDocumentSecurityOrigin())); | 433 siblingRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex( ), ruleData.hasDocumentSecurityOrigin())); |
| 410 if (ruleData.containsUncommonAttributeSelector()) | 434 if (ruleData.containsUncommonAttributeSelector()) |
| 411 uncommonAttributeRules.append(RuleFeature(ruleData.rule(), ruleData.sele ctorIndex(), ruleData.hasDocumentSecurityOrigin())); | 435 uncommonAttributeRules.append(RuleFeature(ruleData.rule(), ruleData.sele ctorIndex(), ruleData.hasDocumentSecurityOrigin())); |
| 412 } | 436 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 visitor->trace(uncommonAttributeRules); | 634 visitor->trace(uncommonAttributeRules); |
| 611 visitor->trace(m_classInvalidationSets); | 635 visitor->trace(m_classInvalidationSets); |
| 612 visitor->trace(m_attributeInvalidationSets); | 636 visitor->trace(m_attributeInvalidationSets); |
| 613 visitor->trace(m_idInvalidationSets); | 637 visitor->trace(m_idInvalidationSets); |
| 614 visitor->trace(m_pseudoInvalidationSets); | 638 visitor->trace(m_pseudoInvalidationSets); |
| 615 visitor->trace(m_styleInvalidator); | 639 visitor->trace(m_styleInvalidator); |
| 616 #endif | 640 #endif |
| 617 } | 641 } |
| 618 | 642 |
| 619 } // namespace blink | 643 } // namespace blink |
| OLD | NEW |