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

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

Issue 20061003: Move isValid/isCurrentColor from Color to StyleColor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 {{ apply_value_border_radius("CSSPropertyBorderBottomLeftRadius") }} 266 {{ apply_value_border_radius("CSSPropertyBorderBottomLeftRadius") }}
267 {{ apply_value_border_radius("CSSPropertyBorderBottomRightRadius") }} 267 {{ apply_value_border_radius("CSSPropertyBorderBottomRightRadius") }}
268 {{ apply_value_border_radius("CSSPropertyBorderTopLeftRadius") }} 268 {{ apply_value_border_radius("CSSPropertyBorderTopLeftRadius") }}
269 {{ apply_value_border_radius("CSSPropertyBorderTopRightRadius") }} 269 {{ apply_value_border_radius("CSSPropertyBorderTopRightRadius") }}
270 270
271 {%- macro apply_color(property_id, default_getter="color", initial_color=none, i nherit_color=false) %} 271 {%- macro apply_color(property_id, default_getter="color", initial_color=none, i nherit_color=false) %}
272 {%- set property = properties[property_id] %} 272 {%- set property = properties[property_id] %}
273 {%- set visited_link_setter = "setVisitedLink" + property.camel_case_name %} 273 {%- set visited_link_setter = "setVisitedLink" + property.camel_case_name %}
274 {{ declare_initial_function(property_id) }} 274 {{ declare_initial_function(property_id) }}
275 { 275 {
276 Color color = {{ initial_color or "Color" -}}(); 276 StyleColor color = {{ initial_color or "StyleColor" -}}();
277 if (state.applyPropertyToRegularStyle()) 277 if (state.applyPropertyToRegularStyle())
278 {{ set_value(property) }}(color); 278 {{ set_value(property) }}(color);
279 if (state.applyPropertyToVisitedLinkStyle()) 279 if (state.applyPropertyToVisitedLinkStyle())
280 state.style()->{{visited_link_setter}}(color); 280 state.style()->{{visited_link_setter}}(color);
281 } 281 }
282 282
283 {{ declare_inherit_function(property_id) }} 283 {{ declare_inherit_function(property_id) }}
284 { 284 {
285 // Visited link style can never explicitly inherit from parent visited link style so no separate getters are needed. 285 // Visited link style can never explicitly inherit from parent visited link style so no separate getters are needed.
286 Color color = state.parentStyle()->{{property.getter}}(); 286 StyleColor color = state.parentStyle()->{{property.getter}}();
287 if (!color.isValid()) 287 if (!color.isValid())
288 color = state.parentStyle()->{{default_getter}}(); 288 color = state.parentStyle()->{{default_getter}}();
289 if (state.applyPropertyToRegularStyle()) 289 if (state.applyPropertyToRegularStyle())
290 {{ set_value(property) }}(color); 290 {{ set_value(property) }}(color);
291 if (state.applyPropertyToVisitedLinkStyle()) 291 if (state.applyPropertyToVisitedLinkStyle())
292 state.style()->{{visited_link_setter}}(color); 292 state.style()->{{visited_link_setter}}(color);
293 } 293 }
294 294
295 {{ declare_value_function(property_id) }} 295 {{ declare_value_function(property_id) }}
296 { 296 {
297 if (!value->isPrimitiveValue()) 297 if (!value->isPrimitiveValue())
298 return; 298 return;
299 299
300 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 300 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
301 301
302 {%- if inherit_color %} 302 {%- if inherit_color %}
303 if (primitiveValue->getValueID() == CSSValueCurrentcolor) { 303 if (primitiveValue->getValueID() == CSSValueCurrentcolor) {
304 applyInherit{{property_id}}(styleResolver, state); 304 applyInherit{{property_id}}(styleResolver, state);
305 return; 305 return;
306 } 306 }
307 {%- endif %} 307 {%- endif %}
308 308
309 if (state.applyPropertyToRegularStyle()) 309 if (state.applyPropertyToRegularStyle())
310 {{ set_value(property) }}(state.document()->textLinkColors().colorFromPr imitiveValue(primitiveValue, state.style()->visitedDependentColor(CSSPropertyCol or))); 310 {{ set_value(property) }}(state.document()->textLinkColors().colorFromPr imitiveValue(primitiveValue));
311 if (state.applyPropertyToVisitedLinkStyle()) 311 if (state.applyPropertyToVisitedLinkStyle())
312 state.style()->{{visited_link_setter}}(state.document()->textLinkColors( ).colorFromPrimitiveValue(primitiveValue, state.style()->visitedDependentColor(C SSPropertyColor), state.element()->isLink() /* forVisitedLink */)); 312 state.style()->{{visited_link_setter}}(state.document()->textLinkColors( ).colorFromPrimitiveValue(primitiveValue, state.element()->isLink() /* forVisite dLink */));
313 } 313 }
314 {%- endmacro %} 314 {%- endmacro %}
315 315
316 {{ apply_color("CSSPropertyBackgroundColor", default_getter="invalidColor") }} 316 {{ apply_color("CSSPropertyBackgroundColor", default_getter="invalidColor") }}
317 {{ apply_color("CSSPropertyBorderBottomColor") }} 317 {{ apply_color("CSSPropertyBorderBottomColor") }}
318 {{ apply_color("CSSPropertyBorderLeftColor") }} 318 {{ apply_color("CSSPropertyBorderLeftColor") }}
319 {{ apply_color("CSSPropertyBorderRightColor") }} 319 {{ apply_color("CSSPropertyBorderRightColor") }}
320 {{ apply_color("CSSPropertyBorderTopColor") }} 320 {{ apply_color("CSSPropertyBorderTopColor") }}
321 {{ apply_color("CSSPropertyColor", inherit_color=true, default_getter="invalidCo lor", initial_color="RenderStyle::initialColor") }} 321 {{ apply_color("CSSPropertyColor", inherit_color=true, default_getter="invalidCo lor", initial_color="RenderStyle::initialColor") }}
322 {{ apply_color("CSSPropertyOutlineColor") }} 322 {{ apply_color("CSSPropertyOutlineColor") }}
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 } 638 }
639 {%- endmacro %} 639 {%- endmacro %}
640 640
641 {{ apply_value_string("CSSPropertyWebkitHighlight", "CSSValueNone") }} 641 {{ apply_value_string("CSSPropertyWebkitHighlight", "CSSValueNone") }}
642 {{ apply_value_string("CSSPropertyWebkitHyphenateCharacter", "CSSValueAuto") }} 642 {{ apply_value_string("CSSPropertyWebkitHyphenateCharacter", "CSSValueAuto") }}
643 {{ apply_value_string("CSSPropertyWebkitLineGrid", "CSSValueNone") }} 643 {{ apply_value_string("CSSPropertyWebkitLineGrid", "CSSValueNone") }}
644 {{ apply_value_string("CSSPropertyWebkitFlowFrom", "CSSValueNone") }} 644 {{ apply_value_string("CSSPropertyWebkitFlowFrom", "CSSValueNone") }}
645 {{ apply_value_string("CSSPropertyWebkitFlowInto", "CSSValueNone") }} 645 {{ apply_value_string("CSSPropertyWebkitFlowInto", "CSSValueNone") }}
646 646
647 } // namespace WebCore 647 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698