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

Side by Side Diff: Source/core/css/resolver/CSSPropertyPriority.h

Issue 1192983003: CSS Custom Properties (Variables) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ToTed Created 5 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CSSPropertyPriority_h 5 #ifndef CSSPropertyPriority_h
6 #define CSSPropertyPriority_h 6 #define CSSPropertyPriority_h
7 7
8 #include "core/CSSPropertyNames.h" 8 #include "core/CSSPropertyNames.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 // The values of high priority properties affect the values of low priority 12 // The values of high priority properties affect the values of low priority
13 // properties. For example, the value of the high priority property 'font-size' 13 // properties. For example, the value of the high priority property 'font-size'
14 // decides the pixel value of low priority properties with 'em' units. 14 // decides the pixel value of low priority properties with 'em' units.
15 15
16 enum CSSPropertyPriority { 16 enum CSSPropertyPriority {
17 ResolveVariables,
17 HighPropertyPriority, 18 HighPropertyPriority,
18 LowPropertyPriority 19 LowPropertyPriority
19 }; 20 };
20 21
21 template <CSSPropertyPriority priority> 22 template <CSSPropertyPriority priority>
22 class CSSPropertyPriorityData { 23 class CSSPropertyPriorityData {
23 public: 24 public:
24 static inline CSSPropertyID first(); 25 static inline CSSPropertyID first();
25 static inline CSSPropertyID last(); 26 static inline CSSPropertyID last();
26 static inline bool propertyHasPriority(CSSPropertyID prop) 27 static inline bool propertyHasPriority(CSSPropertyID prop)
27 { 28 {
28 return first() <= prop && prop <= last(); 29 return first() <= prop && prop <= last();
29 } 30 }
30 }; 31 };
31 32
32 template<> 33 template<>
34 inline CSSPropertyID CSSPropertyPriorityData<ResolveVariables>::first()
35 {
36 static_assert(CSSPropertyVariable == lastCSSProperty, "CSSPropertyVariable s hould be the last property.");
37 return CSSPropertyVariable;
38 }
39
40 template<>
41 inline CSSPropertyID CSSPropertyPriorityData<ResolveVariables>::last()
42 {
43 return CSSPropertyVariable;
44 }
45
46 template<>
33 inline CSSPropertyID CSSPropertyPriorityData<HighPropertyPriority>::first() 47 inline CSSPropertyID CSSPropertyPriorityData<HighPropertyPriority>::first()
34 { 48 {
35 static_assert(CSSPropertyColor == firstCSSProperty, "CSSPropertyColor should be the first high priority property"); 49 static_assert(CSSPropertyColor == firstCSSProperty, "CSSPropertyColor should be the first high priority property");
36 return CSSPropertyColor; 50 return CSSPropertyColor;
37 } 51 }
38 52
39 template<> 53 template<>
40 inline CSSPropertyID CSSPropertyPriorityData<HighPropertyPriority>::last() 54 inline CSSPropertyID CSSPropertyPriorityData<HighPropertyPriority>::last()
41 { 55 {
42 static_assert(CSSPropertyZoom == CSSPropertyColor + 17, "CSSPropertyZoom sho uld be the end of the high priority property range"); 56 static_assert(CSSPropertyZoom == CSSPropertyColor + 17, "CSSPropertyZoom sho uld be the end of the high priority property range");
43 static_assert(CSSPropertyTextRendering == CSSPropertyZoom - 1, "CSSPropertyT extRendering should be immediately before CSSPropertyZoom"); 57 static_assert(CSSPropertyTextRendering == CSSPropertyZoom - 1, "CSSPropertyT extRendering should be immediately before CSSPropertyZoom");
44 return CSSPropertyZoom; 58 return CSSPropertyZoom;
45 } 59 }
46 60
47 template<> 61 template<>
48 inline CSSPropertyID CSSPropertyPriorityData<LowPropertyPriority>::first() 62 inline CSSPropertyID CSSPropertyPriorityData<LowPropertyPriority>::first()
49 { 63 {
50 static_assert(CSSPropertyAlignContent == CSSPropertyZoom + 1, "CSSPropertyAl ignContent should be the first low priority property"); 64 static_assert(CSSPropertyAlignContent == CSSPropertyZoom + 1, "CSSPropertyAl ignContent should be the first low priority property");
51 return CSSPropertyAlignContent; 65 return CSSPropertyAlignContent;
52 } 66 }
53 67
54 template<> 68 template<>
55 inline CSSPropertyID CSSPropertyPriorityData<LowPropertyPriority>::last() 69 inline CSSPropertyID CSSPropertyPriorityData<LowPropertyPriority>::last()
56 { 70 {
57 return static_cast<CSSPropertyID>(lastCSSProperty); 71 static_assert(lastCSSProperty - 1 < CSSPropertyVariable, "CSSPropertyVariabl e shouldn't be included in low priority properties.");
72 return static_cast<CSSPropertyID>(lastCSSProperty - 1);
58 } 73 }
59 74
60 } // namespace blink 75 } // namespace blink
61 76
62 #endif // CSSPropertyPriority_h 77 #endif // CSSPropertyPriority_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698