| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 } | 172 } |
| 173 | 173 |
| 174 DescendantInvalidationSet* RuleFeatureSet::invalidationSetForSelector(const CSSS
elector& selector) | 174 DescendantInvalidationSet* RuleFeatureSet::invalidationSetForSelector(const CSSS
elector& selector) |
| 175 { | 175 { |
| 176 if (selector.m_match == CSSSelector::Class) | 176 if (selector.m_match == CSSSelector::Class) |
| 177 return &ensureClassInvalidationSet(selector.value()); | 177 return &ensureClassInvalidationSet(selector.value()); |
| 178 if (selector.isAttributeSelector()) | 178 if (selector.isAttributeSelector()) |
| 179 return &ensureAttributeInvalidationSet(selector.attribute().localName())
; | 179 return &ensureAttributeInvalidationSet(selector.attribute().localName())
; |
| 180 if (selector.m_match == CSSSelector::Id) | 180 if (selector.m_match == CSSSelector::Id) |
| 181 return &ensureIdInvalidationSet(selector.value()); | 181 return &ensureIdInvalidationSet(selector.value()); |
| 182 if (selector.m_match == CSSSelector::PseudoClass) { |
| 183 CSSSelector::PseudoType pseudo = selector.pseudoType(); |
| 184 if (pseudo == CSSSelector::PseudoHover || pseudo == CSSSelector::PseudoA
ctive || pseudo == CSSSelector::PseudoFocus) |
| 185 return &ensurePseudoInvalidationSet(pseudo); |
| 186 } |
| 182 return 0; | 187 return 0; |
| 183 } | 188 } |
| 184 | 189 |
| 185 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const
CSSSelector& selector) | 190 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const
CSSSelector& selector) |
| 186 { | 191 { |
| 187 InvalidationSetMode mode = invalidationSetModeForSelector(selector); | 192 InvalidationSetMode mode = invalidationSetModeForSelector(selector); |
| 188 if (mode != AddFeatures) | 193 if (mode != AddFeatures) |
| 189 return mode; | 194 return mode; |
| 190 | 195 |
| 191 InvalidationSetFeatures features; | 196 InvalidationSetFeatures features; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 } | 308 } |
| 304 | 309 |
| 305 DescendantInvalidationSet& RuleFeatureSet::ensureIdInvalidationSet(const AtomicS
tring& id) | 310 DescendantInvalidationSet& RuleFeatureSet::ensureIdInvalidationSet(const AtomicS
tring& id) |
| 306 { | 311 { |
| 307 InvalidationSetMap::AddResult addResult = m_idInvalidationSets.add(id, nullp
tr); | 312 InvalidationSetMap::AddResult addResult = m_idInvalidationSets.add(id, nullp
tr); |
| 308 if (addResult.isNewEntry) | 313 if (addResult.isNewEntry) |
| 309 addResult.storedValue->value = DescendantInvalidationSet::create(); | 314 addResult.storedValue->value = DescendantInvalidationSet::create(); |
| 310 return *addResult.storedValue->value; | 315 return *addResult.storedValue->value; |
| 311 } | 316 } |
| 312 | 317 |
| 318 DescendantInvalidationSet& RuleFeatureSet::ensurePseudoInvalidationSet(CSSSelect
or::PseudoType pseudoType) |
| 319 { |
| 320 PseudoTypeInvalidationSetMap::AddResult addResult = m_pseudoInvalidationSets
.add(pseudoType, nullptr); |
| 321 if (addResult.isNewEntry) |
| 322 addResult.storedValue->value = DescendantInvalidationSet::create(); |
| 323 return *addResult.storedValue->value; |
| 324 } |
| 325 |
| 313 void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector) | 326 void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector) |
| 314 { | 327 { |
| 315 collectFeaturesFromSelector(selector, m_metadata, UseSubtreeStyleChange); | 328 collectFeaturesFromSelector(selector, m_metadata, UseSubtreeStyleChange); |
| 316 } | 329 } |
| 317 | 330 |
| 318 void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector, Ru
leFeatureSet::FeatureMetadata& metadata, InvalidationSetMode mode) | 331 void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector, Ru
leFeatureSet::FeatureMetadata& metadata, InvalidationSetMode mode) |
| 319 { | 332 { |
| 320 unsigned maxDirectAdjacentSelectors = 0; | 333 unsigned maxDirectAdjacentSelectors = 0; |
| 321 | 334 |
| 322 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { | 335 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { |
| 323 if (mode != AddFeatures && (current->m_match == CSSSelector::Class || cu
rrent->m_match == CSSSelector::Id || current->isAttributeSelector())) { | 336 if (mode != AddFeatures) { |
| 324 DescendantInvalidationSet* invalidationSet = invalidationSetForSelec
tor(*current); | 337 if (DescendantInvalidationSet* invalidationSet = invalidationSetForS
elector(*current)) { |
| 325 ASSERT(invalidationSet); | 338 if (mode == UseSubtreeStyleChange) |
| 326 if (mode == UseSubtreeStyleChange) | 339 invalidationSet->setWholeSubtreeInvalid(); |
| 327 invalidationSet->setWholeSubtreeInvalid(); | 340 } |
| 328 } | 341 } |
| 329 if (current->pseudoType() == CSSSelector::PseudoFirstLine) | 342 if (current->pseudoType() == CSSSelector::PseudoFirstLine) |
| 330 metadata.usesFirstLineRules = true; | 343 metadata.usesFirstLineRules = true; |
| 331 if (current->isDirectAdjacentSelector()) { | 344 if (current->isDirectAdjacentSelector()) { |
| 332 maxDirectAdjacentSelectors++; | 345 maxDirectAdjacentSelectors++; |
| 333 } else if (maxDirectAdjacentSelectors) { | 346 } else if (maxDirectAdjacentSelectors) { |
| 334 if (maxDirectAdjacentSelectors > metadata.maxDirectAdjacentSelectors
) | 347 if (maxDirectAdjacentSelectors > metadata.maxDirectAdjacentSelectors
) |
| 335 metadata.maxDirectAdjacentSelectors = maxDirectAdjacentSelectors
; | 348 metadata.maxDirectAdjacentSelectors = maxDirectAdjacentSelectors
; |
| 336 maxDirectAdjacentSelectors = 0; | 349 maxDirectAdjacentSelectors = 0; |
| 337 } | 350 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 } | 383 } |
| 371 | 384 |
| 372 void RuleFeatureSet::add(const RuleFeatureSet& other) | 385 void RuleFeatureSet::add(const RuleFeatureSet& other) |
| 373 { | 386 { |
| 374 for (InvalidationSetMap::const_iterator it = other.m_classInvalidationSets.b
egin(); it != other.m_classInvalidationSets.end(); ++it) | 387 for (InvalidationSetMap::const_iterator it = other.m_classInvalidationSets.b
egin(); it != other.m_classInvalidationSets.end(); ++it) |
| 375 ensureClassInvalidationSet(it->key).combine(*it->value); | 388 ensureClassInvalidationSet(it->key).combine(*it->value); |
| 376 for (InvalidationSetMap::const_iterator it = other.m_attributeInvalidationSe
ts.begin(); it != other.m_attributeInvalidationSets.end(); ++it) | 389 for (InvalidationSetMap::const_iterator it = other.m_attributeInvalidationSe
ts.begin(); it != other.m_attributeInvalidationSets.end(); ++it) |
| 377 ensureAttributeInvalidationSet(it->key).combine(*it->value); | 390 ensureAttributeInvalidationSet(it->key).combine(*it->value); |
| 378 for (InvalidationSetMap::const_iterator it = other.m_idInvalidationSets.begi
n(); it != other.m_idInvalidationSets.end(); ++it) | 391 for (InvalidationSetMap::const_iterator it = other.m_idInvalidationSets.begi
n(); it != other.m_idInvalidationSets.end(); ++it) |
| 379 ensureIdInvalidationSet(it->key).combine(*it->value); | 392 ensureIdInvalidationSet(it->key).combine(*it->value); |
| 393 for (PseudoTypeInvalidationSetMap::const_iterator it = other.m_pseudoInvalid
ationSets.begin(); it != other.m_pseudoInvalidationSets.end(); ++it) |
| 394 ensurePseudoInvalidationSet(static_cast<CSSSelector::PseudoType>(it->key
)).combine(*it->value); |
| 380 | 395 |
| 381 m_metadata.add(other.m_metadata); | 396 m_metadata.add(other.m_metadata); |
| 382 | 397 |
| 383 siblingRules.appendVector(other.siblingRules); | 398 siblingRules.appendVector(other.siblingRules); |
| 384 uncommonAttributeRules.appendVector(other.uncommonAttributeRules); | 399 uncommonAttributeRules.appendVector(other.uncommonAttributeRules); |
| 385 } | 400 } |
| 386 | 401 |
| 387 void RuleFeatureSet::clear() | 402 void RuleFeatureSet::clear() |
| 388 { | 403 { |
| 389 siblingRules.clear(); | 404 siblingRules.clear(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 if (!oldId.isEmpty()) { | 465 if (!oldId.isEmpty()) { |
| 451 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_idInvalidation
Sets.get(oldId)) | 466 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_idInvalidation
Sets.get(oldId)) |
| 452 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); | 467 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); |
| 453 } | 468 } |
| 454 if (!newId.isEmpty()) { | 469 if (!newId.isEmpty()) { |
| 455 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_idInvalidation
Sets.get(newId)) | 470 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_idInvalidation
Sets.get(newId)) |
| 456 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); | 471 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); |
| 457 } | 472 } |
| 458 } | 473 } |
| 459 | 474 |
| 475 void RuleFeatureSet::scheduleStyleInvalidationForPseudoChange(CSSSelector::Pseud
oType pseudo, Element& element) |
| 476 { |
| 477 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_pseudoInvalidation
Sets.get(pseudo)) |
| 478 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); |
| 479 } |
| 480 |
| 460 void RuleFeatureSet::addClassToInvalidationSet(const AtomicString& className, El
ement& element) | 481 void RuleFeatureSet::addClassToInvalidationSet(const AtomicString& className, El
ement& element) |
| 461 { | 482 { |
| 462 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_classInvalidationS
ets.get(className)) | 483 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_classInvalidationS
ets.get(className)) |
| 463 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); | 484 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); |
| 464 } | 485 } |
| 465 | 486 |
| 466 StyleInvalidator& RuleFeatureSet::styleInvalidator() | 487 StyleInvalidator& RuleFeatureSet::styleInvalidator() |
| 467 { | 488 { |
| 468 return m_styleInvalidator; | 489 return m_styleInvalidator; |
| 469 } | 490 } |
| 470 | 491 |
| 471 } // namespace WebCore | 492 } // namespace WebCore |
| OLD | NEW |