зеркало из https://github.com/mozilla/gecko-dev.git
Bug 893308: Move hashtable of @keyframes rules (keyed by name) from nsAnimationManager to RuleCascadeData. r=heycam
This commit is contained in:
Родитель
c9730554d0
Коммит
f76fcad70f
|
@ -1791,7 +1791,6 @@ nsPresContext::RebuildAllStyleData(nsChangeHint aExtraHint)
|
|||
mUsesRootEMUnits = false;
|
||||
mUsesViewportUnits = false;
|
||||
RebuildUserFontSet();
|
||||
AnimationManager()->KeyframesListIsDirty();
|
||||
|
||||
RestyleManager()->RebuildAllStyleData(aExtraHint);
|
||||
}
|
||||
|
|
|
@ -4216,7 +4216,6 @@ nsIPresShell::ReconstructStyleDataInternal()
|
|||
|
||||
if (mPresContext) {
|
||||
mPresContext->RebuildUserFontSet();
|
||||
mPresContext->AnimationManager()->KeyframesListIsDirty();
|
||||
}
|
||||
|
||||
Element* root = mDocument->GetRootElement();
|
||||
|
|
|
@ -529,7 +529,6 @@ nsAnimationManager::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
|||
|
||||
// Measurement of the following members may be added later if DMD finds it is
|
||||
// worthwhile:
|
||||
// - mKeyframesRules
|
||||
// - mPendingEvents
|
||||
}
|
||||
|
||||
|
@ -765,7 +764,8 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
|
|||
|
||||
aDest.mIterationDuration = TimeDuration::FromMilliseconds(aSrc.GetDuration());
|
||||
|
||||
nsCSSKeyframesRule *rule = KeyframesRuleFor(aDest.mName);
|
||||
nsCSSKeyframesRule* rule =
|
||||
mPresContext->StyleSet()->KeyframesRuleForName(mPresContext, aDest.mName);
|
||||
if (!rule) {
|
||||
// no segments
|
||||
continue;
|
||||
|
@ -1088,24 +1088,3 @@ nsAnimationManager::DoDispatchEvents()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCSSKeyframesRule*
|
||||
nsAnimationManager::KeyframesRuleFor(const nsSubstring& aName)
|
||||
{
|
||||
if (mKeyframesListIsDirty) {
|
||||
mKeyframesListIsDirty = false;
|
||||
|
||||
nsTArray<nsCSSKeyframesRule*> rules;
|
||||
mPresContext->StyleSet()->AppendKeyframesRules(mPresContext, rules);
|
||||
|
||||
// Per css3-animations, the last @keyframes rule specified wins.
|
||||
mKeyframesRules.Clear();
|
||||
for (uint32_t i = 0, i_end = rules.Length(); i != i_end; ++i) {
|
||||
nsCSSKeyframesRule *rule = rules[i];
|
||||
mKeyframesRules.Put(rule->GetName(), rule);
|
||||
}
|
||||
}
|
||||
|
||||
return mKeyframesRules.Get(aName);
|
||||
}
|
||||
|
||||
|
|
|
@ -195,10 +195,8 @@ class nsAnimationManager MOZ_FINAL
|
|||
public:
|
||||
nsAnimationManager(nsPresContext *aPresContext)
|
||||
: mozilla::css::CommonAnimationManager(aPresContext)
|
||||
, mKeyframesListIsDirty(true)
|
||||
, mObservingRefreshDriver(false)
|
||||
{
|
||||
mKeyframesRules.Init(16); // FIXME: make infallible!
|
||||
}
|
||||
|
||||
static ElementAnimations* GetAnimationsForCompositor(nsIContent* aContent,
|
||||
|
@ -262,10 +260,6 @@ public:
|
|||
nsIStyleRule* CheckAnimationRule(nsStyleContext* aStyleContext,
|
||||
mozilla::dom::Element* aElement);
|
||||
|
||||
void KeyframesListIsDirty() {
|
||||
mKeyframesListIsDirty = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch any pending events. We accumulate animationend and
|
||||
* animationiteration events only during refresh driver notifications
|
||||
|
@ -307,14 +301,9 @@ private:
|
|||
nsIStyleRule* GetAnimationRule(mozilla::dom::Element* aElement,
|
||||
nsCSSPseudoElements::Type aPseudoType);
|
||||
|
||||
nsCSSKeyframesRule* KeyframesRuleFor(const nsSubstring& aName);
|
||||
|
||||
// The guts of DispatchEvents
|
||||
void DoDispatchEvents();
|
||||
|
||||
bool mKeyframesListIsDirty;
|
||||
nsDataHashtable<nsStringHashKey, nsCSSKeyframesRule*> mKeyframesRules;
|
||||
|
||||
EventArray mPendingEvents;
|
||||
|
||||
bool mObservingRefreshDriver;
|
||||
|
|
|
@ -944,6 +944,7 @@ struct RuleCascadeData {
|
|||
PL_DHashTableInit(&mXULTreeRules, &RuleHash_TagTable_Ops, nullptr,
|
||||
sizeof(RuleHashTagTableEntry), 16);
|
||||
#endif
|
||||
mKeyframesRuleTable.Init(16); // FIXME: make infallible!
|
||||
}
|
||||
|
||||
~RuleCascadeData()
|
||||
|
@ -982,6 +983,8 @@ struct RuleCascadeData {
|
|||
nsTArray<nsCSSFontFeatureValuesRule*> mFontFeatureValuesRules;
|
||||
nsTArray<nsCSSPageRule*> mPageRules;
|
||||
|
||||
nsDataHashtable<nsStringHashKey, nsCSSKeyframesRule*> mKeyframesRuleTable;
|
||||
|
||||
// Looks up or creates the appropriate list in |mAttributeSelectors|.
|
||||
// Returns null only on allocation failure.
|
||||
nsTArray<nsCSSSelector*>* AttributeListFor(nsIAtom* aAttribute);
|
||||
|
@ -2776,21 +2779,17 @@ nsCSSRuleProcessor::AppendFontFaceRules(
|
|||
return true;
|
||||
}
|
||||
|
||||
// Append all the currently-active keyframes rules to aArray. Return
|
||||
// true for success and false for failure.
|
||||
bool
|
||||
nsCSSRuleProcessor::AppendKeyframesRules(
|
||||
nsPresContext *aPresContext,
|
||||
nsTArray<nsCSSKeyframesRule*>& aArray)
|
||||
nsCSSKeyframesRule*
|
||||
nsCSSRuleProcessor::KeyframesRuleForName(nsPresContext* aPresContext,
|
||||
const nsString& aName)
|
||||
{
|
||||
RuleCascadeData* cascade = GetRuleCascade(aPresContext);
|
||||
|
||||
if (cascade) {
|
||||
if (!aArray.AppendElements(cascade->mKeyframesRules))
|
||||
return false;
|
||||
return cascade->mKeyframesRuleTable.Get(aName);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Append all the currently-active page rules to aArray. Return
|
||||
|
@ -3298,6 +3297,8 @@ FillWeightArray(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
|||
RuleCascadeData*
|
||||
nsCSSRuleProcessor::GetRuleCascade(nsPresContext* aPresContext)
|
||||
{
|
||||
// FIXME: Make this infallible!
|
||||
|
||||
// If anything changes about the presentation context, we will be
|
||||
// notified. Otherwise, our cache is valid if mLastPresContext
|
||||
// matches aPresContext. (The only rule processors used for multiple
|
||||
|
@ -3374,6 +3375,13 @@ nsCSSRuleProcessor::RefreshRuleCascade(nsPresContext* aPresContext)
|
|||
}
|
||||
}
|
||||
|
||||
// Build mKeyframesRuleTable.
|
||||
for (nsTArray<nsCSSKeyframesRule*>::size_type i = 0,
|
||||
iEnd = newCascade->mKeyframesRules.Length(); i < iEnd; ++i) {
|
||||
nsCSSKeyframesRule* rule = newCascade->mKeyframesRules[i];
|
||||
newCascade->mKeyframesRuleTable.Put(rule->GetName(), rule);
|
||||
}
|
||||
|
||||
// Ensure that the current one is always mRuleCascades.
|
||||
newCascade->mNext = mRuleCascades;
|
||||
mRuleCascades = newCascade.forget();
|
||||
|
|
|
@ -123,8 +123,8 @@ public:
|
|||
bool AppendFontFaceRules(nsPresContext* aPresContext,
|
||||
nsTArray<nsFontFaceRuleContainer>& aArray);
|
||||
|
||||
bool AppendKeyframesRules(nsPresContext* aPresContext,
|
||||
nsTArray<nsCSSKeyframesRule*>& aArray);
|
||||
nsCSSKeyframesRule* KeyframesRuleForName(nsPresContext* aPresContext,
|
||||
const nsString& aName);
|
||||
|
||||
bool AppendPageRules(nsPresContext* aPresContext,
|
||||
nsTArray<nsCSSPageRule*>& aArray);
|
||||
|
|
|
@ -122,6 +122,7 @@ nsDisableTextZoomStyleRule::List(FILE* out, int32_t aIndent) const
|
|||
#endif
|
||||
|
||||
static const nsStyleSet::sheetType gCSSSheetTypes[] = {
|
||||
// From lowest to highest in cascading order.
|
||||
nsStyleSet::eAgentSheet,
|
||||
nsStyleSet::eUserSheet,
|
||||
nsStyleSet::eDocSheet,
|
||||
|
@ -1551,21 +1552,25 @@ nsStyleSet::AppendFontFaceRules(nsPresContext* aPresContext,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
nsStyleSet::AppendKeyframesRules(nsPresContext* aPresContext,
|
||||
nsTArray<nsCSSKeyframesRule*>& aArray)
|
||||
nsCSSKeyframesRule*
|
||||
nsStyleSet::KeyframesRuleForName(nsPresContext* aPresContext,
|
||||
const nsString& aName)
|
||||
{
|
||||
NS_ENSURE_FALSE(mInShutdown, false);
|
||||
NS_ENSURE_FALSE(mInShutdown, nullptr);
|
||||
|
||||
for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
|
||||
for (uint32_t i = ArrayLength(gCSSSheetTypes); i-- != 0; ) {
|
||||
if (gCSSSheetTypes[i] == eScopedDocSheet)
|
||||
continue;
|
||||
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
|
||||
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
||||
if (ruleProc && !ruleProc->AppendKeyframesRules(aPresContext, aArray))
|
||||
return false;
|
||||
if (!ruleProc)
|
||||
continue;
|
||||
nsCSSKeyframesRule* result =
|
||||
ruleProc->KeyframesRuleForName(aPresContext, aName);
|
||||
if (result)
|
||||
return result;
|
||||
}
|
||||
return true;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -170,10 +170,9 @@ class nsStyleSet
|
|||
bool AppendFontFaceRules(nsPresContext* aPresContext,
|
||||
nsTArray<nsFontFaceRuleContainer>& aArray);
|
||||
|
||||
// Append all the currently-active keyframes rules to aArray. Return
|
||||
// true for success and false for failure.
|
||||
bool AppendKeyframesRules(nsPresContext* aPresContext,
|
||||
nsTArray<nsCSSKeyframesRule*>& aArray);
|
||||
// Return the winning (in the cascade) @keyframes rule for the given name.
|
||||
nsCSSKeyframesRule* KeyframesRuleForName(nsPresContext* aPresContext,
|
||||
const nsString& aName);
|
||||
|
||||
// Fetch object for looking up font feature values
|
||||
already_AddRefed<gfxFontFeatureValueSet> GetFontFeatureValuesLookup();
|
||||
|
|
Загрузка…
Ссылка в новой задаче