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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after 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()) | |
143 return; | |
144 | |
145 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 142 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
146 if (primitiveValue->getValueID() == {{auto_identity}}) | 143 if (primitiveValue->getValueID() == {{auto_identity}}) |
147 state.style()->{{auto_setter}}(); | 144 state.style()->{{auto_setter}}(); |
148 else | 145 else |
149 {{convert_and_set_value(property)}} | 146 {{convert_and_set_value(property)}} |
150 } | 147 } |
151 {% endmacro %} | 148 {% endmacro %} |
152 {{apply_auto('CSSPropertyClip')}} | 149 {{apply_auto('CSSPropertyClip')}} |
153 {{apply_auto('CSSPropertyOrphans')}} | 150 {{apply_auto('CSSPropertyOrphans')}} |
154 {{apply_auto('CSSPropertyWebkitColumnCount')}} | 151 {{apply_auto('CSSPropertyWebkitColumnCount')}} |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 return; | 341 return; |
345 } | 342 } |
346 | 343 |
347 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); | 344 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); |
348 | 345 |
349 CSSValueList* list = toCSSValueList(value); | 346 CSSValueList* list = toCSSValueList(value); |
350 | 347 |
351 int length = list ? list->length() : 0; | 348 int length = list ? list->length() : 0; |
352 for (int i = 0; i < length; ++i) { | 349 for (int i = 0; i < length; ++i) { |
353 CSSValue* currValue = list->item(i); | 350 CSSValue* currValue = list->item(i); |
354 if (!currValue->isPrimitiveValue()) | |
355 continue; | |
356 | |
357 Pair* pair = toCSSPrimitiveValue(currValue)->getPairValue(); | 351 Pair* pair = toCSSPrimitiveValue(currValue)->getPairValue(); |
358 if (!pair || !pair->first() || !pair->second()) | |
359 continue; | |
360 | |
361 AtomicString identifier(pair->first()->getStringValue()); | 352 AtomicString identifier(pair->first()->getStringValue()); |
362 int value = pair->second()->getIntValue(); | 353 int value = pair->second()->getIntValue(); |
363 CounterDirectives& directives = map.add(identifier, CounterDirectives())
.storedValue->value; | 354 CounterDirectives& directives = map.add(identifier, CounterDirectives())
.storedValue->value; |
364 {% if action == 'Reset' %} | 355 {% if action == 'Reset' %} |
365 directives.setResetValue(value); | 356 directives.setResetValue(value); |
366 {% else %} | 357 {% else %} |
367 directives.addIncrementValue(value); | 358 directives.addIncrementValue(value); |
368 {% endif %} | 359 {% endif %} |
369 } | 360 } |
370 ASSERT(!map.isEmpty()); | 361 ASSERT(!map.isEmpty()); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 state.style()->setGridTemplate{{type}}s(state.parentStyle()->gridTemplate{{t
ype}}s()); | 458 state.style()->setGridTemplate{{type}}s(state.parentStyle()->gridTemplate{{t
ype}}s()); |
468 state.style()->setNamedGrid{{type}}Lines(state.parentStyle()->namedGrid{{typ
e}}Lines()); | 459 state.style()->setNamedGrid{{type}}Lines(state.parentStyle()->namedGrid{{typ
e}}Lines()); |
469 state.style()->setOrderedNamedGrid{{type}}Lines(state.parentStyle()->ordered
NamedGrid{{type}}Lines()); | 460 state.style()->setOrderedNamedGrid{{type}}Lines(state.parentStyle()->ordered
NamedGrid{{type}}Lines()); |
470 } | 461 } |
471 | 462 |
472 {{declare_value_function(property_id)}} | 463 {{declare_value_function(property_id)}} |
473 { | 464 { |
474 Vector<GridTrackSize> trackSizes; | 465 Vector<GridTrackSize> trackSizes; |
475 NamedGridLinesMap namedGridLines; | 466 NamedGridLinesMap namedGridLines; |
476 OrderedNamedGridLines orderedNamedGridLines; | 467 OrderedNamedGridLines orderedNamedGridLines; |
477 if (!StyleBuilderConverter::convertGridTrackList(value, trackSizes, namedGri
dLines, orderedNamedGridLines, state)) | 468 StyleBuilderConverter::convertGridTrackList(value, trackSizes, namedGridLine
s, orderedNamedGridLines, state); |
478 return; | |
479 const NamedGridAreaMap& namedGridAreas = state.style()->namedGridArea(); | 469 const NamedGridAreaMap& namedGridAreas = state.style()->namedGridArea(); |
480 if (!namedGridAreas.isEmpty()) | 470 if (!namedGridAreas.isEmpty()) |
481 StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(namedGri
dAreas, namedGridLines, For{{type}}s); | 471 StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(namedGri
dAreas, namedGridLines, For{{type}}s); |
482 state.style()->setGridTemplate{{type}}s(trackSizes); | 472 state.style()->setGridTemplate{{type}}s(trackSizes); |
483 state.style()->setNamedGrid{{type}}Lines(namedGridLines); | 473 state.style()->setNamedGrid{{type}}Lines(namedGridLines); |
484 state.style()->setOrderedNamedGrid{{type}}Lines(orderedNamedGridLines); | 474 state.style()->setOrderedNamedGrid{{type}}Lines(orderedNamedGridLines); |
485 } | 475 } |
486 {% endmacro %} | 476 {% endmacro %} |
487 {{apply_grid_template('CSSPropertyGridTemplateColumns', 'Column')}} | 477 {{apply_grid_template('CSSPropertyGridTemplateColumns', 'Column')}} |
488 {{apply_grid_template('CSSPropertyGridTemplateRows', 'Row')}} | 478 {{apply_grid_template('CSSPropertyGridTemplateRows', 'Row')}} |
(...skipping 19 matching lines...) Expand all Loading... |
508 svgParentStyle.{{paint_type|lower_first}}Uri(), | 498 svgParentStyle.{{paint_type|lower_first}}Uri(), |
509 state.applyPropertyToRegularStyle(), | 499 state.applyPropertyToRegularStyle(), |
510 state.applyPropertyToVisitedLinkStyle()); | 500 state.applyPropertyToVisitedLinkStyle()); |
511 } | 501 } |
512 | 502 |
513 {{declare_value_function(property_id)}} | 503 {{declare_value_function(property_id)}} |
514 { | 504 { |
515 String url; | 505 String url; |
516 if (value->isValueList()) { | 506 if (value->isValueList()) { |
517 CSSValueList* list = toCSSValueList(value); | 507 CSSValueList* list = toCSSValueList(value); |
518 ASSERT(list->length() > 1); | 508 ASSERT(list->length() == 2); |
519 | 509 url = toCSSPrimitiveValue(list->item(0))->getStringValue(); |
520 if (!list->item(0)->isPrimitiveValue()) | |
521 return; | |
522 | |
523 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(list->item(0)); | |
524 if (!primitiveValue->isURI()) | |
525 return; | |
526 | |
527 url = primitiveValue->getStringValue(); | |
528 value = list->item(1); | 510 value = list->item(1); |
529 } | 511 } |
530 if (value->isPrimitiveValue()) { | 512 |
531 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 513 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
532 Color color; | 514 Color color; |
533 SVGPaintType paintType = SVG_PAINTTYPE_RGBCOLOR; | 515 SVGPaintType paintType = SVG_PAINTTYPE_RGBCOLOR; |
534 if (primitiveValue->getValueID() == CSSValueNone) { | 516 if (primitiveValue->getValueID() == CSSValueNone) { |
535 paintType = url.isEmpty() ? SVG_PAINTTYPE_NONE : SVG_PAINTTYPE_URI_N
ONE; | 517 paintType = url.isEmpty() ? SVG_PAINTTYPE_NONE : SVG_PAINTTYPE_URI_NONE; |
536 } else if (primitiveValue->isURI()) { | 518 } else if (primitiveValue->isURI()) { |
537 paintType = SVG_PAINTTYPE_URI; | 519 paintType = SVG_PAINTTYPE_URI; |
538 url = primitiveValue->getStringValue(); | 520 url = primitiveValue->getStringValue(); |
539 } else if (primitiveValue->getValueID() == CSSValueCurrentcolor) { | 521 } else if (primitiveValue->getValueID() == CSSValueCurrentcolor) { |
540 color = state.style()->color(); | 522 color = state.style()->color(); |
541 paintType = url.isEmpty() ? SVG_PAINTTYPE_CURRENTCOLOR : SVG_PAINTTY
PE_URI_CURRENTCOLOR; | 523 paintType = url.isEmpty() ? SVG_PAINTTYPE_CURRENTCOLOR : SVG_PAINTTYPE_U
RI_CURRENTCOLOR; |
542 } else { | 524 } else { |
543 color = StyleBuilderConverter::convertColor(state, primitiveValue); | 525 color = StyleBuilderConverter::convertColor(state, primitiveValue); |
544 paintType = url.isEmpty() ? SVG_PAINTTYPE_RGBCOLOR : SVG_PAINTTYPE_U
RI_RGBCOLOR; | 526 paintType = url.isEmpty() ? SVG_PAINTTYPE_RGBCOLOR : SVG_PAINTTYPE_URI_R
GBCOLOR; |
545 } | |
546 {{set_value(property)}}(paintType, color, url, | |
547 state.applyPropertyToRegularStyle(), | |
548 state.applyPropertyToVisitedLinkStyle()); | |
549 } | 527 } |
| 528 {{set_value(property)}}(paintType, color, url, |
| 529 state.applyPropertyToRegularStyle(), |
| 530 state.applyPropertyToVisitedLinkStyle()); |
550 } | 531 } |
551 {% endmacro %} | 532 {% endmacro %} |
552 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} | 533 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} |
553 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} | 534 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} |
554 } // namespace blink | 535 } // namespace blink |
OLD | NEW |