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 ColorPropertyFunctions_h | 5 #ifndef ColorPropertyFunctions_h |
6 #define ColorPropertyFunctions_h | 6 #define ColorPropertyFunctions_h |
7 | 7 |
8 #include "core/CSSPropertyNames.h" | 8 #include "core/CSSPropertyNames.h" |
9 #include "core/css/StyleColor.h" | 9 #include "core/css/StyleColor.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 class ComputedStyle; | 13 class ComputedStyle; |
14 | 14 |
| 15 struct OptionalStyleColor { |
| 16 public: |
| 17 OptionalStyleColor(std::nullptr_t) : m_isNull(true) {} |
| 18 OptionalStyleColor(const StyleColor& styleColor) |
| 19 : m_isNull(false), m_styleColor(styleColor) {} |
| 20 OptionalStyleColor(const Color& color) |
| 21 : m_isNull(false), m_styleColor(color) {} |
| 22 |
| 23 bool isNull() const { return m_isNull; } |
| 24 const StyleColor& access() const { |
| 25 DCHECK(!m_isNull); |
| 26 return m_styleColor; |
| 27 } |
| 28 bool operator==(const OptionalStyleColor& other) const { |
| 29 return m_isNull == other.m_isNull && m_styleColor == other.m_styleColor; |
| 30 } |
| 31 |
| 32 private: |
| 33 bool m_isNull; |
| 34 StyleColor m_styleColor; |
| 35 }; |
| 36 |
15 class ColorPropertyFunctions { | 37 class ColorPropertyFunctions { |
16 public: | 38 public: |
17 static bool getInitialColor(CSSPropertyID, StyleColor& initialColor); | 39 static OptionalStyleColor getInitialColor(CSSPropertyID); |
18 static StyleColor getUnvisitedColor(CSSPropertyID, const ComputedStyle&); | 40 static OptionalStyleColor getUnvisitedColor(CSSPropertyID, |
19 static StyleColor getVisitedColor(CSSPropertyID, const ComputedStyle&); | 41 const ComputedStyle&); |
| 42 static OptionalStyleColor getVisitedColor(CSSPropertyID, |
| 43 const ComputedStyle&); |
20 static void setUnvisitedColor(CSSPropertyID, ComputedStyle&, const Color&); | 44 static void setUnvisitedColor(CSSPropertyID, ComputedStyle&, const Color&); |
21 static void setVisitedColor(CSSPropertyID, ComputedStyle&, const Color&); | 45 static void setVisitedColor(CSSPropertyID, ComputedStyle&, const Color&); |
22 }; | 46 }; |
23 | 47 |
24 } // namespace blink | 48 } // namespace blink |
25 | 49 |
26 #endif // ColorPropertyFunctions_h | 50 #endif // ColorPropertyFunctions_h |
OLD | NEW |