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

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

Issue 1238943004: CSSValue Immediates: Replace CSSValue usage with const references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_1
Patch Set: Rebase Created 5 years, 4 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
OLDNEW
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/Pair.h" 16 #include "core/css/Pair.h"
17 #include "core/css/resolver/StyleResolverState.h" 17 #include "core/css/resolver/StyleResolverState.h"
18 18
19 {% macro declare_initial_function(property_id) %} 19 {% macro declare_initial_function(property_id) %}
20 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat e) 20 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat e)
21 {%- endmacro %} 21 {%- endmacro %}
22 {% macro declare_inherit_function(property_id) %} 22 {% macro declare_inherit_function(property_id) %}
23 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat e) 23 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat e)
24 {%- endmacro %} 24 {%- endmacro %}
25 {% macro declare_value_function(property_id) %} 25 {% macro declare_value_function(property_id) %}
26 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state, CSSValue value) 26 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state, const CSSValue& value)
27 {%- endmacro %} 27 {%- endmacro %}
28 {% macro set_value(property) %} 28 {% macro set_value(property) %}
29 {% if property.svg %} 29 {% if property.svg %}
30 state.style()->accessSVGStyle().{{property.setter}} 30 state.style()->accessSVGStyle().{{property.setter}}
31 {%- elif property.font %} 31 {%- elif property.font %}
32 state.fontBuilder().{{property.setter}} 32 state.fontBuilder().{{property.setter}}
33 {%- else %} 33 {%- else %}
34 state.style()->{{property.setter}} 34 state.style()->{{property.setter}}
35 {%- endif %} 35 {%- endif %}
36 {% endmacro %} 36 {% endmacro %}
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 svgParentStyle.{{paint_type|lower_first}}Type(), 506 svgParentStyle.{{paint_type|lower_first}}Type(),
507 svgParentStyle.{{paint_type|lower_first}}Color(), 507 svgParentStyle.{{paint_type|lower_first}}Color(),
508 svgParentStyle.{{paint_type|lower_first}}Uri(), 508 svgParentStyle.{{paint_type|lower_first}}Uri(),
509 state.applyPropertyToRegularStyle(), 509 state.applyPropertyToRegularStyle(),
510 state.applyPropertyToVisitedLinkStyle()); 510 state.applyPropertyToVisitedLinkStyle());
511 } 511 }
512 512
513 {{declare_value_function(property_id)}} 513 {{declare_value_function(property_id)}}
514 { 514 {
515 String url; 515 String url;
516 if (value.isValueList()) { 516 CSSValue valueToUse = value;
517 CSSValueList& list = toCSSValueList(value); 517 if (valueToUse.isValueList()) {
518 CSSValueList& list = toCSSValueList(valueToUse);
518 ASSERT(list.length() > 1); 519 ASSERT(list.length() > 1);
519 520
520 if (!list.item(0).isPrimitiveValue()) 521 if (!list.item(0).isPrimitiveValue())
521 return; 522 return;
522 523
523 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(list.item(0)); 524 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(list.item(0));
524 if (!primitiveValue.isURI()) 525 if (!primitiveValue.isURI())
525 return; 526 return;
526 527
527 url = primitiveValue.getStringValue(); 528 url = primitiveValue.getStringValue();
528 value = list.item(1); 529 valueToUse = list.item(1);
529 } 530 }
530 if (value.isPrimitiveValue()) { 531 if (valueToUse.isPrimitiveValue()) {
531 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 532 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(valueToUse);
532 Color color; 533 Color color;
533 SVGPaintType paintType = SVG_PAINTTYPE_RGBCOLOR; 534 SVGPaintType paintType = SVG_PAINTTYPE_RGBCOLOR;
534 if (primitiveValue.getValueID() == CSSValueNone) { 535 if (primitiveValue.getValueID() == CSSValueNone) {
535 paintType = url.isEmpty() ? SVG_PAINTTYPE_NONE : SVG_PAINTTYPE_URI_N ONE; 536 paintType = url.isEmpty() ? SVG_PAINTTYPE_NONE : SVG_PAINTTYPE_URI_N ONE;
536 } else if (primitiveValue.isURI()) { 537 } else if (primitiveValue.isURI()) {
537 paintType = SVG_PAINTTYPE_URI; 538 paintType = SVG_PAINTTYPE_URI;
538 url = primitiveValue.getStringValue(); 539 url = primitiveValue.getStringValue();
539 } else if (primitiveValue.getValueID() == CSSValueCurrentcolor) { 540 } else if (primitiveValue.getValueID() == CSSValueCurrentcolor) {
540 color = state.style()->color(); 541 color = state.style()->color();
541 paintType = url.isEmpty() ? SVG_PAINTTYPE_CURRENTCOLOR : SVG_PAINTTY PE_URI_CURRENTCOLOR; 542 paintType = url.isEmpty() ? SVG_PAINTTYPE_CURRENTCOLOR : SVG_PAINTTY PE_URI_CURRENTCOLOR;
542 } else { 543 } else {
543 color = StyleBuilderConverter::convertColor(state, value); 544 color = StyleBuilderConverter::convertColor(state, valueToUse);
544 paintType = url.isEmpty() ? SVG_PAINTTYPE_RGBCOLOR : SVG_PAINTTYPE_U RI_RGBCOLOR; 545 paintType = url.isEmpty() ? SVG_PAINTTYPE_RGBCOLOR : SVG_PAINTTYPE_U RI_RGBCOLOR;
545 } 546 }
546 {{set_value(property)}}(paintType, color, url, 547 {{set_value(property)}}(paintType, color, url,
547 state.applyPropertyToRegularStyle(), 548 state.applyPropertyToRegularStyle(),
548 state.applyPropertyToVisitedLinkStyle()); 549 state.applyPropertyToVisitedLinkStyle());
549 } 550 }
550 } 551 }
551 {% endmacro %} 552 {% endmacro %}
552 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} 553 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}}
553 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} 554 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}}
554 } // namespace blink 555 } // namespace blink
OLDNEW
« no previous file with comments | « Source/build/scripts/templates/StyleBuilder.cpp.tmpl ('k') | Source/build/scripts/templates/StyleBuilderFunctions.h.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698