OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CSSPropertyPriority_h |
| 6 #define CSSPropertyPriority_h |
| 7 |
| 8 #include "core/CSSPropertyNames.h" |
| 9 |
| 10 namespace blink { |
| 11 |
| 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' |
| 14 // decides the pixel value of low priority properties with 'em' units. |
| 15 |
| 16 enum CSSPropertyPriority { |
| 17 HighPropertyPriority, |
| 18 LowPropertyPriority |
| 19 }; |
| 20 |
| 21 template <CSSPropertyPriority priority> |
| 22 class CSSPropertyPriorityData { |
| 23 public: |
| 24 static inline CSSPropertyID first(); |
| 25 static inline CSSPropertyID last(); |
| 26 static inline bool propertyHasPriority(CSSPropertyID prop) |
| 27 { |
| 28 return first() <= prop && prop <= last(); |
| 29 } |
| 30 }; |
| 31 |
| 32 template<> |
| 33 inline CSSPropertyID CSSPropertyPriorityData<HighPropertyPriority>::first() |
| 34 { |
| 35 static_assert(CSSPropertyColor == firstCSSProperty, "CSSPropertyColor should
be the first high priority property"); |
| 36 return CSSPropertyColor; |
| 37 } |
| 38 |
| 39 template<> |
| 40 inline CSSPropertyID CSSPropertyPriorityData<HighPropertyPriority>::last() |
| 41 { |
| 42 static_assert(CSSPropertyZoom == CSSPropertyColor + 16, "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"); |
| 44 return CSSPropertyZoom; |
| 45 } |
| 46 |
| 47 template<> |
| 48 inline CSSPropertyID CSSPropertyPriorityData<LowPropertyPriority>::first() |
| 49 { |
| 50 static_assert(CSSPropertyAlignContent == CSSPropertyZoom + 1, "CSSPropertyAl
ignContent should be the first low priority property"); |
| 51 return CSSPropertyAlignContent; |
| 52 } |
| 53 |
| 54 template<> |
| 55 inline CSSPropertyID CSSPropertyPriorityData<LowPropertyPriority>::last() |
| 56 { |
| 57 return static_cast<CSSPropertyID>(lastCSSProperty); |
| 58 } |
| 59 |
| 60 } // namespace blink |
| 61 |
| 62 #endif // CSSPropertyPriority_h |
OLD | NEW |