зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1315874 - Add a method to nsSMILCSSValueType that takes a StyleAnimationValue; r=dholbert
In a subsequent patch we will extract a StyleAnimationValue from an nsStyleContext. Rather than serializing it and then re-parsing it into a StyleAnimationValue, this patch adds a method to directly accept a StyleAnimationValue since that is what nsSMILCSSValueType stores internally anyway. MozReview-Commit-ID: KBaLYAzAlWZ --HG-- extra : rebase_source : b42f25236fba52939e07c63f5195d10678ea12bd
This commit is contained in:
Родитель
e6e8efa20f
Коммит
c02e19cf1f
|
@ -417,6 +417,34 @@ nsSMILCSSValueType::ValueFromString(nsCSSPropertyID aPropID,
|
|||
}
|
||||
}
|
||||
|
||||
// static
|
||||
nsSMILValue
|
||||
nsSMILCSSValueType::ValueFromAnimationValue(nsCSSPropertyID aPropID,
|
||||
Element* aTargetElement,
|
||||
const StyleAnimationValue& aValue)
|
||||
{
|
||||
nsSMILValue result;
|
||||
|
||||
nsIDocument* doc = aTargetElement->GetUncomposedDoc();
|
||||
// We'd like to avoid serializing |aValue| if possible, and since the
|
||||
// string passed to CSPAllowsInlineStyle is only used for reporting violations
|
||||
// and an intermediate CSS value is not likely to be particularly useful
|
||||
// in that case, we just use a generic placeholder string instead.
|
||||
static const nsLiteralString kPlaceholderText =
|
||||
NS_LITERAL_STRING("[SVG animation of CSS]");
|
||||
if (doc && !nsStyleUtil::CSPAllowsInlineStyle(nullptr,
|
||||
doc->NodePrincipal(),
|
||||
doc->GetDocumentURI(),
|
||||
0, kPlaceholderText, nullptr)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
sSingleton.Init(result);
|
||||
result.mU.mPtr = new ValueWrapper(aPropID, aValue);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
nsSMILCSSValueType::ValueToString(const nsSMILValue& aValue,
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
class nsAString;
|
||||
|
||||
namespace mozilla {
|
||||
class StyleAnimationValue;
|
||||
namespace dom {
|
||||
class Element;
|
||||
} // namespace dom
|
||||
|
@ -28,6 +29,7 @@ class nsSMILCSSValueType : public nsISMILType
|
|||
{
|
||||
public:
|
||||
typedef mozilla::dom::Element Element;
|
||||
typedef mozilla::StyleAnimationValue StyleAnimationValue;
|
||||
|
||||
// Singleton for nsSMILValue objects to hold onto.
|
||||
static nsSMILCSSValueType sSingleton;
|
||||
|
@ -84,6 +86,21 @@ public:
|
|||
nsSMILValue& aValue,
|
||||
bool* aIsContextSensitive);
|
||||
|
||||
/**
|
||||
* Creates an nsSMILValue to wrap the given animation value.
|
||||
*
|
||||
* @param aPropID The property that |aValue| corresponds to.
|
||||
* @param aTargetElement The target element to which the animation value
|
||||
* applies.
|
||||
* @param aValue The animation value to use.
|
||||
* @return A new nsSMILValue. On failure, returns an
|
||||
* nsSMILValue with the null type (i.e. rv.IsNull()
|
||||
* returns true).
|
||||
*/
|
||||
static nsSMILValue ValueFromAnimationValue(nsCSSPropertyID aPropID,
|
||||
Element* aTargetElement,
|
||||
const StyleAnimationValue& aValue);
|
||||
|
||||
/**
|
||||
* Creates a string representation of the given nsSMILValue.
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче