Changeset 286555 in webkit
- Timestamp:
- Dec 6, 2021 11:30:57 AM (8 months ago)
- Location:
- trunk
- Files:
-
- 6 added
- 17 edited
- 6 copied
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/platform/win/TestExpectations (modified) (1 diff)
-
LayoutTests/webanimations/custom-effect (added)
-
LayoutTests/webanimations/custom-effect/custom-effect-expected.txt (added)
-
LayoutTests/webanimations/custom-effect/custom-effect.html (added)
-
LayoutTests/webanimations/custom-effect/document-timeline-animate-expected.txt (added)
-
LayoutTests/webanimations/custom-effect/document-timeline-animate.html (added)
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (modified) (1 diff)
-
Source/WebCore/CMakeLists.txt (modified) (2 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/DerivedSources-input.xcfilelist (modified) (1 diff)
-
Source/WebCore/DerivedSources-output.xcfilelist (modified) (1 diff)
-
Source/WebCore/DerivedSources.make (modified) (1 diff)
-
Source/WebCore/Headers.cmake (modified) (1 diff)
-
Source/WebCore/Sources.txt (modified) (2 diffs)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (5 diffs)
-
Source/WebCore/animation/AnimationEffect.h (modified) (1 diff)
-
Source/WebCore/animation/CustomAnimationOptions.h (copied) (copied from trunk/Source/WebCore/animation/DocumentTimeline.idl) (2 diffs)
-
Source/WebCore/animation/CustomAnimationOptions.idl (copied) (copied from trunk/Source/WebCore/animation/DocumentTimeline.idl) (2 diffs)
-
Source/WebCore/animation/CustomEffect.cpp (added)
-
Source/WebCore/animation/CustomEffect.h (copied) (copied from trunk/Source/WebCore/animation/DocumentTimeline.idl) (2 diffs)
-
Source/WebCore/animation/CustomEffect.idl (copied) (copied from trunk/Source/WebCore/animation/DocumentTimeline.idl) (2 diffs)
-
Source/WebCore/animation/CustomEffectCallback.h (copied) (copied from trunk/Source/WebCore/animation/DocumentTimeline.idl) (2 diffs)
-
Source/WebCore/animation/CustomEffectCallback.idl (copied) (copied from trunk/Source/WebCore/animation/DocumentTimeline.idl) (2 diffs)
-
Source/WebCore/animation/DocumentTimeline.cpp (modified) (2 diffs)
-
Source/WebCore/animation/DocumentTimeline.h (modified) (2 diffs)
-
Source/WebCore/animation/DocumentTimeline.idl (modified) (1 diff)
-
Source/WebCore/bindings/js/WebCoreBuiltinNames.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r286553 r286555 1 2021-12-06 Antoine Quint <graouts@webkit.org> 2 3 [Web Animations] Add a way to run scripted animations 4 https://bugs.webkit.org/show_bug.cgi?id=233869 5 rdar://85983542 6 7 Reviewed by Dean Jackson. 8 9 Add tests for the new CustomEffect interface and the document.timeline.animate() method. 10 These are written using WPT libraries such that they may be upstreamed to the WPT repository 11 in the future if and when the CustomEffect interface is standardized. 12 13 * platform/win/TestExpectations: 14 * webanimations/custom-effect/custom-effect-expected.txt: Added. 15 * webanimations/custom-effect/custom-effect.html: Added. 16 * webanimations/custom-effect/document-timeline-animate-expected.txt: Added. 17 * webanimations/custom-effect/document-timeline-animate.html: Added. 18 1 19 2021-12-06 Rob Buis <rbuis@igalia.com> 2 20 -
trunk/LayoutTests/platform/win/TestExpectations
r286406 r286555 4761 4761 4762 4762 webkit.org/b/232703 webanimations/no-style-updates-for-animated-sibling-elements-accelerated.html [ Failure ] 4763 4764 webkit.org/b/233887 webanimations/custom-effect [ Failure ] -
trunk/Source/WTF/ChangeLog
r286554 r286555 1 2021-12-06 Antoine Quint <graouts@webkit.org> 2 3 [Web Animations] Add a way to run scripted animations 4 https://bugs.webkit.org/show_bug.cgi?id=233869 5 rdar://85983542 6 7 Reviewed by Dean Jackson. 8 9 Add a new experimental feature for the CustomEffect interface. 10 11 * Scripts/Preferences/WebPreferencesExperimental.yaml: 12 1 13 2021-12-06 Jon Lee <jonlee@apple.com> 2 14 -
trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml
r286554 r286555 1472 1472 default: false 1473 1473 1474 WebAnimationsCustomEffectsEnabled: 1475 type: bool 1476 humanReadableName: "Web Animations custom effects" 1477 humanReadableDescription: "Support for the CustomEffect interface" 1478 defaultValue: 1479 WebKitLegacy: 1480 default: false 1481 WebKit: 1482 "ENABLE(EXPERIMENTAL_FEATURES)" : true 1483 default: false 1484 WebCore: 1485 default: false 1486 1474 1487 # FIXME: This is enabled when ENABLE(EXPERIMENTAL_FEATURES) is true in WebKit2. Perhaps we should consider using that for WebKitLegacy as well. 1475 1488 WebAnimationsMutableTimelinesEnabled: -
trunk/Source/WebCore/CMakeLists.txt
r286464 r286555 680 680 animation/AnimationEffect.idl 681 681 animation/AnimationFrameProvider.idl 682 animation/EffectTiming.idl683 682 animation/AnimationPlaybackEvent.idl 684 683 animation/AnimationPlaybackEventInit.idl … … 689 688 animation/CompositeOperationOrAuto.idl 690 689 animation/ComputedEffectTiming.idl 690 animation/CustomAnimationOptions.idl 691 animation/CustomEffect.idl 692 animation/CustomEffectCallback.idl 691 693 animation/Document+WebAnimations.idl 692 694 animation/DocumentOrShadowRoot+WebAnimations.idl 693 695 animation/DocumentTimeline.idl 694 696 animation/DocumentTimelineOptions.idl 697 animation/EffectTiming.idl 695 698 animation/FillMode.idl 696 699 animation/GetAnimationsOptions.idl -
trunk/Source/WebCore/ChangeLog
r286553 r286555 1 2021-12-06 Antoine Quint <graouts@webkit.org> 2 3 [Web Animations] Add a way to run scripted animations 4 https://bugs.webkit.org/show_bug.cgi?id=233869 5 rdar://85983542 6 7 Reviewed by Dean Jackson. 8 9 Tests: webanimations/custom-effect/custom-effect.html 10 webanimations/custom-effect/document-timeline-animate.html 11 12 This patch adds two new Web-exposed features to allow authors to write callback-based animations 13 leveraging the full power of the Web Animations model. 14 15 First, we add a new AnimationEffect subclass which wraps a callback to be executed on every tick 16 of the associated animation's timeline: CustomEffect. It can be constructed by providing a JS function 17 as its first parameter, and either a number or a dictionary to provide timing properties for the effect. 18 This is similar to how KeyframeEffect will accept a keyframes object and then timing data. The callback 19 is provided the effect progress as its sole parameter. Web authors can use this new interface as follows: 20 21 const animation = new Animation; 22 animation.effect = new CustomEffect(progress => { … }, 1000); 23 animation.play(); 24 25 Second, to make starting callback-based animations more straightforward and in a very similar fashion 26 to how keyframe animations can be initiated on an element using Element.animate(), we introduce a new 27 animate() method on DocumentTimeline, allowing the previous exmaple to be written as: 28 29 const animation = document.timeline.animate(progress => { … }, 1000); 30 31 This simple approach allows Web authors to move past the simple use of requestAnimationFrame() and harness 32 the Web Animations timing model which will let them pause and resume animations, seek them, control their 33 playback rate, apply easing, respond to the "finished" promise, etc. 34 35 The code itself is very simple, CustomEffect is simply an AnimationEffect subclass that indicates that it's 36 always interested in scheduling updates while active using the ticksContinouslyWhileActive() method. This 37 means that all the scheduling logic contained in WebAnimation and AnimationEffect applies, allowing callbacks 38 to not be fired when the animation is paused or when the page is suspended, or fired sparingly when a steps() 39 timing function is specified. 40 41 * CMakeLists.txt: 42 * DerivedSources-input.xcfilelist: 43 * DerivedSources-output.xcfilelist: 44 * DerivedSources.make: 45 * Headers.cmake: 46 * Sources.txt: 47 * WebCore.xcodeproj/project.pbxproj: 48 * animation/AnimationEffect.h: 49 (WebCore::AnimationEffect::isCustomEffect const): 50 * animation/CustomAnimationOptions.h: Added. 51 * animation/CustomAnimationOptions.idl: Added. 52 * animation/CustomEffect.cpp: Added. 53 (WebCore::CustomEffect::create): 54 (WebCore::CustomEffect::CustomEffect): 55 (WebCore::CustomEffect::animationDidTick): 56 * animation/CustomEffect.h: Added. 57 (WebCore::CustomEffect::~CustomEffect): 58 * animation/CustomEffect.idl: Added. 59 * animation/CustomEffectCallback.h: Added. 60 * animation/CustomEffectCallback.idl: Added. 61 * animation/DocumentTimeline.cpp: 62 (WebCore::DocumentTimeline::animate): 63 * animation/DocumentTimeline.h: 64 * animation/DocumentTimeline.idl: 65 * bindings/js/WebCoreBuiltinNames.h: 66 1 67 2021-12-06 Rob Buis <rbuis@igalia.com> 2 68 -
trunk/Source/WebCore/DerivedSources-input.xcfilelist
r286464 r286555 815 815 $(PROJECT_DIR)/animation/CompositeOperationOrAuto.idl 816 816 $(PROJECT_DIR)/animation/ComputedEffectTiming.idl 817 $(PROJECT_DIR)/animation/CustomAnimationOptions.idl 818 $(PROJECT_DIR)/animation/CustomEffect.idl 819 $(PROJECT_DIR)/animation/CustomEffectCallback.idl 817 820 $(PROJECT_DIR)/animation/Document+WebAnimations.idl 818 821 $(PROJECT_DIR)/animation/DocumentOrShadowRoot+WebAnimations.idl -
trunk/Source/WebCore/DerivedSources-output.xcfilelist
r286419 r286555 531 531 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCryptoRsaKeyAlgorithm.cpp 532 532 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCryptoRsaKeyAlgorithm.h 533 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCustomAnimationOptions.cpp 534 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCustomAnimationOptions.h 535 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCustomEffect.cpp 536 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCustomEffect.h 537 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCustomEffectCallback.cpp 538 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCustomEffectCallback.h 533 539 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCustomElementRegistry.cpp 534 540 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCustomElementRegistry.h -
trunk/Source/WebCore/DerivedSources.make
r286464 r286555 704 704 $(WebCore)/animation/CompositeOperationOrAuto.idl \ 705 705 $(WebCore)/animation/ComputedEffectTiming.idl \ 706 $(WebCore)/animation/CustomAnimationOptions.idl \ 707 $(WebCore)/animation/CustomEffect.idl \ 708 $(WebCore)/animation/CustomEffectCallback.idl \ 706 709 $(WebCore)/animation/Document+WebAnimations.idl \ 707 710 $(WebCore)/animation/DocumentOrShadowRoot+WebAnimations.idl \ -
trunk/Source/WebCore/Headers.cmake
r286538 r286555 385 385 386 386 animation/CSSPropertyBlendingClient.h 387 animation/CustomAnimationOptions.h 387 388 animation/CompositeOperation.h 388 389 animation/DocumentTimelinesController.h -
trunk/Source/WebCore/Sources.txt
r286464 r286555 470 470 animation/CSSPropertyAnimation.cpp 471 471 animation/CSSTransition.cpp 472 animation/CustomEffect.cpp 472 473 animation/DeclarativeAnimation.cpp 473 474 animation/DocumentTimeline.cpp … … 3006 3007 JSCryptoRsaHashedKeyAlgorithm.cpp 3007 3008 JSCryptoRsaKeyAlgorithm.cpp 3009 JSCustomAnimationOptions.cpp 3010 JSCustomEffect.cpp 3011 JSCustomEffectCallback.cpp 3008 3012 JSCustomElementRegistry.cpp 3009 3013 JSCustomEvent.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r286538 r286555 2280 2280 71729F7B20F3BA4900801CE6 /* DocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7A20F3BA3A00801CE6 /* DocumentTimelineOptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2281 2281 71729F7E20F3BB4700801CE6 /* JSDocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7C20F3BAB900801CE6 /* JSDocumentTimelineOptions.h */; }; 2282 7173694A275E0B5E003ADA9B /* CustomEffect.h in Headers */ = {isa = PBXBuildFile; fileRef = 71A74B082759293600DE80BA /* CustomEffect.h */; }; 2283 7173694B275E0B6A003ADA9B /* CustomEffectCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 71A74B0A27592B3500DE80BA /* CustomEffectCallback.h */; }; 2284 7173694C275E0BAB003ADA9B /* CustomAnimationOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71736947275E0B4B003ADA9B /* CustomAnimationOptions.h */; }; 2282 2285 7177AD57274295D1002F103B /* HTMLModelElementCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = 7177AD5627429590002F103B /* HTMLModelElementCamera.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2283 2286 7181A16C244F0F40007D8A24 /* DocumentTimelinesController.h in Headers */ = {isa = PBXBuildFile; fileRef = 7181A169244F0F2C007D8A24 /* DocumentTimelinesController.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 11077 11080 71729F7C20F3BAB900801CE6 /* JSDocumentTimelineOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDocumentTimelineOptions.h; sourceTree = "<group>"; }; 11078 11081 71729F7D20F3BABA00801CE6 /* JSDocumentTimelineOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentTimelineOptions.cpp; sourceTree = "<group>"; }; 11082 71736947275E0B4B003ADA9B /* CustomAnimationOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomAnimationOptions.h; sourceTree = "<group>"; }; 11083 71736949275E0B4C003ADA9B /* CustomAnimationOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CustomAnimationOptions.idl; sourceTree = "<group>"; }; 11079 11084 7173DEBD2614DF040097DF32 /* Styleable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Styleable.cpp; sourceTree = "<group>"; }; 11080 11085 7177AD542742952F002F103B /* HTMLModelElementCamera.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLModelElementCamera.idl; sourceTree = "<group>"; }; … … 11113 11118 71A58193236F466400D81A24 /* KeyframeEffectStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyframeEffectStack.h; sourceTree = "<group>"; }; 11114 11119 71A58195236F466500D81A24 /* KeyframeEffectStack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyframeEffectStack.cpp; sourceTree = "<group>"; }; 11120 71A74B052759293600DE80BA /* CustomEffect.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CustomEffect.idl; sourceTree = "<group>"; }; 11121 71A74B072759293600DE80BA /* CustomEffect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomEffect.cpp; sourceTree = "<group>"; }; 11122 71A74B082759293600DE80BA /* CustomEffect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomEffect.h; sourceTree = "<group>"; }; 11123 71A74B0927592A5300DE80BA /* CustomEffectCallback.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CustomEffectCallback.idl; sourceTree = "<group>"; }; 11124 71A74B0A27592B3500DE80BA /* CustomEffectCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomEffectCallback.h; sourceTree = "<group>"; }; 11115 11125 71AEE4EB21B5A49C00DDB036 /* TouchAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TouchAction.h; sourceTree = "<group>"; }; 11116 11126 71B0460A1DD3C2EE00EE19CF /* status-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "status-support.js"; sourceTree = "<group>"; }; … … 24258 24268 7123C186204739BA00789392 /* CSSTransition.h */, 24259 24269 7123C185204739B900789392 /* CSSTransition.idl */, 24270 71736947275E0B4B003ADA9B /* CustomAnimationOptions.h */, 24271 71736949275E0B4C003ADA9B /* CustomAnimationOptions.idl */, 24272 71A74B072759293600DE80BA /* CustomEffect.cpp */, 24273 71A74B082759293600DE80BA /* CustomEffect.h */, 24274 71A74B052759293600DE80BA /* CustomEffect.idl */, 24275 71A74B0A27592B3500DE80BA /* CustomEffectCallback.h */, 24276 71A74B0927592A5300DE80BA /* CustomEffectCallback.idl */, 24260 24277 715AD71F2050512400D592DC /* DeclarativeAnimation.cpp */, 24261 24278 715AD71D2050512400D592DC /* DeclarativeAnimation.h */, … … 33809 33826 BC2272A20E82E87C00E7F975 /* CursorData.h in Headers */, 33810 33827 BC2272AD0E82E8F300E7F975 /* CursorList.h in Headers */, 33828 7173694C275E0BAB003ADA9B /* CustomAnimationOptions.h in Headers */, 33829 7173694A275E0B5E003ADA9B /* CustomEffect.h in Headers */, 33830 7173694B275E0B6A003ADA9B /* CustomEffectCallback.h in Headers */, 33811 33831 93D437A01D57B19A00AB85EA /* CustomElementReactionQueue.h in Headers */, 33812 33832 9BD4E91B1C462CFC005065BC /* CustomElementRegistry.h in Headers */, -
trunk/Source/WebCore/animation/AnimationEffect.h
r286544 r286555 52 52 virtual ~AnimationEffect(); 53 53 54 virtual bool isCustomEffect() const { return false; } 54 55 virtual bool isKeyframeEffect() const { return false; } 55 56 -
trunk/Source/WebCore/animation/CustomAnimationOptions.h
r286554 r286555 1 1 /* 2 * Copyright (C) 20 17Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 [ 27 Exposed=Window 28 ] interface DocumentTimeline : AnimationTimeline { 29 [CallWith=Document] constructor(optional DocumentTimelineOptions options); 26 #pragma once 27 28 #include "EffectTiming.h" 29 30 namespace WebCore { 31 32 struct CustomAnimationOptions : EffectTiming { 33 String id; 30 34 }; 35 36 } // namespace WebCore 37 -
trunk/Source/WebCore/animation/CustomAnimationOptions.idl
r286554 r286555 1 1 /* 2 * Copyright (C) 20 17Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 [ 27 Exposed=Window 28 ] interface DocumentTimeline : AnimationTimeline { 29 [CallWith=Document] constructor(optional DocumentTimelineOptions options); 26 dictionary CustomAnimationOptions : EffectTiming { 27 DOMString id = ""; 30 28 }; 29 -
trunk/Source/WebCore/animation/CustomEffect.h
r286554 r286555 1 1 /* 2 * Copyright (C) 20 17Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 [ 27 Exposed=Window 28 ] interface DocumentTimeline : AnimationTimeline { 29 [CallWith=Document] constructor(optional DocumentTimelineOptions options); 26 #pragma once 27 28 #include "AnimationEffect.h" 29 #include "CustomEffectCallback.h" 30 #include "EffectTiming.h" 31 #include <wtf/Ref.h> 32 33 namespace WebCore { 34 35 class CustomEffect : public AnimationEffect { 36 public: 37 static ExceptionOr<Ref<CustomEffect>> create(Ref<CustomEffectCallback>&&, std::optional<std::variant<double, EffectTiming>>&&); 38 ~CustomEffect() { } 39 40 private: 41 CustomEffect(Ref<CustomEffectCallback>&&); 42 43 // AnimationEffect 44 bool isCustomEffect() const final { return true; } 45 void animationDidTick() final; 46 bool ticksContinouslyWhileActive() const final { return true; } 47 48 Ref<CustomEffectCallback> m_callback; 30 49 }; 50 51 } // namespace WebCore 52 53 SPECIALIZE_TYPE_TRAITS_ANIMATION_EFFECT(CustomEffect, isCustomEffect()); -
trunk/Source/WebCore/animation/CustomEffect.idl
r286554 r286555 1 1 /* 2 * Copyright (C) 20 17Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 [ 27 Exposed=Window 28 ] interface DocumentTimeline : AnimationTimeline { 29 [CallWith=Document] constructor(optional DocumentTimelineOptions options); 27 EnabledBySetting=WebAnimationsCustomEffectsEnabled, 28 Exposed=Window, 29 JSGenerateToNativeObject, 30 ] interface CustomEffect : AnimationEffect { 31 constructor(CustomEffectCallback callback, optional (unrestricted double or EffectTiming) options); 30 32 }; -
trunk/Source/WebCore/animation/CustomEffectCallback.h
r286554 r286555 1 1 /* 2 * Copyright (C) 20 17Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 [ 27 Exposed=Window 28 ] interface DocumentTimeline : AnimationTimeline { 29 [CallWith=Document] constructor(optional DocumentTimelineOptions options); 26 #pragma once 27 28 #include "ActiveDOMCallback.h" 29 #include "CallbackResult.h" 30 #include <wtf/RefCounted.h> 31 #include <wtf/Seconds.h> 32 33 namespace WebCore { 34 35 class CustomEffectCallback : public RefCounted<CustomEffectCallback>, public ActiveDOMCallback { 36 public: 37 using ActiveDOMCallback::ActiveDOMCallback; 38 39 virtual CallbackResult<void> handleEvent(double progress) = 0; 30 40 }; 41 42 } // namespace WebCore -
trunk/Source/WebCore/animation/CustomEffectCallback.idl
r286554 r286555 1 1 /* 2 * Copyright (C) 20 17Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 [ 27 Exposed=Window 28 ] interface DocumentTimeline : AnimationTimeline { 29 [CallWith=Document] constructor(optional DocumentTimelineOptions options); 30 }; 26 callback CustomEffectCallback = undefined (double progress); -
trunk/Source/WebCore/animation/DocumentTimeline.cpp
r285397 r286555 29 29 #include "AnimationEventBase.h" 30 30 #include "CSSTransition.h" 31 #include "CustomAnimationOptions.h" 32 #include "CustomEffect.h" 33 #include "CustomEffectCallback.h" 31 34 #include "DeclarativeAnimation.h" 32 35 #include "Document.h" … … 495 498 } 496 499 500 ExceptionOr<Ref<WebAnimation>> DocumentTimeline::animate(Ref<CustomEffectCallback>&& callback, std::optional<std::variant<double, CustomAnimationOptions>>&& options) 501 { 502 ASSERT(m_document); 503 504 String id = ""; 505 std::optional<std::variant<double, EffectTiming>> customEffectOptions; 506 507 if (options) { 508 std::variant<double, EffectTiming> customEffectOptionsVariant; 509 if (std::holds_alternative<double>(*options)) 510 customEffectOptionsVariant = std::get<double>(*options); 511 else { 512 auto customEffectOptions = std::get<CustomAnimationOptions>(*options); 513 id = customEffectOptions.id; 514 customEffectOptionsVariant = WTFMove(customEffectOptions); 515 } 516 customEffectOptions = customEffectOptionsVariant; 517 } 518 519 auto customEffectResult = CustomEffect::create(WTFMove(callback), WTFMove(customEffectOptions)); 520 if (customEffectResult.hasException()) 521 return customEffectResult.releaseException(); 522 523 auto animation = WebAnimation::create(*document(), &customEffectResult.returnValue().get()); 524 animation->setId(id); 525 526 auto animationPlayResult = animation->play(); 527 if (animationPlayResult.hasException()) 528 return animationPlayResult.releaseException(); 529 530 return animation; 531 } 532 497 533 } // namespace WebCore -
trunk/Source/WebCore/animation/DocumentTimeline.h
r284202 r286555 35 35 36 36 class AnimationEventBase; 37 class CustomEffectCallback; 37 38 class DocumentTimelinesController; 38 39 class RenderBoxModelObject; 39 40 class RenderElement; 41 42 struct CustomAnimationOptions; 40 43 41 44 class DocumentTimeline final : public AnimationTimeline … … 51 54 52 55 std::optional<Seconds> currentTime() override; 56 ExceptionOr<Ref<WebAnimation>> animate(Ref<CustomEffectCallback>&&, std::optional<std::variant<double, CustomAnimationOptions>>&&); 53 57 54 58 void animationTimingDidChange(WebAnimation&) override; -
trunk/Source/WebCore/animation/DocumentTimeline.idl
r267813 r286555 28 28 ] interface DocumentTimeline : AnimationTimeline { 29 29 [CallWith=Document] constructor(optional DocumentTimelineOptions options); 30 [EnabledBySetting=WebAnimationsCustomEffectsEnabled] WebAnimation animate(CustomEffectCallback callback, optional (unrestricted double or CustomAnimationOptions) options); 30 31 }; -
trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
r286419 r286555 107 107 macro(CSSVariableReferenceValue) \ 108 108 macro(CustomElementRegistry) \ 109 macro(CustomEffect) \ 109 110 macro(Database) \ 110 111 macro(DataTransferItem) \
Note: See TracChangeset
for help on using the changeset viewer.