author Brian Birtles <>
Tue, 09 Jun 2015 11:13:54 +0900
changeset 251991 6a5491acd59ccdeaa0baf2ca3b4329dcf677f8dd
child 391978 5009b892ddb56abdbcaa325d46478bc1e2a60d20
permissions -rw-r--r--
Bug 1171817 part 14 - Add AnimationPtrComparator class; r=dbaron 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).

/* -*- 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 */

#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 {
  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