Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Web Animations] Distinguish between an omitted and a null timeline a…
…rgument to the Animation constructor https://bugs.webkit.org/show_bug.cgi?id=179065 LayoutTests/imported/w3c: Reviewed by Dean Jackson. Update WPT test output with progressions. * web-platform-tests/web-animations/interfaces/Animation/constructor-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt: Source/WebCore: <rdar://problem/36869046> Reviewed by Dean Jackson. The Web Animations specification requires that a missing or undefined "timeline" parameter means that the document's timeline should be used, but a null value should be supported. To support this, we need to provide a custom Animation constructor where we can check on the ExecState whether the second argument passed is undefined, which is true if an explicit "undefined" value is passed or if the argument does not exist. * Sources.txt: Add the new JSWebAnimationCustom.cpp file. * WebCore.xcodeproj/project.pbxproj: Add the new JSWebAnimationCustom.cpp file. * animation/WebAnimation.cpp: (WebCore::WebAnimation::create): Add a create() variant that doesn't provide an AnimationTimeline parameter to clearly indicate that the provided Document's timeline should be used. * animation/WebAnimation.h: * animation/WebAnimation.idl: * bindings/js/JSWebAnimationCustom.cpp: Added. (WebCore::constructJSWebAnimation): Provide a custom Animation constructor where we check whether the second argument, the timeline, is undefined. * dom/Element.cpp: (WebCore::Element::animate): Use the new create() variant since passing "nullptr" now means a null timeline. Canonical link: https://commits.webkit.org/198023@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227714 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
12 changed files
with
125 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...orted/w3c/web-platform-tests/web-animations/interfaces/Animation/constructor-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (C) 2018 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 "JSWebAnimation.h" | ||
|
||
#include "JSAnimationEffect.h" | ||
#include "JSAnimationTimeline.h" | ||
#include "JSDOMConstructor.h" | ||
|
||
namespace WebCore { | ||
|
||
using namespace JSC; | ||
|
||
EncodedJSValue JSC_HOST_CALL constructJSWebAnimation(ExecState& state) | ||
{ | ||
VM& vm = state.vm(); | ||
auto throwScope = DECLARE_THROW_SCOPE(vm); | ||
UNUSED_PARAM(throwScope); | ||
auto* jsConstructor = jsCast<JSDOMConstructorBase*>(state.jsCallee()); | ||
ASSERT(jsConstructor); | ||
auto* context = jsConstructor->scriptExecutionContext(); | ||
if (UNLIKELY(!context)) | ||
return throwConstructorScriptExecutionContextUnavailableError(state, throwScope, "Animation"); | ||
auto& document = downcast<Document>(*context); | ||
auto effect = convert<IDLNullable<IDLInterface<AnimationEffect>>>(state, state.argument(0), [](ExecState& state, ThrowScope& scope) { | ||
throwArgumentTypeError(state, scope, 0, "effect", "Animation", nullptr, "AnimationEffect"); | ||
}); | ||
RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); | ||
|
||
if (state.argument(1).isUndefined()) { | ||
auto object = WebAnimation::create(document, WTFMove(effect)); | ||
return JSValue::encode(toJSNewlyCreated<IDLInterface<WebAnimation>>(state, *jsConstructor->globalObject(), WTFMove(object))); | ||
} | ||
|
||
auto timeline = convert<IDLNullable<IDLInterface<AnimationTimeline>>>(state, state.uncheckedArgument(1), [](ExecState& state, ThrowScope& scope) { | ||
throwArgumentTypeError(state, scope, 1, "timeline", "Animation", nullptr, "AnimationTimeline"); | ||
}); | ||
RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); | ||
auto object = WebAnimation::create(document, WTFMove(effect), WTFMove(timeline)); | ||
return JSValue::encode(toJSNewlyCreated<IDLInterface<WebAnimation>>(state, *jsConstructor->globalObject(), WTFMove(object))); | ||
} | ||
|
||
} // namespace WebCore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters