зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1174575 - Part 5: Support pseudo-element type in StyleAnimation. r=birtles
Add one more argument, nsCSSPseudoElement::Type, for StyleAnimation::ComputeValue and StyleAnimation::ComputeValues
This commit is contained in:
Родитель
2a5bfa8330
Коммит
8627ee5709
|
@ -1197,12 +1197,14 @@ GenerateValueEntries(Element* aTarget,
|
||||||
// Parse the property's string value and produce a KeyframeValueEntry (or
|
// Parse the property's string value and produce a KeyframeValueEntry (or
|
||||||
// more than one, for shorthands) for it.
|
// more than one, for shorthands) for it.
|
||||||
nsTArray<PropertyStyleAnimationValuePair> values;
|
nsTArray<PropertyStyleAnimationValuePair> values;
|
||||||
if (StyleAnimationValue::ComputeValues(pair.mProperty,
|
if (StyleAnimationValue::ComputeValues(
|
||||||
nsCSSProps::eEnabledForAllContent,
|
pair.mProperty,
|
||||||
aTarget,
|
nsCSSProps::eEnabledForAllContent,
|
||||||
pair.mValues[0],
|
aTarget,
|
||||||
/* aUseSVGMode */ false,
|
nsCSSPseudoElements::ePseudo_NotPseudoElement,
|
||||||
values)) {
|
pair.mValues[0],
|
||||||
|
/* aUseSVGMode */ false,
|
||||||
|
values)) {
|
||||||
for (auto& value : values) {
|
for (auto& value : values) {
|
||||||
// If we already got a value for this property on the keyframe,
|
// If we already got a value for this property on the keyframe,
|
||||||
// skip this one.
|
// skip this one.
|
||||||
|
@ -1477,12 +1479,14 @@ BuildAnimationPropertyListFromPropertyIndexedKeyframes(
|
||||||
// value instead.
|
// value instead.
|
||||||
nsTArray<PropertyStyleAnimationValuePair> fromValues;
|
nsTArray<PropertyStyleAnimationValuePair> fromValues;
|
||||||
float fromKey = 0.0f;
|
float fromKey = 0.0f;
|
||||||
if (!StyleAnimationValue::ComputeValues(pair.mProperty,
|
if (!StyleAnimationValue::ComputeValues(
|
||||||
nsCSSProps::eEnabledForAllContent,
|
pair.mProperty,
|
||||||
aTarget,
|
nsCSSProps::eEnabledForAllContent,
|
||||||
pair.mValues[0],
|
aTarget,
|
||||||
/* aUseSVGMode */ false,
|
nsCSSPseudoElements::ePseudo_NotPseudoElement,
|
||||||
fromValues)) {
|
pair.mValues[0],
|
||||||
|
/* aUseSVGMode */ false,
|
||||||
|
fromValues)) {
|
||||||
// We need to throw for an invalid first value, since that would imply an
|
// We need to throw for an invalid first value, since that would imply an
|
||||||
// additive animation, which we don't support yet.
|
// additive animation, which we don't support yet.
|
||||||
aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR);
|
aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR);
|
||||||
|
@ -1529,12 +1533,14 @@ BuildAnimationPropertyListFromPropertyIndexedKeyframes(
|
||||||
for (size_t i = 0; i < count - 1; ++i) {
|
for (size_t i = 0; i < count - 1; ++i) {
|
||||||
nsTArray<PropertyStyleAnimationValuePair> toValues;
|
nsTArray<PropertyStyleAnimationValuePair> toValues;
|
||||||
float toKey = (i + 1) * portion;
|
float toKey = (i + 1) * portion;
|
||||||
if (!StyleAnimationValue::ComputeValues(pair.mProperty,
|
if (!StyleAnimationValue::ComputeValues(
|
||||||
nsCSSProps::eEnabledForAllContent,
|
pair.mProperty,
|
||||||
aTarget,
|
nsCSSProps::eEnabledForAllContent,
|
||||||
pair.mValues[i + 1],
|
aTarget,
|
||||||
/* aUseSVGMode */ false,
|
nsCSSPseudoElements::ePseudo_NotPseudoElement,
|
||||||
toValues)) {
|
pair.mValues[i + 1],
|
||||||
|
/* aUseSVGMode */ false,
|
||||||
|
toValues)) {
|
||||||
if (i + 1 == count - 1) {
|
if (i + 1 == count - 1) {
|
||||||
// We need to throw for an invalid last value, since that would
|
// We need to throw for an invalid last value, since that would
|
||||||
// imply an additive animation, which we don't support yet.
|
// imply an additive animation, which we don't support yet.
|
||||||
|
|
|
@ -2247,8 +2247,13 @@ ComputeAnimationValue(nsCSSProperty aProperty,
|
||||||
StyleAnimationValue& aOutput)
|
StyleAnimationValue& aOutput)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!StyleAnimationValue::ComputeValue(aProperty, aElement, aInput,
|
if (!StyleAnimationValue::ComputeValue(
|
||||||
false, aOutput)) {
|
aProperty,
|
||||||
|
aElement,
|
||||||
|
nsCSSPseudoElements::ePseudo_NotPseudoElement,
|
||||||
|
aInput,
|
||||||
|
false,
|
||||||
|
aOutput)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -360,9 +360,14 @@ ValueFromStringHelper(nsCSSProperty aPropID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nsDependentSubstring subString(aString, subStringBegin);
|
nsDependentSubstring subString(aString, subStringBegin);
|
||||||
if (!StyleAnimationValue::ComputeValue(aPropID, aTargetElement, subString,
|
if (!StyleAnimationValue::ComputeValue(
|
||||||
true, aStyleAnimValue,
|
aPropID,
|
||||||
aIsContextSensitive)) {
|
aTargetElement,
|
||||||
|
nsCSSPseudoElements::ePseudo_NotPseudoElement,
|
||||||
|
subString,
|
||||||
|
true,
|
||||||
|
aStyleAnimValue,
|
||||||
|
aIsContextSensitive)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (isNegative) {
|
if (isNegative) {
|
||||||
|
|
|
@ -2525,19 +2525,25 @@ BuildStyleRule(nsCSSProperty aProperty,
|
||||||
|
|
||||||
inline
|
inline
|
||||||
already_AddRefed<nsStyleContext>
|
already_AddRefed<nsStyleContext>
|
||||||
LookupStyleContext(dom::Element* aElement)
|
LookupStyleContext(dom::Element* aElement,
|
||||||
|
nsCSSPseudoElements::Type aPseudoType)
|
||||||
{
|
{
|
||||||
nsIDocument* doc = aElement->GetCurrentDoc();
|
nsIDocument* doc = aElement->GetCurrentDoc();
|
||||||
nsIPresShell* shell = doc->GetShell();
|
nsIPresShell* shell = doc->GetShell();
|
||||||
if (!shell) {
|
if (!shell) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return nsComputedDOMStyle::GetStyleContextForElement(aElement, nullptr, shell);
|
|
||||||
|
nsIAtom* pseudo =
|
||||||
|
aPseudoType < nsCSSPseudoElements::ePseudo_PseudoElementCount ?
|
||||||
|
nsCSSPseudoElements::GetPseudoAtom(aPseudoType) : nullptr;
|
||||||
|
return nsComputedDOMStyle::GetStyleContextForElement(aElement, pseudo, shell);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool
|
/* static */ bool
|
||||||
StyleAnimationValue::ComputeValue(nsCSSProperty aProperty,
|
StyleAnimationValue::ComputeValue(nsCSSProperty aProperty,
|
||||||
dom::Element* aTargetElement,
|
dom::Element* aTargetElement,
|
||||||
|
nsCSSPseudoElements::Type aPseudoType,
|
||||||
const nsAString& aSpecifiedValue,
|
const nsAString& aSpecifiedValue,
|
||||||
bool aUseSVGMode,
|
bool aUseSVGMode,
|
||||||
StyleAnimationValue& aComputedValue,
|
StyleAnimationValue& aComputedValue,
|
||||||
|
@ -2549,6 +2555,9 @@ StyleAnimationValue::ComputeValue(nsCSSProperty aProperty,
|
||||||
"are in a document");
|
"are in a document");
|
||||||
|
|
||||||
// Parse specified value into a temporary css::StyleRule
|
// Parse specified value into a temporary css::StyleRule
|
||||||
|
// Note: BuildStyleRule needs an element's OwnerDoc, BaseURI, and Principal.
|
||||||
|
// If it is a pseudo element, use its parent element's OwnerDoc, BaseURI,
|
||||||
|
// and Principal.
|
||||||
RefPtr<css::StyleRule> styleRule =
|
RefPtr<css::StyleRule> styleRule =
|
||||||
BuildStyleRule(aProperty, aTargetElement, aSpecifiedValue, aUseSVGMode);
|
BuildStyleRule(aProperty, aTargetElement, aSpecifiedValue, aUseSVGMode);
|
||||||
if (!styleRule) {
|
if (!styleRule) {
|
||||||
|
@ -2569,7 +2578,7 @@ StyleAnimationValue::ComputeValue(nsCSSProperty aProperty,
|
||||||
|
|
||||||
AutoTArray<PropertyStyleAnimationValuePair,1> values;
|
AutoTArray<PropertyStyleAnimationValuePair,1> values;
|
||||||
bool ok = ComputeValues(aProperty, nsCSSProps::eIgnoreEnabledState,
|
bool ok = ComputeValues(aProperty, nsCSSProps::eIgnoreEnabledState,
|
||||||
aTargetElement, styleRule, values,
|
aTargetElement, aPseudoType, styleRule, values,
|
||||||
aIsContextSensitive);
|
aIsContextSensitive);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -2586,6 +2595,7 @@ StyleAnimationValue::ComputeValue(nsCSSProperty aProperty,
|
||||||
StyleAnimationValue::ComputeValues(nsCSSProperty aProperty,
|
StyleAnimationValue::ComputeValues(nsCSSProperty aProperty,
|
||||||
nsCSSProps::EnabledState aEnabledState,
|
nsCSSProps::EnabledState aEnabledState,
|
||||||
dom::Element* aTargetElement,
|
dom::Element* aTargetElement,
|
||||||
|
nsCSSPseudoElements::Type aPseudoType,
|
||||||
const nsAString& aSpecifiedValue,
|
const nsAString& aSpecifiedValue,
|
||||||
bool aUseSVGMode,
|
bool aUseSVGMode,
|
||||||
nsTArray<PropertyStyleAnimationValuePair>& aResult)
|
nsTArray<PropertyStyleAnimationValuePair>& aResult)
|
||||||
|
@ -2596,6 +2606,9 @@ StyleAnimationValue::ComputeValues(nsCSSProperty aProperty,
|
||||||
"are in a document");
|
"are in a document");
|
||||||
|
|
||||||
// Parse specified value into a temporary css::StyleRule
|
// Parse specified value into a temporary css::StyleRule
|
||||||
|
// Note: BuildStyleRule needs an element's OwnerDoc, BaseURI, and Principal.
|
||||||
|
// If it is a pseudo element, use its parent element's OwnerDoc, BaseURI,
|
||||||
|
// and Principal.
|
||||||
RefPtr<css::StyleRule> styleRule =
|
RefPtr<css::StyleRule> styleRule =
|
||||||
BuildStyleRule(aProperty, aTargetElement, aSpecifiedValue, aUseSVGMode);
|
BuildStyleRule(aProperty, aTargetElement, aSpecifiedValue, aUseSVGMode);
|
||||||
if (!styleRule) {
|
if (!styleRule) {
|
||||||
|
@ -2603,8 +2616,8 @@ StyleAnimationValue::ComputeValues(nsCSSProperty aProperty,
|
||||||
}
|
}
|
||||||
|
|
||||||
aResult.Clear();
|
aResult.Clear();
|
||||||
return ComputeValues(aProperty, aEnabledState, aTargetElement, styleRule,
|
return ComputeValues(aProperty, aEnabledState, aTargetElement, aPseudoType,
|
||||||
aResult, /* aIsContextSensitive */ nullptr);
|
styleRule, aResult, /* aIsContextSensitive */ nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool
|
/* static */ bool
|
||||||
|
@ -2612,6 +2625,7 @@ StyleAnimationValue::ComputeValues(
|
||||||
nsCSSProperty aProperty,
|
nsCSSProperty aProperty,
|
||||||
nsCSSProps::EnabledState aEnabledState,
|
nsCSSProps::EnabledState aEnabledState,
|
||||||
dom::Element* aTargetElement,
|
dom::Element* aTargetElement,
|
||||||
|
nsCSSPseudoElements::Type aPseudoType,
|
||||||
css::StyleRule* aStyleRule,
|
css::StyleRule* aStyleRule,
|
||||||
nsTArray<PropertyStyleAnimationValuePair>& aValues,
|
nsTArray<PropertyStyleAnimationValuePair>& aValues,
|
||||||
bool* aIsContextSensitive)
|
bool* aIsContextSensitive)
|
||||||
|
@ -2620,8 +2634,9 @@ StyleAnimationValue::ComputeValues(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look up style context for our target element
|
// Look up style context for our target, element:psuedo pair
|
||||||
RefPtr<nsStyleContext> styleContext = LookupStyleContext(aTargetElement);
|
RefPtr<nsStyleContext> styleContext = LookupStyleContext(aTargetElement,
|
||||||
|
aPseudoType);
|
||||||
if (!styleContext) {
|
if (!styleContext) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "nsCoord.h"
|
#include "nsCoord.h"
|
||||||
#include "nsColor.h"
|
#include "nsColor.h"
|
||||||
#include "nsCSSProps.h"
|
#include "nsCSSProps.h"
|
||||||
|
#include "nsCSSPseudoElements.h"
|
||||||
#include "nsCSSValue.h"
|
#include "nsCSSValue.h"
|
||||||
|
|
||||||
class nsIFrame;
|
class nsIFrame;
|
||||||
|
@ -133,7 +134,11 @@ public:
|
||||||
*
|
*
|
||||||
* @param aProperty The property whose value we're computing.
|
* @param aProperty The property whose value we're computing.
|
||||||
* @param aTargetElement The content node to which our computed value is
|
* @param aTargetElement The content node to which our computed value is
|
||||||
* applicable.
|
* applicable. For pseudo-elements, this is the parent
|
||||||
|
* element to which the pseudo is attached, not the
|
||||||
|
* generated content node.
|
||||||
|
* @param aPseudoType The type of pseudo-element to which the computed
|
||||||
|
* value is applicable.
|
||||||
* @param aSpecifiedValue The specified value, from which we'll build our
|
* @param aSpecifiedValue The specified value, from which we'll build our
|
||||||
* computed value.
|
* computed value.
|
||||||
* @param aUseSVGMode A flag to indicate whether we should parse
|
* @param aUseSVGMode A flag to indicate whether we should parse
|
||||||
|
@ -150,11 +155,12 @@ public:
|
||||||
* @return true on success, false on failure.
|
* @return true on success, false on failure.
|
||||||
*/
|
*/
|
||||||
static bool ComputeValue(nsCSSProperty aProperty,
|
static bool ComputeValue(nsCSSProperty aProperty,
|
||||||
mozilla::dom::Element* aTargetElement,
|
mozilla::dom::Element* aTargetElement,
|
||||||
const nsAString& aSpecifiedValue,
|
nsCSSPseudoElements::Type aPseudoType,
|
||||||
bool aUseSVGMode,
|
const nsAString& aSpecifiedValue,
|
||||||
StyleAnimationValue& aComputedValue,
|
bool aUseSVGMode,
|
||||||
bool* aIsContextSensitive = nullptr);
|
StyleAnimationValue& aComputedValue,
|
||||||
|
bool* aIsContextSensitive = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like ComputeValue, but returns an array of StyleAnimationValues.
|
* Like ComputeValue, but returns an array of StyleAnimationValues.
|
||||||
|
@ -169,6 +175,7 @@ public:
|
||||||
static bool ComputeValues(nsCSSProperty aProperty,
|
static bool ComputeValues(nsCSSProperty aProperty,
|
||||||
nsCSSProps::EnabledState aEnabledState,
|
nsCSSProps::EnabledState aEnabledState,
|
||||||
mozilla::dom::Element* aTargetElement,
|
mozilla::dom::Element* aTargetElement,
|
||||||
|
nsCSSPseudoElements::Type aPseudoType,
|
||||||
const nsAString& aSpecifiedValue,
|
const nsAString& aSpecifiedValue,
|
||||||
bool aUseSVGMode,
|
bool aUseSVGMode,
|
||||||
nsTArray<PropertyStyleAnimationValuePair>& aResult);
|
nsTArray<PropertyStyleAnimationValuePair>& aResult);
|
||||||
|
@ -396,6 +403,7 @@ private:
|
||||||
static bool ComputeValues(nsCSSProperty aProperty,
|
static bool ComputeValues(nsCSSProperty aProperty,
|
||||||
nsCSSProps::EnabledState aEnabledState,
|
nsCSSProps::EnabledState aEnabledState,
|
||||||
mozilla::dom::Element* aTargetElement,
|
mozilla::dom::Element* aTargetElement,
|
||||||
|
nsCSSPseudoElements::Type aPseudoType,
|
||||||
mozilla::css::StyleRule* aStyleRule,
|
mozilla::css::StyleRule* aStyleRule,
|
||||||
nsTArray<PropertyStyleAnimationValuePair>& aValues,
|
nsTArray<PropertyStyleAnimationValuePair>& aValues,
|
||||||
bool* aIsContextSensitive);
|
bool* aIsContextSensitive);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче