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

Unified Diff: Source/core/css/resolver/CSSPropertyPriority.h

Issue 892643002: Split property priority functions out of StyleResolver. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use template class CSSPropertyPriority. Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/css/resolver/StyleResolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/CSSPropertyPriority.h
diff --git a/Source/core/css/resolver/CSSPropertyPriority.h b/Source/core/css/resolver/CSSPropertyPriority.h
new file mode 100644
index 0000000000000000000000000000000000000000..96fee8bdbb182e47266902ed6e86a08d82c5e0f1
--- /dev/null
+++ b/Source/core/css/resolver/CSSPropertyPriority.h
@@ -0,0 +1,62 @@
+// Copyright 2015 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 CSSPropertyPriority_h
+#define CSSPropertyPriority_h
+
+#include "core/CSSPropertyNames.h"
+
+namespace blink {
+
+// The values of high priority properties affect the values of low priority
+// properties. For example, the value of the high priority property 'font-size'
+// decides the pixel value of low priority properties with 'em' units.
+
+enum CSSPropertyPriority {
+ HighPropertyPriority,
+ LowPropertyPriority
+};
+
+template <CSSPropertyPriority priority>
+class CSSPropertyPriorityData {
+public:
+ static inline CSSPropertyID first();
+ static inline CSSPropertyID last();
+ static inline bool propertyHasPriority(CSSPropertyID prop)
+ {
+ return first() <= prop && prop <= last();
+ }
+};
+
+template<>
+inline CSSPropertyID CSSPropertyPriorityData<HighPropertyPriority>::first()
+{
+ static_assert(CSSPropertyColor == firstCSSProperty, "CSSPropertyColor should be the first high priority property");
+ return CSSPropertyColor;
+}
+
+template<>
+inline CSSPropertyID CSSPropertyPriorityData<HighPropertyPriority>::last()
+{
+ static_assert(CSSPropertyZoom == CSSPropertyColor + 16, "CSSPropertyZoom should be the end of the high priority property range");
+ static_assert(CSSPropertyTextRendering == CSSPropertyZoom - 1, "CSSPropertyTextRendering should be immediately before CSSPropertyZoom");
+ return CSSPropertyZoom;
+}
+
+template<>
+inline CSSPropertyID CSSPropertyPriorityData<LowPropertyPriority>::first()
+{
+ static_assert(CSSPropertyAlignContent == CSSPropertyZoom + 1, "CSSPropertyAlignContent should be the first low priority property");
+ return CSSPropertyAlignContent;
+}
+
+template<>
+inline CSSPropertyID CSSPropertyPriorityData<LowPropertyPriority>::last()
+{
+ return static_cast<CSSPropertyID>(lastCSSProperty);
+}
+
+} // namespace blink
+
+#endif // CSSPropertyPriority_h
« no previous file with comments | « no previous file | Source/core/css/resolver/StyleResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698