зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1212720 - Part 1: Implement Document.getAnimations(). r=heycam, r=smaug
This commit is contained in:
Родитель
4236137699
Коммит
df09492fe4
|
@ -3318,6 +3318,13 @@ Element::GetAnimations(nsTArray<RefPtr<Animation>>& aAnimations)
|
|||
doc->FlushPendingNotifications(Flush_Style);
|
||||
}
|
||||
|
||||
GetAnimationsUnsorted(aAnimations);
|
||||
aAnimations.Sort(AnimationPtrComparator<RefPtr<Animation>>());
|
||||
}
|
||||
|
||||
void
|
||||
Element::GetAnimationsUnsorted(nsTArray<RefPtr<Animation>>& aAnimations)
|
||||
{
|
||||
EffectSet* effects = EffectSet::GetEffectSet(this,
|
||||
nsCSSPseudoElements::ePseudo_NotPseudoElement);
|
||||
if (!effects) {
|
||||
|
@ -3335,8 +3342,6 @@ Element::GetAnimations(nsTArray<RefPtr<Animation>>& aAnimations)
|
|||
"effect set");
|
||||
aAnimations.AppendElement(animation);
|
||||
}
|
||||
|
||||
aAnimations.Sort(AnimationPtrComparator<RefPtr<Animation>>());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -821,7 +821,9 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
// Note: GetAnimations will flush style while GetAnimationsUnsorted won't.
|
||||
void GetAnimations(nsTArray<RefPtr<Animation>>& aAnimations);
|
||||
void GetAnimationsUnsorted(nsTArray<RefPtr<Animation>>& aAnimations);
|
||||
|
||||
NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML);
|
||||
virtual void SetInnerHTML(const nsAString& aInnerHTML, ErrorResult& aError);
|
||||
|
|
|
@ -10,10 +10,12 @@
|
|||
|
||||
#include "nsDocument.h"
|
||||
|
||||
#include "mozilla/AnimationComparator.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/BinarySearch.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/EffectSet.h"
|
||||
#include "mozilla/IntegerRange.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Likely.h"
|
||||
|
@ -3134,6 +3136,32 @@ nsDocument::Timeline()
|
|||
return mDocumentTimeline;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::GetAnimations(nsTArray<RefPtr<Animation>>& aAnimations)
|
||||
{
|
||||
FlushPendingNotifications(Flush_Style);
|
||||
|
||||
// Bug 1174575: Until we implement a suitable PseudoElement interface we
|
||||
// don't have anything to return for the |target| attribute of
|
||||
// KeyframeEffect(ReadOnly) objects that refer to pseudo-elements.
|
||||
// Rather than return some half-baked version of these objects (e.g.
|
||||
// we a null effect attribute) we simply don't provide access to animations
|
||||
// whose effect refers to a pseudo-element until we can support them
|
||||
// properly.
|
||||
for (nsIContent* node = nsINode::GetFirstChild();
|
||||
node;
|
||||
node = node->GetNextNode(this)) {
|
||||
if (!node->IsElement()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
node->AsElement()->GetAnimationsUnsorted(aAnimations);
|
||||
}
|
||||
|
||||
// Sort animations by priority
|
||||
aAnimations.Sort(AnimationPtrComparator<RefPtr<Animation>>());
|
||||
}
|
||||
|
||||
/* Return true if the document is in the focused top-level window, and is an
|
||||
* ancestor of the focused DOMWindow. */
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -787,6 +787,8 @@ public:
|
|||
|
||||
static bool IsWebAnimationsEnabled(JSContext* aCx, JSObject* aObject);
|
||||
virtual mozilla::dom::DocumentTimeline* Timeline() override;
|
||||
virtual void GetAnimations(
|
||||
nsTArray<RefPtr<mozilla::dom::Animation>>& aAnimations) override;
|
||||
|
||||
virtual nsresult SetSubDocumentFor(Element* aContent,
|
||||
nsIDocument* aSubDoc) override;
|
||||
|
|
|
@ -103,6 +103,7 @@ class Rule;
|
|||
} // namespace css
|
||||
|
||||
namespace dom {
|
||||
class Animation;
|
||||
class AnonymousContent;
|
||||
class Attr;
|
||||
class BoxObject;
|
||||
|
@ -2156,6 +2157,9 @@ public:
|
|||
|
||||
virtual mozilla::dom::DocumentTimeline* Timeline() = 0;
|
||||
|
||||
virtual void GetAnimations(
|
||||
nsTArray<RefPtr<mozilla::dom::Animation>>& aAnimations) = 0;
|
||||
|
||||
nsresult ScheduleFrameRequestCallback(mozilla::dom::FrameRequestCallback& aCallback,
|
||||
int32_t *aHandle);
|
||||
void CancelFrameRequestCallback(int32_t aHandle);
|
||||
|
|
|
@ -303,6 +303,8 @@ partial interface Document {
|
|||
partial interface Document {
|
||||
[Func="nsDocument::IsWebAnimationsEnabled"]
|
||||
readonly attribute DocumentTimeline timeline;
|
||||
[Func="nsDocument::IsWebAnimationsEnabled"]
|
||||
sequence<Animation> getAnimations();
|
||||
};
|
||||
|
||||
// Mozilla extensions of various sorts
|
||||
|
|
Загрузка…
Ссылка в новой задаче