Bug 1700051: part 35) Reduce accessibility of `mSoftText.mDOMMapping` to `private...
[gecko.git] / layout / style / StyleAnimationValue.h
blob330ab86a0bbcedead48e87499343ef3e7b29fa96
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* Utilities for animation of computed style values */
9 #ifndef mozilla_StyleAnimationValue_h_
10 #define mozilla_StyleAnimationValue_h_
12 #include "mozilla/gfx/MatrixFwd.h"
13 #include "mozilla/gfx/Point.h"
14 #include "mozilla/RefPtr.h"
15 #include "mozilla/ServoBindingTypes.h"
16 #include "mozilla/ServoStyleConsts.h" // Servo_AnimationValue_Dump
17 #include "mozilla/DbgMacro.h"
18 #include "nsStringFwd.h"
19 #include "nsStringBuffer.h"
20 #include "nsCoord.h"
21 #include "nsColor.h"
22 #include "nsCSSPropertyID.h"
23 #include "nsCSSValue.h"
24 #include "nsStyleConsts.h"
25 #include "nsStyleTransformMatrix.h"
27 class nsIFrame;
28 class gfx3DMatrix;
30 namespace mozilla {
32 namespace css {
33 class StyleRule;
34 } // namespace css
36 namespace dom {
37 class Element;
38 } // namespace dom
40 namespace layers {
41 class Animatable;
42 } // namespace layers
44 enum class PseudoStyleType : uint8_t;
45 struct PropertyStyleAnimationValuePair;
47 struct AnimationValue {
48 explicit AnimationValue(const RefPtr<RawServoAnimationValue>& aValue)
49 : mServo(aValue) {}
50 AnimationValue() = default;
52 AnimationValue(const AnimationValue& aOther) = default;
53 AnimationValue(AnimationValue&& aOther) = default;
55 AnimationValue& operator=(const AnimationValue& aOther) = default;
56 AnimationValue& operator=(AnimationValue&& aOther) = default;
58 bool operator==(const AnimationValue& aOther) const;
59 bool operator!=(const AnimationValue& aOther) const;
61 bool IsNull() const { return !mServo; }
63 float GetOpacity() const;
65 // Returns nscolor value in this AnimationValue.
66 // Currently only background-color is supported.
67 nscolor GetColor(nscolor aForegroundColor) const;
69 // Returns true if this AnimationValue is current-color.
70 // Currently only background-color is supported.
71 bool IsCurrentColor() const;
73 // Return a transform list for the transform property.
74 const mozilla::StyleTransform& GetTransformProperty() const;
75 const mozilla::StyleScale& GetScaleProperty() const;
76 const mozilla::StyleTranslate& GetTranslateProperty() const;
77 const mozilla::StyleRotate& GetRotateProperty() const;
79 // Motion path properties.
80 const mozilla::StyleOffsetPath& GetOffsetPathProperty() const;
81 const mozilla::LengthPercentage& GetOffsetDistanceProperty() const;
82 const mozilla::StyleOffsetRotate& GetOffsetRotateProperty() const;
83 const mozilla::StylePositionOrAuto& GetOffsetAnchorProperty() const;
85 // Return the scale for mServo, which is calculated with reference to aFrame.
86 mozilla::gfx::Size GetScaleValue(const nsIFrame* aFrame) const;
88 // Uncompute this AnimationValue and then serialize it.
89 void SerializeSpecifiedValue(nsCSSPropertyID aProperty,
90 const RawServoStyleSet* aRawSet,
91 nsACString& aString) const;
93 // Check if |*this| and |aToValue| can be interpolated.
94 bool IsInterpolableWith(nsCSSPropertyID aProperty,
95 const AnimationValue& aToValue) const;
97 // Compute the distance between *this and aOther.
98 double ComputeDistance(nsCSSPropertyID aProperty,
99 const AnimationValue& aOther) const;
101 // Create an AnimaitonValue from a string. This method flushes style, so we
102 // should use this carefully. Now, it is only used by
103 // nsDOMWindowUtils::ComputeAnimationDistance.
104 static AnimationValue FromString(nsCSSPropertyID aProperty,
105 const nsACString& aValue,
106 dom::Element* aElement);
108 // Create an already_AddRefed<RawServoAnimationValue> from a
109 // layers::Animatable. Basically, this function should return AnimationValue,
110 // but it seems the caller, AnimationHelper, only needs
111 // RawServoAnimationValue, so we return its already_AddRefed<> to avoid
112 // adding/removing a redundant ref-count.
113 static already_AddRefed<RawServoAnimationValue> FromAnimatable(
114 nsCSSPropertyID aProperty, const layers::Animatable& aAnimatable);
116 RefPtr<RawServoAnimationValue> mServo;
119 inline std::ostream& operator<<(std::ostream& aOut,
120 const AnimationValue& aValue) {
121 MOZ_ASSERT(aValue.mServo);
122 nsAutoCString s;
123 Servo_AnimationValue_Dump(aValue.mServo, &s);
124 return aOut << s;
127 struct PropertyStyleAnimationValuePair {
128 nsCSSPropertyID mProperty;
129 AnimationValue mValue;
131 } // namespace mozilla
133 #endif