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

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

Powered by Google App Engine
This is Rietveld 408576698