| OLD | NEW |
| (Empty) |
| 1 {% from "macros.tmpl" import lower_first -%} | |
| 2 | |
| 3 {# | |
| 4 This file is for property handlers which use the templating engine to | |
| 5 reduce (handwritten) code duplication. | |
| 6 | |
| 7 The `properties' dict can be used to access a property's parameters in | |
| 8 jinja2 templates (i.e. setter, getter, initial, type_name) | |
| 9 -#} | |
| 10 | |
| 11 #include "config.h" | |
| 12 #include "StyleBuilderFunctions.h" | |
| 13 | |
| 14 #include "CSSValueKeywords.h" | |
| 15 #include "core/css/BasicShapeFunctions.h" | |
| 16 #include "core/css/CSSPrimitiveValueMappings.h" | |
| 17 #include "core/css/Pair.h" | |
| 18 #include "core/css/resolver/StyleResolverState.h" | |
| 19 #include "core/platform/animation/CSSAnimationDataList.h" | |
| 20 | |
| 21 | |
| 22 {%- macro declare_initial_function(property_id) -%} | |
| 23 void StyleBuilderFunctions::applyInitial{{property_id}}(StyleResolverState& stat
e) | |
| 24 {%- endmacro %} | |
| 25 | |
| 26 {%- macro declare_inherit_function(property_id) -%} | |
| 27 void StyleBuilderFunctions::applyInherit{{property_id}}(StyleResolverState& stat
e) | |
| 28 {%- endmacro %} | |
| 29 | |
| 30 {%- macro declare_value_function(property_id) -%} | |
| 31 void StyleBuilderFunctions::applyValue{{property_id}}(StyleResolverState& state,
CSSValue* value) | |
| 32 {%- endmacro %} | |
| 33 | |
| 34 // FIXME: This is duplicated in StyleBuilder.cpp.tmpl, but we'll move the | |
| 35 // function definitions there over to here later. | |
| 36 {%- macro set_value(property) %} | |
| 37 {%- if property.svg -%} | |
| 38 state.style()->accessSVGStyle()->{{property.setter}} | |
| 39 {%- else -%} | |
| 40 state.style()->{{property.setter}} | |
| 41 {%- endif -%} | |
| 42 {%- endmacro %} | |
| 43 | |
| 44 namespace WebCore { | |
| 45 | |
| 46 {%- macro apply_animation(property_id, attribute, animation) %} | |
| 47 {{ declare_initial_function(property_id) }} | |
| 48 { | |
| 49 CSSAnimationDataList* list = state.style()->access{{animation}}(); | |
| 50 if (list->isEmpty()) | |
| 51 list->append(CSSAnimationData::create()); | |
| 52 list->animation(0)->set{{attribute}}(CSSAnimationData::initialAnimation{{att
ribute}}()); | |
| 53 {%- if property_id == "CSSPropertyWebkitTransitionProperty" %} | |
| 54 list->animation(0)->setAnimationMode(CSSAnimationData::AnimateAll); | |
| 55 {%- endif %} | |
| 56 for (size_t i = 1; i < list->size(); ++i) | |
| 57 list->animation(i)->clear{{attribute}}(); | |
| 58 } | |
| 59 | |
| 60 {{ declare_inherit_function(property_id) }} | |
| 61 { | |
| 62 CSSAnimationDataList* list = state.style()->access{{animation}}(); | |
| 63 const CSSAnimationDataList* parentList = state.parentStyle()->{{animation|lo
wer}}(); | |
| 64 size_t i = 0, parentSize = parentList ? parentList->size() : 0; | |
| 65 for ( ; i < parentSize && parentList->animation(i)->is{{attribute}}Set(); ++
i) { | |
| 66 ASSERT(list->size() >= i); | |
| 67 if (list->size() == i) | |
| 68 list->append(CSSAnimationData::create()); | |
| 69 list->animation(i)->set{{attribute}}(parentList->animation(i)->{{lower_f
irst(attribute)}}()); | |
| 70 list->animation(i)->setAnimationMode(parentList->animation(i)->animation
Mode()); | |
| 71 } | |
| 72 | |
| 73 // Reset any remaining animations to not have the property set. | |
| 74 for ( ; i < list->size(); ++i) | |
| 75 list->animation(i)->clear{{attribute}}(); | |
| 76 } | |
| 77 | |
| 78 {{ declare_value_function(property_id) }} | |
| 79 { | |
| 80 CSSAnimationDataList* list = state.style()->access{{animation}}(); | |
| 81 size_t childIndex = 0; | |
| 82 if (value->isValueList()) { | |
| 83 // Walk each value and put it into an animation, creating new animations
as needed. | |
| 84 for (CSSValueListIterator i = value; i.hasMore(); i.advance()) { | |
| 85 ASSERT(list->size() >= childIndex); | |
| 86 if (list->size() == childIndex) | |
| 87 list->append(CSSAnimationData::create()); | |
| 88 state.styleMap().mapAnimation{{attribute}}(list->animation(childInde
x), i.value()); | |
| 89 ++childIndex; | |
| 90 } | |
| 91 } else { | |
| 92 if (list->isEmpty()) | |
| 93 list->append(CSSAnimationData::create()); | |
| 94 state.styleMap().mapAnimation{{attribute}}(list->animation(childIndex),
value); | |
| 95 childIndex = 1; | |
| 96 } | |
| 97 for ( ; childIndex < list->size(); ++childIndex) { | |
| 98 // Reset all remaining animations to not have the property set. | |
| 99 list->animation(childIndex)->clear{{attribute}}(); | |
| 100 } | |
| 101 } | |
| 102 {%- endmacro %} | |
| 103 | |
| 104 {{ apply_animation("CSSPropertyWebkitAnimationDelay", "Delay", "Animations") }} | |
| 105 {{ apply_animation("CSSPropertyWebkitAnimationDirection", "Direction", "Animatio
ns") }} | |
| 106 {{ apply_animation("CSSPropertyWebkitAnimationDuration", "Duration", "Animations
") }} | |
| 107 {{ apply_animation("CSSPropertyWebkitAnimationFillMode", "FillMode", "Animations
") }} | |
| 108 {{ apply_animation("CSSPropertyWebkitAnimationIterationCount", "IterationCount",
"Animations") }} | |
| 109 {{ apply_animation("CSSPropertyWebkitAnimationName", "Name", "Animations") }} | |
| 110 {{ apply_animation("CSSPropertyWebkitAnimationPlayState", "PlayState", "Animatio
ns") }} | |
| 111 {{ apply_animation("CSSPropertyWebkitAnimationTimingFunction", "TimingFunction",
"Animations") }} | |
| 112 {{ apply_animation("CSSPropertyWebkitTransitionDelay", "Delay", "Transitions") }
} | |
| 113 {{ apply_animation("CSSPropertyWebkitTransitionDuration", "Duration", "Transitio
ns") }} | |
| 114 {{ apply_animation("CSSPropertyWebkitTransitionProperty", "Property", "Transitio
ns") }} | |
| 115 {{ apply_animation("CSSPropertyWebkitTransitionTimingFunction", "TimingFunction"
, "Transitions") }} | |
| 116 | |
| 117 {%- macro apply_auto(property_id, auto_getter=none, auto_setter=none, auto_ident
ity="CSSValueAuto", compute_length=false) %} | |
| 118 {%- set property = properties[property_id] %} | |
| 119 {%- set auto_getter = auto_getter or "hasAuto" + property.camel_case_name %} | |
| 120 {%- set auto_setter = auto_setter or "setHasAuto" + property.camel_case_name %} | |
| 121 {{ declare_initial_function(property_id) }} | |
| 122 { | |
| 123 state.style()->{{auto_setter}}(); | |
| 124 } | |
| 125 | |
| 126 {{ declare_inherit_function(property_id) }} | |
| 127 { | |
| 128 if (state.parentStyle()->{{auto_getter}}()) | |
| 129 state.style()->{{auto_setter}}(); | |
| 130 else | |
| 131 {{ set_value(property) }}(state.parentStyle()->{{property.getter}}()); | |
| 132 } | |
| 133 | |
| 134 {{ declare_value_function(property_id) }} | |
| 135 { | |
| 136 if (!value->isPrimitiveValue()) | |
| 137 return; | |
| 138 | |
| 139 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
| 140 if (primitiveValue->getValueID() == {{auto_identity}}) | |
| 141 state.style()->{{auto_setter}}(); | |
| 142 else | |
| 143 {%- if compute_length %} | |
| 144 {{ set_value(property) }}(primitiveValue->computeLength<{{property.type_
name}}>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom())
); | |
| 145 {%- else %} | |
| 146 {{ set_value(property) }}(*primitiveValue); | |
| 147 {%- endif %} | |
| 148 } | |
| 149 {%- endmacro %} | |
| 150 | |
| 151 {{ apply_auto("CSSPropertyOrphans") }} | |
| 152 {{ apply_auto("CSSPropertyWebkitColumnCount") }} | |
| 153 {{ apply_auto("CSSPropertyWebkitColumnGap", auto_getter="hasNormalColumnGap", au
to_setter="setHasNormalColumnGap", auto_identity="CSSValueNormal", compute_lengt
h=true) }} | |
| 154 {{ apply_auto("CSSPropertyWebkitColumnWidth", compute_length=true) }} | |
| 155 {{ apply_auto("CSSPropertyWidows") }} | |
| 156 {{ apply_auto("CSSPropertyZIndex") }} | |
| 157 | |
| 158 {%- macro apply_value_border_image(property_id) %} | |
| 159 {{ declare_value_function(property_id) }} | |
| 160 { | |
| 161 {%- set property = properties[property_id] %} | |
| 162 NinePieceImage image; | |
| 163 {%- if property_id == "CSSPropertyWebkitMaskBoxImage" %} | |
| 164 image.setMaskDefaults(); | |
| 165 {%- endif %} | |
| 166 state.styleMap().mapNinePieceImage(state.style(), {{property_id}}, value, im
age); | |
| 167 {{ set_value(property) }}(image); | |
| 168 } | |
| 169 {%- endmacro %} | |
| 170 | |
| 171 {{ apply_value_border_image("CSSPropertyWebkitBorderImage") }} | |
| 172 {{ apply_value_border_image("CSSPropertyWebkitMaskBoxImage") }} | |
| 173 | |
| 174 {%- macro apply_border_image_modifier(property_id, modifier_type) %} | |
| 175 {%- set is_mask_box = "MaskBox" in property_id %} | |
| 176 {%- set getter = "maskBoxImage" if is_mask_box else "borderImage" %} | |
| 177 {%- set setter = "setMaskBoxImage" if is_mask_box else "setBorderImage" %} | |
| 178 {{ declare_initial_function(property_id) }} | |
| 179 { | |
| 180 NinePieceImage image(state.style()->{{getter}}()); | |
| 181 {%- if modifier_type == "Outset" %} | |
| 182 image.setOutset(LengthBox(0)); | |
| 183 {%- elif modifier_type == "Repeat" %} | |
| 184 image.setHorizontalRule(StretchImageRule); | |
| 185 image.setVerticalRule(StretchImageRule); | |
| 186 {%- elif modifier_type == "Slice" %} | |
| 187 // Masks have a different initial value for slices. Preserve the value of 0
for backwards compatibility. | |
| 188 image.setImageSlices(LengthBox({{ (["Length(100, Percent)"]*4) | join(", ")
if not is_mask_box }})); | |
| 189 image.setFill(false); | |
| 190 {%- elif modifier_type == "Width" %} | |
| 191 // Masks have a different initial value for widths. Preserve the value of 0
for backwards compatibility. | |
| 192 image.setBorderSlices(LengthBox({{ (["Length(1, Relative)"]*4) | join(", ")
if not is_mask_box }})); | |
| 193 {%- endif %} | |
| 194 state.style()->{{setter}}(image); | |
| 195 } | |
| 196 | |
| 197 {{ declare_inherit_function(property_id) }} | |
| 198 { | |
| 199 NinePieceImage image(state.style()->{{getter}}()); | |
| 200 {%- if modifier_type == "Outset" %} | |
| 201 image.copyOutsetFrom(state.parentStyle()->{{getter}}()); | |
| 202 {%- elif modifier_type == "Repeat" %} | |
| 203 image.copyRepeatFrom(state.parentStyle()->{{getter}}()); | |
| 204 {%- elif modifier_type == "Slice" %} | |
| 205 image.copyImageSlicesFrom(state.parentStyle()->{{getter}}()); | |
| 206 {%- elif modifier_type == "Width" %} | |
| 207 image.copyBorderSlicesFrom(state.parentStyle()->{{getter}}()); | |
| 208 {%- endif %} | |
| 209 state.style()->{{setter}}(image); | |
| 210 } | |
| 211 | |
| 212 {{ declare_value_function(property_id) }} | |
| 213 { | |
| 214 NinePieceImage image(state.style()->{{getter}}()); | |
| 215 {%- if modifier_type == "Outset" %} | |
| 216 image.setOutset(state.styleMap().mapNinePieceImageQuad(value)); | |
| 217 {%- elif modifier_type == "Repeat" %} | |
| 218 state.styleMap().mapNinePieceImageRepeat(value, image); | |
| 219 {%- elif modifier_type == "Slice" %} | |
| 220 state.styleMap().mapNinePieceImageSlice(value, image); | |
| 221 {%- elif modifier_type == "Width" %} | |
| 222 image.setBorderSlices(state.styleMap().mapNinePieceImageQuad(value)); | |
| 223 {%- endif %} | |
| 224 state.style()->{{setter}}(image); | |
| 225 } | |
| 226 {%- endmacro %} | |
| 227 | |
| 228 {{ apply_border_image_modifier("CSSPropertyBorderImageOutset", "Outset") }} | |
| 229 {{ apply_border_image_modifier("CSSPropertyBorderImageRepeat", "Repeat") }} | |
| 230 {{ apply_border_image_modifier("CSSPropertyBorderImageSlice", "Slice") }} | |
| 231 {{ apply_border_image_modifier("CSSPropertyBorderImageWidth", "Width") }} | |
| 232 {{ apply_border_image_modifier("CSSPropertyWebkitMaskBoxImageOutset", "Outset")
}} | |
| 233 {{ apply_border_image_modifier("CSSPropertyWebkitMaskBoxImageRepeat", "Repeat")
}} | |
| 234 {{ apply_border_image_modifier("CSSPropertyWebkitMaskBoxImageSlice", "Slice") }} | |
| 235 {{ apply_border_image_modifier("CSSPropertyWebkitMaskBoxImageWidth", "Width") }} | |
| 236 | |
| 237 {%- macro apply_value_border_image_source(property_id) %} | |
| 238 {{ declare_value_function(property_id) }} | |
| 239 { | |
| 240 {%- set property = properties[property_id] %} | |
| 241 {{ set_value(property) }}(state.styleImage({{property_id}}, value)); | |
| 242 } | |
| 243 {%- endmacro %} | |
| 244 | |
| 245 {{ apply_value_border_image_source("CSSPropertyBorderImageSource") }} | |
| 246 {{ apply_value_border_image_source("CSSPropertyWebkitMaskBoxImageSource") }} | |
| 247 | |
| 248 {%- macro apply_color(property_id, default_getter="color", initial_color=none, i
nherit_color=false) %} | |
| 249 {%- set property = properties[property_id] %} | |
| 250 {%- set visited_link_setter = "setVisitedLink" + property.camel_case_name %} | |
| 251 {{ declare_initial_function(property_id) }} | |
| 252 { | |
| 253 Color color = {{ initial_color or "Color" -}}(); | |
| 254 if (state.applyPropertyToRegularStyle()) | |
| 255 {{ set_value(property) }}(color); | |
| 256 if (state.applyPropertyToVisitedLinkStyle()) | |
| 257 state.style()->{{visited_link_setter}}(color); | |
| 258 } | |
| 259 | |
| 260 {{ declare_inherit_function(property_id) }} | |
| 261 { | |
| 262 // Visited link style can never explicitly inherit from parent visited link
style so no separate getters are needed. | |
| 263 Color color = state.parentStyle()->{{property.getter}}(); | |
| 264 if (!color.isValid()) | |
| 265 color = state.parentStyle()->{{default_getter}}(); | |
| 266 if (state.applyPropertyToRegularStyle()) | |
| 267 {{ set_value(property) }}(color); | |
| 268 if (state.applyPropertyToVisitedLinkStyle()) | |
| 269 state.style()->{{visited_link_setter}}(color); | |
| 270 } | |
| 271 | |
| 272 {{ declare_value_function(property_id) }} | |
| 273 { | |
| 274 if (!value->isPrimitiveValue()) | |
| 275 return; | |
| 276 | |
| 277 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
| 278 | |
| 279 {%- if inherit_color %} | |
| 280 if (primitiveValue->getValueID() == CSSValueCurrentcolor) { | |
| 281 applyInherit{{property_id}}(state); | |
| 282 return; | |
| 283 } | |
| 284 {%- endif %} | |
| 285 | |
| 286 if (state.applyPropertyToRegularStyle()) | |
| 287 {{ set_value(property) }}(state.document().textLinkColors().colorFromPri
mitiveValue(primitiveValue, state.style()->visitedDependentColor(CSSPropertyColo
r))); | |
| 288 if (state.applyPropertyToVisitedLinkStyle()) | |
| 289 state.style()->{{visited_link_setter}}(state.document().textLinkColors()
.colorFromPrimitiveValue(primitiveValue, state.style()->visitedDependentColor(CS
SPropertyColor), state.element()->isLink() /* forVisitedLink */)); | |
| 290 } | |
| 291 {%- endmacro %} | |
| 292 | |
| 293 {{ apply_color("CSSPropertyBackgroundColor", default_getter="invalidColor") }} | |
| 294 {{ apply_color("CSSPropertyBorderBottomColor") }} | |
| 295 {{ apply_color("CSSPropertyBorderLeftColor") }} | |
| 296 {{ apply_color("CSSPropertyBorderRightColor") }} | |
| 297 {{ apply_color("CSSPropertyBorderTopColor") }} | |
| 298 {{ apply_color("CSSPropertyColor", inherit_color=true, default_getter="invalidCo
lor", initial_color="RenderStyle::initialColor") }} | |
| 299 {{ apply_color("CSSPropertyOutlineColor") }} | |
| 300 {{ apply_color("CSSPropertyTextDecorationColor") }} | |
| 301 {{ apply_color("CSSPropertyWebkitColumnRuleColor") }} | |
| 302 {{ apply_color("CSSPropertyWebkitTextEmphasisColor") }} | |
| 303 {{ apply_color("CSSPropertyWebkitTextFillColor") }} | |
| 304 {{ apply_color("CSSPropertyWebkitTextStrokeColor") }} | |
| 305 | |
| 306 {%- macro apply_counter(property_id, action) %} | |
| 307 {%- set property = properties[property_id] %} | |
| 308 {{ declare_initial_function(property_id) }} { } | |
| 309 | |
| 310 {{ declare_inherit_function(property_id) }} | |
| 311 { | |
| 312 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); | |
| 313 CounterDirectiveMap& parentMap = state.parentStyle()->accessCounterDirective
s(); | |
| 314 | |
| 315 typedef CounterDirectiveMap::iterator Iterator; | |
| 316 Iterator end = parentMap.end(); | |
| 317 for (Iterator it = parentMap.begin(); it != end; ++it) { | |
| 318 CounterDirectives& directives = map.add(it->key, CounterDirectives()).it
erator->value; | |
| 319 directives.inherit{{action}}(it->value); | |
| 320 } | |
| 321 } | |
| 322 | |
| 323 {{ declare_value_function(property_id) }} | |
| 324 { | |
| 325 if (!value->isValueList()) | |
| 326 return; | |
| 327 | |
| 328 CSSValueList* list = toCSSValueList(value); | |
| 329 | |
| 330 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); | |
| 331 typedef CounterDirectiveMap::iterator Iterator; | |
| 332 | |
| 333 Iterator end = map.end(); | |
| 334 for (Iterator it = map.begin(); it != end; ++it) | |
| 335 it->value.clear{{action}}(); | |
| 336 | |
| 337 int length = list ? list->length() : 0; | |
| 338 for (int i = 0; i < length; ++i) { | |
| 339 CSSValue* currValue = list->itemWithoutBoundsCheck(i); | |
| 340 if (!currValue->isPrimitiveValue()) | |
| 341 continue; | |
| 342 | |
| 343 Pair* pair = toCSSPrimitiveValue(currValue)->getPairValue(); | |
| 344 if (!pair || !pair->first() || !pair->second()) | |
| 345 continue; | |
| 346 | |
| 347 AtomicString identifier = pair->first()->getStringValue(); | |
| 348 int value = pair->second()->getIntValue(); | |
| 349 CounterDirectives& directives = map.add(identifier, CounterDirectives())
.iterator->value; | |
| 350 {%- if action == "Reset" %} | |
| 351 directives.setResetValue(value); | |
| 352 {%- else %} | |
| 353 directives.addIncrementValue(value); | |
| 354 {%- endif %} | |
| 355 } | |
| 356 } | |
| 357 {%- endmacro %} | |
| 358 | |
| 359 {{ apply_counter("CSSPropertyCounterIncrement", "Increment") }} | |
| 360 {{ apply_counter("CSSPropertyCounterReset", "Reset") }} | |
| 361 | |
| 362 {%- macro apply_fill_layer(property_id, fill_type) %} | |
| 363 {%- set layer_type = "Background" if "Background" in property_id else "Mask" %} | |
| 364 {%- set fill_layer_type = layer_type + "FillLayer" %} | |
| 365 {%- set access_layers = "access" + layer_type + "Layers" %} | |
| 366 {%- set map_fill = "mapFill" + fill_type %} | |
| 367 {{ declare_initial_function(property_id) }} | |
| 368 { | |
| 369 FillLayer* currChild = state.style()->{{access_layers}}(); | |
| 370 currChild->set{{fill_type}}(FillLayer::initialFill{{fill_type}}({{fill_layer
_type}})); | |
| 371 for (currChild = currChild->next(); currChild; currChild = currChild->next()
) | |
| 372 currChild->clear{{fill_type}}(); | |
| 373 } | |
| 374 | |
| 375 {{ declare_inherit_function(property_id) }} | |
| 376 { | |
| 377 FillLayer* currChild = state.style()->{{access_layers}}(); | |
| 378 FillLayer* prevChild = 0; | |
| 379 const FillLayer* currParent = state.parentStyle()->{{layer_type|lower}}Layer
s(); | |
| 380 while (currParent && currParent->is{{fill_type}}Set()) { | |
| 381 if (!currChild) { | |
| 382 /* Need to make a new layer.*/ | |
| 383 currChild = new FillLayer({{fill_layer_type}}); | |
| 384 prevChild->setNext(currChild); | |
| 385 } | |
| 386 currChild->set{{fill_type}}(currParent->{{lower_first(fill_type)}}()); | |
| 387 prevChild = currChild; | |
| 388 currChild = prevChild->next(); | |
| 389 currParent = currParent->next(); | |
| 390 } | |
| 391 | |
| 392 while (currChild) { | |
| 393 /* Reset any remaining layers to not have the property set. */ | |
| 394 currChild->clear{{fill_type}}(); | |
| 395 currChild = currChild->next(); | |
| 396 } | |
| 397 } | |
| 398 | |
| 399 {{ declare_value_function(property_id) }} | |
| 400 { | |
| 401 FillLayer* currChild = state.style()->{{access_layers}}(); | |
| 402 FillLayer* prevChild = 0; | |
| 403 if (value->isValueList() && !value->isImageSetValue()) { | |
| 404 /* Walk each value and put it into a layer, creating new layers as neede
d. */ | |
| 405 CSSValueList* valueList = toCSSValueList(value); | |
| 406 for (unsigned int i = 0; i < valueList->length(); i++) { | |
| 407 if (!currChild) { | |
| 408 /* Need to make a new layer to hold this value */ | |
| 409 currChild = new FillLayer({{fill_layer_type}}); | |
| 410 prevChild->setNext(currChild); | |
| 411 } | |
| 412 state.styleMap().{{map_fill}}({{property_id}}, currChild, valueList-
>itemWithoutBoundsCheck(i)); | |
| 413 prevChild = currChild; | |
| 414 currChild = currChild->next(); | |
| 415 } | |
| 416 } else { | |
| 417 state.styleMap().{{map_fill}}({{property_id}}, currChild, value); | |
| 418 currChild = currChild->next(); | |
| 419 } | |
| 420 while (currChild) { | |
| 421 /* Reset all remaining layers to not have the property set. */ | |
| 422 currChild->clear{{fill_type}}(); | |
| 423 currChild = currChild->next(); | |
| 424 } | |
| 425 } | |
| 426 {%- endmacro %} | |
| 427 | |
| 428 {{ apply_fill_layer("CSSPropertyBackgroundAttachment", "Attachment") }} | |
| 429 {{ apply_fill_layer("CSSPropertyBackgroundBlendMode", "BlendMode") }} | |
| 430 {{ apply_fill_layer("CSSPropertyBackgroundClip", "Clip") }} | |
| 431 {{ apply_fill_layer("CSSPropertyBackgroundImage", "Image") }} | |
| 432 {{ apply_fill_layer("CSSPropertyBackgroundOrigin", "Origin") }} | |
| 433 {{ apply_fill_layer("CSSPropertyBackgroundPositionX", "XPosition") }} | |
| 434 {{ apply_fill_layer("CSSPropertyBackgroundPositionY", "YPosition") }} | |
| 435 {{ apply_fill_layer("CSSPropertyBackgroundRepeatX", "RepeatX") }} | |
| 436 {{ apply_fill_layer("CSSPropertyBackgroundRepeatY", "RepeatY") }} | |
| 437 {{ apply_fill_layer("CSSPropertyBackgroundSize", "Size") }} | |
| 438 {{ apply_fill_layer("CSSPropertyMaskSourceType", "MaskSourceType") }} | |
| 439 {{ apply_fill_layer("CSSPropertyWebkitBackgroundComposite", "Composite") }} | |
| 440 {{ apply_fill_layer("CSSPropertyWebkitMaskClip", "Clip") }} | |
| 441 {{ apply_fill_layer("CSSPropertyWebkitMaskComposite", "Composite") }} | |
| 442 {{ apply_fill_layer("CSSPropertyWebkitMaskImage", "Image") }} | |
| 443 {{ apply_fill_layer("CSSPropertyWebkitMaskOrigin", "Origin") }} | |
| 444 {{ apply_fill_layer("CSSPropertyWebkitMaskPositionX", "XPosition") }} | |
| 445 {{ apply_fill_layer("CSSPropertyWebkitMaskPositionY", "YPosition") }} | |
| 446 {{ apply_fill_layer("CSSPropertyWebkitMaskRepeatX", "RepeatX") }} | |
| 447 {{ apply_fill_layer("CSSPropertyWebkitMaskRepeatY", "RepeatY") }} | |
| 448 {{ apply_fill_layer("CSSPropertyWebkitMaskSize", "Size") }} | |
| 449 | |
| 450 {%- macro apply_font(property_id, name_for_methods, initial, type_name) %} | |
| 451 {#- We specify the getters/setters here since they are on FontDescription | |
| 452 and not RenderStyle #} | |
| 453 {%- set getter = lower_first(name_for_methods) %} | |
| 454 {%- set setter = "set" + name_for_methods %} | |
| 455 {{ declare_initial_function(property_id) }} | |
| 456 { | |
| 457 state.fontBuilder().{{setter}}({{initial}}); | |
| 458 } | |
| 459 | |
| 460 {{ declare_inherit_function(property_id) }} | |
| 461 { | |
| 462 state.fontBuilder().{{setter}}(state.parentFontDescription().{{getter}}()); | |
| 463 } | |
| 464 | |
| 465 {{ declare_value_function(property_id) }} | |
| 466 { | |
| 467 if (!value->isPrimitiveValue()) | |
| 468 return; | |
| 469 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
| 470 state.fontBuilder().{{setter}}(static_cast<{{type_name}}>(*primitiveValue)); | |
| 471 } | |
| 472 {%- endmacro %} | |
| 473 | |
| 474 {{ apply_font("CSSPropertyFontStyle", "Italic", "FontItalicOff", "FontItalic") }
} | |
| 475 {{ apply_font("CSSPropertyFontVariant", "SmallCaps", "FontSmallCapsOff", "FontSm
allCaps") }} | |
| 476 {{ apply_font("CSSPropertyTextRendering", "TextRenderingMode", "AutoTextRenderin
g", "TextRenderingMode") }} | |
| 477 {{ apply_font("CSSPropertyWebkitFontKerning", "Kerning", "FontDescription::AutoK
erning", "FontDescription::Kerning") }} | |
| 478 {{ apply_font("CSSPropertyWebkitFontSmoothing", "FontSmoothing", "AutoSmoothing"
, "FontSmoothingMode") }} | |
| 479 | |
| 480 {%- macro apply_value_number(property_id, id_for_minus_one) %} | |
| 481 {{ declare_value_function(property_id) }} | |
| 482 { | |
| 483 {%- set property = properties[property_id] %} | |
| 484 if (!value->isPrimitiveValue()) | |
| 485 return; | |
| 486 | |
| 487 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
| 488 if (primitiveValue->getValueID() == {{id_for_minus_one}}) | |
| 489 {{ set_value(property) }}(-1); | |
| 490 else | |
| 491 {{ set_value(property) }}(primitiveValue->getValue<{{property.type_name}
}>(CSSPrimitiveValue::CSS_NUMBER)); | |
| 492 } | |
| 493 {%- endmacro %} | |
| 494 | |
| 495 {{ apply_value_number("CSSPropertyInternalMarqueeRepetition", "CSSValueInfinite"
) }} | |
| 496 | |
| 497 {%- macro apply_value_shape(property_id) %} | |
| 498 {{ declare_value_function(property_id) }} | |
| 499 { | |
| 500 {%- set property = properties[property_id] %} | |
| 501 if (value->isPrimitiveValue()) { | |
| 502 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
| 503 if (primitiveValue->getValueID() == CSSValueAuto) | |
| 504 {{ set_value(property) }}(0); | |
| 505 else if (primitiveValue->getValueID() == CSSValueOutsideShape) | |
| 506 {{ set_value(property) }}(ShapeValue::createOutsideValue()); | |
| 507 else if (primitiveValue->isShape()) { | |
| 508 {{ set_value(property) }}(ShapeValue::createShapeValue(basicShapeFor
Value(state, primitiveValue->getShapeValue()))); | |
| 509 } | |
| 510 } else if (value->isImageValue()) { | |
| 511 {{ set_value(property) }}(ShapeValue::createImageValue(state.styleImage(
{{property_id}}, value))); | |
| 512 } | |
| 513 } | |
| 514 {%- endmacro %} | |
| 515 | |
| 516 {{ apply_value_shape("CSSPropertyWebkitShapeInside") }} | |
| 517 {{ apply_value_shape("CSSPropertyWebkitShapeOutside") }} | |
| 518 | |
| 519 } // namespace WebCore | |
| OLD | NEW |