1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619
|
{% from 'macros.tmpl' import license %}
{#
This file is for property handlers which use the templating engine to
reduce (handwritten) code duplication.
The `properties' dict can be used to access a property's parameters in
jinja2 templates (i.e. setter, getter, initial, type_name)
#}
#include "config.h"
#include "StyleBuilderFunctions.h"
#include "CSSValueKeywords.h"
#include "core/css/BasicShapeFunctions.h"
#include "core/css/CSSPrimitiveValueMappings.h"
#include "core/css/Pair.h"
#include "core/css/resolver/StyleResolverState.h"
{% macro declare_initial_function(property_id) %}
void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& state)
{%- endmacro %}
{% macro declare_inherit_function(property_id) %}
void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& state)
{%- endmacro %}
{% macro declare_value_function(property_id) %}
void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state, CSSValue* value)
{%- endmacro %}
{% macro set_value(property) %}
{% if property.svg %}
state.style()->accessSVGStyle()->{{property.setter}}
{%- elif property.font %}
state.fontBuilder().{{property.setter}}
{%- else %}
state.style()->{{property.setter}}
{%- endif %}
{% endmacro %}
namespace WebCore {
{% for property_id, property in properties.items() if property.should_declare_functions %}
{% set apply_type = property.apply_type %}
{% if not property.custom_initial %}
{{declare_initial_function(property_id)}}
{
{% if property.svg %}
{{set_value(property)}}(SVGRenderStyle::{{property.initial}}());
{% elif property.font %}
{{set_value(property)}}(FontBuilder::{{property.initial}}());
{% else %}
{{set_value(property)}}(RenderStyle::{{property.initial}}());
{% endif %}
}
{% endif %}
{% if not property.custom_inherit %}
{{declare_inherit_function(property_id)}}
{
{% if property.svg %}
{{set_value(property)}}(state.parentStyle()->svgStyle()->{{property.getter}}());
{% elif property.font %}
{{set_value(property)}}(state.parentFontDescription().{{property.getter}}());
{% else %}
{{set_value(property)}}(state.parentStyle()->{{property.getter}}());
{% endif %}
}
{% endif %}
{% if not property.custom_value %}
{{declare_value_function(property_id)}}
{
{% if property.converter %}
{{set_value(property)}}(StyleBuilderConverter::{{property.converter}}(state, value));
{% else %}
{{set_value(property)}}(static_cast<{{property.type_name}}>(*toCSSPrimitiveValue(value)));
{% endif %}
}
{% endif %}
{% endfor %}
{% macro apply_animation(property_id, attribute, animation) %}
{% set vector = attribute|lower_first + "List()" %}
{{declare_initial_function(property_id)}}
{
CSS{{animation}}Data& data = state.style()->access{{animation}}s();
data.{{vector}}.clear();
data.{{vector}}.append(CSS{{animation}}Data::initial{{attribute}}());
}
{{declare_inherit_function(property_id)}}
{
const CSS{{animation}}Data* parentData = state.parentStyle()->{{animation|lower}}s();
if (!parentData)
applyInitial{{property_id}}(state);
else
state.style()->access{{animation}}s().{{vector}} = parentData->{{vector}};
}
{{declare_value_function(property_id)}}
{
CSS{{animation}}Data& data = state.style()->access{{animation}}s();
data.{{vector}}.clear();
for (CSSValueListIterator i = value; i.hasMore(); i.advance())
data.{{vector}}.append(state.styleMap().mapAnimation{{attribute}}(i.value()));
}
{% endmacro %}
{{apply_animation('CSSPropertyWebkitAnimationDelay', 'Delay', 'Animation')}}
{{apply_animation('CSSPropertyWebkitAnimationDirection', 'Direction', 'Animation')}}
{{apply_animation('CSSPropertyWebkitAnimationDuration', 'Duration', 'Animation')}}
{{apply_animation('CSSPropertyWebkitAnimationFillMode', 'FillMode', 'Animation')}}
{{apply_animation('CSSPropertyWebkitAnimationIterationCount', 'IterationCount', 'Animation')}}
{{apply_animation('CSSPropertyWebkitAnimationName', 'Name', 'Animation')}}
{{apply_animation('CSSPropertyWebkitAnimationPlayState', 'PlayState', 'Animation')}}
{{apply_animation('CSSPropertyWebkitAnimationTimingFunction', 'TimingFunction', 'Animation')}}
{{apply_animation('CSSPropertyWebkitTransitionDelay', 'Delay', 'Transition')}}
{{apply_animation('CSSPropertyWebkitTransitionDuration', 'Duration', 'Transition')}}
{{apply_animation('CSSPropertyWebkitTransitionProperty', 'Property', 'Transition')}}
{{apply_animation('CSSPropertyWebkitTransitionTimingFunction', 'TimingFunction', 'Transition')}}
{% macro apply_auto(property_id, auto_getter=none, auto_setter=none, auto_identity='CSSValueAuto', compute_length=false) %}
{% set property = properties[property_id] %}
{% set auto_getter = auto_getter or 'hasAuto' + property.camel_case_name %}
{% set auto_setter = auto_setter or 'setHasAuto' + property.camel_case_name %}
{{declare_initial_function(property_id)}}
{
state.style()->{{auto_setter}}();
}
{{declare_inherit_function(property_id)}}
{
if (state.parentStyle()->{{auto_getter}}())
state.style()->{{auto_setter}}();
else
{{set_value(property)}}(state.parentStyle()->{{property.getter}}());
}
{{declare_value_function(property_id)}}
{
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (primitiveValue->getValueID() == {{auto_identity}})
state.style()->{{auto_setter}}();
else
{% if compute_length %}
{{set_value(property)}}(primitiveValue->computeLength<{{property.type_name}}>(state.cssToLengthConversionData()));
{% else %}
{{set_value(property)}}(*primitiveValue);
{% endif %}
}
{% endmacro %}
{{apply_auto('CSSPropertyOrphans')}}
{{apply_auto('CSSPropertyWebkitColumnCount')}}
{{apply_auto('CSSPropertyWebkitColumnGap', auto_getter='hasNormalColumnGap', auto_setter='setHasNormalColumnGap', auto_identity='CSSValueNormal', compute_length=true)}}
{{apply_auto('CSSPropertyWebkitColumnWidth', compute_length=true)}}
{{apply_auto('CSSPropertyWidows')}}
{{apply_auto('CSSPropertyZIndex')}}
static bool lengthTypeAndValueMatch(const Length& length, LengthType type, float value)
{
return length.type() == type && length.value() == value;
}
static bool lengthTypeAndValueMatch(const LengthBox& lengthBox, LengthType type, float value)
{
return (lengthTypeAndValueMatch(lengthBox.left(), type, value)
&& lengthTypeAndValueMatch(lengthBox.right(), type, value)
&& lengthTypeAndValueMatch(lengthBox.top(), type, value)
&& lengthTypeAndValueMatch(lengthBox.bottom(), type, value));
}
static bool lengthTypeAndValueMatch(const BorderImageLength& borderImageLength, LengthType type, float value)
{
return borderImageLength.isLength() && lengthTypeAndValueMatch(borderImageLength.length(), type, value);
}
static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengthBox, LengthType type, float value)
{
return (lengthTypeAndValueMatch(borderImageLengthBox.left(), type, value)
&& lengthTypeAndValueMatch(borderImageLengthBox.right(), type, value)
&& lengthTypeAndValueMatch(borderImageLengthBox.top(), type, value)
&& lengthTypeAndValueMatch(borderImageLengthBox.bottom(), type, value));
}
{% macro apply_border_image_modifier(property_id, modifier_type) %}
{% set is_mask_box = 'MaskBox' in property_id %}
{% set getter = 'maskBoxImage' if is_mask_box else 'borderImage' %}
{% set setter = 'setMaskBoxImage' if is_mask_box else 'setBorderImage' %}
{{ declare_initial_function(property_id) }}
{
const NinePieceImage& currentImage = state.style()->{{getter}}();
{# Check for equality in case we can bail out before creating a new NinePieceImage. #}
{% if modifier_type == 'Outset' %}
if (lengthTypeAndValueMatch(currentImage.outset(), Fixed, 0))
return;
{% elif modifier_type == 'Repeat' %}
if (currentImage.horizontalRule() == StretchImageRule && currentImage.verticalRule() == StretchImageRule)
return;
{% elif modifier_type == 'Slice' and is_mask_box %}
// Masks have a different initial value for slices. Preserve the value of 0 for backwards compatibility.
if (currentImage.fill() == true && lengthTypeAndValueMatch(currentImage.imageSlices(), Fixed, 0))
return;
{% elif modifier_type == 'Slice' and not is_mask_box %}
if (currentImage.fill() == false && lengthTypeAndValueMatch(currentImage.imageSlices(), Percent, 100))
return;
{% elif modifier_type == 'Width' and is_mask_box %}
// Masks have a different initial value for widths. Preserve the value of 'auto' for backwards compatibility.
if (lengthTypeAndValueMatch(currentImage.borderSlices(), Auto, 0))
return;
{% elif modifier_type == 'Width' and not is_mask_box %}
if (lengthTypeAndValueMatch(currentImage.borderSlices(), Fixed, 1))
return;
{% endif %}
NinePieceImage image(currentImage);
{% if modifier_type == 'Outset' %}
image.setOutset(Length(0, Fixed));
{% elif modifier_type == 'Repeat' %}
image.setHorizontalRule(StretchImageRule);
image.setVerticalRule(StretchImageRule);
{% elif modifier_type == 'Slice' and is_mask_box %}
image.setImageSlices(LengthBox({{ (['Length(0, Fixed)']*4) | join(', ') }}));
image.setFill(true);
{% elif modifier_type == 'Slice' and not is_mask_box %}
image.setImageSlices(LengthBox({{ (['Length(100, Percent)']*4) | join(', ') }}));
image.setFill(false);
{% elif modifier_type == 'Width' %}
image.setBorderSlices({{ 'Length(Auto)' if is_mask_box else '1.0' }});
{% endif %}
state.style()->{{setter}}(image);
}
{{declare_inherit_function(property_id)}}
{
NinePieceImage image(state.style()->{{getter}}());
{% if modifier_type == 'Outset' %}
image.copyOutsetFrom(state.parentStyle()->{{getter}}());
{% elif modifier_type == 'Repeat' %}
image.copyRepeatFrom(state.parentStyle()->{{getter}}());
{% elif modifier_type == 'Slice' %}
image.copyImageSlicesFrom(state.parentStyle()->{{getter}}());
{% elif modifier_type == 'Width' %}
image.copyBorderSlicesFrom(state.parentStyle()->{{getter}}());
{% endif %}
state.style()->{{setter}}(image);
}
{{declare_value_function(property_id)}}
{
NinePieceImage image(state.style()->{{getter}}());
{% if modifier_type == 'Outset' %}
image.setOutset(state.styleMap().mapNinePieceImageQuad(value));
{% elif modifier_type == 'Repeat' %}
state.styleMap().mapNinePieceImageRepeat(value, image);
{% elif modifier_type == 'Slice' %}
state.styleMap().mapNinePieceImageSlice(value, image);
{% elif modifier_type == 'Width' %}
image.setBorderSlices(state.styleMap().mapNinePieceImageQuad(value));
{% endif %}
state.style()->{{setter}}(image);
}
{% endmacro %}
{{apply_border_image_modifier('CSSPropertyBorderImageOutset', 'Outset')}}
{{apply_border_image_modifier('CSSPropertyBorderImageRepeat', 'Repeat')}}
{{apply_border_image_modifier('CSSPropertyBorderImageSlice', 'Slice')}}
{{apply_border_image_modifier('CSSPropertyBorderImageWidth', 'Width')}}
{{apply_border_image_modifier('CSSPropertyWebkitMaskBoxImageOutset', 'Outset')}}
{{apply_border_image_modifier('CSSPropertyWebkitMaskBoxImageRepeat', 'Repeat')}}
{{apply_border_image_modifier('CSSPropertyWebkitMaskBoxImageSlice', 'Slice')}}
{{apply_border_image_modifier('CSSPropertyWebkitMaskBoxImageWidth', 'Width')}}
{% macro apply_value_border_image_source(property_id) %}
{{declare_value_function(property_id)}}
{
{% set property = properties[property_id] %}
{{set_value(property)}}(state.styleImage({{property_id}}, value));
}
{% endmacro %}
{{apply_value_border_image_source('CSSPropertyBorderImageSource')}}
{{apply_value_border_image_source('CSSPropertyWebkitMaskBoxImageSource')}}
{% macro apply_color(property_id, initial_color='StyleColor::currentColor') %}
{% set property = properties[property_id] %}
{% set visited_link_setter = 'setVisitedLink' + property.camel_case_name %}
{{declare_initial_function(property_id)}}
{
StyleColor color = {{initial_color}}();
if (state.applyPropertyToRegularStyle())
{{set_value(property)}}(color);
if (state.applyPropertyToVisitedLinkStyle())
state.style()->{{visited_link_setter}}(color);
}
{{declare_inherit_function(property_id)}}
{
// Visited link style can never explicitly inherit from parent visited link style so no separate getters are needed.
StyleColor color = state.parentStyle()->{{property.getter}}();
Color resolvedColor = color.resolve(state.parentStyle()->color());
if (state.applyPropertyToRegularStyle())
{{set_value(property)}}(resolvedColor);
if (state.applyPropertyToVisitedLinkStyle())
state.style()->{{visited_link_setter}}(resolvedColor);
}
{{declare_value_function(property_id)}}
{
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (state.applyPropertyToRegularStyle())
{{set_value(property)}}(state.document().textLinkColors().colorFromPrimitiveValue(primitiveValue, state.style()->color()));
if (state.applyPropertyToVisitedLinkStyle())
state.style()->{{visited_link_setter}}(state.document().textLinkColors().colorFromPrimitiveValue(primitiveValue, state.style()->color(), true));
}
{% endmacro %}
{{apply_color('CSSPropertyBackgroundColor', initial_color='RenderStyle::initialBackgroundColor') }}
{{apply_color('CSSPropertyBorderBottomColor')}}
{{apply_color('CSSPropertyBorderLeftColor')}}
{{apply_color('CSSPropertyBorderRightColor')}}
{{apply_color('CSSPropertyBorderTopColor')}}
{{apply_color('CSSPropertyOutlineColor')}}
{{apply_color('CSSPropertyTextDecorationColor')}}
{{apply_color('CSSPropertyWebkitColumnRuleColor')}}
{{apply_color('CSSPropertyWebkitTextEmphasisColor')}}
{{apply_color('CSSPropertyWebkitTextFillColor')}}
{{apply_color('CSSPropertyWebkitTextStrokeColor')}}
{% macro apply_counter(property_id, action) %}
{% set property = properties[property_id] %}
{{declare_initial_function(property_id)}} { }
{{declare_inherit_function(property_id)}}
{
CounterDirectiveMap& map = state.style()->accessCounterDirectives();
CounterDirectiveMap& parentMap = state.parentStyle()->accessCounterDirectives();
typedef CounterDirectiveMap::iterator Iterator;
Iterator end = parentMap.end();
for (Iterator it = parentMap.begin(); it != end; ++it) {
CounterDirectives& directives = map.add(it->key, CounterDirectives()).storedValue->value;
directives.inherit{{action}}(it->value);
}
}
{{declare_value_function(property_id)}}
{
CounterDirectiveMap& map = state.style()->accessCounterDirectives();
typedef CounterDirectiveMap::iterator Iterator;
Iterator end = map.end();
for (Iterator it = map.begin(); it != end; ++it)
it->value.clear{{action}}();
if (!value->isValueList()) {
ASSERT(value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueNone);
return;
}
CSSValueList* list = toCSSValueList(value);
int length = list ? list->length() : 0;
for (int i = 0; i < length; ++i) {
CSSValue* currValue = list->itemWithoutBoundsCheck(i);
if (!currValue->isPrimitiveValue())
continue;
Pair* pair = toCSSPrimitiveValue(currValue)->getPairValue();
if (!pair || !pair->first() || !pair->second())
continue;
AtomicString identifier(pair->first()->getStringValue());
int value = pair->second()->getIntValue();
CounterDirectives& directives = map.add(identifier, CounterDirectives()).storedValue->value;
{% if action == 'Reset' %}
directives.setResetValue(value);
{% else %}
directives.addIncrementValue(value);
{% endif %}
}
}
{% endmacro %}
{{apply_counter('CSSPropertyCounterIncrement', 'Increment')}}
{{apply_counter('CSSPropertyCounterReset', 'Reset')}}
{% macro apply_fill_layer(property_id, fill_type) %}
{% set layer_type = 'Background' if 'Background' in property_id else 'Mask' %}
{% set fill_layer_type = layer_type + 'FillLayer' %}
{% set access_layers = 'access' + layer_type + 'Layers' %}
{% set map_fill = 'mapFill' + fill_type %}
{{declare_initial_function(property_id)}}
{
FillLayer* currChild = state.style()->{{access_layers}}();
currChild->set{{fill_type}}(FillLayer::initialFill{{fill_type}}({{fill_layer_type}}));
for (currChild = currChild->next(); currChild; currChild = currChild->next())
currChild->clear{{fill_type}}();
}
{{declare_inherit_function(property_id)}}
{
FillLayer* currChild = state.style()->{{access_layers}}();
FillLayer* prevChild = 0;
const FillLayer* currParent = state.parentStyle()->{{layer_type|lower}}Layers();
while (currParent && currParent->is{{fill_type}}Set()) {
if (!currChild) {
/* Need to make a new layer.*/
currChild = new FillLayer({{fill_layer_type}});
prevChild->setNext(currChild);
}
currChild->set{{fill_type}}(currParent->{{fill_type|lower_first}}());
prevChild = currChild;
currChild = prevChild->next();
currParent = currParent->next();
}
while (currChild) {
/* Reset any remaining layers to not have the property set. */
currChild->clear{{fill_type}}();
currChild = currChild->next();
}
}
{{declare_value_function(property_id)}}
{
FillLayer* currChild = state.style()->{{access_layers}}();
FillLayer* prevChild = 0;
if (value->isValueList() && !value->isImageSetValue()) {
/* Walk each value and put it into a layer, creating new layers as needed. */
CSSValueList* valueList = toCSSValueList(value);
for (unsigned int i = 0; i < valueList->length(); i++) {
if (!currChild) {
/* Need to make a new layer to hold this value */
currChild = new FillLayer({{fill_layer_type}});
prevChild->setNext(currChild);
}
state.styleMap().{{map_fill}}({{property_id}}, currChild, valueList->itemWithoutBoundsCheck(i));
prevChild = currChild;
currChild = currChild->next();
}
} else {
state.styleMap().{{map_fill}}({{property_id}}, currChild, value);
currChild = currChild->next();
}
while (currChild) {
/* Reset all remaining layers to not have the property set. */
currChild->clear{{fill_type}}();
currChild = currChild->next();
}
}
{% endmacro %}
{{apply_fill_layer('CSSPropertyBackgroundAttachment', 'Attachment')}}
{{apply_fill_layer('CSSPropertyBackgroundBlendMode', 'BlendMode')}}
{{apply_fill_layer('CSSPropertyBackgroundClip', 'Clip')}}
{{apply_fill_layer('CSSPropertyBackgroundImage', 'Image')}}
{{apply_fill_layer('CSSPropertyBackgroundOrigin', 'Origin')}}
{{apply_fill_layer('CSSPropertyBackgroundPositionX', 'XPosition')}}
{{apply_fill_layer('CSSPropertyBackgroundPositionY', 'YPosition')}}
{{apply_fill_layer('CSSPropertyBackgroundRepeatX', 'RepeatX')}}
{{apply_fill_layer('CSSPropertyBackgroundRepeatY', 'RepeatY')}}
{{apply_fill_layer('CSSPropertyBackgroundSize', 'Size')}}
{{apply_fill_layer('CSSPropertyMaskSourceType', 'MaskSourceType')}}
{{apply_fill_layer('CSSPropertyWebkitBackgroundComposite', 'Composite')}}
{{apply_fill_layer('CSSPropertyWebkitMaskClip', 'Clip')}}
{{apply_fill_layer('CSSPropertyWebkitMaskComposite', 'Composite')}}
{{apply_fill_layer('CSSPropertyWebkitMaskImage', 'Image')}}
{{apply_fill_layer('CSSPropertyWebkitMaskOrigin', 'Origin')}}
{{apply_fill_layer('CSSPropertyWebkitMaskPositionX', 'XPosition')}}
{{apply_fill_layer('CSSPropertyWebkitMaskPositionY', 'YPosition')}}
{{apply_fill_layer('CSSPropertyWebkitMaskRepeatX', 'RepeatX')}}
{{apply_fill_layer('CSSPropertyWebkitMaskRepeatY', 'RepeatY')}}
{{apply_fill_layer('CSSPropertyWebkitMaskSize', 'Size')}}
{% macro apply_grid_template(property_id, type) %}
{{declare_initial_function(property_id)}}
{
state.style()->setGridTemplate{{type}}s(RenderStyle::initialGridTemplate{{type}}s());
state.style()->setNamedGrid{{type}}Lines(RenderStyle::initialNamedGrid{{type}}Lines());
state.style()->setOrderedNamedGrid{{type}}Lines(RenderStyle::initialOrderedNamedGrid{{type}}Lines());
}
{{declare_inherit_function(property_id)}}
{
state.style()->setGridTemplate{{type}}s(state.parentStyle()->gridTemplate{{type}}s());
state.style()->setNamedGrid{{type}}Lines(state.parentStyle()->namedGrid{{type}}Lines());
state.style()->setOrderedNamedGrid{{type}}Lines(state.parentStyle()->orderedNamedGrid{{type}}Lines());
}
{{declare_value_function(property_id)}}
{
Vector<GridTrackSize> trackSizes;
NamedGridLinesMap namedGridLines;
OrderedNamedGridLines orderedNamedGridLines;
if (!StyleBuilderConverter::convertGridTrackList(value, trackSizes, namedGridLines, orderedNamedGridLines, state))
return;
const NamedGridAreaMap& namedGridAreas = state.style()->namedGridArea();
if (!namedGridAreas.isEmpty())
StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(namedGridAreas, namedGridLines, For{{type}}s);
state.style()->setGridTemplate{{type}}s(trackSizes);
state.style()->setNamedGrid{{type}}Lines(namedGridLines);
state.style()->setOrderedNamedGrid{{type}}Lines(orderedNamedGridLines);
}
{% endmacro %}
{{apply_grid_template('CSSPropertyGridTemplateColumns', 'Column')}}
{{apply_grid_template('CSSPropertyGridTemplateRows', 'Row')}}
{% macro apply_value_number(property_id, id_for_minus_one) %}
{{declare_value_function(property_id)}}
{
{% set property = properties[property_id] %}
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (primitiveValue->getValueID() == {{id_for_minus_one}})
{{set_value(property)}}(-1);
else
{{set_value(property)}}(primitiveValue->getValue<{{property.type_name}}>(CSSPrimitiveValue::CSS_NUMBER));
}
{% endmacro %}
{{apply_value_number('CSSPropertyInternalMarqueeRepetition', 'CSSValueInfinite')}}
{% macro apply_value_shape(property_id) %}
{{declare_value_function(property_id)}}
{
{% set property = properties[property_id] %}
if (value->isPrimitiveValue()) {
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (primitiveValue->getValueID() == CSSValueNone)
{{set_value(property)}}(nullptr);
} else if (value->isImageValue() || value->isImageGeneratorValue() || value->isImageSetValue()) {
{{set_value(property)}}(ShapeValue::createImageValue(state.styleImage({{property_id}}, value)));
} else if (value->isValueList()) {
RefPtr<BasicShape> shape;
CSSBoxType cssBox = BoxMissing;
CSSValueList* valueList = toCSSValueList(value);
for (unsigned i = 0; i < valueList->length(); ++i) {
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->itemWithoutBoundsCheck(i));
if (primitiveValue->isShape())
shape = basicShapeForValue(state, primitiveValue->getShapeValue());
else if (primitiveValue->getValueID() == CSSValueContentBox
|| primitiveValue->getValueID() == CSSValueBorderBox
|| primitiveValue->getValueID() == CSSValuePaddingBox
|| primitiveValue->getValueID() == CSSValueMarginBox)
cssBox = CSSBoxType(*primitiveValue);
else
return;
}
if (shape)
{{set_value(property)}}(ShapeValue::createShapeValue(shape.release(), cssBox));
else if (cssBox != BoxMissing)
{{set_value(property)}}(ShapeValue::createBoxShapeValue(cssBox));
}
}
{% endmacro %}
{{apply_value_shape('CSSPropertyShapeOutside')}}
{% macro apply_alignment(property_id, alignment_type) %}
{{declare_value_function(property_id)}}
{
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (Pair* pairValue = primitiveValue->getPairValue()) {
state.style()->set{{alignment_type}}(*pairValue->first());
state.style()->set{{alignment_type}}OverflowAlignment(*pairValue->second());
} else {
state.style()->set{{alignment_type}}(*primitiveValue);
// FIXME: We should clear the overflow-alignment mode here and probably
// also set it in the initial and inherit handlers
}
}
{% endmacro %}
{{apply_alignment('CSSPropertyJustifySelf', 'JustifySelf')}}
{{apply_alignment('CSSPropertyAlignItems', 'AlignItems')}}
{{apply_alignment('CSSPropertyAlignSelf', 'AlignSelf')}}
{% macro apply_svg_paint(property_id, paint_type) %}
{% set property = properties[property_id] %}
{{declare_initial_function(property_id)}}
{
{{set_value(property)}}(
SVGRenderStyle::initial{{paint_type}}Type(),
SVGRenderStyle::initial{{paint_type}}Color(),
SVGRenderStyle::initial{{paint_type}}Uri(),
state.applyPropertyToRegularStyle(),
state.applyPropertyToVisitedLinkStyle());
}
{{declare_inherit_function(property_id)}}
{
const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle();
{{set_value(property)}}(
svgParentStyle->{{paint_type|lower_first}}Type(),
svgParentStyle->{{paint_type|lower_first}}Color(),
svgParentStyle->{{paint_type|lower_first}}Uri(),
state.applyPropertyToRegularStyle(),
state.applyPropertyToVisitedLinkStyle());
}
{{declare_value_function(property_id)}}
{
if (value->isSVGPaint()) {
SVGPaint* svgPaint = toSVGPaint(value);
Color color;
if (svgPaint->paintType() == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR
|| svgPaint->paintType() == SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR)
color = state.style()->color();
else
color = svgPaint->color();
{{set_value(property)}}(svgPaint->paintType(),
color,
svgPaint->uri(),
state.applyPropertyToRegularStyle(),
state.applyPropertyToVisitedLinkStyle());
}
}
{% endmacro %}
{{apply_svg_paint('CSSPropertyFill', 'FillPaint')}}
{{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}}
} // namespace WebCore
|