| 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 "StyleBuilderFunctions.h" | |
| 8 #include "core/css/CSSPrimitiveValueMappings.h" | |
| 9 #include "core/css/resolver/StyleResolverState.h" | |
| 10 | |
| 11 // FIXME: currently we're just generating a switch statement, but we should | |
| 12 // test other variations for performance once we have more properties here. | |
| 13 | |
| 14 {%- macro set_value(property) %} | |
| 15 {%- if property.svg -%} | |
| 16 state.style()->accessSVGStyle()->{{property.setter}} | |
| 17 {%- else -%} | |
| 18 state.style()->{{property.setter}} | |
| 19 {%- endif %} | |
| 20 {%- endmacro %} | |
| 21 | |
| 22 namespace WebCore { | |
| 23 | |
| 24 {%- macro apply_value_length(property) -%} | |
| 25 if (!value->isPrimitiveValue()) | |
| 26 return; | |
| 27 | |
| 28 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
| 29 Length length; | |
| 30 switch(primitiveValue->getValueID()) { | |
| 31 | |
| 32 {%- if property.use_none %} | |
| 33 case CSSValueNone: | |
| 34 length = Length(Undefined); | |
| 35 break; | |
| 36 {%- endif %} | |
| 37 | |
| 38 {%- if property.use_intrinsic %} | |
| 39 case CSSValueIntrinsic: | |
| 40 length = Length(Intrinsic); | |
| 41 break; | |
| 42 case CSSValueMinIntrinsic: | |
| 43 length = Length(MinIntrinsic); | |
| 44 break; | |
| 45 case CSSValueWebkitMinContent: | |
| 46 length = Length(MinContent); | |
| 47 break; | |
| 48 case CSSValueWebkitMaxContent: | |
| 49 length = Length(MaxContent); | |
| 50 break; | |
| 51 case CSSValueWebkitFillAvailable: | |
| 52 length = Length(FillAvailable); | |
| 53 break; | |
| 54 case CSSValueWebkitFitContent: | |
| 55 length = Length(FitContent); | |
| 56 break; | |
| 57 {%- endif %} | |
| 58 | |
| 59 {%- if property.use_auto %} | |
| 60 case CSSValueAuto: | |
| 61 break; // default ctor is auto | |
| 62 {%- endif %} | |
| 63 | |
| 64 case CSSValueInvalid: | |
| 65 length = primitiveValue->convertToLength<FixedIntegerConversion | Percen
tConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZo
om()); | |
| 66 length.setQuirk(primitiveValue->isQuirkValue()); | |
| 67 break; | |
| 68 default: | |
| 69 ASSERT_NOT_REACHED(); | |
| 70 } | |
| 71 {{ set_value(property) }}(length); | |
| 72 {%- endmacro %} | |
| 73 | |
| 74 {%- for property_id, property in properties.items() if not property.use_handlers
_for %} | |
| 75 {%- call wrap_with_condition(property.condition) %} | |
| 76 {%- set apply_type = property.apply_type %} | |
| 77 | |
| 78 {%- if not property.custom_initial %} | |
| 79 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat
e) | |
| 80 { | |
| 81 {%- if property.svg %} | |
| 82 {{ set_value(property) }}(SVGRenderStyle::{{property.initial}}()); | |
| 83 {%- else %} | |
| 84 {{ set_value(property) }}(RenderStyle::{{property.initial}}()); | |
| 85 {%- endif %} | |
| 86 } | |
| 87 {% endif %} | |
| 88 | |
| 89 {%- if not property.custom_inherit %} | |
| 90 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat
e) | |
| 91 { | |
| 92 {%- if property.svg %} | |
| 93 {{ set_value(property) }}(state.parentStyle()->svgStyle()->{{property.getter
}}()); | |
| 94 {%- else %} | |
| 95 {{ set_value(property) }}(state.parentStyle()->{{property.getter}}()); | |
| 96 {%- endif %} | |
| 97 } | |
| 98 {% endif %} | |
| 99 | |
| 100 {%- if not property.custom_value %} | |
| 101 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state,
CSSValue* value) | |
| 102 { | |
| 103 {%- if apply_type == "length" %} | |
| 104 {{ apply_value_length(property) }} | |
| 105 {%- else %} | |
| 106 {{ set_value(property) }}(static_cast<{{property.type_name}}>(*toCSSPrimitiv
eValue(value))); | |
| 107 {%- endif %} | |
| 108 } | |
| 109 {% endif %} | |
| 110 | |
| 111 {%- endcall %} | |
| 112 {%- endfor %} | |
| 113 | |
| 114 bool StyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& sta
te, CSSValue* value, bool isInitial, bool isInherit) { | |
| 115 switch(property) { | |
| 116 {%- for property_id, property in properties.items() %} | |
| 117 {%- set used_property = properties[property.use_handlers_for] or property %} | |
| 118 {%- set used_property_id = used_property.property_id %} | |
| 119 {%- call wrap_with_condition(used_property.condition) %} | |
| 120 case {{ property_id }}: | |
| 121 if (isInitial) | |
| 122 StyleBuilderFunctions::applyInitial{{ used_property_id }}(state); | |
| 123 else if (isInherit) | |
| 124 StyleBuilderFunctions::applyInherit{{ used_property_id }}(state); | |
| 125 else | |
| 126 StyleBuilderFunctions::applyValue{{ used_property_id }}(state, value
); | |
| 127 return true; | |
| 128 {%- endcall %} | |
| 129 {% endfor %} | |
| 130 default: | |
| 131 return false; | |
| 132 } | |
| 133 } | |
| 134 | |
| 135 } // namespace WebCore | |
| 136 | |
| OLD | NEW |