mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 996796 patch 5 - Move the guts of UpdateThrottledStyle into nsStyleSet, where it can be reused. r=heycam
This commit is contained in:
parent
f402ea6beb
commit
29e1f8c013
@ -248,53 +248,10 @@ CommonAnimationManager::UpdateThrottledStyle(dom::Element* aElement,
|
||||
}
|
||||
|
||||
nsStyleContext* oldStyle = primaryFrame->StyleContext();
|
||||
nsRuleNode* ruleNode = oldStyle->RuleNode();
|
||||
nsTArray<nsStyleSet::RuleAndLevel> rules;
|
||||
do {
|
||||
if (ruleNode->IsRoot()) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsStyleSet::RuleAndLevel curRule;
|
||||
curRule.mLevel = ruleNode->GetLevel();
|
||||
|
||||
if (curRule.mLevel == nsStyleSet::eAnimationSheet) {
|
||||
ElementAnimationCollection* collection =
|
||||
mPresContext->AnimationManager()->GetElementAnimations(
|
||||
aElement,
|
||||
oldStyle->GetPseudoType(),
|
||||
false);
|
||||
NS_ASSERTION(collection,
|
||||
"Rule has level eAnimationSheet without animation on manager");
|
||||
|
||||
mPresContext->AnimationManager()->UpdateStyleAndEvents(
|
||||
collection, mPresContext->RefreshDriver()->MostRecentRefresh(),
|
||||
EnsureStyleRule_IsNotThrottled);
|
||||
curRule.mRule = collection->mStyleRule;
|
||||
} else if (curRule.mLevel == nsStyleSet::eTransitionSheet) {
|
||||
ElementAnimationCollection* collection =
|
||||
mPresContext->TransitionManager()->GetElementTransitions(
|
||||
aElement,
|
||||
oldStyle->GetPseudoType(),
|
||||
false);
|
||||
NS_ASSERTION(collection,
|
||||
"Rule has level eTransitionSheet without transition on manager");
|
||||
|
||||
collection->EnsureStyleRuleFor(
|
||||
mPresContext->RefreshDriver()->MostRecentRefresh(),
|
||||
EnsureStyleRule_IsNotThrottled);
|
||||
curRule.mRule = collection->mStyleRule;
|
||||
} else {
|
||||
curRule.mRule = ruleNode->GetRule();
|
||||
}
|
||||
|
||||
if (curRule.mRule) {
|
||||
rules.AppendElement(curRule);
|
||||
}
|
||||
} while ((ruleNode = ruleNode->GetParent()));
|
||||
|
||||
nsRefPtr<nsStyleContext> newStyle = mPresContext->PresShell()->StyleSet()->
|
||||
ResolveStyleForRules(aParentStyle, oldStyle, rules);
|
||||
nsStyleSet* styleSet = mPresContext->StyleSet();
|
||||
nsRefPtr<nsStyleContext> newStyle =
|
||||
styleSet->ResolveStyleWithReplacement(aElement, aParentStyle, oldStyle);
|
||||
|
||||
// We absolutely must call CalcStyleDifference in order to ensure the
|
||||
// new context has all the structs cached that the old context had.
|
||||
@ -306,8 +263,7 @@ CommonAnimationManager::UpdateThrottledStyle(dom::Element* aElement,
|
||||
|
||||
primaryFrame->SetStyleContext(newStyle);
|
||||
|
||||
ReparentBeforeAndAfter(aElement, primaryFrame, newStyle,
|
||||
mPresContext->PresShell()->StyleSet());
|
||||
ReparentBeforeAndAfter(aElement, primaryFrame, newStyle, styleSet);
|
||||
|
||||
return newStyle;
|
||||
}
|
||||
|
@ -1320,6 +1320,60 @@ nsStyleSet::ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
|
||||
nullptr, flags);
|
||||
}
|
||||
|
||||
already_AddRefed<nsStyleContext>
|
||||
nsStyleSet::ResolveStyleWithReplacement(Element* aElement,
|
||||
nsStyleContext* aNewParentContext,
|
||||
nsStyleContext* aOldStyleContext)
|
||||
{
|
||||
nsRuleNode* ruleNode = aOldStyleContext->RuleNode();
|
||||
nsTArray<nsStyleSet::RuleAndLevel> rules;
|
||||
do {
|
||||
if (ruleNode->IsRoot()) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsStyleSet::RuleAndLevel curRule;
|
||||
curRule.mLevel = ruleNode->GetLevel();
|
||||
|
||||
if (curRule.mLevel == nsStyleSet::eAnimationSheet) {
|
||||
nsAnimationManager* animationManager = PresContext()->AnimationManager();
|
||||
ElementAnimationCollection* collection = animationManager->GetElementAnimations(
|
||||
aElement, aOldStyleContext->GetPseudoType(), false);
|
||||
NS_ASSERTION(collection,
|
||||
"Rule has level eAnimationSheet without animation on manager");
|
||||
|
||||
animationManager->UpdateStyleAndEvents(
|
||||
collection, PresContext()->RefreshDriver()->MostRecentRefresh(),
|
||||
EnsureStyleRule_IsNotThrottled);
|
||||
curRule.mRule = collection->mStyleRule;
|
||||
} else if (curRule.mLevel == nsStyleSet::eTransitionSheet) {
|
||||
nsPresContext* presContext = PresContext();
|
||||
ElementAnimationCollection* collection =
|
||||
presContext->TransitionManager()->GetElementTransitions(
|
||||
aElement,
|
||||
aOldStyleContext->GetPseudoType(),
|
||||
false);
|
||||
NS_ASSERTION(collection,
|
||||
"Rule has level eTransitionSheet without transition on manager");
|
||||
|
||||
collection->EnsureStyleRuleFor(
|
||||
presContext->RefreshDriver()->MostRecentRefresh(),
|
||||
EnsureStyleRule_IsNotThrottled);
|
||||
curRule.mRule = collection->mStyleRule;
|
||||
} else {
|
||||
curRule.mRule = ruleNode->GetRule();
|
||||
}
|
||||
|
||||
if (curRule.mRule) {
|
||||
rules.AppendElement(curRule);
|
||||
}
|
||||
} while ((ruleNode = ruleNode->GetParent()));
|
||||
|
||||
// FIXME: Does this handle visited contexts correctly???
|
||||
return ResolveStyleForRules(aNewParentContext, aOldStyleContext, rules);
|
||||
}
|
||||
|
||||
|
||||
already_AddRefed<nsStyleContext>
|
||||
nsStyleSet::ResolveStyleForNonElement(nsStyleContext* aParentContext)
|
||||
{
|
||||
|
@ -134,6 +134,13 @@ class nsStyleSet
|
||||
ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
|
||||
const nsCOMArray<nsIStyleRule> &aRules);
|
||||
|
||||
// Resolve style by replacing the animation and transition rules, but
|
||||
// otherwise maintaining the status quo.
|
||||
already_AddRefed<nsStyleContext>
|
||||
ResolveStyleWithReplacement(mozilla::dom::Element* aElement,
|
||||
nsStyleContext* aNewParentContext,
|
||||
nsStyleContext* aOldStyleContext);
|
||||
|
||||
// Get a style context for a non-element (which no rules will match),
|
||||
// such as text nodes, placeholder frames, and the nsFirstLetterFrame
|
||||
// for everything after the first letter.
|
||||
|
Loading…
Reference in New Issue
Block a user