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

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

Issue 892643002: Split property priority functions out of StyleResolver. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/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
« 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