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:
Boris Chiou 2016-02-09 05:04:00 +01:00
Родитель 2a5bfa8330
Коммит 8627ee5709
5 изменённых файлов: 75 добавлений и 36 удалений

Просмотреть файл

@ -1197,9 +1197,11 @@ 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(
pair.mProperty,
nsCSSProps::eEnabledForAllContent, nsCSSProps::eEnabledForAllContent,
aTarget, aTarget,
nsCSSPseudoElements::ePseudo_NotPseudoElement,
pair.mValues[0], pair.mValues[0],
/* aUseSVGMode */ false, /* aUseSVGMode */ false,
values)) { values)) {
@ -1477,9 +1479,11 @@ 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(
pair.mProperty,
nsCSSProps::eEnabledForAllContent, nsCSSProps::eEnabledForAllContent,
aTarget, aTarget,
nsCSSPseudoElements::ePseudo_NotPseudoElement,
pair.mValues[0], pair.mValues[0],
/* aUseSVGMode */ false, /* aUseSVGMode */ false,
fromValues)) { fromValues)) {
@ -1529,9 +1533,11 @@ 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(
pair.mProperty,
nsCSSProps::eEnabledForAllContent, nsCSSProps::eEnabledForAllContent,
aTarget, aTarget,
nsCSSPseudoElements::ePseudo_NotPseudoElement,
pair.mValues[i + 1], pair.mValues[i + 1],
/* aUseSVGMode */ false, /* aUseSVGMode */ false,
toValues)) { toValues)) {

Просмотреть файл

@ -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,8 +360,13 @@ ValueFromStringHelper(nsCSSProperty aPropID,
} }
} }
nsDependentSubstring subString(aString, subStringBegin); nsDependentSubstring subString(aString, subStringBegin);
if (!StyleAnimationValue::ComputeValue(aPropID, aTargetElement, subString, if (!StyleAnimationValue::ComputeValue(
true, aStyleAnimValue, aPropID,
aTargetElement,
nsCSSPseudoElements::ePseudo_NotPseudoElement,
subString,
true,
aStyleAnimValue,
aIsContextSensitive)) { aIsContextSensitive)) {
return false; return false;
} }

Просмотреть файл

@ -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
@ -151,6 +156,7 @@ public:
*/ */
static bool ComputeValue(nsCSSProperty aProperty, static bool ComputeValue(nsCSSProperty aProperty,
mozilla::dom::Element* aTargetElement, mozilla::dom::Element* aTargetElement,
nsCSSPseudoElements::Type aPseudoType,
const nsAString& aSpecifiedValue, const nsAString& aSpecifiedValue,
bool aUseSVGMode, bool aUseSVGMode,
StyleAnimationValue& aComputedValue, StyleAnimationValue& aComputedValue,
@ -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);