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

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

Issue 1306823004: Split out String, URI and CustomIdent from CSSPrimitiveValue (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@split_out_attr_values
Patch Set: Fixing tests Created 5 years, 3 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/CSSStringValueBase.h"
16 #include "core/css/CSSValuePair.h" 17 #include "core/css/CSSValuePair.h"
17 #include "core/css/resolver/StyleResolverState.h" 18 #include "core/css/resolver/StyleResolverState.h"
18 19
19 {% macro declare_initial_function(property_id) %} 20 {% macro declare_initial_function(property_id) %}
20 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat e) 21 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat e)
21 {%- endmacro %} 22 {%- endmacro %}
22 {% macro declare_inherit_function(property_id) %} 23 {% macro declare_inherit_function(property_id) %}
23 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat e) 24 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat e)
24 {%- endmacro %} 25 {%- endmacro %}
25 {% macro declare_value_function(property_id) %} 26 {% macro declare_value_function(property_id) %}
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 return; 341 return;
341 } 342 }
342 343
343 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); 344 CounterDirectiveMap& map = state.style()->accessCounterDirectives();
344 345
345 CSSValueList* list = toCSSValueList(value); 346 CSSValueList* list = toCSSValueList(value);
346 347
347 int length = list ? list->length() : 0; 348 int length = list ? list->length() : 0;
348 for (int i = 0; i < length; ++i) { 349 for (int i = 0; i < length; ++i) {
349 const CSSValuePair* pair = toCSSValuePair(list->item(i)); 350 const CSSValuePair* pair = toCSSValuePair(list->item(i));
350 AtomicString identifier(toCSSPrimitiveValue(pair->first()).getStringValu e()); 351 AtomicString identifier(toCSSCustomIdentValue(pair->first()).value());
351 int value = toCSSPrimitiveValue(pair->second()).getIntValue(); 352 int value = toCSSPrimitiveValue(pair->second()).getIntValue();
352 CounterDirectives& directives = map.add(identifier, CounterDirectives()) .storedValue->value; 353 CounterDirectives& directives = map.add(identifier, CounterDirectives()) .storedValue->value;
353 {% if action == 'Reset' %} 354 {% if action == 'Reset' %}
354 directives.setResetValue(value); 355 directives.setResetValue(value);
355 {% else %} 356 {% else %}
356 directives.addIncrementValue(value); 357 directives.addIncrementValue(value);
357 {% endif %} 358 {% endif %}
358 } 359 }
359 ASSERT(!map.isEmpty()); 360 ASSERT(!map.isEmpty());
360 } 361 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 state.applyPropertyToRegularStyle(), 498 state.applyPropertyToRegularStyle(),
498 state.applyPropertyToVisitedLinkStyle()); 499 state.applyPropertyToVisitedLinkStyle());
499 } 500 }
500 501
501 {{declare_value_function(property_id)}} 502 {{declare_value_function(property_id)}}
502 { 503 {
503 String url; 504 String url;
504 if (value->isValueList()) { 505 if (value->isValueList()) {
505 CSSValueList* list = toCSSValueList(value); 506 CSSValueList* list = toCSSValueList(value);
506 ASSERT(list->length() == 2); 507 ASSERT(list->length() == 2);
507 url = toCSSPrimitiveValue(list->item(0))->getStringValue(); 508 url = toCSSURIValue(list->item(0))->value();
508 value = list->item(1); 509 value = list->item(1);
509 } 510 }
510 511
511 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
512 Color color; 512 Color color;
513 SVGPaintType paintType = SVG_PAINTTYPE_RGBCOLOR; 513 SVGPaintType paintType = SVG_PAINTTYPE_RGBCOLOR;
514 if (primitiveValue->getValueID() == CSSValueNone) { 514 if (value->isURIValue()) {
515 paintType = url.isEmpty() ? SVG_PAINTTYPE_NONE : SVG_PAINTTYPE_URI_NONE;
516 } else if (primitiveValue->isURI()) {
517 paintType = SVG_PAINTTYPE_URI; 515 paintType = SVG_PAINTTYPE_URI;
518 url = primitiveValue->getStringValue(); 516 url = toCSSURIValue(value)->value();
519 } else if (primitiveValue->getValueID() == CSSValueCurrentcolor) {
520 color = state.style()->color();
521 paintType = url.isEmpty() ? SVG_PAINTTYPE_CURRENTCOLOR : SVG_PAINTTYPE_U RI_CURRENTCOLOR;
522 } else { 517 } else {
523 color = StyleBuilderConverter::convertColor(state, primitiveValue); 518 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
524 paintType = url.isEmpty() ? SVG_PAINTTYPE_RGBCOLOR : SVG_PAINTTYPE_URI_R GBCOLOR; 519 if (primitiveValue->getValueID() == CSSValueNone) {
520 paintType = url.isEmpty() ? SVG_PAINTTYPE_NONE : SVG_PAINTTYPE_URI_N ONE;
521 } else if (primitiveValue->getValueID() == CSSValueCurrentcolor) {
522 color = state.style()->color();
523 paintType = url.isEmpty() ? SVG_PAINTTYPE_CURRENTCOLOR : SVG_PAINTTY PE_URI_CURRENTCOLOR;
524 } else {
525 color = StyleBuilderConverter::convertColor(state, primitiveValue);
526 paintType = url.isEmpty() ? SVG_PAINTTYPE_RGBCOLOR : SVG_PAINTTYPE_U RI_RGBCOLOR;
527 }
525 } 528 }
526 {{set_value(property)}}(paintType, color, url, 529 {{set_value(property)}}(paintType, color, url,
527 state.applyPropertyToRegularStyle(), 530 state.applyPropertyToRegularStyle(),
528 state.applyPropertyToVisitedLinkStyle()); 531 state.applyPropertyToVisitedLinkStyle());
529 } 532 }
530 {% endmacro %} 533 {% endmacro %}
531 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} 534 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}}
532 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} 535 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}}
533 } // namespace blink 536 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/core/animation/DeferredLegacyStyleInterpolation.cpp » ('j') | Source/core/css/CSSStringValueBase.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698