зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1315874 - Pass a base style context to nsSMILCSSProperty; r=heycam
We will use this in the next patch in this series to fetch the base style. (I tried simply passing this as a parameter to GetBaseStyle but it proved to be more complicated since all the overrides of GetBaseStyle would need to be updated to take a parameter that would be irrelevant to most of them.) MozReview-Commit-ID: Fdr4rFUlE9V --HG-- extra : rebase_source : 26978951302b4764938959a065402f05220b6093
This commit is contained in:
Родитель
19ef9bec3d
Коммит
c94eac8983
|
@ -53,8 +53,11 @@ GetCSSComputedValue(Element* aElem,
|
|||
|
||||
// Class Methods
|
||||
nsSMILCSSProperty::nsSMILCSSProperty(nsCSSPropertyID aPropID,
|
||||
Element* aElement)
|
||||
: mPropID(aPropID), mElement(aElement)
|
||||
Element* aElement,
|
||||
nsStyleContext* aBaseStyleContext)
|
||||
: mPropID(aPropID)
|
||||
, mElement(aElement)
|
||||
, mBaseStyleContext(aBaseStyleContext)
|
||||
{
|
||||
MOZ_ASSERT(IsPropertyAnimatable(mPropID),
|
||||
"Creating a nsSMILCSSProperty for a property "
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "nsCSSPropertyID.h"
|
||||
#include "nsCSSValue.h"
|
||||
|
||||
class nsStyleContext;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class Element;
|
||||
|
@ -33,8 +35,14 @@ public:
|
|||
* Constructs a new nsSMILCSSProperty.
|
||||
* @param aPropID The CSS property we're interested in animating.
|
||||
* @param aElement The element whose CSS property is being animated.
|
||||
* @param aBaseStyleContext The style context to use when getting the base
|
||||
* value. If this is nullptr and GetBaseValue is
|
||||
* called, an empty nsSMILValue initialized with
|
||||
* the nsSMILCSSValueType will be returned.
|
||||
*/
|
||||
nsSMILCSSProperty(nsCSSPropertyID aPropID, mozilla::dom::Element* aElement);
|
||||
nsSMILCSSProperty(nsCSSPropertyID aPropID,
|
||||
mozilla::dom::Element* aElement,
|
||||
nsStyleContext* aBaseStyleContext);
|
||||
|
||||
// nsISMILAttr methods
|
||||
virtual nsresult ValueFromString(const nsAString& aStr,
|
||||
|
@ -62,6 +70,12 @@ protected:
|
|||
// as the Compositing step, and DOM elements don't get a chance to die during
|
||||
// that time.
|
||||
mozilla::dom::Element* mElement;
|
||||
|
||||
// The style context to use when fetching base styles.
|
||||
// As with mElement, since an nsISMILAttr only lives as long as the
|
||||
// compositing step and since ComposeAttribute holds an owning reference to
|
||||
// the base style context, we can use a non-owning reference here.
|
||||
nsStyleContext* mBaseStyleContext;
|
||||
};
|
||||
|
||||
#endif // NS_SMILCSSPROPERTY_H_
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "nsSMILCompositor.h"
|
||||
|
||||
#include "nsComputedDOMStyle.h"
|
||||
#include "nsCSSProps.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsSMILCSSProperty.h"
|
||||
|
@ -54,9 +55,18 @@ nsSMILCompositor::ComposeAttribute(bool& aMightHavePendingStyleUpdates)
|
|||
if (!mKey.mElement)
|
||||
return;
|
||||
|
||||
// If we might need to resolve base styles, grab a suitable style context
|
||||
// for initializing our nsISMILAttr with.
|
||||
RefPtr<nsStyleContext> baseStyleContext;
|
||||
if (MightNeedBaseStyle()) {
|
||||
baseStyleContext =
|
||||
nsComputedDOMStyle::GetUnanimatedStyleContextNoFlush(mKey.mElement,
|
||||
nullptr, nullptr);
|
||||
}
|
||||
|
||||
// FIRST: Get the nsISMILAttr (to grab base value from, and to eventually
|
||||
// give animated value to)
|
||||
UniquePtr<nsISMILAttr> smilAttr = CreateSMILAttr();
|
||||
UniquePtr<nsISMILAttr> smilAttr = CreateSMILAttr(baseStyleContext);
|
||||
if (!smilAttr) {
|
||||
// Target attribute not found (or, out of memory)
|
||||
return;
|
||||
|
@ -115,7 +125,7 @@ nsSMILCompositor::ClearAnimationEffects()
|
|||
if (!mKey.mElement || !mKey.mAttributeName)
|
||||
return;
|
||||
|
||||
UniquePtr<nsISMILAttr> smilAttr = CreateSMILAttr();
|
||||
UniquePtr<nsISMILAttr> smilAttr = CreateSMILAttr(nullptr);
|
||||
if (!smilAttr) {
|
||||
// Target attribute not found (or, out of memory)
|
||||
return;
|
||||
|
@ -126,12 +136,13 @@ nsSMILCompositor::ClearAnimationEffects()
|
|||
// Protected Helper Functions
|
||||
// --------------------------
|
||||
UniquePtr<nsISMILAttr>
|
||||
nsSMILCompositor::CreateSMILAttr()
|
||||
nsSMILCompositor::CreateSMILAttr(nsStyleContext* aBaseStyleContext)
|
||||
{
|
||||
nsCSSPropertyID propID = GetCSSPropertyToAnimate();
|
||||
|
||||
if (propID != eCSSProperty_UNKNOWN) {
|
||||
return MakeUnique<nsSMILCSSProperty>(propID, mKey.mElement.get());
|
||||
return MakeUnique<nsSMILCSSProperty>(propID, mKey.mElement.get(),
|
||||
aBaseStyleContext);
|
||||
}
|
||||
|
||||
return mKey.mElement->GetAnimatedAttr(mKey.mAttributeNamespaceID,
|
||||
|
|
|
@ -74,7 +74,11 @@ public:
|
|||
|
||||
private:
|
||||
// Create a nsISMILAttr for my target, on the heap.
|
||||
mozilla::UniquePtr<nsISMILAttr> CreateSMILAttr();
|
||||
//
|
||||
// @param aBaseStyleContext An optional style context which, if set, will be
|
||||
// used when fetching the base style.
|
||||
mozilla::UniquePtr<nsISMILAttr>
|
||||
CreateSMILAttr(nsStyleContext* aBaseStyleContext);
|
||||
|
||||
// Returns the CSS property this compositor should animate, or
|
||||
// eCSSProperty_UNKNOWN if this compositor does not animate a CSS property.
|
||||
|
|
Загрузка…
Ссылка в новой задаче