| 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/CSSStringValue.h" |
| 16 #include "core/css/CSSValuePair.h" | 17 #include "core/css/CSSValuePair.h" |
| 17 #include "core/css/resolver/StyleResolverState.h" | 18 #include "core/css/resolver/StyleResolverState.h" |
| 18 | 19 |
| 19 {% macro declare_initial_function(property_id) %} | 20 {% macro declare_initial_function(property_id) %} |
| 20 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat
e) | 21 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat
e) |
| 21 {%- endmacro %} | 22 {%- endmacro %} |
| 22 {% macro declare_inherit_function(property_id) %} | 23 {% macro declare_inherit_function(property_id) %} |
| 23 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat
e) | 24 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat
e) |
| 24 {%- endmacro %} | 25 {%- endmacro %} |
| 25 {% macro declare_value_function(property_id) %} | 26 {% macro declare_value_function(property_id) %} |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 return; | 341 return; |
| 341 } | 342 } |
| 342 | 343 |
| 343 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); | 344 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); |
| 344 | 345 |
| 345 CSSValueList* list = toCSSValueList(value); | 346 CSSValueList* list = toCSSValueList(value); |
| 346 | 347 |
| 347 int length = list ? list->length() : 0; | 348 int length = list ? list->length() : 0; |
| 348 for (int i = 0; i < length; ++i) { | 349 for (int i = 0; i < length; ++i) { |
| 349 const CSSValuePair* pair = toCSSValuePair(list->item(i)); | 350 const CSSValuePair* pair = toCSSValuePair(list->item(i)); |
| 350 AtomicString identifier(toCSSPrimitiveValue(pair->first())->getStringVal
ue()); | 351 AtomicString identifier(toCSSStringValue(pair->first())->getStringValue(
)); |
| 351 int value = toCSSPrimitiveValue(pair->second())->getIntValue(); | 352 int value = toCSSPrimitiveValue(pair->second())->getIntValue(); |
| 352 CounterDirectives& directives = map.add(identifier, CounterDirectives())
.storedValue->value; | 353 CounterDirectives& directives = map.add(identifier, CounterDirectives())
.storedValue->value; |
| 353 {% if action == 'Reset' %} | 354 {% if action == 'Reset' %} |
| 354 directives.setResetValue(value); | 355 directives.setResetValue(value); |
| 355 {% else %} | 356 {% else %} |
| 356 directives.addIncrementValue(value); | 357 directives.addIncrementValue(value); |
| 357 {% endif %} | 358 {% endif %} |
| 358 } | 359 } |
| 359 ASSERT(!map.isEmpty()); | 360 ASSERT(!map.isEmpty()); |
| 360 } | 361 } |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 state.applyPropertyToRegularStyle(), | 498 state.applyPropertyToRegularStyle(), |
| 498 state.applyPropertyToVisitedLinkStyle()); | 499 state.applyPropertyToVisitedLinkStyle()); |
| 499 } | 500 } |
| 500 | 501 |
| 501 {{declare_value_function(property_id)}} | 502 {{declare_value_function(property_id)}} |
| 502 { | 503 { |
| 503 String url; | 504 String url; |
| 504 if (value->isValueList()) { | 505 if (value->isValueList()) { |
| 505 CSSValueList* list = toCSSValueList(value); | 506 CSSValueList* list = toCSSValueList(value); |
| 506 ASSERT(list->length() == 2); | 507 ASSERT(list->length() == 2); |
| 507 url = toCSSPrimitiveValue(list->item(0))->getStringValue(); | 508 url = toCSSStringValue(list->item(0))->getStringValue(); |
| 508 value = list->item(1); | 509 value = list->item(1); |
| 509 } | 510 } |
| 510 | 511 |
| 511 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
| 512 Color color; | 512 Color color; |
| 513 SVGPaintType paintType = SVG_PAINTTYPE_RGBCOLOR; | 513 SVGPaintType paintType = SVG_PAINTTYPE_RGBCOLOR; |
| 514 if (primitiveValue->getValueID() == CSSValueNone) { | 514 if (value->isStringValue()) { |
| 515 paintType = url.isEmpty() ? SVG_PAINTTYPE_NONE : SVG_PAINTTYPE_URI_NONE; | 515 ASSERT(toCSSStringValue(value)->serializationType() == CSSStringValue::S
erializeAsURI); |
| 516 } else if (primitiveValue->isURI()) { | |
| 517 paintType = SVG_PAINTTYPE_URI; | 516 paintType = SVG_PAINTTYPE_URI; |
| 518 url = primitiveValue->getStringValue(); | 517 url = toCSSStringValue(value)->getStringValue(); |
| 519 } else if (primitiveValue->getValueID() == CSSValueCurrentcolor) { | |
| 520 color = state.style()->color(); | |
| 521 paintType = url.isEmpty() ? SVG_PAINTTYPE_CURRENTCOLOR : SVG_PAINTTYPE_U
RI_CURRENTCOLOR; | |
| 522 } else { | 518 } else { |
| 523 color = StyleBuilderConverter::convertColor(state, primitiveValue); | 519 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 524 paintType = url.isEmpty() ? SVG_PAINTTYPE_RGBCOLOR : SVG_PAINTTYPE_URI_R
GBCOLOR; | 520 if (primitiveValue->getValueID() == CSSValueNone) { |
| 521 paintType = url.isEmpty() ? SVG_PAINTTYPE_NONE : SVG_PAINTTYPE_URI_N
ONE; |
| 522 } else if (primitiveValue->getValueID() == CSSValueCurrentcolor) { |
| 523 color = state.style()->color(); |
| 524 paintType = url.isEmpty() ? SVG_PAINTTYPE_CURRENTCOLOR : SVG_PAINTTY
PE_URI_CURRENTCOLOR; |
| 525 } else { |
| 526 color = StyleBuilderConverter::convertColor(state, primitiveValue); |
| 527 paintType = url.isEmpty() ? SVG_PAINTTYPE_RGBCOLOR : SVG_PAINTTYPE_U
RI_RGBCOLOR; |
| 528 } |
| 525 } | 529 } |
| 526 {{set_value(property)}}(paintType, color, url, | 530 {{set_value(property)}}(paintType, color, url, |
| 527 state.applyPropertyToRegularStyle(), | 531 state.applyPropertyToRegularStyle(), |
| 528 state.applyPropertyToVisitedLinkStyle()); | 532 state.applyPropertyToVisitedLinkStyle()); |
| 529 } | 533 } |
| 530 {% endmacro %} | 534 {% endmacro %} |
| 531 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} | 535 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} |
| 532 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} | 536 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} |
| 533 } // namespace blink | 537 } // namespace blink |
| OLD | NEW |