Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: Source/build/scripts/templates/StyleBuilderFunctions.cpp.tmpl

Issue 186403002: Make font-related CSS properties less custom. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 {% from "macros.tmpl" import lower_first -%} 1 {% from "macros.tmpl" import lower_first -%}
2 2
3 {# 3 {#
4 This file is for property handlers which use the templating engine to 4 This file is for property handlers which use the templating engine to
5 reduce (handwritten) code duplication. 5 reduce (handwritten) code duplication.
6 6
7 The `properties' dict can be used to access a property's parameters in 7 The `properties' dict can be used to access a property's parameters in
8 jinja2 templates (i.e. setter, getter, initial, type_name) 8 jinja2 templates (i.e. setter, getter, initial, type_name)
9 -#} 9 -#}
10 10
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 {{ apply_fill_layer("CSSPropertyWebkitMaskClip", "Clip") }} 419 {{ apply_fill_layer("CSSPropertyWebkitMaskClip", "Clip") }}
420 {{ apply_fill_layer("CSSPropertyWebkitMaskComposite", "Composite") }} 420 {{ apply_fill_layer("CSSPropertyWebkitMaskComposite", "Composite") }}
421 {{ apply_fill_layer("CSSPropertyWebkitMaskImage", "Image") }} 421 {{ apply_fill_layer("CSSPropertyWebkitMaskImage", "Image") }}
422 {{ apply_fill_layer("CSSPropertyWebkitMaskOrigin", "Origin") }} 422 {{ apply_fill_layer("CSSPropertyWebkitMaskOrigin", "Origin") }}
423 {{ apply_fill_layer("CSSPropertyWebkitMaskPositionX", "XPosition") }} 423 {{ apply_fill_layer("CSSPropertyWebkitMaskPositionX", "XPosition") }}
424 {{ apply_fill_layer("CSSPropertyWebkitMaskPositionY", "YPosition") }} 424 {{ apply_fill_layer("CSSPropertyWebkitMaskPositionY", "YPosition") }}
425 {{ apply_fill_layer("CSSPropertyWebkitMaskRepeatX", "RepeatX") }} 425 {{ apply_fill_layer("CSSPropertyWebkitMaskRepeatX", "RepeatX") }}
426 {{ apply_fill_layer("CSSPropertyWebkitMaskRepeatY", "RepeatY") }} 426 {{ apply_fill_layer("CSSPropertyWebkitMaskRepeatY", "RepeatY") }}
427 {{ apply_fill_layer("CSSPropertyWebkitMaskSize", "Size") }} 427 {{ apply_fill_layer("CSSPropertyWebkitMaskSize", "Size") }}
428 428
429 {%- macro apply_font(property_id, name_for_methods, initial, type_name) %}
430 {#- We specify the getters/setters here since they are on FontDescription
431 and not RenderStyle #}
432 {%- set getter = lower_first(name_for_methods) %}
433 {%- set setter = "set" + name_for_methods %}
434 {{ declare_initial_function(property_id) }}
435 {
436 state.fontBuilder().{{setter}}({{initial}});
437 }
438
439 {{ declare_inherit_function(property_id) }}
440 {
441 state.fontBuilder().{{setter}}(state.parentFontDescription().{{getter}}());
442 }
443
444 {{ declare_value_function(property_id) }}
445 {
446 if (!value->isPrimitiveValue())
447 return;
448 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
449 state.fontBuilder().{{setter}}(static_cast<{{type_name}}>(*primitiveValue));
450 }
451 {%- endmacro %}
452
453 {{ apply_font("CSSPropertyFontStyle", "Italic", "FontItalicOff", "FontItalic") } }
454 {{ apply_font("CSSPropertyFontVariant", "SmallCaps", "FontSmallCapsOff", "FontSm allCaps") }}
455 {{ apply_font("CSSPropertyTextRendering", "TextRenderingMode", "AutoTextRenderin g", "TextRenderingMode") }}
456 {{ apply_font("CSSPropertyFontKerning", "Kerning", "FontDescription::AutoKerning ", "FontDescription::Kerning") }}
457 {{ apply_font("CSSPropertyWebkitFontSmoothing", "FontSmoothing", "AutoSmoothing" , "FontSmoothingMode") }}
458
459 {%- macro apply_value_number(property_id, id_for_minus_one) %} 429 {%- macro apply_value_number(property_id, id_for_minus_one) %}
460 {{ declare_value_function(property_id) }} 430 {{ declare_value_function(property_id) }}
461 { 431 {
462 {%- set property = properties[property_id] %} 432 {%- set property = properties[property_id] %}
463 if (!value->isPrimitiveValue()) 433 if (!value->isPrimitiveValue())
464 return; 434 return;
465 435
466 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 436 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
467 if (primitiveValue->getValueID() == {{id_for_minus_one}}) 437 if (primitiveValue->getValueID() == {{id_for_minus_one}})
468 {{ set_value(property) }}(-1); 438 {{ set_value(property) }}(-1);
(...skipping 25 matching lines...) Expand all
494 } else if (value->isImageValue() || value->isImageSetValue()) { 464 } else if (value->isImageValue() || value->isImageSetValue()) {
495 {{ set_value(property) }}(ShapeValue::createImageValue(state.styleImage( {{property_id}}, value))); 465 {{ set_value(property) }}(ShapeValue::createImageValue(state.styleImage( {{property_id}}, value)));
496 } 466 }
497 } 467 }
498 {%- endmacro %} 468 {%- endmacro %}
499 469
500 {{ apply_value_shape("CSSPropertyShapeInside") }} 470 {{ apply_value_shape("CSSPropertyShapeInside") }}
501 {{ apply_value_shape("CSSPropertyShapeOutside") }} 471 {{ apply_value_shape("CSSPropertyShapeOutside") }}
502 472
503 } // namespace WebCore 473 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698