Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/StyleAnimationValue.h
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
/* Utilities for animation of computed style values */
8
9
#ifndef mozilla_StyleAnimationValue_h_
10
#define mozilla_StyleAnimationValue_h_
11
12
#include "mozilla/gfx/MatrixFwd.h"
13
#include "mozilla/gfx/Point.h"
14
#include "mozilla/ServoBindingTypes.h"
15
#include "mozilla/UniquePtr.h"
16
#include "nsStringFwd.h"
17
#include "nsStringBuffer.h"
18
#include "nsCoord.h"
19
#include "nsColor.h"
20
#include "nsCSSPropertyID.h"
21
#include "nsCSSValue.h"
22
#include "nsStyleCoord.h"
23
#include "nsStyleTransformMatrix.h"
24
25
class nsIFrame;
26
class gfx3DMatrix;
27
28
namespace mozilla {
29
30
class ComputedStyle;
31
32
namespace css {
33
class StyleRule;
34
} // namespace css
35
36
namespace dom {
37
class Element;
38
} // namespace dom
39
40
enum class CSSPseudoElementType : uint8_t;
41
struct PropertyStyleAnimationValuePair;
42
43
44
struct AnimationValue
45
{
46
  explicit AnimationValue(const RefPtr<RawServoAnimationValue>& aValue)
47
0
    : mServo(aValue) { }
48
0
  AnimationValue() = default;
49
50
  AnimationValue(const AnimationValue& aOther)
51
0
    : mServo(aOther.mServo) { }
52
  AnimationValue(AnimationValue&& aOther)
53
0
    : mServo(std::move(aOther.mServo)) { }
54
55
  AnimationValue& operator=(const AnimationValue& aOther)
56
0
  {
57
0
    if (this != &aOther) {
58
0
      mServo = aOther.mServo;
59
0
    }
60
0
    return *this;
61
0
  }
62
  AnimationValue& operator=(AnimationValue&& aOther)
63
0
  {
64
0
    MOZ_ASSERT(this != &aOther, "Do not move itself");
65
0
    if (this != &aOther) {
66
0
      mServo = std::move(aOther.mServo);
67
0
    }
68
0
    return *this;
69
0
  }
70
71
  bool operator==(const AnimationValue& aOther) const;
72
  bool operator!=(const AnimationValue& aOther) const;
73
74
  bool IsNull() const
75
0
  {
76
0
    return !mServo;
77
0
  }
78
79
  float GetOpacity() const;
80
81
  // Return the transform list as a RefPtr.
82
  already_AddRefed<const nsCSSValueSharedList> GetTransformList() const;
83
84
  // Return the scale for mServo, which is calculated with reference to aFrame.
85
  mozilla::gfx::Size GetScaleValue(const nsIFrame* aFrame) const;
86
87
  // Uncompute this AnimationValue and then serialize it.
88
  void SerializeSpecifiedValue(nsCSSPropertyID aProperty,
89
                               nsAString& aString) const;
90
91
  // Check if |*this| and |aToValue| can be interpolated.
92
  bool IsInterpolableWith(nsCSSPropertyID aProperty,
93
                          const AnimationValue& aToValue) const;
94
95
  // Compute the distance between *this and aOther.
96
  // If |aComputedStyle| is nullptr, we will return 0.0 if we have mismatched
97
  // transform lists.
98
  double ComputeDistance(nsCSSPropertyID aProperty,
99
                         const AnimationValue& aOther,
100
                         ComputedStyle* aComputedStyle) const;
101
102
  // Create an AnimaitonValue from a string. This method flushes style, so we
103
  // should use this carefully. Now, it is only used by
104
  // nsDOMWindowUtils::ComputeAnimationDistance.
105
  static AnimationValue FromString(nsCSSPropertyID aProperty,
106
                                   const nsAString& aValue,
107
                                   dom::Element* aElement);
108
109
  // Create an AnimationValue from an opacity value.
110
  static AnimationValue Opacity(float aOpacity);
111
  // Create an AnimationValue from a transform list.
112
  static AnimationValue Transform(nsCSSValueSharedList& aList);
113
114
  static already_AddRefed<nsCSSValue::Array>
115
  AppendTransformFunction(nsCSSKeyword aTransformFunction,
116
                          nsCSSValueList**& aListTail);
117
118
  RefPtr<RawServoAnimationValue> mServo;
119
};
120
121
struct PropertyStyleAnimationValuePair
122
{
123
  nsCSSPropertyID mProperty;
124
  AnimationValue mValue;
125
};
126
} // namespace mozilla
127
128
#endif