Bug 977991 patch 1 - Expose variant of RulesMatching on nsHTMLCSSStyleSheet that is less work to call. r=birtles

This allows nsStyleSet::RuleNodeWithReplacement to call it without
constructing an entire (and unnecessary) ElementRuleProcessorData, which
will happen in patch 3.
This commit is contained in:
L. David Baron 2014-09-13 06:17:36 -07:00
parent 86f1147a3a
commit fbfb854963
2 changed files with 29 additions and 9 deletions

View File

@ -54,29 +54,36 @@ NS_IMPL_ISUPPORTS(nsHTMLCSSStyleSheet, nsIStyleRuleProcessor)
/* virtual */ void
nsHTMLCSSStyleSheet::RulesMatching(ElementRuleProcessorData* aData)
{
Element* element = aData->mElement;
ElementRulesMatching(aData->mPresContext, aData->mElement,
aData->mRuleWalker);
}
void
nsHTMLCSSStyleSheet::ElementRulesMatching(nsPresContext* aPresContext,
Element* aElement,
nsRuleWalker* aRuleWalker)
{
// just get the one and only style rule from the content's STYLE attribute
css::StyleRule* rule = element->GetInlineStyleRule();
css::StyleRule* rule = aElement->GetInlineStyleRule();
if (rule) {
rule->RuleMatched();
aData->mRuleWalker->Forward(rule);
aRuleWalker->Forward(rule);
}
rule = element->GetSMILOverrideStyleRule();
rule = aElement->GetSMILOverrideStyleRule();
if (rule) {
if (aData->mPresContext->IsProcessingRestyles() &&
!aData->mPresContext->IsProcessingAnimationStyleChange()) {
if (aPresContext->IsProcessingRestyles() &&
!aPresContext->IsProcessingAnimationStyleChange()) {
// Non-animation restyle -- don't process SMIL override style, because we
// don't want SMIL animation to trigger new CSS transitions. Instead,
// request an Animation restyle, so we still get noticed.
aData->mPresContext->PresShell()->RestyleForAnimation(element,
eRestyle_Self);
aPresContext->PresShell()->RestyleForAnimation(aElement,
eRestyle_Self);
} else {
// Animation restyle (or non-restyle traversal of rules)
// Now we can walk SMIL overrride style, without triggering transitions.
rule->RuleMatched();
aData->mRuleWalker->Forward(rule);
aRuleWalker->Forward(rule);
}
}
}

View File

@ -16,8 +16,15 @@
#include "nsDataHashtable.h"
#include "nsIStyleRuleProcessor.h"
class nsRuleWalker;
struct MiscContainer;
namespace mozilla {
namespace dom {
class Element;
}
}
class nsHTMLCSSStyleSheet MOZ_FINAL : public nsIStyleRuleProcessor
{
public:
@ -43,6 +50,12 @@ public:
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
const MOZ_MUST_OVERRIDE MOZ_OVERRIDE;
// Variant of RulesMatching method above that is specific to this
// rule processor.
void ElementRulesMatching(nsPresContext* aPresContext,
mozilla::dom::Element* aElement,
nsRuleWalker* aRuleWalker);
void CacheStyleAttr(const nsAString& aSerialized, MiscContainer* aValue);
void EvictStyleAttr(const nsAString& aSerialized, MiscContainer* aValue);
MiscContainer* LookupStyleAttr(const nsAString& aSerialized);