Bug 1343753 - Part 8: Rename and add new methods in nsTransitionManager.
Rename UpdateTransitions as DoUpdateTransitions, and add a public
method, UpdateTransitions for stylo.
MozReview-Commit-ID: 7UiGzFsGZC4
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -32,16 +32,17 @@
#include "nsMediaFeatures.h"
#include "nsNameSpaceManager.h"
#include "nsNetUtil.h"
#include "nsRuleNode.h"
#include "nsString.h"
#include "nsStyleStruct.h"
#include "nsStyleUtil.h"
#include "nsTArray.h"
+#include "nsTransitionManager.h"
#include "mozilla/EffectCompositor.h"
#include "mozilla/EffectSet.h"
#include "mozilla/EventStates.h"
#include "mozilla/Keyframe.h"
#include "mozilla/Mutex.h"
#include "mozilla/ServoElementSnapshot.h"
#include "mozilla/ServoRestyleManager.h"
@@ -443,16 +444,17 @@ Gecko_StyleAnimationsEquals(RawGeckoStyl
RawGeckoStyleAnimationListBorrowed aB)
{
return *aA == *aB;
}
void
Gecko_UpdateAnimations(RawGeckoElementBorrowed aElement,
nsIAtom* aPseudoTagOrNull,
+ ServoComputedValuesBorrowedOrNull aOldComputedValues,
ServoComputedValuesBorrowedOrNull aComputedValues,
ServoComputedValuesBorrowedOrNull aParentComputedValues,
UpdateAnimationsTasks aTaskBits)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aElement);
MOZ_ASSERT(!aPseudoTagOrNull ||
aPseudoTagOrNull == nsCSSPseudoElements::before ||
@@ -471,16 +473,24 @@ Gecko_UpdateAnimations(RawGeckoElementBo
nsCSSPseudoElements::GetPseudoType(aPseudoTagOrNull,
CSSEnabledState::eForAllContent);
if (tasks & UpdateAnimationsTasks::CSSAnimations) {
presContext->AnimationManager()->
UpdateAnimations(const_cast<dom::Element*>(aElement), pseudoType,
servoValues);
}
+ if (tasks & UpdateAnimationsTasks::CSSTransitions) {
+ MOZ_ASSERT(aOldComputedValues);
+ const ServoComputedValuesWithParent oldServoValues =
+ { aOldComputedValues, nullptr };
+ presContext->TransitionManager()->
+ UpdateTransitions(const_cast<dom::Element*>(aElement), pseudoType,
+ oldServoValues, servoValues);
+ }
if (tasks & UpdateAnimationsTasks::EffectProperties) {
presContext->EffectCompositor()->UpdateEffectProperties(
servoValues, const_cast<dom::Element*>(aElement), pseudoType);
}
}
}
bool
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -193,16 +193,17 @@ bool
Gecko_GetAnimationRule(RawGeckoElementBorrowed aElement,
nsIAtom* aPseudoTag,
mozilla::EffectCompositor::CascadeLevel aCascadeLevel,
RawServoAnimationValueMapBorrowed aAnimationValues);
bool Gecko_StyleAnimationsEquals(RawGeckoStyleAnimationListBorrowed,
RawGeckoStyleAnimationListBorrowed);
void Gecko_UpdateAnimations(RawGeckoElementBorrowed aElement,
nsIAtom* aPseudoTagOrNull,
+ ServoComputedValuesBorrowedOrNull aOldComputedValues,
ServoComputedValuesBorrowedOrNull aComputedValues,
ServoComputedValuesBorrowedOrNull aParentComputedValues,
mozilla::UpdateAnimationsTasks aTaskBits);
bool Gecko_ElementHasAnimations(RawGeckoElementBorrowed aElement,
nsIAtom* aPseudoTagOrNull);
bool Gecko_ElementHasCSSAnimations(RawGeckoElementBorrowed aElement,
nsIAtom* aPseudoTagOrNull);
double Gecko_GetProgressFromComputedTiming(RawGeckoComputedTimingBorrowed aComputedTiming);
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -580,22 +580,22 @@ nsTransitionManager::StyleContextChanged
}
nsAutoAnimationMutationBatch mb(aElement->OwnerDoc());
DebugOnly<bool> startedAny = false;
// We don't have to update transitions if display:none, although we will
// cancel them after restyling.
if (!afterChangeStyle->IsInDisplayNoneSubtree()) {
- startedAny = UpdateTransitions(disp,
- aElement,
- afterChangeStyle->GetPseudoType(),
- collection,
- aOldStyleContext,
- afterChangeStyle.get());
+ startedAny = DoUpdateTransitions(disp,
+ aElement,
+ afterChangeStyle->GetPseudoType(),
+ collection,
+ aOldStyleContext,
+ afterChangeStyle.get());
}
MOZ_ASSERT(!startedAny || collection,
"must have element transitions if we started any transitions");
EffectCompositor::CascadeLevel cascadeLevel =
EffectCompositor::CascadeLevel::Transitions;
@@ -615,19 +615,40 @@ nsTransitionManager::StyleContextChanged
// manager's GetAnimationGeneration() will ensure that we don't go
// through the rest of this function again when we do.
mPresContext->EffectCompositor()->PostRestyleForAnimation(aElement,
pseudoType,
cascadeLevel);
}
}
+bool
+nsTransitionManager::UpdateTransitions(
+ dom::Element *aElement,
+ CSSPseudoElementType aPseudoType,
+ const ServoComputedValuesWithParent& aOldStyle,
+ const ServoComputedValuesWithParent& aNewStyle)
+{
+ if (!mPresContext->IsDynamic()) {
+ // For print or print preview, ignore transitions.
+ return false;
+ }
+
+ CSSTransitionCollection* collection =
+ CSSTransitionCollection::GetAnimationCollection(aElement, aPseudoType);
+ const nsStyleDisplay *disp = Servo_GetStyleDisplay(aNewStyle.mCurrentStyle);
+ return DoUpdateTransitions(disp,
+ aElement, aPseudoType,
+ collection,
+ aOldStyle, aNewStyle);
+}
+
template<typename StyleType>
bool
-nsTransitionManager::UpdateTransitions(
+nsTransitionManager::DoUpdateTransitions(
const nsStyleDisplay* aDisp,
dom::Element* aElement,
CSSPseudoElementType aPseudoType,
CSSTransitionCollection*& aElementTransitions,
StyleType aOldStyle,
StyleType aNewStyle)
{
MOZ_ASSERT(aDisp, "Null nsStyleDisplay");
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -367,16 +367,25 @@ public:
* of the restyling of descendants. If it does, this function will
* take care of causing the necessary restyle afterwards.
*/
void StyleContextChanged(mozilla::dom::Element *aElement,
nsStyleContext *aOldStyleContext,
RefPtr<nsStyleContext>* aNewStyleContext /* inout */);
/**
+ * Update transitions for stylo.
+ */
+ bool UpdateTransitions(
+ mozilla::dom::Element *aElement,
+ mozilla::CSSPseudoElementType aPseudoType,
+ const mozilla::ServoComputedValuesWithParent& aOldStyle,
+ const mozilla::ServoComputedValuesWithParent& aNewStyle);
+
+ /**
* When we're resolving style for an element that previously didn't have
* style, we might have some old finished transitions for it, if,
* say, it was display:none for a while, but previously displayed.
*
* This method removes any finished transitions that don't match the
* new style.
*/
void PruneCompletedTransitions(mozilla::dom::Element* aElement,
@@ -406,27 +415,28 @@ public:
void ClearEventQueue() { mEventDispatcher.ClearEventQueue(); }
protected:
virtual ~nsTransitionManager() {}
typedef nsTArray<RefPtr<mozilla::dom::CSSTransition>>
OwningCSSTransitionPtrArray;
- // Update the transitions. It'd start new, replace, or stop current
- // transitions if need. aDisp and aElement shouldn't be nullptr.
+ // Update transitions. This will start new transitions,
+ // replace existing transitions, and stop existing transitions
+ // as needed. aDisp and aElement must be non-null.
// aElementTransitions is the collection of current transitions, and it
// could be a nullptr if we don't have any transitions.
template<typename StyleType> bool
- UpdateTransitions(const nsStyleDisplay* aDisp,
- mozilla::dom::Element* aElement,
- mozilla::CSSPseudoElementType aPseudoType,
- CSSTransitionCollection*& aElementTransitions,
- StyleType aOldStyle,
- StyleType aNewStyle);
+ DoUpdateTransitions(const nsStyleDisplay* aDisp,
+ mozilla::dom::Element* aElement,
+ mozilla::CSSPseudoElementType aPseudoType,
+ CSSTransitionCollection*& aElementTransitions,
+ StyleType aOldStyle,
+ StyleType aNewStyle);
template<typename StyleType> void
ConsiderInitiatingTransition(nsCSSPropertyID aProperty,
const mozilla::StyleTransition& aTransition,
mozilla::dom::Element* aElement,
mozilla::CSSPseudoElementType aPseudoType,
CSSTransitionCollection*& aElementTransitions,
StyleType aOldStyle,