Index: Source/core/css/resolver/StylePropertyRange.h |
diff --git a/Source/core/css/resolver/StylePropertyRange.h b/Source/core/css/resolver/StylePropertyRange.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c8946ff183f46d04d1418174a78d27df3e117c36 |
--- /dev/null |
+++ b/Source/core/css/resolver/StylePropertyRange.h |
@@ -0,0 +1,76 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
Timothy Loh
2015/02/01 22:17:09
2015 ;)
andersr
2015/02/02 15:51:24
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef StylePropertyRange_h |
+#define StylePropertyRange_h |
+ |
+#include "core/CSSPropertyNames.h" |
+ |
+namespace blink { |
+ |
+enum StyleApplicationPass { |
Timothy Loh
2015/02/01 22:17:09
Nit-picking about names since we're already touchi
andersr
2015/02/02 15:51:24
Done.
|
+ HighPriorityProperties, |
+ LowPriorityProperties |
+}; |
+ |
+class StylePropertyRange { |
+public: |
+ template <StyleApplicationPass pass> |
+ static inline CSSPropertyID firstCSSPropertyId(); |
+ |
+ template <StyleApplicationPass pass> |
+ static inline CSSPropertyID lastCSSPropertyId(); |
+ |
+ template <StyleApplicationPass pass> |
+ static inline bool isPropertyForPass(CSSPropertyID property) |
+ { |
+ return firstCSSPropertyId<pass>() <= property && property <= lastCSSPropertyId<pass>(); |
+ } |
+}; |
+ |
+// This method returns the first CSSPropertyId of high priority properties. |
Timothy Loh
2015/02/01 22:17:09
I'd describe property priority above the enum up t
andersr
2015/02/02 15:51:24
Done.
|
+// Other properties can depend on high priority properties. For example, |
+// border-color property with currentColor value depends on color property. |
+// All high priority properties are obtained by using |
+// firstCSSPropertyId<HighPriorityProperties> and |
+// lastCSSPropertyId<HighPriorityProperties>. |
+template<> |
+inline CSSPropertyID StylePropertyRange::firstCSSPropertyId<HighPriorityProperties>() |
+{ |
+ static_assert(CSSPropertyColor == firstCSSProperty, "CSSPropertyColor should be the first high priority property"); |
+ return CSSPropertyColor; |
+} |
+ |
+// This method returns the last CSSPropertyId of high priority properties. |
+template<> |
+inline CSSPropertyID StylePropertyRange::lastCSSPropertyId<HighPriorityProperties>() |
+{ |
+ 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; |
+} |
+ |
+// This method returns the first CSSPropertyId of remaining properties, |
+// i.e. low priority properties. No properties depend on low priority |
+// properties. So we don't need to resolve such properties quickly. |
+// All low priority properties are obtained by using |
+// firstCSSPropertyId<LowPriorityProperties> and |
+// lastCSSPropertyId<LowPriorityProperties>. |
+template<> |
+inline CSSPropertyID StylePropertyRange::firstCSSPropertyId<LowPriorityProperties>() |
+{ |
+ static_assert(CSSPropertyAlignContent == CSSPropertyZoom + 1, "CSSPropertyAlignContent should be the first low priority property"); |
+ return CSSPropertyAlignContent; |
+} |
+ |
+// This method returns the last CSSPropertyId of low priority properties. |
+template<> |
+inline CSSPropertyID StylePropertyRange::lastCSSPropertyId<LowPriorityProperties>() |
+{ |
+ return static_cast<CSSPropertyID>(lastCSSProperty); |
+} |
+ |
+} // namespace blink |
+ |
+#endif // StylePropertyRange_h |