OLD | NEW |
---|---|
(Empty) | |
1 // 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.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef StylePropertyRange_h | |
6 #define StylePropertyRange_h | |
7 | |
8 #include "core/CSSPropertyNames.h" | |
9 | |
10 namespace blink { | |
11 | |
12 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.
| |
13 HighPriorityProperties, | |
14 LowPriorityProperties | |
15 }; | |
16 | |
17 class StylePropertyRange { | |
18 public: | |
19 template <StyleApplicationPass pass> | |
20 static inline CSSPropertyID firstCSSPropertyId(); | |
21 | |
22 template <StyleApplicationPass pass> | |
23 static inline CSSPropertyID lastCSSPropertyId(); | |
24 | |
25 template <StyleApplicationPass pass> | |
26 static inline bool isPropertyForPass(CSSPropertyID property) | |
27 { | |
28 return firstCSSPropertyId<pass>() <= property && property <= lastCSSProp ertyId<pass>(); | |
29 } | |
30 }; | |
31 | |
32 // 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.
| |
33 // Other properties can depend on high priority properties. For example, | |
34 // border-color property with currentColor value depends on color property. | |
35 // All high priority properties are obtained by using | |
36 // firstCSSPropertyId<HighPriorityProperties> and | |
37 // lastCSSPropertyId<HighPriorityProperties>. | |
38 template<> | |
39 inline CSSPropertyID StylePropertyRange::firstCSSPropertyId<HighPriorityProperti es>() | |
40 { | |
41 static_assert(CSSPropertyColor == firstCSSProperty, "CSSPropertyColor should be the first high priority property"); | |
42 return CSSPropertyColor; | |
43 } | |
44 | |
45 // This method returns the last CSSPropertyId of high priority properties. | |
46 template<> | |
47 inline CSSPropertyID StylePropertyRange::lastCSSPropertyId<HighPriorityPropertie s>() | |
48 { | |
49 static_assert(CSSPropertyZoom == CSSPropertyColor + 16, "CSSPropertyZoom sho uld be the end of the high priority property range"); | |
50 static_assert(CSSPropertyTextRendering == CSSPropertyZoom - 1, "CSSPropertyT extRendering should be immediately before CSSPropertyZoom"); | |
51 return CSSPropertyZoom; | |
52 } | |
53 | |
54 // This method returns the first CSSPropertyId of remaining properties, | |
55 // i.e. low priority properties. No properties depend on low priority | |
56 // properties. So we don't need to resolve such properties quickly. | |
57 // All low priority properties are obtained by using | |
58 // firstCSSPropertyId<LowPriorityProperties> and | |
59 // lastCSSPropertyId<LowPriorityProperties>. | |
60 template<> | |
61 inline CSSPropertyID StylePropertyRange::firstCSSPropertyId<LowPriorityPropertie s>() | |
62 { | |
63 static_assert(CSSPropertyAlignContent == CSSPropertyZoom + 1, "CSSPropertyAl ignContent should be the first low priority property"); | |
64 return CSSPropertyAlignContent; | |
65 } | |
66 | |
67 // This method returns the last CSSPropertyId of low priority properties. | |
68 template<> | |
69 inline CSSPropertyID StylePropertyRange::lastCSSPropertyId<LowPriorityProperties >() | |
70 { | |
71 return static_cast<CSSPropertyID>(lastCSSProperty); | |
72 } | |
73 | |
74 } // namespace blink | |
75 | |
76 #endif // StylePropertyRange_h | |
OLD | NEW |