| 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" |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 return; | 445 return; |
| 446 | 446 |
| 447 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 447 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 448 if (primitiveValue->getValueID() == {{id_for_minus_one}}) | 448 if (primitiveValue->getValueID() == {{id_for_minus_one}}) |
| 449 {{set_value(property)}}(-1); | 449 {{set_value(property)}}(-1); |
| 450 else | 450 else |
| 451 {{set_value(property)}}(primitiveValue->getValue<{{property.type_name}}>
(CSSPrimitiveValue::CSS_NUMBER)); | 451 {{set_value(property)}}(primitiveValue->getValue<{{property.type_name}}>
(CSSPrimitiveValue::CSS_NUMBER)); |
| 452 } | 452 } |
| 453 {% endmacro %} | 453 {% endmacro %} |
| 454 | 454 |
| 455 {% macro apply_value_shape(property_id) %} | |
| 456 {{declare_value_function(property_id)}} | |
| 457 { | |
| 458 {% set property = properties[property_id] %} | |
| 459 if (value->isPrimitiveValue()) { | |
| 460 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
| 461 if (primitiveValue->getValueID() == CSSValueNone) | |
| 462 {{set_value(property)}}(nullptr); | |
| 463 } else if (value->isImageValue() || value->isImageGeneratorValue() || value-
>isImageSetValue()) { | |
| 464 {{set_value(property)}}(ShapeValue::createImageValue(state.styleImage({{
property_id}}, value))); | |
| 465 } else if (value->isValueList()) { | |
| 466 RefPtr<BasicShape> shape; | |
| 467 CSSBoxType cssBox = BoxMissing; | |
| 468 CSSValueList* valueList = toCSSValueList(value); | |
| 469 for (unsigned i = 0; i < valueList->length(); ++i) { | |
| 470 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->i
tem(i)); | |
| 471 if (primitiveValue->isShape()) | |
| 472 shape = basicShapeForValue(state, primitiveValue->getShapeValue(
)); | |
| 473 else if (primitiveValue->getValueID() == CSSValueContentBox | |
| 474 || primitiveValue->getValueID() == CSSValueBorderBox | |
| 475 || primitiveValue->getValueID() == CSSValuePaddingBox | |
| 476 || primitiveValue->getValueID() == CSSValueMarginBox) | |
| 477 cssBox = CSSBoxType(*primitiveValue); | |
| 478 else | |
| 479 return; | |
| 480 } | |
| 481 | |
| 482 if (shape) | |
| 483 {{set_value(property)}}(ShapeValue::createShapeValue(shape.release()
, cssBox)); | |
| 484 else if (cssBox != BoxMissing) | |
| 485 {{set_value(property)}}(ShapeValue::createBoxShapeValue(cssBox)); | |
| 486 } | |
| 487 } | |
| 488 {% endmacro %} | |
| 489 {{apply_value_shape('CSSPropertyShapeOutside')}} | |
| 490 | |
| 491 {% macro apply_alignment(property_id, alignment_type) %} | 455 {% macro apply_alignment(property_id, alignment_type) %} |
| 492 {% set property = properties[property_id] %} | 456 {% set property = properties[property_id] %} |
| 493 {{declare_initial_function(property_id)}} | 457 {{declare_initial_function(property_id)}} |
| 494 { | 458 { |
| 495 state.style()->set{{alignment_type}}(RenderStyle::initial{{alignment_type}}(
)); | 459 state.style()->set{{alignment_type}}(RenderStyle::initial{{alignment_type}}(
)); |
| 496 state.style()->set{{alignment_type}}OverflowAlignment(RenderStyle::initial{{
alignment_type}}OverflowAlignment()); | 460 state.style()->set{{alignment_type}}OverflowAlignment(RenderStyle::initial{{
alignment_type}}OverflowAlignment()); |
| 497 } | 461 } |
| 498 | 462 |
| 499 {{declare_inherit_function(property_id)}} | 463 {{declare_inherit_function(property_id)}} |
| 500 { | 464 { |
| 501 state.style()->set{{alignment_type}}(state.parentStyle()->{{property.getter}
}()); | 465 state.style()->set{{alignment_type}}(state.parentStyle()->{{property.getter}
}()); |
| 502 state.style()->set{{alignment_type}}OverflowAlignment(state.parentStyle()->{
{property.getter}}OverflowAlignment()); | 466 state.style()->set{{alignment_type}}OverflowAlignment(state.parentStyle()->{
{property.getter}}OverflowAlignment()); |
| 503 } | 467 } |
| 504 | 468 |
| 505 {{declare_value_function(property_id)}} | 469 {{declare_value_function(property_id)}} |
| 506 { | 470 { |
| 507 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 471 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 508 if (Pair* pairValue = primitiveValue->getPairValue()) { | 472 if (Pair* pairValue = primitiveValue->getPairValue()) { |
| 509 state.style()->set{{alignment_type}}(*pairValue->first()); | 473 state.style()->set{{alignment_type}}(*pairValue->first()); |
| 510 state.style()->set{{alignment_type}}OverflowAlignment(*pairValue->second
()); | 474 state.style()->set{{alignment_type}}OverflowAlignment(*pairValue->second
()); |
| 511 } else { | 475 } else { |
| 512 state.style()->set{{alignment_type}}(*primitiveValue); | 476 state.style()->set{{alignment_type}}(*primitiveValue); |
| 513 } | 477 } |
| 514 } | 478 } |
| 515 {% endmacro %} | 479 {% endmacro %} |
| 516 {{apply_alignment('CSSPropertyAlignItems', 'AlignItems')}} | 480 {{apply_alignment('CSSPropertyAlignItems', 'AlignItems')}} |
| 517 {{apply_alignment('CSSPropertyAlignSelf', 'AlignSelf')}} | 481 {{apply_alignment('CSSPropertyAlignSelf', 'AlignSelf')}} |
| 518 | 482 |
| 519 } // namespace blink | 483 } // namespace blink |
| OLD | NEW |