Index: third_party/WebKit/Source/core/css/StyleAutoColor.h |
diff --git a/third_party/WebKit/Source/core/css/StyleAutoColor.h b/third_party/WebKit/Source/core/css/StyleAutoColor.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a13bff8e3e36dd7658c7c7c1d0995a97350953c9 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/css/StyleAutoColor.h |
@@ -0,0 +1,55 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef StyleAutoColor_h |
+#define StyleAutoColor_h |
+ |
+#include "core/css/StyleColor.h" |
+ |
+namespace blink { |
+ |
+class StyleAutoColor : public StyleColor { |
Timothy Loh
2016/11/28 03:11:21
This is a weird use of inheritance because it brea
Manuel Rego
2016/11/28 10:47:55
Ok, yeah I had doubts about what to do. I'll creat
|
+ DISALLOW_NEW(); |
+ |
+ public: |
+ StyleAutoColor() : m_autoColor(true) { setCurrentColor(false); } |
+ StyleAutoColor(Color color) : StyleColor(color), m_autoColor(false) {} |
+ static StyleAutoColor autoColor() { return StyleAutoColor(); } |
+ static StyleAutoColor currentColor() { |
+ StyleAutoColor currentColor; |
+ currentColor.m_autoColor = false; |
+ currentColor.setCurrentColor(true); |
+ return currentColor; |
+ } |
+ |
+ bool isAutoColor() const { return m_autoColor; } |
+ Color getColor() const { |
+ DCHECK(!isAutoColor()); |
+ DCHECK(!isCurrentColor()); |
+ return color(); |
+ } |
+ |
+ Color resolve(Color currentColor) const { |
+ return isAutoColor() || isCurrentColor() ? currentColor : color(); |
+ } |
+ |
+ private: |
+ bool m_autoColor; |
+}; |
+ |
+inline bool operator==(const StyleAutoColor& a, const StyleAutoColor& b) { |
+ if (a.isAutoColor() || b.isAutoColor()) |
+ return a.isAutoColor() && b.isAutoColor(); |
+ if (a.isCurrentColor() || b.isCurrentColor()) |
+ return a.isCurrentColor() && b.isCurrentColor(); |
+ return a.getColor() == b.getColor(); |
+} |
+ |
+inline bool operator!=(const StyleAutoColor& a, const StyleAutoColor& b) { |
+ return !(a == b); |
+} |
+ |
+} // namespace blink |
+ |
+#endif // StyleAutoColor_h |