4e36000ef2beb7d5ced038336fa8e3f88e3adf2d
[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 static inline CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver& styleResolver)
929 {
930     if (Frame* frame = styleResolver.document().frame())
931         return styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(styleResolver.style()->effectiveZoom() * frame->textZoomFactor());
932
933     return styleResolver.state().cssToLengthConversionData();
934 }
935
936 class ApplyPropertyTextDecorationSkip {
937 public:
938     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
939     {
940         if (is<CSSPrimitiveValue>(*value)) {
941             styleResolver->style()->setTextDecorationSkip(valueToDecorationSkip(downcast<CSSPrimitiveValue>(*value)));
942             return;
943         }
944
945         TextDecorationSkip skip = RenderStyle::initialTextDecorationSkip();
946         if (is<CSSValueList>(*value)) {
947             for (auto& currentValue : downcast<CSSValueList>(*value))
948                 skip |= valueToDecorationSkip(downcast<CSSPrimitiveValue>(currentValue.get()));
949         }
950         styleResolver->style()->setTextDecorationSkip(skip);
951     }
952     static PropertyHandler createHandler()
953     {
954         PropertyHandler handler = ApplyPropertyDefaultBase<TextDecorationSkip, &RenderStyle::textDecorationSkip, TextDecorationSkip, &RenderStyle::setTextDecorationSkip, TextDecorationSkip, &RenderStyle::initialTextDecorationSkip>::createHandler();
955         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
956     }
957 };
958
959 class ApplyPropertyMarqueeRepetition {
960 public:
961     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
962     {
963         if (!is<CSSPrimitiveValue>(*value))
964             return;
965
966         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
967         if (primitiveValue.getValueID() == CSSValueInfinite)
968             styleResolver->style()->setMarqueeLoopCount(-1); // -1 means repeat forever.
969         else if (primitiveValue.isNumber())
970             styleResolver->style()->setMarqueeLoopCount(primitiveValue.getIntValue());
971     }
972     static PropertyHandler createHandler()
973     {
974         PropertyHandler handler = ApplyPropertyDefault<int, &RenderStyle::marqueeLoopCount, int, &RenderStyle::setMarqueeLoopCount, int, &RenderStyle::initialMarqueeLoopCount>::createHandler();
975         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
976     }
977 };
978
979 class ApplyPropertyTextUnderlinePosition {
980 public:
981     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
982     {
983         // This is true if value is 'auto' or 'alphabetic'.
984         if (is<CSSPrimitiveValue>(*value)) {
985             TextUnderlinePosition t = downcast<CSSPrimitiveValue>(*value);
986             styleResolver->style()->setTextUnderlinePosition(t);
987             return;
988         }
989
990         unsigned t = 0;
991         if (is<CSSValueList>(*value)) {
992             for (auto& currentValue : downcast<CSSValueList>(*value)) {
993                 TextUnderlinePosition t2 = downcast<CSSPrimitiveValue>(currentValue.get());
994                 t |= t2;
995             }
996         }
997         styleResolver->style()->setTextUnderlinePosition(static_cast<TextUnderlinePosition>(t));
998     }
999     static PropertyHandler createHandler()
1000     {
1001         PropertyHandler handler = ApplyPropertyDefaultBase<TextUnderlinePosition, &RenderStyle::textUnderlinePosition, TextUnderlinePosition, &RenderStyle::setTextUnderlinePosition, TextUnderlinePosition, &RenderStyle::initialTextUnderlinePosition>::createHandler();
1002         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
1003     }
1004 };
1005
1006 class ApplyPropertyLineHeight {
1007 public:
1008     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
1009     {
1010         if (!is<CSSPrimitiveValue>(*value))
1011             return;
1012
1013         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
1014         Length lineHeight;
1015
1016         if (primitiveValue.getValueID() == CSSValueNormal)
1017             lineHeight = RenderStyle::initialLineHeight();
1018         else if (primitiveValue.isLength())
1019             lineHeight = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(*styleResolver));
1020         else if (primitiveValue.isPercentage()) {
1021             // FIXME: percentage should not be restricted to an integer here.
1022             lineHeight = Length((styleResolver->style()->computedFontSize() * primitiveValue.getIntValue()) / 100, Fixed);
1023         } else if (primitiveValue.isNumber()) {
1024             // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent).
1025             lineHeight = Length(primitiveValue.getDoubleValue() * 100.0, Percent);
1026         } else
1027             return;
1028         styleResolver->style()->setLineHeight(lineHeight);
1029     }
1030     static PropertyHandler createHandler()
1031     {
1032         PropertyHandler handler = ApplyPropertyDefaultBase<const Length&, &RenderStyle::specifiedLineHeight, Length, &RenderStyle::setLineHeight, Length, &RenderStyle::initialLineHeight>::createHandler();
1033         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
1034     }
1035 };
1036
1037 #if ENABLE(IOS_TEXT_AUTOSIZING)
1038 // FIXME: Share more code with class ApplyPropertyLineHeight.
1039 class ApplyPropertyLineHeightForIOSTextAutosizing {
1040 public:
1041     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
1042     {
1043         if (!is<CSSPrimitiveValue>(*value))
1044             return;
1045
1046         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
1047         Length lineHeight;
1048
1049         if (primitiveValue.getValueID() == CSSValueNormal)
1050             lineHeight = RenderStyle::initialLineHeight();
1051         else if (primitiveValue.isLength()) {
1052             lineHeight = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(*styleResolver));
1053             if (styleResolver->style()->textSizeAdjust().isPercentage())
1054                 lineHeight = Length(lineHeight.value() * styleResolver->style()->textSizeAdjust().multiplier(), Fixed);
1055         } else if (primitiveValue.isPercentage()) {
1056             // FIXME: percentage should not be restricted to an integer here.
1057             lineHeight = Length((styleResolver->style()->fontSize() * primitiveValue.getIntValue()) / 100, Fixed);
1058         } else if (primitiveValue.isNumber()) {
1059             // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent).
1060             if (styleResolver->style()->textSizeAdjust().isPercentage())
1061                 lineHeight = Length(primitiveValue.getDoubleValue() * styleResolver->style()->textSizeAdjust().multiplier() * 100.0, Percent);
1062             else
1063                 lineHeight = Length(primitiveValue.getDoubleValue() * 100.0, Percent);
1064         } else
1065             return;
1066         styleResolver->style()->setLineHeight(lineHeight);
1067         styleResolver->style()->setSpecifiedLineHeight(lineHeight);
1068     }
1069
1070     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
1071     {
1072         styleResolver->style()->setLineHeight(RenderStyle::initialLineHeight());
1073         styleResolver->style()->setSpecifiedLineHeight(RenderStyle::initialSpecifiedLineHeight());
1074     }
1075
1076     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
1077     {
1078         styleResolver->style()->setLineHeight(styleResolver->parentStyle()->lineHeight());
1079         styleResolver->style()->setSpecifiedLineHeight(styleResolver->parentStyle()->specifiedLineHeight());
1080     }
1081
1082     static PropertyHandler createHandler()
1083     {
1084         return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
1085     }
1086 };
1087 #endif
1088
1089 class ApplyPropertyWordSpacing {
1090 public:
1091     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
1092     {
1093         if (!is<CSSPrimitiveValue>(*value))
1094             return;
1095
1096         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
1097         Length wordSpacing;
1098
1099         if (primitiveValue.getValueID() == CSSValueNormal)
1100             wordSpacing = RenderStyle::initialWordSpacing();
1101         else if (primitiveValue.isLength()) {
1102             wordSpacing = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(*styleResolver));
1103         } else if (primitiveValue.isPercentage())
1104             wordSpacing = Length(clampTo<float>(primitiveValue.getDoubleValue(), minValueForCssLength, maxValueForCssLength), Percent);
1105         else if (primitiveValue.isNumber())
1106             wordSpacing = Length(primitiveValue.getDoubleValue(), Fixed);
1107         else
1108             return;
1109         styleResolver->style()->setWordSpacing(wordSpacing);
1110     }
1111     static PropertyHandler createHandler()
1112     {
1113         PropertyHandler handler = ApplyPropertyDefaultBase<const Length&, &RenderStyle::wordSpacing, Length, &RenderStyle::setWordSpacing, Length, &RenderStyle::initialWordSpacing>::createHandler();
1114         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
1115     }
1116 };
1117
1118 class ApplyPropertyTextEmphasisStyle {
1119 public:
1120     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
1121     {
1122         styleResolver->style()->setTextEmphasisFill(styleResolver->parentStyle()->textEmphasisFill());
1123         styleResolver->style()->setTextEmphasisMark(styleResolver->parentStyle()->textEmphasisMark());
1124         styleResolver->style()->setTextEmphasisCustomMark(styleResolver->parentStyle()->textEmphasisCustomMark());
1125     }
1126
1127     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
1128     {
1129         styleResolver->style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill());
1130         styleResolver->style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark());
1131         styleResolver->style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCustomMark());
1132     }
1133
1134     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
1135     {
1136         if (is<CSSValueList>(*value)) {
1137             CSSValueList& list = downcast<CSSValueList>(*value);
1138             ASSERT(list.length() == 2);
1139             if (list.length() != 2)
1140                 return;
1141             for (unsigned i = 0; i < 2; ++i) {
1142                 CSSValue* item = list.itemWithoutBoundsCheck(i);
1143                 if (!is<CSSPrimitiveValue>(*item))
1144                     continue;
1145
1146                 CSSPrimitiveValue& value = downcast<CSSPrimitiveValue>(*item);
1147                 if (value.getValueID() == CSSValueFilled || value.getValueID() == CSSValueOpen)
1148                     styleResolver->style()->setTextEmphasisFill(value);
1149                 else
1150                     styleResolver->style()->setTextEmphasisMark(value);
1151             }
1152             styleResolver->style()->setTextEmphasisCustomMark(nullAtom);
1153             return;
1154         }
1155
1156         if (!is<CSSPrimitiveValue>(*value))
1157             return;
1158         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
1159
1160         if (primitiveValue.isString()) {
1161             styleResolver->style()->setTextEmphasisFill(TextEmphasisFillFilled);
1162             styleResolver->style()->setTextEmphasisMark(TextEmphasisMarkCustom);
1163             styleResolver->style()->setTextEmphasisCustomMark(primitiveValue.getStringValue());
1164             return;
1165         }
1166
1167         styleResolver->style()->setTextEmphasisCustomMark(nullAtom);
1168
1169         if (primitiveValue.getValueID() == CSSValueFilled || primitiveValue.getValueID() == CSSValueOpen) {
1170             styleResolver->style()->setTextEmphasisFill(primitiveValue);
1171             styleResolver->style()->setTextEmphasisMark(TextEmphasisMarkAuto);
1172         } else {
1173             styleResolver->style()->setTextEmphasisFill(TextEmphasisFillFilled);
1174             styleResolver->style()->setTextEmphasisMark(primitiveValue);
1175         }
1176     }
1177
1178     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
1179 };
1180
1181 template <typename T,
1182           T (Animation::*getterFunction)() const,
1183           void (Animation::*setterFunction)(T),
1184           bool (Animation::*testFunction)() const,
1185           void (Animation::*clearFunction)(),
1186           T (*initialFunction)(),
1187           void (CSSToStyleMap::*mapFunction)(Animation*, CSSValue&),
1188           AnimationList* (RenderStyle::*animationGetterFunction)(),
1189           const AnimationList* (RenderStyle::*immutableAnimationGetterFunction)() const>
1190 class ApplyPropertyAnimation {
1191 public:
1192     static void setValue(Animation& animation, T value) { (animation.*setterFunction)(value); }
1193     static T value(const Animation& animation) { return (animation.*getterFunction)(); }
1194     static bool test(const Animation& animation) { return (animation.*testFunction)(); }
1195     static void clear(Animation& animation) { (animation.*clearFunction)(); }
1196     static T initial() { return (*initialFunction)(); }
1197     static void map(StyleResolver* styleResolver, Animation& animation, CSSValue& value) { (styleResolver->styleMap()->*mapFunction)(&animation, value); }
1198     static AnimationList* accessAnimations(RenderStyle* style) { return (style->*animationGetterFunction)(); }
1199     static const AnimationList* animations(RenderStyle* style) { return (style->*immutableAnimationGetterFunction)(); }
1200
1201     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
1202     {
1203         AnimationList* list = accessAnimations(styleResolver->style());
1204         const AnimationList* parentList = animations(styleResolver->parentStyle());
1205         size_t i = 0, parentSize = parentList ? parentList->size() : 0;
1206         for ( ; i < parentSize && test(parentList->animation(i)); ++i) {
1207             if (list->size() <= i)
1208                 list->append(Animation::create());
1209             setValue(list->animation(i), value(parentList->animation(i)));
1210             list->animation(i).setAnimationMode(parentList->animation(i).animationMode());
1211         }
1212
1213         /* Reset any remaining animations to not have the property set. */
1214         for ( ; i < list->size(); ++i)
1215             clear(list->animation(i));
1216     }
1217
1218     static void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver)
1219     {
1220         AnimationList* list = accessAnimations(styleResolver->style());
1221         if (list->isEmpty())
1222             list->append(Animation::create());
1223         setValue(list->animation(0), initial());
1224         if (propertyID == CSSPropertyWebkitTransitionProperty)
1225             list->animation(0).setAnimationMode(Animation::AnimateAll);
1226         for (size_t i = 1; i < list->size(); ++i)
1227             clear(list->animation(i));
1228     }
1229
1230     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
1231     {
1232         AnimationList* list = accessAnimations(styleResolver->style());
1233         size_t childIndex = 0;
1234         if (is<CSSValueList>(*value)) {
1235             /* Walk each value and put it into an animation, creating new animations as needed. */
1236             for (auto& currentValue : downcast<CSSValueList>(*value)) {
1237                 if (childIndex <= list->size())
1238                     list->append(Animation::create());
1239                 map(styleResolver, list->animation(childIndex), currentValue);
1240                 ++childIndex;
1241             }
1242         } else {
1243             if (list->isEmpty())
1244                 list->append(Animation::create());
1245             map(styleResolver, list->animation(childIndex), *value);
1246             childIndex = 1;
1247         }
1248         for ( ; childIndex < list->size(); ++childIndex) {
1249             /* Reset all remaining animations to not have the property set. */
1250             clear(list->animation(childIndex));
1251         }
1252     }
1253
1254     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
1255 };
1256
1257 class ApplyPropertyOutlineStyle {
1258 public:
1259     static void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver)
1260     {
1261         ApplyPropertyDefaultBase<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyInheritValue(propertyID, styleResolver);
1262         ApplyPropertyDefaultBase<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyInheritValue(propertyID, styleResolver);
1263     }
1264
1265     static void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver)
1266     {
1267         ApplyPropertyDefaultBase<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyInitialValue(propertyID, styleResolver);
1268         ApplyPropertyDefaultBase<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyInitialValue(propertyID, styleResolver);
1269     }
1270
1271     static void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value)
1272     {
1273         ApplyPropertyDefault<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyValue(propertyID, styleResolver, value);
1274         ApplyPropertyDefault<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyValue(propertyID, styleResolver, value);
1275     }
1276
1277     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
1278 };
1279
1280 class ApplyPropertyAspectRatio {
1281 public:
1282     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
1283     {
1284         if (styleResolver->parentStyle()->aspectRatioType() == AspectRatioAuto)
1285             return;
1286         styleResolver->style()->setAspectRatioType(styleResolver->parentStyle()->aspectRatioType());
1287         styleResolver->style()->setAspectRatioDenominator(styleResolver->parentStyle()->aspectRatioDenominator());
1288         styleResolver->style()->setAspectRatioNumerator(styleResolver->parentStyle()->aspectRatioNumerator());
1289     }
1290
1291     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
1292     {
1293         styleResolver->style()->setAspectRatioType(RenderStyle::initialAspectRatioType());
1294         styleResolver->style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDenominator());
1295         styleResolver->style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumerator());
1296     }
1297
1298     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
1299     {
1300         if (is<CSSPrimitiveValue>(*value)) {
1301             CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
1302
1303             if (primitiveValue.getValueID() == CSSValueAuto)
1304                 return styleResolver->style()->setAspectRatioType(AspectRatioAuto);
1305             if (primitiveValue.getValueID() == CSSValueFromDimensions)
1306                 return styleResolver->style()->setAspectRatioType(AspectRatioFromDimensions);
1307             if (primitiveValue.getValueID() == CSSValueFromIntrinsic)
1308                 return styleResolver->style()->setAspectRatioType(AspectRatioFromIntrinsic);
1309         }
1310
1311         if (!is<CSSAspectRatioValue>(*value)) {
1312             styleResolver->style()->setAspectRatioType(AspectRatioAuto);
1313             return;
1314         }
1315
1316         CSSAspectRatioValue& aspectRatioValue = downcast<CSSAspectRatioValue>(*value);
1317         styleResolver->style()->setAspectRatioType(AspectRatioSpecified);
1318         styleResolver->style()->setAspectRatioDenominator(aspectRatioValue.denominatorValue());
1319         styleResolver->style()->setAspectRatioNumerator(aspectRatioValue.numeratorValue());
1320     }
1321
1322     static PropertyHandler createHandler()
1323     {
1324         return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
1325     }
1326 };
1327
1328 class ApplyPropertyDisplay {
1329 private:
1330     static inline bool isValidDisplayValue(StyleResolver* styleResolver, EDisplay displayPropertyValue)
1331     {
1332         if (styleResolver->element() && styleResolver->element()->isSVGElement() && styleResolver->style()->styleType() == NOPSEUDO)
1333             return (displayPropertyValue == INLINE || displayPropertyValue == BLOCK || displayPropertyValue == NONE);
1334         return true;
1335     }
1336 public:
1337     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
1338     {
1339         EDisplay display = styleResolver->parentStyle()->display();
1340         if (!isValidDisplayValue(styleResolver, display))
1341             return;
1342         styleResolver->style()->setDisplay(display);
1343     }
1344
1345     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
1346     {
1347         styleResolver->style()->setDisplay(RenderStyle::initialDisplay());
1348     }
1349
1350     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
1351     {
1352         if (!is<CSSPrimitiveValue>(*value))
1353             return;
1354
1355         EDisplay display = downcast<CSSPrimitiveValue>(*value);
1356
1357         if (!isValidDisplayValue(styleResolver, display))
1358             return;
1359
1360         styleResolver->style()->setDisplay(display);
1361     }
1362
1363     static PropertyHandler createHandler()
1364     {
1365         return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
1366     }
1367 };
1368
1369 const DeprecatedStyleBuilder& DeprecatedStyleBuilder::sharedStyleBuilder()
1370 {
1371     static NeverDestroyed<DeprecatedStyleBuilder> styleBuilderInstance;
1372     return styleBuilderInstance;
1373 }
1374
1375 DeprecatedStyleBuilder::DeprecatedStyleBuilder()
1376 {
1377     for (int i = 0; i < numCSSProperties; ++i)
1378         m_propertyMap[i] = PropertyHandler();
1379
1380     // Please keep CSS property list in alphabetical order.
1381     setPropertyHandler(CSSPropertyBackgroundAttachment, ApplyPropertyFillLayer<EFillAttachment, CSSPropertyBackgroundAttachment, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isAttachmentSet, &FillLayer::attachment, &FillLayer::setAttachment, &FillLayer::clearAttachment, &FillLayer::initialFillAttachment, &CSSToStyleMap::mapFillAttachment>::createHandler());
1382     setPropertyHandler(CSSPropertyBackgroundBlendMode, ApplyPropertyFillLayer<BlendMode, CSSPropertyBackgroundBlendMode, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isBlendModeSet, &FillLayer::blendMode, &FillLayer::setBlendMode, &FillLayer::clearBlendMode, &FillLayer::initialFillBlendMode, &CSSToStyleMap::mapFillBlendMode>::createHandler());
1383     setPropertyHandler(CSSPropertyBackgroundClip, ApplyPropertyFillLayer<EFillBox, CSSPropertyBackgroundClip, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isClipSet, &FillLayer::clip, &FillLayer::setClip, &FillLayer::clearClip, &FillLayer::initialFillClip, &CSSToStyleMap::mapFillClip>::createHandler());
1384     setPropertyHandler(CSSPropertyBackgroundColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::backgroundColor, &RenderStyle::setBackgroundColor, &RenderStyle::setVisitedLinkBackgroundColor, &RenderStyle::invalidColor>::createHandler());
1385     setPropertyHandler(CSSPropertyBackgroundImage, ApplyPropertyFillLayer<StyleImage*, CSSPropertyBackgroundImage, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isImageSet, &FillLayer::image, &FillLayer::setImage, &FillLayer::clearImage, &FillLayer::initialFillImage, &CSSToStyleMap::mapFillImage>::createHandler());
1386     setPropertyHandler(CSSPropertyBackgroundOrigin, ApplyPropertyFillLayer<EFillBox, CSSPropertyBackgroundOrigin, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &CSSToStyleMap::mapFillOrigin>::createHandler());
1387     setPropertyHandler(CSSPropertyBackgroundPositionX, ApplyPropertyFillLayer<Length, CSSPropertyBackgroundPositionX, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isXPositionSet, &FillLayer::xPosition, &FillLayer::setXPosition, &FillLayer::clearXPosition, &FillLayer::initialFillXPosition, &CSSToStyleMap::mapFillXPosition>::createHandler());
1388     setPropertyHandler(CSSPropertyBackgroundPositionY, ApplyPropertyFillLayer<Length, CSSPropertyBackgroundPositionY, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isYPositionSet, &FillLayer::yPosition, &FillLayer::setYPosition, &FillLayer::clearYPosition, &FillLayer::initialFillYPosition, &CSSToStyleMap::mapFillYPosition>::createHandler());
1389     setPropertyHandler(CSSPropertyBackgroundRepeatX, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyBackgroundRepeatX, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isRepeatXSet, &FillLayer::repeatX, &FillLayer::setRepeatX, &FillLayer::clearRepeatX, &FillLayer::initialFillRepeatX, &CSSToStyleMap::mapFillRepeatX>::createHandler());
1390     setPropertyHandler(CSSPropertyBackgroundRepeatY, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyBackgroundRepeatY, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isRepeatYSet, &FillLayer::repeatY, &FillLayer::setRepeatY, &FillLayer::clearRepeatY, &FillLayer::initialFillRepeatY, &CSSToStyleMap::mapFillRepeatY>::createHandler());
1391     setPropertyHandler(CSSPropertyBackgroundSize, ApplyPropertyFillLayer<FillSize, CSSPropertyBackgroundSize, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSToStyleMap::mapFillSize>::createHandler());
1392     setPropertyHandler(CSSPropertyBorderBottomColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderBottomColor, &RenderStyle::setBorderBottomColor, &RenderStyle::setVisitedLinkBorderBottomColor, &RenderStyle::color>::createHandler());
1393     setPropertyHandler(CSSPropertyBorderLeftColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderLeftColor, &RenderStyle::setBorderLeftColor, &RenderStyle::setVisitedLinkBorderLeftColor, &RenderStyle::color>::createHandler());
1394     setPropertyHandler(CSSPropertyBorderRightColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderRightColor, &RenderStyle::setBorderRightColor, &RenderStyle::setVisitedLinkBorderRightColor, &RenderStyle::color>::createHandler());
1395     setPropertyHandler(CSSPropertyBorderTopColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderTopColor, &RenderStyle::setBorderTopColor, &RenderStyle::setVisitedLinkBorderTopColor, &RenderStyle::color>::createHandler());
1396     setPropertyHandler(CSSPropertyClip, ApplyPropertyClip::createHandler());
1397     setPropertyHandler(CSSPropertyColor, ApplyPropertyColor<InheritFromParent, &RenderStyle::color, &RenderStyle::setColor, &RenderStyle::setVisitedLinkColor, &RenderStyle::invalidColor, RenderStyle::initialColor>::createHandler());
1398     setPropertyHandler(CSSPropertyCounterIncrement, ApplyPropertyCounter<Increment>::createHandler());
1399     setPropertyHandler(CSSPropertyCounterReset, ApplyPropertyCounter<Reset>::createHandler());
1400     setPropertyHandler(CSSPropertyCursor, ApplyPropertyCursor::createHandler());
1401     setPropertyHandler(CSSPropertyDisplay, ApplyPropertyDisplay::createHandler());
1402     setPropertyHandler(CSSPropertyFontFamily, ApplyPropertyFontFamily::createHandler());
1403     setPropertyHandler(CSSPropertyFontSize, ApplyPropertyFontSize::createHandler());
1404     setPropertyHandler(CSSPropertyFontStyle, ApplyPropertyFont<FontItalic, &FontDescription::italic, &FontDescription::setItalic, FontItalicOff>::createHandler());
1405     setPropertyHandler(CSSPropertyFontVariant, ApplyPropertyFont<FontSmallCaps, &FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff>::createHandler());
1406     setPropertyHandler(CSSPropertyFontWeight, ApplyPropertyFontWeight::createHandler());
1407 #if ENABLE(IOS_TEXT_AUTOSIZING)
1408     setPropertyHandler(CSSPropertyLineHeight, ApplyPropertyLineHeightForIOSTextAutosizing::createHandler());
1409 #else
1410     setPropertyHandler(CSSPropertyLineHeight, ApplyPropertyLineHeight::createHandler());
1411 #endif
1412     setPropertyHandler(CSSPropertyListStyleImage, ApplyPropertyStyleImage<&RenderStyle::listStyleImage, &RenderStyle::setListStyleImage, &RenderStyle::initialListStyleImage, CSSPropertyListStyleImage>::createHandler());
1413     setPropertyHandler(CSSPropertyOrphans, ApplyPropertyAuto<short, &RenderStyle::orphans, &RenderStyle::setOrphans, &RenderStyle::hasAutoOrphans, &RenderStyle::setHasAutoOrphans>::createHandler());
1414     setPropertyHandler(CSSPropertyOutlineColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::outlineColor, &RenderStyle::setOutlineColor, &RenderStyle::setVisitedLinkOutlineColor, &RenderStyle::color>::createHandler());
1415     setPropertyHandler(CSSPropertyOutlineStyle, ApplyPropertyOutlineStyle::createHandler());
1416     setPropertyHandler(CSSPropertyWebkitTextDecorationColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textDecorationColor, &RenderStyle::setTextDecorationColor, &RenderStyle::setVisitedLinkTextDecorationColor, &RenderStyle::color>::createHandler());
1417     setPropertyHandler(CSSPropertyWebkitTextDecorationSkip, ApplyPropertyTextDecorationSkip::createHandler());
1418     setPropertyHandler(CSSPropertyWebkitTextUnderlinePosition, ApplyPropertyTextUnderlinePosition::createHandler());
1419     setPropertyHandler(CSSPropertyTextRendering, ApplyPropertyFont<TextRenderingMode, &FontDescription::textRenderingMode, &FontDescription::setTextRenderingMode, AutoTextRendering>::createHandler());
1420
1421     setPropertyHandler(CSSPropertyAnimationDelay, ApplyPropertyAnimation<double, &Animation::delay, &Animation::setDelay, &Animation::isDelaySet, &Animation::clearDelay, &Animation::initialAnimationDelay, &CSSToStyleMap::mapAnimationDelay, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1422     setPropertyHandler(CSSPropertyAnimationDirection, ApplyPropertyAnimation<Animation::AnimationDirection, &Animation::direction, &Animation::setDirection, &Animation::isDirectionSet, &Animation::clearDirection, &Animation::initialAnimationDirection, &CSSToStyleMap::mapAnimationDirection, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1423     setPropertyHandler(CSSPropertyAnimationDuration, ApplyPropertyAnimation<double, &Animation::duration, &Animation::setDuration, &Animation::isDurationSet, &Animation::clearDuration, &Animation::initialAnimationDuration, &CSSToStyleMap::mapAnimationDuration, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1424     setPropertyHandler(CSSPropertyAnimationFillMode, ApplyPropertyAnimation<unsigned, &Animation::fillMode, &Animation::setFillMode, &Animation::isFillModeSet, &Animation::clearFillMode, &Animation::initialAnimationFillMode, &CSSToStyleMap::mapAnimationFillMode, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1425     setPropertyHandler(CSSPropertyAnimationIterationCount, ApplyPropertyAnimation<double, &Animation::iterationCount, &Animation::setIterationCount, &Animation::isIterationCountSet, &Animation::clearIterationCount, &Animation::initialAnimationIterationCount, &CSSToStyleMap::mapAnimationIterationCount, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1426     setPropertyHandler(CSSPropertyAnimationName, ApplyPropertyAnimation<const String&, &Animation::name, &Animation::setName, &Animation::isNameSet, &Animation::clearName, &Animation::initialAnimationName, &CSSToStyleMap::mapAnimationName, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1427     setPropertyHandler(CSSPropertyAnimationPlayState, ApplyPropertyAnimation<EAnimPlayState, &Animation::playState, &Animation::setPlayState, &Animation::isPlayStateSet, &Animation::clearPlayState, &Animation::initialAnimationPlayState, &CSSToStyleMap::mapAnimationPlayState, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1428     setPropertyHandler(CSSPropertyAnimationTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSToStyleMap::mapAnimationTimingFunction, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1429
1430     setPropertyHandler(CSSPropertyWebkitAnimationDelay, ApplyPropertyAnimation<double, &Animation::delay, &Animation::setDelay, &Animation::isDelaySet, &Animation::clearDelay, &Animation::initialAnimationDelay, &CSSToStyleMap::mapAnimationDelay, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1431     setPropertyHandler(CSSPropertyWebkitAnimationDirection, ApplyPropertyAnimation<Animation::AnimationDirection, &Animation::direction, &Animation::setDirection, &Animation::isDirectionSet, &Animation::clearDirection, &Animation::initialAnimationDirection, &CSSToStyleMap::mapAnimationDirection, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1432     setPropertyHandler(CSSPropertyWebkitAnimationDuration, ApplyPropertyAnimation<double, &Animation::duration, &Animation::setDuration, &Animation::isDurationSet, &Animation::clearDuration, &Animation::initialAnimationDuration, &CSSToStyleMap::mapAnimationDuration, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1433     setPropertyHandler(CSSPropertyWebkitAnimationFillMode, ApplyPropertyAnimation<unsigned, &Animation::fillMode, &Animation::setFillMode, &Animation::isFillModeSet, &Animation::clearFillMode, &Animation::initialAnimationFillMode, &CSSToStyleMap::mapAnimationFillMode, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1434     setPropertyHandler(CSSPropertyWebkitAnimationIterationCount, ApplyPropertyAnimation<double, &Animation::iterationCount, &Animation::setIterationCount, &Animation::isIterationCountSet, &Animation::clearIterationCount, &Animation::initialAnimationIterationCount, &CSSToStyleMap::mapAnimationIterationCount, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1435     setPropertyHandler(CSSPropertyWebkitAnimationName, ApplyPropertyAnimation<const String&, &Animation::name, &Animation::setName, &Animation::isNameSet, &Animation::clearName, &Animation::initialAnimationName, &CSSToStyleMap::mapAnimationName, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1436     setPropertyHandler(CSSPropertyWebkitAnimationPlayState, ApplyPropertyAnimation<EAnimPlayState, &Animation::playState, &Animation::setPlayState, &Animation::isPlayStateSet, &Animation::clearPlayState, &Animation::initialAnimationPlayState, &CSSToStyleMap::mapAnimationPlayState, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1437     setPropertyHandler(CSSPropertyWebkitAnimationTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSToStyleMap::mapAnimationTimingFunction, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1438     setPropertyHandler(CSSPropertyWebkitAspectRatio, ApplyPropertyAspectRatio::createHandler());
1439     setPropertyHandler(CSSPropertyWebkitBackgroundClip, CSSPropertyBackgroundClip);
1440     setPropertyHandler(CSSPropertyWebkitBackgroundComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitBackgroundComposite, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSToStyleMap::mapFillComposite>::createHandler());
1441     setPropertyHandler(CSSPropertyWebkitBackgroundOrigin, CSSPropertyBackgroundOrigin);
1442     setPropertyHandler(CSSPropertyWebkitBackgroundSize, CSSPropertyBackgroundSize);
1443     setPropertyHandler(CSSPropertyColumnCount, ApplyPropertyAuto<unsigned short, &RenderStyle::columnCount, &RenderStyle::setColumnCount, &RenderStyle::hasAutoColumnCount, &RenderStyle::setHasAutoColumnCount>::createHandler());
1444     setPropertyHandler(CSSPropertyColumnGap, ApplyPropertyAuto<float, &RenderStyle::columnGap, &RenderStyle::setColumnGap, &RenderStyle::hasNormalColumnGap, &RenderStyle::setHasNormalColumnGap, ComputeLength, CSSValueNormal>::createHandler());
1445     setPropertyHandler(CSSPropertyColumnRuleColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::columnRuleColor, &RenderStyle::setColumnRuleColor, &RenderStyle::setVisitedLinkColumnRuleColor, &RenderStyle::color>::createHandler());
1446     setPropertyHandler(CSSPropertyColumnWidth, ApplyPropertyAuto<float, &RenderStyle::columnWidth, &RenderStyle::setColumnWidth, &RenderStyle::hasAutoColumnWidth, &RenderStyle::setHasAutoColumnWidth, ComputeLength>::createHandler());
1447     setPropertyHandler(CSSPropertyWebkitFontKerning, ApplyPropertyFont<FontDescription::Kerning, &FontDescription::kerning, &FontDescription::setKerning, FontDescription::AutoKerning>::createHandler());
1448     setPropertyHandler(CSSPropertyWebkitFontSmoothing, ApplyPropertyFont<FontSmoothingMode, &FontDescription::fontSmoothing, &FontDescription::setFontSmoothing, AutoSmoothing>::createHandler());
1449     setPropertyHandler(CSSPropertyWebkitFontVariantLigatures, ApplyPropertyFontVariantLigatures::createHandler());
1450     setPropertyHandler(CSSPropertyWebkitMarqueeRepetition, ApplyPropertyMarqueeRepetition::createHandler());
1451     setPropertyHandler(CSSPropertyWebkitMaskClip, ApplyPropertyFillLayer<EFillBox, CSSPropertyWebkitMaskClip, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isClipSet, &FillLayer::clip, &FillLayer::setClip, &FillLayer::clearClip, &FillLayer::initialFillClip, &CSSToStyleMap::mapFillClip>::createHandler());
1452     setPropertyHandler(CSSPropertyWebkitMaskComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitMaskComposite, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSToStyleMap::mapFillComposite>::createHandler());
1453     setPropertyHandler(CSSPropertyWebkitMaskImage, ApplyPropertyFillLayer<StyleImage*, CSSPropertyWebkitMaskImage, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isImageSet, &FillLayer::image, &FillLayer::setImage, &FillLayer::clearImage, &FillLayer::initialFillImage, &CSSToStyleMap::mapFillImage>::createHandler());
1454     setPropertyHandler(CSSPropertyWebkitMaskOrigin, ApplyPropertyFillLayer<EFillBox, CSSPropertyWebkitMaskOrigin, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &CSSToStyleMap::mapFillOrigin>::createHandler());
1455     setPropertyHandler(CSSPropertyWebkitMaskPositionX, ApplyPropertyFillLayer<Length, CSSPropertyWebkitMaskPositionX, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isXPositionSet, &FillLayer::xPosition, &FillLayer::setXPosition, &FillLayer::clearXPosition, &FillLayer::initialFillXPosition, &CSSToStyleMap::mapFillXPosition>::createHandler());
1456     setPropertyHandler(CSSPropertyWebkitMaskPositionY, ApplyPropertyFillLayer<Length, CSSPropertyWebkitMaskPositionY, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isYPositionSet, &FillLayer::yPosition, &FillLayer::setYPosition, &FillLayer::clearYPosition, &FillLayer::initialFillYPosition, &CSSToStyleMap::mapFillYPosition>::createHandler());
1457     setPropertyHandler(CSSPropertyWebkitMaskRepeatX, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyWebkitMaskRepeatX, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isRepeatXSet, &FillLayer::repeatX, &FillLayer::setRepeatX, &FillLayer::clearRepeatX, &FillLayer::initialFillRepeatX, &CSSToStyleMap::mapFillRepeatX>::createHandler());
1458     setPropertyHandler(CSSPropertyWebkitMaskRepeatY, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyWebkitMaskRepeatY, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isRepeatYSet, &FillLayer::repeatY, &FillLayer::setRepeatY, &FillLayer::clearRepeatY, &FillLayer::initialFillRepeatY, &CSSToStyleMap::mapFillRepeatY>::createHandler());
1459     setPropertyHandler(CSSPropertyWebkitMaskSize, ApplyPropertyFillLayer<FillSize, CSSPropertyWebkitMaskSize, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSToStyleMap::mapFillSize>::createHandler());
1460     setPropertyHandler(CSSPropertyWebkitMaskSourceType, ApplyPropertyFillLayer<EMaskSourceType, CSSPropertyWebkitMaskSourceType, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isMaskSourceTypeSet, &FillLayer::maskSourceType, &FillLayer::setMaskSourceType, &FillLayer::clearMaskSourceType, &FillLayer::initialMaskSourceType, &CSSToStyleMap::mapFillMaskSourceType>::createHandler());
1461     setPropertyHandler(CSSPropertyWebkitPerspectiveOrigin, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitPerspectiveOriginX, CSSPropertyWebkitPerspectiveOriginY>::createHandler());
1462     setPropertyHandler(CSSPropertyWebkitTextEmphasisColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textEmphasisColor, &RenderStyle::setTextEmphasisColor, &RenderStyle::setVisitedLinkTextEmphasisColor, &RenderStyle::color>::createHandler());
1463     setPropertyHandler(CSSPropertyWebkitTextEmphasisStyle, ApplyPropertyTextEmphasisStyle::createHandler());
1464     setPropertyHandler(CSSPropertyWebkitTextFillColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textFillColor, &RenderStyle::setTextFillColor, &RenderStyle::setVisitedLinkTextFillColor, &RenderStyle::color>::createHandler());
1465     setPropertyHandler(CSSPropertyWebkitTextStrokeColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textStrokeColor, &RenderStyle::setTextStrokeColor, &RenderStyle::setVisitedLinkTextStrokeColor, &RenderStyle::color>::createHandler());
1466     setPropertyHandler(CSSPropertyWebkitTransitionDelay, ApplyPropertyAnimation<double, &Animation::delay, &Animation::setDelay, &Animation::isDelaySet, &Animation::clearDelay, &Animation::initialAnimationDelay, &CSSToStyleMap::mapAnimationDelay, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
1467     setPropertyHandler(CSSPropertyWebkitTransitionDuration, ApplyPropertyAnimation<double, &Animation::duration, &Animation::setDuration, &Animation::isDurationSet, &Animation::clearDuration, &Animation::initialAnimationDuration, &CSSToStyleMap::mapAnimationDuration, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
1468     setPropertyHandler(CSSPropertyWebkitTransitionProperty, ApplyPropertyAnimation<CSSPropertyID, &Animation::property, &Animation::setProperty, &Animation::isPropertySet, &Animation::clearProperty, &Animation::initialAnimationProperty, &CSSToStyleMap::mapAnimationProperty, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
1469     setPropertyHandler(CSSPropertyWebkitTransitionTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSToStyleMap::mapAnimationTimingFunction, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
1470     setPropertyHandler(CSSPropertyWidows, ApplyPropertyAuto<short, &RenderStyle::widows, &RenderStyle::setWidows, &RenderStyle::hasAutoWidows, &RenderStyle::setHasAutoWidows>::createHandler());
1471     setPropertyHandler(CSSPropertyWordSpacing, ApplyPropertyWordSpacing::createHandler());
1472
1473     setPropertyHandler(CSSPropertyZIndex, ApplyPropertyAuto<int, &RenderStyle::zIndex, &RenderStyle::setZIndex, &RenderStyle::hasAutoZIndex, &RenderStyle::setHasAutoZIndex>::createHandler());
1474 }
1475
1476
1477 }