Bug 1075137 patch 4 - Convert callers from IsProcessingRestyles/IsProcessingAnimationStyleChange to SkipAnimationRules/PostAnimationRestyles. r=birtles

This commit is contained in:
L. David Baron 2014-10-02 21:53:24 -07:00
Родитель 5975be57fc
Коммит 9e7caa1603
6 изменённых файлов: 52 добавлений и 35 удалений

Просмотреть файл

@ -259,6 +259,7 @@ LOCAL_INCLUDES += [
'/dom/smil',
'/dom/xbl',
'/dom/xml',
'/layout/base',
'/layout/generic',
'/layout/style',
'/layout/svg',

Просмотреть файл

@ -51,6 +51,7 @@
#include "nsSMILAnimationController.h"
#include "mozilla/dom/SVGElementBinding.h"
#include "mozilla/unused.h"
#include "RestyleManager.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -916,17 +917,18 @@ nsSVGElement::WalkAnimatedContentStyleRules(nsRuleWalker* aRuleWalker)
// whether this is a "no-animation restyle". (This should match the check
// in nsHTMLCSSStyleSheet::RulesMatching(), where we determine whether to
// apply the SMILOverrideStyle.)
nsIDocument* doc = OwnerDoc();
nsIPresShell* shell = doc->GetShell();
nsPresContext* context = shell ? shell->GetPresContext() : nullptr;
if (context && context->IsProcessingRestyles() &&
!context->IsProcessingAnimationStyleChange()) {
// Any style changes right now could trigger CSS Transitions. We don't
// want that to happen from SMIL-animated value of mapped attrs, so
// ignore animated value for now, and request an animation restyle to
// get our animated value noticed.
shell->RestyleForAnimation(this,
eRestyle_SVGAttrAnimations | eRestyle_ChangeAnimationPhase);
nsPresContext* context = aRuleWalker->PresContext();
nsIPresShell* shell = context->PresShell();
RestyleManager* restyleManager = context->RestyleManager();
if (restyleManager->SkipAnimationRules()) {
if (restyleManager->PostAnimationRestyles()) {
// Any style changes right now could trigger CSS Transitions. We don't
// want that to happen from SMIL-animated value of mapped attrs, so
// ignore animated value for now, and request an animation restyle to
// get our animated value noticed.
shell->RestyleForAnimation(this,
eRestyle_SVGAttrAnimations | eRestyle_ChangeAnimationPhase);
}
} else {
// Ok, this is an animation restyle -- go ahead and update/walk the
// animated content style rule.

Просмотреть файл

@ -667,12 +667,12 @@ nsAnimationManager::GetAnimationRule(mozilla::dom::Element* aElement,
return nullptr;
}
if (mPresContext->IsProcessingRestyles() &&
!mPresContext->IsProcessingAnimationStyleChange()) {
RestyleManager* restyleManager = mPresContext->RestyleManager();
if (restyleManager->SkipAnimationRules()) {
// During the non-animation part of processing restyles, we don't
// add the animation rule.
if (collection->mStyleRule) {
if (collection->mStyleRule && restyleManager->PostAnimationRestyles()) {
collection->PostRestyleForAnimation(mPresContext);
}

Просмотреть файл

@ -17,6 +17,7 @@
#include "mozilla/dom/Element.h"
#include "nsAttrValue.h"
#include "nsAttrValueInlines.h"
#include "RestyleManager.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -72,13 +73,15 @@ nsHTMLCSSStyleSheet::ElementRulesMatching(nsPresContext* aPresContext,
rule = aElement->GetSMILOverrideStyleRule();
if (rule) {
if (aPresContext->IsProcessingRestyles() &&
!aPresContext->IsProcessingAnimationStyleChange()) {
RestyleManager* restyleManager = aPresContext->RestyleManager();
if (restyleManager->SkipAnimationRules()) {
// 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.
aPresContext->PresShell()->RestyleForAnimation(aElement,
eRestyle_StyleAttribute | eRestyle_ChangeAnimationPhase);
if (restyleManager->PostAnimationRestyles()) {
aPresContext->PresShell()->RestyleForAnimation(aElement,
eRestyle_StyleAttribute | eRestyle_ChangeAnimationPhase);
}
} else {
// Animation restyle (or non-restyle traversal of rules)
// Now we can walk SMIL overrride style, without triggering transitions.

Просмотреть файл

@ -37,6 +37,7 @@
#include "nsCSSRules.h"
#include "nsPrintfCString.h"
#include "nsIFrame.h"
#include "RestyleManager.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -1367,6 +1368,7 @@ nsStyleSet::RuleNodeWithReplacement(Element* aElement,
uint32_t(aReplacements)).get());
bool skipAnimationRules = false;
bool postAnimationRestyles = false;
// If we're changing animation phase, we have to reconsider what rules
// are in these four levels.
@ -1376,9 +1378,9 @@ nsStyleSet::RuleNodeWithReplacement(Element* aElement,
eRestyle_SVGAttrAnimations |
eRestyle_StyleAttribute;
nsPresContext* presContext = PresContext();
skipAnimationRules = presContext->IsProcessingRestyles() &&
!presContext->IsProcessingAnimationStyleChange();
RestyleManager* restyleManager = PresContext()->RestyleManager();
skipAnimationRules = restyleManager->SkipAnimationRules();
postAnimationRestyles = restyleManager->PostAnimationRestyles();
}
// FIXME (perf): This should probably not rebuild the whole path, but
@ -1430,7 +1432,9 @@ nsStyleSet::RuleNodeWithReplacement(Element* aElement,
if (collection) {
if (skipAnimationRules) {
collection->PostRestyleForAnimation(presContext);
if (postAnimationRestyles) {
collection->PostRestyleForAnimation(presContext);
}
} else {
animationManager->UpdateStyleAndEvents(
collection, PresContext()->RefreshDriver()->MostRecentRefresh(),
@ -1453,7 +1457,9 @@ nsStyleSet::RuleNodeWithReplacement(Element* aElement,
if (collection) {
if (skipAnimationRules) {
collection->PostRestyleForAnimation(presContext);
if (postAnimationRestyles) {
collection->PostRestyleForAnimation(presContext);
}
} else {
collection->EnsureStyleRuleFor(
presContext->RefreshDriver()->MostRecentRefresh(),
@ -2080,7 +2086,8 @@ nsStyleSet::GCRuleTrees()
* rules removed, and post a restyle if needed.
*/
static inline nsRuleNode*
SkipAnimationRules(nsRuleNode* aRuleNode, Element* aElementOrPseudoElement)
SkipAnimationRules(nsRuleNode* aRuleNode, Element* aElementOrPseudoElement,
bool aPostAnimationRestyles)
{
nsRuleNode* ruleNode = aRuleNode;
// The transition rule must be at the top of the cascade.
@ -2099,7 +2106,7 @@ SkipAnimationRules(nsRuleNode* aRuleNode, Element* aElementOrPseudoElement)
ruleNode = ReplaceAnimationRule(ruleNode, animationRule, nullptr);
}
if (ruleNode != aRuleNode) {
if (ruleNode != aRuleNode && aPostAnimationRestyles) {
NS_ASSERTION(aElementOrPseudoElement,
"How can we have transition rules but no element?");
// Need to do an animation restyle, just like
@ -2135,14 +2142,15 @@ nsStyleSet::ReparentStyleContext(nsStyleContext* aStyleContext,
// Skip transition rules as needed just like
// nsTransitionManager::WalkTransitionRule would.
bool skipAnimationRules = PresContext()->IsProcessingRestyles() &&
!PresContext()->IsProcessingAnimationStyleChange();
RestyleManager* restyleManager = PresContext()->RestyleManager();
bool skipAnimationRules = restyleManager->SkipAnimationRules();
bool postAnimationRestyles = restyleManager->PostAnimationRestyles();
if (skipAnimationRules) {
// Make sure that we're not using transition rules or animation rules for
// our new style context. If we need them, an animation restyle will
// provide.
ruleNode =
SkipAnimationRules(ruleNode, aElementOrPseudoElement);
ruleNode = SkipAnimationRules(ruleNode, aElementOrPseudoElement,
postAnimationRestyles);
}
nsRuleNode* visitedRuleNode = nullptr;
@ -2157,7 +2165,8 @@ nsStyleSet::ReparentStyleContext(nsStyleContext* aStyleContext,
if (skipAnimationRules) {
// FIXME do something here for animations?
visitedRuleNode =
SkipAnimationRules(visitedRuleNode, aElementOrPseudoElement);
SkipAnimationRules(visitedRuleNode, aElementOrPseudoElement,
postAnimationRestyles);
}
}

Просмотреть файл

@ -640,16 +640,18 @@ nsTransitionManager::WalkTransitionRule(
return;
}
if (aData->mPresContext->IsProcessingRestyles() &&
!aData->mPresContext->IsProcessingAnimationStyleChange()) {
RestyleManager* restyleManager = aData->mPresContext->RestyleManager();
if (restyleManager->SkipAnimationRules()) {
// If we're processing a normal style change rather than one from
// animation, don't add the transition rule. This allows us to
// compute the new style value rather than having the transition
// override it, so that we can start transitioning differently.
// We need to immediately restyle with animation
// after doing this.
collection->PostRestyleForAnimation(mPresContext);
if (restyleManager->PostAnimationRestyles()) {
// We need to immediately restyle with animation
// after doing this.
collection->PostRestyleForAnimation(mPresContext);
}
return;
}