Move more CSS properties to the new StyleBuilder
[WebKit-https.git] / Source / WebCore / css / DeprecatedStyleBuilder.cpp
1 /*
2  * Copyright (C) 2011 Google Inc. All rights reserved.
3  * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
4  * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
16  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #include "config.h"
28 #include "DeprecatedStyleBuilder.h"
29
30 #include "BasicShapeFunctions.h"
31 #include "BasicShapes.h"
32 #include "CSSAspectRatioValue.h"
33 #include "CSSCalculationValue.h"
34 #include "CSSCursorImageValue.h"
35 #include "CSSImageGeneratorValue.h"
36 #include "CSSImageSetValue.h"
37 #include "CSSPrimitiveValue.h"
38 #include "CSSPrimitiveValueMappings.h"
39 #include "CSSToStyleMap.h"
40 #include "CSSValueList.h"
41 #include "ClipPathOperation.h"
42 #include "CursorList.h"
43 #include "Document.h"
44 #include "Frame.h"
45 #include "HTMLElement.h"
46 #include "Pair.h"
47 #include "Rect.h"
48 #include "RenderStyle.h"
49 #include "RenderView.h"
50 #include "Settings.h"
51 #include "StyleFontSizeFunctions.h"
52 #include "StyleResolver.h"
53 #include <wtf/StdLibExtras.h>
54
55 #if ENABLE(CSS_SHAPES)
56 #include "ShapeValue.h"
57 #endif
58
59 namespace WebCore {
60
61 using namespace HTMLNames;
62
63 enum ExpandValueBehavior {SuppressValue = 0, ExpandValue};
64 template <ExpandValueBehavior expandValue, CSSPropertyID one = CSSPropertyInvalid, CSSPropertyID two = CSSPropertyInvalid, CSSPropertyID three = CSSPropertyInvalid, CSSPropertyID four = CSSPropertyInvalid, CSSPropertyID five = CSSPropertyInvalid>
65 class ApplyPropertyExpanding {
66 public:
67
68     template <CSSPropertyID id>
69     static inline void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver)
70     {
71         if (id == CSSPropertyInvalid)
72             return;
73
74         const DeprecatedStyleBuilder& table = DeprecatedStyleBuilder::sharedStyleBuilder();
75         const PropertyHandler& handler = table.propertyHandler(id);
76         if (handler.isValid())
77             handler.applyInheritValue(propertyID, styleResolver);
78     }
79
80     static void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver)
81     {
82         applyInheritValue<one>(propertyID, styleResolver);
83         applyInheritValue<two>(propertyID, styleResolver);
84         applyInheritValue<three>(propertyID, styleResolver);
85         applyInheritValue<four>(propertyID, styleResolver);
86         applyInheritValue<five>(propertyID, styleResolver);
87     }
88
89     template <CSSPropertyID id>
90     static inline void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver)
91     {
92         if (id == CSSPropertyInvalid)
93             return;
94
95         const DeprecatedStyleBuilder& table = DeprecatedStyleBuilder::sharedStyleBuilder();
96         const PropertyHandler& handler = table.propertyHandler(id);
97         if (handler.isValid())
98             handler.applyInitialValue(propertyID, styleResolver);
99     }
100
101     static void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver)
102     {
103         applyInitialValue<one>(propertyID, styleResolver);
104         applyInitialValue<two>(propertyID, styleResolver);
105         applyInitialValue<three>(propertyID, styleResolver);
106         applyInitialValue<four>(propertyID, styleResolver);
107         applyInitialValue<five>(propertyID, styleResolver);
108     }
109
110     template <CSSPropertyID id>
111     static inline void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value)
112     {
113         if (id == CSSPropertyInvalid)
114             return;
115
116         const DeprecatedStyleBuilder& table = DeprecatedStyleBuilder::sharedStyleBuilder();
117         const PropertyHandler& handler = table.propertyHandler(id);
118         if (handler.isValid())
119             handler.applyValue(propertyID, styleResolver, value);
120     }
121
122     static void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value)
123     {
124         if (!expandValue)
125             return;
126
127         applyValue<one>(propertyID, styleResolver, value);
128         applyValue<two>(propertyID, styleResolver, value);
129         applyValue<three>(propertyID, styleResolver, value);
130         applyValue<four>(propertyID, styleResolver, value);
131         applyValue<five>(propertyID, styleResolver, value);
132     }
133     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
134 };
135
136 template <typename GetterType, GetterType (RenderStyle::*getterFunction)() const, typename SetterType, void (RenderStyle::*setterFunction)(SetterType), typename InitialType, InitialType (*initialFunction)()>
137 class ApplyPropertyDefaultBase {
138 public:
139     static void setValue(RenderStyle* style, SetterType value) { (style->*setterFunction)(value); }
140     static GetterType value(RenderStyle* style) { return (style->*getterFunction)(); }
141     static InitialType initial() { return (*initialFunction)(); }
142     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { setValue(styleResolver->style(), value(styleResolver->parentStyle())); }
143     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { setValue(styleResolver->style(), initial()); }
144     static void applyValue(CSSPropertyID, StyleResolver*, CSSValue*) { }
145     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
146 };
147
148 template <typename GetterType, GetterType (RenderStyle::*getterFunction)() const, typename SetterType, void (RenderStyle::*setterFunction)(SetterType), typename InitialType, InitialType (*initialFunction)()>
149 class ApplyPropertyDefault {
150 public:
151     static void setValue(RenderStyle* style, SetterType value) { (style->*setterFunction)(value); }
152     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
153     {
154         if (is<CSSPrimitiveValue>(*value))
155             setValue(styleResolver->style(), downcast<CSSPrimitiveValue>(*value));
156     }
157     static PropertyHandler createHandler()
158     {
159         PropertyHandler handler = ApplyPropertyDefaultBase<GetterType, getterFunction, SetterType, setterFunction, InitialType, initialFunction>::createHandler();
160         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
161     }
162 };
163
164 template <StyleImage* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<StyleImage>), StyleImage* (*initialFunction)(), CSSPropertyID property>
165 class ApplyPropertyStyleImage {
166 public:
167     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { (styleResolver->style()->*setterFunction)(styleResolver->styleImage(property, *value)); }
168     static PropertyHandler createHandler()
169     {
170         PropertyHandler handler = ApplyPropertyDefaultBase<StyleImage*, getterFunction, PassRefPtr<StyleImage>, setterFunction, StyleImage*, initialFunction>::createHandler();
171         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
172     }
173 };
174
175 enum AutoValueType {Number = 0, ComputeLength};
176 template <typename T, T (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(T), bool (RenderStyle::*hasAutoFunction)() const, void (RenderStyle::*setAutoFunction)(), AutoValueType valueType = Number, int autoIdentity = CSSValueAuto>
177 class ApplyPropertyAuto {
178 public:
179     static void setValue(RenderStyle* style, T value) { (style->*setterFunction)(value); }
180     static T value(RenderStyle* style) { return (style->*getterFunction)(); }
181     static bool hasAuto(RenderStyle* style) { return (style->*hasAutoFunction)(); }
182     static void setAuto(RenderStyle* style) { (style->*setAutoFunction)(); }
183
184     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
185     {
186         if (hasAuto(styleResolver->parentStyle()))
187             setAuto(styleResolver->style());
188         else
189             setValue(styleResolver->style(), value(styleResolver->parentStyle()));
190     }
191
192     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { setAuto(styleResolver->style()); }
193
194     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
195     {
196         if (!is<CSSPrimitiveValue>(*value))
197             return;
198
199         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
200         if (primitiveValue.getValueID() == autoIdentity)
201             setAuto(styleResolver->style());
202         else if (valueType == Number)
203             setValue(styleResolver->style(), primitiveValue);
204         else if (valueType == ComputeLength)
205             setValue(styleResolver->style(), primitiveValue.computeLength<T>(styleResolver->state().cssToLengthConversionData()));
206     }
207
208     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
209 };
210
211 class ApplyPropertyClip {
212 private:
213     static Length convertToLength(StyleResolver* styleResolver, CSSPrimitiveValue* value)
214     {
215         return value->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(styleResolver->state().cssToLengthConversionData());
216     }
217 public:
218     static void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver)
219     {
220         RenderStyle* parentStyle = styleResolver->parentStyle();
221         if (!parentStyle->hasClip())
222             return applyInitialValue(propertyID, styleResolver);
223         styleResolver->style()->setClip(parentStyle->clipTop(), parentStyle->clipRight(), parentStyle->clipBottom(), parentStyle->clipLeft());
224         styleResolver->style()->setHasClip(true);
225     }
226
227     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
228     {
229         styleResolver->style()->setClip(Length(), Length(), Length(), Length());
230         styleResolver->style()->setHasClip(false);
231     }
232
233     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
234     {
235         if (!is<CSSPrimitiveValue>(*value))
236             return;
237
238         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
239
240         if (Rect* rect = primitiveValue.getRectValue()) {
241             Length top = convertToLength(styleResolver, rect->top());
242             Length right = convertToLength(styleResolver, rect->right());
243             Length bottom = convertToLength(styleResolver, rect->bottom());
244             Length left = convertToLength(styleResolver, rect->left());
245             styleResolver->style()->setClip(top, right, bottom, left);
246             styleResolver->style()->setHasClip(true);
247         } else if (primitiveValue.getValueID() == CSSValueAuto) {
248             styleResolver->style()->setClip(Length(), Length(), Length(), Length());
249             styleResolver->style()->setHasClip(false);
250         }
251     }
252
253     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
254 };
255
256 enum ColorInherit {NoInheritFromParent = 0, InheritFromParent};
257 Color defaultInitialColor();
258 Color defaultInitialColor() { return Color(); }
259 template <ColorInherit inheritColorFromParent,
260           Color (RenderStyle::*getterFunction)() const,
261           void (RenderStyle::*setterFunction)(const Color&),
262           void (RenderStyle::*visitedLinkSetterFunction)(const Color&),
263           Color (RenderStyle::*defaultFunction)() const,
264           Color (*initialFunction)() = &defaultInitialColor>
265 class ApplyPropertyColor {
266 public:
267     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
268     {
269         // Visited link style can never explicitly inherit from parent visited link style so no separate getters are needed.
270         Color color = (styleResolver->parentStyle()->*getterFunction)();
271         applyColorValue(styleResolver, color.isValid() ? color : (styleResolver->parentStyle()->*defaultFunction)());
272     }
273
274     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
275     {
276         applyColorValue(styleResolver, initialFunction());
277     }
278
279     static void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value)
280     {
281         if (!is<CSSPrimitiveValue>(*value))
282             return;
283
284         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
285         if (inheritColorFromParent && primitiveValue.getValueID() == CSSValueCurrentcolor)
286             applyInheritValue(propertyID, styleResolver);
287         else {
288             if (styleResolver->applyPropertyToRegularStyle())
289                 (styleResolver->style()->*setterFunction)(styleResolver->colorFromPrimitiveValue(&primitiveValue));
290             if (styleResolver->applyPropertyToVisitedLinkStyle())
291                 (styleResolver->style()->*visitedLinkSetterFunction)(styleResolver->colorFromPrimitiveValue(&primitiveValue, /* forVisitedLink */ true));
292         }
293     }
294
295     static void applyColorValue(StyleResolver* styleResolver, const Color& color)
296     {
297         if (styleResolver->applyPropertyToRegularStyle())
298             (styleResolver->style()->*setterFunction)(color);
299         if (styleResolver->applyPropertyToVisitedLinkStyle())
300             (styleResolver->style()->*visitedLinkSetterFunction)(color);
301     }
302
303     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
304 };
305
306 template <typename T>
307 struct FillLayerAccessorTypes {
308     typedef T Setter;
309     typedef T Getter;
310     typedef T InitialGetter;
311 };
312
313 template <>
314 struct FillLayerAccessorTypes<StyleImage*> {
315     typedef PassRefPtr<StyleImage> Setter;
316     typedef StyleImage* Getter;
317     typedef StyleImage* InitialGetter;
318 };
319
320 template<>
321 struct FillLayerAccessorTypes<Length>
322 {
323     typedef Length Setter;
324     typedef const Length& Getter;
325     typedef Length InitialGetter;
326 };
327
328 template <typename T,
329           CSSPropertyID propertyId,
330           EFillLayerType fillLayerType,
331           FillLayer* (RenderStyle::*accessLayersFunction)(),
332           const FillLayer* (RenderStyle::*layersFunction)() const,
333           bool (FillLayer::*testFunction)() const,
334           typename FillLayerAccessorTypes<T>::Getter (FillLayer::*getFunction)() const,
335           void (FillLayer::*setFunction)(typename FillLayerAccessorTypes<T>::Setter),
336           void (FillLayer::*clearFunction)(),
337           typename FillLayerAccessorTypes<T>::InitialGetter (*initialFunction)(EFillLayerType),
338           void (CSSToStyleMap::*mapFillFunction)(CSSPropertyID, FillLayer*, CSSValue*)>
339 class ApplyPropertyFillLayer {
340 public:
341     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
342     {
343         // Check for no-op before copying anything.
344         if (*(styleResolver->parentStyle()->*layersFunction)() == *(styleResolver->style()->*layersFunction)())
345             return;
346
347         auto* child = (styleResolver->style()->*accessLayersFunction)();
348         FillLayer* previousChild = nullptr;
349         for (auto* parent = (styleResolver->parentStyle()->*layersFunction)(); parent && (parent->*testFunction)(); parent = parent->next()) {
350             if (!child) {
351                 previousChild->setNext(std::make_unique<FillLayer>(fillLayerType));
352                 child = previousChild->next();
353             }
354             (child->*setFunction)((parent->*getFunction)());
355             previousChild = child;
356             child = previousChild->next();
357         }
358         for (; child; child = child->next())
359             (child->*clearFunction)();
360     }
361
362     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
363     {
364         // Check for (single-layer) no-op before clearing anything.
365         const FillLayer& layers = *(styleResolver->style()->*layersFunction)();
366         if (!layers.next() && (!(layers.*testFunction)() || (layers.*getFunction)() == (*initialFunction)(fillLayerType)))
367             return;
368
369         FillLayer* child = (styleResolver->style()->*accessLayersFunction)();
370         (child->*setFunction)((*initialFunction)(fillLayerType));
371         for (child = child->next(); child; child = child->next())
372             (child->*clearFunction)();
373     }
374
375     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
376     {
377         FillLayer* child = (styleResolver->style()->*accessLayersFunction)();
378         FillLayer* previousChild = nullptr;
379         if (is<CSSValueList>(*value)
380 #if ENABLE(CSS_IMAGE_SET)
381         && !is<CSSImageSetValue>(*value)
382 #endif
383         ) {
384             // Walk each value and put it into a layer, creating new layers as needed.
385             CSSValueList& valueList = downcast<CSSValueList>(*value);
386             for (unsigned i = 0; i < valueList.length(); i++) {
387                 if (!child) {
388                     previousChild->setNext(std::make_unique<FillLayer>(fillLayerType));
389                     child = previousChild->next();
390                 }
391                 (styleResolver->styleMap()->*mapFillFunction)(propertyId, child, valueList.itemWithoutBoundsCheck(i));
392                 previousChild = child;
393                 child = child->next();
394             }
395         } else {
396             (styleResolver->styleMap()->*mapFillFunction)(propertyId, child, value);
397             child = child->next();
398         }
399         for (; child; child = child->next())
400             (child->*clearFunction)();
401     }
402
403     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
404 };
405
406 template <typename T, T (FontDescription::*getterFunction)() const, void (FontDescription::*setterFunction)(T), T initialValue>
407 class ApplyPropertyFont {
408 public:
409     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
410     {
411         FontDescription fontDescription = styleResolver->fontDescription();
412         (fontDescription.*setterFunction)((styleResolver->parentFontDescription().*getterFunction)());
413         styleResolver->setFontDescription(fontDescription);
414     }
415
416     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
417     {
418         FontDescription fontDescription = styleResolver->fontDescription();
419         (fontDescription.*setterFunction)(initialValue);
420         styleResolver->setFontDescription(fontDescription);
421     }
422
423     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
424     {
425         if (!is<CSSPrimitiveValue>(*value))
426             return;
427         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
428         FontDescription fontDescription = styleResolver->fontDescription();
429         (fontDescription.*setterFunction)(primitiveValue);
430         styleResolver->setFontDescription(fontDescription);
431     }
432
433     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
434 };
435
436 class ApplyPropertyFontFamily {
437 public:
438     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
439     {
440         FontDescription fontDescription = styleResolver->style()->fontDescription();
441         FontDescription parentFontDescription = styleResolver->parentStyle()->fontDescription();
442         
443         fontDescription.setGenericFamily(parentFontDescription.genericFamily());
444         fontDescription.setFamilies(parentFontDescription.families());
445         fontDescription.setIsSpecifiedFont(parentFontDescription.isSpecifiedFont());
446         styleResolver->setFontDescription(fontDescription);
447         return;
448     }
449
450     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
451     {
452         FontDescription fontDescription = styleResolver->style()->fontDescription();
453         FontDescription initialDesc = FontDescription();
454         
455         // We need to adjust the size to account for the generic family change from monospace to non-monospace.
456         if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize())
457             styleResolver->setFontSize(fontDescription, Style::fontSizeForKeyword(CSSValueXxSmall + fontDescription.keywordSize() - 1, false, styleResolver->document()));
458         fontDescription.setGenericFamily(initialDesc.genericFamily());
459         if (!initialDesc.firstFamily().isEmpty())
460             fontDescription.setFamilies(initialDesc.families());
461
462         styleResolver->setFontDescription(fontDescription);
463         return;
464     }
465
466     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
467     {
468         if (!is<CSSValueList>(*value))
469             return;
470
471         auto& valueList = downcast<CSSValueList>(*value);
472
473         FontDescription fontDescription = styleResolver->style()->fontDescription();
474         // Before mapping in a new font-family property, we should reset the generic family.
475         bool oldFamilyUsedFixedDefaultSize = fontDescription.useFixedDefaultSize();
476         fontDescription.setGenericFamily(FontDescription::NoFamily);
477
478         Vector<AtomicString> families;
479         families.reserveInitialCapacity(valueList.length());
480
481         for (unsigned i = 0; i < valueList.length(); ++i) {
482             CSSValue* item = valueList.item(i);
483             if (!is<CSSPrimitiveValue>(*item))
484                 continue;
485             CSSPrimitiveValue& contentValue = downcast<CSSPrimitiveValue>(*item);
486             AtomicString face;
487             if (contentValue.isString())
488                 face = contentValue.getStringValue();
489             else if (Settings* settings = styleResolver->document().settings()) {
490                 switch (contentValue.getValueID()) {
491                 case CSSValueWebkitBody:
492                     face = settings->standardFontFamily();
493                     break;
494                 case CSSValueSerif:
495                     face = serifFamily;
496                     fontDescription.setGenericFamily(FontDescription::SerifFamily);
497                     break;
498                 case CSSValueSansSerif:
499                     face = sansSerifFamily;
500                     fontDescription.setGenericFamily(FontDescription::SansSerifFamily);
501                     break;
502                 case CSSValueCursive:
503                     face = cursiveFamily;
504                     fontDescription.setGenericFamily(FontDescription::CursiveFamily);
505                     break;
506                 case CSSValueFantasy:
507                     face = fantasyFamily;
508                     fontDescription.setGenericFamily(FontDescription::FantasyFamily);
509                     break;
510                 case CSSValueMonospace:
511                     face = monospaceFamily;
512                     fontDescription.setGenericFamily(FontDescription::MonospaceFamily);
513                     break;
514                 case CSSValueWebkitPictograph:
515                     face = pictographFamily;
516                     fontDescription.setGenericFamily(FontDescription::PictographFamily);
517                     break;
518                 default:
519                     break;
520                 }
521             }
522
523             if (face.isEmpty())
524                 continue;
525             if (families.isEmpty())
526                 fontDescription.setIsSpecifiedFont(fontDescription.genericFamily() == FontDescription::NoFamily);
527             families.uncheckedAppend(face);
528         }
529
530         if (families.isEmpty())
531             return;
532         fontDescription.setFamilies(families);
533
534         if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize() != oldFamilyUsedFixedDefaultSize)
535             styleResolver->setFontSize(fontDescription, Style::fontSizeForKeyword(CSSValueXxSmall + fontDescription.keywordSize() - 1, !oldFamilyUsedFixedDefaultSize, styleResolver->document()));
536
537         styleResolver->setFontDescription(fontDescription);
538     }
539
540     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
541 };
542
543 class ApplyPropertyFontSize {
544 private:
545     // When the CSS keyword "larger" is used, this function will attempt to match within the keyword
546     // table, and failing that, will simply multiply by 1.2.
547     static float largerFontSize(float size)
548     {
549         // FIXME: Figure out where we fall in the size ranges (xx-small to xxx-large) and scale up to
550         // the next size level.
551         return size * 1.2f;
552     }
553
554     // Like the previous function, but for the keyword "smaller".
555     static float smallerFontSize(float size)
556     {
557         // FIXME: Figure out where we fall in the size ranges (xx-small to xxx-large) and scale down to
558         // the next size level.
559         return size / 1.2f;
560     }
561 public:
562     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
563     {
564         float size = styleResolver->parentStyle()->fontDescription().specifiedSize();
565
566         if (size < 0)
567             return;
568
569         FontDescription fontDescription = styleResolver->style()->fontDescription();
570         fontDescription.setKeywordSize(styleResolver->parentStyle()->fontDescription().keywordSize());
571         styleResolver->setFontSize(fontDescription, size);
572         styleResolver->setFontDescription(fontDescription);
573         return;
574     }
575
576     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
577     {
578         FontDescription fontDescription = styleResolver->style()->fontDescription();
579         float size = Style::fontSizeForKeyword(CSSValueMedium, fontDescription.useFixedDefaultSize(), styleResolver->document());
580
581         if (size < 0)
582             return;
583
584         fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
585         styleResolver->setFontSize(fontDescription, size);
586         styleResolver->setFontDescription(fontDescription);
587         return;
588     }
589
590     static float determineRubyTextSizeMultiplier(StyleResolver* styleResolver)
591     {
592         if (styleResolver->style()->rubyPosition() != RubyPositionInterCharacter)
593             return 0.5f;
594         
595         Element* element = styleResolver->state().element();
596         if (element == nullptr)
597             return 0.25f;
598         
599         // FIXME: This hack is to ensure tone marks are the same size as
600         // the bopomofo. This code will go away if we make a special renderer
601         // for the tone marks eventually.
602         for (const Element* currElement = element->parentElement(); currElement; currElement = currElement->parentElement()) {
603             if (currElement->hasTagName(rtTag))
604                 return 1.0f;
605         }
606         return 0.25f;
607     }
608     
609     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
610     {
611         if (!is<CSSPrimitiveValue>(*value))
612             return;
613
614         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
615
616         FontDescription fontDescription = styleResolver->style()->fontDescription();
617         fontDescription.setKeywordSize(0);
618         float parentSize = 0;
619         bool parentIsAbsoluteSize = false;
620         float size = 0;
621
622         if (styleResolver->parentStyle()) {
623             parentSize = styleResolver->parentStyle()->fontDescription().specifiedSize();
624             parentIsAbsoluteSize = styleResolver->parentStyle()->fontDescription().isAbsoluteSize();
625         }
626
627         if (CSSValueID ident = primitiveValue.getValueID()) {
628             // Keywords are being used.
629             switch (ident) {
630             case CSSValueXxSmall:
631             case CSSValueXSmall:
632             case CSSValueSmall:
633             case CSSValueMedium:
634             case CSSValueLarge:
635             case CSSValueXLarge:
636             case CSSValueXxLarge:
637             case CSSValueWebkitXxxLarge:
638                 size = Style::fontSizeForKeyword(ident, fontDescription.useFixedDefaultSize(), styleResolver->document());
639                 fontDescription.setKeywordSize(ident - CSSValueXxSmall + 1);
640                 break;
641             case CSSValueLarger:
642                 size = largerFontSize(parentSize);
643                 break;
644             case CSSValueSmaller:
645                 size = smallerFontSize(parentSize);
646                 break;
647             case CSSValueWebkitRubyText: {
648                 float rubyTextSizeMultiplier = determineRubyTextSizeMultiplier(styleResolver);
649                 size = rubyTextSizeMultiplier * parentSize;
650                 break;
651             } default:
652                 return;
653             }
654
655             fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize && (ident == CSSValueLarger || ident == CSSValueSmaller || ident == CSSValueWebkitRubyText));
656         } else {
657             fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize || !(primitiveValue.isPercentage() || primitiveValue.isFontRelativeLength()));
658             if (primitiveValue.isLength()) {
659                 size = primitiveValue.computeLength<float>(CSSToLengthConversionData(styleResolver->parentStyle(), styleResolver->rootElementStyle(), styleResolver->document().renderView(), 1.0f, true));
660                 styleResolver->state().setFontSizeHasViewportUnits(primitiveValue.isViewportPercentageLength());
661             } else if (primitiveValue.isPercentage())
662                 size = (primitiveValue.getFloatValue() * parentSize) / 100.0f;
663             else if (primitiveValue.isCalculatedPercentageWithLength()) {
664                 Ref<CalculationValue> calculationValue { primitiveValue.cssCalcValue()->createCalculationValue(styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f)) };
665                 size = calculationValue->evaluate(parentSize);
666             } else
667                 return;
668         }
669
670         if (size < 0)
671             return;
672
673         // Overly large font sizes will cause crashes on some platforms (such as Windows).
674         // Cap font size here to make sure that doesn't happen.
675         size = std::min(maximumAllowedFontSize, size);
676
677         styleResolver->setFontSize(fontDescription, size);
678         styleResolver->setFontDescription(fontDescription);
679         return;
680     }
681
682     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
683 };
684
685 class ApplyPropertyFontWeight {
686 public:
687     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
688     {
689         if (!is<CSSPrimitiveValue>(*value))
690             return;
691         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
692         FontDescription fontDescription = styleResolver->fontDescription();
693         switch (primitiveValue.getValueID()) {
694         case CSSValueInvalid:
695             ASSERT_NOT_REACHED();
696             break;
697         case CSSValueBolder:
698             fontDescription.setWeight(styleResolver->parentStyle()->fontDescription().weight());
699             fontDescription.setWeight(fontDescription.bolderWeight());
700             break;
701         case CSSValueLighter:
702             fontDescription.setWeight(styleResolver->parentStyle()->fontDescription().weight());
703             fontDescription.setWeight(fontDescription.lighterWeight());
704             break;
705         default:
706             fontDescription.setWeight(primitiveValue);
707         }
708         styleResolver->setFontDescription(fontDescription);
709     }
710     static PropertyHandler createHandler()
711     {
712         PropertyHandler handler = ApplyPropertyFont<FontWeight, &FontDescription::weight, &FontDescription::setWeight, FontWeightNormal>::createHandler();
713         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
714     }
715 };
716
717 class ApplyPropertyFontVariantLigatures {
718 public:
719     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
720     {
721         const FontDescription& parentFontDescription = styleResolver->parentFontDescription();
722         FontDescription fontDescription = styleResolver->fontDescription();
723
724         fontDescription.setCommonLigaturesState(parentFontDescription.commonLigaturesState());
725         fontDescription.setDiscretionaryLigaturesState(parentFontDescription.discretionaryLigaturesState());
726         fontDescription.setHistoricalLigaturesState(parentFontDescription.historicalLigaturesState());
727
728         styleResolver->setFontDescription(fontDescription);
729     }
730
731     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
732     {
733         FontDescription fontDescription = styleResolver->fontDescription();
734
735         fontDescription.setCommonLigaturesState(FontDescription::NormalLigaturesState);
736         fontDescription.setDiscretionaryLigaturesState(FontDescription::NormalLigaturesState);
737         fontDescription.setHistoricalLigaturesState(FontDescription::NormalLigaturesState);
738
739         styleResolver->setFontDescription(fontDescription);
740     }
741
742     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
743     {
744         FontDescription::LigaturesState commonLigaturesState = FontDescription::NormalLigaturesState;
745         FontDescription::LigaturesState discretionaryLigaturesState = FontDescription::NormalLigaturesState;
746         FontDescription::LigaturesState historicalLigaturesState = FontDescription::NormalLigaturesState;
747
748         if (is<CSSValueList>(*value)) {
749             CSSValueList& valueList = downcast<CSSValueList>(*value);
750             for (size_t i = 0; i < valueList.length(); ++i) {
751                 CSSValue* item = valueList.itemWithoutBoundsCheck(i);
752                 if (is<CSSPrimitiveValue>(*item)) {
753                     switch (downcast<CSSPrimitiveValue>(*item).getValueID()) {
754                     case CSSValueNoCommonLigatures:
755                         commonLigaturesState = FontDescription::DisabledLigaturesState;
756                         break;
757                     case CSSValueCommonLigatures:
758                         commonLigaturesState = FontDescription::EnabledLigaturesState;
759                         break;
760                     case CSSValueNoDiscretionaryLigatures:
761                         discretionaryLigaturesState = FontDescription::DisabledLigaturesState;
762                         break;
763                     case CSSValueDiscretionaryLigatures:
764                         discretionaryLigaturesState = FontDescription::EnabledLigaturesState;
765                         break;
766                     case CSSValueNoHistoricalLigatures:
767                         historicalLigaturesState = FontDescription::DisabledLigaturesState;
768                         break;
769                     case CSSValueHistoricalLigatures:
770                         historicalLigaturesState = FontDescription::EnabledLigaturesState;
771                         break;
772                     default:
773                         ASSERT_NOT_REACHED();
774                         break;
775                     }
776                 }
777             }
778         }
779 #if !ASSERT_DISABLED
780         else
781             ASSERT(downcast<CSSPrimitiveValue>(*value).getValueID() == CSSValueNormal);
782 #endif
783
784         FontDescription fontDescription = styleResolver->fontDescription();
785         fontDescription.setCommonLigaturesState(commonLigaturesState);
786         fontDescription.setDiscretionaryLigaturesState(discretionaryLigaturesState);
787         fontDescription.setHistoricalLigaturesState(historicalLigaturesState);
788         styleResolver->setFontDescription(fontDescription);
789     }
790
791     static PropertyHandler createHandler()
792     {
793         return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
794     }
795 };
796
797 enum CounterBehavior {Increment = 0, Reset};
798 template <CounterBehavior counterBehavior>
799 class ApplyPropertyCounter {
800 public:
801     static void emptyFunction(CSSPropertyID, StyleResolver*) { }
802     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
803     {
804         CounterDirectiveMap& map = styleResolver->style()->accessCounterDirectives();
805         CounterDirectiveMap& parentMap = styleResolver->parentStyle()->accessCounterDirectives();
806
807         typedef CounterDirectiveMap::iterator Iterator;
808         Iterator end = parentMap.end();
809         for (Iterator it = parentMap.begin(); it != end; ++it) {
810             CounterDirectives& directives = map.add(it->key, CounterDirectives()).iterator->value;
811             if (counterBehavior == Reset) {
812                 directives.inheritReset(it->value);
813             } else {
814                 directives.inheritIncrement(it->value);
815             }
816         }
817     }
818     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
819     {
820         bool setCounterIncrementToNone = counterBehavior == Increment && is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).getValueID() == CSSValueNone;
821
822         if (!is<CSSValueList>(*value) && !setCounterIncrementToNone)
823             return;
824
825         CounterDirectiveMap& map = styleResolver->style()->accessCounterDirectives();
826         typedef CounterDirectiveMap::iterator Iterator;
827
828         Iterator end = map.end();
829         for (Iterator it = map.begin(); it != end; ++it)
830             if (counterBehavior == Reset)
831                 it->value.clearReset();
832             else
833                 it->value.clearIncrement();
834         
835         if (setCounterIncrementToNone)
836             return;
837         
838         CSSValueList& list = downcast<CSSValueList>(*value);
839         int length = list.length();
840         for (int i = 0; i < length; ++i) {
841             CSSValue* currValue = list.itemWithoutBoundsCheck(i);
842             if (!is<CSSPrimitiveValue>(*currValue))
843                 continue;
844
845             Pair* pair = downcast<CSSPrimitiveValue>(*currValue).getPairValue();
846             if (!pair || !pair->first() || !pair->second())
847                 continue;
848
849             AtomicString identifier = static_cast<CSSPrimitiveValue*>(pair->first())->getStringValue();
850             int value = static_cast<CSSPrimitiveValue*>(pair->second())->getIntValue();
851             CounterDirectives& directives = map.add(identifier, CounterDirectives()).iterator->value;
852             if (counterBehavior == Reset) {
853                 directives.setResetValue(value);
854             } else {
855                 directives.addIncrementValue(value);
856             }
857         }
858     }
859     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &emptyFunction, &applyValue); }
860 };
861
862
863 class ApplyPropertyCursor {
864 public:
865     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
866     {
867         styleResolver->style()->setCursor(styleResolver->parentStyle()->cursor());
868         styleResolver->style()->setCursorList(styleResolver->parentStyle()->cursors());
869     }
870
871     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
872     {
873         styleResolver->style()->clearCursorList();
874         styleResolver->style()->setCursor(RenderStyle::initialCursor());
875     }
876
877     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
878     {
879         styleResolver->style()->clearCursorList();
880         if (is<CSSValueList>(*value)) {
881             CSSValueList& list = downcast<CSSValueList>(*value);
882             int length = list.length();
883             styleResolver->style()->setCursor(CursorAuto);
884             for (int i = 0; i < length; i++) {
885                 CSSValue* item = list.itemWithoutBoundsCheck(i);
886                 if (is<CSSCursorImageValue>(*item)) {
887                     CSSCursorImageValue& image = downcast<CSSCursorImageValue>(*item);
888                     if (image.updateIfSVGCursorIsUsed(styleResolver->element())) // Elements with SVG cursors are not allowed to share style.
889                         styleResolver->style()->setUnique();
890                     styleResolver->style()->addCursor(styleResolver->styleImage(CSSPropertyCursor, image), image.hotSpot());
891                 } else if (is<CSSPrimitiveValue>(*item)) {
892                     CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*item);
893                     if (primitiveValue.isValueID())
894                         styleResolver->style()->setCursor(primitiveValue);
895                 }
896             }
897         } else if (is<CSSPrimitiveValue>(*value)) {
898             CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
899             if (primitiveValue.isValueID() && styleResolver->style()->cursor() != ECursor(primitiveValue))
900                 styleResolver->style()->setCursor(primitiveValue);
901         }
902     }
903
904     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
905 };
906
907 static TextDecorationSkip valueToDecorationSkip(CSSPrimitiveValue& primitiveValue)
908 {
909     ASSERT(primitiveValue.isValueID());
910
911     switch (primitiveValue.getValueID()) {
912     case CSSValueAuto:
913         return TextDecorationSkipAuto;
914     case CSSValueNone:
915         return TextDecorationSkipNone;
916     case CSSValueInk:
917         return TextDecorationSkipInk;
918     case CSSValueObjects:
919         return TextDecorationSkipObjects;
920     default:
921         break;
922     }
923
924     ASSERT_NOT_REACHED();
925     return TextDecorationSkipNone;
926 }
927
928 class ApplyPropertyTextDecorationSkip {
929 public:
930     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
931     {
932         if (is<CSSPrimitiveValue>(*value)) {
933             styleResolver->style()->setTextDecorationSkip(valueToDecorationSkip(downcast<CSSPrimitiveValue>(*value)));
934             return;
935         }
936
937         TextDecorationSkip skip = RenderStyle::initialTextDecorationSkip();
938         if (is<CSSValueList>(*value)) {
939             for (auto& currentValue : downcast<CSSValueList>(*value))
940                 skip |= valueToDecorationSkip(downcast<CSSPrimitiveValue>(currentValue.get()));
941         }
942         styleResolver->style()->setTextDecorationSkip(skip);
943     }
944     static PropertyHandler createHandler()
945     {
946         PropertyHandler handler = ApplyPropertyDefaultBase<TextDecorationSkip, &RenderStyle::textDecorationSkip, TextDecorationSkip, &RenderStyle::setTextDecorationSkip, TextDecorationSkip, &RenderStyle::initialTextDecorationSkip>::createHandler();
947         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
948     }
949 };
950
951 class ApplyPropertyTextEmphasisStyle {
952 public:
953     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
954     {
955         styleResolver->style()->setTextEmphasisFill(styleResolver->parentStyle()->textEmphasisFill());
956         styleResolver->style()->setTextEmphasisMark(styleResolver->parentStyle()->textEmphasisMark());
957         styleResolver->style()->setTextEmphasisCustomMark(styleResolver->parentStyle()->textEmphasisCustomMark());
958     }
959
960     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
961     {
962         styleResolver->style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill());
963         styleResolver->style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark());
964         styleResolver->style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCustomMark());
965     }
966
967     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
968     {
969         if (is<CSSValueList>(*value)) {
970             CSSValueList& list = downcast<CSSValueList>(*value);
971             ASSERT(list.length() == 2);
972             if (list.length() != 2)
973                 return;
974             for (unsigned i = 0; i < 2; ++i) {
975                 CSSValue* item = list.itemWithoutBoundsCheck(i);
976                 if (!is<CSSPrimitiveValue>(*item))
977                     continue;
978
979                 CSSPrimitiveValue& value = downcast<CSSPrimitiveValue>(*item);
980                 if (value.getValueID() == CSSValueFilled || value.getValueID() == CSSValueOpen)
981                     styleResolver->style()->setTextEmphasisFill(value);
982                 else
983                     styleResolver->style()->setTextEmphasisMark(value);
984             }
985             styleResolver->style()->setTextEmphasisCustomMark(nullAtom);
986             return;
987         }
988
989         if (!is<CSSPrimitiveValue>(*value))
990             return;
991         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
992
993         if (primitiveValue.isString()) {
994             styleResolver->style()->setTextEmphasisFill(TextEmphasisFillFilled);
995             styleResolver->style()->setTextEmphasisMark(TextEmphasisMarkCustom);
996             styleResolver->style()->setTextEmphasisCustomMark(primitiveValue.getStringValue());
997             return;
998         }
999
1000         styleResolver->style()->setTextEmphasisCustomMark(nullAtom);
1001
1002         if (primitiveValue.getValueID() == CSSValueFilled || primitiveValue.getValueID() == CSSValueOpen) {
1003             styleResolver->style()->setTextEmphasisFill(primitiveValue);
1004             styleResolver->style()->setTextEmphasisMark(TextEmphasisMarkAuto);
1005         } else {
1006             styleResolver->style()->setTextEmphasisFill(TextEmphasisFillFilled);
1007             styleResolver->style()->setTextEmphasisMark(primitiveValue);
1008         }
1009     }
1010
1011     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
1012 };
1013
1014 template <typename T,
1015           T (Animation::*getterFunction)() const,
1016           void (Animation::*setterFunction)(T),
1017           bool (Animation::*testFunction)() const,
1018           void (Animation::*clearFunction)(),
1019           T (*initialFunction)(),
1020           void (CSSToStyleMap::*mapFunction)(Animation*, CSSValue&),
1021           AnimationList* (RenderStyle::*animationGetterFunction)(),
1022           const AnimationList* (RenderStyle::*immutableAnimationGetterFunction)() const>
1023 class ApplyPropertyAnimation {
1024 public:
1025     static void setValue(Animation& animation, T value) { (animation.*setterFunction)(value); }
1026     static T value(const Animation& animation) { return (animation.*getterFunction)(); }
1027     static bool test(const Animation& animation) { return (animation.*testFunction)(); }
1028     static void clear(Animation& animation) { (animation.*clearFunction)(); }
1029     static T initial() { return (*initialFunction)(); }
1030     static void map(StyleResolver* styleResolver, Animation& animation, CSSValue& value) { (styleResolver->styleMap()->*mapFunction)(&animation, value); }
1031     static AnimationList* accessAnimations(RenderStyle* style) { return (style->*animationGetterFunction)(); }
1032     static const AnimationList* animations(RenderStyle* style) { return (style->*immutableAnimationGetterFunction)(); }
1033
1034     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
1035     {
1036         AnimationList* list = accessAnimations(styleResolver->style());
1037         const AnimationList* parentList = animations(styleResolver->parentStyle());
1038         size_t i = 0, parentSize = parentList ? parentList->size() : 0;
1039         for ( ; i < parentSize && test(parentList->animation(i)); ++i) {
1040             if (list->size() <= i)
1041                 list->append(Animation::create());
1042             setValue(list->animation(i), value(parentList->animation(i)));
1043             list->animation(i).setAnimationMode(parentList->animation(i).animationMode());
1044         }
1045
1046         /* Reset any remaining animations to not have the property set. */
1047         for ( ; i < list->size(); ++i)
1048             clear(list->animation(i));
1049     }
1050
1051     static void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver)
1052     {
1053         AnimationList* list = accessAnimations(styleResolver->style());
1054         if (list->isEmpty())
1055             list->append(Animation::create());
1056         setValue(list->animation(0), initial());
1057         if (propertyID == CSSPropertyWebkitTransitionProperty)
1058             list->animation(0).setAnimationMode(Animation::AnimateAll);
1059         for (size_t i = 1; i < list->size(); ++i)
1060             clear(list->animation(i));
1061     }
1062
1063     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
1064     {
1065         AnimationList* list = accessAnimations(styleResolver->style());
1066         size_t childIndex = 0;
1067         if (is<CSSValueList>(*value)) {
1068             /* Walk each value and put it into an animation, creating new animations as needed. */
1069             for (auto& currentValue : downcast<CSSValueList>(*value)) {
1070                 if (childIndex <= list->size())
1071                     list->append(Animation::create());
1072                 map(styleResolver, list->animation(childIndex), currentValue);
1073                 ++childIndex;
1074             }
1075         } else {
1076             if (list->isEmpty())
1077                 list->append(Animation::create());
1078             map(styleResolver, list->animation(childIndex), *value);
1079             childIndex = 1;
1080         }
1081         for ( ; childIndex < list->size(); ++childIndex) {
1082             /* Reset all remaining animations to not have the property set. */
1083             clear(list->animation(childIndex));
1084         }
1085     }
1086
1087     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
1088 };
1089
1090 class ApplyPropertyOutlineStyle {
1091 public:
1092     static void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver)
1093     {
1094         ApplyPropertyDefaultBase<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyInheritValue(propertyID, styleResolver);
1095         ApplyPropertyDefaultBase<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyInheritValue(propertyID, styleResolver);
1096     }
1097
1098     static void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver)
1099     {
1100         ApplyPropertyDefaultBase<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyInitialValue(propertyID, styleResolver);
1101         ApplyPropertyDefaultBase<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyInitialValue(propertyID, styleResolver);
1102     }
1103
1104     static void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value)
1105     {
1106         ApplyPropertyDefault<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyValue(propertyID, styleResolver, value);
1107         ApplyPropertyDefault<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyValue(propertyID, styleResolver, value);
1108     }
1109
1110     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
1111 };
1112
1113 class ApplyPropertyAspectRatio {
1114 public:
1115     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
1116     {
1117         if (styleResolver->parentStyle()->aspectRatioType() == AspectRatioAuto)
1118             return;
1119         styleResolver->style()->setAspectRatioType(styleResolver->parentStyle()->aspectRatioType());
1120         styleResolver->style()->setAspectRatioDenominator(styleResolver->parentStyle()->aspectRatioDenominator());
1121         styleResolver->style()->setAspectRatioNumerator(styleResolver->parentStyle()->aspectRatioNumerator());
1122     }
1123
1124     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
1125     {
1126         styleResolver->style()->setAspectRatioType(RenderStyle::initialAspectRatioType());
1127         styleResolver->style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDenominator());
1128         styleResolver->style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumerator());
1129     }
1130
1131     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
1132     {
1133         if (is<CSSPrimitiveValue>(*value)) {
1134             CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
1135
1136             if (primitiveValue.getValueID() == CSSValueAuto)
1137                 return styleResolver->style()->setAspectRatioType(AspectRatioAuto);
1138             if (primitiveValue.getValueID() == CSSValueFromDimensions)
1139                 return styleResolver->style()->setAspectRatioType(AspectRatioFromDimensions);
1140             if (primitiveValue.getValueID() == CSSValueFromIntrinsic)
1141                 return styleResolver->style()->setAspectRatioType(AspectRatioFromIntrinsic);
1142         }
1143
1144         if (!is<CSSAspectRatioValue>(*value)) {
1145             styleResolver->style()->setAspectRatioType(AspectRatioAuto);
1146             return;
1147         }
1148
1149         CSSAspectRatioValue& aspectRatioValue = downcast<CSSAspectRatioValue>(*value);
1150         styleResolver->style()->setAspectRatioType(AspectRatioSpecified);
1151         styleResolver->style()->setAspectRatioDenominator(aspectRatioValue.denominatorValue());
1152         styleResolver->style()->setAspectRatioNumerator(aspectRatioValue.numeratorValue());
1153     }
1154
1155     static PropertyHandler createHandler()
1156     {
1157         return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
1158     }
1159 };
1160
1161 class ApplyPropertyDisplay {
1162 private:
1163     static inline bool isValidDisplayValue(StyleResolver* styleResolver, EDisplay displayPropertyValue)
1164     {
1165         if (styleResolver->element() && styleResolver->element()->isSVGElement() && styleResolver->style()->styleType() == NOPSEUDO)
1166             return (displayPropertyValue == INLINE || displayPropertyValue == BLOCK || displayPropertyValue == NONE);
1167         return true;
1168     }
1169 public:
1170     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
1171     {
1172         EDisplay display = styleResolver->parentStyle()->display();
1173         if (!isValidDisplayValue(styleResolver, display))
1174             return;
1175         styleResolver->style()->setDisplay(display);
1176     }
1177
1178     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
1179     {
1180         styleResolver->style()->setDisplay(RenderStyle::initialDisplay());
1181     }
1182
1183     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
1184     {
1185         if (!is<CSSPrimitiveValue>(*value))
1186             return;
1187
1188         EDisplay display = downcast<CSSPrimitiveValue>(*value);
1189
1190         if (!isValidDisplayValue(styleResolver, display))
1191             return;
1192
1193         styleResolver->style()->setDisplay(display);
1194     }
1195
1196     static PropertyHandler createHandler()
1197     {
1198         return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
1199     }
1200 };
1201
1202 const DeprecatedStyleBuilder& DeprecatedStyleBuilder::sharedStyleBuilder()
1203 {
1204     static NeverDestroyed<DeprecatedStyleBuilder> styleBuilderInstance;
1205     return styleBuilderInstance;
1206 }
1207
1208 DeprecatedStyleBuilder::DeprecatedStyleBuilder()
1209 {
1210     for (int i = 0; i < numCSSProperties; ++i)
1211         m_propertyMap[i] = PropertyHandler();
1212
1213     // Please keep CSS property list in alphabetical order.
1214     setPropertyHandler(CSSPropertyBackgroundAttachment, ApplyPropertyFillLayer<EFillAttachment, CSSPropertyBackgroundAttachment, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isAttachmentSet, &FillLayer::attachment, &FillLayer::setAttachment, &FillLayer::clearAttachment, &FillLayer::initialFillAttachment, &CSSToStyleMap::mapFillAttachment>::createHandler());
1215     setPropertyHandler(CSSPropertyBackgroundBlendMode, ApplyPropertyFillLayer<BlendMode, CSSPropertyBackgroundBlendMode, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isBlendModeSet, &FillLayer::blendMode, &FillLayer::setBlendMode, &FillLayer::clearBlendMode, &FillLayer::initialFillBlendMode, &CSSToStyleMap::mapFillBlendMode>::createHandler());
1216     setPropertyHandler(CSSPropertyBackgroundClip, ApplyPropertyFillLayer<EFillBox, CSSPropertyBackgroundClip, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isClipSet, &FillLayer::clip, &FillLayer::setClip, &FillLayer::clearClip, &FillLayer::initialFillClip, &CSSToStyleMap::mapFillClip>::createHandler());
1217     setPropertyHandler(CSSPropertyBackgroundColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::backgroundColor, &RenderStyle::setBackgroundColor, &RenderStyle::setVisitedLinkBackgroundColor, &RenderStyle::invalidColor>::createHandler());
1218     setPropertyHandler(CSSPropertyBackgroundImage, ApplyPropertyFillLayer<StyleImage*, CSSPropertyBackgroundImage, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isImageSet, &FillLayer::image, &FillLayer::setImage, &FillLayer::clearImage, &FillLayer::initialFillImage, &CSSToStyleMap::mapFillImage>::createHandler());
1219     setPropertyHandler(CSSPropertyBackgroundOrigin, ApplyPropertyFillLayer<EFillBox, CSSPropertyBackgroundOrigin, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &CSSToStyleMap::mapFillOrigin>::createHandler());
1220     setPropertyHandler(CSSPropertyBackgroundPositionX, ApplyPropertyFillLayer<Length, CSSPropertyBackgroundPositionX, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isXPositionSet, &FillLayer::xPosition, &FillLayer::setXPosition, &FillLayer::clearXPosition, &FillLayer::initialFillXPosition, &CSSToStyleMap::mapFillXPosition>::createHandler());
1221     setPropertyHandler(CSSPropertyBackgroundPositionY, ApplyPropertyFillLayer<Length, CSSPropertyBackgroundPositionY, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isYPositionSet, &FillLayer::yPosition, &FillLayer::setYPosition, &FillLayer::clearYPosition, &FillLayer::initialFillYPosition, &CSSToStyleMap::mapFillYPosition>::createHandler());
1222     setPropertyHandler(CSSPropertyBackgroundRepeatX, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyBackgroundRepeatX, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isRepeatXSet, &FillLayer::repeatX, &FillLayer::setRepeatX, &FillLayer::clearRepeatX, &FillLayer::initialFillRepeatX, &CSSToStyleMap::mapFillRepeatX>::createHandler());
1223     setPropertyHandler(CSSPropertyBackgroundRepeatY, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyBackgroundRepeatY, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isRepeatYSet, &FillLayer::repeatY, &FillLayer::setRepeatY, &FillLayer::clearRepeatY, &FillLayer::initialFillRepeatY, &CSSToStyleMap::mapFillRepeatY>::createHandler());
1224     setPropertyHandler(CSSPropertyBackgroundSize, ApplyPropertyFillLayer<FillSize, CSSPropertyBackgroundSize, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSToStyleMap::mapFillSize>::createHandler());
1225     setPropertyHandler(CSSPropertyBorderBottomColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderBottomColor, &RenderStyle::setBorderBottomColor, &RenderStyle::setVisitedLinkBorderBottomColor, &RenderStyle::color>::createHandler());
1226     setPropertyHandler(CSSPropertyBorderLeftColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderLeftColor, &RenderStyle::setBorderLeftColor, &RenderStyle::setVisitedLinkBorderLeftColor, &RenderStyle::color>::createHandler());
1227     setPropertyHandler(CSSPropertyBorderRightColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderRightColor, &RenderStyle::setBorderRightColor, &RenderStyle::setVisitedLinkBorderRightColor, &RenderStyle::color>::createHandler());
1228     setPropertyHandler(CSSPropertyBorderTopColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderTopColor, &RenderStyle::setBorderTopColor, &RenderStyle::setVisitedLinkBorderTopColor, &RenderStyle::color>::createHandler());
1229     setPropertyHandler(CSSPropertyClip, ApplyPropertyClip::createHandler());
1230     setPropertyHandler(CSSPropertyColor, ApplyPropertyColor<InheritFromParent, &RenderStyle::color, &RenderStyle::setColor, &RenderStyle::setVisitedLinkColor, &RenderStyle::invalidColor, RenderStyle::initialColor>::createHandler());
1231     setPropertyHandler(CSSPropertyCounterIncrement, ApplyPropertyCounter<Increment>::createHandler());
1232     setPropertyHandler(CSSPropertyCounterReset, ApplyPropertyCounter<Reset>::createHandler());
1233     setPropertyHandler(CSSPropertyCursor, ApplyPropertyCursor::createHandler());
1234     setPropertyHandler(CSSPropertyDisplay, ApplyPropertyDisplay::createHandler());
1235     setPropertyHandler(CSSPropertyFontFamily, ApplyPropertyFontFamily::createHandler());
1236     setPropertyHandler(CSSPropertyFontSize, ApplyPropertyFontSize::createHandler());
1237     setPropertyHandler(CSSPropertyFontStyle, ApplyPropertyFont<FontItalic, &FontDescription::italic, &FontDescription::setItalic, FontItalicOff>::createHandler());
1238     setPropertyHandler(CSSPropertyFontVariant, ApplyPropertyFont<FontSmallCaps, &FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff>::createHandler());
1239     setPropertyHandler(CSSPropertyFontWeight, ApplyPropertyFontWeight::createHandler());
1240     setPropertyHandler(CSSPropertyListStyleImage, ApplyPropertyStyleImage<&RenderStyle::listStyleImage, &RenderStyle::setListStyleImage, &RenderStyle::initialListStyleImage, CSSPropertyListStyleImage>::createHandler());
1241     setPropertyHandler(CSSPropertyOrphans, ApplyPropertyAuto<short, &RenderStyle::orphans, &RenderStyle::setOrphans, &RenderStyle::hasAutoOrphans, &RenderStyle::setHasAutoOrphans>::createHandler());
1242     setPropertyHandler(CSSPropertyOutlineColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::outlineColor, &RenderStyle::setOutlineColor, &RenderStyle::setVisitedLinkOutlineColor, &RenderStyle::color>::createHandler());
1243     setPropertyHandler(CSSPropertyOutlineStyle, ApplyPropertyOutlineStyle::createHandler());
1244     setPropertyHandler(CSSPropertyWebkitTextDecorationColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textDecorationColor, &RenderStyle::setTextDecorationColor, &RenderStyle::setVisitedLinkTextDecorationColor, &RenderStyle::color>::createHandler());
1245     setPropertyHandler(CSSPropertyWebkitTextDecorationSkip, ApplyPropertyTextDecorationSkip::createHandler());
1246     setPropertyHandler(CSSPropertyTextRendering, ApplyPropertyFont<TextRenderingMode, &FontDescription::textRenderingMode, &FontDescription::setTextRenderingMode, AutoTextRendering>::createHandler());
1247
1248     setPropertyHandler(CSSPropertyAnimationDelay, ApplyPropertyAnimation<double, &Animation::delay, &Animation::setDelay, &Animation::isDelaySet, &Animation::clearDelay, &Animation::initialAnimationDelay, &CSSToStyleMap::mapAnimationDelay, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1249     setPropertyHandler(CSSPropertyAnimationDirection, ApplyPropertyAnimation<Animation::AnimationDirection, &Animation::direction, &Animation::setDirection, &Animation::isDirectionSet, &Animation::clearDirection, &Animation::initialAnimationDirection, &CSSToStyleMap::mapAnimationDirection, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1250     setPropertyHandler(CSSPropertyAnimationDuration, ApplyPropertyAnimation<double, &Animation::duration, &Animation::setDuration, &Animation::isDurationSet, &Animation::clearDuration, &Animation::initialAnimationDuration, &CSSToStyleMap::mapAnimationDuration, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1251     setPropertyHandler(CSSPropertyAnimationFillMode, ApplyPropertyAnimation<unsigned, &Animation::fillMode, &Animation::setFillMode, &Animation::isFillModeSet, &Animation::clearFillMode, &Animation::initialAnimationFillMode, &CSSToStyleMap::mapAnimationFillMode, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1252     setPropertyHandler(CSSPropertyAnimationIterationCount, ApplyPropertyAnimation<double, &Animation::iterationCount, &Animation::setIterationCount, &Animation::isIterationCountSet, &Animation::clearIterationCount, &Animation::initialAnimationIterationCount, &CSSToStyleMap::mapAnimationIterationCount, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1253     setPropertyHandler(CSSPropertyAnimationName, ApplyPropertyAnimation<const String&, &Animation::name, &Animation::setName, &Animation::isNameSet, &Animation::clearName, &Animation::initialAnimationName, &CSSToStyleMap::mapAnimationName, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1254     setPropertyHandler(CSSPropertyAnimationPlayState, ApplyPropertyAnimation<EAnimPlayState, &Animation::playState, &Animation::setPlayState, &Animation::isPlayStateSet, &Animation::clearPlayState, &Animation::initialAnimationPlayState, &CSSToStyleMap::mapAnimationPlayState, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1255     setPropertyHandler(CSSPropertyAnimationTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSToStyleMap::mapAnimationTimingFunction, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1256
1257     setPropertyHandler(CSSPropertyWebkitAnimationDelay, ApplyPropertyAnimation<double, &Animation::delay, &Animation::setDelay, &Animation::isDelaySet, &Animation::clearDelay, &Animation::initialAnimationDelay, &CSSToStyleMap::mapAnimationDelay, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1258     setPropertyHandler(CSSPropertyWebkitAnimationDirection, ApplyPropertyAnimation<Animation::AnimationDirection, &Animation::direction, &Animation::setDirection, &Animation::isDirectionSet, &Animation::clearDirection, &Animation::initialAnimationDirection, &CSSToStyleMap::mapAnimationDirection, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1259     setPropertyHandler(CSSPropertyWebkitAnimationDuration, ApplyPropertyAnimation<double, &Animation::duration, &Animation::setDuration, &Animation::isDurationSet, &Animation::clearDuration, &Animation::initialAnimationDuration, &CSSToStyleMap::mapAnimationDuration, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1260     setPropertyHandler(CSSPropertyWebkitAnimationFillMode, ApplyPropertyAnimation<unsigned, &Animation::fillMode, &Animation::setFillMode, &Animation::isFillModeSet, &Animation::clearFillMode, &Animation::initialAnimationFillMode, &CSSToStyleMap::mapAnimationFillMode, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1261     setPropertyHandler(CSSPropertyWebkitAnimationIterationCount, ApplyPropertyAnimation<double, &Animation::iterationCount, &Animation::setIterationCount, &Animation::isIterationCountSet, &Animation::clearIterationCount, &Animation::initialAnimationIterationCount, &CSSToStyleMap::mapAnimationIterationCount, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1262     setPropertyHandler(CSSPropertyWebkitAnimationName, ApplyPropertyAnimation<const String&, &Animation::name, &Animation::setName, &Animation::isNameSet, &Animation::clearName, &Animation::initialAnimationName, &CSSToStyleMap::mapAnimationName, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1263     setPropertyHandler(CSSPropertyWebkitAnimationPlayState, ApplyPropertyAnimation<EAnimPlayState, &Animation::playState, &Animation::setPlayState, &Animation::isPlayStateSet, &Animation::clearPlayState, &Animation::initialAnimationPlayState, &CSSToStyleMap::mapAnimationPlayState, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1264     setPropertyHandler(CSSPropertyWebkitAnimationTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSToStyleMap::mapAnimationTimingFunction, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1265     setPropertyHandler(CSSPropertyWebkitAspectRatio, ApplyPropertyAspectRatio::createHandler());
1266     setPropertyHandler(CSSPropertyWebkitBackgroundClip, CSSPropertyBackgroundClip);
1267     setPropertyHandler(CSSPropertyWebkitBackgroundComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitBackgroundComposite, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSToStyleMap::mapFillComposite>::createHandler());
1268     setPropertyHandler(CSSPropertyWebkitBackgroundOrigin, CSSPropertyBackgroundOrigin);
1269     setPropertyHandler(CSSPropertyWebkitBackgroundSize, CSSPropertyBackgroundSize);
1270     setPropertyHandler(CSSPropertyColumnCount, ApplyPropertyAuto<unsigned short, &RenderStyle::columnCount, &RenderStyle::setColumnCount, &RenderStyle::hasAutoColumnCount, &RenderStyle::setHasAutoColumnCount>::createHandler());
1271     setPropertyHandler(CSSPropertyColumnGap, ApplyPropertyAuto<float, &RenderStyle::columnGap, &RenderStyle::setColumnGap, &RenderStyle::hasNormalColumnGap, &RenderStyle::setHasNormalColumnGap, ComputeLength, CSSValueNormal>::createHandler());
1272     setPropertyHandler(CSSPropertyColumnRuleColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::columnRuleColor, &RenderStyle::setColumnRuleColor, &RenderStyle::setVisitedLinkColumnRuleColor, &RenderStyle::color>::createHandler());
1273     setPropertyHandler(CSSPropertyColumnWidth, ApplyPropertyAuto<float, &RenderStyle::columnWidth, &RenderStyle::setColumnWidth, &RenderStyle::hasAutoColumnWidth, &RenderStyle::setHasAutoColumnWidth, ComputeLength>::createHandler());
1274     setPropertyHandler(CSSPropertyWebkitFontKerning, ApplyPropertyFont<FontDescription::Kerning, &FontDescription::kerning, &FontDescription::setKerning, FontDescription::AutoKerning>::createHandler());
1275     setPropertyHandler(CSSPropertyWebkitFontSmoothing, ApplyPropertyFont<FontSmoothingMode, &FontDescription::fontSmoothing, &FontDescription::setFontSmoothing, AutoSmoothing>::createHandler());
1276     setPropertyHandler(CSSPropertyWebkitFontVariantLigatures, ApplyPropertyFontVariantLigatures::createHandler());
1277     setPropertyHandler(CSSPropertyWebkitMaskClip, ApplyPropertyFillLayer<EFillBox, CSSPropertyWebkitMaskClip, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isClipSet, &FillLayer::clip, &FillLayer::setClip, &FillLayer::clearClip, &FillLayer::initialFillClip, &CSSToStyleMap::mapFillClip>::createHandler());
1278     setPropertyHandler(CSSPropertyWebkitMaskComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitMaskComposite, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSToStyleMap::mapFillComposite>::createHandler());
1279     setPropertyHandler(CSSPropertyWebkitMaskImage, ApplyPropertyFillLayer<StyleImage*, CSSPropertyWebkitMaskImage, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isImageSet, &FillLayer::image, &FillLayer::setImage, &FillLayer::clearImage, &FillLayer::initialFillImage, &CSSToStyleMap::mapFillImage>::createHandler());
1280     setPropertyHandler(CSSPropertyWebkitMaskOrigin, ApplyPropertyFillLayer<EFillBox, CSSPropertyWebkitMaskOrigin, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &CSSToStyleMap::mapFillOrigin>::createHandler());
1281     setPropertyHandler(CSSPropertyWebkitMaskPositionX, ApplyPropertyFillLayer<Length, CSSPropertyWebkitMaskPositionX, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isXPositionSet, &FillLayer::xPosition, &FillLayer::setXPosition, &FillLayer::clearXPosition, &FillLayer::initialFillXPosition, &CSSToStyleMap::mapFillXPosition>::createHandler());
1282     setPropertyHandler(CSSPropertyWebkitMaskPositionY, ApplyPropertyFillLayer<Length, CSSPropertyWebkitMaskPositionY, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isYPositionSet, &FillLayer::yPosition, &FillLayer::setYPosition, &FillLayer::clearYPosition, &FillLayer::initialFillYPosition, &CSSToStyleMap::mapFillYPosition>::createHandler());
1283     setPropertyHandler(CSSPropertyWebkitMaskRepeatX, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyWebkitMaskRepeatX, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isRepeatXSet, &FillLayer::repeatX, &FillLayer::setRepeatX, &FillLayer::clearRepeatX, &FillLayer::initialFillRepeatX, &CSSToStyleMap::mapFillRepeatX>::createHandler());
1284     setPropertyHandler(CSSPropertyWebkitMaskRepeatY, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyWebkitMaskRepeatY, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isRepeatYSet, &FillLayer::repeatY, &FillLayer::setRepeatY, &FillLayer::clearRepeatY, &FillLayer::initialFillRepeatY, &CSSToStyleMap::mapFillRepeatY>::createHandler());
1285     setPropertyHandler(CSSPropertyWebkitMaskSize, ApplyPropertyFillLayer<FillSize, CSSPropertyWebkitMaskSize, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSToStyleMap::mapFillSize>::createHandler());
1286     setPropertyHandler(CSSPropertyWebkitMaskSourceType, ApplyPropertyFillLayer<EMaskSourceType, CSSPropertyWebkitMaskSourceType, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isMaskSourceTypeSet, &FillLayer::maskSourceType, &FillLayer::setMaskSourceType, &FillLayer::clearMaskSourceType, &FillLayer::initialMaskSourceType, &CSSToStyleMap::mapFillMaskSourceType>::createHandler());
1287     setPropertyHandler(CSSPropertyWebkitPerspectiveOrigin, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitPerspectiveOriginX, CSSPropertyWebkitPerspectiveOriginY>::createHandler());
1288     setPropertyHandler(CSSPropertyWebkitTextEmphasisColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textEmphasisColor, &RenderStyle::setTextEmphasisColor, &RenderStyle::setVisitedLinkTextEmphasisColor, &RenderStyle::color>::createHandler());
1289     setPropertyHandler(CSSPropertyWebkitTextEmphasisStyle, ApplyPropertyTextEmphasisStyle::createHandler());
1290     setPropertyHandler(CSSPropertyWebkitTextFillColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textFillColor, &RenderStyle::setTextFillColor, &RenderStyle::setVisitedLinkTextFillColor, &RenderStyle::color>::createHandler());
1291     setPropertyHandler(CSSPropertyWebkitTextStrokeColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textStrokeColor, &RenderStyle::setTextStrokeColor, &RenderStyle::setVisitedLinkTextStrokeColor, &RenderStyle::color>::createHandler());
1292     setPropertyHandler(CSSPropertyWebkitTransitionDelay, ApplyPropertyAnimation<double, &Animation::delay, &Animation::setDelay, &Animation::isDelaySet, &Animation::clearDelay, &Animation::initialAnimationDelay, &CSSToStyleMap::mapAnimationDelay, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
1293     setPropertyHandler(CSSPropertyWebkitTransitionDuration, ApplyPropertyAnimation<double, &Animation::duration, &Animation::setDuration, &Animation::isDurationSet, &Animation::clearDuration, &Animation::initialAnimationDuration, &CSSToStyleMap::mapAnimationDuration, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
1294     setPropertyHandler(CSSPropertyWebkitTransitionProperty, ApplyPropertyAnimation<CSSPropertyID, &Animation::property, &Animation::setProperty, &Animation::isPropertySet, &Animation::clearProperty, &Animation::initialAnimationProperty, &CSSToStyleMap::mapAnimationProperty, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
1295     setPropertyHandler(CSSPropertyWebkitTransitionTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSToStyleMap::mapAnimationTimingFunction, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
1296     setPropertyHandler(CSSPropertyWidows, ApplyPropertyAuto<short, &RenderStyle::widows, &RenderStyle::setWidows, &RenderStyle::hasAutoWidows, &RenderStyle::setHasAutoWidows>::createHandler());
1297
1298     setPropertyHandler(CSSPropertyZIndex, ApplyPropertyAuto<int, &RenderStyle::zIndex, &RenderStyle::setZIndex, &RenderStyle::hasAutoZIndex, &RenderStyle::setHasAutoZIndex>::createHandler());
1299 }
1300
1301
1302 }