OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef InterpolationEnvironment_h | 5 #ifndef InterpolationEnvironment_h |
6 #define InterpolationEnvironment_h | 6 #define InterpolationEnvironment_h |
7 | 7 |
8 #include "core/animation/InterpolationTypesMap.h" | 8 #include "core/animation/InterpolationTypesMap.h" |
9 #include "core/css/resolver/StyleResolverState.h" | |
10 #include "platform/heap/Handle.h" | |
11 #include "platform/wtf/Allocator.h" | 9 #include "platform/wtf/Allocator.h" |
12 | 10 |
13 namespace blink { | 11 namespace blink { |
14 | 12 |
15 class ComputedStyle; | |
16 class SVGPropertyBase; | |
17 class SVGElement; | |
18 | |
19 class InterpolationEnvironment { | 13 class InterpolationEnvironment { |
20 STACK_ALLOCATED(); | 14 STACK_ALLOCATED(); |
21 | |
22 public: | 15 public: |
23 explicit InterpolationEnvironment(const InterpolationTypesMap& map, | 16 virtual bool IsCSS() const { return false; } |
24 StyleResolverState& state) | 17 virtual bool IsSVG() const { return false; } |
25 : interpolation_types_map_(map), state_(&state), style_(state.Style()) {} | |
26 | |
27 explicit InterpolationEnvironment(const InterpolationTypesMap& map, | |
28 const ComputedStyle& style) | |
29 : interpolation_types_map_(map), style_(&style) {} | |
30 | |
31 explicit InterpolationEnvironment(const InterpolationTypesMap& map, | |
32 SVGElement& svg_element, | |
33 const SVGPropertyBase& svg_base_value) | |
34 : interpolation_types_map_(map), | |
35 svg_element_(&svg_element), | |
36 svg_base_value_(&svg_base_value) {} | |
37 | 18 |
38 const InterpolationTypesMap& GetInterpolationTypesMap() const { | 19 const InterpolationTypesMap& GetInterpolationTypesMap() const { |
39 return interpolation_types_map_; | 20 return interpolation_types_map_; |
40 } | 21 } |
41 | 22 |
42 StyleResolverState& GetState() { | 23 protected: |
43 DCHECK(state_); | 24 virtual ~InterpolationEnvironment() {} |
44 return *state_; | |
45 } | |
46 const StyleResolverState& GetState() const { | |
47 DCHECK(state_); | |
48 return *state_; | |
49 } | |
50 | 25 |
51 const ComputedStyle& Style() const { | 26 explicit InterpolationEnvironment(const InterpolationTypesMap& map) |
52 DCHECK(style_); | 27 : interpolation_types_map_(map) {} |
53 return *style_; | |
54 } | |
55 | |
56 SVGElement& SvgElement() { | |
57 DCHECK(svg_element_); | |
58 return *svg_element_; | |
59 } | |
60 const SVGElement& SvgElement() const { | |
61 DCHECK(svg_element_); | |
62 return *svg_element_; | |
63 } | |
64 | |
65 const SVGPropertyBase& SvgBaseValue() const { | |
66 DCHECK(svg_base_value_); | |
67 return *svg_base_value_; | |
68 } | |
69 | 28 |
70 private: | 29 private: |
71 const InterpolationTypesMap& interpolation_types_map_; | 30 const InterpolationTypesMap& interpolation_types_map_; |
72 | |
73 // CSSInterpolationType environment | |
74 StyleResolverState* state_ = nullptr; | |
75 const ComputedStyle* style_ = nullptr; | |
76 | |
77 // SVGInterpolationType environment | |
78 Member<SVGElement> svg_element_ = nullptr; | |
79 Member<const SVGPropertyBase> svg_base_value_ = nullptr; | |
80 }; | 31 }; |
81 | 32 |
82 } // namespace blink | 33 } // namespace blink |
83 | 34 |
84 #endif // InterpolationEnvironment_h | 35 #endif // InterpolationEnvironment_h |
OLD | NEW |