Bug 1057231 patch 3 - Add new cascade level for rules from SMIL Animation of SVG attributes to the style set. r=dholbert

I will fix the indentation of gCascadeLevels in bug 977991 patch 2,
which adds a member to each element of the array.

Note that this bumps the maximum sheetType from 8 to 9 (and number of
them from 9 to 10), which does not require updating
NS_RULE_NODE_LEVEL_MASK, since NS_RULE_NODE_LEVEL_MASK currently has 4
bits and allows a maximum of 15.
This commit is contained in:
L. David Baron 2014-09-13 06:17:35 -07:00
parent c929dfbd38
commit 702140ab45
2 changed files with 34 additions and 11 deletions

View File

@ -33,6 +33,7 @@
#include "GeckoProfiler.h"
#include "nsHTMLCSSStyleSheet.h"
#include "nsHTMLStyleSheet.h"
#include "SVGAttrAnimationRuleProcessor.h"
#include "nsCSSRules.h"
#include "nsPrintfCString.h"
#include "nsIFrame.h"
@ -187,8 +188,14 @@ nsStyleSet::Init(nsPresContext *aPresContext)
mRuleTree = nsRuleNode::CreateRootNode(aPresContext);
// Make an explicit GatherRuleProcessors call for the levels that
// don't have style sheets. The other levels will have their calls
// triggered by DirtyRuleProcessors. (We should probably convert the
// ePresHintSheet and eStyleAttrSheet levels to work like this as
// well, and not implement nsIStyleSheet.)
GatherRuleProcessors(eAnimationSheet);
GatherRuleProcessors(eTransitionSheet);
GatherRuleProcessors(eSVGAttrAnimationSheet);
}
nsresult
@ -360,20 +367,26 @@ nsStyleSet::GatherRuleProcessors(sheetType aType)
// handle the types for which have a rule processor that does not
// implement the style sheet interface.
case eAnimationSheet:
MOZ_ASSERT(mSheets[aType].Count() == 0);
MOZ_ASSERT(mSheets[aType].IsEmpty());
mRuleProcessors[aType] = PresContext()->AnimationManager();
return NS_OK;
case eTransitionSheet:
MOZ_ASSERT(mSheets[aType].Count() == 0);
MOZ_ASSERT(mSheets[aType].IsEmpty());
mRuleProcessors[aType] = PresContext()->TransitionManager();
return NS_OK;
case eStyleAttrSheet:
MOZ_ASSERT(mSheets[aType].Count() == 0);
MOZ_ASSERT(mSheets[aType].IsEmpty());
mRuleProcessors[aType] = PresContext()->Document()->GetInlineStyleSheet();
return NS_OK;
case ePresHintSheet:
MOZ_ASSERT(mSheets[aType].Count() == 0);
mRuleProcessors[aType] = PresContext()->Document()->GetAttributeStyleSheet();
MOZ_ASSERT(mSheets[aType].IsEmpty());
mRuleProcessors[aType] =
PresContext()->Document()->GetAttributeStyleSheet();
return NS_OK;
case eSVGAttrAnimationSheet:
MOZ_ASSERT(mSheets[aType].IsEmpty());
mRuleProcessors[aType] =
PresContext()->Document()->GetSVGAttrAnimationRuleProcessor();
return NS_OK;
default:
// keep going
@ -960,6 +973,7 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
// - UA normal rules = Agent normal
// - User normal rules = User normal
// - Presentation hints = PresHint normal
// - SVG Animation (highest pres hint) = SVGAttrAnimation normal
// - Author normal rules = Document normal
// - Override normal rules = Override normal
// - animation rules = Animation normal
@ -991,8 +1005,12 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
aRuleWalker->SetLevel(ePresHintSheet, false, false);
if (mRuleProcessors[ePresHintSheet])
(*aCollectorFunc)(mRuleProcessors[ePresHintSheet], aData);
nsRuleNode* lastPresHintRN = aRuleWalker->CurrentNode();
aRuleWalker->SetLevel(eSVGAttrAnimationSheet, false, false);
if (mRuleProcessors[eSVGAttrAnimationSheet])
(*aCollectorFunc)(mRuleProcessors[eSVGAttrAnimationSheet], aData);
nsRuleNode* lastSVGAttrAnimationRN = aRuleWalker->CurrentNode();
aRuleWalker->SetLevel(eDocSheet, false, true);
bool cutOffInheritance = false;
if (mBindingManager && aElement) {
@ -1065,11 +1083,11 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
if (haveImportantDocRules) {
aRuleWalker->SetLevel(eDocSheet, true, false);
AddImportantRules(lastDocRN, lastPresHintRN, aRuleWalker); // doc
AddImportantRules(lastDocRN, lastSVGAttrAnimationRN, aRuleWalker); // doc
}
#ifdef DEBUG
else {
AssertNoImportantRules(lastDocRN, lastPresHintRN);
AssertNoImportantRules(lastDocRN, lastSVGAttrAnimationRN);
}
#endif
@ -1094,7 +1112,7 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
#endif
#ifdef DEBUG
AssertNoCSSRules(lastPresHintRN, lastUserRN);
AssertNoCSSRules(lastSVGAttrAnimationRN, lastUserRN);
#endif
if (haveImportantUserRules) {
@ -1149,6 +1167,9 @@ nsStyleSet::WalkRuleProcessors(nsIStyleRuleProcessor::EnumFunc aFunc,
if (mRuleProcessors[ePresHintSheet])
(*aFunc)(mRuleProcessors[ePresHintSheet], aData);
if (mRuleProcessors[eSVGAttrAnimationSheet])
(*aFunc)(mRuleProcessors[eSVGAttrAnimationSheet], aData);
bool cutOffInheritance = false;
if (mBindingManager) {
// We can supply additional document-level sheets that should be walked.
@ -1314,6 +1335,7 @@ static const CascadeLevel gCascadeLevels[] = {
{ nsStyleSet::eAgentSheet, false, nsRestyleHint(0) },
{ nsStyleSet::eUserSheet, false, nsRestyleHint(0) },
{ nsStyleSet::ePresHintSheet, false, nsRestyleHint(0) },
{ nsStyleSet::eSVGAttrAnimationSheet, false, nsRestyleHint(0) },
{ nsStyleSet::eDocSheet, false, nsRestyleHint(0) },
{ nsStyleSet::eScopedDocSheet, false, nsRestyleHint(0) },
{ nsStyleSet::eStyleAttrSheet, false, nsRestyleHint(0) },

View File

@ -275,6 +275,7 @@ class nsStyleSet
eAgentSheet, // CSS
eUserSheet, // CSS
ePresHintSheet,
eSVGAttrAnimationSheet,
eDocSheet, // CSS
eScopedDocSheet,
eStyleAttrSheet,
@ -472,7 +473,7 @@ class nsStyleSet
unsigned mAuthorStyleDisabled: 1;
unsigned mInReconstruct : 1;
unsigned mInitFontFeatureValuesLookup : 1;
unsigned mDirty : 9; // one dirty bit is used per sheet type
unsigned mDirty : 10; // one dirty bit is used per sheet type
uint32_t mUnusedRuleNodeCount; // used to batch rule node GC
nsTArray<nsStyleContext*> mRoots; // style contexts with no parent