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

Unified Diff: third_party/WebKit/Source/core/css/StyleAutoColor.h

Issue 2520873002: [css-ui] Add support for caret-color property (Closed)
Patch Set: Add new baselines for Mac and Windows Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698