| Index: Source/core/dom/Element.cpp
|
| diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
|
| index 45ff5c326d6a6bf146c7c1bd35870a4174f8f4e0..fa737a7d41b2aac65697cfdb14f461f421c0ab2f 100644
|
| --- a/Source/core/dom/Element.cpp
|
| +++ b/Source/core/dom/Element.cpp
|
| @@ -1044,19 +1044,27 @@ static inline bool classStringHasClassName(const AtomicString& newClassString)
|
| return classStringHasClassName(newClassString.characters16(), length);
|
| }
|
|
|
| +static bool debug = false;
|
| +
|
| +
|
| template<typename Checker>
|
| -static bool checkSelectorForClassChange(const SpaceSplitString& changedClasses, const Checker& checker)
|
| +bool Element::checkSelectorForClassChange(const SpaceSplitString& changedClasses, const Checker& checker)
|
| {
|
| unsigned changedSize = changedClasses.size();
|
| for (unsigned i = 0; i < changedSize; ++i) {
|
| - if (checker.hasSelectorForClass(changedClasses[i]))
|
| - return true;
|
| + RuleSetAnalyzer* ruleSetAnalyzer = checker.getRuleSetAnalyzer();
|
| + if (!ruleSetAnalyzer || !ruleSetAnalyzer->scheduleClassInvalidationForElement(changedClasses[i], this)) {
|
| + if (debug)
|
| + printf("Fail!!");
|
| + if (checker.hasSelectorForClass(changedClasses[i]))
|
| + return true;
|
| + }
|
| }
|
| return false;
|
| }
|
|
|
| template<typename Checker>
|
| -static bool checkSelectorForClassChange(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses, const Checker& checker)
|
| +bool Element::checkSelectorForClassChange(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses, const Checker& checker)
|
| {
|
| if (!oldClasses.size())
|
| return checkSelectorForClassChange(newClasses, checker);
|
| @@ -1064,6 +1072,7 @@ static bool checkSelectorForClassChange(const SpaceSplitString& oldClasses, cons
|
| // Class vectors tend to be very short. This is faster than using a hash table.
|
| BitVector remainingClassBits;
|
| remainingClassBits.ensureSize(oldClasses.size());
|
| + RuleSetAnalyzer* ruleSetAnalyzer = checker.getRuleSetAnalyzer();
|
|
|
| for (unsigned i = 0; i < newClasses.size(); ++i) {
|
| bool found = false;
|
| @@ -1077,16 +1086,29 @@ static bool checkSelectorForClassChange(const SpaceSplitString& oldClasses, cons
|
| }
|
| }
|
| // Class was added.
|
| - if (!found && checker.hasSelectorForClass(newClasses[i]))
|
| - return true;
|
| + if (!found) {
|
| + if (!ruleSetAnalyzer || !ruleSetAnalyzer->scheduleClassInvalidationForElement(newClasses[i], this)) {
|
| + if (debug)
|
| + printf("Fail!!");
|
| +
|
| + if (checker.hasSelectorForClass(newClasses[i]))
|
| + return true;
|
| + }
|
| + }
|
| }
|
|
|
| for (unsigned i = 0; i < oldClasses.size(); ++i) {
|
| if (remainingClassBits.quickGet(i))
|
| continue;
|
| +
|
| // Class was removed.
|
| - if (checker.hasSelectorForClass(oldClasses[i]))
|
| - return true;
|
| + if (!ruleSetAnalyzer || !ruleSetAnalyzer->scheduleClassInvalidationForElement(oldClasses[i], this)) {
|
| + if (debug)
|
| + printf("Fail!!");
|
| +
|
| + if (checker.hasSelectorForClass(oldClasses[i]))
|
| + return true;
|
| + }
|
| }
|
|
|
| return false;
|
| @@ -1606,11 +1628,16 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change)
|
| ASSERT(!parentOrShadowHostNode()->needsStyleRecalc());
|
| ASSERT(change >= Inherit || needsStyleRecalc());
|
| ASSERT(parentRenderStyle());
|
| + if (debug)
|
| + printf("recalcOwnStyle: outerHTML=%s", outerHTML().ascii().data());
|
|
|
| RefPtr<RenderStyle> oldStyle = renderStyle();
|
| RefPtr<RenderStyle> newStyle = styleForRenderer();
|
| StyleRecalcChange localChange = RenderStyle::compare(oldStyle.get(), newStyle.get());
|
| -
|
| + if (debug) {
|
| + printf("localChange=%d\n", localChange);
|
| + printf("background color=%s\n", newStyle->backgroundColor().serialized().ascii().data());
|
| + }
|
| ASSERT(newStyle);
|
|
|
| if (localChange == Reattach) {
|
| @@ -1690,6 +1717,8 @@ void Element::recalcChildStyle(StyleRecalcChange change)
|
| parentPusher.push();
|
| element->recalcStyle(change, lastTextNode);
|
| } else if (element->supportsStyleSharing()) {
|
| + if (debug)
|
| + printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!! style sharing for element outerHTML=%s\n", element->outerHTML().ascii().data());
|
| styleResolver.addToStyleSharingList(*element);
|
| }
|
| if (element->renderer())
|
| @@ -2542,6 +2571,16 @@ RenderStyle* Element::computedStyle(PseudoId pseudoElementSpecifier)
|
| return pseudoElementSpecifier ? rareData.computedStyle()->getCachedPseudoStyle(pseudoElementSpecifier) : rareData.computedStyle();
|
| }
|
|
|
| +bool Element::needsInvalidation() const
|
| +{
|
| + if (!document().styleResolver())
|
| + return false;
|
| +
|
| + if (RuleSetAnalyzer* analyzer = document().styleResolver()->ensureRuleFeatureSet().getRuleSetAnalyzer())
|
| + return analyzer->needsInvalidation(this);
|
| + return false;
|
| +}
|
| +
|
| void Element::setStyleAffectedByEmpty()
|
| {
|
| ensureElementRareData().setStyleAffectedByEmpty(true);
|
|
|