mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1180125 part 8 - Dispatch transition events from refresh driver; r=dbaron
This patch causes transition events to be dispatched as a separate step after sampling the transitions. Eventually this will allow us to sample transitions from their timeline (independently of where they came from and in potentially any order) by separating the concepts of sampling and event dispatch.
This commit is contained in:
parent
256f836f71
commit
a8682cf4b0
@ -1490,25 +1490,44 @@ nsRefreshDriver::DispatchPendingEvents()
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
enum class AnimationEventType {
|
||||
CSSAnimations,
|
||||
CSSTransitions
|
||||
};
|
||||
|
||||
struct DispatchAnimationEventParams {
|
||||
AnimationEventType mEventType;
|
||||
nsRefreshDriver* mRefreshDriver;
|
||||
};
|
||||
}
|
||||
|
||||
static bool
|
||||
DispatchAnimationEventsOnSubDocuments(nsIDocument* aDocument,
|
||||
void* aRefreshDriver)
|
||||
void* aParams)
|
||||
{
|
||||
MOZ_ASSERT(aParams, "Animation event parameters should be set");
|
||||
auto params = static_cast<DispatchAnimationEventParams*>(aParams);
|
||||
|
||||
nsIPresShell* shell = aDocument->GetShell();
|
||||
if (!shell) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsPresContext* context = shell->GetPresContext();
|
||||
if (!context || context->RefreshDriver() != aRefreshDriver) {
|
||||
if (!context || context->RefreshDriver() != params->mRefreshDriver) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> kungFuDeathGrip(aDocument);
|
||||
|
||||
context->AnimationManager()->DispatchEvents();
|
||||
if (params->mEventType == AnimationEventType::CSSAnimations) {
|
||||
context->AnimationManager()->DispatchEvents();
|
||||
} else {
|
||||
context->TransitionManager()->DispatchEvents();
|
||||
}
|
||||
aDocument->EnumerateSubDocuments(DispatchAnimationEventsOnSubDocuments,
|
||||
nullptr);
|
||||
aParams);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1521,7 +1540,18 @@ nsRefreshDriver::DispatchAnimationEvents()
|
||||
}
|
||||
|
||||
nsIDocument* doc = mPresContext->Document();
|
||||
DispatchAnimationEventsOnSubDocuments(doc, this);
|
||||
|
||||
// Dispatch transition events first since transitions conceptually sit
|
||||
// below animations in terms of compositing order.
|
||||
DispatchAnimationEventParams params { AnimationEventType::CSSTransitions,
|
||||
this };
|
||||
DispatchAnimationEventsOnSubDocuments(doc, ¶ms);
|
||||
if (!mPresContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
params.mEventType = AnimationEventType::CSSAnimations;
|
||||
DispatchAnimationEventsOnSubDocuments(doc, ¶ms);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1003,6 +1003,4 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
|
||||
}
|
||||
|
||||
MaybeStartOrStopObservingRefreshDriver();
|
||||
|
||||
mEventDispatcher.DispatchEvents(mPresContext);
|
||||
}
|
||||
|
@ -285,6 +285,7 @@ public:
|
||||
mozilla::Forward<mozilla::TransitionEventInfo>(aEventInfo));
|
||||
}
|
||||
|
||||
void DispatchEvents() { mEventDispatcher.DispatchEvents(mPresContext); }
|
||||
void ClearEventQueue() { mEventDispatcher.ClearEventQueue(); }
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user