a30084fe0034412b92288c9e67c730e7b1aa52c2
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / css / resolver / StyleBuilderCustom.cpp
1 /*
2  * Copyright (C) 2013 Google Inc. All rights reserved.
3  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4  *           (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
5  * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
6  * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
7  * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8  * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
10  * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
11  * Copyright (C) Research In Motion Limited 2011. All rights reserved.
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions are
14  * met:
15  *
16  *     * Redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer.
18  *     * Redistributions in binary form must reproduce the above
19  * copyright notice, this list of conditions and the following disclaimer
20  * in the documentation and/or other materials provided with the
21  * distribution.
22  *     * Neither the name of Google Inc. nor the names of its
23  * contributors may be used to endorse or promote products derived from
24  * this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */
38
39 #include "config.h"
40 #include "StyleBuilderFunctions.h"
41
42 #include "CSSPropertyNames.h"
43 #include "CSSValueKeywords.h"
44 #include "StylePropertyShorthand.h"
45 #include "core/css/BasicShapeFunctions.h"
46 #include "core/css/CSSAspectRatioValue.h"
47 #include "core/css/CSSCursorImageValue.h"
48 #include "core/css/CSSFontValue.h"
49 #include "core/css/CSSFunctionValue.h"
50 #include "core/css/CSSGradientValue.h"
51 #include "core/css/CSSGridLineNamesValue.h"
52 #include "core/css/CSSGridTemplateAreasValue.h"
53 #include "core/css/CSSHelper.h"
54 #include "core/css/CSSImageSetValue.h"
55 #include "core/css/CSSLineBoxContainValue.h"
56 #include "core/css/parser/BisonCSSParser.h"
57 #include "core/css/CSSPrimitiveValueMappings.h"
58 #include "core/css/CSSProperty.h"
59 #include "core/css/CSSReflectValue.h"
60 #include "core/css/Counter.h"
61 #include "core/css/Pair.h"
62 #include "core/css/Rect.h"
63 #include "core/css/StylePropertySet.h"
64 #include "core/css/StyleRule.h"
65 #include "core/css/resolver/ElementStyleResources.h"
66 #include "core/css/resolver/FilterOperationResolver.h"
67 #include "core/css/resolver/FontBuilder.h"
68 #include "core/css/resolver/StyleBuilder.h"
69 #include "core/css/resolver/TransformBuilder.h"
70 #include "core/frame/Frame.h"
71 #include "core/frame/Settings.h"
72 #include "core/rendering/style/CounterContent.h"
73 #include "core/rendering/style/CursorList.h"
74 #include "core/rendering/style/QuotesData.h"
75 #include "core/rendering/style/RenderStyle.h"
76 #include "core/rendering/style/RenderStyleConstants.h"
77 #include "core/rendering/style/SVGRenderStyle.h"
78 #include "core/rendering/style/SVGRenderStyleDefs.h"
79 #include "core/rendering/style/StyleGeneratedImage.h"
80 #include "core/svg/SVGColor.h"
81 #include "core/svg/SVGPaint.h"
82 #include "platform/fonts/FontDescription.h"
83 #include "wtf/MathExtras.h"
84 #include "wtf/StdLibExtras.h"
85 #include "wtf/Vector.h"
86
87 namespace WebCore {
88
89 static Length clipConvertToLength(StyleResolverState& state, CSSPrimitiveValue* value)
90 {
91     return value->convertToLength<FixedConversion | PercentConversion | AutoConversion>(state.cssToLengthConversionData());
92 }
93
94 void StyleBuilderFunctions::applyInitialCSSPropertyClip(StyleResolverState& state)
95 {
96     state.style()->setClip(Length(), Length(), Length(), Length());
97     state.style()->setHasClip(false);
98 }
99
100 void StyleBuilderFunctions::applyInheritCSSPropertyClip(StyleResolverState& state)
101 {
102     RenderStyle* parentStyle = state.parentStyle();
103     if (!parentStyle->hasClip())
104         return applyInitialCSSPropertyClip(state);
105     state.style()->setClip(parentStyle->clipTop(), parentStyle->clipRight(), parentStyle->clipBottom(), parentStyle->clipLeft());
106     state.style()->setHasClip(true);
107 }
108
109 void StyleBuilderFunctions::applyValueCSSPropertyClip(StyleResolverState& state, CSSValue* value)
110 {
111     if (!value->isPrimitiveValue())
112         return;
113
114     CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
115
116     if (Rect* rect = primitiveValue->getRectValue()) {
117         Length top = clipConvertToLength(state, rect->top());
118         Length right = clipConvertToLength(state, rect->right());
119         Length bottom = clipConvertToLength(state, rect->bottom());
120         Length left = clipConvertToLength(state, rect->left());
121         state.style()->setClip(top, right, bottom, left);
122         state.style()->setHasClip(true);
123     } else if (primitiveValue->getValueID() == CSSValueAuto) {
124         state.style()->setClip(Length(), Length(), Length(), Length());
125         state.style()->setHasClip(false);
126     }
127 }
128
129 void StyleBuilderFunctions::applyInitialCSSPropertyColor(StyleResolverState& state)
130 {
131     Color color = RenderStyle::initialColor();
132     if (state.applyPropertyToRegularStyle())
133         state.style()->setColor(color);
134     if (state.applyPropertyToVisitedLinkStyle())
135         state.style()->setVisitedLinkColor(color);
136 }
137
138 void StyleBuilderFunctions::applyInheritCSSPropertyColor(StyleResolverState& state)
139 {
140     Color color = state.parentStyle()->color();
141     if (state.applyPropertyToRegularStyle())
142         state.style()->setColor(color);
143     if (state.applyPropertyToVisitedLinkStyle())
144         state.style()->setVisitedLinkColor(color);
145 }
146
147 void StyleBuilderFunctions::applyValueCSSPropertyColor(StyleResolverState& state, CSSValue* value)
148 {
149     CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
150     // As per the spec, 'color: currentColor' is treated as 'color: inherit'
151     if (primitiveValue->getValueID() == CSSValueCurrentcolor) {
152         applyInheritCSSPropertyColor(state);
153         return;
154     }
155
156     if (state.applyPropertyToRegularStyle())
157         state.style()->setColor(state.document().textLinkColors().colorFromPrimitiveValue(primitiveValue, state.style()->color()));
158     if (state.applyPropertyToVisitedLinkStyle())
159         state.style()->setVisitedLinkColor(state.document().textLinkColors().colorFromPrimitiveValue(primitiveValue, state.style()->color(), state.element()->isLink() /* forVisitedLink */));
160 }
161
162 void StyleBuilderFunctions::applyInitialCSSPropertyCursor(StyleResolverState& state)
163 {
164     state.style()->clearCursorList();
165     state.style()->setCursor(RenderStyle::initialCursor());
166 }
167
168 void StyleBuilderFunctions::applyInheritCSSPropertyCursor(StyleResolverState& state)
169 {
170     state.style()->setCursor(state.parentStyle()->cursor());
171     state.style()->setCursorList(state.parentStyle()->cursors());
172 }
173
174 void StyleBuilderFunctions::applyValueCSSPropertyCursor(StyleResolverState& state, CSSValue* value)
175 {
176     state.style()->clearCursorList();
177     if (value->isValueList()) {
178         CSSValueList* list = toCSSValueList(value);
179         int len = list->length();
180         state.style()->setCursor(CURSOR_AUTO);
181         for (int i = 0; i < len; i++) {
182             CSSValue* item = list->itemWithoutBoundsCheck(i);
183             if (item->isCursorImageValue()) {
184                 CSSCursorImageValue* image = toCSSCursorImageValue(item);
185                 if (image->updateIfSVGCursorIsUsed(state.element())) // Elements with SVG cursors are not allowed to share style.
186                     state.style()->setUnique();
187                 state.style()->addCursor(state.styleImage(CSSPropertyCursor, image), image->hotSpot());
188             } else if (item->isPrimitiveValue()) {
189                 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(item);
190                 if (primitiveValue->isValueID())
191                     state.style()->setCursor(*primitiveValue);
192             }
193         }
194     } else if (value->isPrimitiveValue()) {
195         CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
196         if (primitiveValue->isValueID() && state.style()->cursor() != ECursor(*primitiveValue))
197             state.style()->setCursor(*primitiveValue);
198     }
199 }
200
201 void StyleBuilderFunctions::applyValueCSSPropertyDirection(StyleResolverState& state, CSSValue* value)
202 {
203     state.style()->setDirection(*toCSSPrimitiveValue(value));
204     Element* element = state.element();
205     if (element && element == element->document().documentElement())
206         element->document().setDirectionSetOnDocumentElement(true);
207 }
208
209 static inline bool isValidDisplayValue(StyleResolverState& state, EDisplay displayPropertyValue)
210 {
211     if (state.element() && state.element()->isSVGElement() && state.style()->styleType() == NOPSEUDO)
212         return (displayPropertyValue == INLINE || displayPropertyValue == BLOCK || displayPropertyValue == NONE);
213     return true;
214 }
215
216 void StyleBuilderFunctions::applyInheritCSSPropertyDisplay(StyleResolverState& state)
217 {
218     EDisplay display = state.parentStyle()->display();
219     if (!isValidDisplayValue(state, display))
220         return;
221     state.style()->setDisplay(display);
222 }
223
224 void StyleBuilderFunctions::applyValueCSSPropertyDisplay(StyleResolverState& state, CSSValue* value)
225 {
226     if (!value->isPrimitiveValue())
227         return;
228
229     EDisplay display = *toCSSPrimitiveValue(value);
230
231     if (!isValidDisplayValue(state, display))
232         return;
233
234     state.style()->setDisplay(display);
235 }
236
237 void StyleBuilderFunctions::applyInitialCSSPropertyFontFamily(StyleResolverState& state)
238 {
239     state.fontBuilder().setFontFamilyInitial(state.style()->effectiveZoom());
240 }
241
242 void StyleBuilderFunctions::applyInheritCSSPropertyFontFamily(StyleResolverState& state)
243 {
244     state.fontBuilder().setFontFamilyInherit(state.parentFontDescription());
245 }
246
247 void StyleBuilderFunctions::applyValueCSSPropertyFontFamily(StyleResolverState& state, CSSValue* value)
248 {
249     state.fontBuilder().setFontFamilyValue(value, state.style()->effectiveZoom());
250 }
251
252 void StyleBuilderFunctions::applyInitialCSSPropertyFontSize(StyleResolverState& state)
253 {
254     state.fontBuilder().setFontSizeInitial(state.style()->effectiveZoom());
255 }
256
257 void StyleBuilderFunctions::applyInheritCSSPropertyFontSize(StyleResolverState& state)
258 {
259     state.fontBuilder().setFontSizeInherit(state.parentFontDescription(), state.style()->effectiveZoom());
260 }
261
262 void StyleBuilderFunctions::applyValueCSSPropertyFontSize(StyleResolverState& state, CSSValue* value)
263 {
264     state.fontBuilder().setFontSizeValue(value, state.parentStyle(), state.rootElementStyle(), state.style()->effectiveZoom());
265 }
266
267 void StyleBuilderFunctions::applyInitialCSSPropertyFontWeight(StyleResolverState& state)
268 {
269     state.fontBuilder().setWeight(FontWeightNormal);
270 }
271
272 void StyleBuilderFunctions::applyInheritCSSPropertyFontWeight(StyleResolverState& state)
273 {
274     state.fontBuilder().setWeight(state.parentFontDescription().weight());
275 }
276
277 void StyleBuilderFunctions::applyValueCSSPropertyFontWeight(StyleResolverState& state, CSSValue* value)
278 {
279     if (!value->isPrimitiveValue())
280         return;
281     CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
282     switch (primitiveValue->getValueID()) {
283     case CSSValueInvalid:
284         ASSERT_NOT_REACHED();
285         break;
286     case CSSValueBolder:
287         state.fontBuilder().setWeight(state.parentStyle()->fontDescription().weight());
288         state.fontBuilder().setWeightBolder();
289         break;
290     case CSSValueLighter:
291         state.fontBuilder().setWeight(state.parentStyle()->fontDescription().weight());
292         state.fontBuilder().setWeightLighter();
293         break;
294     default:
295         state.fontBuilder().setWeight(*primitiveValue);
296     }
297 }
298
299 void StyleBuilderFunctions::applyValueCSSPropertyLineHeight(StyleResolverState& state, CSSValue* value)
300 {
301     if (!value->isPrimitiveValue())
302         return;
303
304     CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
305     Length lineHeight;
306
307     if (primitiveValue->getValueID() == CSSValueNormal) {
308         lineHeight = RenderStyle::initialLineHeight();
309     } else if (primitiveValue->isLength()) {
310         float multiplier = state.style()->effectiveZoom();
311         if (Frame* frame = state.document().frame())
312             multiplier *= frame->textZoomFactor();
313         lineHeight = primitiveValue->computeLength<Length>(state.cssToLengthConversionData().copyWithAdjustedZoom(multiplier));
314     } else if (primitiveValue->isPercentage()) {
315         lineHeight = Length((state.style()->computedFontSize() * primitiveValue->getIntValue()) / 100.0, Fixed);
316     } else if (primitiveValue->isNumber()) {
317         lineHeight = Length(primitiveValue->getDoubleValue() * 100.0, Percent);
318     } else if (primitiveValue->isCalculated()) {
319         double multiplier = state.style()->effectiveZoom();
320         if (Frame* frame = state.document().frame())
321             multiplier *= frame->textZoomFactor();
322         Length zoomedLength = Length(primitiveValue->cssCalcValue()->toCalcValue(state.cssToLengthConversionData().copyWithAdjustedZoom(multiplier)));
323         lineHeight = Length(valueForLength(zoomedLength, state.style()->fontSize()), Fixed);
324     } else {
325         return;
326     }
327     state.style()->setLineHeight(lineHeight);
328 }
329
330 void StyleBuilderFunctions::applyValueCSSPropertyListStyleImage(StyleResolverState& state, CSSValue* value)
331 {
332     state.style()->setListStyleImage(state.styleImage(CSSPropertyListStyleImage, value));
333 }
334
335 void StyleBuilderFunctions::applyInitialCSSPropertyOutlineStyle(StyleResolverState& state)
336 {
337     state.style()->setOutlineStyleIsAuto(RenderStyle::initialOutlineStyleIsAuto());
338     state.style()->setOutlineStyle(RenderStyle::initialBorderStyle());
339 }
340
341 void StyleBuilderFunctions::applyInheritCSSPropertyOutlineStyle(StyleResolverState& state)
342 {
343     state.style()->setOutlineStyleIsAuto(state.parentStyle()->outlineStyleIsAuto());
344     state.style()->setOutlineStyle(state.parentStyle()->outlineStyle());
345 }
346
347 void StyleBuilderFunctions::applyValueCSSPropertyOutlineStyle(StyleResolverState& state, CSSValue* value)
348 {
349     CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
350     state.style()->setOutlineStyleIsAuto(*primitiveValue);
351     state.style()->setOutlineStyle(*primitiveValue);
352 }
353
354 void StyleBuilderFunctions::applyValueCSSPropertyResize(StyleResolverState& state, CSSValue* value)
355 {
356     if (!value->isPrimitiveValue())
357         return;
358
359     CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
360
361     EResize r = RESIZE_NONE;
362     switch (primitiveValue->getValueID()) {
363     case 0:
364         return;
365     case CSSValueAuto:
366         if (Settings* settings = state.document().settings())
367             r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE;
368         break;
369     default:
370         r = *primitiveValue;
371     }
372     state.style()->setResize(r);
373 }
374
375 static Length mmLength(double mm) { return Length(mm * cssPixelsPerMillimeter, Fixed); }
376 static Length inchLength(double inch) { return Length(inch * cssPixelsPerInch, Fixed); }
377 static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height)
378 {
379     DEFINE_STATIC_LOCAL(Length, a5Width, (mmLength(148)));
380     DEFINE_STATIC_LOCAL(Length, a5Height, (mmLength(210)));
381     DEFINE_STATIC_LOCAL(Length, a4Width, (mmLength(210)));
382     DEFINE_STATIC_LOCAL(Length, a4Height, (mmLength(297)));
383     DEFINE_STATIC_LOCAL(Length, a3Width, (mmLength(297)));
384     DEFINE_STATIC_LOCAL(Length, a3Height, (mmLength(420)));
385     DEFINE_STATIC_LOCAL(Length, b5Width, (mmLength(176)));
386     DEFINE_STATIC_LOCAL(Length, b5Height, (mmLength(250)));
387     DEFINE_STATIC_LOCAL(Length, b4Width, (mmLength(250)));
388     DEFINE_STATIC_LOCAL(Length, b4Height, (mmLength(353)));
389     DEFINE_STATIC_LOCAL(Length, letterWidth, (inchLength(8.5)));
390     DEFINE_STATIC_LOCAL(Length, letterHeight, (inchLength(11)));
391     DEFINE_STATIC_LOCAL(Length, legalWidth, (inchLength(8.5)));
392     DEFINE_STATIC_LOCAL(Length, legalHeight, (inchLength(14)));
393     DEFINE_STATIC_LOCAL(Length, ledgerWidth, (inchLength(11)));
394     DEFINE_STATIC_LOCAL(Length, ledgerHeight, (inchLength(17)));
395
396     if (!pageSizeName)
397         return false;
398
399     switch (pageSizeName->getValueID()) {
400     case CSSValueA5:
401         width = a5Width;
402         height = a5Height;
403         break;
404     case CSSValueA4:
405         width = a4Width;
406         height = a4Height;
407         break;
408     case CSSValueA3:
409         width = a3Width;
410         height = a3Height;
411         break;
412     case CSSValueB5:
413         width = b5Width;
414         height = b5Height;
415         break;
416     case CSSValueB4:
417         width = b4Width;
418         height = b4Height;
419         break;
420     case CSSValueLetter:
421         width = letterWidth;
422         height = letterHeight;
423         break;
424     case CSSValueLegal:
425         width = legalWidth;
426         height = legalHeight;
427         break;
428     case CSSValueLedger:
429         width = ledgerWidth;
430         height = ledgerHeight;
431         break;
432     default:
433         return false;
434     }
435
436     if (pageOrientation) {
437         switch (pageOrientation->getValueID()) {
438         case CSSValueLandscape:
439             std::swap(width, height);
440             break;
441         case CSSValuePortrait:
442             // Nothing to do.
443             break;
444         default:
445             return false;
446         }
447     }
448     return true;
449 }
450
451 void StyleBuilderFunctions::applyInitialCSSPropertySize(StyleResolverState&) { }
452 void StyleBuilderFunctions::applyInheritCSSPropertySize(StyleResolverState&) { }
453 void StyleBuilderFunctions::applyValueCSSPropertySize(StyleResolverState& state, CSSValue* value)
454 {
455     state.style()->resetPageSizeType();
456     Length width;
457     Length height;
458     PageSizeType pageSizeType = PAGE_SIZE_AUTO;
459     CSSValueListInspector inspector(value);
460     switch (inspector.length()) {
461     case 2: {
462         // <length>{2} | <page-size> <orientation>
463         if (!inspector.first()->isPrimitiveValue() || !inspector.second()->isPrimitiveValue())
464             return;
465         CSSPrimitiveValue* first = toCSSPrimitiveValue(inspector.first());
466         CSSPrimitiveValue* second = toCSSPrimitiveValue(inspector.second());
467         if (first->isLength()) {
468             // <length>{2}
469             if (!second->isLength())
470                 return;
471             width = first->computeLength<Length>(state.cssToLengthConversionData().copyWithAdjustedZoom(1.0));
472             height = second->computeLength<Length>(state.cssToLengthConversionData().copyWithAdjustedZoom(1.0));
473         } else {
474             // <page-size> <orientation>
475             // The value order is guaranteed. See BisonCSSParser::parseSizeParameter.
476             if (!getPageSizeFromName(first, second, width, height))
477                 return;
478         }
479         pageSizeType = PAGE_SIZE_RESOLVED;
480         break;
481     }
482     case 1: {
483         // <length> | auto | <page-size> | [ portrait | landscape]
484         if (!inspector.first()->isPrimitiveValue())
485             return;
486         CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(inspector.first());
487         if (primitiveValue->isLength()) {
488             // <length>
489             pageSizeType = PAGE_SIZE_RESOLVED;
490             width = height = primitiveValue->computeLength<Length>(state.cssToLengthConversionData().copyWithAdjustedZoom(1.0));
491         } else {
492             switch (primitiveValue->getValueID()) {
493             case 0:
494                 return;
495             case CSSValueAuto:
496                 pageSizeType = PAGE_SIZE_AUTO;
497                 break;
498             case CSSValuePortrait:
499                 pageSizeType = PAGE_SIZE_AUTO_PORTRAIT;
500                 break;
501             case CSSValueLandscape:
502                 pageSizeType = PAGE_SIZE_AUTO_LANDSCAPE;
503                 break;
504             default:
505                 // <page-size>
506                 pageSizeType = PAGE_SIZE_RESOLVED;
507                 if (!getPageSizeFromName(primitiveValue, 0, width, height))
508                     return;
509             }
510         }
511         break;
512     }
513     default:
514         return;
515     }
516     state.style()->setPageSizeType(pageSizeType);
517     state.style()->setPageSize(LengthSize(width, height));
518 }
519
520 void StyleBuilderFunctions::applyValueCSSPropertyTextAlign(StyleResolverState& state, CSSValue* value)
521 {
522     if (!value->isPrimitiveValue())
523         return;
524
525     CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
526     // FIXME : Per http://www.w3.org/TR/css3-text/#text-align0 can now take <string> but this is not implemented in the
527     // rendering code.
528     if (primitiveValue->isString())
529         return;
530
531     if (primitiveValue->isValueID() && primitiveValue->getValueID() != CSSValueWebkitMatchParent)
532         state.style()->setTextAlign(*primitiveValue);
533     else if (state.parentStyle()->textAlign() == TASTART)
534         state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT);
535     else if (state.parentStyle()->textAlign() == TAEND)
536         state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection() ? RIGHT : LEFT);
537     else
538         state.style()->setTextAlign(state.parentStyle()->textAlign());
539 }
540
541 void StyleBuilderFunctions::applyValueCSSPropertyTextDecoration(StyleResolverState& state, CSSValue* value)
542 {
543     TextDecoration t = RenderStyle::initialTextDecoration();
544     for (CSSValueListIterator i(value); i.hasMore(); i.advance()) {
545         CSSValue* item = i.value();
546         t |= *toCSSPrimitiveValue(item);
547     }
548     state.style()->setTextDecoration(t);
549 }
550
551 void StyleBuilderFunctions::applyInheritCSSPropertyTextIndent(StyleResolverState& state)
552 {
553     state.style()->setTextIndent(state.parentStyle()->textIndent());
554     state.style()->setTextIndentLine(state.parentStyle()->textIndentLine());
555 }
556
557 void StyleBuilderFunctions::applyInitialCSSPropertyTextIndent(StyleResolverState& state)
558 {
559     state.style()->setTextIndent(RenderStyle::initialTextIndent());
560     state.style()->setTextIndentLine(RenderStyle::initialTextIndentLine());
561 }
562
563 void StyleBuilderFunctions::applyValueCSSPropertyTextIndent(StyleResolverState& state, CSSValue* value)
564 {
565     if (!value->isValueList())
566         return;
567
568     // [ <length> | <percentage> ] each-line
569     // The order is guaranteed. See BisonCSSParser::parseTextIndent.
570     // The second value, each-line is handled only when css3TextEnabled() returns true.
571
572     CSSValueList* valueList = toCSSValueList(value);
573     CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->itemWithoutBoundsCheck(0));
574     Length lengthOrPercentageValue = primitiveValue->convertToLength<FixedConversion | PercentConversion>(state.cssToLengthConversionData());
575     state.style()->setTextIndent(lengthOrPercentageValue);
576
577     ASSERT(valueList->length() <= 2);
578     CSSPrimitiveValue* eachLineValue = toCSSPrimitiveValue(valueList->item(1));
579     if (eachLineValue) {
580         ASSERT(eachLineValue->getValueID() == CSSValueEachLine);
581         state.style()->setTextIndentLine(TextIndentEachLine);
582     } else
583         state.style()->setTextIndentLine(TextIndentFirstLine);
584 }
585
586 void StyleBuilderFunctions::applyValueCSSPropertyVerticalAlign(StyleResolverState& state, CSSValue* value)
587 {
588     if (!value->isPrimitiveValue())
589         return;
590
591     CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
592
593     if (primitiveValue->getValueID())
594         return state.style()->setVerticalAlign(*primitiveValue);
595
596     state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedConversion | PercentConversion>(state.cssToLengthConversionData()));
597 }
598
599 void StyleBuilderFunctions::applyValueCSSPropertyTouchAction(StyleResolverState& state, CSSValue* value)
600 {
601     TouchAction action = RenderStyle::initialTouchAction();
602     for (CSSValueListIterator i(value); i.hasMore(); i.advance())
603         action |= *toCSSPrimitiveValue(i.value());
604
605     state.style()->setTouchAction(action);
606 }
607
608 static void resetEffectiveZoom(StyleResolverState& state)
609 {
610     // Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect.
611     state.setEffectiveZoom(state.parentStyle() ? state.parentStyle()->effectiveZoom() : RenderStyle::initialZoom());
612 }
613
614 void StyleBuilderFunctions::applyInitialCSSPropertyZoom(StyleResolverState& state)
615 {
616     resetEffectiveZoom(state);
617     state.setZoom(RenderStyle::initialZoom());
618 }
619
620 void StyleBuilderFunctions::applyInheritCSSPropertyZoom(StyleResolverState& state)
621 {
622     resetEffectiveZoom(state);
623     state.setZoom(state.parentStyle()->zoom());
624 }
625
626 void StyleBuilderFunctions::applyValueCSSPropertyZoom(StyleResolverState& state, CSSValue* value)
627 {
628     ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue());
629     CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
630
631     if (primitiveValue->getValueID() == CSSValueNormal) {
632         resetEffectiveZoom(state);
633         state.setZoom(RenderStyle::initialZoom());
634     } else if (primitiveValue->getValueID() == CSSValueReset) {
635         state.setEffectiveZoom(RenderStyle::initialZoom());
636         state.setZoom(RenderStyle::initialZoom());
637     } else if (primitiveValue->getValueID() == CSSValueDocument) {
638         float docZoom = state.rootElementStyle() ? state.rootElementStyle()->zoom() : RenderStyle::initialZoom();
639         state.setEffectiveZoom(docZoom);
640         state.setZoom(docZoom);
641     } else if (primitiveValue->isPercentage()) {
642         resetEffectiveZoom(state);
643         if (float percent = primitiveValue->getFloatValue())
644             state.setZoom(percent / 100.0f);
645     } else if (primitiveValue->isNumber()) {
646         resetEffectiveZoom(state);
647         if (float number = primitiveValue->getFloatValue())
648             state.setZoom(number);
649     }
650 }
651
652 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitAspectRatio(StyleResolverState& state)
653 {
654     state.style()->setHasAspectRatio(RenderStyle::initialHasAspectRatio());
655     state.style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDenominator());
656     state.style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumerator());
657 }
658
659 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitAspectRatio(StyleResolverState& state)
660 {
661     if (!state.parentStyle()->hasAspectRatio())
662         return;
663     state.style()->setHasAspectRatio(true);
664     state.style()->setAspectRatioDenominator(state.parentStyle()->aspectRatioDenominator());
665     state.style()->setAspectRatioNumerator(state.parentStyle()->aspectRatioNumerator());
666 }
667
668 void StyleBuilderFunctions::applyValueCSSPropertyWebkitAspectRatio(StyleResolverState& state, CSSValue* value)
669 {
670     if (!value->isAspectRatioValue()) {
671         state.style()->setHasAspectRatio(false);
672         return;
673     }
674     CSSAspectRatioValue* aspectRatioValue = toCSSAspectRatioValue(value);
675     state.style()->setHasAspectRatio(true);
676     state.style()->setAspectRatioDenominator(aspectRatioValue->denominatorValue());
677     state.style()->setAspectRatioNumerator(aspectRatioValue->numeratorValue());
678 }
679
680 void StyleBuilderFunctions::applyValueCSSPropertyWebkitBorderImage(StyleResolverState& state, CSSValue* value)
681 {
682     NinePieceImage image;
683     state.styleMap().mapNinePieceImage(state.style(), CSSPropertyWebkitBorderImage, value, image);
684     state.style()->setBorderImage(image);
685 }
686
687 void StyleBuilderFunctions::applyValueCSSPropertyWebkitClipPath(StyleResolverState& state, CSSValue* value)
688 {
689     if (value->isPrimitiveValue()) {
690         CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
691         if (primitiveValue->getValueID() == CSSValueNone) {
692             state.style()->setClipPath(0);
693         } else if (primitiveValue->isShape()) {
694             state.style()->setClipPath(ShapeClipPathOperation::create(basicShapeForValue(state, primitiveValue->getShapeValue())));
695         } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_URI) {
696             String cssURLValue = primitiveValue->getStringValue();
697             KURL url = state.document().completeURL(cssURLValue);
698             // FIXME: It doesn't work with forward or external SVG references (see https://bugs.webkit.org/show_bug.cgi?id=90405)
699             state.style()->setClipPath(ReferenceClipPathOperation::create(cssURLValue, AtomicString(url.fragmentIdentifier())));
700         }
701     }
702 }
703
704 void StyleBuilderFunctions::applyInitialCSSPropertyFontVariantLigatures(StyleResolverState& state)
705 {
706     state.fontBuilder().setFontVariantLigaturesInitial();
707 }
708
709 void StyleBuilderFunctions::applyInheritCSSPropertyFontVariantLigatures(StyleResolverState& state)
710 {
711     state.fontBuilder().setFontVariantLigaturesInherit(state.parentFontDescription());
712 }
713
714 void StyleBuilderFunctions::applyValueCSSPropertyFontVariantLigatures(StyleResolverState& state, CSSValue* value)
715 {
716     state.fontBuilder().setFontVariantLigaturesValue(value);
717 }
718
719 void StyleBuilderFunctions::applyValueCSSPropertyInternalMarqueeIncrement(StyleResolverState& state, CSSValue* value)
720 {
721     if (!value->isPrimitiveValue())
722         return;
723
724     CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
725     if (primitiveValue->getValueID()) {
726         switch (primitiveValue->getValueID()) {
727         case CSSValueSmall:
728             state.style()->setMarqueeIncrement(Length(1, Fixed)); // 1px.
729             break;
730         case CSSValueNormal:
731             state.style()->setMarqueeIncrement(Length(6, Fixed)); // 6px. The WinIE default.
732             break;
733         case CSSValueLarge:
734             state.style()->setMarqueeIncrement(Length(36, Fixed)); // 36px.
735             break;
736         default:
737             break;
738         }
739     } else {
740         Length marqueeLength = primitiveValue->convertToLength<FixedConversion | PercentConversion>(state.cssToLengthConversionData());
741         state.style()->setMarqueeIncrement(marqueeLength);
742     }
743 }
744
745 void StyleBuilderFunctions::applyValueCSSPropertyInternalMarqueeSpeed(StyleResolverState& state, CSSValue* value)
746 {
747     if (!value->isPrimitiveValue())
748         return;
749
750     CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
751     if (CSSValueID valueID = primitiveValue->getValueID()) {
752         switch (valueID) {
753         case CSSValueSlow:
754             state.style()->setMarqueeSpeed(500); // 500 msec.
755             break;
756         case CSSValueNormal:
757             state.style()->setMarqueeSpeed(85); // 85msec. The WinIE default.
758             break;
759         case CSSValueFast:
760             state.style()->setMarqueeSpeed(10); // 10msec. Super fast.
761             break;
762         default:
763             break;
764         }
765     } else if (primitiveValue->isTime()) {
766         state.style()->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimitiveValue::Milliseconds>());
767     } else if (primitiveValue->isNumber()) { // For scrollamount support.
768         state.style()->setMarqueeSpeed(primitiveValue->getIntValue());
769     }
770 }
771
772 // FIXME: We should use the same system for this as the rest of the pseudo-shorthands (e.g. background-position)
773 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitPerspectiveOrigin(StyleResolverState& state)
774 {
775     applyInitialCSSPropertyWebkitPerspectiveOriginX(state);
776     applyInitialCSSPropertyWebkitPerspectiveOriginY(state);
777 }
778
779 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitPerspectiveOrigin(StyleResolverState& state)
780 {
781     applyInheritCSSPropertyWebkitPerspectiveOriginX(state);
782     applyInheritCSSPropertyWebkitPerspectiveOriginY(state);
783 }
784
785 void StyleBuilderFunctions::applyValueCSSPropertyWebkitPerspectiveOrigin(StyleResolverState&, CSSValue* value)
786 {
787     // This is expanded in the parser
788     ASSERT_NOT_REACHED();
789 }
790
791 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitTextEmphasisStyle(StyleResolverState& state)
792 {
793     state.style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill());
794     state.style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark());
795     state.style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCustomMark());
796 }
797
798 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitTextEmphasisStyle(StyleResolverState& state)
799 {
800     state.style()->setTextEmphasisFill(state.parentStyle()->textEmphasisFill());
801     state.style()->setTextEmphasisMark(state.parentStyle()->textEmphasisMark());
802     state.style()->setTextEmphasisCustomMark(state.parentStyle()->textEmphasisCustomMark());
803 }
804
805 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextEmphasisStyle(StyleResolverState& state, CSSValue* value)
806 {
807     if (value->isValueList()) {
808         CSSValueList* list = toCSSValueList(value);
809         ASSERT(list->length() == 2);
810         if (list->length() != 2)
811             return;
812         for (unsigned i = 0; i < 2; ++i) {
813             CSSValue* item = list->itemWithoutBoundsCheck(i);
814             if (!item->isPrimitiveValue())
815                 continue;
816
817             CSSPrimitiveValue* value = toCSSPrimitiveValue(item);
818             if (value->getValueID() == CSSValueFilled || value->getValueID() == CSSValueOpen)
819                 state.style()->setTextEmphasisFill(*value);
820             else
821                 state.style()->setTextEmphasisMark(*value);
822         }
823         state.style()->setTextEmphasisCustomMark(nullAtom);
824         return;
825     }
826
827     if (!value->isPrimitiveValue())
828         return;
829     CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
830
831     if (primitiveValue->isString()) {
832         state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
833         state.style()->setTextEmphasisMark(TextEmphasisMarkCustom);
834         state.style()->setTextEmphasisCustomMark(AtomicString(primitiveValue->getStringValue()));
835         return;
836     }
837
838     state.style()->setTextEmphasisCustomMark(nullAtom);
839
840     if (primitiveValue->getValueID() == CSSValueFilled || primitiveValue->getValueID() == CSSValueOpen) {
841         state.style()->setTextEmphasisFill(*primitiveValue);
842         state.style()->setTextEmphasisMark(TextEmphasisMarkAuto);
843     } else {
844         state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
845         state.style()->setTextEmphasisMark(*primitiveValue);
846     }
847 }
848
849 void StyleBuilderFunctions::applyValueCSSPropertyTextUnderlinePosition(StyleResolverState& state, CSSValue* value)
850 {
851     // This is true if value is 'auto' or 'alphabetic'.
852     if (value->isPrimitiveValue()) {
853         TextUnderlinePosition t = *toCSSPrimitiveValue(value);
854         state.style()->setTextUnderlinePosition(t);
855         return;
856     }
857
858     unsigned t = 0;
859     for (CSSValueListIterator i(value); i.hasMore(); i.advance()) {
860         CSSValue* item = i.value();
861         TextUnderlinePosition t2 = *toCSSPrimitiveValue(item);
862         t |= t2;
863     }
864     state.style()->setTextUnderlinePosition(static_cast<TextUnderlinePosition>(t));
865 }
866
867 // Everything below this line is from the old StyleResolver::applyProperty
868 // and eventually needs to move into new StyleBuilderFunctions calls intead.
869
870 #define HANDLE_INHERIT(prop, Prop) \
871 if (isInherit) { \
872     state.style()->set##Prop(state.parentStyle()->prop()); \
873     return; \
874 }
875
876 #define HANDLE_INHERIT_AND_INITIAL(prop, Prop) \
877 HANDLE_INHERIT(prop, Prop) \
878 if (isInitial) { \
879     state.style()->set##Prop(RenderStyle::initial##Prop()); \
880     return; \
881 }
882
883 #define HANDLE_SVG_INHERIT(prop, Prop) \
884 if (isInherit) { \
885     state.style()->accessSVGStyle()->set##Prop(state.parentStyle()->svgStyle()->prop()); \
886     return; \
887 }
888
889 #define HANDLE_SVG_INHERIT_AND_INITIAL(prop, Prop) \
890 HANDLE_SVG_INHERIT(prop, Prop) \
891 if (isInitial) { \
892     state.style()->accessSVGStyle()->set##Prop(SVGRenderStyle::initial##Prop()); \
893     return; \
894 }
895
896 static GridLength createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, const StyleResolverState& state)
897 {
898     if (primitiveValue->getValueID() == CSSValueMinContent)
899         return Length(MinContent);
900
901     if (primitiveValue->getValueID() == CSSValueMaxContent)
902         return Length(MaxContent);
903
904     // Fractional unit.
905     if (primitiveValue->isFlex())
906         return GridLength(primitiveValue->getDoubleValue());
907
908     return primitiveValue->convertToLength<FixedConversion | PercentConversion | AutoConversion>(state.cssToLengthConversionData());
909 }
910
911 static GridTrackSize createGridTrackSize(CSSValue* value, const StyleResolverState& state)
912 {
913     if (value->isPrimitiveValue())
914         return GridTrackSize(createGridTrackBreadth(toCSSPrimitiveValue(value), state));
915
916     CSSFunctionValue* minmaxFunction = toCSSFunctionValue(value);
917     CSSValueList* arguments = minmaxFunction->arguments();
918     ASSERT_WITH_SECURITY_IMPLICATION(arguments->length() == 2);
919     GridLength minTrackBreadth(createGridTrackBreadth(toCSSPrimitiveValue(arguments->itemWithoutBoundsCheck(0)), state));
920     GridLength maxTrackBreadth(createGridTrackBreadth(toCSSPrimitiveValue(arguments->itemWithoutBoundsCheck(1)), state));
921     return GridTrackSize(minTrackBreadth, maxTrackBreadth);
922 }
923
924 static bool createGridTrackList(CSSValue* value, Vector<GridTrackSize>& trackSizes, NamedGridLinesMap& namedGridLines, OrderedNamedGridLines& orderedNamedGridLines, const StyleResolverState& state)
925 {
926     // Handle 'none'.
927     if (value->isPrimitiveValue()) {
928         CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
929         return primitiveValue->getValueID() == CSSValueNone;
930     }
931
932     if (!value->isValueList())
933         return false;
934
935     size_t currentNamedGridLine = 0;
936     for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
937         CSSValue* currValue = i.value();
938         if (currValue->isGridLineNamesValue()) {
939             CSSGridLineNamesValue* lineNamesValue = toCSSGridLineNamesValue(currValue);
940             for (CSSValueListIterator j = lineNamesValue; j.hasMore(); j.advance()) {
941                 String namedGridLine = toCSSPrimitiveValue(j.value())->getStringValue();
942                 NamedGridLinesMap::AddResult result = namedGridLines.add(namedGridLine, Vector<size_t>());
943                 result.storedValue->value.append(currentNamedGridLine);
944                 OrderedNamedGridLines::AddResult orderedInsertionResult = orderedNamedGridLines.add(currentNamedGridLine, Vector<String>());
945                 orderedInsertionResult.storedValue->value.append(namedGridLine);
946             }
947             continue;
948         }
949
950         ++currentNamedGridLine;
951         trackSizes.append(createGridTrackSize(currValue, state));
952     }
953
954     // The parser should have rejected any <track-list> without any <track-size> as
955     // this is not conformant to the syntax.
956     ASSERT(!trackSizes.isEmpty());
957     return true;
958 }
959
960 static bool createGridPosition(CSSValue* value, GridPosition& position)
961 {
962     // We accept the specification's grammar:
963     // 'auto' | [ <integer> || <string> ] | [ span && [ <integer> || string ] ] | <ident>
964
965     if (value->isPrimitiveValue()) {
966         CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
967         // We translate <ident> to <string> during parsing as it
968         // makes handling it more simple.
969         if (primitiveValue->isString()) {
970             position.setNamedGridArea(primitiveValue->getStringValue());
971             return true;
972         }
973
974         ASSERT(primitiveValue->getValueID() == CSSValueAuto);
975         return true;
976     }
977
978     CSSValueList* values = toCSSValueList(value);
979     ASSERT(values->length());
980
981     bool isSpanPosition = false;
982     // The specification makes the <integer> optional, in which case it default to '1'.
983     int gridLineNumber = 1;
984     String gridLineName;
985
986     CSSValueListIterator it = values;
987     CSSPrimitiveValue* currentValue = toCSSPrimitiveValue(it.value());
988     if (currentValue->getValueID() == CSSValueSpan) {
989         isSpanPosition = true;
990         it.advance();
991         currentValue = it.hasMore() ? toCSSPrimitiveValue(it.value()) : 0;
992     }
993
994     if (currentValue && currentValue->isNumber()) {
995         gridLineNumber = currentValue->getIntValue();
996         it.advance();
997         currentValue = it.hasMore() ? toCSSPrimitiveValue(it.value()) : 0;
998     }
999
1000     if (currentValue && currentValue->isString()) {
1001         gridLineName = currentValue->getStringValue();
1002         it.advance();
1003     }
1004
1005     ASSERT(!it.hasMore());
1006     if (isSpanPosition)
1007         position.setSpanPosition(gridLineNumber, gridLineName);
1008     else
1009         position.setExplicitPosition(gridLineNumber, gridLineName);
1010
1011     return true;
1012 }
1013
1014 static bool degreeToGlyphOrientation(CSSPrimitiveValue* primitiveValue, EGlyphOrientation& orientation)
1015 {
1016     if (!primitiveValue)
1017         return false;
1018
1019     if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_DEG)
1020         return false;
1021
1022     float angle = fabsf(fmodf(primitiveValue->getFloatValue(), 360.0f));
1023
1024     if (angle <= 45.0f || angle > 315.0f) {
1025         orientation = GO_0DEG;
1026         return true;
1027     }
1028     if (angle > 45.0f && angle <= 135.0f) {
1029         orientation = GO_90DEG;
1030         return true;
1031     }
1032     if (angle > 135.0f && angle <= 225.0f) {
1033         orientation = GO_180DEG;
1034         return true;
1035     }
1036     orientation = GO_270DEG;
1037     return true;
1038 }
1039
1040 static Color colorFromSVGColorCSSValue(SVGColor* svgColor, const Color& fgColor)
1041 {
1042     Color color;
1043     if (svgColor->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR)
1044         color = fgColor;
1045     else
1046         color = svgColor->color();
1047     return color;
1048 }
1049
1050 static EPaintOrder paintOrderFlattened(CSSValue* cssPaintOrder)
1051 {
1052     if (cssPaintOrder->isValueList()) {
1053         int paintOrder = 0;
1054         CSSValueListInspector iter(cssPaintOrder);
1055         for (size_t i = 0; i < iter.length(); i++) {
1056             CSSPrimitiveValue* value = toCSSPrimitiveValue(iter.item(i));
1057
1058             EPaintOrderType paintOrderType = PT_NONE;
1059             switch (value->getValueID()) {
1060             case CSSValueFill:
1061                 paintOrderType = PT_FILL;
1062                 break;
1063             case CSSValueStroke:
1064                 paintOrderType = PT_STROKE;
1065                 break;
1066             case CSSValueMarkers:
1067                 paintOrderType = PT_MARKERS;
1068                 break;
1069             default:
1070                 ASSERT_NOT_REACHED();
1071                 break;
1072             }
1073
1074             paintOrder |= (paintOrderType << kPaintOrderBitwidth*i);
1075         }
1076         return (EPaintOrder)paintOrder;
1077     }
1078
1079     return PO_NORMAL;
1080 }
1081
1082 static inline bool isValidVisitedLinkProperty(CSSPropertyID id)
1083 {
1084     switch (id) {
1085     case CSSPropertyBackgroundColor:
1086     case CSSPropertyBorderLeftColor:
1087     case CSSPropertyBorderRightColor:
1088     case CSSPropertyBorderTopColor:
1089     case CSSPropertyBorderBottomColor:
1090     case CSSPropertyColor:
1091     case CSSPropertyFill:
1092     case CSSPropertyOutlineColor:
1093     case CSSPropertyStroke:
1094     case CSSPropertyTextDecorationColor:
1095     case CSSPropertyWebkitColumnRuleColor:
1096     case CSSPropertyWebkitTextEmphasisColor:
1097     case CSSPropertyWebkitTextFillColor:
1098     case CSSPropertyWebkitTextStrokeColor:
1099         return true;
1100     default:
1101         break;
1102     }
1103
1104     return false;
1105 }
1106
1107
1108 void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CSSValue* value)
1109 {
1110     ASSERT_WITH_MESSAGE(!isExpandedShorthand(id), "Shorthand property id = %d wasn't expanded at parsing time", id);
1111
1112     bool isInherit = state.parentNode() && value->isInheritedValue();
1113     bool isInitial = value->isInitialValue() || (!state.parentNode() && value->isInheritedValue());
1114
1115     ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit
1116     ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInherit -> (state.parentNode() && state.parentStyle())
1117
1118     if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLinkStyle() || !isValidVisitedLinkProperty(id))) {
1119         // Limit the properties that can be applied to only the ones honored by :visited.
1120         return;
1121     }
1122
1123     CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimitiveValue(value) : 0;
1124     if (primitiveValue && primitiveValue->getValueID() == CSSValueCurrentcolor)
1125         state.style()->setHasCurrentColor();
1126
1127     if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id))
1128         state.parentStyle()->setHasExplicitlyInheritedProperties();
1129
1130     if (StyleBuilder::applyProperty(id, state, value, isInitial, isInherit))
1131         return;
1132
1133     // Fall back to the old switch statement, which is now in StyleBuilderCustom.cpp
1134     StyleBuilder::oldApplyProperty(id, state, value, isInitial, isInherit);
1135 }
1136
1137
1138 void StyleBuilder::oldApplyProperty(CSSPropertyID id, StyleResolverState& state, CSSValue* value, bool isInitial, bool isInherit)
1139 {
1140     CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimitiveValue(value) : 0;
1141
1142     // What follows is a list that maps the CSS properties into their corresponding front-end
1143     // RenderStyle values.
1144     switch (id) {
1145     case CSSPropertyContent:
1146         // list of string, uri, counter, attr, i
1147         {
1148             // FIXME: In CSS3, it will be possible to inherit content. In CSS2 it is not. This
1149             // note is a reminder that eventually "inherit" needs to be supported.
1150
1151             if (isInitial) {
1152                 state.style()->clearContent();
1153                 return;
1154             }
1155
1156             if (!value->isValueList())
1157                 return;
1158
1159             bool didSet = false;
1160             for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
1161                 CSSValue* item = i.value();
1162                 if (item->isImageGeneratorValue()) {
1163                     if (item->isGradientValue())
1164                         state.style()->setContent(StyleGeneratedImage::create(toCSSGradientValue(item)->gradientWithStylesResolved(state.document().textLinkColors(), state.style()->color()).get()), didSet);
1165                     else
1166                         state.style()->setContent(StyleGeneratedImage::create(toCSSImageGeneratorValue(item)), didSet);
1167                     didSet = true;
1168                 } else if (item->isImageSetValue()) {
1169                     state.style()->setContent(state.elementStyleResources().setOrPendingFromValue(CSSPropertyContent, toCSSImageSetValue(item)), didSet);
1170                     didSet = true;
1171                 }
1172
1173                 if (item->isImageValue()) {
1174                     state.style()->setContent(state.elementStyleResources().cachedOrPendingFromValue(CSSPropertyContent, toCSSImageValue(item)), didSet);
1175                     didSet = true;
1176                     continue;
1177                 }
1178
1179                 if (!item->isPrimitiveValue())
1180                     continue;
1181
1182                 CSSPrimitiveValue* contentValue = toCSSPrimitiveValue(item);
1183
1184                 if (contentValue->isString()) {
1185                     state.style()->setContent(contentValue->getStringValue().impl(), didSet);
1186                     didSet = true;
1187                 } else if (contentValue->isAttr()) {
1188                     // FIXME: Can a namespace be specified for an attr(foo)?
1189                     if (state.style()->styleType() == NOPSEUDO)
1190                         state.style()->setUnique();
1191                     else
1192                         state.parentStyle()->setUnique();
1193                     QualifiedName attr(nullAtom, AtomicString(contentValue->getStringValue()), nullAtom);
1194                     const AtomicString& value = state.element()->getAttribute(attr);
1195                     state.style()->setContent(value.isNull() ? emptyString() : value.string(), didSet);
1196                     didSet = true;
1197                     // register the fact that the attribute value affects the style
1198                     state.contentAttrValues().append(attr.localName());
1199                 } else if (contentValue->isCounter()) {
1200                     Counter* counterValue = contentValue->getCounterValue();
1201                     EListStyleType listStyleType = NoneListStyle;
1202                     CSSValueID listStyleIdent = counterValue->listStyleIdent();
1203                     if (listStyleIdent != CSSValueNone)
1204                         listStyleType = static_cast<EListStyleType>(listStyleIdent - CSSValueDisc);
1205                     OwnPtr<CounterContent> counter = adoptPtr(new CounterContent(AtomicString(counterValue->identifier()), listStyleType, AtomicString(counterValue->separator())));
1206                     state.style()->setContent(counter.release(), didSet);
1207                     didSet = true;
1208                 } else {
1209                     switch (contentValue->getValueID()) {
1210                     case CSSValueOpenQuote:
1211                         state.style()->setContent(OPEN_QUOTE, didSet);
1212                         didSet = true;
1213                         break;
1214                     case CSSValueCloseQuote:
1215                         state.style()->setContent(CLOSE_QUOTE, didSet);
1216                         didSet = true;
1217                         break;
1218                     case CSSValueNoOpenQuote:
1219                         state.style()->setContent(NO_OPEN_QUOTE, didSet);
1220                         didSet = true;
1221                         break;
1222                     case CSSValueNoCloseQuote:
1223                         state.style()->setContent(NO_CLOSE_QUOTE, didSet);
1224                         didSet = true;
1225                         break;
1226                     default:
1227                         // normal and none do not have any effect.
1228                         { }
1229                     }
1230                 }
1231             }
1232             if (!didSet)
1233                 state.style()->clearContent();
1234             return;
1235         }
1236     case CSSPropertyQuotes:
1237         HANDLE_INHERIT_AND_INITIAL(quotes, Quotes);
1238         if (value->isValueList()) {
1239             CSSValueList* list = toCSSValueList(value);
1240             RefPtr<QuotesData> quotes = QuotesData::create();
1241             for (size_t i = 0; i < list->length(); i += 2) {
1242                 CSSValue* first = list->itemWithoutBoundsCheck(i);
1243                 // item() returns null if out of bounds so this is safe.
1244                 CSSValue* second = list->item(i + 1);
1245                 if (!second)
1246                     continue;
1247                 String startQuote = toCSSPrimitiveValue(first)->getStringValue();
1248                 String endQuote = toCSSPrimitiveValue(second)->getStringValue();
1249                 quotes->addPair(std::make_pair(startQuote, endQuote));
1250             }
1251             state.style()->setQuotes(quotes);
1252             return;
1253         }
1254         if (primitiveValue) {
1255             if (primitiveValue->getValueID() == CSSValueNone)
1256                 state.style()->setQuotes(QuotesData::create());
1257         }
1258         return;
1259     // Shorthand properties.
1260     case CSSPropertyFont:
1261         // Only System Font identifiers should come through this method
1262         // all other values should have been handled when the shorthand
1263         // was expanded by the parser.
1264         // FIXME: System Font identifiers should not hijack this
1265         // short-hand CSSProperty like this.
1266         ASSERT(!isInitial);
1267         ASSERT(!isInherit);
1268         ASSERT(primitiveValue);
1269         state.style()->setLineHeight(RenderStyle::initialLineHeight());
1270         state.setLineHeightValue(0);
1271         state.fontBuilder().fromSystemFont(primitiveValue->getValueID(), state.style()->effectiveZoom());
1272         return;
1273     case CSSPropertyAnimation:
1274     case CSSPropertyBackground:
1275     case CSSPropertyBackgroundPosition:
1276     case CSSPropertyBackgroundRepeat:
1277     case CSSPropertyBorder:
1278     case CSSPropertyBorderBottom:
1279     case CSSPropertyBorderColor:
1280     case CSSPropertyBorderImage:
1281     case CSSPropertyBorderLeft:
1282     case CSSPropertyBorderRadius:
1283     case CSSPropertyBorderRight:
1284     case CSSPropertyBorderSpacing:
1285     case CSSPropertyBorderStyle:
1286     case CSSPropertyBorderTop:
1287     case CSSPropertyBorderWidth:
1288     case CSSPropertyListStyle:
1289     case CSSPropertyMargin:
1290     case CSSPropertyObjectPosition:
1291     case CSSPropertyOutline:
1292     case CSSPropertyOverflow:
1293     case CSSPropertyPadding:
1294     case CSSPropertyTransition:
1295     case CSSPropertyWebkitAnimation:
1296     case CSSPropertyWebkitBorderAfter:
1297     case CSSPropertyWebkitBorderBefore:
1298     case CSSPropertyWebkitBorderEnd:
1299     case CSSPropertyWebkitBorderStart:
1300     case CSSPropertyWebkitBorderRadius:
1301     case CSSPropertyWebkitColumns:
1302     case CSSPropertyWebkitColumnRule:
1303     case CSSPropertyFlex:
1304     case CSSPropertyFlexFlow:
1305     case CSSPropertyGridColumn:
1306     case CSSPropertyGridRow:
1307     case CSSPropertyGridArea:
1308     case CSSPropertyWebkitMarginCollapse:
1309     case CSSPropertyWebkitMask:
1310     case CSSPropertyWebkitMaskPosition:
1311     case CSSPropertyWebkitMaskRepeat:
1312     case CSSPropertyWebkitTextEmphasis:
1313     case CSSPropertyWebkitTextStroke:
1314     case CSSPropertyWebkitTransition:
1315     case CSSPropertyWebkitTransformOrigin:
1316         ASSERT(isExpandedShorthand(id));
1317         ASSERT_NOT_REACHED();
1318         break;
1319
1320     // CSS3 Properties
1321     case CSSPropertyWebkitBoxReflect: {
1322         HANDLE_INHERIT_AND_INITIAL(boxReflect, BoxReflect)
1323         if (primitiveValue) {
1324             state.style()->setBoxReflect(RenderStyle::initialBoxReflect());
1325             return;
1326         }
1327
1328         if (!value->isReflectValue())
1329             return;
1330
1331         CSSReflectValue* reflectValue = toCSSReflectValue(value);
1332         RefPtr<StyleReflection> reflection = StyleReflection::create();
1333         reflection->setDirection(*reflectValue->direction());
1334         if (reflectValue->offset())
1335             reflection->setOffset(reflectValue->offset()->convertToLength<FixedConversion | PercentConversion>(state.cssToLengthConversionData()));
1336         NinePieceImage mask;
1337         mask.setMaskDefaults();
1338         state.styleMap().mapNinePieceImage(state.style(), id, reflectValue->mask(), mask);
1339         reflection->setMask(mask);
1340
1341         state.style()->setBoxReflect(reflection.release());
1342         return;
1343     }
1344     case CSSPropertySrc: // Only used in @font-face rules.
1345         return;
1346     case CSSPropertyUnicodeRange: // Only used in @font-face rules.
1347         return;
1348     case CSSPropertyWebkitLocale: {
1349         HANDLE_INHERIT_AND_INITIAL(locale, Locale);
1350         if (!primitiveValue)
1351             return;
1352         if (primitiveValue->getValueID() == CSSValueAuto)
1353             state.style()->setLocale(nullAtom);
1354         else
1355             state.style()->setLocale(AtomicString(primitiveValue->getStringValue()));
1356         state.fontBuilder().setScript(state.style()->locale());
1357         return;
1358     }
1359     case CSSPropertyWebkitAppRegion: {
1360         if (!primitiveValue || !primitiveValue->getValueID())
1361             return;
1362         state.style()->setDraggableRegionMode(primitiveValue->getValueID() == CSSValueDrag ? DraggableRegionDrag : DraggableRegionNoDrag);
1363         state.document().setHasAnnotatedRegions(true);
1364         return;
1365     }
1366     case CSSPropertyWebkitTextStrokeWidth: {
1367         HANDLE_INHERIT_AND_INITIAL(textStrokeWidth, TextStrokeWidth)
1368         float width = 0;
1369         switch (primitiveValue->getValueID()) {
1370         case CSSValueThin:
1371         case CSSValueMedium:
1372         case CSSValueThick: {
1373             double result = 1.0 / 48;
1374             if (primitiveValue->getValueID() == CSSValueMedium)
1375                 result *= 3;
1376             else if (primitiveValue->getValueID() == CSSValueThick)
1377                 result *= 5;
1378             width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLength<float>(state.cssToLengthConversionData());
1379             break;
1380         }
1381         default:
1382             width = primitiveValue->computeLength<float>(state.cssToLengthConversionData());
1383             break;
1384         }
1385         state.style()->setTextStrokeWidth(width);
1386         return;
1387     }
1388     case CSSPropertyWebkitTransform: {
1389         HANDLE_INHERIT_AND_INITIAL(transform, Transform);
1390         TransformOperations operations;
1391         TransformBuilder::createTransformOperations(value, state.cssToLengthConversionData(), operations);
1392         state.style()->setTransform(operations);
1393         return;
1394     }
1395     case CSSPropertyWebkitPerspective: {
1396         HANDLE_INHERIT_AND_INITIAL(perspective, Perspective)
1397
1398         if (!primitiveValue)
1399             return;
1400
1401         if (primitiveValue->getValueID() == CSSValueNone) {
1402             state.style()->setPerspective(0);
1403             return;
1404         }
1405
1406         float perspectiveValue;
1407         if (primitiveValue->isLength()) {
1408             perspectiveValue = primitiveValue->computeLength<float>(state.cssToLengthConversionData());
1409         } else if (primitiveValue->isNumber()) {
1410             // For backward compatibility, treat valueless numbers as px.
1411             perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(state.cssToLengthConversionData());
1412         } else {
1413             return;
1414         }
1415
1416         if (perspectiveValue >= 0.0f)
1417             state.style()->setPerspective(perspectiveValue);
1418         return;
1419     }
1420     case CSSPropertyWebkitTapHighlightColor: {
1421         HANDLE_INHERIT_AND_INITIAL(tapHighlightColor, TapHighlightColor);
1422         if (!primitiveValue)
1423             break;
1424
1425         Color col = state.document().textLinkColors().colorFromPrimitiveValue(primitiveValue, state.style()->color());
1426         state.style()->setTapHighlightColor(col);
1427         return;
1428     }
1429     case CSSPropertyInternalCallback: {
1430         if (isInherit || isInitial)
1431             return;
1432         if (primitiveValue && primitiveValue->getValueID() == CSSValueInternalPresence) {
1433             state.style()->addCallbackSelector(state.currentRule()->selectorList().selectorsText());
1434             return;
1435         }
1436         break;
1437     }
1438     case CSSPropertyInvalid:
1439         return;
1440     // Directional properties are resolved by resolveDirectionAwareProperty() before the switch.
1441     case CSSPropertyWebkitBorderEndColor:
1442     case CSSPropertyWebkitBorderEndStyle:
1443     case CSSPropertyWebkitBorderEndWidth:
1444     case CSSPropertyWebkitBorderStartColor:
1445     case CSSPropertyWebkitBorderStartStyle:
1446     case CSSPropertyWebkitBorderStartWidth:
1447     case CSSPropertyWebkitBorderBeforeColor:
1448     case CSSPropertyWebkitBorderBeforeStyle:
1449     case CSSPropertyWebkitBorderBeforeWidth:
1450     case CSSPropertyWebkitBorderAfterColor:
1451     case CSSPropertyWebkitBorderAfterStyle:
1452     case CSSPropertyWebkitBorderAfterWidth:
1453     case CSSPropertyWebkitMarginEnd:
1454     case CSSPropertyWebkitMarginStart:
1455     case CSSPropertyWebkitMarginBefore:
1456     case CSSPropertyWebkitMarginAfter:
1457     case CSSPropertyWebkitMarginBeforeCollapse:
1458     case CSSPropertyWebkitMarginTopCollapse:
1459     case CSSPropertyWebkitMarginAfterCollapse:
1460     case CSSPropertyWebkitMarginBottomCollapse:
1461     case CSSPropertyWebkitPaddingEnd:
1462     case CSSPropertyWebkitPaddingStart:
1463     case CSSPropertyWebkitPaddingBefore:
1464     case CSSPropertyWebkitPaddingAfter:
1465     case CSSPropertyWebkitLogicalWidth:
1466     case CSSPropertyWebkitLogicalHeight:
1467     case CSSPropertyWebkitMinLogicalWidth:
1468     case CSSPropertyWebkitMinLogicalHeight:
1469     case CSSPropertyWebkitMaxLogicalWidth:
1470     case CSSPropertyWebkitMaxLogicalHeight:
1471     {
1472         CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, state.style()->direction(), state.style()->writingMode());
1473         ASSERT(newId != id);
1474         return applyProperty(newId, state, value);
1475     }
1476     case CSSPropertyFontStretch:
1477     case CSSPropertyPage:
1478     case CSSPropertyTextLineThroughColor:
1479     case CSSPropertyTextLineThroughMode:
1480     case CSSPropertyTextLineThroughStyle:
1481     case CSSPropertyTextLineThroughWidth:
1482     case CSSPropertyTextOverlineColor:
1483     case CSSPropertyTextOverlineMode:
1484     case CSSPropertyTextOverlineStyle:
1485     case CSSPropertyTextOverlineWidth:
1486     case CSSPropertyTextUnderlineColor:
1487     case CSSPropertyTextUnderlineMode:
1488     case CSSPropertyTextUnderlineStyle:
1489     case CSSPropertyTextUnderlineWidth:
1490     case CSSPropertyWebkitFontSizeDelta:
1491     case CSSPropertyWebkitTextDecorationsInEffect:
1492         return;
1493
1494     // CSS Text Layout Module Level 3: Vertical writing support
1495     case CSSPropertyWebkitWritingMode: {
1496         HANDLE_INHERIT_AND_INITIAL(writingMode, WritingMode);
1497
1498         if (primitiveValue)
1499             state.setWritingMode(*primitiveValue);
1500
1501         // FIXME: It is not ok to modify document state while applying style.
1502         if (state.element() && state.element() == state.document().documentElement())
1503             state.document().setWritingModeSetOnDocumentElement(true);
1504         return;
1505     }
1506
1507     case CSSPropertyWebkitTextOrientation: {
1508         HANDLE_INHERIT_AND_INITIAL(textOrientation, TextOrientation);
1509
1510         if (primitiveValue)
1511             state.setTextOrientation(*primitiveValue);
1512
1513         return;
1514     }
1515
1516     case CSSPropertyWebkitLineBoxContain: {
1517         HANDLE_INHERIT_AND_INITIAL(lineBoxContain, LineBoxContain)
1518         if (primitiveValue && primitiveValue->getValueID() == CSSValueNone) {
1519             state.style()->setLineBoxContain(LineBoxContainNone);
1520             return;
1521         }
1522
1523         if (!value->isLineBoxContainValue())
1524             return;
1525
1526         state.style()->setLineBoxContain(toCSSLineBoxContainValue(value)->value());
1527         return;
1528     }
1529
1530     // CSS Fonts Module Level 3
1531     case CSSPropertyWebkitFontFeatureSettings: {
1532         if (primitiveValue && primitiveValue->getValueID() == CSSValueNormal) {
1533             state.fontBuilder().setFeatureSettingsNormal();
1534             return;
1535         }
1536
1537         if (!value->isValueList())
1538             return;
1539
1540         state.fontBuilder().setFeatureSettingsValue(value);
1541         return;
1542     }
1543
1544     case CSSPropertyWebkitFilter: {
1545         HANDLE_INHERIT_AND_INITIAL(filter, Filter);
1546         FilterOperations operations;
1547         if (FilterOperationResolver::createFilterOperations(value, state.cssToLengthConversionData(), operations, state))
1548             state.style()->setFilter(operations);
1549         return;
1550     }
1551     case CSSPropertyGridAutoColumns: {
1552         HANDLE_INHERIT_AND_INITIAL(gridAutoColumns, GridAutoColumns);
1553         state.style()->setGridAutoColumns(createGridTrackSize(value, state));
1554         return;
1555     }
1556     case CSSPropertyGridAutoRows: {
1557         HANDLE_INHERIT_AND_INITIAL(gridAutoRows, GridAutoRows);
1558         state.style()->setGridAutoRows(createGridTrackSize(value, state));
1559         return;
1560     }
1561     case CSSPropertyGridTemplateColumns: {
1562         if (isInherit) {
1563             state.style()->setGridTemplateColumns(state.parentStyle()->gridTemplateColumns());
1564             state.style()->setNamedGridColumnLines(state.parentStyle()->namedGridColumnLines());
1565             state.style()->setOrderedNamedGridColumnLines(state.parentStyle()->orderedNamedGridColumnLines());
1566             return;
1567         }
1568         if (isInitial) {
1569             state.style()->setGridTemplateColumns(RenderStyle::initialGridTemplateColumns());
1570             state.style()->setNamedGridColumnLines(RenderStyle::initialNamedGridColumnLines());
1571             state.style()->setOrderedNamedGridColumnLines(RenderStyle::initialOrderedNamedGridColumnLines());
1572             return;
1573         }
1574
1575         Vector<GridTrackSize> trackSizes;
1576         NamedGridLinesMap namedGridLines;
1577         OrderedNamedGridLines orderedNamedGridLines;
1578         if (!createGridTrackList(value, trackSizes, namedGridLines, orderedNamedGridLines, state))
1579             return;
1580         state.style()->setGridTemplateColumns(trackSizes);
1581         state.style()->setNamedGridColumnLines(namedGridLines);
1582         state.style()->setOrderedNamedGridColumnLines(orderedNamedGridLines);
1583         return;
1584     }
1585     case CSSPropertyGridTemplateRows: {
1586         if (isInherit) {
1587             state.style()->setGridTemplateRows(state.parentStyle()->gridTemplateRows());
1588             state.style()->setNamedGridRowLines(state.parentStyle()->namedGridRowLines());
1589             state.style()->setOrderedNamedGridRowLines(state.parentStyle()->orderedNamedGridRowLines());
1590             return;
1591         }
1592         if (isInitial) {
1593             state.style()->setGridTemplateRows(RenderStyle::initialGridTemplateRows());
1594             state.style()->setNamedGridRowLines(RenderStyle::initialNamedGridRowLines());
1595             state.style()->setOrderedNamedGridRowLines(RenderStyle::initialOrderedNamedGridRowLines());
1596             return;
1597         }
1598
1599         Vector<GridTrackSize> trackSizes;
1600         NamedGridLinesMap namedGridLines;
1601         OrderedNamedGridLines orderedNamedGridLines;
1602         if (!createGridTrackList(value, trackSizes, namedGridLines, orderedNamedGridLines, state))
1603             return;
1604         state.style()->setGridTemplateRows(trackSizes);
1605         state.style()->setNamedGridRowLines(namedGridLines);
1606         state.style()->setOrderedNamedGridRowLines(orderedNamedGridLines);
1607         return;
1608     }
1609
1610     case CSSPropertyGridColumnStart: {
1611         HANDLE_INHERIT_AND_INITIAL(gridColumnStart, GridColumnStart);
1612         GridPosition startPosition;
1613         if (!createGridPosition(value, startPosition))
1614             return;
1615         state.style()->setGridColumnStart(startPosition);
1616         return;
1617     }
1618     case CSSPropertyGridColumnEnd: {
1619         HANDLE_INHERIT_AND_INITIAL(gridColumnEnd, GridColumnEnd);
1620         GridPosition endPosition;
1621         if (!createGridPosition(value, endPosition))
1622             return;
1623         state.style()->setGridColumnEnd(endPosition);
1624         return;
1625     }
1626
1627     case CSSPropertyGridRowStart: {
1628         HANDLE_INHERIT_AND_INITIAL(gridRowStart, GridRowStart);
1629         GridPosition beforePosition;
1630         if (!createGridPosition(value, beforePosition))
1631             return;
1632         state.style()->setGridRowStart(beforePosition);
1633         return;
1634     }
1635     case CSSPropertyGridRowEnd: {
1636         HANDLE_INHERIT_AND_INITIAL(gridRowEnd, GridRowEnd);
1637         GridPosition afterPosition;
1638         if (!createGridPosition(value, afterPosition))
1639             return;
1640         state.style()->setGridRowEnd(afterPosition);
1641         return;
1642     }
1643
1644     case CSSPropertyGridTemplateAreas: {
1645         if (isInherit) {
1646             state.style()->setNamedGridArea(state.parentStyle()->namedGridArea());
1647             state.style()->setNamedGridAreaRowCount(state.parentStyle()->namedGridAreaRowCount());
1648             state.style()->setNamedGridAreaColumnCount(state.parentStyle()->namedGridAreaColumnCount());
1649             return;
1650         }
1651         if (isInitial) {
1652             state.style()->setNamedGridArea(RenderStyle::initialNamedGridArea());
1653             state.style()->setNamedGridAreaRowCount(RenderStyle::initialNamedGridAreaCount());
1654             state.style()->setNamedGridAreaColumnCount(RenderStyle::initialNamedGridAreaCount());
1655             return;
1656         }
1657
1658         if (value->isPrimitiveValue()) {
1659             ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone);
1660             return;
1661         }
1662
1663         CSSGridTemplateAreasValue* gridTemplateAreasValue = toCSSGridTemplateAreasValue(value);
1664         state.style()->setNamedGridArea(gridTemplateAreasValue->gridAreaMap());
1665         state.style()->setNamedGridAreaRowCount(gridTemplateAreasValue->rowCount());
1666         state.style()->setNamedGridAreaColumnCount(gridTemplateAreasValue->columnCount());
1667         return;
1668     }
1669
1670     case CSSPropertyJustifySelf: {
1671         HANDLE_INHERIT_AND_INITIAL(justifySelf, JustifySelf);
1672         CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1673         if (Pair* pairValue = primitiveValue->getPairValue()) {
1674             state.style()->setJustifySelf(*pairValue->first());
1675             state.style()->setJustifySelfOverflowAlignment(*pairValue->second());
1676         } else {
1677             state.style()->setJustifySelf(*primitiveValue);
1678         }
1679         return;
1680     }
1681
1682     case CSSPropertyAlignSelf: {
1683         HANDLE_INHERIT_AND_INITIAL(alignSelf, AlignSelf);
1684         CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1685         if (Pair* pairValue = primitiveValue->getPairValue()) {
1686             state.style()->setAlignSelf(*pairValue->first());
1687             state.style()->setAlignSelfOverflowAlignment(*pairValue->second());
1688         } else {
1689             state.style()->setAlignSelf(*primitiveValue);
1690         }
1691         return;
1692     }
1693
1694     case CSSPropertyAlignItems: {
1695         HANDLE_INHERIT_AND_INITIAL(alignItems, AlignItems);
1696         CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1697         if (Pair* pairValue = primitiveValue->getPairValue()) {
1698             state.style()->setAlignItems(*pairValue->first());
1699             state.style()->setAlignItemsOverflowAlignment(*pairValue->second());
1700         } else {
1701             state.style()->setAlignItems(*primitiveValue);
1702         }
1703         return;
1704     }
1705
1706     // These properties are aliased and we already applied the property on the prefixed version.
1707     case CSSPropertyAnimationDelay:
1708     case CSSPropertyAnimationDirection:
1709     case CSSPropertyAnimationDuration:
1710     case CSSPropertyAnimationFillMode:
1711     case CSSPropertyAnimationIterationCount:
1712     case CSSPropertyAnimationName:
1713     case CSSPropertyAnimationPlayState:
1714     case CSSPropertyAnimationTimingFunction:
1715     case CSSPropertyTransitionDelay:
1716     case CSSPropertyTransitionDuration:
1717     case CSSPropertyTransitionProperty:
1718     case CSSPropertyTransitionTimingFunction:
1719         return;
1720     // These properties are implemented in StyleBuilder::applyProperty.
1721     case CSSPropertyBackgroundAttachment:
1722     case CSSPropertyBackgroundBlendMode:
1723     case CSSPropertyBackgroundClip:
1724     case CSSPropertyBackgroundColor:
1725     case CSSPropertyBackgroundImage:
1726     case CSSPropertyBackgroundOrigin:
1727     case CSSPropertyBackgroundPositionX:
1728     case CSSPropertyBackgroundPositionY:
1729     case CSSPropertyBackgroundRepeatX:
1730     case CSSPropertyBackgroundRepeatY:
1731     case CSSPropertyBackgroundSize:
1732     case CSSPropertyBorderBottomColor:
1733     case CSSPropertyBorderBottomLeftRadius:
1734     case CSSPropertyBorderBottomRightRadius:
1735     case CSSPropertyBorderBottomStyle:
1736     case CSSPropertyBorderBottomWidth:
1737     case CSSPropertyBorderCollapse:
1738     case CSSPropertyBorderImageOutset:
1739     case CSSPropertyBorderImageRepeat:
1740     case CSSPropertyBorderImageSlice:
1741     case CSSPropertyBorderImageSource:
1742     case CSSPropertyBorderImageWidth:
1743     case CSSPropertyBorderLeftColor:
1744     case CSSPropertyBorderLeftStyle:
1745     case CSSPropertyBorderLeftWidth:
1746     case CSSPropertyBorderRightColor:
1747     case CSSPropertyBorderRightStyle:
1748     case CSSPropertyBorderRightWidth:
1749     case CSSPropertyBorderTopColor:
1750     case CSSPropertyBorderTopLeftRadius:
1751     case CSSPropertyBorderTopRightRadius:
1752     case CSSPropertyBorderTopStyle:
1753     case CSSPropertyBorderTopWidth:
1754     case CSSPropertyBottom:
1755     case CSSPropertyBoxShadow:
1756     case CSSPropertyBoxSizing:
1757     case CSSPropertyCaptionSide:
1758     case CSSPropertyClear:
1759     case CSSPropertyClip:
1760     case CSSPropertyColor:
1761     case CSSPropertyCounterIncrement:
1762     case CSSPropertyCounterReset:
1763     case CSSPropertyCursor:
1764     case CSSPropertyDirection:
1765     case CSSPropertyDisplay:
1766     case CSSPropertyEmptyCells:
1767     case CSSPropertyFloat:
1768     case CSSPropertyFontKerning:
1769     case CSSPropertyFontSize:
1770     case CSSPropertyFontStyle:
1771     case CSSPropertyFontVariant:
1772     case CSSPropertyFontVariantLigatures:
1773     case CSSPropertyFontWeight:
1774     case CSSPropertyHeight:
1775     case CSSPropertyImageRendering:
1776     case CSSPropertyIsolation:
1777     case CSSPropertyLeft:
1778     case CSSPropertyLetterSpacing:
1779     case CSSPropertyLineHeight:
1780     case CSSPropertyListStyleImage:
1781     case CSSPropertyListStylePosition:
1782     case CSSPropertyListStyleType:
1783     case CSSPropertyMarginBottom:
1784     case CSSPropertyMarginLeft:
1785     case CSSPropertyMarginRight:
1786     case CSSPropertyMarginTop:
1787     case CSSPropertyMaxHeight:
1788     case CSSPropertyMaxWidth:
1789     case CSSPropertyMinHeight:
1790     case CSSPropertyMixBlendMode:
1791     case CSSPropertyMinWidth:
1792     case CSSPropertyObjectFit:
1793     case CSSPropertyOpacity:
1794     case CSSPropertyOrphans:
1795     case CSSPropertyOutlineColor:
1796     case CSSPropertyOutlineOffset:
1797     case CSSPropertyOutlineStyle:
1798     case CSSPropertyOutlineWidth:
1799     case CSSPropertyOverflowWrap:
1800     case CSSPropertyOverflowX:
1801     case CSSPropertyOverflowY:
1802     case CSSPropertyPaddingBottom:
1803     case CSSPropertyPaddingLeft:
1804     case CSSPropertyPaddingRight:
1805     case CSSPropertyPaddingTop:
1806     case CSSPropertyPageBreakAfter:
1807     case CSSPropertyPageBreakBefore:
1808     case CSSPropertyPageBreakInside:
1809     case CSSPropertyPointerEvents:
1810     case CSSPropertyPosition:
1811     case CSSPropertyResize:
1812     case CSSPropertyRight:
1813     case CSSPropertyScrollBehavior:
1814     case CSSPropertySize:
1815     case CSSPropertySpeak:
1816     case CSSPropertyTabSize:
1817     case CSSPropertyTableLayout:
1818     case CSSPropertyTextAlign:
1819     case CSSPropertyTextAlignLast:
1820     case CSSPropertyTextDecoration:
1821     case CSSPropertyTextDecorationLine:
1822     case CSSPropertyTextDecorationStyle:
1823     case CSSPropertyTextDecorationColor:
1824     case CSSPropertyTextIndent:
1825     case CSSPropertyTextJustify:
1826     case CSSPropertyTextOverflow:
1827     case CSSPropertyTextRendering:
1828     case CSSPropertyTextShadow:
1829     case CSSPropertyTextTransform:
1830     case CSSPropertyTop:
1831     case CSSPropertyTouchAction:
1832     case CSSPropertyTouchActionDelay:
1833     case CSSPropertyUnicodeBidi:
1834     case CSSPropertyVerticalAlign:
1835     case CSSPropertyVisibility:
1836     case CSSPropertyWebkitAnimationDelay:
1837     case CSSPropertyWebkitAnimationDirection:
1838     case CSSPropertyWebkitAnimationDuration:
1839     case CSSPropertyWebkitAnimationFillMode:
1840     case CSSPropertyWebkitAnimationIterationCount:
1841     case CSSPropertyWebkitAnimationName:
1842     case CSSPropertyWebkitAnimationPlayState:
1843     case CSSPropertyWebkitAnimationTimingFunction:
1844     case CSSPropertyWebkitAppearance:
1845     case CSSPropertyWebkitAspectRatio:
1846     case CSSPropertyWebkitBackfaceVisibility:
1847     case CSSPropertyWebkitBackgroundClip:
1848     case CSSPropertyWebkitBackgroundComposite:
1849     case CSSPropertyWebkitBackgroundOrigin:
1850     case CSSPropertyWebkitBackgroundSize:
1851     case CSSPropertyWebkitBorderFit:
1852     case CSSPropertyWebkitBorderHorizontalSpacing:
1853     case CSSPropertyWebkitBorderImage:
1854     case CSSPropertyWebkitBorderVerticalSpacing:
1855     case CSSPropertyWebkitBoxAlign:
1856     case CSSPropertyWebkitBoxDecorationBreak:
1857     case CSSPropertyWebkitBoxDirection:
1858     case CSSPropertyWebkitBoxFlex:
1859     case CSSPropertyWebkitBoxFlexGroup:
1860     case CSSPropertyWebkitBoxLines:
1861     case CSSPropertyWebkitBoxOrdinalGroup:
1862     case CSSPropertyWebkitBoxOrient:
1863     case CSSPropertyWebkitBoxPack:
1864     case CSSPropertyWebkitBoxShadow:
1865     case CSSPropertyWebkitColumnAxis:
1866     case CSSPropertyWebkitColumnBreakAfter:
1867     case CSSPropertyWebkitColumnBreakBefore:
1868     case CSSPropertyWebkitColumnBreakInside:
1869     case CSSPropertyWebkitColumnCount:
1870     case CSSPropertyColumnFill:
1871     case CSSPropertyWebkitColumnGap:
1872     case CSSPropertyWebkitColumnProgression:
1873     case CSSPropertyWebkitColumnRuleColor:
1874     case CSSPropertyWebkitColumnRuleStyle:
1875     case CSSPropertyWebkitColumnRuleWidth:
1876     case CSSPropertyWebkitColumnSpan:
1877     case CSSPropertyWebkitColumnWidth:
1878     case CSSPropertyAlignContent:
1879     case CSSPropertyFlexBasis:
1880     case CSSPropertyFlexDirection:
1881     case CSSPropertyFlexGrow:
1882     case CSSPropertyFlexShrink:
1883     case CSSPropertyFlexWrap:
1884     case CSSPropertyJustifyContent:
1885     case CSSPropertyOrder:
1886     case CSSPropertyWebkitFontSmoothing:
1887     case CSSPropertyWebkitHighlight:
1888     case CSSPropertyWebkitHyphenateCharacter:
1889     case CSSPropertyWebkitLineBreak:
1890     case CSSPropertyWebkitLineClamp:
1891     case CSSPropertyInternalMarqueeDirection:
1892     case CSSPropertyInternalMarqueeIncrement:
1893     case CSSPropertyInternalMarqueeRepetition:
1894     case CSSPropertyInternalMarqueeSpeed:
1895     case CSSPropertyInternalMarqueeStyle:
1896     case CSSPropertyWebkitMaskBoxImage:
1897     case CSSPropertyWebkitMaskBoxImageOutset:
1898     case CSSPropertyWebkitMaskBoxImageRepeat:
1899     case CSSPropertyWebkitMaskBoxImageSlice:
1900     case CSSPropertyWebkitMaskBoxImageSource:
1901     case CSSPropertyWebkitMaskBoxImageWidth:
1902     case CSSPropertyWebkitMaskClip:
1903     case CSSPropertyWebkitMaskComposite:
1904     case CSSPropertyWebkitMaskImage:
1905     case CSSPropertyWebkitMaskOrigin:
1906     case CSSPropertyWebkitMaskPositionX:
1907     case CSSPropertyWebkitMaskPositionY:
1908     case CSSPropertyWebkitMaskRepeatX:
1909     case CSSPropertyWebkitMaskRepeatY:
1910     case CSSPropertyWebkitMaskSize:
1911     case CSSPropertyWebkitPerspectiveOrigin:
1912     case CSSPropertyWebkitPerspectiveOriginX:
1913     case CSSPropertyWebkitPerspectiveOriginY:
1914     case CSSPropertyWebkitPrintColorAdjust:
1915     case CSSPropertyWebkitRtlOrdering:
1916     case CSSPropertyWebkitRubyPosition:
1917     case CSSPropertyWebkitTextCombine:
1918     case CSSPropertyTextUnderlinePosition:
1919     case CSSPropertyWebkitTextEmphasisColor:
1920     case CSSPropertyWebkitTextEmphasisPosition:
1921     case CSSPropertyWebkitTextEmphasisStyle:
1922     case CSSPropertyWebkitTextFillColor:
1923     case CSSPropertyWebkitTextSecurity:
1924     case CSSPropertyWebkitTextStrokeColor:
1925     case CSSPropertyWebkitTransformOriginX:
1926     case CSSPropertyWebkitTransformOriginY:
1927     case CSSPropertyWebkitTransformOriginZ:
1928     case CSSPropertyWebkitTransformStyle:
1929     case CSSPropertyWebkitTransitionDelay:
1930     case CSSPropertyWebkitTransitionDuration:
1931     case CSSPropertyWebkitTransitionProperty:
1932     case CSSPropertyWebkitTransitionTimingFunction:
1933     case CSSPropertyWebkitUserDrag:
1934     case CSSPropertyWebkitUserModify:
1935     case CSSPropertyWebkitUserSelect:
1936     case CSSPropertyWebkitClipPath:
1937     case CSSPropertyWebkitWrapFlow:
1938     case CSSPropertyShapeMargin:
1939     case CSSPropertyShapePadding:
1940     case CSSPropertyShapeImageThreshold:
1941     case CSSPropertyWebkitWrapThrough:
1942     case CSSPropertyShapeInside:
1943     case CSSPropertyShapeOutside:
1944     case CSSPropertyWhiteSpace:
1945     case CSSPropertyWidows:
1946     case CSSPropertyWidth:
1947     case CSSPropertyWordBreak:
1948     case CSSPropertyWordSpacing:
1949     case CSSPropertyWordWrap:
1950     case CSSPropertyZIndex:
1951     case CSSPropertyZoom:
1952     case CSSPropertyFontFamily:
1953     case CSSPropertyGridAutoFlow:
1954     case CSSPropertyMarker:
1955     case CSSPropertyAlignmentBaseline:
1956     case CSSPropertyBufferedRendering:
1957     case CSSPropertyClipRule:
1958     case CSSPropertyColorInterpolation:
1959     case CSSPropertyColorInterpolationFilters:
1960     case CSSPropertyColorRendering:
1961     case CSSPropertyDominantBaseline:
1962     case CSSPropertyFillRule:
1963     case CSSPropertyMaskSourceType:
1964     case CSSPropertyMaskType:
1965     case CSSPropertyShapeRendering:
1966     case CSSPropertyStrokeLinecap:
1967     case CSSPropertyStrokeLinejoin:
1968     case CSSPropertyTextAnchor:
1969     case CSSPropertyVectorEffect:
1970     case CSSPropertyWritingMode:
1971     case CSSPropertyClipPath:
1972     case CSSPropertyFillOpacity:
1973     case CSSPropertyFilter:
1974     case CSSPropertyFloodOpacity:
1975     case CSSPropertyKerning:
1976     case CSSPropertyMarkerEnd:
1977     case CSSPropertyMarkerMid:
1978     case CSSPropertyMarkerStart:
1979     case CSSPropertyMask:
1980     case CSSPropertyStopOpacity:
1981     case CSSPropertyStrokeDashoffset:
1982     case CSSPropertyStrokeMiterlimit:
1983     case CSSPropertyStrokeOpacity:
1984     case CSSPropertyStrokeWidth:
1985         ASSERT_NOT_REACHED();
1986         return;
1987     // Only used in @viewport rules
1988     case CSSPropertyMaxZoom:
1989     case CSSPropertyMinZoom:
1990     case CSSPropertyOrientation:
1991     case CSSPropertyUserZoom:
1992         return;
1993
1994     case CSSPropertyBaselineShift:
1995     {
1996         HANDLE_SVG_INHERIT_AND_INITIAL(baselineShift, BaselineShift);
1997         if (!primitiveValue)
1998             break;
1999
2000         SVGRenderStyle* svgStyle = state.style()->accessSVGStyle();
2001         if (primitiveValue->getValueID()) {
2002             switch (primitiveValue->getValueID()) {
2003             case CSSValueBaseline:
2004                 svgStyle->setBaselineShift(BS_BASELINE);
2005                 break;
2006             case CSSValueSub:
2007                 svgStyle->setBaselineShift(BS_SUB);
2008                 break;
2009             case CSSValueSuper:
2010                 svgStyle->setBaselineShift(BS_SUPER);
2011                 break;
2012             default:
2013                 break;
2014             }
2015         } else {
2016             svgStyle->setBaselineShift(BS_LENGTH);
2017             svgStyle->setBaselineShiftValue(SVGLength::fromCSSPrimitiveValue(primitiveValue));
2018         }
2019
2020         break;
2021     }
2022     case CSSPropertyColorProfile:
2023     {
2024         // Not implemented.
2025         break;
2026     }
2027     // end of ident only properties
2028     case CSSPropertyFill:
2029     {
2030         SVGRenderStyle* svgStyle = state.style()->accessSVGStyle();
2031         if (isInherit) {
2032             const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle();
2033             svgStyle->setFillPaint(svgParentStyle->fillPaintType(), svgParentStyle->fillPaintColor(), svgParentStyle->fillPaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle());
2034             return;
2035         }
2036         if (isInitial) {
2037             svgStyle->setFillPaint(SVGRenderStyle::initialFillPaintType(), SVGRenderStyle::initialFillPaintColor(), SVGRenderStyle::initialFillPaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle());
2038             return;
2039         }
2040         if (value->isSVGPaint()) {
2041             SVGPaint* svgPaint = toSVGPaint(value);
2042             svgStyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle());
2043         }
2044         break;
2045     }
2046     case CSSPropertyStroke:
2047     {
2048         SVGRenderStyle* svgStyle = state.style()->accessSVGStyle();
2049         if (isInherit) {
2050             const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle();
2051             svgStyle->setStrokePaint(svgParentStyle->strokePaintType(), svgParentStyle->strokePaintColor(), svgParentStyle->strokePaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle());
2052             return;
2053         }
2054         if (isInitial) {
2055             svgStyle->setStrokePaint(SVGRenderStyle::initialStrokePaintType(), SVGRenderStyle::initialStrokePaintColor(), SVGRenderStyle::initialStrokePaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle());
2056             return;
2057         }
2058         if (value->isSVGPaint()) {
2059             SVGPaint* svgPaint = toSVGPaint(value);
2060             svgStyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle());
2061         }
2062         break;
2063     }
2064     case CSSPropertyStrokeDasharray:
2065     {
2066         HANDLE_SVG_INHERIT_AND_INITIAL(strokeDashArray, StrokeDashArray)
2067         if (!value->isValueList()) {
2068             state.style()->accessSVGStyle()->setStrokeDashArray(SVGRenderStyle::initialStrokeDashArray());
2069             break;
2070         }
2071
2072         CSSValueList* dashes = toCSSValueList(value);
2073
2074         RefPtr<SVGLengthList> array = SVGLengthList::create();
2075         size_t length = dashes->length();
2076         for (size_t i = 0; i < length; ++i) {
2077             CSSValue* currValue = dashes->itemWithoutBoundsCheck(i);
2078             if (!currValue->isPrimitiveValue())
2079                 continue;
2080
2081             CSSPrimitiveValue* dash = toCSSPrimitiveValue(dashes->itemWithoutBoundsCheck(i));
2082             array->append(SVGLength::fromCSSPrimitiveValue(dash));
2083         }
2084
2085         state.style()->accessSVGStyle()->setStrokeDashArray(array.release());
2086         break;
2087     }
2088     case CSSPropertyStopColor:
2089     {
2090         HANDLE_SVG_INHERIT_AND_INITIAL(stopColor, StopColor);
2091         if (value->isSVGColor())
2092             state.style()->accessSVGStyle()->setStopColor(colorFromSVGColorCSSValue(toSVGColor(value), state.style()->color()));
2093         break;
2094     }
2095     case CSSPropertyLightingColor:
2096     {
2097         HANDLE_SVG_INHERIT_AND_INITIAL(lightingColor, LightingColor);
2098         if (value->isSVGColor())
2099             state.style()->accessSVGStyle()->setLightingColor(colorFromSVGColorCSSValue(toSVGColor(value), state.style()->color()));
2100         break;
2101     }
2102     case CSSPropertyFloodColor:
2103     {
2104         HANDLE_SVG_INHERIT_AND_INITIAL(floodColor, FloodColor);
2105         if (value->isSVGColor())
2106             state.style()->accessSVGStyle()->setFloodColor(colorFromSVGColorCSSValue(toSVGColor(value), state.style()->color()));
2107         break;
2108     }
2109     case CSSPropertyGlyphOrientationHorizontal:
2110     {
2111         HANDLE_SVG_INHERIT_AND_INITIAL(glyphOrientationHorizontal, GlyphOrientationHorizontal)
2112         EGlyphOrientation orientation;
2113         if (degreeToGlyphOrientation(primitiveValue, orientation))
2114             state.style()->accessSVGStyle()->setGlyphOrientationHorizontal(orientation);
2115         break;
2116     }
2117     case CSSPropertyPaintOrder: {
2118         HANDLE_SVG_INHERIT_AND_INITIAL(paintOrder, PaintOrder)
2119         if (value->isValueList())
2120             state.style()->accessSVGStyle()->setPaintOrder(paintOrderFlattened(value));
2121         break;
2122     }
2123     case CSSPropertyGlyphOrientationVertical:
2124     {
2125         HANDLE_SVG_INHERIT_AND_INITIAL(glyphOrientationVertical, GlyphOrientationVertical)
2126         if (primitiveValue->getValueID() == CSSValueAuto) {
2127             state.style()->accessSVGStyle()->setGlyphOrientationVertical(GO_AUTO);
2128             break;
2129         }
2130         EGlyphOrientation orientation;
2131         if (degreeToGlyphOrientation(primitiveValue, orientation))
2132             state.style()->accessSVGStyle()->setGlyphOrientationVertical(orientation);
2133         break;
2134     }
2135     case CSSPropertyEnableBackground:
2136         // Silently ignoring this property for now
2137         // http://bugs.webkit.org/show_bug.cgi?id=6022
2138         break;
2139     }
2140 }
2141
2142 } // namespace WebCore