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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 { |
52 {% if property.svg %} | 52 {% if property.svg %} |
53 {{set_value(property)}}(SVGLayoutStyle::{{property.initial}}()); | 53 {{set_value(property)}}(SVGComputedStyle::{{property.initial}}()); |
54 {% elif property.font %} | 54 {% elif property.font %} |
55 {{set_value(property)}}(FontBuilder::{{property.initial}}()); | 55 {{set_value(property)}}(FontBuilder::{{property.initial}}()); |
56 {% else %} | 56 {% else %} |
57 {{set_value(property)}}(LayoutStyle::{{property.initial}}()); | 57 {{set_value(property)}}(ComputedStyle::{{property.initial}}()); |
58 {% endif %} | 58 {% endif %} |
59 } | 59 } |
60 | 60 |
61 {% endif %} | 61 {% endif %} |
62 {% if not property.custom_inherit %} | 62 {% if not property.custom_inherit %} |
63 {{declare_inherit_function(property_id)}} | 63 {{declare_inherit_function(property_id)}} |
64 { | 64 { |
65 {% if property.svg %} | 65 {% if property.svg %} |
66 {{set_value(property)}}(state.parentStyle()->svgStyle().{{property.getter}}(
)); | 66 {{set_value(property)}}(state.parentStyle()->svgStyle().{{property.getter}}(
)); |
67 {% elif property.font %} | 67 {% elif property.font %} |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 304 } |
305 | 305 |
306 {{declare_value_function(property_id)}} | 306 {{declare_value_function(property_id)}} |
307 { | 307 { |
308 if (state.applyPropertyToRegularStyle()) | 308 if (state.applyPropertyToRegularStyle()) |
309 {{set_value(property)}}(StyleBuilderConverter::convertStyleColor(state,
value)); | 309 {{set_value(property)}}(StyleBuilderConverter::convertStyleColor(state,
value)); |
310 if (state.applyPropertyToVisitedLinkStyle()) | 310 if (state.applyPropertyToVisitedLinkStyle()) |
311 state.style()->{{visited_link_setter}}(StyleBuilderConverter::convertSty
leColor(state, value, true)); | 311 state.style()->{{visited_link_setter}}(StyleBuilderConverter::convertSty
leColor(state, value, true)); |
312 } | 312 } |
313 {% endmacro %} | 313 {% endmacro %} |
314 {{apply_color('CSSPropertyBackgroundColor', initial_color='LayoutStyle::initialB
ackgroundColor') }} | 314 {{apply_color('CSSPropertyBackgroundColor', initial_color='ComputedStyle::initia
lBackgroundColor') }} |
315 {{apply_color('CSSPropertyBorderBottomColor')}} | 315 {{apply_color('CSSPropertyBorderBottomColor')}} |
316 {{apply_color('CSSPropertyBorderLeftColor')}} | 316 {{apply_color('CSSPropertyBorderLeftColor')}} |
317 {{apply_color('CSSPropertyBorderRightColor')}} | 317 {{apply_color('CSSPropertyBorderRightColor')}} |
318 {{apply_color('CSSPropertyBorderTopColor')}} | 318 {{apply_color('CSSPropertyBorderTopColor')}} |
319 {{apply_color('CSSPropertyOutlineColor')}} | 319 {{apply_color('CSSPropertyOutlineColor')}} |
320 {{apply_color('CSSPropertyTextDecorationColor')}} | 320 {{apply_color('CSSPropertyTextDecorationColor')}} |
321 {{apply_color('CSSPropertyWebkitColumnRuleColor')}} | 321 {{apply_color('CSSPropertyWebkitColumnRuleColor')}} |
322 {{apply_color('CSSPropertyWebkitTextEmphasisColor')}} | 322 {{apply_color('CSSPropertyWebkitTextEmphasisColor')}} |
323 {{apply_color('CSSPropertyWebkitTextFillColor')}} | 323 {{apply_color('CSSPropertyWebkitTextFillColor')}} |
324 {{apply_color('CSSPropertyWebkitTextStrokeColor')}} | 324 {{apply_color('CSSPropertyWebkitTextStrokeColor')}} |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 {{apply_fill_layer('CSSPropertyWebkitMaskOrigin', 'Origin')}} | 461 {{apply_fill_layer('CSSPropertyWebkitMaskOrigin', 'Origin')}} |
462 {{apply_fill_layer('CSSPropertyWebkitMaskPositionX', 'XPosition')}} | 462 {{apply_fill_layer('CSSPropertyWebkitMaskPositionX', 'XPosition')}} |
463 {{apply_fill_layer('CSSPropertyWebkitMaskPositionY', 'YPosition')}} | 463 {{apply_fill_layer('CSSPropertyWebkitMaskPositionY', 'YPosition')}} |
464 {{apply_fill_layer('CSSPropertyWebkitMaskRepeatX', 'RepeatX')}} | 464 {{apply_fill_layer('CSSPropertyWebkitMaskRepeatX', 'RepeatX')}} |
465 {{apply_fill_layer('CSSPropertyWebkitMaskRepeatY', 'RepeatY')}} | 465 {{apply_fill_layer('CSSPropertyWebkitMaskRepeatY', 'RepeatY')}} |
466 {{apply_fill_layer('CSSPropertyWebkitMaskSize', 'Size')}} | 466 {{apply_fill_layer('CSSPropertyWebkitMaskSize', 'Size')}} |
467 | 467 |
468 {% macro apply_grid_template(property_id, type) %} | 468 {% macro apply_grid_template(property_id, type) %} |
469 {{declare_initial_function(property_id)}} | 469 {{declare_initial_function(property_id)}} |
470 { | 470 { |
471 state.style()->setGridTemplate{{type}}s(LayoutStyle::initialGridTemplate{{ty
pe}}s()); | 471 state.style()->setGridTemplate{{type}}s(ComputedStyle::initialGridTemplate{{
type}}s()); |
472 state.style()->setNamedGrid{{type}}Lines(LayoutStyle::initialNamedGrid{{type
}}Lines()); | 472 state.style()->setNamedGrid{{type}}Lines(ComputedStyle::initialNamedGrid{{ty
pe}}Lines()); |
473 state.style()->setOrderedNamedGrid{{type}}Lines(LayoutStyle::initialOrderedN
amedGrid{{type}}Lines()); | 473 state.style()->setOrderedNamedGrid{{type}}Lines(ComputedStyle::initialOrdere
dNamedGrid{{type}}Lines()); |
474 } | 474 } |
475 | 475 |
476 {{declare_inherit_function(property_id)}} | 476 {{declare_inherit_function(property_id)}} |
477 { | 477 { |
478 state.style()->setGridTemplate{{type}}s(state.parentStyle()->gridTemplate{{t
ype}}s()); | 478 state.style()->setGridTemplate{{type}}s(state.parentStyle()->gridTemplate{{t
ype}}s()); |
479 state.style()->setNamedGrid{{type}}Lines(state.parentStyle()->namedGrid{{typ
e}}Lines()); | 479 state.style()->setNamedGrid{{type}}Lines(state.parentStyle()->namedGrid{{typ
e}}Lines()); |
480 state.style()->setOrderedNamedGrid{{type}}Lines(state.parentStyle()->ordered
NamedGrid{{type}}Lines()); | 480 state.style()->setOrderedNamedGrid{{type}}Lines(state.parentStyle()->ordered
NamedGrid{{type}}Lines()); |
481 } | 481 } |
482 | 482 |
483 {{declare_value_function(property_id)}} | 483 {{declare_value_function(property_id)}} |
(...skipping 11 matching lines...) Expand all Loading... |
495 state.style()->setOrderedNamedGrid{{type}}Lines(orderedNamedGridLines); | 495 state.style()->setOrderedNamedGrid{{type}}Lines(orderedNamedGridLines); |
496 } | 496 } |
497 {% endmacro %} | 497 {% endmacro %} |
498 {{apply_grid_template('CSSPropertyGridTemplateColumns', 'Column')}} | 498 {{apply_grid_template('CSSPropertyGridTemplateColumns', 'Column')}} |
499 {{apply_grid_template('CSSPropertyGridTemplateRows', 'Row')}} | 499 {{apply_grid_template('CSSPropertyGridTemplateRows', 'Row')}} |
500 | 500 |
501 {% macro apply_alignment(property_id, alignment_type) %} | 501 {% macro apply_alignment(property_id, alignment_type) %} |
502 {% set property = properties[property_id] %} | 502 {% set property = properties[property_id] %} |
503 {{declare_initial_function(property_id)}} | 503 {{declare_initial_function(property_id)}} |
504 { | 504 { |
505 state.style()->set{{alignment_type}}(LayoutStyle::initial{{alignment_type}}(
)); | 505 state.style()->set{{alignment_type}}(ComputedStyle::initial{{alignment_type}
}()); |
506 state.style()->set{{alignment_type}}OverflowAlignment(LayoutStyle::initial{{
alignment_type}}OverflowAlignment()); | 506 state.style()->set{{alignment_type}}OverflowAlignment(ComputedStyle::initial
{{alignment_type}}OverflowAlignment()); |
507 } | 507 } |
508 | 508 |
509 {{declare_inherit_function(property_id)}} | 509 {{declare_inherit_function(property_id)}} |
510 { | 510 { |
511 state.style()->set{{alignment_type}}(state.parentStyle()->{{property.getter}
}()); | 511 state.style()->set{{alignment_type}}(state.parentStyle()->{{property.getter}
}()); |
512 state.style()->set{{alignment_type}}OverflowAlignment(state.parentStyle()->{
{property.getter}}OverflowAlignment()); | 512 state.style()->set{{alignment_type}}OverflowAlignment(state.parentStyle()->{
{property.getter}}OverflowAlignment()); |
513 } | 513 } |
514 | 514 |
515 {{declare_value_function(property_id)}} | 515 {{declare_value_function(property_id)}} |
516 { | 516 { |
517 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 517 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
518 if (Pair* pairValue = primitiveValue->getPairValue()) { | 518 if (Pair* pairValue = primitiveValue->getPairValue()) { |
519 state.style()->set{{alignment_type}}(*pairValue->first()); | 519 state.style()->set{{alignment_type}}(*pairValue->first()); |
520 state.style()->set{{alignment_type}}OverflowAlignment(*pairValue->second
()); | 520 state.style()->set{{alignment_type}}OverflowAlignment(*pairValue->second
()); |
521 } else { | 521 } else { |
522 state.style()->set{{alignment_type}}(*primitiveValue); | 522 state.style()->set{{alignment_type}}(*primitiveValue); |
523 state.style()->set{{alignment_type}}OverflowAlignment(LayoutStyle::initi
al{{alignment_type}}OverflowAlignment()); | 523 state.style()->set{{alignment_type}}OverflowAlignment(ComputedStyle::ini
tial{{alignment_type}}OverflowAlignment()); |
524 } | 524 } |
525 } | 525 } |
526 {% endmacro %} | 526 {% endmacro %} |
527 {{apply_alignment('CSSPropertyJustifySelf', 'JustifySelf')}} | 527 {{apply_alignment('CSSPropertyJustifySelf', 'JustifySelf')}} |
528 {{apply_alignment('CSSPropertyAlignItems', 'AlignItems')}} | 528 {{apply_alignment('CSSPropertyAlignItems', 'AlignItems')}} |
529 {{apply_alignment('CSSPropertyAlignSelf', 'AlignSelf')}} | 529 {{apply_alignment('CSSPropertyAlignSelf', 'AlignSelf')}} |
530 | 530 |
531 {% macro apply_content_alignment(property_id, alignment_type) %} | 531 {% macro apply_content_alignment(property_id, alignment_type) %} |
532 {% set property = properties[property_id] %} | 532 {% set property = properties[property_id] %} |
533 {{declare_initial_function(property_id)}} | 533 {{declare_initial_function(property_id)}} |
534 { | 534 { |
535 state.style()->set{{alignment_type}}(LayoutStyle::initial{{alignment_type}}(
)); | 535 state.style()->set{{alignment_type}}(ComputedStyle::initial{{alignment_type}
}()); |
536 state.style()->set{{alignment_type}}OverflowAlignment(LayoutStyle::initial{{
alignment_type}}OverflowAlignment()); | 536 state.style()->set{{alignment_type}}OverflowAlignment(ComputedStyle::initial
{{alignment_type}}OverflowAlignment()); |
537 state.style()->set{{alignment_type}}Distribution(LayoutStyle::initial{{align
ment_type}}Distribution()); | 537 state.style()->set{{alignment_type}}Distribution(ComputedStyle::initial{{ali
gnment_type}}Distribution()); |
538 } | 538 } |
539 | 539 |
540 {{declare_inherit_function(property_id)}} | 540 {{declare_inherit_function(property_id)}} |
541 { | 541 { |
542 state.style()->set{{alignment_type}}(state.parentStyle()->{{property.getter}
}()); | 542 state.style()->set{{alignment_type}}(state.parentStyle()->{{property.getter}
}()); |
543 state.style()->set{{alignment_type}}OverflowAlignment(state.parentStyle()->{
{property.getter}}OverflowAlignment()); | 543 state.style()->set{{alignment_type}}OverflowAlignment(state.parentStyle()->{
{property.getter}}OverflowAlignment()); |
544 state.style()->set{{alignment_type}}Distribution(state.parentStyle()->{{prop
erty.getter}}Distribution()); | 544 state.style()->set{{alignment_type}}Distribution(state.parentStyle()->{{prop
erty.getter}}Distribution()); |
545 } | 545 } |
546 | 546 |
547 {{declare_value_function(property_id)}} | 547 {{declare_value_function(property_id)}} |
548 { | 548 { |
549 state.style()->set{{alignment_type}}(LayoutStyle::initial{{alignment_type}}(
)); | 549 state.style()->set{{alignment_type}}(ComputedStyle::initial{{alignment_type}
}()); |
550 state.style()->set{{alignment_type}}OverflowAlignment(LayoutStyle::initial{{
alignment_type}}OverflowAlignment()); | 550 state.style()->set{{alignment_type}}OverflowAlignment(ComputedStyle::initial
{{alignment_type}}OverflowAlignment()); |
551 state.style()->set{{alignment_type}}Distribution(LayoutStyle::initial{{align
ment_type}}Distribution()); | 551 state.style()->set{{alignment_type}}Distribution(ComputedStyle::initial{{ali
gnment_type}}Distribution()); |
552 | 552 |
553 CSSContentDistributionValue* contentValue = toCSSContentDistributionValue(va
lue); | 553 CSSContentDistributionValue* contentValue = toCSSContentDistributionValue(va
lue); |
554 if (contentValue->distribution()->getValueID() != CSSValueInvalid) | 554 if (contentValue->distribution()->getValueID() != CSSValueInvalid) |
555 state.style()->set{{alignment_type}}Distribution(*contentValue->distribu
tion()); | 555 state.style()->set{{alignment_type}}Distribution(*contentValue->distribu
tion()); |
556 if (contentValue->position()->getValueID() != CSSValueInvalid) | 556 if (contentValue->position()->getValueID() != CSSValueInvalid) |
557 state.style()->set{{alignment_type}}(*contentValue->position()); | 557 state.style()->set{{alignment_type}}(*contentValue->position()); |
558 if (contentValue->overflow()->getValueID() != CSSValueInvalid) | 558 if (contentValue->overflow()->getValueID() != CSSValueInvalid) |
559 state.style()->set{{alignment_type}}OverflowAlignment(*contentValue->ove
rflow()); | 559 state.style()->set{{alignment_type}}OverflowAlignment(*contentValue->ove
rflow()); |
560 } | 560 } |
561 {% endmacro %} | 561 {% endmacro %} |
562 {{apply_content_alignment('CSSPropertyJustifyContent', 'JustifyContent')}} | 562 {{apply_content_alignment('CSSPropertyJustifyContent', 'JustifyContent')}} |
563 {{apply_content_alignment('CSSPropertyAlignContent', 'AlignContent')}} | 563 {{apply_content_alignment('CSSPropertyAlignContent', 'AlignContent')}} |
564 | 564 |
565 {% macro apply_svg_paint(property_id, paint_type) %} | 565 {% macro apply_svg_paint(property_id, paint_type) %} |
566 {% set property = properties[property_id] %} | 566 {% set property = properties[property_id] %} |
567 {{declare_initial_function(property_id)}} | 567 {{declare_initial_function(property_id)}} |
568 { | 568 { |
569 {{set_value(property)}}( | 569 {{set_value(property)}}( |
570 SVGLayoutStyle::initial{{paint_type}}Type(), | 570 SVGComputedStyle::initial{{paint_type}}Type(), |
571 SVGLayoutStyle::initial{{paint_type}}Color(), | 571 SVGComputedStyle::initial{{paint_type}}Color(), |
572 SVGLayoutStyle::initial{{paint_type}}Uri(), | 572 SVGComputedStyle::initial{{paint_type}}Uri(), |
573 state.applyPropertyToRegularStyle(), | 573 state.applyPropertyToRegularStyle(), |
574 state.applyPropertyToVisitedLinkStyle()); | 574 state.applyPropertyToVisitedLinkStyle()); |
575 } | 575 } |
576 | 576 |
577 {{declare_inherit_function(property_id)}} | 577 {{declare_inherit_function(property_id)}} |
578 { | 578 { |
579 const SVGLayoutStyle& svgParentStyle = state.parentStyle()->svgStyle(); | 579 const SVGComputedStyle& svgParentStyle = state.parentStyle()->svgStyle(); |
580 {{set_value(property)}}( | 580 {{set_value(property)}}( |
581 svgParentStyle.{{paint_type|lower_first}}Type(), | 581 svgParentStyle.{{paint_type|lower_first}}Type(), |
582 svgParentStyle.{{paint_type|lower_first}}Color(), | 582 svgParentStyle.{{paint_type|lower_first}}Color(), |
583 svgParentStyle.{{paint_type|lower_first}}Uri(), | 583 svgParentStyle.{{paint_type|lower_first}}Uri(), |
584 state.applyPropertyToRegularStyle(), | 584 state.applyPropertyToRegularStyle(), |
585 state.applyPropertyToVisitedLinkStyle()); | 585 state.applyPropertyToVisitedLinkStyle()); |
586 } | 586 } |
587 | 587 |
588 {{declare_value_function(property_id)}} | 588 {{declare_value_function(property_id)}} |
589 { | 589 { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 } | 622 } |
623 {{set_value(property)}}(ptype, c, url, | 623 {{set_value(property)}}(ptype, c, url, |
624 state.applyPropertyToRegularStyle(), | 624 state.applyPropertyToRegularStyle(), |
625 state.applyPropertyToVisitedLinkStyle()); | 625 state.applyPropertyToVisitedLinkStyle()); |
626 } | 626 } |
627 } | 627 } |
628 {% endmacro %} | 628 {% endmacro %} |
629 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} | 629 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} |
630 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} | 630 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} |
631 } // namespace blink | 631 } // namespace blink |
OLD | NEW |