2017-10-27 17:33:53 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
2009-09-10 19:03:36 +00:00
|
|
|
|
|
|
|
/* Utilities for animation of computed style values */
|
|
|
|
|
2014-06-24 06:29:54 +00:00
|
|
|
#ifndef mozilla_StyleAnimationValue_h_
|
|
|
|
#define mozilla_StyleAnimationValue_h_
|
2009-09-10 19:03:36 +00:00
|
|
|
|
2015-12-02 23:52:00 +00:00
|
|
|
#include "mozilla/gfx/MatrixFwd.h"
|
2017-11-12 23:37:33 +00:00
|
|
|
#include "mozilla/gfx/Point.h"
|
2016-12-01 01:34:54 +00:00
|
|
|
#include "mozilla/ServoBindingTypes.h"
|
2016-03-30 03:39:59 +00:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2013-09-16 01:06:52 +00:00
|
|
|
#include "nsStringFwd.h"
|
2009-12-10 17:26:27 +00:00
|
|
|
#include "nsStringBuffer.h"
|
2009-10-20 11:46:16 +00:00
|
|
|
#include "nsCoord.h"
|
|
|
|
#include "nsColor.h"
|
2018-04-26 05:00:50 +00:00
|
|
|
#include "nsCSSPropertyID.h"
|
2012-07-31 17:28:21 +00:00
|
|
|
#include "nsCSSValue.h"
|
2016-10-31 23:30:43 +00:00
|
|
|
#include "nsStyleCoord.h"
|
2017-02-06 09:54:49 +00:00
|
|
|
#include "nsStyleTransformMatrix.h"
|
2009-09-10 19:03:36 +00:00
|
|
|
|
2015-07-20 02:30:40 +00:00
|
|
|
class nsIFrame;
|
2011-09-26 21:53:33 +00:00
|
|
|
class gfx3DMatrix;
|
2009-09-10 19:03:36 +00:00
|
|
|
|
2011-03-28 16:51:59 +00:00
|
|
|
namespace mozilla {
|
2014-06-24 06:29:54 +00:00
|
|
|
|
2018-03-22 18:20:41 +00:00
|
|
|
class ComputedStyle;
|
2017-07-21 01:22:00 +00:00
|
|
|
|
2015-10-22 08:22:38 +00:00
|
|
|
namespace css {
|
|
|
|
class StyleRule;
|
|
|
|
} // namespace css
|
|
|
|
|
2011-03-28 16:51:59 +00:00
|
|
|
namespace dom {
|
|
|
|
class Element;
|
|
|
|
} // namespace dom
|
|
|
|
|
2016-02-17 20:37:00 +00:00
|
|
|
enum class CSSPseudoElementType : uint8_t;
|
2015-10-22 08:22:38 +00:00
|
|
|
struct PropertyStyleAnimationValuePair;
|
|
|
|
|
2009-09-10 19:03:36 +00:00
|
|
|
|
2017-02-08 03:00:36 +00:00
|
|
|
struct AnimationValue
|
|
|
|
{
|
2017-04-26 04:00:11 +00:00
|
|
|
explicit AnimationValue(const RefPtr<RawServoAnimationValue>& aValue)
|
2018-04-13 13:01:28 +00:00
|
|
|
: mServo(aValue) { }
|
2017-04-26 04:00:11 +00:00
|
|
|
AnimationValue() = default;
|
|
|
|
|
2017-05-03 03:15:27 +00:00
|
|
|
AnimationValue(const AnimationValue& aOther)
|
2018-02-01 04:04:04 +00:00
|
|
|
: mServo(aOther.mServo) { }
|
2017-05-03 03:15:27 +00:00
|
|
|
AnimationValue(AnimationValue&& aOther)
|
2018-02-01 04:04:04 +00:00
|
|
|
: mServo(Move(aOther.mServo)) { }
|
2017-05-03 03:15:27 +00:00
|
|
|
|
|
|
|
AnimationValue& operator=(const AnimationValue& aOther)
|
|
|
|
{
|
|
|
|
if (this != &aOther) {
|
|
|
|
mServo = aOther.mServo;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
AnimationValue& operator=(AnimationValue&& aOther)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(this != &aOther, "Do not move itself");
|
|
|
|
if (this != &aOther) {
|
|
|
|
mServo = Move(aOther.mServo);
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
2017-02-04 05:57:08 +00:00
|
|
|
|
2017-03-31 09:46:37 +00:00
|
|
|
bool operator==(const AnimationValue& aOther) const;
|
2017-03-09 04:33:15 +00:00
|
|
|
bool operator!=(const AnimationValue& aOther) const;
|
2017-02-08 03:31:15 +00:00
|
|
|
|
2018-02-01 04:04:04 +00:00
|
|
|
bool IsNull() const
|
|
|
|
{
|
|
|
|
return !mServo;
|
|
|
|
}
|
2017-02-08 03:31:15 +00:00
|
|
|
|
2017-03-31 09:46:37 +00:00
|
|
|
float GetOpacity() const;
|
2017-02-06 08:32:21 +00:00
|
|
|
|
2017-09-25 06:25:43 +00:00
|
|
|
// Return the transform list as a RefPtr.
|
|
|
|
already_AddRefed<const nsCSSValueSharedList> GetTransformList() const;
|
|
|
|
|
2018-05-03 16:31:54 +00:00
|
|
|
// Return the scale for mServo, which is calculated with reference to aFrame.
|
2017-11-12 23:37:33 +00:00
|
|
|
mozilla::gfx::Size GetScaleValue(const nsIFrame* aFrame) const;
|
2017-02-09 03:33:17 +00:00
|
|
|
|
|
|
|
// Uncompute this AnimationValue and then serialize it.
|
2017-03-31 09:46:37 +00:00
|
|
|
void SerializeSpecifiedValue(nsCSSPropertyID aProperty,
|
|
|
|
nsAString& aString) const;
|
2017-04-12 08:26:59 +00:00
|
|
|
|
|
|
|
// Check if |*this| and |aToValue| can be interpolated.
|
|
|
|
bool IsInterpolableWith(nsCSSPropertyID aProperty,
|
|
|
|
const AnimationValue& aToValue) const;
|
2017-04-26 12:05:04 +00:00
|
|
|
|
|
|
|
// Compute the distance between *this and aOther.
|
2018-03-22 18:20:41 +00:00
|
|
|
// If |aComputedStyle| is nullptr, we will return 0.0 if we have mismatched
|
2017-04-26 12:05:04 +00:00
|
|
|
// transform lists.
|
|
|
|
double ComputeDistance(nsCSSPropertyID aProperty,
|
|
|
|
const AnimationValue& aOther,
|
2018-03-22 18:20:41 +00:00
|
|
|
ComputedStyle* aComputedStyle) const;
|
2017-05-03 03:15:27 +00:00
|
|
|
|
|
|
|
// Create an AnimaitonValue from a string. This method flushes style, so we
|
|
|
|
// should use this carefully. Now, it is only used by
|
|
|
|
// nsDOMWindowUtils::ComputeAnimationDistance.
|
|
|
|
static AnimationValue FromString(nsCSSPropertyID aProperty,
|
|
|
|
const nsAString& aValue,
|
|
|
|
dom::Element* aElement);
|
|
|
|
|
2017-10-27 19:04:52 +00:00
|
|
|
// Create an AnimationValue from an opacity value.
|
2018-03-28 15:34:34 +00:00
|
|
|
static AnimationValue Opacity(float aOpacity);
|
2017-10-27 19:06:30 +00:00
|
|
|
// Create an AnimationValue from a transform list.
|
2018-03-28 15:34:34 +00:00
|
|
|
static AnimationValue Transform(nsCSSValueSharedList& aList);
|
2017-10-27 19:04:52 +00:00
|
|
|
|
2017-10-17 05:11:19 +00:00
|
|
|
static already_AddRefed<nsCSSValue::Array>
|
|
|
|
AppendTransformFunction(nsCSSKeyword aTransformFunction,
|
|
|
|
nsCSSValueList**& aListTail);
|
|
|
|
|
2017-05-03 03:15:27 +00:00
|
|
|
RefPtr<RawServoAnimationValue> mServo;
|
2017-02-08 03:00:36 +00:00
|
|
|
};
|
|
|
|
|
2015-10-22 08:22:38 +00:00
|
|
|
struct PropertyStyleAnimationValuePair
|
|
|
|
{
|
2016-08-17 01:37:48 +00:00
|
|
|
nsCSSPropertyID mProperty;
|
2017-02-08 03:00:36 +00:00
|
|
|
AnimationValue mValue;
|
2015-10-22 08:22:38 +00:00
|
|
|
};
|
2014-06-24 06:29:54 +00:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2009-09-10 19:03:36 +00:00
|
|
|
#endif
|