Rename flex-align to flex-item-align.
[WebKit-https.git] / Source / WebCore / css / CSSStyleApplyProperty.cpp
1 /*
2  * Copyright (C) 2011 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1.  Redistributions of source code must retain the above copyright
8  *     notice, this list of conditions and the following disclaimer.
9  * 2.  Redistributions in binary form must reproduce the above copyright
10  *     notice, this list of conditions and the following disclaimer in the
11  *     documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16  * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  */
24
25 #include "config.h"
26 #include "CSSStyleApplyProperty.h"
27
28 #include "CSSAspectRatioValue.h"
29 #include "CSSCursorImageValue.h"
30 #include "CSSFlexValue.h"
31 #include "CSSPrimitiveValueMappings.h"
32 #include "CSSStyleSelector.h"
33 #include "CSSValueList.h"
34 #include "CursorList.h"
35 #include "Document.h"
36 #include "Element.h"
37 #include "Pair.h"
38 #include "RenderObject.h"
39 #include "RenderStyle.h"
40 #include "Settings.h"
41 #include <wtf/StdLibExtras.h>
42 #include <wtf/UnusedParam.h>
43
44 using namespace std;
45
46 namespace WebCore {
47
48 enum ExpandValueBehavior {SuppressValue = 0, ExpandValue};
49 template <ExpandValueBehavior expandValue, CSSPropertyID one = CSSPropertyInvalid, CSSPropertyID two = CSSPropertyInvalid, CSSPropertyID three = CSSPropertyInvalid, CSSPropertyID four = CSSPropertyInvalid>
50 class ApplyPropertyExpanding {
51 public:
52
53     template <CSSPropertyID id>
54     static inline void applyInheritValue(CSSStyleSelector* selector)
55     {
56         if (id == CSSPropertyInvalid)
57             return;
58
59         const CSSStyleApplyProperty& table = CSSStyleApplyProperty::sharedCSSStyleApplyProperty();
60         const PropertyHandler& handler = table.propertyHandler(id);
61         if (handler.isValid())
62             handler.applyInheritValue(selector);
63     }
64
65     static void applyInheritValue(CSSStyleSelector* selector)
66     {
67         applyInheritValue<one>(selector);
68         applyInheritValue<two>(selector);
69         applyInheritValue<three>(selector);
70         applyInheritValue<four>(selector);
71     }
72
73     template <CSSPropertyID id>
74     static inline void applyInitialValue(CSSStyleSelector* selector)
75     {
76         if (id == CSSPropertyInvalid)
77             return;
78
79         const CSSStyleApplyProperty& table = CSSStyleApplyProperty::sharedCSSStyleApplyProperty();
80         const PropertyHandler& handler = table.propertyHandler(id);
81         if (handler.isValid())
82             handler.applyInitialValue(selector);
83     }
84
85     static void applyInitialValue(CSSStyleSelector* selector)
86     {
87         applyInitialValue<one>(selector);
88         applyInitialValue<two>(selector);
89         applyInitialValue<three>(selector);
90         applyInitialValue<four>(selector);
91     }
92
93     template <CSSPropertyID id>
94     static inline void applyValue(CSSStyleSelector* selector, CSSValue* value)
95     {
96         if (id == CSSPropertyInvalid)
97             return;
98
99         const CSSStyleApplyProperty& table = CSSStyleApplyProperty::sharedCSSStyleApplyProperty();
100         const PropertyHandler& handler = table.propertyHandler(id);
101         if (handler.isValid())
102             handler.applyValue(selector, value);
103     }
104
105     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
106     {
107         if (!expandValue)
108             return;
109
110         applyValue<one>(selector, value);
111         applyValue<two>(selector, value);
112         applyValue<three>(selector, value);
113         applyValue<four>(selector, value);
114     }
115     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
116 };
117
118 template <typename GetterType, GetterType (RenderStyle::*getterFunction)() const, typename SetterType, void (RenderStyle::*setterFunction)(SetterType), typename InitialType, InitialType (*initialFunction)()>
119 class ApplyPropertyDefaultBase {
120 public:
121     static void setValue(RenderStyle* style, SetterType value) { (style->*setterFunction)(value); }
122     static GetterType value(RenderStyle* style) { return (style->*getterFunction)(); }
123     static InitialType initial() { return (*initialFunction)(); }
124     static void applyInheritValue(CSSStyleSelector* selector) { setValue(selector->style(), value(selector->parentStyle())); }
125     static void applyInitialValue(CSSStyleSelector* selector) { setValue(selector->style(), initial()); }
126     static void applyValue(CSSStyleSelector*, CSSValue*) { }
127     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
128 };
129
130 template <typename GetterType, GetterType (RenderStyle::*getterFunction)() const, typename SetterType, void (RenderStyle::*setterFunction)(SetterType), typename InitialType, InitialType (*initialFunction)()>
131 class ApplyPropertyDefault {
132 public:
133     static void setValue(RenderStyle* style, SetterType value) { (style->*setterFunction)(value); }
134     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
135     {
136         if (value->isPrimitiveValue())
137             setValue(selector->style(), *static_cast<CSSPrimitiveValue*>(value));
138     }
139     static PropertyHandler createHandler()
140     {
141         PropertyHandler handler = ApplyPropertyDefaultBase<GetterType, getterFunction, SetterType, setterFunction, InitialType, initialFunction>::createHandler();
142         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
143     }
144 };
145
146 template <typename NumberType, NumberType (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(NumberType), NumberType (*initialFunction)(), int idMapsToMinusOne = CSSValueAuto>
147 class ApplyPropertyNumber {
148 public:
149     static void setValue(RenderStyle* style, NumberType value) { (style->*setterFunction)(value); }
150     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
151     {
152         if (!value->isPrimitiveValue())
153             return;
154
155         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
156         if (primitiveValue->getIdent() == idMapsToMinusOne)
157             setValue(selector->style(), -1);
158         else
159             setValue(selector->style(), primitiveValue->getValue<NumberType>(CSSPrimitiveValue::CSS_NUMBER));
160     }
161     static PropertyHandler createHandler()
162     {
163         PropertyHandler handler = ApplyPropertyDefaultBase<NumberType, getterFunction, NumberType, setterFunction, NumberType, initialFunction>::createHandler();
164         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
165     }
166 };
167
168 template <StyleImage* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<StyleImage>), StyleImage* (*initialFunction)(), CSSPropertyID property>
169 class ApplyPropertyStyleImage {
170 public:
171     static void applyValue(CSSStyleSelector* selector, CSSValue* value) { (selector->style()->*setterFunction)(selector->styleImage(property, value)); }
172     static PropertyHandler createHandler()
173     {
174         PropertyHandler handler = ApplyPropertyDefaultBase<StyleImage*, getterFunction, PassRefPtr<StyleImage>, setterFunction, StyleImage*, initialFunction>::createHandler();
175         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
176     }
177 };
178
179 enum AutoValueType {Number = 0, ComputeLength};
180 template <typename T, T (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(T), bool (RenderStyle::*hasAutoFunction)() const, void (RenderStyle::*setAutoFunction)(), AutoValueType valueType = Number, int autoIdentity = CSSValueAuto>
181 class ApplyPropertyAuto {
182 public:
183     static void setValue(RenderStyle* style, T value) { (style->*setterFunction)(value); }
184     static T value(RenderStyle* style) { return (style->*getterFunction)(); }
185     static bool hasAuto(RenderStyle* style) { return (style->*hasAutoFunction)(); }
186     static void setAuto(RenderStyle* style) { (style->*setAutoFunction)(); }
187
188     static void applyInheritValue(CSSStyleSelector* selector)
189     {
190         if (hasAuto(selector->parentStyle()))
191             setAuto(selector->style());
192         else
193             setValue(selector->style(), value(selector->parentStyle()));
194     }
195
196     static void applyInitialValue(CSSStyleSelector* selector) { setAuto(selector->style()); }
197
198     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
199     {
200         if (!value->isPrimitiveValue())
201             return;
202
203         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
204         if (primitiveValue->getIdent() == autoIdentity)
205             setAuto(selector->style());
206         else if (valueType == Number)
207             setValue(selector->style(), *primitiveValue);
208         else if (valueType == ComputeLength)
209             setValue(selector->style(), primitiveValue->computeLength<T>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()));
210     }
211
212     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
213 };
214
215 enum ColorInherit {NoInheritFromParent = 0, InheritFromParent};
216 Color defaultInitialColor();
217 Color defaultInitialColor() { return Color(); }
218 template <ColorInherit inheritColorFromParent,
219           const Color& (RenderStyle::*getterFunction)() const,
220           void (RenderStyle::*setterFunction)(const Color&),
221           void (RenderStyle::*visitedLinkSetterFunction)(const Color&),
222           const Color& (RenderStyle::*defaultFunction)() const,
223           Color (*initialFunction)() = &defaultInitialColor>
224 class ApplyPropertyColor {
225 public:
226     static void applyInheritValue(CSSStyleSelector* selector)
227     {
228         // Visited link style can never explicitly inherit from parent visited link style so no separate getters are needed.
229         const Color& color = (selector->parentStyle()->*getterFunction)();
230         applyColorValue(selector, color.isValid() ? color : (selector->parentStyle()->*defaultFunction)());
231     }
232
233     static void applyInitialValue(CSSStyleSelector* selector)
234     {
235         applyColorValue(selector, initialFunction());
236     }
237
238     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
239     {
240         if (!value->isPrimitiveValue())
241             return;
242
243         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
244         if (inheritColorFromParent && primitiveValue->getIdent() == CSSValueCurrentcolor)
245             applyInheritValue(selector);
246         else {
247             if (selector->applyPropertyToRegularStyle())
248                 (selector->style()->*setterFunction)(selector->colorFromPrimitiveValue(primitiveValue));
249             if (selector->applyPropertyToVisitedLinkStyle())
250                 (selector->style()->*visitedLinkSetterFunction)(selector->colorFromPrimitiveValue(primitiveValue, /* forVisitedLink */ true));
251         }
252     }
253
254     static void applyColorValue(CSSStyleSelector* selector, const Color& color)
255     {
256         if (selector->applyPropertyToRegularStyle())
257             (selector->style()->*setterFunction)(color);
258         if (selector->applyPropertyToVisitedLinkStyle())
259             (selector->style()->*visitedLinkSetterFunction)(color);
260     }
261
262     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
263 };
264
265 template <TextDirection (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(TextDirection), TextDirection (*initialFunction)()>
266 class ApplyPropertyDirection {
267 public:
268     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
269     {
270         ApplyPropertyDefault<TextDirection, getterFunction, TextDirection, setterFunction, TextDirection, initialFunction>::applyValue(selector, value);
271         Element* element = selector->element();
272         if (element && selector->element() == element->document()->documentElement())
273             element->document()->setDirectionSetOnDocumentElement(true);
274     }
275
276     static PropertyHandler createHandler()
277     {
278         PropertyHandler handler = ApplyPropertyDefault<TextDirection, getterFunction, TextDirection, setterFunction, TextDirection, initialFunction>::createHandler();
279         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
280     }
281 };
282
283 enum LengthAuto { AutoDisabled = 0, AutoEnabled };
284 enum LengthIntrinsic { IntrinsicDisabled = 0, IntrinsicEnabled };
285 enum LengthMinIntrinsic { MinIntrinsicDisabled = 0, MinIntrinsicEnabled };
286 enum LengthNone { NoneDisabled = 0, NoneEnabled };
287 enum LengthUndefined { UndefinedDisabled = 0, UndefinedEnabled };
288 enum LengthFlexDirection { FlexDirectionDisabled = 0, FlexWidth, FlexHeight };
289 template <Length (RenderStyle::*getterFunction)() const,
290           void (RenderStyle::*setterFunction)(Length),
291           Length (*initialFunction)(),
292           LengthAuto autoEnabled = AutoDisabled,
293           LengthIntrinsic intrinsicEnabled = IntrinsicDisabled,
294           LengthMinIntrinsic minIntrinsicEnabled = MinIntrinsicDisabled,
295           LengthNone noneEnabled = NoneDisabled,
296           LengthUndefined noneUndefined = UndefinedDisabled,
297           LengthFlexDirection flexDirection = FlexDirectionDisabled>
298 class ApplyPropertyLength {
299 public:
300     static void setValue(RenderStyle* style, Length value) { (style->*setterFunction)(value); }
301     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
302     {
303         if (!value->isPrimitiveValue()) {
304             if (!flexDirection || !value->isFlexValue())
305                 return;
306
307             CSSFlexValue* flexValue = static_cast<CSSFlexValue*>(value);
308             value = flexValue->preferredSize();
309
310             if (flexDirection == FlexWidth) {
311                 selector->style()->setFlexboxWidthPositiveFlex(flexValue->positiveFlex());
312                 selector->style()->setFlexboxWidthNegativeFlex(flexValue->negativeFlex());
313             } else if (flexDirection == FlexHeight) {
314                 selector->style()->setFlexboxHeightPositiveFlex(flexValue->positiveFlex());
315                 selector->style()->setFlexboxHeightNegativeFlex(flexValue->negativeFlex());
316             }
317         }
318
319         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
320         if (noneEnabled && primitiveValue->getIdent() == CSSValueNone)
321             if (noneUndefined)
322                 setValue(selector->style(), Length(Undefined));
323             else
324                 setValue(selector->style(), Length());
325         else if (intrinsicEnabled && primitiveValue->getIdent() == CSSValueIntrinsic)
326             setValue(selector->style(), Length(Intrinsic));
327         else if (minIntrinsicEnabled && primitiveValue->getIdent() == CSSValueMinIntrinsic)
328             setValue(selector->style(), Length(MinIntrinsic));
329         else if (autoEnabled && primitiveValue->getIdent() == CSSValueAuto)
330             setValue(selector->style(), Length());
331         else {
332             int type = primitiveValue->primitiveType();
333             if (CSSPrimitiveValue::isUnitTypeLength(type)) {
334                 Length length = primitiveValue->computeLength<Length>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
335                 length.setQuirk(primitiveValue->isQuirkValue());
336                 setValue(selector->style(), length);
337             } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
338                 setValue(selector->style(), Length(primitiveValue->getDoubleValue(), Percent));
339         }
340     }
341
342     static PropertyHandler createHandler()
343     {
344         PropertyHandler handler = ApplyPropertyDefaultBase<Length, getterFunction, Length, setterFunction, Length, initialFunction>::createHandler();
345         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
346     }
347 };
348
349 enum StringIdentBehavior { NothingMapsToNull = 0, MapNoneToNull, MapAutoToNull };
350 template <StringIdentBehavior identBehavior, const AtomicString& (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(const AtomicString&), const AtomicString& (*initialFunction)()>
351 class ApplyPropertyString {
352 public:
353     static void setValue(RenderStyle* style, const AtomicString& value) { (style->*setterFunction)(value); }
354     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
355     {
356         if (!value->isPrimitiveValue())
357             return;
358         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
359         if ((identBehavior == MapNoneToNull && primitiveValue->getIdent() == CSSValueNone)
360             || (identBehavior == MapAutoToNull && primitiveValue->getIdent() == CSSValueAuto))
361             setValue(selector->style(), nullAtom);
362         else
363             setValue(selector->style(), primitiveValue->getStringValue());
364     }
365     static PropertyHandler createHandler()
366     {
367         PropertyHandler handler = ApplyPropertyDefaultBase<const AtomicString&, getterFunction, const AtomicString&, setterFunction, const AtomicString&, initialFunction>::createHandler();
368         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
369     }
370 };
371
372 template <LengthSize (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(LengthSize), LengthSize (*initialFunction)()>
373 class ApplyPropertyBorderRadius {
374 public:
375     static void setValue(RenderStyle* style, LengthSize value) { (style->*setterFunction)(value); }
376     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
377     {
378         if (!value->isPrimitiveValue())
379             return;
380
381         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
382         Pair* pair = primitiveValue->getPairValue();
383         if (!pair || !pair->first() || !pair->second())
384             return;
385
386         Length radiusWidth;
387         Length radiusHeight;
388         if (pair->first()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
389             radiusWidth = Length(pair->first()->getDoubleValue(), Percent);
390         else
391             radiusWidth = Length(max(intMinForLength, min(intMaxForLength, pair->first()->computeLength<int>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()))), Fixed);
392         if (pair->second()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
393             radiusHeight = Length(pair->second()->getDoubleValue(), Percent);
394         else
395             radiusHeight = Length(max(intMinForLength, min(intMaxForLength, pair->second()->computeLength<int>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()))), Fixed);
396         int width = radiusWidth.value();
397         int height = radiusHeight.value();
398         if (width < 0 || height < 0)
399             return;
400         if (!width)
401             radiusHeight = radiusWidth; // Null out the other value.
402         else if (!height)
403             radiusWidth = radiusHeight; // Null out the other value.
404
405         LengthSize size(radiusWidth, radiusHeight);
406         setValue(selector->style(), size);
407     }
408     static PropertyHandler createHandler()
409     {
410         PropertyHandler handler = ApplyPropertyDefaultBase<LengthSize, getterFunction, LengthSize, setterFunction, LengthSize, initialFunction>::createHandler();
411         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
412     }
413 };
414
415 template <typename T>
416 struct FillLayerAccessorTypes {
417     typedef T Setter;
418     typedef T Getter;
419 };
420
421 template <>
422 struct FillLayerAccessorTypes<StyleImage*> {
423     typedef PassRefPtr<StyleImage> Setter;
424     typedef StyleImage* Getter;
425 };
426
427 template <typename T,
428           CSSPropertyID propertyId,
429           EFillLayerType fillLayerType,
430           FillLayer* (RenderStyle::*accessLayersFunction)(),
431           const FillLayer* (RenderStyle::*layersFunction)() const,
432           bool (FillLayer::*testFunction)() const,
433           typename FillLayerAccessorTypes<T>::Getter (FillLayer::*getFunction)() const,
434           void (FillLayer::*setFunction)(typename FillLayerAccessorTypes<T>::Setter),
435           void (FillLayer::*clearFunction)(),
436           typename FillLayerAccessorTypes<T>::Getter (*initialFunction)(EFillLayerType),
437           void (CSSStyleSelector::*mapFillFunction)(CSSPropertyID, FillLayer*, CSSValue*)>
438 class ApplyPropertyFillLayer {
439 public:
440     static void applyInheritValue(CSSStyleSelector* selector)
441     {
442         FillLayer* currChild = (selector->style()->*accessLayersFunction)();
443         FillLayer* prevChild = 0;
444         const FillLayer* currParent = (selector->parentStyle()->*layersFunction)();
445         while (currParent && (currParent->*testFunction)()) {
446             if (!currChild) {
447                 /* Need to make a new layer.*/
448                 currChild = new FillLayer(fillLayerType);
449                 prevChild->setNext(currChild);
450             }
451             (currChild->*setFunction)((currParent->*getFunction)());
452             prevChild = currChild;
453             currChild = prevChild->next();
454             currParent = currParent->next();
455         }
456
457         while (currChild) {
458             /* Reset any remaining layers to not have the property set. */
459             (currChild->*clearFunction)();
460             currChild = currChild->next();
461         }
462     }
463
464     static void applyInitialValue(CSSStyleSelector* selector)
465     {
466         FillLayer* currChild = (selector->style()->*accessLayersFunction)();
467         (currChild->*setFunction)((*initialFunction)(fillLayerType));
468         for (currChild = currChild->next(); currChild; currChild = currChild->next())
469             (currChild->*clearFunction)();
470     }
471
472     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
473     {
474         FillLayer* currChild = (selector->style()->*accessLayersFunction)();
475         FillLayer* prevChild = 0;
476         if (value->isValueList()) {
477             /* Walk each value and put it into a layer, creating new layers as needed. */
478             CSSValueList* valueList = static_cast<CSSValueList*>(value);
479             for (unsigned int i = 0; i < valueList->length(); i++) {
480                 if (!currChild) {
481                     /* Need to make a new layer to hold this value */
482                     currChild = new FillLayer(fillLayerType);
483                     prevChild->setNext(currChild);
484                 }
485                 (selector->*mapFillFunction)(propertyId, currChild, valueList->itemWithoutBoundsCheck(i));
486                 prevChild = currChild;
487                 currChild = currChild->next();
488             }
489         } else {
490             (selector->*mapFillFunction)(propertyId, currChild, value);
491             currChild = currChild->next();
492         }
493         while (currChild) {
494             /* Reset all remaining layers to not have the property set. */
495             (currChild->*clearFunction)();
496             currChild = currChild->next();
497         }
498     }
499
500     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
501 };
502
503 enum ComputeLengthNormal {NormalDisabled = 0, NormalEnabled};
504 enum ComputeLengthThickness {ThicknessDisabled = 0, ThicknessEnabled};
505 enum ComputeLengthSVGZoom {SVGZoomDisabled = 0, SVGZoomEnabled};
506 template <typename T,
507           T (RenderStyle::*getterFunction)() const,
508           void (RenderStyle::*setterFunction)(T),
509           T (*initialFunction)(),
510           ComputeLengthNormal normalEnabled = NormalDisabled,
511           ComputeLengthThickness thicknessEnabled = ThicknessDisabled,
512           ComputeLengthSVGZoom svgZoomEnabled = SVGZoomDisabled>
513 class ApplyPropertyComputeLength {
514 public:
515     static void setValue(RenderStyle* style, T value) { (style->*setterFunction)(value); }
516     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
517     {
518         // note: CSSPropertyLetter/WordSpacing right now sets to zero if it's not a primitive value for some reason...
519         if (!value->isPrimitiveValue())
520             return;
521
522         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
523
524         int ident = primitiveValue->getIdent();
525         T length;
526         if (normalEnabled && ident == CSSValueNormal) {
527             length = 0;
528         } else if (thicknessEnabled && ident == CSSValueThin) {
529             length = 1;
530         } else if (thicknessEnabled && ident == CSSValueMedium) {
531             length = 3;
532         } else if (thicknessEnabled && ident == CSSValueThick) {
533             length = 5;
534         } else if (ident == CSSValueInvalid) {
535             float zoom = (svgZoomEnabled && selector->useSVGZoomRules()) ? 1.0f : selector->style()->effectiveZoom();
536             length = primitiveValue->computeLength<T>(selector->style(), selector->rootElementStyle(), zoom);
537         } else {
538             ASSERT_NOT_REACHED();
539             length = 0;
540         }
541
542         setValue(selector->style(), length);
543     }
544     static PropertyHandler createHandler()
545     {
546         PropertyHandler handler = ApplyPropertyDefaultBase<T, getterFunction, T, setterFunction, T, initialFunction>::createHandler();
547         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
548     }
549 };
550
551 template <typename T, T (FontDescription::*getterFunction)() const, void (FontDescription::*setterFunction)(T), T initialValue>
552 class ApplyPropertyFont {
553 public:
554     static void applyInheritValue(CSSStyleSelector* selector)
555     {
556         FontDescription fontDescription = selector->fontDescription();
557         (fontDescription.*setterFunction)((selector->parentFontDescription().*getterFunction)());
558         selector->setFontDescription(fontDescription);
559     }
560
561     static void applyInitialValue(CSSStyleSelector* selector)
562     {
563         FontDescription fontDescription = selector->fontDescription();
564         (fontDescription.*setterFunction)(initialValue);
565         selector->setFontDescription(fontDescription);
566     }
567
568     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
569     {
570         if (!value->isPrimitiveValue())
571             return;
572         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
573         FontDescription fontDescription = selector->fontDescription();
574         (fontDescription.*setterFunction)(*primitiveValue);
575         selector->setFontDescription(fontDescription);
576     }
577
578     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
579 };
580
581 class ApplyPropertyFontSize {
582 private:
583     // When the CSS keyword "larger" is used, this function will attempt to match within the keyword
584     // table, and failing that, will simply multiply by 1.2.
585     static float largerFontSize(float size)
586     {
587         // FIXME: Figure out where we fall in the size ranges (xx-small to xxx-large) and scale up to
588         // the next size level.
589         return size * 1.2f;
590     }
591
592     // Like the previous function, but for the keyword "smaller".
593     static float smallerFontSize(float size)
594     {
595         // FIXME: Figure out where we fall in the size ranges (xx-small to xxx-large) and scale down to
596         // the next size level.
597         return size / 1.2f;
598     }
599 public:
600     static void applyInheritValue(CSSStyleSelector* selector)
601     {
602         float size = selector->parentStyle()->fontDescription().specifiedSize();
603
604         if (size < 0)
605             return;
606
607         FontDescription fontDescription = selector->style()->fontDescription();
608         fontDescription.setKeywordSize(selector->parentStyle()->fontDescription().keywordSize());
609         selector->setFontSize(fontDescription, size);
610         selector->setFontDescription(fontDescription);
611         return;
612     }
613
614     static void applyInitialValue(CSSStyleSelector* selector)
615     {
616         FontDescription fontDescription = selector->style()->fontDescription();
617         float size = selector->fontSizeForKeyword(selector->document(), CSSValueMedium, fontDescription.useFixedDefaultSize());
618
619         if (size < 0)
620             return;
621
622         fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
623         selector->setFontSize(fontDescription, size);
624         selector->setFontDescription(fontDescription);
625         return;
626     }
627
628     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
629     {
630         if (!value->isPrimitiveValue())
631             return;
632
633         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
634
635         FontDescription fontDescription = selector->style()->fontDescription();
636         fontDescription.setKeywordSize(0);
637         float parentSize = 0;
638         bool parentIsAbsoluteSize = false;
639         float size = 0;
640
641         if (selector->hasParentNode()) {
642             parentSize = selector->parentStyle()->fontDescription().specifiedSize();
643             parentIsAbsoluteSize = selector->parentStyle()->fontDescription().isAbsoluteSize();
644         }
645
646         if (int ident = primitiveValue->getIdent()) {
647             // Keywords are being used.
648             switch (ident) {
649             case CSSValueXxSmall:
650             case CSSValueXSmall:
651             case CSSValueSmall:
652             case CSSValueMedium:
653             case CSSValueLarge:
654             case CSSValueXLarge:
655             case CSSValueXxLarge:
656             case CSSValueWebkitXxxLarge:
657                 size = selector->fontSizeForKeyword(selector->document(), ident, fontDescription.useFixedDefaultSize());
658                 fontDescription.setKeywordSize(ident - CSSValueXxSmall + 1);
659                 break;
660             case CSSValueLarger:
661                 size = largerFontSize(parentSize);
662                 break;
663             case CSSValueSmaller:
664                 size = smallerFontSize(parentSize);
665                 break;
666             default:
667                 return;
668             }
669
670             fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize && (ident == CSSValueLarger || ident == CSSValueSmaller));
671         } else {
672             int type = primitiveValue->primitiveType();
673             fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize
674                                               || (type != CSSPrimitiveValue::CSS_PERCENTAGE
675                                                   && type != CSSPrimitiveValue::CSS_EMS
676                                                   && type != CSSPrimitiveValue::CSS_EXS
677                                                   && type != CSSPrimitiveValue::CSS_REMS));
678             if (primitiveValue->isLength())
679                 size = primitiveValue->computeLength<float>(selector->parentStyle(), selector->rootElementStyle(), 1.0, true);
680             else if (primitiveValue->isPercentage())
681                 size = (primitiveValue->getFloatValue() * parentSize) / 100.0f;
682             else
683                 return;
684         }
685
686         if (size < 0)
687             return;
688
689         selector->setFontSize(fontDescription, size);
690         selector->setFontDescription(fontDescription);
691         return;
692     }
693
694     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
695 };
696
697 class ApplyPropertyFontWeight {
698 public:
699     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
700     {
701         if (!value->isPrimitiveValue())
702             return;
703         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
704         FontDescription fontDescription = selector->fontDescription();
705         switch (primitiveValue->getIdent()) {
706         case CSSValueInvalid:
707             ASSERT_NOT_REACHED();
708             break;
709         case CSSValueBolder:
710             fontDescription.setWeight(fontDescription.bolderWeight());
711             break;
712         case CSSValueLighter:
713             fontDescription.setWeight(fontDescription.lighterWeight());
714             break;
715         default:
716             fontDescription.setWeight(*primitiveValue);
717         }
718         selector->setFontDescription(fontDescription);
719     }
720     static PropertyHandler createHandler()
721     {
722         PropertyHandler handler = ApplyPropertyFont<FontWeight, &FontDescription::weight, &FontDescription::setWeight, FontWeightNormal>::createHandler();
723         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
724     }
725 };
726
727 enum BorderImageType { Image = 0, Mask };
728 template <BorderImageType borderImageType,
729           CSSPropertyID property,
730           const NinePieceImage& (RenderStyle::*getterFunction)() const,
731           void (RenderStyle::*setterFunction)(const NinePieceImage&)>
732 class ApplyPropertyBorderImage {
733 public:
734     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
735     {
736         NinePieceImage image;
737         if (borderImageType == Mask)
738             image.setMaskDefaults();
739         selector->mapNinePieceImage(property, value, image);
740         (selector->style()->*setterFunction)(image);
741     }
742
743     static PropertyHandler createHandler()
744     {
745         PropertyHandler handler = ApplyPropertyDefaultBase<const NinePieceImage&, getterFunction, const NinePieceImage&, setterFunction, NinePieceImage, &RenderStyle::initialNinePieceImage>::createHandler();
746         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
747     }
748 };
749
750 enum BorderImageModifierType { Outset, Repeat, Slice, Width };
751 template <BorderImageType type, BorderImageModifierType modifier>
752 class ApplyPropertyBorderImageModifier {
753 private:
754     static inline const NinePieceImage& getValue(RenderStyle* style) { return type == Image ? style->borderImage() : style->maskBoxImage(); }
755     static inline void setValue(RenderStyle* style, const NinePieceImage& value) { return type == Image ? style->setBorderImage(value) : style->setMaskBoxImage(value); }
756 public:
757     static void applyInheritValue(CSSStyleSelector* selector)
758     {
759         NinePieceImage image(getValue(selector->style()));
760         switch (modifier) {
761         case Outset:
762             image.copyOutsetFrom(getValue(selector->parentStyle()));
763             break;
764         case Repeat:
765             image.copyRepeatFrom(getValue(selector->parentStyle()));
766             break;
767         case Slice:
768             image.copyImageSlicesFrom(getValue(selector->parentStyle()));
769             break;
770         case Width:
771             image.copyBorderSlicesFrom(getValue(selector->parentStyle()));
772             break;
773         }
774         setValue(selector->style(), image);
775     }
776
777     static void applyInitialValue(CSSStyleSelector* selector)
778     {
779         NinePieceImage image(getValue(selector->style()));
780         switch (modifier) {
781         case Outset:
782             image.setOutset(LengthBox());
783             break;
784         case Repeat:
785             image.setHorizontalRule(StretchImageRule);
786             image.setVerticalRule(StretchImageRule);
787             break;
788         case Slice:
789             // Masks have a different initial value for slices. Preserve the value of 0 for backwards compatibility.
790             image.setImageSlices(type == Image ? LengthBox(Length(100, Percent), Length(100, Percent), Length(100, Percent), Length(100, Percent)) : LengthBox());
791             image.setFill(false);
792             break;
793         case Width:
794             // Masks have a different initial value for widths. They use an 'auto' value rather than trying to fit to the border.
795             image.setBorderSlices(type == Image ? LengthBox(Length(1, Relative), Length(1, Relative), Length(1, Relative), Length(1, Relative)) : LengthBox());
796             break;
797         }
798         setValue(selector->style(), image);
799     }
800
801     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
802     {
803         NinePieceImage image(getValue(selector->style()));
804         switch (modifier) {
805         case Outset:
806             image.setOutset(selector->mapNinePieceImageQuad(value));
807             break;
808         case Repeat:
809             selector->mapNinePieceImageRepeat(value, image);
810             break;
811         case Slice:
812             selector->mapNinePieceImageSlice(value, image);
813             break;
814         case Width:
815             image.setBorderSlices(selector->mapNinePieceImageQuad(value));
816             break;
817         }
818         setValue(selector->style(), image);
819     }
820
821     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
822 };
823
824 template <CSSPropertyID id, StyleImage* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<StyleImage>), StyleImage* (*initialFunction)()>
825 class ApplyPropertyBorderImageSource {
826 public:
827     static void applyValue(CSSStyleSelector* selector, CSSValue* value) { (selector->style()->*setterFunction)(selector->styleImage(id, value)); }
828     static PropertyHandler createHandler()
829     {
830         PropertyHandler handler = ApplyPropertyDefaultBase<StyleImage*, getterFunction, PassRefPtr<StyleImage>, setterFunction, StyleImage*, initialFunction>::createHandler();
831         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
832     }
833 };
834
835 enum CounterBehavior {Increment = 0, Reset};
836 template <CounterBehavior counterBehavior>
837 class ApplyPropertyCounter {
838 public:
839     static void emptyFunction(CSSStyleSelector*) { }
840     static void applyInheritValue(CSSStyleSelector* selector)
841     {
842         CounterDirectiveMap& map = selector->style()->accessCounterDirectives();
843         CounterDirectiveMap& parentMap = selector->parentStyle()->accessCounterDirectives();
844
845         typedef CounterDirectiveMap::iterator Iterator;
846         Iterator end = parentMap.end();
847         for (Iterator it = parentMap.begin(); it != end; ++it) {
848             CounterDirectives& directives = map.add(it->first, CounterDirectives()).first->second;
849             if (counterBehavior == Reset) {
850                 directives.m_reset = it->second.m_reset;
851                 directives.m_resetValue = it->second.m_resetValue;
852             } else {
853                 // Inheriting a counter-increment means taking the parent's current value for the counter
854                 // and adding it to itself.
855                 directives.m_increment = it->second.m_increment;
856                 directives.m_incrementValue = 0;
857                 if (directives.m_increment) {
858                     float incrementValue = directives.m_incrementValue;
859                     directives.m_incrementValue = clampToInteger(incrementValue + it->second.m_incrementValue);
860                 } else {
861                     directives.m_increment = true;
862                     directives.m_incrementValue = it->second.m_incrementValue;
863                 }
864             }
865         }
866     }
867     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
868     {
869         if (!value->isValueList())
870             return;
871
872         CSSValueList* list = static_cast<CSSValueList*>(value);
873
874         CounterDirectiveMap& map = selector->style()->accessCounterDirectives();
875         typedef CounterDirectiveMap::iterator Iterator;
876
877         Iterator end = map.end();
878         for (Iterator it = map.begin(); it != end; ++it)
879             if (counterBehavior == Reset)
880                 it->second.m_reset = false;
881             else
882                 it->second.m_increment = false;
883
884         int length = list ? list->length() : 0;
885         for (int i = 0; i < length; ++i) {
886             CSSValue* currValue = list->itemWithoutBoundsCheck(i);
887             if (!currValue->isPrimitiveValue())
888                 continue;
889
890             Pair* pair = static_cast<CSSPrimitiveValue*>(currValue)->getPairValue();
891             if (!pair || !pair->first() || !pair->second())
892                 continue;
893
894             AtomicString identifier = static_cast<CSSPrimitiveValue*>(pair->first())->getStringValue();
895             int value = static_cast<CSSPrimitiveValue*>(pair->second())->getIntValue();
896             CounterDirectives& directives = map.add(identifier.impl(), CounterDirectives()).first->second;
897             if (counterBehavior == Reset) {
898                 directives.m_reset = true;
899                 directives.m_resetValue = value;
900             } else {
901                 if (directives.m_increment) {
902                     float incrementValue = directives.m_incrementValue;
903                     directives.m_incrementValue = clampToInteger(incrementValue + value);
904                 } else {
905                     directives.m_increment = true;
906                     directives.m_incrementValue = value;
907                 }
908             }
909             
910         }
911     }
912     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &emptyFunction, &applyValue); }
913 };
914
915
916 class ApplyPropertyCursor {
917 public:
918     static void applyInheritValue(CSSStyleSelector* selector)
919     {
920         selector->style()->setCursor(selector->parentStyle()->cursor());
921         selector->style()->setCursorList(selector->parentStyle()->cursors());
922     }
923
924     static void applyInitialValue(CSSStyleSelector* selector)
925     {
926         selector->style()->clearCursorList();
927         selector->style()->setCursor(RenderStyle::initialCursor());
928     }
929
930     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
931     {
932         selector->style()->clearCursorList();
933         if (value->isValueList()) {
934             CSSValueList* list = static_cast<CSSValueList*>(value);
935             int len = list->length();
936             selector->style()->setCursor(CURSOR_AUTO);
937             for (int i = 0; i < len; i++) {
938                 CSSValue* item = list->itemWithoutBoundsCheck(i);
939                 if (!item->isPrimitiveValue())
940                     continue;
941                 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(item);
942                 int type = primitiveValue->primitiveType();
943                 if (type == CSSPrimitiveValue::CSS_URI) {
944                     if (primitiveValue->isCursorImageValue()) {
945                         CSSCursorImageValue* image = static_cast<CSSCursorImageValue*>(primitiveValue);
946                         if (image->updateIfSVGCursorIsUsed(selector->element())) // Elements with SVG cursors are not allowed to share style.
947                             selector->style()->setUnique();
948                         selector->style()->addCursor(selector->cachedOrPendingFromValue(CSSPropertyCursor, image), image->hotSpot());
949                     }
950                 } else if (type == CSSPrimitiveValue::CSS_IDENT)
951                     selector->style()->setCursor(*primitiveValue);
952             }
953         } else if (value->isPrimitiveValue()) {
954             CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
955             int type = primitiveValue->primitiveType();
956             if (type == CSSPrimitiveValue::CSS_IDENT && selector->style()->cursor() != ECursor(*primitiveValue))
957                 selector->style()->setCursor(*primitiveValue);
958         }
959     }
960
961     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
962 };
963
964 class ApplyPropertyTextAlign {
965 public:
966     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
967     {
968         if (!value->isPrimitiveValue())
969             return;
970
971         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
972
973         if (primitiveValue->getIdent() != CSSValueWebkitMatchParent)
974             selector->style()->setTextAlign(*primitiveValue);
975         else if (selector->parentStyle()->textAlign() == TASTART)
976             selector->style()->setTextAlign(selector->parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT);
977         else if (selector->parentStyle()->textAlign() == TAEND)
978             selector->style()->setTextAlign(selector->parentStyle()->isLeftToRightDirection() ? RIGHT : LEFT);
979         else
980             selector->style()->setTextAlign(selector->parentStyle()->textAlign());
981     }
982     static PropertyHandler createHandler()
983     {
984         PropertyHandler handler = ApplyPropertyDefaultBase<ETextAlign, &RenderStyle::textAlign, ETextAlign, &RenderStyle::setTextAlign, ETextAlign, &RenderStyle::initialTextAlign>::createHandler();
985         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
986     }
987 };
988
989 class ApplyPropertyTextDecoration {
990 public:
991     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
992     {
993         ETextDecoration t = RenderStyle::initialTextDecoration();
994         for (CSSValueListIterator i(value); i.hasMore(); i.advance()) {
995             CSSValue* item = i.value();
996             ASSERT(item->isPrimitiveValue());
997             t |= *static_cast<CSSPrimitiveValue*>(item);
998         }
999         selector->style()->setTextDecoration(t);
1000     }
1001     static PropertyHandler createHandler()
1002     {
1003         PropertyHandler handler = ApplyPropertyDefaultBase<ETextDecoration, &RenderStyle::textDecoration, ETextDecoration, &RenderStyle::setTextDecoration, ETextDecoration, &RenderStyle::initialTextDecoration>::createHandler();
1004         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
1005     }
1006 };
1007
1008 class ApplyPropertyLineHeight {
1009 public:
1010     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
1011     {
1012         if (!value->isPrimitiveValue())
1013             return;
1014
1015         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
1016         Length lineHeight;
1017
1018         if (primitiveValue->getIdent() == CSSValueNormal)
1019             lineHeight = Length(-100.0, Percent);
1020         else if (primitiveValue->isLength()) {
1021             double multiplier = selector->style()->effectiveZoom();
1022             if (selector->style()->textSizeAdjust()) {
1023                 if (Frame* frame = selector->document()->frame())
1024                     multiplier *= frame->textZoomFactor();
1025             }
1026             lineHeight = primitiveValue->computeLength<Length>(selector->style(), selector->rootElementStyle(), multiplier);
1027         } else if (primitiveValue->isPercentage()) {
1028             // FIXME: percentage should not be restricted to an integer here.
1029             lineHeight = Length((selector->style()->fontSize() * primitiveValue->getIntValue()) / 100, Fixed);
1030         } else if (primitiveValue->isNumber()) {
1031             // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent).
1032             lineHeight = Length(primitiveValue->getDoubleValue() * 100.0, Percent);
1033         } else
1034             return;
1035         selector->style()->setLineHeight(lineHeight);
1036     }
1037     static PropertyHandler createHandler()
1038     {
1039         PropertyHandler handler = ApplyPropertyDefaultBase<Length, &RenderStyle::lineHeight, Length, &RenderStyle::setLineHeight, Length, &RenderStyle::initialLineHeight>::createHandler();
1040         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
1041     }
1042 };
1043
1044 class ApplyPropertyPageSize {
1045 private:
1046     static Length mmLength(double mm) { return CSSPrimitiveValue::create(mm, CSSPrimitiveValue::CSS_MM)->computeLength<Length>(0, 0); }
1047     static Length inchLength(double inch) { return CSSPrimitiveValue::create(inch, CSSPrimitiveValue::CSS_IN)->computeLength<Length>(0, 0); }
1048     static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height)
1049     {
1050         static const Length a5Width = mmLength(148), a5Height = mmLength(210);
1051         static const Length a4Width = mmLength(210), a4Height = mmLength(297);
1052         static const Length a3Width = mmLength(297), a3Height = mmLength(420);
1053         static const Length b5Width = mmLength(176), b5Height = mmLength(250);
1054         static const Length b4Width = mmLength(250), b4Height = mmLength(353);
1055         static const Length letterWidth = inchLength(8.5), letterHeight = inchLength(11);
1056         static const Length legalWidth = inchLength(8.5), legalHeight = inchLength(14);
1057         static const Length ledgerWidth = inchLength(11), ledgerHeight = inchLength(17);
1058
1059         if (!pageSizeName)
1060             return false;
1061
1062         switch (pageSizeName->getIdent()) {
1063         case CSSValueA5:
1064             width = a5Width;
1065             height = a5Height;
1066             break;
1067         case CSSValueA4:
1068             width = a4Width;
1069             height = a4Height;
1070             break;
1071         case CSSValueA3:
1072             width = a3Width;
1073             height = a3Height;
1074             break;
1075         case CSSValueB5:
1076             width = b5Width;
1077             height = b5Height;
1078             break;
1079         case CSSValueB4:
1080             width = b4Width;
1081             height = b4Height;
1082             break;
1083         case CSSValueLetter:
1084             width = letterWidth;
1085             height = letterHeight;
1086             break;
1087         case CSSValueLegal:
1088             width = legalWidth;
1089             height = legalHeight;
1090             break;
1091         case CSSValueLedger:
1092             width = ledgerWidth;
1093             height = ledgerHeight;
1094             break;
1095         default:
1096             return false;
1097         }
1098
1099         if (pageOrientation) {
1100             switch (pageOrientation->getIdent()) {
1101             case CSSValueLandscape:
1102                 std::swap(width, height);
1103                 break;
1104             case CSSValuePortrait:
1105                 // Nothing to do.
1106                 break;
1107             default:
1108                 return false;
1109             }
1110         }
1111         return true;
1112     }
1113 public:
1114     static void applyInheritValue(CSSStyleSelector*) { }
1115     static void applyInitialValue(CSSStyleSelector*) { }
1116     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
1117     {
1118         selector->style()->resetPageSizeType();
1119         Length width;
1120         Length height;
1121         PageSizeType pageSizeType = PAGE_SIZE_AUTO;
1122         CSSValueListInspector inspector(value);
1123         switch (inspector.length()) {
1124         case 2: {
1125             // <length>{2} | <page-size> <orientation>
1126             if (!inspector.first()->isPrimitiveValue() || !inspector.second()->isPrimitiveValue())
1127                 return;
1128             CSSPrimitiveValue* first = static_cast<CSSPrimitiveValue*>(inspector.first());
1129             CSSPrimitiveValue* second = static_cast<CSSPrimitiveValue*>(inspector.second());
1130             if (first->isLength()) {
1131                 // <length>{2}
1132                 if (!second->isLength())
1133                     return;
1134                 width = first->computeLength<Length>(selector->style(), selector->rootElementStyle());
1135                 height = second->computeLength<Length>(selector->style(), selector->rootElementStyle());
1136             } else {
1137                 // <page-size> <orientation>
1138                 // The value order is guaranteed. See CSSParser::parseSizeParameter.
1139                 if (!getPageSizeFromName(first, second, width, height))
1140                     return;
1141             }
1142             pageSizeType = PAGE_SIZE_RESOLVED;
1143             break;
1144         }
1145         case 1: {
1146             // <length> | auto | <page-size> | [ portrait | landscape]
1147             if (!inspector.first()->isPrimitiveValue())
1148                 return;
1149             CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(inspector.first());
1150             if (primitiveValue->isLength()) {
1151                 // <length>
1152                 pageSizeType = PAGE_SIZE_RESOLVED;
1153                 width = height = primitiveValue->computeLength<Length>(selector->style(), selector->rootElementStyle());
1154             } else {
1155                 if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_IDENT)
1156                     return;
1157                 switch (primitiveValue->getIdent()) {
1158                 case CSSValueAuto:
1159                     pageSizeType = PAGE_SIZE_AUTO;
1160                     break;
1161                 case CSSValuePortrait:
1162                     pageSizeType = PAGE_SIZE_AUTO_PORTRAIT;
1163                     break;
1164                 case CSSValueLandscape:
1165                     pageSizeType = PAGE_SIZE_AUTO_LANDSCAPE;
1166                     break;
1167                 default:
1168                     // <page-size>
1169                     pageSizeType = PAGE_SIZE_RESOLVED;
1170                     if (!getPageSizeFromName(primitiveValue, 0, width, height))
1171                         return;
1172                 }
1173             }
1174             break;
1175         }
1176         default:
1177             return;
1178         }
1179         selector->style()->setPageSizeType(pageSizeType);
1180         selector->style()->setPageSize(LengthSize(width, height));
1181     }
1182     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
1183 };
1184
1185 class ApplyPropertyTextEmphasisStyle {
1186 public:
1187     static void applyInheritValue(CSSStyleSelector* selector)
1188     {
1189         selector->style()->setTextEmphasisFill(selector->parentStyle()->textEmphasisFill());
1190         selector->style()->setTextEmphasisMark(selector->parentStyle()->textEmphasisMark());
1191         selector->style()->setTextEmphasisCustomMark(selector->parentStyle()->textEmphasisCustomMark());
1192     }
1193
1194     static void applyInitialValue(CSSStyleSelector* selector)
1195     {
1196         selector->style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill());
1197         selector->style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark());
1198         selector->style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCustomMark());
1199     }
1200
1201     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
1202     {
1203         if (value->isValueList()) {
1204             CSSValueList* list = static_cast<CSSValueList*>(value);
1205             ASSERT(list->length() == 2);
1206             if (list->length() != 2)
1207                 return;
1208             for (unsigned i = 0; i < 2; ++i) {
1209                 CSSValue* item = list->itemWithoutBoundsCheck(i);
1210                 if (!item->isPrimitiveValue())
1211                     continue;
1212
1213                 CSSPrimitiveValue* value = static_cast<CSSPrimitiveValue*>(item);
1214                 if (value->getIdent() == CSSValueFilled || value->getIdent() == CSSValueOpen)
1215                     selector->style()->setTextEmphasisFill(*value);
1216                 else
1217                     selector->style()->setTextEmphasisMark(*value);
1218             }
1219             selector->style()->setTextEmphasisCustomMark(nullAtom);
1220             return;
1221         }
1222
1223         if (!value->isPrimitiveValue())
1224             return;
1225         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
1226
1227         if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_STRING) {
1228             selector->style()->setTextEmphasisFill(TextEmphasisFillFilled);
1229             selector->style()->setTextEmphasisMark(TextEmphasisMarkCustom);
1230             selector->style()->setTextEmphasisCustomMark(primitiveValue->getStringValue());
1231             return;
1232         }
1233
1234         selector->style()->setTextEmphasisCustomMark(nullAtom);
1235
1236         if (primitiveValue->getIdent() == CSSValueFilled || primitiveValue->getIdent() == CSSValueOpen) {
1237             selector->style()->setTextEmphasisFill(*primitiveValue);
1238             selector->style()->setTextEmphasisMark(TextEmphasisMarkAuto);
1239         } else {
1240             selector->style()->setTextEmphasisFill(TextEmphasisFillFilled);
1241             selector->style()->setTextEmphasisMark(*primitiveValue);
1242         }
1243     }
1244
1245     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
1246 };
1247
1248 template <typename T,
1249           T (Animation::*getterFunction)() const,
1250           void (Animation::*setterFunction)(T),
1251           bool (Animation::*testFunction)() const,
1252           void (Animation::*clearFunction)(),
1253           T (*initialFunction)(),
1254           void (CSSStyleSelector::*mapFunction)(Animation*, CSSValue*),
1255           AnimationList* (RenderStyle::*animationGetterFunction)(),
1256           const AnimationList* (RenderStyle::*immutableAnimationGetterFunction)() const>
1257 class ApplyPropertyAnimation {
1258 public:
1259     static void setValue(Animation* animation, T value) { (animation->*setterFunction)(value); }
1260     static T value(const Animation* animation) { return (animation->*getterFunction)(); }
1261     static bool test(const Animation* animation) { return (animation->*testFunction)(); }
1262     static void clear(Animation* animation) { (animation->*clearFunction)(); }
1263     static T initial() { return (*initialFunction)(); }
1264     static void map(CSSStyleSelector* selector, Animation* animation, CSSValue* value) { (selector->*mapFunction)(animation, value); }
1265     static AnimationList* accessAnimations(RenderStyle* style) { return (style->*animationGetterFunction)(); }
1266     static const AnimationList* animations(RenderStyle* style) { return (style->*immutableAnimationGetterFunction)(); }
1267
1268     static void applyInheritValue(CSSStyleSelector* selector)
1269     {
1270         AnimationList* list = accessAnimations(selector->style());
1271         const AnimationList* parentList = animations(selector->parentStyle());
1272         size_t i = 0, parentSize = parentList ? parentList->size() : 0;
1273         for ( ; i < parentSize && test(parentList->animation(i)); ++i) {
1274             if (list->size() <= i)
1275                 list->append(Animation::create());
1276             setValue(list->animation(i), value(parentList->animation(i)));
1277         }
1278
1279         /* Reset any remaining animations to not have the property set. */
1280         for ( ; i < list->size(); ++i)
1281             clear(list->animation(i));
1282     }
1283
1284     static void applyInitialValue(CSSStyleSelector* selector)
1285     {
1286         AnimationList* list = accessAnimations(selector->style());
1287         if (list->isEmpty())
1288             list->append(Animation::create());
1289         setValue(list->animation(0), initial());
1290         for (size_t i = 1; i < list->size(); ++i)
1291             clear(list->animation(i));
1292     }
1293
1294     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
1295     {
1296         AnimationList* list = accessAnimations(selector->style());
1297         size_t childIndex = 0;
1298         if (value->isValueList()) {
1299             /* Walk each value and put it into an animation, creating new animations as needed. */
1300             for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
1301                 if (childIndex <= list->size())
1302                     list->append(Animation::create());
1303                 map(selector, list->animation(childIndex), i.value());
1304                 ++childIndex;
1305             }
1306         } else {
1307             if (list->isEmpty())
1308                 list->append(Animation::create());
1309             map(selector, list->animation(childIndex), value);
1310             childIndex = 1;
1311         }
1312         for ( ; childIndex < list->size(); ++childIndex) {
1313             /* Reset all remaining animations to not have the property set. */
1314             clear(list->animation(childIndex));
1315         }
1316     }
1317
1318     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
1319 };
1320
1321 class ApplyPropertyOutlineStyle {
1322 public:
1323     static void applyInheritValue(CSSStyleSelector* selector)
1324     {
1325         ApplyPropertyDefaultBase<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyInheritValue(selector);
1326         ApplyPropertyDefaultBase<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyInheritValue(selector);
1327     }
1328
1329     static void applyInitialValue(CSSStyleSelector* selector)
1330     {
1331         ApplyPropertyDefaultBase<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyInitialValue(selector);
1332         ApplyPropertyDefaultBase<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyInitialValue(selector);
1333     }
1334
1335     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
1336     {
1337         ApplyPropertyDefault<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyValue(selector, value);
1338         ApplyPropertyDefault<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyValue(selector, value);
1339     }
1340
1341     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
1342 };
1343
1344 class ApplyPropertyResize {
1345 public:
1346     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
1347     {
1348         if (!value->isPrimitiveValue())
1349             return;
1350
1351         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
1352
1353         EResize r = RESIZE_NONE;
1354         switch (primitiveValue->getIdent()) {
1355         case 0:
1356             return;
1357         case CSSValueAuto:
1358             if (Settings* settings = selector->document()->settings())
1359                 r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE;
1360             break;
1361         default:
1362             r = *primitiveValue;
1363         }
1364         selector->style()->setResize(r);
1365     }
1366
1367     static PropertyHandler createHandler()
1368     {
1369         PropertyHandler handler = ApplyPropertyDefaultBase<EResize, &RenderStyle::resize, EResize, &RenderStyle::setResize, EResize, &RenderStyle::initialResize>::createHandler();
1370         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
1371     }
1372 };
1373
1374 class ApplyPropertyVerticalAlign {
1375 public:
1376     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
1377     {
1378         if (!value->isPrimitiveValue())
1379             return;
1380
1381         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
1382
1383         if (primitiveValue->getIdent())
1384             return selector->style()->setVerticalAlign(*primitiveValue);
1385
1386         Length length;
1387         if (primitiveValue->isLength())
1388             length = primitiveValue->computeLength<Length>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
1389         else if (primitiveValue->isPercentage())
1390             length = Length(primitiveValue->getDoubleValue(), Percent);
1391
1392         selector->style()->setVerticalAlignLength(length);
1393     }
1394
1395     static PropertyHandler createHandler()
1396     {
1397         PropertyHandler handler = ApplyPropertyDefaultBase<EVerticalAlign, &RenderStyle::verticalAlign, EVerticalAlign, &RenderStyle::setVerticalAlign, EVerticalAlign, &RenderStyle::initialVerticalAlign>::createHandler();
1398         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
1399     }
1400 };
1401
1402 class ApplyPropertyAspectRatio {
1403 public:
1404     static void applyInheritValue(CSSStyleSelector* selector)
1405     {
1406         if (!selector->parentStyle()->hasAspectRatio())
1407             return;
1408         selector->style()->setHasAspectRatio(true);
1409         selector->style()->setAspectRatioDenominator(selector->parentStyle()->aspectRatioDenominator());
1410         selector->style()->setAspectRatioNumerator(selector->parentStyle()->aspectRatioNumerator());
1411     }
1412
1413     static void applyInitialValue(CSSStyleSelector* selector)
1414     {
1415         selector->style()->setHasAspectRatio(RenderStyle::initialHasAspectRatio());
1416         selector->style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDenominator());
1417         selector->style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumerator());
1418     }
1419
1420     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
1421     {
1422         if (!value->isAspectRatioValue()) {
1423             selector->style()->setHasAspectRatio(false);
1424             return;
1425         }
1426         CSSAspectRatioValue* aspectRatioValue = static_cast<CSSAspectRatioValue*>(value);
1427         selector->style()->setHasAspectRatio(true);
1428         selector->style()->setAspectRatioDenominator(aspectRatioValue->denominatorValue());
1429         selector->style()->setAspectRatioNumerator(aspectRatioValue->numeratorValue());
1430     }
1431
1432     static PropertyHandler createHandler()
1433     {
1434         return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
1435     }
1436 };
1437
1438 class ApplyPropertyZoom {
1439 private:
1440     static void resetEffectiveZoom(CSSStyleSelector* selector)
1441     {
1442         // Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect.
1443         selector->setEffectiveZoom(selector->parentStyle() ? selector->parentStyle()->effectiveZoom() : RenderStyle::initialZoom());
1444     }
1445
1446 public:
1447     static void applyInheritValue(CSSStyleSelector* selector)
1448     {
1449         resetEffectiveZoom(selector);
1450         selector->setZoom(selector->parentStyle()->zoom());
1451     }
1452
1453     static void applyInitialValue(CSSStyleSelector* selector)
1454     {
1455         resetEffectiveZoom(selector);
1456         selector->setZoom(RenderStyle::initialZoom());
1457     }
1458
1459     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
1460     {
1461         ASSERT(value->isPrimitiveValue());
1462         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
1463
1464         if (primitiveValue->getIdent() == CSSValueNormal) {
1465             resetEffectiveZoom(selector);
1466             selector->setZoom(RenderStyle::initialZoom());
1467         } else if (primitiveValue->getIdent() == CSSValueReset) {
1468             selector->setEffectiveZoom(RenderStyle::initialZoom());
1469             selector->setZoom(RenderStyle::initialZoom());
1470         } else if (primitiveValue->getIdent() == CSSValueDocument) {
1471             float docZoom = selector->document()->renderer()->style()->zoom();
1472             selector->setEffectiveZoom(docZoom);
1473             selector->setZoom(docZoom);
1474         } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE) {
1475             resetEffectiveZoom(selector);
1476             if (float percent = primitiveValue->getFloatValue())
1477                 selector->setZoom(percent / 100.0f);
1478         } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) {
1479             resetEffectiveZoom(selector);
1480             if (float number = primitiveValue->getFloatValue())
1481                 selector->setZoom(number);
1482         }
1483     }
1484
1485     static PropertyHandler createHandler()
1486     {
1487         return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
1488     }
1489 };
1490
1491 class ApplyPropertyDisplay {
1492 private:
1493     static inline bool isValidDisplayValue(CSSStyleSelector* selector, EDisplay displayPropertyValue)
1494     {
1495 #if ENABLE(SVG)
1496         if (selector->element() && selector->element()->isSVGElement() && selector->style()->styleType() == NOPSEUDO)
1497             return (displayPropertyValue == INLINE || displayPropertyValue == BLOCK || displayPropertyValue == NONE);
1498 #endif
1499         return true;
1500     }
1501 public:
1502     static void applyInheritValue(CSSStyleSelector* selector)
1503     {
1504         EDisplay display = selector->parentStyle()->display();
1505         if (!isValidDisplayValue(selector, display))
1506             return;
1507         selector->style()->setDisplay(display);
1508     }
1509
1510     static void applyInitialValue(CSSStyleSelector* selector)
1511     {
1512         selector->style()->setDisplay(RenderStyle::initialDisplay());
1513     }
1514
1515     static void applyValue(CSSStyleSelector* selector, CSSValue* value)
1516     {
1517         if (!value->isPrimitiveValue())
1518             return;
1519
1520         EDisplay display = *static_cast<CSSPrimitiveValue*>(value);
1521
1522         if (!isValidDisplayValue(selector, display))
1523             return;
1524
1525         selector->style()->setDisplay(display);
1526     }
1527
1528     static PropertyHandler createHandler()
1529     {
1530         return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
1531     }
1532 };
1533
1534 const CSSStyleApplyProperty& CSSStyleApplyProperty::sharedCSSStyleApplyProperty()
1535 {
1536     DEFINE_STATIC_LOCAL(CSSStyleApplyProperty, cssStyleApplyPropertyInstance, ());
1537     return cssStyleApplyPropertyInstance;
1538 }
1539
1540 CSSStyleApplyProperty::CSSStyleApplyProperty()
1541 {
1542     for (int i = 0; i < numCSSProperties; ++i)
1543         m_propertyMap[i] = PropertyHandler();
1544
1545     setPropertyHandler(CSSPropertyWebkitAspectRatio, ApplyPropertyAspectRatio::createHandler());
1546
1547     setPropertyHandler(CSSPropertyColor, ApplyPropertyColor<InheritFromParent, &RenderStyle::color, &RenderStyle::setColor, &RenderStyle::setVisitedLinkColor, &RenderStyle::invalidColor, RenderStyle::initialColor>::createHandler());
1548     setPropertyHandler(CSSPropertyDirection, ApplyPropertyDirection<&RenderStyle::direction, &RenderStyle::setDirection, RenderStyle::initialDirection>::createHandler());
1549
1550     setPropertyHandler(CSSPropertyBackgroundAttachment, ApplyPropertyFillLayer<EFillAttachment, CSSPropertyBackgroundAttachment, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
1551                        &FillLayer::isAttachmentSet, &FillLayer::attachment, &FillLayer::setAttachment, &FillLayer::clearAttachment, &FillLayer::initialFillAttachment, &CSSStyleSelector::mapFillAttachment>::createHandler());
1552     setPropertyHandler(CSSPropertyBackgroundClip, ApplyPropertyFillLayer<EFillBox, CSSPropertyBackgroundClip, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
1553                        &FillLayer::isClipSet, &FillLayer::clip, &FillLayer::setClip, &FillLayer::clearClip, &FillLayer::initialFillClip, &CSSStyleSelector::mapFillClip>::createHandler());
1554     setPropertyHandler(CSSPropertyWebkitBackgroundClip, CSSPropertyBackgroundClip);
1555     setPropertyHandler(CSSPropertyWebkitBackgroundComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitBackgroundComposite, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
1556                        &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSStyleSelector::mapFillComposite>::createHandler());
1557
1558     setPropertyHandler(CSSPropertyDisplay, ApplyPropertyDisplay::createHandler());
1559
1560     setPropertyHandler(CSSPropertyBackgroundImage, ApplyPropertyFillLayer<StyleImage*, CSSPropertyBackgroundImage, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
1561                        &FillLayer::isImageSet, &FillLayer::image, &FillLayer::setImage, &FillLayer::clearImage, &FillLayer::initialFillImage, &CSSStyleSelector::mapFillImage>::createHandler());
1562
1563     setPropertyHandler(CSSPropertyBackgroundOrigin, ApplyPropertyFillLayer<EFillBox, CSSPropertyBackgroundOrigin, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
1564                        &FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &CSSStyleSelector::mapFillOrigin>::createHandler());
1565     setPropertyHandler(CSSPropertyWebkitBackgroundOrigin, CSSPropertyBackgroundOrigin);
1566
1567     setPropertyHandler(CSSPropertyBackgroundPositionX, ApplyPropertyFillLayer<Length, CSSPropertyBackgroundPositionX, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
1568                        &FillLayer::isXPositionSet, &FillLayer::xPosition, &FillLayer::setXPosition, &FillLayer::clearXPosition, &FillLayer::initialFillXPosition, &CSSStyleSelector::mapFillXPosition>::createHandler());
1569     setPropertyHandler(CSSPropertyBackgroundPositionY, ApplyPropertyFillLayer<Length, CSSPropertyBackgroundPositionY, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
1570                        &FillLayer::isYPositionSet, &FillLayer::yPosition, &FillLayer::setYPosition, &FillLayer::clearYPosition, &FillLayer::initialFillYPosition, &CSSStyleSelector::mapFillYPosition>::createHandler());
1571     setPropertyHandler(CSSPropertyBackgroundPosition, ApplyPropertyExpanding<SuppressValue, CSSPropertyBackgroundPositionX, CSSPropertyBackgroundPositionY>::createHandler());
1572
1573     setPropertyHandler(CSSPropertyBackgroundRepeatX, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyBackgroundRepeatX, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
1574                        &FillLayer::isRepeatXSet, &FillLayer::repeatX, &FillLayer::setRepeatX, &FillLayer::clearRepeatX, &FillLayer::initialFillRepeatX, &CSSStyleSelector::mapFillRepeatX>::createHandler());
1575     setPropertyHandler(CSSPropertyBackgroundRepeatY, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyBackgroundRepeatY, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
1576                        &FillLayer::isRepeatYSet, &FillLayer::repeatY, &FillLayer::setRepeatY, &FillLayer::clearRepeatY, &FillLayer::initialFillRepeatY, &CSSStyleSelector::mapFillRepeatY>::createHandler());
1577     setPropertyHandler(CSSPropertyBackgroundRepeat, ApplyPropertyExpanding<SuppressValue, CSSPropertyBackgroundRepeatX, CSSPropertyBackgroundRepeatY>::createHandler());
1578
1579     setPropertyHandler(CSSPropertyBackgroundSize, ApplyPropertyFillLayer<FillSize, CSSPropertyBackgroundSize, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
1580                        &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSStyleSelector::mapFillSize>::createHandler());
1581     setPropertyHandler(CSSPropertyWebkitBackgroundSize, CSSPropertyBackgroundSize);
1582
1583     setPropertyHandler(CSSPropertyWebkitMaskAttachment, ApplyPropertyFillLayer<EFillAttachment, CSSPropertyWebkitMaskAttachment, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
1584                        &FillLayer::isAttachmentSet, &FillLayer::attachment, &FillLayer::setAttachment, &FillLayer::clearAttachment, &FillLayer::initialFillAttachment, &CSSStyleSelector::mapFillAttachment>::createHandler());
1585     setPropertyHandler(CSSPropertyWebkitMaskClip, ApplyPropertyFillLayer<EFillBox, CSSPropertyWebkitMaskClip, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
1586                        &FillLayer::isClipSet, &FillLayer::clip, &FillLayer::setClip, &FillLayer::clearClip, &FillLayer::initialFillClip, &CSSStyleSelector::mapFillClip>::createHandler());
1587     setPropertyHandler(CSSPropertyWebkitMaskComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitMaskComposite, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
1588                        &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSStyleSelector::mapFillComposite>::createHandler());
1589
1590     setPropertyHandler(CSSPropertyWebkitMaskImage, ApplyPropertyFillLayer<StyleImage*, CSSPropertyWebkitMaskImage, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
1591                        &FillLayer::isImageSet, &FillLayer::image, &FillLayer::setImage, &FillLayer::clearImage, &FillLayer::initialFillImage, &CSSStyleSelector::mapFillImage>::createHandler());
1592
1593     setPropertyHandler(CSSPropertyWebkitMaskOrigin, ApplyPropertyFillLayer<EFillBox, CSSPropertyWebkitMaskOrigin, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
1594                        &FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &CSSStyleSelector::mapFillOrigin>::createHandler());
1595     setPropertyHandler(CSSPropertyWebkitMaskSize, ApplyPropertyFillLayer<FillSize, CSSPropertyWebkitMaskSize, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
1596                        &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSStyleSelector::mapFillSize>::createHandler());
1597
1598     setPropertyHandler(CSSPropertyWebkitMaskPositionX, ApplyPropertyFillLayer<Length, CSSPropertyWebkitMaskPositionX, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
1599                        &FillLayer::isXPositionSet, &FillLayer::xPosition, &FillLayer::setXPosition, &FillLayer::clearXPosition, &FillLayer::initialFillXPosition, &CSSStyleSelector::mapFillXPosition>::createHandler());
1600     setPropertyHandler(CSSPropertyWebkitMaskPositionY, ApplyPropertyFillLayer<Length, CSSPropertyWebkitMaskPositionY, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
1601                        &FillLayer::isYPositionSet, &FillLayer::yPosition, &FillLayer::setYPosition, &FillLayer::clearYPosition, &FillLayer::initialFillYPosition, &CSSStyleSelector::mapFillYPosition>::createHandler());
1602     setPropertyHandler(CSSPropertyWebkitMaskPosition, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitMaskPositionX, CSSPropertyWebkitMaskPositionY>::createHandler());
1603
1604     setPropertyHandler(CSSPropertyWebkitMaskRepeatX, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyWebkitMaskRepeatX, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
1605                        &FillLayer::isRepeatXSet, &FillLayer::repeatX, &FillLayer::setRepeatX, &FillLayer::clearRepeatX, &FillLayer::initialFillRepeatX, &CSSStyleSelector::mapFillRepeatX>::createHandler());
1606     setPropertyHandler(CSSPropertyWebkitMaskRepeatY, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyWebkitMaskRepeatY, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
1607                        &FillLayer::isRepeatYSet, &FillLayer::repeatY, &FillLayer::setRepeatY, &FillLayer::clearRepeatY, &FillLayer::initialFillRepeatY, &CSSStyleSelector::mapFillRepeatY>::createHandler());
1608     setPropertyHandler(CSSPropertyWebkitMaskRepeat, ApplyPropertyExpanding<SuppressValue, CSSPropertyBackgroundRepeatX, CSSPropertyBackgroundRepeatY>::createHandler());
1609
1610     setPropertyHandler(CSSPropertyBackgroundColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::backgroundColor, &RenderStyle::setBackgroundColor, &RenderStyle::setVisitedLinkBackgroundColor, &RenderStyle::invalidColor>::createHandler());
1611     setPropertyHandler(CSSPropertyBorderBottomColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderBottomColor, &RenderStyle::setBorderBottomColor, &RenderStyle::setVisitedLinkBorderBottomColor, &RenderStyle::color>::createHandler());
1612     setPropertyHandler(CSSPropertyBorderLeftColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderLeftColor, &RenderStyle::setBorderLeftColor, &RenderStyle::setVisitedLinkBorderLeftColor, &RenderStyle::color>::createHandler());
1613     setPropertyHandler(CSSPropertyBorderRightColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderRightColor, &RenderStyle::setBorderRightColor, &RenderStyle::setVisitedLinkBorderRightColor, &RenderStyle::color>::createHandler());
1614     setPropertyHandler(CSSPropertyBorderTopColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderTopColor, &RenderStyle::setBorderTopColor, &RenderStyle::setVisitedLinkBorderTopColor, &RenderStyle::color>::createHandler());
1615
1616     setPropertyHandler(CSSPropertyBorderTopStyle, ApplyPropertyDefault<EBorderStyle, &RenderStyle::borderTopStyle, EBorderStyle, &RenderStyle::setBorderTopStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::createHandler());
1617     setPropertyHandler(CSSPropertyBorderRightStyle, ApplyPropertyDefault<EBorderStyle, &RenderStyle::borderRightStyle, EBorderStyle, &RenderStyle::setBorderRightStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::createHandler());
1618     setPropertyHandler(CSSPropertyBorderBottomStyle, ApplyPropertyDefault<EBorderStyle, &RenderStyle::borderBottomStyle, EBorderStyle, &RenderStyle::setBorderBottomStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::createHandler());
1619     setPropertyHandler(CSSPropertyBorderLeftStyle, ApplyPropertyDefault<EBorderStyle, &RenderStyle::borderLeftStyle, EBorderStyle, &RenderStyle::setBorderLeftStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::createHandler());
1620
1621     setPropertyHandler(CSSPropertyBorderTopWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::borderTopWidth, &RenderStyle::setBorderTopWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
1622     setPropertyHandler(CSSPropertyBorderRightWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::borderRightWidth, &RenderStyle::setBorderRightWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
1623     setPropertyHandler(CSSPropertyBorderBottomWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::borderBottomWidth, &RenderStyle::setBorderBottomWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
1624     setPropertyHandler(CSSPropertyBorderLeftWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::borderLeftWidth, &RenderStyle::setBorderLeftWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
1625     setPropertyHandler(CSSPropertyOutlineWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::outlineWidth, &RenderStyle::setOutlineWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
1626     setPropertyHandler(CSSPropertyWebkitColumnRuleWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::columnRuleWidth, &RenderStyle::setColumnRuleWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
1627
1628     setPropertyHandler(CSSPropertyBorderTop, ApplyPropertyExpanding<SuppressValue, CSSPropertyBorderTopColor, CSSPropertyBorderTopStyle, CSSPropertyBorderTopWidth>::createHandler());
1629     setPropertyHandler(CSSPropertyBorderRight, ApplyPropertyExpanding<SuppressValue, CSSPropertyBorderRightColor, CSSPropertyBorderRightStyle, CSSPropertyBorderRightWidth>::createHandler());
1630     setPropertyHandler(CSSPropertyBorderBottom, ApplyPropertyExpanding<SuppressValue, CSSPropertyBorderBottomColor, CSSPropertyBorderBottomStyle, CSSPropertyBorderBottomWidth>::createHandler());
1631     setPropertyHandler(CSSPropertyBorderLeft, ApplyPropertyExpanding<SuppressValue, CSSPropertyBorderLeftColor, CSSPropertyBorderLeftStyle, CSSPropertyBorderLeftWidth>::createHandler());
1632
1633     setPropertyHandler(CSSPropertyBorderStyle, ApplyPropertyExpanding<SuppressValue, CSSPropertyBorderTopStyle, CSSPropertyBorderRightStyle, CSSPropertyBorderBottomStyle, CSSPropertyBorderLeftStyle>::createHandler());
1634     setPropertyHandler(CSSPropertyBorderWidth, ApplyPropertyExpanding<SuppressValue, CSSPropertyBorderTopWidth, CSSPropertyBorderRightWidth, CSSPropertyBorderBottomWidth, CSSPropertyBorderLeftWidth>::createHandler());
1635     setPropertyHandler(CSSPropertyBorderColor, ApplyPropertyExpanding<SuppressValue, CSSPropertyBorderTopColor, CSSPropertyBorderRightColor, CSSPropertyBorderBottomColor, CSSPropertyBorderLeftColor>::createHandler());
1636     setPropertyHandler(CSSPropertyBorder, ApplyPropertyExpanding<SuppressValue, CSSPropertyBorderStyle, CSSPropertyBorderWidth, CSSPropertyBorderColor>::createHandler());
1637
1638     setPropertyHandler(CSSPropertyBorderImage, ApplyPropertyBorderImage<Image, CSSPropertyBorderImage, &RenderStyle::borderImage, &RenderStyle::setBorderImage>::createHandler());
1639     setPropertyHandler(CSSPropertyWebkitBorderImage, ApplyPropertyBorderImage<Image, CSSPropertyWebkitBorderImage, &RenderStyle::borderImage, &RenderStyle::setBorderImage>::createHandler());
1640     setPropertyHandler(CSSPropertyWebkitMaskBoxImage, ApplyPropertyBorderImage<Mask, CSSPropertyWebkitMaskBoxImage, &RenderStyle::maskBoxImage, &RenderStyle::setMaskBoxImage>::createHandler());
1641
1642     setPropertyHandler(CSSPropertyBorderImageOutset, ApplyPropertyBorderImageModifier<Image, Outset>::createHandler());
1643     setPropertyHandler(CSSPropertyWebkitMaskBoxImageOutset, ApplyPropertyBorderImageModifier<Mask, Outset>::createHandler());
1644     setPropertyHandler(CSSPropertyBorderImageRepeat, ApplyPropertyBorderImageModifier<Image, Repeat>::createHandler());
1645     setPropertyHandler(CSSPropertyWebkitMaskBoxImageRepeat, ApplyPropertyBorderImageModifier<Mask, Repeat>::createHandler());
1646     setPropertyHandler(CSSPropertyBorderImageSlice, ApplyPropertyBorderImageModifier<Image, Slice>::createHandler());
1647     setPropertyHandler(CSSPropertyWebkitMaskBoxImageSlice, ApplyPropertyBorderImageModifier<Mask, Slice>::createHandler());
1648     setPropertyHandler(CSSPropertyBorderImageWidth, ApplyPropertyBorderImageModifier<Image, Width>::createHandler());
1649     setPropertyHandler(CSSPropertyWebkitMaskBoxImageWidth, ApplyPropertyBorderImageModifier<Mask, Width>::createHandler());
1650
1651     setPropertyHandler(CSSPropertyBorderImageSource, ApplyPropertyBorderImageSource<CSSPropertyBorderImageSource, &RenderStyle::borderImageSource, &RenderStyle::setBorderImageSource, &RenderStyle::initialBorderImageSource>::createHandler());
1652     setPropertyHandler(CSSPropertyWebkitMaskBoxImageSource, ApplyPropertyBorderImageSource<CSSPropertyWebkitMaskBoxImageSource, &RenderStyle::maskBoxImageSource, &RenderStyle::setMaskBoxImageSource, &RenderStyle::initialMaskBoxImageSource>::createHandler());
1653
1654     setPropertyHandler(CSSPropertyBorderTopLeftRadius, ApplyPropertyBorderRadius<&RenderStyle::borderTopLeftRadius, &RenderStyle::setBorderTopLeftRadius, &RenderStyle::initialBorderRadius>::createHandler());
1655     setPropertyHandler(CSSPropertyBorderTopRightRadius, ApplyPropertyBorderRadius<&RenderStyle::borderTopRightRadius, &RenderStyle::setBorderTopRightRadius, &RenderStyle::initialBorderRadius>::createHandler());
1656     setPropertyHandler(CSSPropertyBorderBottomLeftRadius, ApplyPropertyBorderRadius<&RenderStyle::borderBottomLeftRadius, &RenderStyle::setBorderBottomLeftRadius, &RenderStyle::initialBorderRadius>::createHandler());
1657     setPropertyHandler(CSSPropertyBorderBottomRightRadius, ApplyPropertyBorderRadius<&RenderStyle::borderBottomRightRadius, &RenderStyle::setBorderBottomRightRadius, &RenderStyle::initialBorderRadius>::createHandler());
1658     setPropertyHandler(CSSPropertyBorderRadius, ApplyPropertyExpanding<ExpandValue, CSSPropertyBorderTopLeftRadius, CSSPropertyBorderTopRightRadius, CSSPropertyBorderBottomLeftRadius, CSSPropertyBorderBottomRightRadius>::createHandler());
1659     setPropertyHandler(CSSPropertyWebkitBorderRadius, CSSPropertyBorderRadius);
1660
1661     setPropertyHandler(CSSPropertyWebkitBorderHorizontalSpacing, ApplyPropertyComputeLength<short, &RenderStyle::horizontalBorderSpacing, &RenderStyle::setHorizontalBorderSpacing, &RenderStyle::initialHorizontalBorderSpacing>::createHandler());
1662     setPropertyHandler(CSSPropertyWebkitBorderVerticalSpacing, ApplyPropertyComputeLength<short, &RenderStyle::verticalBorderSpacing, &RenderStyle::setVerticalBorderSpacing, &RenderStyle::initialVerticalBorderSpacing>::createHandler());
1663     setPropertyHandler(CSSPropertyBorderSpacing, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitBorderHorizontalSpacing, CSSPropertyWebkitBorderVerticalSpacing>::createHandler());
1664
1665     setPropertyHandler(CSSPropertyLetterSpacing, ApplyPropertyComputeLength<int, &RenderStyle::letterSpacing, &RenderStyle::setLetterSpacing, &RenderStyle::initialLetterWordSpacing, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>::createHandler());
1666     setPropertyHandler(CSSPropertyWordSpacing, ApplyPropertyComputeLength<int, &RenderStyle::wordSpacing, &RenderStyle::setWordSpacing, &RenderStyle::initialLetterWordSpacing, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>::createHandler());
1667
1668     setPropertyHandler(CSSPropertyCursor, ApplyPropertyCursor::createHandler());
1669
1670     setPropertyHandler(CSSPropertyCounterIncrement, ApplyPropertyCounter<Increment>::createHandler());
1671     setPropertyHandler(CSSPropertyCounterReset, ApplyPropertyCounter<Reset>::createHandler());
1672
1673     setPropertyHandler(CSSPropertyWebkitFlexOrder, ApplyPropertyDefault<int, &RenderStyle::flexOrder, int, &RenderStyle::setFlexOrder, int, &RenderStyle::initialFlexOrder>::createHandler());
1674     setPropertyHandler(CSSPropertyWebkitFlexPack, ApplyPropertyDefault<EFlexPack, &RenderStyle::flexPack, EFlexPack, &RenderStyle::setFlexPack, EFlexPack, &RenderStyle::initialFlexPack>::createHandler());
1675     setPropertyHandler(CSSPropertyWebkitFlexItemAlign, ApplyPropertyDefault<EFlexAlign, &RenderStyle::flexItemAlign, EFlexAlign, &RenderStyle::setFlexItemAlign, EFlexAlign, &RenderStyle::initialFlexItemAlign>::createHandler());
1676     setPropertyHandler(CSSPropertyWebkitFlexDirection, ApplyPropertyDefault<EFlexDirection, &RenderStyle::flexDirection, EFlexDirection, &RenderStyle::setFlexDirection, EFlexDirection, &RenderStyle::initialFlexDirection>::createHandler());
1677     setPropertyHandler(CSSPropertyWebkitFlexWrap, ApplyPropertyDefault<EFlexWrap, &RenderStyle::flexWrap, EFlexWrap, &RenderStyle::setFlexWrap, EFlexWrap, &RenderStyle::initialFlexWrap>::createHandler());
1678     setPropertyHandler(CSSPropertyWebkitFlexFlow, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitFlexDirection, CSSPropertyWebkitFlexWrap>::createHandler());
1679
1680     setPropertyHandler(CSSPropertyFontSize, ApplyPropertyFontSize::createHandler());
1681     setPropertyHandler(CSSPropertyFontStyle, ApplyPropertyFont<FontItalic, &FontDescription::italic, &FontDescription::setItalic, FontItalicOff>::createHandler());
1682     setPropertyHandler(CSSPropertyFontVariant, ApplyPropertyFont<FontSmallCaps, &FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff>::createHandler());
1683     setPropertyHandler(CSSPropertyTextRendering, ApplyPropertyFont<TextRenderingMode, &FontDescription::textRenderingMode, &FontDescription::setTextRenderingMode, AutoTextRendering>::createHandler());
1684     setPropertyHandler(CSSPropertyWebkitFontSmoothing, ApplyPropertyFont<FontSmoothingMode, &FontDescription::fontSmoothing, &FontDescription::setFontSmoothing, AutoSmoothing>::createHandler());
1685     setPropertyHandler(CSSPropertyWebkitTextOrientation, ApplyPropertyFont<TextOrientation, &FontDescription::textOrientation, &FontDescription::setTextOrientation, TextOrientationVerticalRight>::createHandler());
1686     setPropertyHandler(CSSPropertyFontWeight, ApplyPropertyFontWeight::createHandler());
1687
1688     setPropertyHandler(CSSPropertyTextAlign, ApplyPropertyTextAlign::createHandler());
1689     setPropertyHandler(CSSPropertyTextDecoration, ApplyPropertyTextDecoration::createHandler());
1690
1691     setPropertyHandler(CSSPropertyOutlineStyle, ApplyPropertyOutlineStyle::createHandler());
1692     setPropertyHandler(CSSPropertyOutlineColor, ApplyPropertyColor<InheritFromParent, &RenderStyle::outlineColor, &RenderStyle::setOutlineColor, &RenderStyle::setVisitedLinkOutlineColor, &RenderStyle::color>::createHandler());
1693     setPropertyHandler(CSSPropertyOutlineOffset, ApplyPropertyComputeLength<int, &RenderStyle::outlineOffset, &RenderStyle::setOutlineOffset, &RenderStyle::initialOutlineOffset>::createHandler());
1694
1695     setPropertyHandler(CSSPropertyOutline, ApplyPropertyExpanding<SuppressValue, CSSPropertyOutlineWidth, CSSPropertyOutlineColor, CSSPropertyOutlineStyle>::createHandler());
1696
1697     setPropertyHandler(CSSPropertyOverflowX, ApplyPropertyDefault<EOverflow, &RenderStyle::overflowX, EOverflow, &RenderStyle::setOverflowX, EOverflow, &RenderStyle::initialOverflowX>::createHandler());
1698     setPropertyHandler(CSSPropertyOverflowY, ApplyPropertyDefault<EOverflow, &RenderStyle::overflowY, EOverflow, &RenderStyle::setOverflowY, EOverflow, &RenderStyle::initialOverflowY>::createHandler());
1699     setPropertyHandler(CSSPropertyOverflow, ApplyPropertyExpanding<ExpandValue, CSSPropertyOverflowX, CSSPropertyOverflowY>::createHandler());
1700
1701     setPropertyHandler(CSSPropertyWebkitColumnRuleColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::columnRuleColor, &RenderStyle::setColumnRuleColor, &RenderStyle::setVisitedLinkColumnRuleColor, &RenderStyle::color>::createHandler());
1702     setPropertyHandler(CSSPropertyWebkitTextEmphasisColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textEmphasisColor, &RenderStyle::setTextEmphasisColor, &RenderStyle::setVisitedLinkTextEmphasisColor, &RenderStyle::color>::createHandler());
1703     setPropertyHandler(CSSPropertyWebkitTextFillColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textFillColor, &RenderStyle::setTextFillColor, &RenderStyle::setVisitedLinkTextFillColor, &RenderStyle::color>::createHandler());
1704     setPropertyHandler(CSSPropertyWebkitTextStrokeColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textStrokeColor, &RenderStyle::setTextStrokeColor, &RenderStyle::setVisitedLinkTextStrokeColor, &RenderStyle::color>::createHandler());
1705
1706     setPropertyHandler(CSSPropertyTop, ApplyPropertyLength<&RenderStyle::top, &RenderStyle::setTop, &RenderStyle::initialOffset, AutoEnabled>::createHandler());
1707     setPropertyHandler(CSSPropertyRight, ApplyPropertyLength<&RenderStyle::right, &RenderStyle::setRight, &RenderStyle::initialOffset, AutoEnabled>::createHandler());
1708     setPropertyHandler(CSSPropertyBottom, ApplyPropertyLength<&RenderStyle::bottom, &RenderStyle::setBottom, &RenderStyle::initialOffset, AutoEnabled>::createHandler());
1709     setPropertyHandler(CSSPropertyLeft, ApplyPropertyLength<&RenderStyle::left, &RenderStyle::setLeft, &RenderStyle::initialOffset, AutoEnabled>::createHandler());
1710
1711     setPropertyHandler(CSSPropertyWidth, ApplyPropertyLength<&RenderStyle::width, &RenderStyle::setWidth, &RenderStyle::initialSize, AutoEnabled, IntrinsicEnabled, MinIntrinsicEnabled, NoneDisabled, UndefinedDisabled, FlexWidth>::createHandler());
1712     setPropertyHandler(CSSPropertyHeight, ApplyPropertyLength<&RenderStyle::height, &RenderStyle::setHeight, &RenderStyle::initialSize, AutoEnabled, IntrinsicEnabled, MinIntrinsicEnabled, NoneDisabled, UndefinedDisabled, FlexHeight>::createHandler());
1713
1714     setPropertyHandler(CSSPropertyTextIndent, ApplyPropertyLength<&RenderStyle::textIndent, &RenderStyle::setTextIndent, &RenderStyle::initialTextIndent>::createHandler());
1715
1716     setPropertyHandler(CSSPropertyLineHeight, ApplyPropertyLineHeight::createHandler());
1717
1718     setPropertyHandler(CSSPropertyListStyleImage, ApplyPropertyStyleImage<&RenderStyle::listStyleImage, &RenderStyle::setListStyleImage, &RenderStyle::initialListStyleImage, CSSPropertyListStyleImage>::createHandler());
1719     setPropertyHandler(CSSPropertyListStylePosition, ApplyPropertyDefault<EListStylePosition, &RenderStyle::listStylePosition, EListStylePosition, &RenderStyle::setListStylePosition, EListStylePosition, &RenderStyle::initialListStylePosition>::createHandler());
1720     setPropertyHandler(CSSPropertyListStyleType, ApplyPropertyDefault<EListStyleType, &RenderStyle::listStyleType, EListStyleType, &RenderStyle::setListStyleType, EListStyleType, &RenderStyle::initialListStyleType>::createHandler());
1721     setPropertyHandler(CSSPropertyListStyle, ApplyPropertyExpanding<SuppressValue, CSSPropertyListStyleType, CSSPropertyListStyleImage, CSSPropertyListStylePosition>::createHandler());
1722
1723     setPropertyHandler(CSSPropertyMaxHeight, ApplyPropertyLength<&RenderStyle::maxHeight, &RenderStyle::setMaxHeight, &RenderStyle::initialMaxSize, AutoEnabled, IntrinsicEnabled, MinIntrinsicEnabled, NoneEnabled, UndefinedEnabled>::createHandler());
1724     setPropertyHandler(CSSPropertyMaxWidth, ApplyPropertyLength<&RenderStyle::maxWidth, &RenderStyle::setMaxWidth, &RenderStyle::initialMaxSize, AutoEnabled, IntrinsicEnabled, MinIntrinsicEnabled, NoneEnabled, UndefinedEnabled>::createHandler());
1725     setPropertyHandler(CSSPropertyMinHeight, ApplyPropertyLength<&RenderStyle::minHeight, &RenderStyle::setMinHeight, &RenderStyle::initialMinSize, AutoEnabled, IntrinsicEnabled, MinIntrinsicEnabled>::createHandler());
1726     setPropertyHandler(CSSPropertyMinWidth, ApplyPropertyLength<&RenderStyle::minWidth, &RenderStyle::setMinWidth, &RenderStyle::initialMinSize, AutoEnabled, IntrinsicEnabled, MinIntrinsicEnabled>::createHandler());
1727
1728     setPropertyHandler(CSSPropertyMarginTop, ApplyPropertyLength<&RenderStyle::marginTop, &RenderStyle::setMarginTop, &RenderStyle::initialMargin, AutoEnabled>::createHandler());
1729     setPropertyHandler(CSSPropertyMarginRight, ApplyPropertyLength<&RenderStyle::marginRight, &RenderStyle::setMarginRight, &RenderStyle::initialMargin, AutoEnabled>::createHandler());
1730     setPropertyHandler(CSSPropertyMarginBottom, ApplyPropertyLength<&RenderStyle::marginBottom, &RenderStyle::setMarginBottom, &RenderStyle::initialMargin, AutoEnabled>::createHandler());
1731     setPropertyHandler(CSSPropertyMarginLeft, ApplyPropertyLength<&RenderStyle::marginLeft, &RenderStyle::setMarginLeft, &RenderStyle::initialMargin, AutoEnabled>::createHandler());
1732     setPropertyHandler(CSSPropertyMargin, ApplyPropertyExpanding<SuppressValue, CSSPropertyMarginTop, CSSPropertyMarginRight, CSSPropertyMarginBottom, CSSPropertyMarginLeft>::createHandler());
1733
1734     setPropertyHandler(CSSPropertyWebkitMarginBeforeCollapse, ApplyPropertyDefault<EMarginCollapse, &RenderStyle::marginBeforeCollapse, EMarginCollapse, &RenderStyle::setMarginBeforeCollapse, EMarginCollapse, &RenderStyle::initialMarginBeforeCollapse>::createHandler());
1735     setPropertyHandler(CSSPropertyWebkitMarginAfterCollapse, ApplyPropertyDefault<EMarginCollapse, &RenderStyle::marginAfterCollapse, EMarginCollapse, &RenderStyle::setMarginAfterCollapse, EMarginCollapse, &RenderStyle::initialMarginAfterCollapse>::createHandler());
1736     setPropertyHandler(CSSPropertyWebkitMarginTopCollapse, CSSPropertyWebkitMarginBeforeCollapse);
1737     setPropertyHandler(CSSPropertyWebkitMarginBottomCollapse, CSSPropertyWebkitMarginAfterCollapse);
1738     setPropertyHandler(CSSPropertyWebkitMarginCollapse, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitMarginBeforeCollapse, CSSPropertyWebkitMarginAfterCollapse>::createHandler());
1739
1740     setPropertyHandler(CSSPropertyPaddingTop, ApplyPropertyLength<&RenderStyle::paddingTop, &RenderStyle::setPaddingTop, &RenderStyle::initialPadding>::createHandler());
1741     setPropertyHandler(CSSPropertyPaddingRight, ApplyPropertyLength<&RenderStyle::paddingRight, &RenderStyle::setPaddingRight, &RenderStyle::initialPadding>::createHandler());
1742     setPropertyHandler(CSSPropertyPaddingBottom, ApplyPropertyLength<&RenderStyle::paddingBottom, &RenderStyle::setPaddingBottom, &RenderStyle::initialPadding>::createHandler());
1743     setPropertyHandler(CSSPropertyPaddingLeft, ApplyPropertyLength<&RenderStyle::paddingLeft, &RenderStyle::setPaddingLeft, &RenderStyle::initialPadding>::createHandler());
1744     setPropertyHandler(CSSPropertyPadding, ApplyPropertyExpanding<SuppressValue, CSSPropertyPaddingTop, CSSPropertyPaddingRight, CSSPropertyPaddingBottom, CSSPropertyPaddingLeft>::createHandler());
1745
1746     setPropertyHandler(CSSPropertyResize, ApplyPropertyResize::createHandler());
1747
1748     setPropertyHandler(CSSPropertyVerticalAlign, ApplyPropertyVerticalAlign::createHandler());
1749
1750     setPropertyHandler(CSSPropertySize, ApplyPropertyPageSize::createHandler());
1751
1752     setPropertyHandler(CSSPropertyWebkitPerspectiveOriginX, ApplyPropertyLength<&RenderStyle::perspectiveOriginX, &RenderStyle::setPerspectiveOriginX, &RenderStyle::initialPerspectiveOriginX>::createHandler());
1753     setPropertyHandler(CSSPropertyWebkitPerspectiveOriginY, ApplyPropertyLength<&RenderStyle::perspectiveOriginY, &RenderStyle::setPerspectiveOriginY, &RenderStyle::initialPerspectiveOriginY>::createHandler());
1754     setPropertyHandler(CSSPropertyWebkitPerspectiveOrigin, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitPerspectiveOriginX, CSSPropertyWebkitPerspectiveOriginY>::createHandler());
1755     setPropertyHandler(CSSPropertyWebkitTransformOriginX, ApplyPropertyLength<&RenderStyle::transformOriginX, &RenderStyle::setTransformOriginX, &RenderStyle::initialTransformOriginX>::createHandler());
1756     setPropertyHandler(CSSPropertyWebkitTransformOriginY, ApplyPropertyLength<&RenderStyle::transformOriginY, &RenderStyle::setTransformOriginY, &RenderStyle::initialTransformOriginY>::createHandler());
1757     setPropertyHandler(CSSPropertyWebkitTransformOriginZ, ApplyPropertyComputeLength<float, &RenderStyle::transformOriginZ, &RenderStyle::setTransformOriginZ, &RenderStyle::initialTransformOriginZ>::createHandler());
1758     setPropertyHandler(CSSPropertyWebkitTransformOrigin, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitTransformOriginX, CSSPropertyWebkitTransformOriginY, CSSPropertyWebkitTransformOriginZ>::createHandler());
1759
1760     setPropertyHandler(CSSPropertyWebkitAnimationDelay, ApplyPropertyAnimation<double, &Animation::delay, &Animation::setDelay, &Animation::isDelaySet, &Animation::clearDelay, &Animation::initialAnimationDelay, &CSSStyleSelector::mapAnimationDelay, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1761     setPropertyHandler(CSSPropertyWebkitAnimationDirection, ApplyPropertyAnimation<Animation::AnimationDirection, &Animation::direction, &Animation::setDirection, &Animation::isDirectionSet, &Animation::clearDirection, &Animation::initialAnimationDirection, &CSSStyleSelector::mapAnimationDirection, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1762     setPropertyHandler(CSSPropertyWebkitAnimationDuration, ApplyPropertyAnimation<double, &Animation::duration, &Animation::setDuration, &Animation::isDurationSet, &Animation::clearDuration, &Animation::initialAnimationDuration, &CSSStyleSelector::mapAnimationDuration, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1763     setPropertyHandler(CSSPropertyWebkitAnimationFillMode, ApplyPropertyAnimation<unsigned, &Animation::fillMode, &Animation::setFillMode, &Animation::isFillModeSet, &Animation::clearFillMode, &Animation::initialAnimationFillMode, &CSSStyleSelector::mapAnimationFillMode, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1764     setPropertyHandler(CSSPropertyWebkitAnimationIterationCount, ApplyPropertyAnimation<int, &Animation::iterationCount, &Animation::setIterationCount, &Animation::isIterationCountSet, &Animation::clearIterationCount, &Animation::initialAnimationIterationCount, &CSSStyleSelector::mapAnimationIterationCount, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1765     setPropertyHandler(CSSPropertyWebkitAnimationName, ApplyPropertyAnimation<const String&, &Animation::name, &Animation::setName, &Animation::isNameSet, &Animation::clearName, &Animation::initialAnimationName, &CSSStyleSelector::mapAnimationName, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1766     setPropertyHandler(CSSPropertyWebkitAnimationPlayState, ApplyPropertyAnimation<EAnimPlayState, &Animation::playState, &Animation::setPlayState, &Animation::isPlayStateSet, &Animation::clearPlayState, &Animation::initialAnimationPlayState, &CSSStyleSelector::mapAnimationPlayState, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1767     setPropertyHandler(CSSPropertyWebkitAnimationTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSStyleSelector::mapAnimationTimingFunction, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
1768
1769     setPropertyHandler(CSSPropertyWebkitTransitionDelay, ApplyPropertyAnimation<double, &Animation::delay, &Animation::setDelay, &Animation::isDelaySet, &Animation::clearDelay, &Animation::initialAnimationDelay, &CSSStyleSelector::mapAnimationDelay, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
1770     setPropertyHandler(CSSPropertyWebkitTransitionDuration, ApplyPropertyAnimation<double, &Animation::duration, &Animation::setDuration, &Animation::isDurationSet, &Animation::clearDuration, &Animation::initialAnimationDuration, &CSSStyleSelector::mapAnimationDuration, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
1771     setPropertyHandler(CSSPropertyWebkitTransitionProperty, ApplyPropertyAnimation<int, &Animation::property, &Animation::setProperty, &Animation::isPropertySet, &Animation::clearProperty, &Animation::initialAnimationProperty, &CSSStyleSelector::mapAnimationProperty, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
1772     setPropertyHandler(CSSPropertyWebkitTransitionTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSStyleSelector::mapAnimationTimingFunction, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
1773
1774     setPropertyHandler(CSSPropertyWebkitColumnCount, ApplyPropertyAuto<unsigned short, &RenderStyle::columnCount, &RenderStyle::setColumnCount, &RenderStyle::hasAutoColumnCount, &RenderStyle::setHasAutoColumnCount>::createHandler());
1775     setPropertyHandler(CSSPropertyWebkitColumnGap, ApplyPropertyAuto<float, &RenderStyle::columnGap, &RenderStyle::setColumnGap, &RenderStyle::hasNormalColumnGap, &RenderStyle::setHasNormalColumnGap, ComputeLength, CSSValueNormal>::createHandler());
1776     setPropertyHandler(CSSPropertyWebkitColumnWidth, ApplyPropertyAuto<float, &RenderStyle::columnWidth, &RenderStyle::setColumnWidth, &RenderStyle::hasAutoColumnWidth, &RenderStyle::setHasAutoColumnWidth, ComputeLength>::createHandler());
1777     setPropertyHandler(CSSPropertyWebkitColumns, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitColumnWidth, CSSPropertyWebkitColumnCount>::createHandler());
1778
1779     setPropertyHandler(CSSPropertyWebkitFlowInto, ApplyPropertyString<MapAutoToNull, &RenderStyle::flowThread, &RenderStyle::setFlowThread, &RenderStyle::initialFlowThread>::createHandler());
1780     setPropertyHandler(CSSPropertyWebkitFlowFrom, ApplyPropertyString<MapNoneToNull, &RenderStyle::regionThread, &RenderStyle::setRegionThread, &RenderStyle::initialRegionThread>::createHandler());
1781
1782     setPropertyHandler(CSSPropertyWebkitHighlight, ApplyPropertyString<MapNoneToNull, &RenderStyle::highlight, &RenderStyle::setHighlight, &RenderStyle::initialHighlight>::createHandler());
1783     setPropertyHandler(CSSPropertyWebkitHyphenateCharacter, ApplyPropertyString<MapAutoToNull, &RenderStyle::hyphenationString, &RenderStyle::setHyphenationString, &RenderStyle::initialHyphenationString>::createHandler());
1784
1785     setPropertyHandler(CSSPropertyWebkitHyphenateLimitAfter, ApplyPropertyNumber<short, &RenderStyle::hyphenationLimitAfter, &RenderStyle::setHyphenationLimitAfter, &RenderStyle::initialHyphenationLimitAfter>::createHandler());
1786     setPropertyHandler(CSSPropertyWebkitHyphenateLimitBefore, ApplyPropertyNumber<short, &RenderStyle::hyphenationLimitBefore, &RenderStyle::setHyphenationLimitBefore, &RenderStyle::initialHyphenationLimitBefore>::createHandler());
1787     setPropertyHandler(CSSPropertyWebkitHyphenateLimitLines, ApplyPropertyNumber<short, &RenderStyle::hyphenationLimitLines, &RenderStyle::setHyphenationLimitLines, &RenderStyle::initialHyphenationLimitLines, CSSValueNoLimit>::createHandler());
1788
1789     setPropertyHandler(CSSPropertyWebkitLineGrid, ApplyPropertyString<MapNoneToNull, &RenderStyle::lineGrid, &RenderStyle::setLineGrid, &RenderStyle::initialLineGrid>::createHandler());
1790     setPropertyHandler(CSSPropertyWebkitLineGridSnap, ApplyPropertyDefault<LineGridSnap, &RenderStyle::lineGridSnap, LineGridSnap, &RenderStyle::setLineGridSnap, LineGridSnap, &RenderStyle::initialLineGridSnap>::createHandler());
1791
1792     setPropertyHandler(CSSPropertyWebkitTextCombine, ApplyPropertyDefault<TextCombine, &RenderStyle::textCombine, TextCombine, &RenderStyle::setTextCombine, TextCombine, &RenderStyle::initialTextCombine>::createHandler());
1793     setPropertyHandler(CSSPropertyWebkitTextEmphasisPosition, ApplyPropertyDefault<TextEmphasisPosition, &RenderStyle::textEmphasisPosition, TextEmphasisPosition, &RenderStyle::setTextEmphasisPosition, TextEmphasisPosition, &RenderStyle::initialTextEmphasisPosition>::createHandler());
1794     setPropertyHandler(CSSPropertyWebkitTextEmphasisStyle, ApplyPropertyTextEmphasisStyle::createHandler());
1795
1796     setPropertyHandler(CSSPropertyWebkitWrapMargin, ApplyPropertyLength<&RenderStyle::wrapMargin, &RenderStyle::setWrapMargin, &RenderStyle::initialWrapMargin>::createHandler());
1797     setPropertyHandler(CSSPropertyWebkitWrapPadding, ApplyPropertyLength<&RenderStyle::wrapPadding, &RenderStyle::setWrapPadding, &RenderStyle::initialWrapPadding>::createHandler());
1798     setPropertyHandler(CSSPropertyWebkitWrapFlow, ApplyPropertyDefault<WrapFlow, &RenderStyle::wrapFlow, WrapFlow, &RenderStyle::setWrapFlow, WrapFlow, &RenderStyle::initialWrapFlow>::createHandler());
1799     setPropertyHandler(CSSPropertyWebkitWrapThrough, ApplyPropertyDefault<WrapThrough, &RenderStyle::wrapThrough, WrapThrough, &RenderStyle::setWrapThrough, WrapThrough, &RenderStyle::initialWrapThrough>::createHandler());
1800     setPropertyHandler(CSSPropertyWebkitWrap, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitWrapFlow, CSSPropertyWebkitWrapMargin, CSSPropertyWebkitWrapPadding>::createHandler());
1801
1802     setPropertyHandler(CSSPropertyZIndex, ApplyPropertyAuto<int, &RenderStyle::zIndex, &RenderStyle::setZIndex, &RenderStyle::hasAutoZIndex, &RenderStyle::setHasAutoZIndex>::createHandler());
1803     setPropertyHandler(CSSPropertyZoom, ApplyPropertyZoom::createHandler());
1804 }
1805
1806
1807 }