Bug 1317209 - Part 6: Support transition cascade level. r=heycam
Implement the mapping between EffectCompositor::CascadeLevel in Gecko and
EffectCompositor_CascadeLevel in Servo, so we can pass it as a parameter into
Gecko_GetAnimationRule.
MozReview-Commit-ID: GRedooyGE8c
--- a/dom/animation/EffectCompositor.h
+++ b/dom/animation/EffectCompositor.h
@@ -55,22 +55,22 @@ public:
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(EffectCompositor)
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(EffectCompositor)
void Disconnect() {
mPresContext = nullptr;
}
// Animations can be applied at two different levels in the CSS cascade:
- enum class CascadeLevel {
+ enum class CascadeLevel : uint32_t {
// The animations sheet (CSS animations, script-generated animations,
// and CSS transitions that are no longer tied to CSS markup)
- Animations,
+ Animations = 0,
// The transitions sheet (CSS transitions that are tied to CSS markup)
- Transitions
+ Transitions = 1
};
// We don't define this as part of CascadeLevel as then we'd have to add
// explicit checks for the Count enum value everywhere CascadeLevel is used.
static const size_t kCascadeLevelCount =
static_cast<size_t>(CascadeLevel::Transitions) + 1;
// NOTE: This can return null after Disconnect().
nsPresContext* PresContext() const { return mPresContext; }
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -324,48 +324,46 @@ Gecko_GetServoDeclarationBlock(RawGeckoE
return nullptr;
}
return reinterpret_cast<const RawServoDeclarationBlockStrong*>
(decl->AsServo()->RefRaw());
}
RawServoDeclarationBlockStrong
Gecko_GetAnimationRule(RawGeckoElementBorrowed aElement,
- nsIAtom* aPseudoTag)
+ nsIAtom* aPseudoTag,
+ EffectCompositor::CascadeLevel aCascadeLevel)
{
MOZ_ASSERT(aElement, "Invalid GeckoElement");
const RawServoDeclarationBlockStrong emptyDeclarationBlock{ nullptr };
nsIDocument* doc = aElement->GetComposedDoc();
if (!doc || !doc->GetShell()) {
return emptyDeclarationBlock;
}
nsPresContext* presContext = doc->GetShell()->GetPresContext();
if (!presContext) {
return emptyDeclarationBlock;
}
- // FIXME: support different cascading levels in the later patch
CSSPseudoElementType pseudoType =
aPseudoTag
? nsCSSPseudoElements::GetPseudoType(
aPseudoTag,
nsCSSProps::EnabledState::eIgnoreEnabledState)
: CSSPseudoElementType::NotPseudo;
if (pseudoType != CSSPseudoElementType::NotPseudo &&
pseudoType != CSSPseudoElementType::before &&
pseudoType != CSSPseudoElementType::after) {
return emptyDeclarationBlock;
}
ServoAnimationRule* rule =
- presContext->EffectCompositor()->GetServoAnimationRule(
- aElement,
- pseudoType,
- EffectCompositor::CascadeLevel::Animations);
+ presContext->EffectCompositor()
+ ->GetServoAnimationRule(aElement, pseudoType, aCascadeLevel);
if (!rule) {
return emptyDeclarationBlock;
}
return rule->GetValues();
}
void
Gecko_FillAllBackgroundLists(nsStyleImageLayers* aLayers, uint32_t aMaxLen)
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -8,16 +8,17 @@
#define mozilla_ServoBindings_h
#include <stdint.h>
#include "mozilla/ServoTypes.h"
#include "mozilla/ServoBindingTypes.h"
#include "mozilla/ServoElementSnapshot.h"
#include "mozilla/css/SheetParsingMode.h"
+#include "mozilla/EffectCompositor.h"
#include "nsChangeHint.h"
#include "nsCSSPseudoClasses.h"
#include "nsStyleStruct.h"
/*
* API for Servo to access Gecko data structures. This file must compile as valid
* C code in order for the binding generator to parse it.
*
@@ -156,17 +157,18 @@ SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNC
// Style attributes.
RawServoDeclarationBlockStrongBorrowedOrNull
Gecko_GetServoDeclarationBlock(RawGeckoElementBorrowed element);
// Animations
RawServoDeclarationBlockStrong
Gecko_GetAnimationRule(RawGeckoElementBorrowed aElement,
- nsIAtom* aPseudoTag);
+ nsIAtom* aPseudoTag,
+ mozilla::EffectCompositor::CascadeLevel aCascadeLevel);
// Atoms.
nsIAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
void Gecko_AddRefAtom(nsIAtom* aAtom);
void Gecko_ReleaseAtom(nsIAtom* aAtom);
const uint16_t* Gecko_GetAtomAsUTF16(nsIAtom* aAtom, uint32_t* aLength);
bool Gecko_AtomEqualsUTF8(nsIAtom* aAtom, const char* aString, uint32_t aLength);
bool Gecko_AtomEqualsUTF8IgnoreCase(nsIAtom* aAtom, const char* aString, uint32_t aLength);