nsStyleContext* ResolvedStyleCache::Get(nsPresContext *aPresContext, nsStyleContext *aParentStyleContext, Declaration* aKeyframeDeclaration) { // FIXME (spec): The css3-animations spec isn't very clear about how // properties are resolved when they have values that depend on other // properties (e.g., values in 'em'). I presume that they're resolved // relative to the other styles of the element. The question is // whether they are resolved relative to other animations: I assume // that they're not, since that would prevent us from caching a lot of // data that we'd really like to cache (in particular, the // StyleAnimationValue values in AnimationPropertySegment). nsStyleContext *result = mCache.GetWeak(aKeyframeDeclaration); if (!result) { aKeyframeDeclaration->SetImmutable(); // The spec says that !important declarations should just be ignored MOZ_ASSERT(!aKeyframeDeclaration->HasImportantData(), "Keyframe rule has !important data"); nsCOMArray<nsIStyleRule> rules; rules.AppendObject(aKeyframeDeclaration); RefPtr<nsStyleContext> resultStrong = aPresContext->StyleSet()-> ResolveStyleByAddingRules(aParentStyleContext, rules); mCache.Put(aKeyframeDeclaration, resultStrong); result = resultStrong; } return result; }
nsStyleContext* ResolvedStyleCache::Get(nsPresContext *aPresContext, nsStyleContext *aParentStyleContext, nsCSSKeyframeRule *aKeyframe) { // FIXME (spec): The css3-animations spec isn't very clear about how // properties are resolved when they have values that depend on other // properties (e.g., values in 'em'). I presume that they're resolved // relative to the other styles of the element. The question is // whether they are resolved relative to other animations: I assume // that they're not, since that would prevent us from caching a lot of // data that we'd really like to cache (in particular, the // nsStyleAnimation::Value values in AnimationPropertySegment). nsStyleContext *result = mCache.GetWeak(aKeyframe); if (!result) { nsCOMArray<nsIStyleRule> rules; rules.AppendObject(aKeyframe); nsRefPtr<nsStyleContext> resultStrong = aPresContext->StyleSet()-> ResolveStyleByAddingRules(aParentStyleContext, rules); mCache.Put(aKeyframe, resultStrong); result = resultStrong; } return result; }