mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 23:30:46 +00:00
Add support for cascading of keyframes rules. (Bug 435442, patch 6) r=bzbarsky
This commit is contained in:
parent
608bc593d5
commit
914379bb82
@ -837,6 +837,7 @@ struct RuleCascadeData {
|
||||
#endif
|
||||
|
||||
nsTArray<nsFontFaceRuleContainer> mFontFaceRules;
|
||||
nsTArray<nsCSSKeyframesRule*> mKeyframesRules;
|
||||
|
||||
// Looks up or creates the appropriate list in |mAttributeSelectors|.
|
||||
// Returns null only on allocation failure.
|
||||
@ -2454,6 +2455,23 @@ nsCSSRuleProcessor::AppendFontFaceRules(
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// Append all the currently-active keyframes rules to aArray. Return
|
||||
// true for success and false for failure.
|
||||
PRBool
|
||||
nsCSSRuleProcessor::AppendKeyframesRules(
|
||||
nsPresContext *aPresContext,
|
||||
nsTArray<nsCSSKeyframesRule*>& aArray)
|
||||
{
|
||||
RuleCascadeData* cascade = GetRuleCascade(aPresContext);
|
||||
|
||||
if (cascade) {
|
||||
if (!aArray.AppendElements(cascade->mKeyframesRules))
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCSSRuleProcessor::ClearRuleCascades()
|
||||
{
|
||||
@ -2719,11 +2737,13 @@ static PLDHashTableOps gRulesByWeightOps = {
|
||||
struct CascadeEnumData {
|
||||
CascadeEnumData(nsPresContext* aPresContext,
|
||||
nsTArray<nsFontFaceRuleContainer>& aFontFaceRules,
|
||||
nsTArray<nsCSSKeyframesRule*>& aKeyframesRules,
|
||||
nsMediaQueryResultCacheKey& aKey,
|
||||
PLArenaPool& aArena,
|
||||
PRUint8 aSheetType)
|
||||
: mPresContext(aPresContext),
|
||||
mFontFaceRules(aFontFaceRules),
|
||||
mKeyframesRules(aKeyframesRules),
|
||||
mCacheKey(aKey),
|
||||
mArena(aArena),
|
||||
mSheetType(aSheetType)
|
||||
@ -2741,6 +2761,7 @@ struct CascadeEnumData {
|
||||
|
||||
nsPresContext* mPresContext;
|
||||
nsTArray<nsFontFaceRuleContainer>& mFontFaceRules;
|
||||
nsTArray<nsCSSKeyframesRule*>& mKeyframesRules;
|
||||
nsMediaQueryResultCacheKey& mCacheKey;
|
||||
PLArenaPool& mArena;
|
||||
// Hooray, a manual PLDHashTable since nsClassHashtable doesn't
|
||||
@ -2756,6 +2777,7 @@ struct CascadeEnumData {
|
||||
* the primary CSS cascade), where they are separated by weight
|
||||
* but kept in order per-weight, and
|
||||
* (2) add any @font-face rules, in order, into data->mFontFaceRules.
|
||||
* (3) add any @keyframes rules, in order, into data->mKeyframesRules.
|
||||
*/
|
||||
static PRBool
|
||||
CascadeRuleEnumFunc(nsICSSRule* aRule, void* aData)
|
||||
@ -2795,6 +2817,13 @@ CascadeRuleEnumFunc(nsICSSRule* aRule, void* aData)
|
||||
ptr->mRule = fontFaceRule;
|
||||
ptr->mSheetType = data->mSheetType;
|
||||
}
|
||||
else if (nsICSSRule::KEYFRAMES_RULE == type) {
|
||||
nsCSSKeyframesRule *keyframesRule =
|
||||
static_cast<nsCSSKeyframesRule*>(aRule);
|
||||
if (!data->mKeyframesRules.AppendElement(keyframesRule)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
@ -2895,6 +2924,7 @@ nsCSSRuleProcessor::RefreshRuleCascade(nsPresContext* aPresContext)
|
||||
eCompatibility_NavQuirks == aPresContext->CompatibilityMode()));
|
||||
if (newCascade) {
|
||||
CascadeEnumData data(aPresContext, newCascade->mFontFaceRules,
|
||||
newCascade->mKeyframesRules,
|
||||
newCascade->mCacheKey,
|
||||
newCascade->mRuleHash.Arena(),
|
||||
mSheetType);
|
||||
|
@ -56,6 +56,7 @@ struct RuleCascadeData;
|
||||
struct nsCSSSelectorList;
|
||||
struct CascadeEnumData;
|
||||
struct TreeMatchContext;
|
||||
class nsCSSKeyframesRule;
|
||||
|
||||
/**
|
||||
* The CSS style rule processor provides a mechanism for sibling style
|
||||
@ -140,6 +141,9 @@ public:
|
||||
PRBool AppendFontFaceRules(nsPresContext* aPresContext,
|
||||
nsTArray<nsFontFaceRuleContainer>& aArray);
|
||||
|
||||
PRBool AppendKeyframesRules(nsPresContext* aPresContext,
|
||||
nsTArray<nsCSSKeyframesRule*>& aArray);
|
||||
|
||||
#ifdef DEBUG
|
||||
void AssertQuirksChangeOK() {
|
||||
NS_ASSERTION(!mRuleCascades, "can't toggle quirks style sheet without "
|
||||
|
@ -1065,6 +1065,21 @@ nsStyleSet::AppendFontFaceRules(nsPresContext* aPresContext,
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsStyleSet::AppendKeyframesRules(nsPresContext* aPresContext,
|
||||
nsTArray<nsCSSKeyframesRule*>& aArray)
|
||||
{
|
||||
NS_ENSURE_FALSE(mInShutdown, PR_FALSE);
|
||||
|
||||
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(gCSSSheetTypes); ++i) {
|
||||
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
|
||||
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
||||
if (ruleProc && !ruleProc->AppendKeyframesRules(aPresContext, aArray))
|
||||
return PR_FALSE;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
nsStyleSet::BeginShutdown(nsPresContext* aPresContext)
|
||||
{
|
||||
|
@ -60,6 +60,7 @@
|
||||
|
||||
class nsIURI;
|
||||
class nsCSSFontFaceRule;
|
||||
class nsCSSKeyframesRule;
|
||||
class nsRuleWalker;
|
||||
struct RuleProcessorData;
|
||||
struct TreeMatchContext;
|
||||
@ -171,6 +172,11 @@ class nsStyleSet
|
||||
PRBool AppendFontFaceRules(nsPresContext* aPresContext,
|
||||
nsTArray<nsFontFaceRuleContainer>& aArray);
|
||||
|
||||
// Append all the currently-active keyframes rules to aArray. Return
|
||||
// true for success and false for failure.
|
||||
PRBool AppendKeyframesRules(nsPresContext* aPresContext,
|
||||
nsTArray<nsCSSKeyframesRule*>& aArray);
|
||||
|
||||
// Begin ignoring style context destruction, to avoid lots of unnecessary
|
||||
// work on document teardown.
|
||||
void BeginShutdown(nsPresContext* aPresContext);
|
||||
|
Loading…
x
Reference in New Issue
Block a user