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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 } | 537 } |
538 | 538 |
539 void RuleFeatureSet::clear() | 539 void RuleFeatureSet::clear() |
540 { | 540 { |
541 siblingRules.clear(); | 541 siblingRules.clear(); |
542 uncommonAttributeRules.clear(); | 542 uncommonAttributeRules.clear(); |
543 m_metadata.clear(); | 543 m_metadata.clear(); |
544 m_classInvalidationSets.clear(); | 544 m_classInvalidationSets.clear(); |
545 m_attributeInvalidationSets.clear(); | 545 m_attributeInvalidationSets.clear(); |
546 m_idInvalidationSets.clear(); | 546 m_idInvalidationSets.clear(); |
547 // We cannot clear m_styleInvalidator here, because the style invalidator mi
ght not | |
548 // have been evaluated yet. If not yet, in StyleInvalidator, there exists so
me element | |
549 // who has needsStyleInvlidation but does not have any invalidation list. | |
550 // This makes Blink not to recalc style correctly. crbug.com/344729. | |
551 } | 547 } |
552 | 548 |
553 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitStr
ing& changedClasses, Element& element) | 549 void RuleFeatureSet::collectInvalidationSetsForClass(InvalidationSetVector& inva
lidationSets, Element& element, const AtomicString& className) const |
554 { | 550 { |
555 unsigned changedSize = changedClasses.size(); | 551 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_classI
nvalidationSets.get(className)) { |
556 for (unsigned i = 0; i < changedSize; ++i) { | 552 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, classChange
, className); |
557 addClassToInvalidationSet(changedClasses[i], element); | 553 invalidationSets.append(invalidationSet); |
558 } | 554 } |
559 } | 555 } |
560 | 556 |
561 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitStr
ing& oldClasses, const SpaceSplitString& newClasses, Element& element) | 557 void RuleFeatureSet::collectInvalidationSetsForId(InvalidationSetVector& invalid
ationSets, Element& element, const AtomicString& id) const |
562 { | 558 { |
563 if (!oldClasses.size()) { | 559 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_idInva
lidationSets.get(id)) { |
564 scheduleStyleInvalidationForClassChange(newClasses, element); | 560 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, idChange, i
d); |
565 return; | 561 invalidationSets.append(invalidationSet); |
566 } | |
567 | |
568 // Class vectors tend to be very short. This is faster than using a hash tab
le. | |
569 BitVector remainingClassBits; | |
570 remainingClassBits.ensureSize(oldClasses.size()); | |
571 | |
572 for (unsigned i = 0; i < newClasses.size(); ++i) { | |
573 bool found = false; | |
574 for (unsigned j = 0; j < oldClasses.size(); ++j) { | |
575 if (newClasses[i] == oldClasses[j]) { | |
576 // Mark each class that is still in the newClasses so we can ski
p doing | |
577 // an n^2 search below when looking for removals. We can't break
from | |
578 // this loop early since a class can appear more than once. | |
579 remainingClassBits.quickSet(j); | |
580 found = true; | |
581 } | |
582 } | |
583 // Class was added. | |
584 if (!found) | |
585 addClassToInvalidationSet(newClasses[i], element); | |
586 } | |
587 | |
588 for (unsigned i = 0; i < oldClasses.size(); ++i) { | |
589 if (remainingClassBits.quickGet(i)) | |
590 continue; | |
591 // Class was removed. | |
592 addClassToInvalidationSet(oldClasses[i], element); | |
593 } | 562 } |
594 } | 563 } |
595 | 564 |
596 void RuleFeatureSet::scheduleStyleInvalidationForAttributeChange(const Qualified
Name& attributeName, Element& element) | 565 void RuleFeatureSet::collectInvalidationSetsForAttribute(InvalidationSetVector&
invalidationSets, Element& element, const QualifiedName& attributeName) const |
597 { | 566 { |
598 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_attrib
uteInvalidationSets.get(attributeName.localName())) { | 567 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_attrib
uteInvalidationSets.get(attributeName.localName())) { |
599 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, attributeCh
ange, attributeName); | 568 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, attributeCh
ange, attributeName); |
600 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); | 569 invalidationSets.append(invalidationSet); |
601 } | 570 } |
602 } | 571 } |
603 | 572 |
604 void RuleFeatureSet::scheduleStyleInvalidationForIdChange(const AtomicString& ol
dId, const AtomicString& newId, Element& element) | 573 void RuleFeatureSet::collectInvalidationSetsForPseudoClass(InvalidationSetVector
& invalidationSets, Element& element, CSSSelector::PseudoType pseudo) const |
605 { | |
606 if (!oldId.isEmpty()) { | |
607 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_id
InvalidationSets.get(oldId)) { | |
608 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, idChang
e, oldId); | |
609 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); | |
610 } | |
611 } | |
612 if (!newId.isEmpty()) { | |
613 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_id
InvalidationSets.get(newId)) { | |
614 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, idChang
e, newId); | |
615 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); | |
616 } | |
617 } | |
618 } | |
619 | |
620 void RuleFeatureSet::scheduleStyleInvalidationForPseudoChange(CSSSelector::Pseud
oType pseudo, Element& element) | |
621 { | 574 { |
622 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_pseudo
InvalidationSets.get(pseudo)) { | 575 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_pseudo
InvalidationSets.get(pseudo)) { |
623 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, pseudoChang
e, pseudo); | 576 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, pseudoChang
e, pseudo); |
624 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); | 577 invalidationSets.append(invalidationSet); |
625 } | 578 } |
626 } | 579 } |
627 | 580 |
628 inline void RuleFeatureSet::addClassToInvalidationSet(const AtomicString& classN
ame, Element& element) | |
629 { | |
630 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_classI
nvalidationSets.get(className)) { | |
631 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, classChange
, className); | |
632 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); | |
633 } | |
634 } | |
635 | |
636 StyleInvalidator& RuleFeatureSet::styleInvalidator() | |
637 { | |
638 return m_styleInvalidator; | |
639 } | |
640 | |
641 DEFINE_TRACE(RuleFeatureSet) | 581 DEFINE_TRACE(RuleFeatureSet) |
642 { | 582 { |
643 #if ENABLE(OILPAN) | 583 #if ENABLE(OILPAN) |
644 visitor->trace(siblingRules); | 584 visitor->trace(siblingRules); |
645 visitor->trace(uncommonAttributeRules); | 585 visitor->trace(uncommonAttributeRules); |
646 visitor->trace(m_classInvalidationSets); | 586 visitor->trace(m_classInvalidationSets); |
647 visitor->trace(m_attributeInvalidationSets); | 587 visitor->trace(m_attributeInvalidationSets); |
648 visitor->trace(m_idInvalidationSets); | 588 visitor->trace(m_idInvalidationSets); |
649 visitor->trace(m_pseudoInvalidationSets); | 589 visitor->trace(m_pseudoInvalidationSets); |
650 visitor->trace(m_styleInvalidator); | |
651 #endif | 590 #endif |
652 } | 591 } |
653 | 592 |
654 } // namespace blink | 593 } // namespace blink |
OLD | NEW |