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 "config.h" | 9 #include "config.h" |
10 #include "StyleBuilderFunctions.h" | 10 #include "StyleBuilderFunctions.h" |
11 | 11 |
12 #include "CSSValueKeywords.h" | 12 #include "CSSValueKeywords.h" |
13 #include "core/css/BasicShapeFunctions.h" | 13 #include "core/css/BasicShapeFunctions.h" |
14 #include "core/css/CSSContentDistributionValue.h" | 14 #include "core/css/CSSContentDistributionValue.h" |
15 #include "core/css/CSSPrimitiveValueMappings.h" | 15 #include "core/css/CSSPrimitiveValueMappings.h" |
16 #include "core/css/Pair.h" | 16 #include "core/css/Pair.h" |
17 #include "core/css/resolver/StyleResolverState.h" | 17 #include "core/css/resolver/StyleResolverState.h" |
18 | 18 |
19 {% macro declare_initial_function(property_id) %} | 19 {% macro declare_initial_function(property_id) %} |
20 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat
e) | 20 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat
e) |
21 {%- endmacro %} | 21 {%- endmacro %} |
22 {% macro declare_inherit_function(property_id) %} | 22 {% macro declare_inherit_function(property_id) %} |
23 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat
e) | 23 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat
e) |
24 {%- endmacro %} | 24 {%- endmacro %} |
25 {% macro declare_value_function(property_id) %} | 25 {% macro declare_value_function(property_id) %} |
26 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state,
CSSValue* value) | 26 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state,
CSSValue value) |
27 {%- endmacro %} | 27 {%- endmacro %} |
28 {% macro set_value(property) %} | 28 {% macro set_value(property) %} |
29 {% if property.svg %} | 29 {% if property.svg %} |
30 state.style()->accessSVGStyle().{{property.setter}} | 30 state.style()->accessSVGStyle().{{property.setter}} |
31 {%- elif property.font %} | 31 {%- elif property.font %} |
32 state.fontBuilder().{{property.setter}} | 32 state.fontBuilder().{{property.setter}} |
33 {%- else %} | 33 {%- else %} |
34 state.style()->{{property.setter}} | 34 state.style()->{{property.setter}} |
35 {%- endif %} | 35 {%- endif %} |
36 {% endmacro %} | 36 {% endmacro %} |
37 {% macro convert_and_set_value(property) %} | 37 {% macro convert_and_set_value(property) %} |
38 {% if property.converter %} | 38 {% if property.converter %} |
39 {{set_value(property)}}(StyleBuilderConverter::{{property.converter}}(state, val
ue)); | 39 {{set_value(property)}}(StyleBuilderConverter::{{property.converter}}(state, val
ue)); |
40 {%- else %} | 40 {%- else %} |
41 {{set_value(property)}}(static_cast<{{property.type_name}}>(*toCSSPrimitiveValue
(value))); | 41 {{set_value(property)}}(static_cast<{{property.type_name}}>(toCSSPrimitiveValue(
value))); |
42 {%- endif %} | 42 {%- endif %} |
43 {% endmacro %} | 43 {% endmacro %} |
44 | 44 |
45 namespace blink { | 45 namespace blink { |
46 | 46 |
47 {% for property_id, property in properties.items() if property.should_declare_fu
nctions %} | 47 {% for property_id, property in properties.items() if property.should_declare_fu
nctions %} |
48 {% set apply_type = property.apply_type %} | 48 {% set apply_type = property.apply_type %} |
49 {% if not property.custom_initial %} | 49 {% if not property.custom_initial %} |
50 {{declare_initial_function(property_id)}} | 50 {{declare_initial_function(property_id)}} |
51 { | 51 { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 if (!parentData) | 96 if (!parentData) |
97 applyInitial{{property_id}}(state); | 97 applyInitial{{property_id}}(state); |
98 else | 98 else |
99 state.style()->access{{animation}}s().{{vector}} = parentData->{{vector}
}; | 99 state.style()->access{{animation}}s().{{vector}} = parentData->{{vector}
}; |
100 } | 100 } |
101 | 101 |
102 {{declare_value_function(property_id)}} | 102 {{declare_value_function(property_id)}} |
103 { | 103 { |
104 CSS{{animation}}Data& data = state.style()->access{{animation}}s(); | 104 CSS{{animation}}Data& data = state.style()->access{{animation}}s(); |
105 data.{{vector}}.clear(); | 105 data.{{vector}}.clear(); |
106 for (auto& listValue : toCSSValueList(*value)) | 106 for (auto& listValue : toCSSValueList(value)) |
107 data.{{vector}}.append(CSSToStyleMap::mapAnimation{{attribute}}(listValu
e.get())); | 107 data.{{vector}}.append(CSSToStyleMap::mapAnimation{{attribute}}(listValu
e)); |
108 } | 108 } |
109 {% endmacro %} | 109 {% endmacro %} |
110 {{apply_animation('CSSPropertyAnimationDelay', 'Delay', 'Animation')}} | 110 {{apply_animation('CSSPropertyAnimationDelay', 'Delay', 'Animation')}} |
111 {{apply_animation('CSSPropertyAnimationDirection', 'Direction', 'Animation')}} | 111 {{apply_animation('CSSPropertyAnimationDirection', 'Direction', 'Animation')}} |
112 {{apply_animation('CSSPropertyAnimationDuration', 'Duration', 'Animation')}} | 112 {{apply_animation('CSSPropertyAnimationDuration', 'Duration', 'Animation')}} |
113 {{apply_animation('CSSPropertyAnimationFillMode', 'FillMode', 'Animation')}} | 113 {{apply_animation('CSSPropertyAnimationFillMode', 'FillMode', 'Animation')}} |
114 {{apply_animation('CSSPropertyAnimationIterationCount', 'IterationCount', 'Anima
tion')}} | 114 {{apply_animation('CSSPropertyAnimationIterationCount', 'IterationCount', 'Anima
tion')}} |
115 {{apply_animation('CSSPropertyAnimationName', 'Name', 'Animation')}} | 115 {{apply_animation('CSSPropertyAnimationName', 'Name', 'Animation')}} |
116 {{apply_animation('CSSPropertyAnimationPlayState', 'PlayState', 'Animation')}} | 116 {{apply_animation('CSSPropertyAnimationPlayState', 'PlayState', 'Animation')}} |
117 {{apply_animation('CSSPropertyAnimationTimingFunction', 'TimingFunction', 'Anima
tion')}} | 117 {{apply_animation('CSSPropertyAnimationTimingFunction', 'TimingFunction', 'Anima
tion')}} |
(...skipping 14 matching lines...) Expand all Loading... |
132 {{declare_inherit_function(property_id)}} | 132 {{declare_inherit_function(property_id)}} |
133 { | 133 { |
134 if (state.parentStyle()->{{auto_getter}}()) | 134 if (state.parentStyle()->{{auto_getter}}()) |
135 state.style()->{{auto_setter}}(); | 135 state.style()->{{auto_setter}}(); |
136 else | 136 else |
137 {{set_value(property)}}(state.parentStyle()->{{property.getter}}()); | 137 {{set_value(property)}}(state.parentStyle()->{{property.getter}}()); |
138 } | 138 } |
139 | 139 |
140 {{declare_value_function(property_id)}} | 140 {{declare_value_function(property_id)}} |
141 { | 141 { |
142 if (!value->isPrimitiveValue()) | 142 if (!value.isPrimitiveValue()) |
143 return; | 143 return; |
144 | 144 |
145 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 145 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
146 if (primitiveValue->getValueID() == {{auto_identity}}) | 146 if (primitiveValue.getValueID() == {{auto_identity}}) |
147 state.style()->{{auto_setter}}(); | 147 state.style()->{{auto_setter}}(); |
148 else | 148 else |
149 {{convert_and_set_value(property)}} | 149 {{convert_and_set_value(property)}} |
150 } | 150 } |
151 {% endmacro %} | 151 {% endmacro %} |
152 {{apply_auto('CSSPropertyClip')}} | 152 {{apply_auto('CSSPropertyClip')}} |
153 {{apply_auto('CSSPropertyOrphans')}} | 153 {{apply_auto('CSSPropertyOrphans')}} |
154 {{apply_auto('CSSPropertyWebkitColumnCount')}} | 154 {{apply_auto('CSSPropertyWebkitColumnCount')}} |
155 {{apply_auto('CSSPropertyWebkitColumnGap', auto_getter='hasNormalColumnGap', aut
o_setter='setHasNormalColumnGap', auto_identity='CSSValueNormal')}} | 155 {{apply_auto('CSSPropertyWebkitColumnGap', auto_getter='hasNormalColumnGap', aut
o_setter='setHasNormalColumnGap', auto_identity='CSSValueNormal')}} |
156 {{apply_auto('CSSPropertyWebkitColumnWidth')}} | 156 {{apply_auto('CSSPropertyWebkitColumnWidth')}} |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 for (Iterator it = parentMap->begin(); it != end; ++it) { | 332 for (Iterator it = parentMap->begin(); it != end; ++it) { |
333 CounterDirectives& directives = map.add(it->key, CounterDirectives()).st
oredValue->value; | 333 CounterDirectives& directives = map.add(it->key, CounterDirectives()).st
oredValue->value; |
334 directives.inherit{{action}}(it->value); | 334 directives.inherit{{action}}(it->value); |
335 } | 335 } |
336 } | 336 } |
337 | 337 |
338 {{declare_value_function(property_id)}} | 338 {{declare_value_function(property_id)}} |
339 { | 339 { |
340 state.style()->clear{{action}}Directives(); | 340 state.style()->clear{{action}}Directives(); |
341 | 341 |
342 if (!value->isValueList()) { | 342 if (!value.isValueList()) { |
343 ASSERT(value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValue
ID() == CSSValueNone); | 343 ASSERT(value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID
() == CSSValueNone); |
344 return; | 344 return; |
345 } | 345 } |
346 | 346 |
347 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); | 347 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); |
348 | 348 |
349 CSSValueList* list = toCSSValueList(value); | 349 CSSValueList& list = toCSSValueList(value); |
350 | 350 |
351 int length = list ? list->length() : 0; | 351 int length = list.length(); |
352 for (int i = 0; i < length; ++i) { | 352 for (int i = 0; i < length; ++i) { |
353 CSSValue* currValue = list->item(i); | 353 CSSValue currValue = list.item(i); |
354 if (!currValue->isPrimitiveValue()) | 354 if (!currValue.isPrimitiveValue()) |
355 continue; | 355 continue; |
356 | 356 |
357 Pair* pair = toCSSPrimitiveValue(currValue)->getPairValue(); | 357 Pair* pair = toCSSPrimitiveValue(currValue).getPairValue(); |
358 if (!pair || !pair->first() || !pair->second()) | 358 if (!pair || !pair->first() || !pair->second()) |
359 continue; | 359 continue; |
360 | 360 |
361 AtomicString identifier(pair->first()->getStringValue()); | 361 AtomicString identifier(pair->first()->getStringValue()); |
362 int value = pair->second()->getIntValue(); | 362 int value = pair->second()->getIntValue(); |
363 CounterDirectives& directives = map.add(identifier, CounterDirectives())
.storedValue->value; | 363 CounterDirectives& directives = map.add(identifier, CounterDirectives())
.storedValue->value; |
364 {% if action == 'Reset' %} | 364 {% if action == 'Reset' %} |
365 directives.setResetValue(value); | 365 directives.setResetValue(value); |
366 {% else %} | 366 {% else %} |
367 directives.addIncrementValue(value); | 367 directives.addIncrementValue(value); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 /* Reset any remaining layers to not have the property set. */ | 404 /* Reset any remaining layers to not have the property set. */ |
405 currChild->clear{{fill_type}}(); | 405 currChild->clear{{fill_type}}(); |
406 currChild = currChild->next(); | 406 currChild = currChild->next(); |
407 } | 407 } |
408 } | 408 } |
409 | 409 |
410 {{declare_value_function(property_id)}} | 410 {{declare_value_function(property_id)}} |
411 { | 411 { |
412 FillLayer* currChild = &state.style()->{{access_layers}}(); | 412 FillLayer* currChild = &state.style()->{{access_layers}}(); |
413 FillLayer* prevChild = 0; | 413 FillLayer* prevChild = 0; |
414 if (value->isValueList() && !value->isImageSetValue()) { | 414 if (value.isValueList() && !value.isImageSetValue()) { |
415 /* Walk each value and put it into a layer, creating new layers as neede
d. */ | 415 /* Walk each value and put it into a layer, creating new layers as neede
d. */ |
416 CSSValueList* valueList = toCSSValueList(value); | 416 CSSValueList& valueList = toCSSValueList(value); |
417 for (unsigned int i = 0; i < valueList->length(); i++) { | 417 for (unsigned int i = 0; i < valueList.length(); i++) { |
418 if (!currChild) | 418 if (!currChild) |
419 currChild = prevChild->ensureNext(); | 419 currChild = prevChild->ensureNext(); |
420 CSSToStyleMap::{{map_fill}}(state, currChild, valueList->item(i)); | 420 CSSToStyleMap::{{map_fill}}(state, currChild, valueList.item(i)); |
421 prevChild = currChild; | 421 prevChild = currChild; |
422 currChild = currChild->next(); | 422 currChild = currChild->next(); |
423 } | 423 } |
424 } else { | 424 } else { |
425 CSSToStyleMap::{{map_fill}}(state, currChild, value); | 425 CSSToStyleMap::{{map_fill}}(state, currChild, value); |
426 currChild = currChild->next(); | 426 currChild = currChild->next(); |
427 } | 427 } |
428 while (currChild) { | 428 while (currChild) { |
429 /* Reset all remaining layers to not have the property set. */ | 429 /* Reset all remaining layers to not have the property set. */ |
430 currChild->clear{{fill_type}}(); | 430 currChild->clear{{fill_type}}(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 svgParentStyle.{{paint_type|lower_first}}Type(), | 506 svgParentStyle.{{paint_type|lower_first}}Type(), |
507 svgParentStyle.{{paint_type|lower_first}}Color(), | 507 svgParentStyle.{{paint_type|lower_first}}Color(), |
508 svgParentStyle.{{paint_type|lower_first}}Uri(), | 508 svgParentStyle.{{paint_type|lower_first}}Uri(), |
509 state.applyPropertyToRegularStyle(), | 509 state.applyPropertyToRegularStyle(), |
510 state.applyPropertyToVisitedLinkStyle()); | 510 state.applyPropertyToVisitedLinkStyle()); |
511 } | 511 } |
512 | 512 |
513 {{declare_value_function(property_id)}} | 513 {{declare_value_function(property_id)}} |
514 { | 514 { |
515 String url; | 515 String url; |
516 if (value->isValueList()) { | 516 if (value.isValueList()) { |
517 CSSValueList* list = toCSSValueList(value); | 517 CSSValueList& list = toCSSValueList(value); |
518 ASSERT(list->length() > 1); | 518 ASSERT(list.length() > 1); |
519 | 519 |
520 if (!list->item(0)->isPrimitiveValue()) | 520 if (!list.item(0).isPrimitiveValue()) |
521 return; | 521 return; |
522 | 522 |
523 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(list->item(0)); | 523 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(list.item(0)); |
524 if (!primitiveValue->isURI()) | 524 if (!primitiveValue.isURI()) |
525 return; | 525 return; |
526 | 526 |
527 url = primitiveValue->getStringValue(); | 527 url = primitiveValue.getStringValue(); |
528 value = list->item(1); | 528 value = list.item(1); |
529 } | 529 } |
530 if (value->isPrimitiveValue()) { | 530 if (value.isPrimitiveValue()) { |
531 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 531 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
532 Color color; | 532 Color color; |
533 SVGPaintType paintType = SVG_PAINTTYPE_RGBCOLOR; | 533 SVGPaintType paintType = SVG_PAINTTYPE_RGBCOLOR; |
534 if (primitiveValue->getValueID() == CSSValueNone) { | 534 if (primitiveValue.getValueID() == CSSValueNone) { |
535 paintType = url.isEmpty() ? SVG_PAINTTYPE_NONE : SVG_PAINTTYPE_URI_N
ONE; | 535 paintType = url.isEmpty() ? SVG_PAINTTYPE_NONE : SVG_PAINTTYPE_URI_N
ONE; |
536 } else if (primitiveValue->isURI()) { | 536 } else if (primitiveValue.isURI()) { |
537 paintType = SVG_PAINTTYPE_URI; | 537 paintType = SVG_PAINTTYPE_URI; |
538 url = primitiveValue->getStringValue(); | 538 url = primitiveValue.getStringValue(); |
539 } else if (primitiveValue->getValueID() == CSSValueCurrentcolor) { | 539 } else if (primitiveValue.getValueID() == CSSValueCurrentcolor) { |
540 color = state.style()->color(); | 540 color = state.style()->color(); |
541 paintType = url.isEmpty() ? SVG_PAINTTYPE_CURRENTCOLOR : SVG_PAINTTY
PE_URI_CURRENTCOLOR; | 541 paintType = url.isEmpty() ? SVG_PAINTTYPE_CURRENTCOLOR : SVG_PAINTTY
PE_URI_CURRENTCOLOR; |
542 } else { | 542 } else { |
543 color = StyleBuilderConverter::convertColor(state, primitiveValue); | 543 color = StyleBuilderConverter::convertColor(state, value); |
544 paintType = url.isEmpty() ? SVG_PAINTTYPE_RGBCOLOR : SVG_PAINTTYPE_U
RI_RGBCOLOR; | 544 paintType = url.isEmpty() ? SVG_PAINTTYPE_RGBCOLOR : SVG_PAINTTYPE_U
RI_RGBCOLOR; |
545 } | 545 } |
546 {{set_value(property)}}(paintType, color, url, | 546 {{set_value(property)}}(paintType, color, url, |
547 state.applyPropertyToRegularStyle(), | 547 state.applyPropertyToRegularStyle(), |
548 state.applyPropertyToVisitedLinkStyle()); | 548 state.applyPropertyToVisitedLinkStyle()); |
549 } | 549 } |
550 } | 550 } |
551 {% endmacro %} | 551 {% endmacro %} |
552 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} | 552 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} |
553 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} | 553 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} |
554 } // namespace blink | 554 } // namespace blink |
OLD | NEW |