OLD | NEW |
(Empty) | |
| 1 {% from "macros.tmpl" import wrap_with_condition, license -%} |
| 2 {{ license() }} |
| 3 |
| 4 #include "config.h" |
| 5 #include "core/css/resolver/StyleBuilder.h" |
| 6 |
| 7 #include "core/css/CSSPrimitiveValueMappings.h" |
| 8 #include "core/css/resolver/StyleResolver.h" |
| 9 |
| 10 // FIXME: currently we're just generating a switch statement, but we should |
| 11 // test other variations for performance once we have more properties here. |
| 12 |
| 13 namespace WebCore { |
| 14 |
| 15 class StyleBuilderImpl { |
| 16 public: |
| 17 |
| 18 {%- macro setValue(property) -%} |
| 19 styleResolver->style()->{{property.setter}} |
| 20 {%- endmacro %} |
| 21 |
| 22 {%- for property in properties %} |
| 23 {%- call wrap_with_condition(property.condition) %} |
| 24 {%- set propertyid = property.propertyid %} |
| 25 {%- set applytype = property.applytype %} |
| 26 |
| 27 static void applyInitial{{propertyid}}(StyleResolver* styleResolver) |
| 28 { |
| 29 {{ setValue(property) }}(RenderStyle::{{property.initial}}()); |
| 30 } |
| 31 |
| 32 static void applyInherit{{propertyid}}(StyleResolver* styleResolver) |
| 33 { |
| 34 {{ setValue(property) }}(styleResolver->parentStyle()->{{property.getter}}()
); |
| 35 } |
| 36 |
| 37 static void applyValue{{propertyid}}(StyleResolver* styleResolver, CSSValue* val
ue) |
| 38 { |
| 39 {{ setValue(property) }}(static_cast<{{property.typename}}>(*static_cast<CSS
PrimitiveValue*>(value))); |
| 40 } |
| 41 |
| 42 {%- endcall %} |
| 43 {%- endfor %} |
| 44 |
| 45 }; |
| 46 |
| 47 bool StyleBuilder::applyProperty(CSSPropertyID property, StyleResolver* styleRes
olver, CSSValue* value, bool isInitial, bool isInherit) { |
| 48 switch(property) { |
| 49 {%- for property in properties %} |
| 50 {%- call wrap_with_condition(property.condition) %} |
| 51 {%- set propertyid = property.propertyid %} |
| 52 case {{propertyid}}: |
| 53 if (isInitial) |
| 54 StyleBuilderImpl::applyInitial{{propertyid}}(styleResolver); |
| 55 else if (isInherit) |
| 56 StyleBuilderImpl::applyInherit{{propertyid}}(styleResolver); |
| 57 else |
| 58 StyleBuilderImpl::applyValue{{propertyid}}(styleResolver, value); |
| 59 return true; |
| 60 {%- endcall %} |
| 61 {% endfor %} |
| 62 default: |
| 63 return false; |
| 64 } |
| 65 } |
| 66 } |
| 67 |
OLD | NEW |