dom/animation/AnimationUtils.h
author George Wright <george@mozilla.com>
Fri, 08 Apr 2016 13:33:27 -0400
changeset 317655 8d87452bfc44bf502e2a1a172db91f88e5284782
parent 313714 4ef42bdeeabb29139d828ef93af56a0a5ffa8c08
child 318527 87509ba26631087a731881e42f9ce8cc269e470f
permissions -rw-r--r--
Revert "Bug 1261416 - Rename firefox-plugin-container back to plugin-container to satisfy Flash's protected mode checks, and ensure that we launch the correct binary r=ted" because of widespread breakage due to whitelisted executable names in third parties This reverts commit 2d44e8ffaf63a32292f8e5b8fdd1485d0a462afc.

/* -*- 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_dom_AnimationUtils_h
#define mozilla_dom_AnimationUtils_h

#include "mozilla/TimeStamp.h"
#include "mozilla/dom/Nullable.h"
#include "nsStringFwd.h"

class nsIContent;
class nsIDocument;
struct JSContext;

namespace mozilla {

class ComputedTimingFunction;

class AnimationUtils
{
public:
  static dom::Nullable<double>
  TimeDurationToDouble(const dom::Nullable<TimeDuration>& aTime)
  {
    dom::Nullable<double> result;

    if (!aTime.IsNull()) {
      result.SetValue(aTime.Value().ToMilliseconds());
    }

    return result;
  }

  static dom::Nullable<TimeDuration>
  DoubleToTimeDuration(const dom::Nullable<double>& aTime)
  {
    dom::Nullable<TimeDuration> result;

    if (!aTime.IsNull()) {
      result.SetValue(TimeDuration::FromMilliseconds(aTime.Value()));
    }

    return result;
  }

  static void LogAsyncAnimationFailure(nsCString& aMessage,
                                       const nsIContent* aContent = nullptr);

  /**
   * Parses a CSS <single-transition-timing-function> value from
   * aEasing into a ComputedTimingFunction.  If parsing fails, Nothing() will
   * be returned.
   */
  static Maybe<ComputedTimingFunction>
  ParseEasing(const nsAString& aEasing, nsIDocument* aDocument);

  /**
   * Get the document from the JS context to use when parsing CSS properties.
   */
  static nsIDocument*
  GetCurrentRealmDocument(JSContext* aCx);
};

} // namespace mozilla

#endif