OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 29 matching lines...) Expand all Loading... |
40 class StyleColor { | 40 class StyleColor { |
41 DISALLOW_NEW(); | 41 DISALLOW_NEW(); |
42 | 42 |
43 public: | 43 public: |
44 StyleColor() : m_currentColor(true) {} | 44 StyleColor() : m_currentColor(true) {} |
45 StyleColor(Color color) : m_color(color), m_currentColor(false) {} | 45 StyleColor(Color color) : m_color(color), m_currentColor(false) {} |
46 static StyleColor currentColor() { return StyleColor(); } | 46 static StyleColor currentColor() { return StyleColor(); } |
47 | 47 |
48 bool isCurrentColor() const { return m_currentColor; } | 48 bool isCurrentColor() const { return m_currentColor; } |
49 Color getColor() const { | 49 Color getColor() const { |
50 ASSERT(!isCurrentColor()); | 50 DCHECK(!isCurrentColor()); |
51 return m_color; | 51 return m_color; |
52 } | 52 } |
53 | 53 |
54 Color resolve(Color currentColor) const { | 54 Color resolve(Color currentColor) const { |
55 return m_currentColor ? currentColor : m_color; | 55 return m_currentColor ? currentColor : m_color; |
56 } | 56 } |
57 | 57 |
58 static Color colorFromKeyword(CSSValueID); | 58 static Color colorFromKeyword(CSSValueID); |
59 static bool isColorKeyword(CSSValueID); | 59 static bool isColorKeyword(CSSValueID); |
60 static bool isSystemColor(CSSValueID); | 60 static bool isSystemColor(CSSValueID); |
61 | 61 |
62 private: | 62 private: |
63 Color m_color; | 63 Color m_color; |
64 bool m_currentColor; | 64 bool m_currentColor; |
65 }; | 65 }; |
66 | 66 |
67 inline bool operator==(const StyleColor& a, const StyleColor& b) { | 67 inline bool operator==(const StyleColor& a, const StyleColor& b) { |
68 if (a.isCurrentColor() || b.isCurrentColor()) | 68 if (a.isCurrentColor() || b.isCurrentColor()) |
69 return a.isCurrentColor() && b.isCurrentColor(); | 69 return a.isCurrentColor() && b.isCurrentColor(); |
70 return a.getColor() == b.getColor(); | 70 return a.getColor() == b.getColor(); |
71 } | 71 } |
72 | 72 |
73 inline bool operator!=(const StyleColor& a, const StyleColor& b) { | 73 inline bool operator!=(const StyleColor& a, const StyleColor& b) { |
74 return !(a == b); | 74 return !(a == b); |
75 } | 75 } |
76 | 76 |
77 } // namespace blink | 77 } // namespace blink |
78 | 78 |
79 #endif // StyleColor_h | 79 #endif // StyleColor_h |
OLD | NEW |