Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: Source/core/animation/UnderlyingValue.h

Issue 1322123003: Add composite() method to InterpolationType interface (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/animation/InvalidatableStyleInterpolation.cpp ('k') | Source/core/core.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UnderlyingValue_h
6 #define UnderlyingValue_h
7
8 #include "core/animation/InterpolationValue.h"
9 #include "wtf/Allocator.h"
10
11 namespace blink {
12
13 // Handles memory management of underlying InterpolationValues in applyStack()
14 // Ensures we perform copy on write if we are not the owner of an underlying Int erpolationValue.
15 // This functions similar to a DataRef except on OwnPtr'd objects.
16 class UnderlyingValue {
17 STACK_ALLOCATED();
18
19 public:
20 UnderlyingValue()
21 : m_valueOwner(nullptr)
22 , m_value(nullptr)
23 { }
24
25 void set(const InterpolationValue* interpolationValue)
26 {
27 // By clearing m_valueOwner we will perform a copy before attempting to mutate m_value,
28 // thus upholding the const contract for this instance of interpolationV alue despite the const_cast.
29 m_valueOwner.clear();
30 m_value = const_cast<InterpolationValue*>(interpolationValue);
31 }
32 void set(PassOwnPtr<InterpolationValue> interpolationValue)
33 {
34 m_valueOwner = interpolationValue;
35 m_value = m_valueOwner.get();
36 }
37 InterpolationComponentValue& mutableComponent()
38 {
39 ASSERT(m_value);
40 if (!m_valueOwner)
41 set(m_value->clone());
42 return m_value->mutableComponent();
43 }
44 const InterpolationValue* get() const { return m_value; }
45 operator bool() const { return m_value; }
46 const InterpolationValue* operator->() const
47 {
48 ASSERT(m_value);
49 return m_value;
50 }
51
52 private:
53 OwnPtr<InterpolationValue> m_valueOwner;
54 InterpolationValue* m_value;
55 };
56
57 } // namespace blink
58
59 #endif // UnderlyingValue_h
OLDNEW
« no previous file with comments | « Source/core/animation/InvalidatableStyleInterpolation.cpp ('k') | Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698