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,
const 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 %} |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 const 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')}} |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 ASSERT(value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID
() == 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.length(); | 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 const 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) |
359 continue; | 359 continue; |
360 | 360 |
361 AtomicString identifier(toCSSPrimitiveValue(*pair->first()).getStringVal
ue()); | 361 AtomicString identifier(pair->first().getStringValue()); |
362 int value = toCSSPrimitiveValue(*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); |
368 {% endif %} | 368 {% endif %} |
369 } | 369 } |
370 ASSERT(!map.isEmpty()); | 370 ASSERT(!map.isEmpty()); |
371 } | 371 } |
372 {% endmacro %} | 372 {% endmacro %} |
(...skipping 133 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 CSSValue realValue = value; |
517 CSSValueList& list = toCSSValueList(value); | 517 if (realValue.isValueList()) { |
| 518 const CSSValueList& list = toCSSValueList(realValue); |
518 ASSERT(list.length() > 1); | 519 ASSERT(list.length() > 1); |
519 | 520 |
520 if (!list.item(0).isPrimitiveValue()) | 521 if (!list.item(0).isPrimitiveValue()) |
521 return; | 522 return; |
522 | 523 |
523 CSSPrimitiveValue primitiveValue = toCSSPrimitiveValue(list.item(0)); | 524 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(list.item(
0)); |
524 if (!primitiveValue.isURI()) | 525 if (!primitiveValue.isURI()) |
525 return; | 526 return; |
526 | 527 |
527 url = primitiveValue.getStringValue(); | 528 url = primitiveValue.getStringValue(); |
528 value = list.item(1); | 529 realValue = list.item(1); |
529 } | 530 } |
530 if (value.isPrimitiveValue()) { | 531 if (realValue.isPrimitiveValue()) { |
531 CSSPrimitiveValue primitiveValue = toCSSPrimitiveValue(value); | 532 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(realValue)
; |
532 Color color; | 533 Color color; |
533 SVGPaintType paintType = SVG_PAINTTYPE_RGBCOLOR; | 534 SVGPaintType paintType = SVG_PAINTTYPE_RGBCOLOR; |
534 if (primitiveValue.getValueID() == CSSValueNone) { | 535 if (primitiveValue.getValueID() == CSSValueNone) { |
535 paintType = url.isEmpty() ? SVG_PAINTTYPE_NONE : SVG_PAINTTYPE_URI_N
ONE; | 536 paintType = url.isEmpty() ? SVG_PAINTTYPE_NONE : SVG_PAINTTYPE_URI_N
ONE; |
536 } else if (primitiveValue.isURI()) { | 537 } else if (primitiveValue.isURI()) { |
537 paintType = SVG_PAINTTYPE_URI; | 538 paintType = SVG_PAINTTYPE_URI; |
538 url = primitiveValue.getStringValue(); | 539 url = primitiveValue.getStringValue(); |
539 } else if (primitiveValue.getValueID() == CSSValueCurrentcolor) { | 540 } else if (primitiveValue.getValueID() == CSSValueCurrentcolor) { |
540 color = state.style()->color(); | 541 color = state.style()->color(); |
541 paintType = url.isEmpty() ? SVG_PAINTTYPE_CURRENTCOLOR : SVG_PAINTTY
PE_URI_CURRENTCOLOR; | 542 paintType = url.isEmpty() ? SVG_PAINTTYPE_CURRENTCOLOR : SVG_PAINTTY
PE_URI_CURRENTCOLOR; |
542 } else { | 543 } else { |
543 color = StyleBuilderConverter::convertColor(state, value); | 544 color = StyleBuilderConverter::convertColor(state, realValue); |
544 paintType = url.isEmpty() ? SVG_PAINTTYPE_RGBCOLOR : SVG_PAINTTYPE_U
RI_RGBCOLOR; | 545 paintType = url.isEmpty() ? SVG_PAINTTYPE_RGBCOLOR : SVG_PAINTTYPE_U
RI_RGBCOLOR; |
545 } | 546 } |
546 {{set_value(property)}}(paintType, color, url, | 547 {{set_value(property)}}(paintType, color, url, |
547 state.applyPropertyToRegularStyle(), | 548 state.applyPropertyToRegularStyle(), |
548 state.applyPropertyToVisitedLinkStyle()); | 549 state.applyPropertyToVisitedLinkStyle()); |
549 } | 550 } |
550 } | 551 } |
551 {% endmacro %} | 552 {% endmacro %} |
552 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} | 553 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} |
553 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} | 554 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} |
554 } // namespace blink | 555 } // namespace blink |
OLD | NEW |