mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-07 05:15:09 +00:00
6fbabd8dad
Having created composite ordering methods for the different kinds of animations this patch adds a Comparator class so that they can be used to sort an array of such animations. This patch uses this Comparator object to sort the results returned by Element.getAnimations. For this case, the order in which we create animations and transitions happens to almost perfectly correspond with the composite ordering defined so that no sorting is necessary. One exception is that some -moz-* transitions may be created after transitions that they should sort before when sorting by transition property. In this case the sorting added in this patch should ensure they are returned in the correct sequence. Unfortunately, we can't easily test this since the test files we have are intended to be cross-browser (where -moz-* properties won't be supported). Once we implement AnimationTimeline.getAnimations (bug 1150810) we'll have a better opportunity to test this sorting. For now, the added tests in this patch just serve as a regression test that the sorting hasn't upset the already correct order (and an interop test in future once we move them to web-platform-tests). --HG-- extra : commitid : KkfoSE69B0F extra : rebase_source : ee4e47f44281504eb4d35e0f6cc3392ee0cffb94
33 lines
987 B
C++
33 lines
987 B
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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/. */
|
|
|
|
#ifndef mozilla_AnimationComparator_h
|
|
#define mozilla_AnimationComparator_h
|
|
|
|
namespace mozilla {
|
|
|
|
// Although this file is called AnimationComparator, we don't actually
|
|
// implement AnimationComparator (to compare const Animation& parameters)
|
|
// since it's not actually needed (yet).
|
|
|
|
template<typename AnimationPtrType>
|
|
class AnimationPtrComparator {
|
|
public:
|
|
bool Equals(const AnimationPtrType& a, const AnimationPtrType& b) const
|
|
{
|
|
return a == b;
|
|
}
|
|
|
|
bool LessThan(const AnimationPtrType& a, const AnimationPtrType& b) const
|
|
{
|
|
return a->HasLowerCompositeOrderThan(*b);
|
|
}
|
|
};
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_AnimationComparator_h
|