haikuwebkit/Source/WebCore/animation/AnimationEventBase.cpp

52 lines
2.0 KiB
C++
Raw Permalink Normal View History

[Web Animations] Make all animation event types inherit from the same base class https://bugs.webkit.org/show_bug.cgi?id=207629 Reviewed by Simon Fraser. Currently we dispatch events CSS Transitions and CSS Animations events using a dedicated event queue on DeclarativeAnimation, while the events added by the Web Animations specification (of type AnimationPlaybackEvent) are dispatched using a shared queue on the DocumentTimeline that is processed during the "update animations and send events procedure". The Web Animations specification dictates that all events should be dispatched during that procedure, which includes sorting of such events based on their timeline time and associated animation relative composite order. In this patch, we prepare the work towards spec compliance for animation events dispatch by making all event types (AnimationPlaybackEvent, TransitionEvent and AnimationEvent) inherit from a single AnimationEventBase interface. This will allow DocumentTimeline to enqueue, sort and dispatch all such events with a single queue in a future patch. Due to CSSAnimationController, we must make the "timeline time" and "animation" parameters optional. When we drop support for CSSAnimationController we'll be able to enforce stronger requirements for these. No new test since this should not introduce any behavior change. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEventBase.cpp: Added. (WebCore::AnimationEventBase::AnimationEventBase): * animation/AnimationEventBase.h: Added. (WebCore::AnimationEventBase::create): (WebCore::AnimationEventBase::isAnimationPlaybackEvent const): (WebCore::AnimationEventBase::isAnimationEvent const): (WebCore::AnimationEventBase::isTransitionEvent const): (WebCore::AnimationEventBase::timelineTime const): (WebCore::AnimationEventBase::animation const): * animation/AnimationPlaybackEvent.cpp: (WebCore::AnimationPlaybackEvent::AnimationPlaybackEvent): (WebCore::AnimationPlaybackEvent::bindingsTimelineTime const): * animation/AnimationPlaybackEvent.h: * animation/CSSAnimation.cpp: (WebCore::CSSAnimation::createEvent): * animation/CSSAnimation.h: * animation/CSSTransition.cpp: (WebCore::CSSTransition::createEvent): * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::enqueueDOMEvent): * animation/DeclarativeAnimation.h: * animation/WebAnimation.cpp: (WebCore::WebAnimation::enqueueAnimationPlaybackEvent): * dom/AnimationEvent.cpp: (WebCore::AnimationEvent::AnimationEvent): * dom/AnimationEvent.h: * dom/TransitionEvent.cpp: (WebCore::TransitionEvent::TransitionEvent): * dom/TransitionEvent.h: * page/animation/CSSAnimationController.cpp: (WebCore::CSSAnimationControllerPrivate::fireEventsAndUpdateStyle): Canonical link: https://commits.webkit.org/220715@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256610 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-14 16:34:52 +00:00
/*
* Copyright (C) 2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "AnimationEventBase.h"
#include "WebAnimation.h"
[Web Animations] Make all animation event types inherit from the same base class https://bugs.webkit.org/show_bug.cgi?id=207629 Reviewed by Simon Fraser. Currently we dispatch events CSS Transitions and CSS Animations events using a dedicated event queue on DeclarativeAnimation, while the events added by the Web Animations specification (of type AnimationPlaybackEvent) are dispatched using a shared queue on the DocumentTimeline that is processed during the "update animations and send events procedure". The Web Animations specification dictates that all events should be dispatched during that procedure, which includes sorting of such events based on their timeline time and associated animation relative composite order. In this patch, we prepare the work towards spec compliance for animation events dispatch by making all event types (AnimationPlaybackEvent, TransitionEvent and AnimationEvent) inherit from a single AnimationEventBase interface. This will allow DocumentTimeline to enqueue, sort and dispatch all such events with a single queue in a future patch. Due to CSSAnimationController, we must make the "timeline time" and "animation" parameters optional. When we drop support for CSSAnimationController we'll be able to enforce stronger requirements for these. No new test since this should not introduce any behavior change. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEventBase.cpp: Added. (WebCore::AnimationEventBase::AnimationEventBase): * animation/AnimationEventBase.h: Added. (WebCore::AnimationEventBase::create): (WebCore::AnimationEventBase::isAnimationPlaybackEvent const): (WebCore::AnimationEventBase::isAnimationEvent const): (WebCore::AnimationEventBase::isTransitionEvent const): (WebCore::AnimationEventBase::timelineTime const): (WebCore::AnimationEventBase::animation const): * animation/AnimationPlaybackEvent.cpp: (WebCore::AnimationPlaybackEvent::AnimationPlaybackEvent): (WebCore::AnimationPlaybackEvent::bindingsTimelineTime const): * animation/AnimationPlaybackEvent.h: * animation/CSSAnimation.cpp: (WebCore::CSSAnimation::createEvent): * animation/CSSAnimation.h: * animation/CSSTransition.cpp: (WebCore::CSSTransition::createEvent): * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::enqueueDOMEvent): * animation/DeclarativeAnimation.h: * animation/WebAnimation.cpp: (WebCore::WebAnimation::enqueueAnimationPlaybackEvent): * dom/AnimationEvent.cpp: (WebCore::AnimationEvent::AnimationEvent): * dom/AnimationEvent.h: * dom/TransitionEvent.cpp: (WebCore::TransitionEvent::TransitionEvent): * dom/TransitionEvent.h: * page/animation/CSSAnimationController.cpp: (WebCore::CSSAnimationControllerPrivate::fireEventsAndUpdateStyle): Canonical link: https://commits.webkit.org/220715@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256610 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-14 16:34:52 +00:00
#include "WebAnimationUtilities.h"
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
WTF_MAKE_ISO_ALLOCATED_IMPL(AnimationEventBase);
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
AnimationEventBase::AnimationEventBase(const AtomString& type, WebAnimation* animation, std::optional<Seconds> timelineTime)
[Web Animations] Make all animation event types inherit from the same base class https://bugs.webkit.org/show_bug.cgi?id=207629 Reviewed by Simon Fraser. Currently we dispatch events CSS Transitions and CSS Animations events using a dedicated event queue on DeclarativeAnimation, while the events added by the Web Animations specification (of type AnimationPlaybackEvent) are dispatched using a shared queue on the DocumentTimeline that is processed during the "update animations and send events procedure". The Web Animations specification dictates that all events should be dispatched during that procedure, which includes sorting of such events based on their timeline time and associated animation relative composite order. In this patch, we prepare the work towards spec compliance for animation events dispatch by making all event types (AnimationPlaybackEvent, TransitionEvent and AnimationEvent) inherit from a single AnimationEventBase interface. This will allow DocumentTimeline to enqueue, sort and dispatch all such events with a single queue in a future patch. Due to CSSAnimationController, we must make the "timeline time" and "animation" parameters optional. When we drop support for CSSAnimationController we'll be able to enforce stronger requirements for these. No new test since this should not introduce any behavior change. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEventBase.cpp: Added. (WebCore::AnimationEventBase::AnimationEventBase): * animation/AnimationEventBase.h: Added. (WebCore::AnimationEventBase::create): (WebCore::AnimationEventBase::isAnimationPlaybackEvent const): (WebCore::AnimationEventBase::isAnimationEvent const): (WebCore::AnimationEventBase::isTransitionEvent const): (WebCore::AnimationEventBase::timelineTime const): (WebCore::AnimationEventBase::animation const): * animation/AnimationPlaybackEvent.cpp: (WebCore::AnimationPlaybackEvent::AnimationPlaybackEvent): (WebCore::AnimationPlaybackEvent::bindingsTimelineTime const): * animation/AnimationPlaybackEvent.h: * animation/CSSAnimation.cpp: (WebCore::CSSAnimation::createEvent): * animation/CSSAnimation.h: * animation/CSSTransition.cpp: (WebCore::CSSTransition::createEvent): * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::enqueueDOMEvent): * animation/DeclarativeAnimation.h: * animation/WebAnimation.cpp: (WebCore::WebAnimation::enqueueAnimationPlaybackEvent): * dom/AnimationEvent.cpp: (WebCore::AnimationEvent::AnimationEvent): * dom/AnimationEvent.h: * dom/TransitionEvent.cpp: (WebCore::TransitionEvent::TransitionEvent): * dom/TransitionEvent.h: * page/animation/CSSAnimationController.cpp: (WebCore::CSSAnimationControllerPrivate::fireEventsAndUpdateStyle): Canonical link: https://commits.webkit.org/220715@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256610 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-14 16:34:52 +00:00
: Event(type, CanBubble::Yes, IsCancelable::No)
, m_animation(animation)
, m_timelineTime(timelineTime)
{
}
AnimationEventBase::AnimationEventBase(const AtomString& type, const EventInit& initializer, IsTrusted isTrusted)
: Event(type, initializer, isTrusted)
{
}
AnimationEventBase::~AnimationEventBase() = default;
} // namespace WebCore