OLD | NEW |
1 {% from 'macros.tmpl' import license %} | 1 {% from 'macros.tmpl' import license %} |
2 {# | 2 {# |
3 This file is for property handlers which use the templating engine to | 3 This file is for property handlers which use the templating engine to |
4 reduce (handwritten) code duplication. | 4 reduce (handwritten) code duplication. |
5 | 5 |
6 The `properties' dict can be used to access a property's parameters in | 6 The `properties' dict can be used to access a property's parameters in |
7 jinja2 templates (i.e. setter, getter, initial, type_name) | 7 jinja2 templates (i.e. setter, getter, initial, type_name) |
8 #} | 8 #} |
9 #include "StyleBuilderFunctions.h" | 9 #include "StyleBuilderFunctions.h" |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 state.style()->accessSVGStyle().{{property.setter}} | 32 state.style()->accessSVGStyle().{{property.setter}} |
33 {%- elif property.font %} | 33 {%- elif property.font %} |
34 state.fontBuilder().{{property.setter}} | 34 state.fontBuilder().{{property.setter}} |
35 {%- else %} | 35 {%- else %} |
36 state.style()->{{property.setter}} | 36 state.style()->{{property.setter}} |
37 {%- endif %} | 37 {%- endif %} |
38 {% endmacro %} | 38 {% endmacro %} |
39 {% macro convert_and_set_value(property) %} | 39 {% macro convert_and_set_value(property) %} |
40 {% if property.converter %} | 40 {% if property.converter %} |
41 {{set_value(property)}}(StyleBuilderConverter::{{property.converter}}(state, val
ue)); | 41 {{set_value(property)}}(StyleBuilderConverter::{{property.converter}}(state, val
ue)); |
| 42 {# TODO(sashab): Remove this list from this file. #} |
| 43 {% elif property.type_name in ['short', 'unsigned short', 'int', 'unsigned int',
'unsigned', 'float', 'LineClampValue'] %} |
| 44 {{set_value(property)}}(toCSSPrimitiveValue(value).convertTo<{{property.type_nam
e}}>()); |
42 {%- else %} | 45 {%- else %} |
43 {{set_value(property)}}(toCSSPrimitiveValue(value).convertTo<{{property.type_nam
e}}>()); | 46 {{set_value(property)}}(toCSSIdentifierValue(value).convertTo<{{property.type_na
me}}>()); |
44 {%- endif %} | 47 {%- endif %} |
45 {% endmacro %} | 48 {% endmacro %} |
46 {% macro set_is_inherited(property) %} | 49 {% macro set_is_inherited(property) %} |
47 state.style()->{{property.is_inherited_setter}} | 50 state.style()->{{property.is_inherited_setter}} |
48 {% endmacro %} | 51 {% endmacro %} |
49 | 52 |
50 namespace blink { | 53 namespace blink { |
51 | 54 |
52 {% for property_id, property in properties.items() if property.should_declare_fu
nctions %} | 55 {% for property_id, property in properties.items() if property.should_declare_fu
nctions %} |
53 {% set apply_type = property.apply_type %} | 56 {% set apply_type = property.apply_type %} |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 {{declare_inherit_function(property_id)}} | 149 {{declare_inherit_function(property_id)}} |
147 { | 150 { |
148 if (state.parentStyle()->{{auto_getter}}()) | 151 if (state.parentStyle()->{{auto_getter}}()) |
149 state.style()->{{auto_setter}}(); | 152 state.style()->{{auto_setter}}(); |
150 else | 153 else |
151 {{set_value(property)}}(state.parentStyle()->{{property.getter}}()); | 154 {{set_value(property)}}(state.parentStyle()->{{property.getter}}()); |
152 } | 155 } |
153 | 156 |
154 {{declare_value_function(property_id)}} | 157 {{declare_value_function(property_id)}} |
155 { | 158 { |
156 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == {
{auto_identity}}) | 159 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
{{auto_identity}}) |
157 state.style()->{{auto_setter}}(); | 160 state.style()->{{auto_setter}}(); |
158 else | 161 else |
159 {{convert_and_set_value(property)}} | 162 {{convert_and_set_value(property)}} |
160 } | 163 } |
161 {% endmacro %} | 164 {% endmacro %} |
162 {{apply_auto('CSSPropertyClip')}} | 165 {{apply_auto('CSSPropertyClip')}} |
163 {{apply_auto('CSSPropertyColumnCount')}} | 166 {{apply_auto('CSSPropertyColumnCount')}} |
164 {{apply_auto('CSSPropertyColumnGap', auto_getter='hasNormalColumnGap', auto_sett
er='setHasNormalColumnGap', auto_identity='CSSValueNormal')}} | 167 {{apply_auto('CSSPropertyColumnGap', auto_getter='hasNormalColumnGap', auto_sett
er='setHasNormalColumnGap', auto_identity='CSSValueNormal')}} |
165 {{apply_auto('CSSPropertyColumnWidth')}} | 168 {{apply_auto('CSSPropertyColumnWidth')}} |
166 {{apply_auto('CSSPropertyZIndex')}} | 169 {{apply_auto('CSSPropertyZIndex')}} |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 CounterDirectives& directives = map.add(it->key, CounterDirectives()).st
oredValue->value; | 344 CounterDirectives& directives = map.add(it->key, CounterDirectives()).st
oredValue->value; |
342 directives.inherit{{action}}(it->value); | 345 directives.inherit{{action}}(it->value); |
343 } | 346 } |
344 } | 347 } |
345 | 348 |
346 {{declare_value_function(property_id)}} | 349 {{declare_value_function(property_id)}} |
347 { | 350 { |
348 state.style()->clear{{action}}Directives(); | 351 state.style()->clear{{action}}Directives(); |
349 | 352 |
350 if (!value.isValueList()) { | 353 if (!value.isValueList()) { |
351 DCHECK(value.isPrimitiveValue()); | 354 DCHECK(value.isIdentifierValue()); |
352 DCHECK_EQ(toCSSPrimitiveValue(value).getValueID(), CSSValueNone); | 355 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
353 return; | 356 return; |
354 } | 357 } |
355 | 358 |
356 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); | 359 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); |
357 | 360 |
358 const CSSValueList& list = toCSSValueList(value); | 361 const CSSValueList& list = toCSSValueList(value); |
359 | 362 |
360 for (size_t i = 0; i < list.length(); ++i) { | 363 for (size_t i = 0; i < list.length(); ++i) { |
361 const CSSValuePair& pair = toCSSValuePair(list.item(i)); | 364 const CSSValuePair& pair = toCSSValuePair(list.item(i)); |
362 AtomicString identifier(toCSSCustomIdentValue(pair.first()).value()); | 365 AtomicString identifier(toCSSCustomIdentValue(pair.first()).value()); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 DCHECK_EQ(list.length(), 2U); | 531 DCHECK_EQ(list.length(), 2U); |
529 url = toCSSURIValue(list.item(0)).value(); | 532 url = toCSSURIValue(list.item(0)).value(); |
530 localValue = &list.item(1); | 533 localValue = &list.item(1); |
531 } | 534 } |
532 | 535 |
533 Color color; | 536 Color color; |
534 SVGPaintType paintType = SVG_PAINTTYPE_RGBCOLOR; | 537 SVGPaintType paintType = SVG_PAINTTYPE_RGBCOLOR; |
535 if (localValue->isURIValue()) { | 538 if (localValue->isURIValue()) { |
536 paintType = SVG_PAINTTYPE_URI; | 539 paintType = SVG_PAINTTYPE_URI; |
537 url = toCSSURIValue(localValue)->value(); | 540 url = toCSSURIValue(localValue)->value(); |
538 } else if (localValue->isPrimitiveValue() && toCSSPrimitiveValue(localValue)
->getValueID() == CSSValueNone) { | 541 } else if (localValue->isIdentifierValue() && toCSSIdentifierValue(localValu
e)->getValueID() == CSSValueNone) { |
539 paintType = url.isEmpty() ? SVG_PAINTTYPE_NONE : SVG_PAINTTYPE_URI_NONE; | 542 paintType = url.isEmpty() ? SVG_PAINTTYPE_NONE : SVG_PAINTTYPE_URI_NONE; |
540 } else if (localValue->isPrimitiveValue() && toCSSPrimitiveValue(localValue)
->getValueID() == CSSValueCurrentcolor) { | 543 } else if (localValue->isIdentifierValue() && toCSSIdentifierValue(localValu
e)->getValueID() == CSSValueCurrentcolor) { |
541 color = state.style()->color(); | 544 color = state.style()->color(); |
542 paintType = url.isEmpty() ? SVG_PAINTTYPE_CURRENTCOLOR : SVG_PAINTTYPE_U
RI_CURRENTCOLOR; | 545 paintType = url.isEmpty() ? SVG_PAINTTYPE_CURRENTCOLOR : SVG_PAINTTYPE_U
RI_CURRENTCOLOR; |
543 } else { | 546 } else { |
544 color = StyleBuilderConverter::convertColor(state, *localValue); | 547 color = StyleBuilderConverter::convertColor(state, *localValue); |
545 paintType = url.isEmpty() ? SVG_PAINTTYPE_RGBCOLOR : SVG_PAINTTYPE_URI_R
GBCOLOR; | 548 paintType = url.isEmpty() ? SVG_PAINTTYPE_RGBCOLOR : SVG_PAINTTYPE_URI_R
GBCOLOR; |
546 } | 549 } |
547 {{set_value(property)}}(paintType, color, url, | 550 {{set_value(property)}}(paintType, color, url, |
548 state.applyPropertyToRegularStyle(), | 551 state.applyPropertyToRegularStyle(), |
549 state.applyPropertyToVisitedLinkStyle()); | 552 state.applyPropertyToVisitedLinkStyle()); |
550 } | 553 } |
551 {% endmacro %} | 554 {% endmacro %} |
552 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} | 555 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} |
553 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} | 556 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} |
554 } // namespace blink | 557 } // namespace blink |
OLD | NEW |