зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1290914 - support Element.animate() on AnonymousContent nodes through the AnonymousContent.setAnimationForElement() method. r=bz
MozReview-Commit-ID: 39QPaCea7Dx
This commit is contained in:
Родитель
da4d00fe95
Коммит
3e295e6280
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "mozilla/dom/KeyframeEffect.h"
|
||||
|
||||
#include "mozilla/dom/AnimatableBinding.h"
|
||||
#include "mozilla/dom/KeyframeAnimationOptionsBinding.h"
|
||||
// For UnrestrictedDoubleOrKeyframeAnimationOptions
|
||||
#include "mozilla/dom/AnimationEffectTiming.h"
|
||||
#include "mozilla/dom/KeyframeEffectBinding.h"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "mozilla/dom/KeyframeEffectReadOnly.h"
|
||||
|
||||
#include "mozilla/dom/AnimatableBinding.h"
|
||||
#include "mozilla/dom/KeyframeAnimationOptionsBinding.h"
|
||||
// For UnrestrictedDoubleOrKeyframeAnimationOptions;
|
||||
#include "mozilla/dom/CSSPseudoElement.h"
|
||||
#include "mozilla/dom/KeyframeEffectBinding.h"
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "mozilla/AnimationUtils.h"
|
||||
#include "mozilla/dom/AnimatableBinding.h"
|
||||
#include "mozilla/dom/KeyframeAnimationOptionsBinding.h"
|
||||
#include "mozilla/dom/KeyframeEffectBinding.h"
|
||||
#include "nsCSSParser.h" // For nsCSSParser
|
||||
#include "nsIDocument.h"
|
||||
|
|
|
@ -137,6 +137,23 @@ AnonymousContent::GetCanvasContext(const nsAString& aElementId,
|
|||
return context.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Animation>
|
||||
AnonymousContent::SetAnimationForElement(JSContext* aContext,
|
||||
const nsAString& aElementId,
|
||||
JS::Handle<JSObject*> aKeyframes,
|
||||
const UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
Element* element = GetElementById(aElementId);
|
||||
|
||||
if (!element) {
|
||||
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return element->Animate(aContext, aKeyframes, aOptions, aRv);
|
||||
}
|
||||
|
||||
Element*
|
||||
AnonymousContent::GetElementById(const nsAString& aElementId)
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
|
||||
class Element;
|
||||
class UnrestrictedDoubleOrAnonymousKeyframeAnimationOptions;
|
||||
|
||||
class AnonymousContent final
|
||||
{
|
||||
|
@ -57,6 +58,12 @@ public:
|
|||
const nsAString& aContextId,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Animation> SetAnimationForElement(JSContext* aContext,
|
||||
const nsAString& aElementId,
|
||||
JS::Handle<JSObject*> aKeyframes,
|
||||
const UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
|
||||
ErrorResult& aError);
|
||||
|
||||
private:
|
||||
~AnonymousContent();
|
||||
nsCOMPtr<Element> mContentNode;
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
#include "mozilla/dom/AnimatableBinding.h"
|
||||
#include "mozilla/dom/KeyframeAnimationOptionsBinding.h"
|
||||
#include "mozilla/AnimationComparator.h"
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/ContentEvents.h"
|
||||
|
|
|
@ -45,7 +45,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1020244
|
|||
|
||||
let members = ["getTextContentForElement", "setTextContentForElement",
|
||||
"getAttributeForElement", "setAttributeForElement",
|
||||
"removeAttributeForElement", "getCanvasContext"];
|
||||
"removeAttributeForElement", "getCanvasContext",
|
||||
"setAnimationForElement"];
|
||||
for (let member of members) {
|
||||
ok(member in anonymousContent, "AnonymousContent object defines " + member);
|
||||
}
|
||||
|
|
|
@ -60,6 +60,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1020244
|
|||
is(anonymousContent.getAttributeForElement("test-element", "class"), null,
|
||||
"Class attribute for the test element was removed");
|
||||
|
||||
let anim = anonymousContent.setAnimationForElement("test-element", [
|
||||
{ transform: 'translateY(0px)' },
|
||||
{ transform: 'translateY(-300px)' }
|
||||
], 2000);
|
||||
is(anim.playState, "pending", "Animation should be running");
|
||||
anim.cancel();
|
||||
is(anim.playState, "idle", "Animation should have stopped immediately");
|
||||
|
||||
chromeDocument.removeAnonymousContent(anonymousContent);
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -22,8 +22,7 @@ dictionary AnimationFilter {
|
|||
interface Animatable {
|
||||
[Func="nsDocument::IsElementAnimateEnabled", Throws]
|
||||
Animation animate(object? keyframes,
|
||||
optional (unrestricted double or KeyframeAnimationOptions)
|
||||
options);
|
||||
optional UnrestrictedDoubleOrKeyframeAnimationOptions options);
|
||||
[Func="nsDocument::IsWebAnimationsEnabled"]
|
||||
sequence<Animation> getAnimations(optional AnimationFilter filter);
|
||||
};
|
||||
|
|
|
@ -61,4 +61,10 @@ interface AnonymousContent {
|
|||
[Throws]
|
||||
nsISupports? getCanvasContext(DOMString elementId,
|
||||
DOMString contextId);
|
||||
|
||||
[Func="nsDocument::IsElementAnimateEnabled", Throws]
|
||||
Animation setAnimationForElement(DOMString elementId,
|
||||
object? keyframes,
|
||||
optional UnrestrictedDoubleOrKeyframeAnimationOptions
|
||||
options);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://dev.w3.org/fxtf/web-animations/#the-animatable-interface
|
||||
*
|
||||
* Copyright © 2014 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
// This typedef is off in its own file, because of bug 995352.
|
||||
typedef (unrestricted double or KeyframeAnimationOptions) UnrestrictedDoubleOrKeyframeAnimationOptions;
|
|
@ -291,6 +291,7 @@ WEBIDL_FILES = [
|
|||
'KeyAlgorithm.webidl',
|
||||
'KeyboardEvent.webidl',
|
||||
'KeyEvent.webidl',
|
||||
'KeyframeAnimationOptions.webidl',
|
||||
'KeyframeEffect.webidl',
|
||||
'LegacyQueryInterface.webidl',
|
||||
'LinkStyle.webidl',
|
||||
|
|
Загрузка…
Ссылка в новой задаче