Roll out r165076.
[WebKit-https.git] / Source / WebCore / css / CSSComputedStyleDeclaration.cpp
1 /*
2  * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3  * Copyright (C) 2004-2014 Apple Inc. All rights reserved.
4  * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5  * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6  * Copyright (C) 2011 Sencha, Inc. All rights reserved.
7  * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301  USA
23  */
24
25 #include "config.h"
26 #include "CSSComputedStyleDeclaration.h"
27
28 #include "AnimationController.h"
29 #include "BasicShapeFunctions.h"
30 #include "BasicShapes.h"
31 #include "CSSAspectRatioValue.h"
32 #include "CSSBasicShapes.h"
33 #include "CSSBorderImage.h"
34 #include "CSSFontFeatureValue.h"
35 #include "CSSFontValue.h"
36 #include "CSSFunctionValue.h"
37 #include "CSSLineBoxContainValue.h"
38 #include "CSSParser.h"
39 #include "CSSPrimitiveValue.h"
40 #include "CSSPrimitiveValueMappings.h"
41 #include "CSSPropertyNames.h"
42 #include "CSSReflectValue.h"
43 #include "CSSSelector.h"
44 #include "CSSShadowValue.h"
45 #include "CSSTimingFunctionValue.h"
46 #include "CSSValueList.h"
47 #include "CSSValuePool.h"
48 #include "ContentData.h"
49 #include "CounterContent.h"
50 #include "CursorList.h"
51 #include "Document.h"
52 #include "ExceptionCode.h"
53 #include "FontFeatureSettings.h"
54 #include "HTMLFrameOwnerElement.h"
55 #include "Pair.h"
56 #include "PseudoElement.h"
57 #include "Rect.h"
58 #include "RenderBox.h"
59 #include "RenderStyle.h"
60 #include "SVGElement.h"
61 #include "StyleInheritedData.h"
62 #include "StyleProperties.h"
63 #include "StylePropertyShorthand.h"
64 #include "StyleResolver.h"
65 #include "WebKitCSSFilterValue.h"
66 #include "WebKitCSSTransformValue.h"
67 #include "WebKitFontFamilyNames.h"
68 #include <wtf/NeverDestroyed.h>
69 #include <wtf/text/StringBuilder.h>
70
71 #if ENABLE(CSS_GRID_LAYOUT)
72 #include "CSSGridLineNamesValue.h"
73 #include "CSSGridTemplateAreasValue.h"
74 #include "RenderGrid.h"
75 #endif
76
77 #if ENABLE(CSS_SHAPES)
78 #include "ShapeValue.h"
79 #endif
80
81 #if ENABLE(DASHBOARD_SUPPORT)
82 #include "DashboardRegion.h"
83 #endif
84
85 #if ENABLE(CSS_SCROLL_SNAP)
86 #include "LengthRepeat.h"
87 #include "StyleScrollSnapPoints.h"
88 #endif
89
90 namespace WebCore {
91
92 // List of all properties we know how to compute, omitting shorthands.
93 static const CSSPropertyID computedProperties[] = {
94     CSSPropertyAlt,
95     CSSPropertyAnimationDelay,
96     CSSPropertyAnimationDirection,
97     CSSPropertyAnimationDuration,
98     CSSPropertyAnimationFillMode,
99     CSSPropertyAnimationIterationCount,
100     CSSPropertyAnimationName,
101     CSSPropertyAnimationPlayState,
102     CSSPropertyAnimationTimingFunction,
103     CSSPropertyBackgroundAttachment,
104     CSSPropertyBackgroundBlendMode,
105     CSSPropertyBackgroundClip,
106     CSSPropertyBackgroundColor,
107     CSSPropertyBackgroundImage,
108     CSSPropertyBackgroundOrigin,
109     CSSPropertyBackgroundPosition, // more-specific background-position-x/y are non-standard
110     CSSPropertyBackgroundRepeat,
111     CSSPropertyBackgroundSize,
112     CSSPropertyBorderBottomColor,
113     CSSPropertyBorderBottomLeftRadius,
114     CSSPropertyBorderBottomRightRadius,
115     CSSPropertyBorderBottomStyle,
116     CSSPropertyBorderBottomWidth,
117     CSSPropertyBorderCollapse,
118     CSSPropertyBorderImageOutset,
119     CSSPropertyBorderImageRepeat,
120     CSSPropertyBorderImageSlice,
121     CSSPropertyBorderImageSource,
122     CSSPropertyBorderImageWidth,
123     CSSPropertyBorderLeftColor,
124     CSSPropertyBorderLeftStyle,
125     CSSPropertyBorderLeftWidth,
126     CSSPropertyBorderRightColor,
127     CSSPropertyBorderRightStyle,
128     CSSPropertyBorderRightWidth,
129     CSSPropertyBorderTopColor,
130     CSSPropertyBorderTopLeftRadius,
131     CSSPropertyBorderTopRightRadius,
132     CSSPropertyBorderTopStyle,
133     CSSPropertyBorderTopWidth,
134     CSSPropertyBottom,
135     CSSPropertyBoxShadow,
136     CSSPropertyBoxSizing,
137     CSSPropertyCaptionSide,
138     CSSPropertyClear,
139     CSSPropertyClip,
140     CSSPropertyColor,
141     CSSPropertyCursor,
142     CSSPropertyDirection,
143     CSSPropertyDisplay,
144     CSSPropertyEmptyCells,
145     CSSPropertyFloat,
146     CSSPropertyFontFamily,
147     CSSPropertyFontSize,
148     CSSPropertyFontStyle,
149     CSSPropertyFontVariant,
150     CSSPropertyFontWeight,
151     CSSPropertyHeight,
152 #if ENABLE(CSS_IMAGE_ORIENTATION)
153     CSSPropertyImageOrientation,
154 #endif
155     CSSPropertyImageRendering,
156 #if ENABLE(CSS_IMAGE_RESOLUTION)
157     CSSPropertyImageResolution,
158 #endif
159     CSSPropertyLeft,
160     CSSPropertyLetterSpacing,
161     CSSPropertyLineHeight,
162     CSSPropertyListStyleImage,
163     CSSPropertyListStylePosition,
164     CSSPropertyListStyleType,
165     CSSPropertyMarginBottom,
166     CSSPropertyMarginLeft,
167     CSSPropertyMarginRight,
168     CSSPropertyMarginTop,
169     CSSPropertyMaxHeight,
170     CSSPropertyMaxWidth,
171     CSSPropertyMinHeight,
172     CSSPropertyMinWidth,
173     CSSPropertyOpacity,
174     CSSPropertyOrphans,
175     CSSPropertyOutlineColor,
176     CSSPropertyOutlineOffset,
177     CSSPropertyOutlineStyle,
178     CSSPropertyOutlineWidth,
179     CSSPropertyOverflowWrap,
180     CSSPropertyOverflowX,
181     CSSPropertyOverflowY,
182     CSSPropertyPaddingBottom,
183     CSSPropertyPaddingLeft,
184     CSSPropertyPaddingRight,
185     CSSPropertyPaddingTop,
186     CSSPropertyPageBreakAfter,
187     CSSPropertyPageBreakBefore,
188     CSSPropertyPageBreakInside,
189     CSSPropertyPointerEvents,
190     CSSPropertyPosition,
191     CSSPropertyResize,
192     CSSPropertyRight,
193     CSSPropertySpeak,
194     CSSPropertyTableLayout,
195     CSSPropertyTabSize,
196     CSSPropertyTextAlign,
197     CSSPropertyTextDecoration,
198 #if ENABLE(CSS3_TEXT)
199     CSSPropertyWebkitTextAlignLast,
200     CSSPropertyWebkitTextJustify,
201 #endif // CSS3_TEXT
202     CSSPropertyWebkitTextDecorationLine,
203     CSSPropertyWebkitTextDecorationStyle,
204     CSSPropertyWebkitTextDecorationColor,
205     CSSPropertyWebkitTextDecorationSkip,
206     CSSPropertyWebkitTextUnderlinePosition,
207     CSSPropertyTextIndent,
208     CSSPropertyTextRendering,
209     CSSPropertyTextShadow,
210     CSSPropertyTextOverflow,
211     CSSPropertyTextTransform,
212     CSSPropertyTop,
213     CSSPropertyTransitionDelay,
214     CSSPropertyTransitionDuration,
215     CSSPropertyTransitionProperty,
216     CSSPropertyTransitionTimingFunction,
217     CSSPropertyUnicodeBidi,
218     CSSPropertyVerticalAlign,
219     CSSPropertyVisibility,
220     CSSPropertyWhiteSpace,
221     CSSPropertyWidows,
222     CSSPropertyWidth,
223     CSSPropertyWordBreak,
224     CSSPropertyWordSpacing,
225     CSSPropertyWordWrap,
226 #if ENABLE(CSS_SCROLL_SNAP)
227     CSSPropertyWebkitScrollSnapType,
228     CSSPropertyWebkitScrollSnapPointsX,
229     CSSPropertyWebkitScrollSnapPointsY,
230     CSSPropertyWebkitScrollSnapDestination,
231     CSSPropertyWebkitScrollSnapCoordinate,
232 #endif
233     CSSPropertyZIndex,
234     CSSPropertyZoom,
235     CSSPropertyWebkitAnimationDelay,
236     CSSPropertyWebkitAnimationDirection,
237     CSSPropertyWebkitAnimationDuration,
238     CSSPropertyWebkitAnimationFillMode,
239     CSSPropertyWebkitAnimationIterationCount,
240     CSSPropertyWebkitAnimationName,
241     CSSPropertyWebkitAnimationPlayState,
242     CSSPropertyWebkitAnimationTimingFunction,
243     CSSPropertyWebkitAppearance,
244     CSSPropertyWebkitBackfaceVisibility,
245     CSSPropertyWebkitBackgroundClip,
246     CSSPropertyWebkitBackgroundComposite,
247     CSSPropertyWebkitBackgroundOrigin,
248     CSSPropertyWebkitBackgroundSize,
249 #if ENABLE(CSS_COMPOSITING)
250     CSSPropertyMixBlendMode,
251     CSSPropertyIsolation,
252 #endif
253     CSSPropertyWebkitBorderFit,
254     CSSPropertyWebkitBorderHorizontalSpacing,
255     CSSPropertyWebkitBorderImage,
256     CSSPropertyWebkitBorderVerticalSpacing,
257     CSSPropertyWebkitBoxAlign,
258 #if ENABLE(CSS_BOX_DECORATION_BREAK)
259     CSSPropertyWebkitBoxDecorationBreak,
260 #endif
261     CSSPropertyWebkitBoxDirection,
262     CSSPropertyWebkitBoxFlex,
263     CSSPropertyWebkitBoxFlexGroup,
264     CSSPropertyWebkitBoxLines,
265     CSSPropertyWebkitBoxOrdinalGroup,
266     CSSPropertyWebkitBoxOrient,
267     CSSPropertyWebkitBoxPack,
268     CSSPropertyWebkitBoxReflect,
269     CSSPropertyWebkitBoxShadow,
270     CSSPropertyWebkitClipPath,
271     CSSPropertyWebkitColorCorrection,
272     CSSPropertyWebkitColumnBreakAfter,
273     CSSPropertyWebkitColumnBreakBefore,
274     CSSPropertyWebkitColumnBreakInside,
275     CSSPropertyWebkitColumnAxis,
276     CSSPropertyColumnCount,
277     CSSPropertyColumnGap,
278     CSSPropertyColumnProgression,
279     CSSPropertyColumnRuleColor,
280     CSSPropertyColumnRuleStyle,
281     CSSPropertyColumnRuleWidth,
282     CSSPropertyColumnSpan,
283     CSSPropertyColumnWidth,
284 #if ENABLE(CURSOR_VISIBILITY)
285     CSSPropertyWebkitCursorVisibility,
286 #endif
287 #if ENABLE(DASHBOARD_SUPPORT)
288     CSSPropertyWebkitDashboardRegion,
289 #endif
290     CSSPropertyAlignContent,
291     CSSPropertyAlignItems,
292     CSSPropertyAlignSelf,
293     CSSPropertyFlexBasis,
294     CSSPropertyFlexGrow,
295     CSSPropertyFlexShrink,
296     CSSPropertyFlexDirection,
297     CSSPropertyFlexWrap,
298     CSSPropertyJustifyContent,
299     CSSPropertyWebkitJustifySelf,
300     CSSPropertyWebkitFilter,
301 #if ENABLE(FILTERS_LEVEL_2)
302     CSSPropertyWebkitBackdropFilter,
303 #endif
304     CSSPropertyWebkitFontKerning,
305     CSSPropertyWebkitFontSmoothing,
306     CSSPropertyWebkitFontVariantLigatures,
307 #if ENABLE(CSS_GRID_LAYOUT)
308     CSSPropertyWebkitGridAutoColumns,
309     CSSPropertyWebkitGridAutoFlow,
310     CSSPropertyWebkitGridAutoRows,
311     CSSPropertyWebkitGridColumnEnd,
312     CSSPropertyWebkitGridColumnStart,
313     CSSPropertyWebkitGridTemplateAreas,
314     CSSPropertyWebkitGridTemplateColumns,
315     CSSPropertyWebkitGridTemplateRows,
316     CSSPropertyWebkitGridRowEnd,
317     CSSPropertyWebkitGridRowStart,
318 #endif
319     CSSPropertyWebkitHyphenateCharacter,
320     CSSPropertyWebkitHyphenateLimitAfter,
321     CSSPropertyWebkitHyphenateLimitBefore,
322     CSSPropertyWebkitHyphenateLimitLines,
323     CSSPropertyWebkitHyphens,
324     CSSPropertyWebkitInitialLetter,
325     CSSPropertyWebkitLineAlign,
326     CSSPropertyWebkitLineBoxContain,
327     CSSPropertyWebkitLineBreak,
328     CSSPropertyWebkitLineClamp,
329     CSSPropertyWebkitLineGrid,
330     CSSPropertyWebkitLineSnap,
331     CSSPropertyWebkitLocale,
332     CSSPropertyWebkitMarginBeforeCollapse,
333     CSSPropertyWebkitMarginAfterCollapse,
334     CSSPropertyWebkitMarqueeDirection,
335     CSSPropertyWebkitMarqueeIncrement,
336     CSSPropertyWebkitMarqueeRepetition,
337     CSSPropertyWebkitMarqueeStyle,
338     CSSPropertyWebkitMaskBoxImage,
339     CSSPropertyWebkitMaskBoxImageOutset,
340     CSSPropertyWebkitMaskBoxImageRepeat,
341     CSSPropertyWebkitMaskBoxImageSlice,
342     CSSPropertyWebkitMaskBoxImageSource,
343     CSSPropertyWebkitMaskBoxImageWidth,
344     CSSPropertyWebkitMaskClip,
345     CSSPropertyWebkitMaskComposite,
346     CSSPropertyWebkitMaskImage,
347     CSSPropertyWebkitMaskOrigin,
348     CSSPropertyWebkitMaskPosition,
349     CSSPropertyWebkitMaskRepeat,
350     CSSPropertyWebkitMaskSize,
351     CSSPropertyWebkitMaskSourceType,
352     CSSPropertyWebkitNbspMode,
353     CSSPropertyOrder,
354 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
355     CSSPropertyWebkitOverflowScrolling,
356 #endif
357     CSSPropertyWebkitPerspective,
358     CSSPropertyWebkitPerspectiveOrigin,
359     CSSPropertyWebkitPrintColorAdjust,
360     CSSPropertyWebkitRtlOrdering,
361 #if PLATFORM(IOS)
362     CSSPropertyWebkitTouchCallout,
363 #endif
364 #if ENABLE(CSS_SHAPES)
365     CSSPropertyWebkitShapeOutside,
366 #endif
367 #if ENABLE(TOUCH_EVENTS)
368     CSSPropertyWebkitTapHighlightColor,
369 #endif
370     CSSPropertyWebkitTextCombine,
371     CSSPropertyWebkitTextDecorationsInEffect,
372     CSSPropertyWebkitTextEmphasisColor,
373     CSSPropertyWebkitTextEmphasisPosition,
374     CSSPropertyWebkitTextEmphasisStyle,
375     CSSPropertyWebkitTextFillColor,
376     CSSPropertyWebkitTextOrientation,
377     CSSPropertyWebkitTextSecurity,
378 #if ENABLE(IOS_TEXT_AUTOSIZING)
379     CSSPropertyWebkitTextSizeAdjust,
380 #endif
381     CSSPropertyWebkitTextStrokeColor,
382     CSSPropertyWebkitTextStrokeWidth,
383     CSSPropertyWebkitTransform,
384     CSSPropertyWebkitTransformOrigin,
385     CSSPropertyWebkitTransformStyle,
386     CSSPropertyWebkitTransitionDelay,
387     CSSPropertyWebkitTransitionDuration,
388     CSSPropertyWebkitTransitionProperty,
389     CSSPropertyWebkitTransitionTimingFunction,
390     CSSPropertyWebkitUserDrag,
391     CSSPropertyWebkitUserModify,
392     CSSPropertyWebkitUserSelect,
393     CSSPropertyWebkitWritingMode,
394 #if ENABLE(CSS_REGIONS)
395     CSSPropertyWebkitFlowInto,
396     CSSPropertyWebkitFlowFrom,
397     CSSPropertyWebkitRegionBreakAfter,
398     CSSPropertyWebkitRegionBreakBefore,
399     CSSPropertyWebkitRegionBreakInside,
400     CSSPropertyWebkitRegionFragment,
401 #endif
402 #if ENABLE(CSS_SHAPES)
403     CSSPropertyWebkitShapeMargin,
404     CSSPropertyWebkitShapeImageThreshold,
405 #endif
406     CSSPropertyBufferedRendering,
407     CSSPropertyClipPath,
408     CSSPropertyClipRule,
409     CSSPropertyCx,
410     CSSPropertyCy,
411     CSSPropertyMask,
412     CSSPropertyFilter,
413     CSSPropertyFloodColor,
414     CSSPropertyFloodOpacity,
415     CSSPropertyLightingColor,
416     CSSPropertyStopColor,
417     CSSPropertyStopOpacity,
418     CSSPropertyColorInterpolation,
419     CSSPropertyColorInterpolationFilters,
420     CSSPropertyColorRendering,
421     CSSPropertyFill,
422     CSSPropertyFillOpacity,
423     CSSPropertyFillRule,
424     CSSPropertyMarkerEnd,
425     CSSPropertyMarkerMid,
426     CSSPropertyMarkerStart,
427     CSSPropertyMaskType,
428     CSSPropertyPaintOrder,
429     CSSPropertyR,
430     CSSPropertyRx,
431     CSSPropertyRy,
432     CSSPropertyShapeRendering,
433     CSSPropertyStroke,
434     CSSPropertyStrokeDasharray,
435     CSSPropertyStrokeDashoffset,
436     CSSPropertyStrokeLinecap,
437     CSSPropertyStrokeLinejoin,
438     CSSPropertyStrokeMiterlimit,
439     CSSPropertyStrokeOpacity,
440     CSSPropertyStrokeWidth,
441     CSSPropertyAlignmentBaseline,
442     CSSPropertyBaselineShift,
443     CSSPropertyDominantBaseline,
444     CSSPropertyKerning,
445     CSSPropertyTextAnchor,
446     CSSPropertyWritingMode,
447     CSSPropertyGlyphOrientationHorizontal,
448     CSSPropertyGlyphOrientationVertical,
449     CSSPropertyWebkitSvgShadow,
450     CSSPropertyVectorEffect,
451     CSSPropertyX,
452     CSSPropertyY
453 };
454
455 const unsigned numComputedProperties = WTF_ARRAY_LENGTH(computedProperties);
456
457 static CSSValueID valueForRepeatRule(int rule)
458 {
459     switch (rule) {
460         case RepeatImageRule:
461             return CSSValueRepeat;
462         case RoundImageRule:
463             return CSSValueRound;
464         case SpaceImageRule:
465             return CSSValueSpace;
466         default:
467             return CSSValueStretch;
468     }
469 }
470
471 static PassRef<CSSPrimitiveValue> valueForImageSliceSide(const Length& length)
472 {
473     // These values can be percentages, numbers, or while an animation of mixed types is in progress,
474     // a calculation that combines a percentage and a number.
475     if (length.isPercentNotCalculated())
476         return cssValuePool().createValue(length.percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
477     if (length.isFixed())
478         return cssValuePool().createValue(length.value(), CSSPrimitiveValue::CSS_NUMBER);
479
480     // Calculating the actual length currently in use would require most of the code from RenderBoxModelObject::paintNinePieceImage.
481     // And even if we could do that, it's not clear if that's exactly what we'd want during animation.
482     // FIXME: For now, just return 0.
483     ASSERT(length.isCalculated());
484     return cssValuePool().createValue(0, CSSPrimitiveValue::CSS_NUMBER);
485 }
486
487 static PassRef<CSSBorderImageSliceValue> valueForNinePieceImageSlice(const NinePieceImage& image)
488 {
489     auto& slices = image.imageSlices();
490
491     RefPtr<CSSPrimitiveValue> top = valueForImageSliceSide(slices.top());
492
493     RefPtr<CSSPrimitiveValue> right;
494     RefPtr<CSSPrimitiveValue> bottom;
495     RefPtr<CSSPrimitiveValue> left;
496
497     if (slices.right() == slices.top() && slices.bottom() == slices.top() && slices.left() == slices.top()) {
498         right = top;
499         bottom = top;
500         left = top;
501     } else {
502         right = valueForImageSliceSide(slices.right());
503
504         if (slices.bottom() == slices.top() && slices.right() == slices.left()) {
505             bottom = top;
506             left = right;
507         } else {
508             bottom = valueForImageSliceSide(slices.bottom());
509
510             if (slices.left() == slices.right())
511                 left = right;
512             else
513                 left = valueForImageSliceSide(slices.left());
514         }
515     }
516
517     RefPtr<Quad> quad = Quad::create();
518     quad->setTop(top.release());
519     quad->setRight(right.release());
520     quad->setBottom(bottom.release());
521     quad->setLeft(left.release());
522
523     return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.release()), image.fill());
524 }
525
526 static PassRef<CSSPrimitiveValue> valueForNinePieceImageQuad(const LengthBox& box)
527 {
528     RefPtr<CSSPrimitiveValue> top;
529     RefPtr<CSSPrimitiveValue> right;
530     RefPtr<CSSPrimitiveValue> bottom;
531     RefPtr<CSSPrimitiveValue> left;
532
533     if (box.top().isRelative())
534         top = cssValuePool().createValue(box.top().value(), CSSPrimitiveValue::CSS_NUMBER);
535     else
536         top = cssValuePool().createValue(box.top());
537
538     if (box.right() == box.top() && box.bottom() == box.top() && box.left() == box.top()) {
539         right = top;
540         bottom = top;
541         left = top;
542     } else {
543         if (box.right().isRelative())
544             right = cssValuePool().createValue(box.right().value(), CSSPrimitiveValue::CSS_NUMBER);
545         else
546             right = cssValuePool().createValue(box.right());
547
548         if (box.bottom() == box.top() && box.right() == box.left()) {
549             bottom = top;
550             left = right;
551         } else {
552             if (box.bottom().isRelative())
553                 bottom = cssValuePool().createValue(box.bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
554             else
555                 bottom = cssValuePool().createValue(box.bottom());
556
557             if (box.left() == box.right())
558                 left = right;
559             else {
560                 if (box.left().isRelative())
561                     left = cssValuePool().createValue(box.left().value(), CSSPrimitiveValue::CSS_NUMBER);
562                 else
563                     left = cssValuePool().createValue(box.left());
564             }
565         }
566     }
567
568     RefPtr<Quad> quad = Quad::create();
569     quad->setTop(top);
570     quad->setRight(right);
571     quad->setBottom(bottom);
572     quad->setLeft(left);
573
574     return cssValuePool().createValue(quad.release());
575 }
576
577 static PassRef<CSSValue> valueForNinePieceImageRepeat(const NinePieceImage& image)
578 {
579     RefPtr<CSSPrimitiveValue> horizontalRepeat;
580     RefPtr<CSSPrimitiveValue> verticalRepeat;
581
582     horizontalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.horizontalRule()));
583     if (image.horizontalRule() == image.verticalRule())
584         verticalRepeat = horizontalRepeat;
585     else
586         verticalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.verticalRule()));
587     return cssValuePool().createValue(Pair::create(horizontalRepeat.release(), verticalRepeat.release()));
588 }
589
590 static PassRef<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
591 {
592     if (!image.hasImage())
593         return cssValuePool().createIdentifierValue(CSSValueNone);
594
595     // Image first.
596     RefPtr<CSSValue> imageValue;
597     if (image.image())
598         imageValue = image.image()->cssValue();
599
600     // Create the image slice.
601     RefPtr<CSSBorderImageSliceValue> imageSlices = valueForNinePieceImageSlice(image);
602
603     // Create the border area slices.
604     RefPtr<CSSValue> borderSlices = valueForNinePieceImageQuad(image.borderSlices());
605
606     // Create the border outset.
607     RefPtr<CSSValue> outset = valueForNinePieceImageQuad(image.outset());
608
609     // Create the repeat rules.
610     RefPtr<CSSValue> repeat = valueForNinePieceImageRepeat(image);
611
612     return createBorderImageValue(imageValue.release(), imageSlices.release(), borderSlices.release(), outset.release(), repeat.release());
613 }
614
615 inline static PassRef<CSSPrimitiveValue> zoomAdjustedPixelValue(double value, const RenderStyle* style)
616 {
617     return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style), CSSPrimitiveValue::CSS_PX);
618 }
619
620 inline static PassRef<CSSPrimitiveValue> zoomAdjustedNumberValue(double value, const RenderStyle* style)
621 {
622     return cssValuePool().createValue(value / style->effectiveZoom(), CSSPrimitiveValue::CSS_NUMBER);
623 }
624
625 static PassRef<CSSValue> zoomAdjustedPixelValueForLength(const Length& length, const RenderStyle* style)
626 {
627     if (length.isFixed())
628         return zoomAdjustedPixelValue(length.value(), style);
629     return cssValuePool().createValue(length, style);
630 }
631
632 static PassRef<CSSValue> valueForReflection(const StyleReflection* reflection, const RenderStyle* style)
633 {
634     if (!reflection)
635         return cssValuePool().createIdentifierValue(CSSValueNone);
636
637     RefPtr<CSSPrimitiveValue> offset;
638     if (reflection->offset().isPercent())
639         offset = cssValuePool().createValue(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
640     else
641         offset = zoomAdjustedPixelValue(reflection->offset().value(), style);
642
643     RefPtr<CSSPrimitiveValue> direction;
644     switch (reflection->direction()) {
645     case ReflectionBelow:
646         direction = cssValuePool().createIdentifierValue(CSSValueBelow);
647         break;
648     case ReflectionAbove:
649         direction = cssValuePool().createIdentifierValue(CSSValueAbove);
650         break;
651     case ReflectionLeft:
652         direction = cssValuePool().createIdentifierValue(CSSValueLeft);
653         break;
654     case ReflectionRight:
655         direction = cssValuePool().createIdentifierValue(CSSValueRight);
656         break;
657     }
658
659     return CSSReflectValue::create(direction.release(), offset.release(), valueForNinePieceImage(reflection->mask()));
660 }
661
662 static PassRef<CSSValueList> createPositionListForLayer(CSSPropertyID propertyID, const FillLayer* layer, const RenderStyle* style)
663 {
664     auto positionList = CSSValueList::createSpaceSeparated();
665     if (layer->isBackgroundOriginSet()) {
666         ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
667         positionList.get().append(cssValuePool().createValue(layer->backgroundXOrigin()));
668     }
669     positionList.get().append(zoomAdjustedPixelValueForLength(layer->xPosition(), style));
670     if (layer->isBackgroundOriginSet()) {
671         ASSERT(propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
672         positionList.get().append(cssValuePool().createValue(layer->backgroundYOrigin()));
673     }
674     positionList.get().append(zoomAdjustedPixelValueForLength(layer->yPosition(), style));
675     return positionList;
676 }
677
678 static PassRefPtr<CSSValue> positionOffsetValue(RenderStyle* style, CSSPropertyID propertyID)
679 {
680     if (!style)
681         return nullptr;
682
683     Length length;
684     switch (propertyID) {
685         case CSSPropertyLeft:
686             length = style->left();
687             break;
688         case CSSPropertyRight:
689             length = style->right();
690             break;
691         case CSSPropertyTop:
692             length = style->top();
693             break;
694         case CSSPropertyBottom:
695             length = style->bottom();
696             break;
697         default:
698             return nullptr;
699     }
700
701     if (style->hasOutOfFlowPosition()) {
702         if (length.isFixed())
703             return zoomAdjustedPixelValue(length.value(), style);
704
705         return cssValuePool().createValue(length);
706     }
707
708     if (style->hasInFlowPosition()) {
709         // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
710         // In other words if left is auto and right is not auto, then left's computed value is negative right().
711         // So we should get the opposite length unit and see if it is auto.
712         return cssValuePool().createValue(length);
713     }
714
715     return cssValuePool().createIdentifierValue(CSSValueAuto);
716 }
717
718 PassRefPtr<CSSPrimitiveValue> ComputedStyleExtractor::currentColorOrValidColor(RenderStyle* style, const Color& color) const
719 {
720     // This function does NOT look at visited information, so that computed style doesn't expose that.
721     if (!color.isValid())
722         return cssValuePool().createColorValue(style->color().rgb());
723     return cssValuePool().createColorValue(color.rgb());
724 }
725
726 static PassRef<CSSPrimitiveValue> percentageOrZoomAdjustedValue(Length length, const RenderStyle* style)
727 {
728     if (length.isPercentNotCalculated())
729         return cssValuePool().createValue(length.percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
730     
731     return zoomAdjustedPixelValue(valueForLength(length, 0), style);
732 }
733
734 static PassRef<CSSPrimitiveValue> autoOrZoomAdjustedValue(Length length, const RenderStyle* style)
735 {
736     if (length.isAuto())
737         return cssValuePool().createIdentifierValue(CSSValueAuto);
738
739     return zoomAdjustedPixelValue(valueForLength(length, 0), style);
740 }
741
742 static PassRef<CSSValueList> getBorderRadiusCornerValues(const LengthSize& radius, const RenderStyle* style)
743 {
744     auto list = CSSValueList::createSpaceSeparated();
745     list.get().append(percentageOrZoomAdjustedValue(radius.width(), style));
746     list.get().append(percentageOrZoomAdjustedValue(radius.height(), style));
747     return list;
748 }
749
750 static PassRef<CSSValue> getBorderRadiusCornerValue(const LengthSize& radius, const RenderStyle* style)
751 {
752     if (radius.width() == radius.height())
753         return percentageOrZoomAdjustedValue(radius.width(), style);
754
755     return getBorderRadiusCornerValues(radius, style);
756 }
757
758 static PassRef<CSSValueList> getBorderRadiusShorthandValue(const RenderStyle* style)
759 {
760     auto list = CSSValueList::createSlashSeparated();
761     bool showHorizontalBottomLeft = style->borderTopRightRadius().width() != style->borderBottomLeftRadius().width();
762     bool showHorizontalBottomRight = showHorizontalBottomLeft || (style->borderBottomRightRadius().width() != style->borderTopLeftRadius().width());
763     bool showHorizontalTopRight = showHorizontalBottomRight || (style->borderTopRightRadius().width() != style->borderTopLeftRadius().width());
764
765     bool showVerticalBottomLeft = style->borderTopRightRadius().height() != style->borderBottomLeftRadius().height();
766     bool showVerticalBottomRight = showVerticalBottomLeft || (style->borderBottomRightRadius().height() != style->borderTopLeftRadius().height());
767     bool showVerticalTopRight = showVerticalBottomRight || (style->borderTopRightRadius().height() != style->borderTopLeftRadius().height());
768
769     RefPtr<CSSValueList> topLeftRadius = getBorderRadiusCornerValues(style->borderTopLeftRadius(), style);
770     RefPtr<CSSValueList> topRightRadius = getBorderRadiusCornerValues(style->borderTopRightRadius(), style);
771     RefPtr<CSSValueList> bottomRightRadius = getBorderRadiusCornerValues(style->borderBottomRightRadius(), style);
772     RefPtr<CSSValueList> bottomLeftRadius = getBorderRadiusCornerValues(style->borderBottomLeftRadius(), style);
773
774     RefPtr<CSSValueList> horizontalRadii = CSSValueList::createSpaceSeparated();
775     horizontalRadii->append(*topLeftRadius->item(0));
776     if (showHorizontalTopRight)
777         horizontalRadii->append(*topRightRadius->item(0));
778     if (showHorizontalBottomRight)
779         horizontalRadii->append(*bottomRightRadius->item(0));
780     if (showHorizontalBottomLeft)
781         horizontalRadii->append(*bottomLeftRadius->item(0));
782
783     list.get().append(horizontalRadii.releaseNonNull());
784
785     RefPtr<CSSValueList> verticalRadiiList = CSSValueList::createSpaceSeparated();
786     verticalRadiiList->append(*topLeftRadius->item(1));
787     if (showVerticalTopRight)
788         verticalRadiiList->append(*topRightRadius->item(1));
789     if (showVerticalBottomRight)
790         verticalRadiiList->append(*bottomRightRadius->item(1));
791     if (showVerticalBottomLeft)
792         verticalRadiiList->append(*bottomLeftRadius->item(1));
793
794     if (!verticalRadiiList->equals(downcast<CSSValueList>(*list.get().item(0))))
795         list.get().append(verticalRadiiList.releaseNonNull());
796
797     return list;
798 }
799
800 static LayoutRect sizingBox(RenderObject& renderer)
801 {
802     if (!is<RenderBox>(renderer))
803         return LayoutRect();
804
805     auto& box = downcast<RenderBox>(renderer);
806     return box.style().boxSizing() == BORDER_BOX ? box.borderBoxRect() : box.computedCSSContentBoxRect();
807 }
808
809 static PassRef<WebKitCSSTransformValue> matrixTransformValue(const TransformationMatrix& transform, const RenderStyle* style)
810 {
811     RefPtr<WebKitCSSTransformValue> transformValue;
812     if (transform.isAffine()) {
813         transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::MatrixTransformOperation);
814
815         transformValue->append(cssValuePool().createValue(transform.a(), CSSPrimitiveValue::CSS_NUMBER));
816         transformValue->append(cssValuePool().createValue(transform.b(), CSSPrimitiveValue::CSS_NUMBER));
817         transformValue->append(cssValuePool().createValue(transform.c(), CSSPrimitiveValue::CSS_NUMBER));
818         transformValue->append(cssValuePool().createValue(transform.d(), CSSPrimitiveValue::CSS_NUMBER));
819         transformValue->append(zoomAdjustedNumberValue(transform.e(), style));
820         transformValue->append(zoomAdjustedNumberValue(transform.f(), style));
821     } else {
822         transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::Matrix3DTransformOperation);
823
824         transformValue->append(cssValuePool().createValue(transform.m11(), CSSPrimitiveValue::CSS_NUMBER));
825         transformValue->append(cssValuePool().createValue(transform.m12(), CSSPrimitiveValue::CSS_NUMBER));
826         transformValue->append(cssValuePool().createValue(transform.m13(), CSSPrimitiveValue::CSS_NUMBER));
827         transformValue->append(cssValuePool().createValue(transform.m14(), CSSPrimitiveValue::CSS_NUMBER));
828
829         transformValue->append(cssValuePool().createValue(transform.m21(), CSSPrimitiveValue::CSS_NUMBER));
830         transformValue->append(cssValuePool().createValue(transform.m22(), CSSPrimitiveValue::CSS_NUMBER));
831         transformValue->append(cssValuePool().createValue(transform.m23(), CSSPrimitiveValue::CSS_NUMBER));
832         transformValue->append(cssValuePool().createValue(transform.m24(), CSSPrimitiveValue::CSS_NUMBER));
833
834         transformValue->append(cssValuePool().createValue(transform.m31(), CSSPrimitiveValue::CSS_NUMBER));
835         transformValue->append(cssValuePool().createValue(transform.m32(), CSSPrimitiveValue::CSS_NUMBER));
836         transformValue->append(cssValuePool().createValue(transform.m33(), CSSPrimitiveValue::CSS_NUMBER));
837         transformValue->append(cssValuePool().createValue(transform.m34(), CSSPrimitiveValue::CSS_NUMBER));
838
839         transformValue->append(zoomAdjustedNumberValue(transform.m41(), style));
840         transformValue->append(zoomAdjustedNumberValue(transform.m42(), style));
841         transformValue->append(zoomAdjustedNumberValue(transform.m43(), style));
842         transformValue->append(cssValuePool().createValue(transform.m44(), CSSPrimitiveValue::CSS_NUMBER));
843     }
844
845     return transformValue.releaseNonNull();
846 }
847
848 static PassRef<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle* style)
849 {
850     if (!renderer || !renderer->hasTransform() || !style->hasTransform())
851         return cssValuePool().createIdentifierValue(CSSValueNone);
852
853     FloatRect pixelSnappedRect;
854     if (is<RenderBox>(*renderer))
855         pixelSnappedRect = snapRectToDevicePixels(downcast<RenderBox>(*renderer).borderBoxRect(), renderer->document().deviceScaleFactor());
856
857     TransformationMatrix transform;
858     style->applyTransform(transform, pixelSnappedRect, RenderStyle::ExcludeTransformOrigin);
859     // Note that this does not flatten to an affine transform if ENABLE(3D_RENDERING) is off, by design.
860
861     // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
862     auto list = CSSValueList::createSpaceSeparated();
863     list.get().append(matrixTransformValue(transform, style));
864     return WTF::move(list);
865 }
866
867 static inline PassRef<CSSPrimitiveValue> adjustLengthForZoom(double length, const RenderStyle* style, AdjustPixelValuesForComputedStyle adjust)
868 {
869     return adjust == AdjustPixelValues ? zoomAdjustedPixelValue(length, style) : cssValuePool().createValue(length, CSSPrimitiveValue::CSS_PX);
870 }
871
872 static inline PassRef<CSSPrimitiveValue> adjustLengthForZoom(const Length& length, const RenderStyle* style, AdjustPixelValuesForComputedStyle adjust)
873 {
874     return adjust == AdjustPixelValues ? zoomAdjustedPixelValue(length.value(), style) : cssValuePool().createValue(length);
875 }
876
877 PassRef<CSSValue> ComputedStyleExtractor::valueForShadow(const ShadowData* shadow, CSSPropertyID propertyID, const RenderStyle* style, AdjustPixelValuesForComputedStyle adjust)
878 {
879     if (!shadow)
880         return cssValuePool().createIdentifierValue(CSSValueNone);
881
882     auto list = CSSValueList::createCommaSeparated();
883     for (const ShadowData* currShadowData = shadow; currShadowData; currShadowData = currShadowData->next()) {
884         RefPtr<CSSPrimitiveValue> x = adjustLengthForZoom(currShadowData->x(), style, adjust);
885         RefPtr<CSSPrimitiveValue> y = adjustLengthForZoom(currShadowData->y(), style, adjust);
886         RefPtr<CSSPrimitiveValue> blur = adjustLengthForZoom(currShadowData->radius(), style, adjust);
887         RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? PassRefPtr<CSSPrimitiveValue>() : adjustLengthForZoom(currShadowData->spread(), style, adjust);
888         RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || currShadowData->style() == Normal ? PassRefPtr<CSSPrimitiveValue>() : cssValuePool().createIdentifierValue(CSSValueInset);
889         RefPtr<CSSPrimitiveValue> color = cssValuePool().createColorValue(currShadowData->color().rgb());
890         list.get().prepend(CSSShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release()));
891     }
892     return WTF::move(list);
893 }
894
895 PassRef<CSSValue> ComputedStyleExtractor::valueForFilter(const RenderStyle* style, const FilterOperations& filterOperations, AdjustPixelValuesForComputedStyle adjust)
896 {
897     if (filterOperations.operations().isEmpty())
898         return cssValuePool().createIdentifierValue(CSSValueNone);
899
900     auto list = CSSValueList::createSpaceSeparated();
901
902     RefPtr<WebKitCSSFilterValue> filterValue;
903
904     Vector<RefPtr<FilterOperation>>::const_iterator end = filterOperations.operations().end();
905     for (Vector<RefPtr<FilterOperation>>::const_iterator it = filterOperations.operations().begin(); it != end; ++it) {
906         FilterOperation& filterOperation = **it;
907         switch (filterOperation.type()) {
908         case FilterOperation::REFERENCE: {
909             ReferenceFilterOperation& referenceOperation = downcast<ReferenceFilterOperation>(filterOperation);
910             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ReferenceFilterOperation);
911             filterValue->append(cssValuePool().createValue(referenceOperation.url(), CSSPrimitiveValue::CSS_URI));
912             break;
913         }
914         case FilterOperation::GRAYSCALE: {
915             BasicColorMatrixFilterOperation& colorMatrixOperation = downcast<BasicColorMatrixFilterOperation>(filterOperation);
916             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::GrayscaleFilterOperation);
917             filterValue->append(cssValuePool().createValue(colorMatrixOperation.amount(), CSSPrimitiveValue::CSS_NUMBER));
918             break;
919         }
920         case FilterOperation::SEPIA: {
921             BasicColorMatrixFilterOperation& colorMatrixOperation = downcast<BasicColorMatrixFilterOperation>(filterOperation);
922             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SepiaFilterOperation);
923             filterValue->append(cssValuePool().createValue(colorMatrixOperation.amount(), CSSPrimitiveValue::CSS_NUMBER));
924             break;
925         }
926         case FilterOperation::SATURATE: {
927             BasicColorMatrixFilterOperation& colorMatrixOperation = downcast<BasicColorMatrixFilterOperation>(filterOperation);
928             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SaturateFilterOperation);
929             filterValue->append(cssValuePool().createValue(colorMatrixOperation.amount(), CSSPrimitiveValue::CSS_NUMBER));
930             break;
931         }
932         case FilterOperation::HUE_ROTATE: {
933             BasicColorMatrixFilterOperation& colorMatrixOperation = downcast<BasicColorMatrixFilterOperation>(filterOperation);
934             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::HueRotateFilterOperation);
935             filterValue->append(cssValuePool().createValue(colorMatrixOperation.amount(), CSSPrimitiveValue::CSS_DEG));
936             break;
937         }
938         case FilterOperation::INVERT: {
939             BasicComponentTransferFilterOperation& componentTransferOperation = downcast<BasicComponentTransferFilterOperation>(filterOperation);
940             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::InvertFilterOperation);
941             filterValue->append(cssValuePool().createValue(componentTransferOperation.amount(), CSSPrimitiveValue::CSS_NUMBER));
942             break;
943         }
944         case FilterOperation::OPACITY: {
945             BasicComponentTransferFilterOperation& componentTransferOperation = downcast<BasicComponentTransferFilterOperation>(filterOperation);
946             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::OpacityFilterOperation);
947             filterValue->append(cssValuePool().createValue(componentTransferOperation.amount(), CSSPrimitiveValue::CSS_NUMBER));
948             break;
949         }
950         case FilterOperation::BRIGHTNESS: {
951             BasicComponentTransferFilterOperation& brightnessOperation = downcast<BasicComponentTransferFilterOperation>(filterOperation);
952             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BrightnessFilterOperation);
953             filterValue->append(cssValuePool().createValue(brightnessOperation.amount(), CSSPrimitiveValue::CSS_NUMBER));
954             break;
955         }
956         case FilterOperation::CONTRAST: {
957             BasicComponentTransferFilterOperation& contrastOperation = downcast<BasicComponentTransferFilterOperation>(filterOperation);
958             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ContrastFilterOperation);
959             filterValue->append(cssValuePool().createValue(contrastOperation.amount(), CSSPrimitiveValue::CSS_NUMBER));
960             break;
961         }
962         case FilterOperation::BLUR: {
963             BlurFilterOperation& blurOperation = downcast<BlurFilterOperation>(filterOperation);
964             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BlurFilterOperation);
965             filterValue->append(adjustLengthForZoom(blurOperation.stdDeviation(), style, adjust));
966             break;
967         }
968         case FilterOperation::DROP_SHADOW: {
969             DropShadowFilterOperation& dropShadowOperation = downcast<DropShadowFilterOperation>(filterOperation);
970             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::DropShadowFilterOperation);
971             // We want our computed style to look like that of a text shadow (has neither spread nor inset style).
972             ShadowData shadowData = ShadowData(dropShadowOperation.location(), dropShadowOperation.stdDeviation(), 0, Normal, false, dropShadowOperation.color());
973             filterValue->append(valueForShadow(&shadowData, CSSPropertyTextShadow, style, adjust));
974             break;
975         }
976         default:
977             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::UnknownFilterOperation);
978             break;
979         }
980         list.get().append(filterValue.releaseNonNull());
981     }
982
983     return WTF::move(list);
984 }
985
986 #if ENABLE(CSS_GRID_LAYOUT)
987 static PassRef<CSSValue> specifiedValueForGridTrackBreadth(const GridLength& trackBreadth, const RenderStyle* style)
988 {
989     if (!trackBreadth.isLength())
990         return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue::CSS_FR);
991
992     const Length& trackBreadthLength = trackBreadth.length();
993     if (trackBreadthLength.isAuto())
994         return cssValuePool().createIdentifierValue(CSSValueAuto);
995     return zoomAdjustedPixelValueForLength(trackBreadthLength, style);
996 }
997
998 static PassRef<CSSValue> specifiedValueForGridTrackSize(const GridTrackSize& trackSize, const RenderStyle* style)
999 {
1000     switch (trackSize.type()) {
1001     case LengthTrackSizing:
1002         return specifiedValueForGridTrackBreadth(trackSize.length(), style);
1003     default:
1004         ASSERT(trackSize.type() == MinMaxTrackSizing);
1005         RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSeparated();
1006         minMaxTrackBreadths->append(specifiedValueForGridTrackBreadth(trackSize.minTrackBreadth(), style));
1007         minMaxTrackBreadths->append(specifiedValueForGridTrackBreadth(trackSize.maxTrackBreadth(), style));
1008         return CSSFunctionValue::create("minmax(", minMaxTrackBreadths);
1009     }
1010 }
1011
1012 static void addValuesForNamedGridLinesAtIndex(const OrderedNamedGridLinesMap& orderedNamedGridLines, size_t i, CSSValueList& list)
1013 {
1014     const Vector<String>& namedGridLines = orderedNamedGridLines.get(i);
1015     if (namedGridLines.isEmpty())
1016         return;
1017
1018     RefPtr<CSSGridLineNamesValue> lineNames = CSSGridLineNamesValue::create();
1019     for (auto& name : namedGridLines)
1020         lineNames->append(cssValuePool().createValue(name, CSSPrimitiveValue::CSS_STRING));
1021     list.append(lineNames.releaseNonNull());
1022 }
1023
1024 static PassRef<CSSValue> valueForGridTrackList(GridTrackSizingDirection direction, RenderObject* renderer, const RenderStyle* style)
1025 {
1026     const Vector<GridTrackSize>& trackSizes = direction == ForColumns ? style->gridColumns() : style->gridRows();
1027     const OrderedNamedGridLinesMap& orderedNamedGridLines = direction == ForColumns ? style->orderedNamedGridColumnLines() : style->orderedNamedGridRowLines();
1028     bool isRenderGrid = is<RenderGrid>(renderer);
1029
1030     // Handle the 'none' case.
1031     bool trackListIsEmpty = trackSizes.isEmpty();
1032     if (isRenderGrid && trackListIsEmpty) {
1033         // For grids we should consider every listed track, whether implicitly or explicitly created. If we don't have
1034         // any explicit track and there are no children then there are no implicit tracks. We cannot simply check the
1035         // number of rows/columns in our internal grid representation because it's always at least 1x1 (see r143331).
1036         trackListIsEmpty = !downcast<RenderBlock>(*renderer).firstChild();
1037     }
1038
1039     if (trackListIsEmpty) {
1040         ASSERT(orderedNamedGridLines.isEmpty());
1041         return cssValuePool().createIdentifierValue(CSSValueNone);
1042     }
1043
1044     auto list = CSSValueList::createSpaceSeparated();
1045     if (isRenderGrid) {
1046         const Vector<LayoutUnit>& trackPositions = direction == ForColumns ? downcast<RenderGrid>(*renderer).columnPositions() : downcast<RenderGrid>(*renderer).rowPositions();
1047         // There are at least #tracks + 1 grid lines (trackPositions). Apart from that, the grid container can generate implicit grid tracks,
1048         // so we'll have more trackPositions than trackSizes as the latter only contain the explicit grid.
1049         ASSERT(trackPositions.size() - 1 >= trackSizes.size());
1050
1051         for (unsigned i = 0; i < trackPositions.size() - 1; ++i) {
1052             addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, list.get());
1053             list.get().append(zoomAdjustedPixelValue(trackPositions[i + 1] - trackPositions[i], style));
1054         }
1055     } else {
1056         for (unsigned i = 0; i < trackSizes.size(); ++i) {
1057             addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, list.get());
1058             list.get().append(specifiedValueForGridTrackSize(trackSizes[i], style));
1059         }
1060     }
1061
1062     // Those are the trailing <ident>* allowed in the syntax.
1063     addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, trackSizes.size(), list.get());
1064     return WTF::move(list);
1065 }
1066
1067 static PassRef<CSSValue> valueForGridPosition(const GridPosition& position)
1068 {
1069     if (position.isAuto())
1070         return cssValuePool().createIdentifierValue(CSSValueAuto);
1071
1072     if (position.isNamedGridArea())
1073         return cssValuePool().createValue(position.namedGridLine(), CSSPrimitiveValue::CSS_STRING);
1074
1075     auto list = CSSValueList::createSpaceSeparated();
1076     if (position.isSpan()) {
1077         list.get().append(cssValuePool().createIdentifierValue(CSSValueSpan));
1078         list.get().append(cssValuePool().createValue(position.spanPosition(), CSSPrimitiveValue::CSS_NUMBER));
1079     } else
1080         list.get().append(cssValuePool().createValue(position.integerPosition(), CSSPrimitiveValue::CSS_NUMBER));
1081
1082     if (!position.namedGridLine().isNull())
1083         list.get().append(cssValuePool().createValue(position.namedGridLine(), CSSPrimitiveValue::CSS_STRING));
1084     return WTF::move(list);
1085 }
1086 #endif
1087
1088 static PassRef<CSSValue> createTransitionPropertyValue(const Animation& animation)
1089 {
1090     if (animation.animationMode() == Animation::AnimateNone)
1091         return cssValuePool().createIdentifierValue(CSSValueNone);
1092     if (animation.animationMode() == Animation::AnimateAll)
1093         return cssValuePool().createIdentifierValue(CSSValueAll);
1094     return cssValuePool().createValue(getPropertyNameString(animation.property()), CSSPrimitiveValue::CSS_STRING);
1095 }
1096
1097 static PassRef<CSSValueList> getTransitionPropertyValue(const AnimationList* animList)
1098 {
1099     auto list = CSSValueList::createCommaSeparated();
1100     if (animList) {
1101         for (size_t i = 0; i < animList->size(); ++i)
1102             list.get().append(createTransitionPropertyValue(animList->animation(i)));
1103     } else
1104         list.get().append(cssValuePool().createIdentifierValue(CSSValueAll));
1105     return list;
1106 }
1107
1108 #if ENABLE(CSS_SCROLL_SNAP)
1109
1110 static PassRef<CSSValueList> scrollSnapDestination(RenderStyle& style, const LengthSize& destination)
1111 {
1112     auto list = CSSValueList::createSpaceSeparated();
1113     list.get().append(percentageOrZoomAdjustedValue(destination.width(), &style));
1114     list.get().append(percentageOrZoomAdjustedValue(destination.height(), &style));
1115     return list;
1116 }
1117
1118 static PassRef<CSSValue> scrollSnapPoints(RenderStyle& style, const ScrollSnapPoints& points)
1119 {
1120     if (points.usesElements)
1121         return cssValuePool().createIdentifierValue(CSSValueElements);
1122     auto list = CSSValueList::createSpaceSeparated();
1123     for (auto& point : points.offsets)
1124         list.get().append(percentageOrZoomAdjustedValue(point, &style));
1125     if (points.hasRepeat)
1126         list.get().append(cssValuePool().createValue(LengthRepeat::create(percentageOrZoomAdjustedValue(points.repeatOffset, &style))));
1127     return WTF::move(list);
1128 }
1129
1130 static PassRef<CSSValue> scrollSnapCoordinates(RenderStyle& style, const Vector<LengthSize>& coordinates)
1131 {
1132     if (coordinates.isEmpty())
1133         return cssValuePool().createIdentifierValue(CSSValueNone);
1134
1135     auto list = CSSValueList::createCommaSeparated();
1136
1137     for (auto& coordinate : coordinates) {
1138         auto pair = CSSValueList::createSpaceSeparated();
1139         pair.get().append(percentageOrZoomAdjustedValue(coordinate.width(), &style));
1140         pair.get().append(percentageOrZoomAdjustedValue(coordinate.height(), &style));
1141         list.get().append(WTF::move(pair));
1142     }
1143
1144     return WTF::move(list);
1145 }
1146
1147 #endif
1148
1149 static PassRef<CSSValueList> getDelayValue(const AnimationList* animList)
1150 {
1151     auto list = CSSValueList::createCommaSeparated();
1152     if (animList) {
1153         for (size_t i = 0; i < animList->size(); ++i)
1154             list.get().append(cssValuePool().createValue(animList->animation(i).delay(), CSSPrimitiveValue::CSS_S));
1155     } else {
1156         // Note that initialAnimationDelay() is used for both transitions and animations
1157         list.get().append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
1158     }
1159     return list;
1160 }
1161
1162 static PassRef<CSSValueList> getDurationValue(const AnimationList* animList)
1163 {
1164     auto list = CSSValueList::createCommaSeparated();
1165     if (animList) {
1166         for (size_t i = 0; i < animList->size(); ++i)
1167             list.get().append(cssValuePool().createValue(animList->animation(i).duration(), CSSPrimitiveValue::CSS_S));
1168     } else {
1169         // Note that initialAnimationDuration() is used for both transitions and animations
1170         list.get().append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
1171     }
1172     return list;
1173 }
1174
1175 static PassRef<CSSValue> createTimingFunctionValue(const TimingFunction* timingFunction)
1176 {
1177     switch (timingFunction->type()) {
1178     case TimingFunction::CubicBezierFunction: {
1179         const CubicBezierTimingFunction* bezierTimingFunction = static_cast<const CubicBezierTimingFunction*>(timingFunction);
1180         if (bezierTimingFunction->timingFunctionPreset() != CubicBezierTimingFunction::Custom) {
1181             CSSValueID valueId = CSSValueInvalid;
1182             switch (bezierTimingFunction->timingFunctionPreset()) {
1183             case CubicBezierTimingFunction::Ease:
1184                 valueId = CSSValueEase;
1185                 break;
1186             case CubicBezierTimingFunction::EaseIn:
1187                 valueId = CSSValueEaseIn;
1188                 break;
1189             case CubicBezierTimingFunction::EaseOut:
1190                 valueId = CSSValueEaseOut;
1191                 break;
1192             default:
1193                 ASSERT(bezierTimingFunction->timingFunctionPreset() == CubicBezierTimingFunction::EaseInOut);
1194                 valueId = CSSValueEaseInOut;
1195                 break;
1196             }
1197             return cssValuePool().createIdentifierValue(valueId);
1198         }
1199         return CSSCubicBezierTimingFunctionValue::create(bezierTimingFunction->x1(), bezierTimingFunction->y1(), bezierTimingFunction->x2(), bezierTimingFunction->y2());
1200     }
1201     case TimingFunction::StepsFunction: {
1202         const StepsTimingFunction* stepsTimingFunction = static_cast<const StepsTimingFunction*>(timingFunction);
1203         return CSSStepsTimingFunctionValue::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtStart());
1204     }
1205     default:
1206         ASSERT(timingFunction->type() == TimingFunction::LinearFunction);
1207         return cssValuePool().createIdentifierValue(CSSValueLinear);
1208     }
1209 }
1210
1211 static PassRef<CSSValueList> getTimingFunctionValue(const AnimationList* animList)
1212 {
1213     auto list = CSSValueList::createCommaSeparated();
1214     if (animList) {
1215         for (size_t i = 0; i < animList->size(); ++i)
1216             list.get().append(createTimingFunctionValue(animList->animation(i).timingFunction().get()));
1217     } else
1218         // Note that initialAnimationTimingFunction() is used for both transitions and animations
1219         list.get().append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
1220     return list;
1221 }
1222
1223 static PassRef<CSSValue> createLineBoxContainValue(unsigned lineBoxContain)
1224 {
1225     if (!lineBoxContain)
1226         return cssValuePool().createIdentifierValue(CSSValueNone);
1227     return CSSLineBoxContainValue::create(lineBoxContain);
1228 }
1229
1230 ComputedStyleExtractor::ComputedStyleExtractor(PassRefPtr<Node> node, bool allowVisitedStyle, PseudoId pseudoElementSpecifier)
1231     : m_node(node)
1232     , m_pseudoElementSpecifier(pseudoElementSpecifier)
1233     , m_allowVisitedStyle(allowVisitedStyle)
1234 {
1235 }
1236
1237
1238 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n, bool allowVisitedStyle, const String& pseudoElementName)
1239     : m_node(n)
1240     , m_allowVisitedStyle(allowVisitedStyle)
1241     , m_refCount(1)
1242 {
1243     unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoElementName[1] == ':' ? 2 : 1) : 0;
1244     m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoElementType(
1245     (pseudoElementName.substringSharingImpl(nameWithoutColonsStart))));
1246 }
1247
1248 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
1249 {
1250 }
1251
1252 void CSSComputedStyleDeclaration::ref()
1253 {
1254     ++m_refCount;
1255 }
1256
1257 void CSSComputedStyleDeclaration::deref()
1258 {
1259     ASSERT(m_refCount);
1260     if (!--m_refCount)
1261         delete this;
1262 }
1263
1264 String CSSComputedStyleDeclaration::cssText() const
1265 {
1266     StringBuilder result;
1267
1268     for (unsigned i = 0; i < numComputedProperties; i++) {
1269         if (i)
1270             result.append(' ');
1271         result.append(getPropertyName(computedProperties[i]));
1272         result.appendLiteral(": ");
1273         result.append(getPropertyValue(computedProperties[i]));
1274         result.append(';');
1275     }
1276
1277     return result.toString();
1278 }
1279
1280 void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
1281 {
1282     ec = NO_MODIFICATION_ALLOWED_ERR;
1283 }
1284
1285 static CSSValueID cssIdentifierForFontSizeKeyword(int keywordSize)
1286 {
1287     ASSERT_ARG(keywordSize, keywordSize);
1288     ASSERT_ARG(keywordSize, keywordSize <= 8);
1289     return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1);
1290 }
1291
1292 PassRefPtr<CSSPrimitiveValue> ComputedStyleExtractor::getFontSizeCSSValuePreferringKeyword() const
1293 {
1294     if (!m_node)
1295         return nullptr;
1296
1297     m_node->document().updateLayoutIgnorePendingStylesheets();
1298
1299     RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1300     if (!style)
1301         return nullptr;
1302
1303     if (int keywordSize = style->fontDescription().keywordSize())
1304         return cssValuePool().createIdentifierValue(cssIdentifierForFontSizeKeyword(keywordSize));
1305
1306     return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style.get());
1307 }
1308
1309 bool ComputedStyleExtractor::useFixedFontDefaultSize() const
1310 {
1311     if (!m_node)
1312         return false;
1313
1314     RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1315     if (!style)
1316         return false;
1317
1318     return style->fontDescription().useFixedDefaultSize();
1319 }
1320
1321
1322 static CSSValueID identifierForFamily(const AtomicString& family)
1323 {
1324     if (family == cursiveFamily)
1325         return CSSValueCursive;
1326     if (family == fantasyFamily)
1327         return CSSValueFantasy;
1328     if (family == monospaceFamily)
1329         return CSSValueMonospace;
1330     if (family == pictographFamily)
1331         return CSSValueWebkitPictograph;
1332     if (family == sansSerifFamily)
1333         return CSSValueSansSerif;
1334     if (family == serifFamily)
1335         return CSSValueSerif;
1336     return CSSValueInvalid;
1337 }
1338
1339 static PassRef<CSSPrimitiveValue> valueForFamily(const AtomicString& family)
1340 {
1341     if (CSSValueID familyIdentifier = identifierForFamily(family))
1342         return cssValuePool().createIdentifierValue(familyIdentifier);
1343     return cssValuePool().createValue(family.string(), CSSPrimitiveValue::CSS_STRING);
1344 }
1345
1346 static PassRef<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration)
1347 {
1348     // Blink value is ignored.
1349     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1350     if (textDecoration & TextDecorationUnderline)
1351         list->append(cssValuePool().createIdentifierValue(CSSValueUnderline));
1352     if (textDecoration & TextDecorationOverline)
1353         list->append(cssValuePool().createIdentifierValue(CSSValueOverline));
1354     if (textDecoration & TextDecorationLineThrough)
1355         list->append(cssValuePool().createIdentifierValue(CSSValueLineThrough));
1356 #if ENABLE(LETTERPRESS)
1357     if (textDecoration & TextDecorationLetterpress)
1358         list->append(cssValuePool().createIdentifierValue(CSSValueWebkitLetterpress));
1359 #endif
1360
1361     if (!list->length())
1362         return cssValuePool().createIdentifierValue(CSSValueNone);
1363     return list.releaseNonNull();
1364 }
1365
1366 static PassRef<CSSValue> renderTextDecorationStyleFlagsToCSSValue(TextDecorationStyle textDecorationStyle)
1367 {
1368     switch (textDecorationStyle) {
1369     case TextDecorationStyleSolid:
1370         return cssValuePool().createIdentifierValue(CSSValueSolid);
1371     case TextDecorationStyleDouble:
1372         return cssValuePool().createIdentifierValue(CSSValueDouble);
1373     case TextDecorationStyleDotted:
1374         return cssValuePool().createIdentifierValue(CSSValueDotted);
1375     case TextDecorationStyleDashed:
1376         return cssValuePool().createIdentifierValue(CSSValueDashed);
1377     case TextDecorationStyleWavy:
1378         return cssValuePool().createIdentifierValue(CSSValueWavy);
1379     }
1380
1381     ASSERT_NOT_REACHED();
1382     return cssValuePool().createExplicitInitialValue();
1383 }
1384
1385 static PassRef<CSSValue> renderTextDecorationSkipFlagsToCSSValue(TextDecorationSkip textDecorationSkip)
1386 {
1387     switch (textDecorationSkip) {
1388     case TextDecorationSkipAuto:
1389         return cssValuePool().createIdentifierValue(CSSValueAuto);
1390     case TextDecorationSkipNone:
1391         return cssValuePool().createIdentifierValue(CSSValueNone);
1392     case TextDecorationSkipInk:
1393         return cssValuePool().createIdentifierValue(CSSValueInk);
1394     case TextDecorationSkipObjects:
1395         return cssValuePool().createIdentifierValue(CSSValueObjects);
1396     }
1397
1398     ASSERT_NOT_REACHED();
1399     return cssValuePool().createExplicitInitialValue();
1400 }
1401
1402 static PassRef<CSSValue> renderEmphasisPositionFlagsToCSSValue(TextEmphasisPosition textEmphasisPosition)
1403 {
1404     ASSERT(!((textEmphasisPosition & TextEmphasisPositionOver) && (textEmphasisPosition & TextEmphasisPositionUnder)));
1405     ASSERT(!((textEmphasisPosition & TextEmphasisPositionLeft) && (textEmphasisPosition & TextEmphasisPositionRight)));
1406     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1407     if (textEmphasisPosition & TextEmphasisPositionOver)
1408         list->append(cssValuePool().createIdentifierValue(CSSValueOver));
1409     if (textEmphasisPosition & TextEmphasisPositionUnder)
1410         list->append(cssValuePool().createIdentifierValue(CSSValueUnder));
1411     if (textEmphasisPosition & TextEmphasisPositionLeft)
1412         list->append(cssValuePool().createIdentifierValue(CSSValueLeft));
1413     if (textEmphasisPosition & TextEmphasisPositionRight)
1414         list->append(cssValuePool().createIdentifierValue(CSSValueRight));
1415
1416     if (!list->length())
1417         return cssValuePool().createIdentifierValue(CSSValueNone);
1418     return list.releaseNonNull();
1419 }
1420
1421 static PassRef<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat)
1422 {
1423     // For backwards compatibility, if both values are equal, just return one of them. And
1424     // if the two values are equivalent to repeat-x or repeat-y, just return the shorthand.
1425     if (xRepeat == yRepeat)
1426         return cssValuePool().createValue(xRepeat);
1427     if (xRepeat == RepeatFill && yRepeat == NoRepeatFill)
1428         return cssValuePool().createIdentifierValue(CSSValueRepeatX);
1429     if (xRepeat == NoRepeatFill && yRepeat == RepeatFill)
1430         return cssValuePool().createIdentifierValue(CSSValueRepeatY);
1431
1432     auto list = CSSValueList::createSpaceSeparated();
1433     list.get().append(cssValuePool().createValue(xRepeat));
1434     list.get().append(cssValuePool().createValue(yRepeat));
1435     return WTF::move(list);
1436 }
1437
1438 static PassRef<CSSValue> fillSourceTypeToCSSValue(EMaskSourceType type)
1439 {
1440     switch (type) {
1441     case MaskAlpha:
1442         return cssValuePool().createValue(CSSValueAlpha);
1443     default:
1444         ASSERT(type == MaskLuminance);
1445         return cssValuePool().createValue(CSSValueLuminance);
1446     }
1447 }
1448
1449 static PassRef<CSSValue> fillSizeToCSSValue(const FillSize& fillSize, const RenderStyle* style)
1450 {
1451     if (fillSize.type == Contain)
1452         return cssValuePool().createIdentifierValue(CSSValueContain);
1453
1454     if (fillSize.type == Cover)
1455         return cssValuePool().createIdentifierValue(CSSValueCover);
1456
1457     if (fillSize.size.height().isAuto())
1458         return zoomAdjustedPixelValueForLength(fillSize.size.width(), style);
1459
1460     auto list = CSSValueList::createSpaceSeparated();
1461     list.get().append(zoomAdjustedPixelValueForLength(fillSize.size.width(), style));
1462     list.get().append(zoomAdjustedPixelValueForLength(fillSize.size.height(), style));
1463     return WTF::move(list);
1464 }
1465
1466 static PassRef<CSSValue> altTextToCSSValue(const RenderStyle* style)
1467 {
1468     return cssValuePool().createValue(style->contentAltText(), CSSPrimitiveValue::CSS_STRING);
1469 }
1470     
1471 static PassRef<CSSValueList> contentToCSSValue(const RenderStyle* style)
1472 {
1473     auto list = CSSValueList::createSpaceSeparated();
1474     for (const ContentData* contentData = style->contentData(); contentData; contentData = contentData->next()) {
1475         if (is<CounterContentData>(*contentData))
1476             list.get().append(cssValuePool().createValue(downcast<CounterContentData>(*contentData).counter().identifier(), CSSPrimitiveValue::CSS_COUNTER_NAME));
1477         else if (is<ImageContentData>(*contentData))
1478             list.get().append(*downcast<ImageContentData>(*contentData).image().cssValue());
1479         else if (is<TextContentData>(*contentData))
1480             list.get().append(cssValuePool().createValue(downcast<TextContentData>(*contentData).text(), CSSPrimitiveValue::CSS_STRING));
1481     }
1482     if (style->hasFlowFrom())
1483         list.get().append(cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING));
1484     return list;
1485 }
1486
1487 static PassRefPtr<CSSValue> counterToCSSValue(const RenderStyle* style, CSSPropertyID propertyID)
1488 {
1489     const CounterDirectiveMap* map = style->counterDirectives();
1490     if (!map)
1491         return nullptr;
1492
1493     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1494     for (CounterDirectiveMap::const_iterator it = map->begin(); it != map->end(); ++it) {
1495         list->append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
1496         short number = propertyID == CSSPropertyCounterIncrement ? it->value.incrementValue() : it->value.resetValue();
1497         list->append(cssValuePool().createValue((double)number, CSSPrimitiveValue::CSS_NUMBER));
1498     }
1499     return list.release();
1500 }
1501
1502 static void logUnimplementedPropertyID(CSSPropertyID propertyID)
1503 {
1504     static NeverDestroyed<HashSet<CSSPropertyID>> propertyIDSet;
1505     if (!propertyIDSet.get().add(propertyID).isNewEntry)
1506         return;
1507
1508     LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", getPropertyName(propertyID));
1509 }
1510
1511 static PassRef<CSSValueList> fontFamilyFromStyle(RenderStyle* style)
1512 {
1513     auto list = CSSValueList::createCommaSeparated();
1514     for (unsigned i = 0; i < style->font().familyCount(); ++i)
1515         list.get().append(valueForFamily(style->font().familyAt(i)));
1516     return list;
1517 }
1518
1519 static PassRef<CSSPrimitiveValue> lineHeightFromStyle(RenderStyle* style)
1520 {
1521     Length length = style->lineHeight();
1522     if (length.isNegative())
1523         return cssValuePool().createIdentifierValue(CSSValueNormal);
1524     if (length.isPercentNotCalculated()) {
1525         // This is imperfect, because it doesn't include the zoom factor and the real computation
1526         // for how high to be in pixels does include things like minimum font size and the zoom factor.
1527         // On the other hand, since font-size doesn't include the zoom factor, we really can't do
1528         // that here either.
1529         return zoomAdjustedPixelValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, style);
1530     }
1531     return zoomAdjustedPixelValue(floatValueForLength(length, 0), style);
1532 }
1533
1534 static PassRef<CSSPrimitiveValue> fontSizeFromStyle(RenderStyle* style)
1535 {
1536     return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style);
1537 }
1538
1539 static PassRef<CSSPrimitiveValue> fontStyleFromStyle(RenderStyle* style)
1540 {
1541     if (style->fontDescription().italic())
1542         return cssValuePool().createIdentifierValue(CSSValueItalic);
1543     return cssValuePool().createIdentifierValue(CSSValueNormal);
1544 }
1545
1546 static PassRef<CSSPrimitiveValue> fontVariantFromStyle(RenderStyle* style)
1547 {
1548     if (style->fontDescription().smallCaps())
1549         return cssValuePool().createIdentifierValue(CSSValueSmallCaps);
1550     return cssValuePool().createIdentifierValue(CSSValueNormal);
1551 }
1552
1553 static PassRef<CSSPrimitiveValue> fontWeightFromStyle(RenderStyle* style)
1554 {
1555     switch (style->fontDescription().weight()) {
1556     case FontWeight100:
1557         return cssValuePool().createIdentifierValue(CSSValue100);
1558     case FontWeight200:
1559         return cssValuePool().createIdentifierValue(CSSValue200);
1560     case FontWeight300:
1561         return cssValuePool().createIdentifierValue(CSSValue300);
1562     case FontWeightNormal:
1563         return cssValuePool().createIdentifierValue(CSSValueNormal);
1564     case FontWeight500:
1565         return cssValuePool().createIdentifierValue(CSSValue500);
1566     case FontWeight600:
1567         return cssValuePool().createIdentifierValue(CSSValue600);
1568     case FontWeightBold:
1569         return cssValuePool().createIdentifierValue(CSSValueBold);
1570     case FontWeight800:
1571         return cssValuePool().createIdentifierValue(CSSValue800);
1572     case FontWeight900:
1573         return cssValuePool().createIdentifierValue(CSSValue900);
1574     }
1575     ASSERT_NOT_REACHED();
1576     return cssValuePool().createIdentifierValue(CSSValueNormal);
1577 }
1578
1579 typedef const Length& (RenderStyle::*RenderStyleLengthGetter)() const;
1580 typedef LayoutUnit (RenderBoxModelObject::*RenderBoxComputedCSSValueGetter)() const;
1581
1582 template<RenderStyleLengthGetter lengthGetter, RenderBoxComputedCSSValueGetter computedCSSValueGetter>
1583 inline PassRefPtr<CSSValue> zoomAdjustedPaddingOrMarginPixelValue(RenderStyle* style, RenderObject* renderer)
1584 {
1585     Length unzoomzedLength = (style->*lengthGetter)();
1586     if (!is<RenderBox>(renderer) || unzoomzedLength.isFixed())
1587         return zoomAdjustedPixelValueForLength(unzoomzedLength, style);
1588     return zoomAdjustedPixelValue((downcast<RenderBox>(*renderer).*computedCSSValueGetter)(), style);
1589 }
1590
1591 template<RenderStyleLengthGetter lengthGetter>
1592 inline bool paddingOrMarginIsRendererDependent(RenderStyle* style, RenderObject* renderer)
1593 {
1594     if (!renderer || !renderer->isBox())
1595         return false;
1596     return !(style && (style->*lengthGetter)().isFixed());
1597 }
1598
1599 static bool isLayoutDependent(CSSPropertyID propertyID, RenderStyle* style, RenderObject* renderer)
1600 {
1601     switch (propertyID) {
1602     case CSSPropertyWidth:
1603     case CSSPropertyHeight:
1604 #if ENABLE(CSS_GRID_LAYOUT)
1605     case CSSPropertyWebkitGridTemplateColumns:
1606     case CSSPropertyWebkitGridTemplateRows:
1607 #endif
1608     case CSSPropertyWebkitPerspectiveOrigin:
1609     case CSSPropertyWebkitTransformOrigin:
1610     case CSSPropertyWebkitTransform:
1611     case CSSPropertyWebkitFilter:
1612 #if ENABLE(FILTERS_LEVEL_2)
1613     case CSSPropertyWebkitBackdropFilter:
1614 #endif
1615         return true;
1616     case CSSPropertyMargin: {
1617         if (!renderer || !renderer->isBox())
1618             return false;
1619         return !(style && style->marginTop().isFixed() && style->marginRight().isFixed()
1620             && style->marginBottom().isFixed() && style->marginLeft().isFixed());
1621     }
1622     case CSSPropertyMarginTop:
1623         return paddingOrMarginIsRendererDependent<&RenderStyle::marginTop>(style, renderer);
1624     case CSSPropertyMarginRight:
1625         return paddingOrMarginIsRendererDependent<&RenderStyle::marginRight>(style, renderer);
1626     case CSSPropertyMarginBottom:
1627         return paddingOrMarginIsRendererDependent<&RenderStyle::marginBottom>(style, renderer);
1628     case CSSPropertyMarginLeft:
1629         return paddingOrMarginIsRendererDependent<&RenderStyle::marginLeft>(style, renderer);
1630     case CSSPropertyPadding: {
1631         if (!renderer || !renderer->isBox())
1632             return false;
1633         return !(style && style->paddingTop().isFixed() && style->paddingRight().isFixed()
1634             && style->paddingBottom().isFixed() && style->paddingLeft().isFixed());
1635     }
1636     case CSSPropertyPaddingTop:
1637         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingTop>(style, renderer);
1638     case CSSPropertyPaddingRight:
1639         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingRight>(style, renderer);
1640     case CSSPropertyPaddingBottom:
1641         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingBottom>(style, renderer);
1642     case CSSPropertyPaddingLeft:
1643         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingLeft>(style, renderer); 
1644     default:
1645         return false;
1646     }
1647 }
1648
1649 Node* ComputedStyleExtractor::styledNode() const
1650 {
1651     if (!m_node)
1652         return nullptr;
1653     if (!is<Element>(*m_node))
1654         return m_node.get();
1655     Element& element = downcast<Element>(*m_node);
1656     PseudoElement* pseudoElement;
1657     if (m_pseudoElementSpecifier == BEFORE && (pseudoElement = element.beforePseudoElement()))
1658         return pseudoElement;
1659     if (m_pseudoElementSpecifier == AFTER && (pseudoElement = element.afterPseudoElement()))
1660         return pseudoElement;
1661     return &element;
1662 }
1663
1664 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1665 {
1666     return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).propertyValue(propertyID, updateLayout);
1667 }
1668
1669 PassRef<MutableStyleProperties> CSSComputedStyleDeclaration::copyProperties() const
1670 {
1671     return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).copyProperties();
1672 }
1673
1674 static inline bool nodeOrItsAncestorNeedsStyleRecalc(Node* styledNode)
1675 {
1676     if (styledNode->document().hasPendingForcedStyleRecalc())
1677         return true;
1678     for (Node* n = styledNode; n; n = n->parentNode()) {// FIXME: parentOrShadowHostNode() instead
1679         if (n->needsStyleRecalc())
1680             return true;
1681     }
1682     return false;
1683 }
1684
1685 static inline PassRefPtr<RenderStyle> computeRenderStyleForProperty(Node* styledNode, PseudoId pseudoElementSpecifier, CSSPropertyID propertyID)
1686 {
1687     RenderObject* renderer = styledNode->renderer();
1688
1689     if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
1690         AnimationUpdateBlock animationUpdateBlock(&renderer->animation());
1691         RefPtr<RenderStyle> style = renderer->animation().getAnimatedStyleForRenderer(downcast<RenderElement>(*renderer));
1692         if (pseudoElementSpecifier && !styledNode->isPseudoElement()) {
1693             // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
1694             return style->getCachedPseudoStyle(pseudoElementSpecifier);
1695         }
1696         return style.release();
1697     }
1698
1699     return styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : pseudoElementSpecifier);
1700 }
1701
1702 #if ENABLE(CSS_SHAPES)
1703 static PassRef<CSSValue> shapePropertyValue(const RenderStyle* style, const ShapeValue* shapeValue)
1704 {
1705     if (!shapeValue)
1706         return cssValuePool().createIdentifierValue(CSSValueNone);
1707
1708     if (shapeValue->type() == ShapeValue::Type::Box)
1709         return cssValuePool().createValue(shapeValue->cssBox());
1710
1711     if (shapeValue->type() == ShapeValue::Type::Image) {
1712         if (shapeValue->image())
1713             return *shapeValue->image()->cssValue();
1714         return cssValuePool().createIdentifierValue(CSSValueNone);
1715     }
1716
1717     ASSERT(shapeValue->type() == ShapeValue::Type::Shape);
1718
1719     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1720     list->append(valueForBasicShape(style, *shapeValue->shape()));
1721     if (shapeValue->cssBox() != BoxMissing)
1722         list->append(cssValuePool().createValue(shapeValue->cssBox()));
1723     return list.releaseNonNull();
1724 }
1725 #endif
1726
1727 PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1728 {
1729     Node* styledNode = this->styledNode();
1730     if (!styledNode)
1731         return nullptr;
1732
1733     RefPtr<RenderStyle> style;
1734     RenderObject* renderer = nullptr;
1735     bool forceFullLayout = false;
1736     if (updateLayout) {
1737         Document& document = styledNode->document();
1738
1739         if (nodeOrItsAncestorNeedsStyleRecalc(styledNode)) {
1740             document.updateStyleIfNeeded();
1741             // The style recalc could have caused the styled node to be discarded or replaced
1742             // if it was a PseudoElement so we need to update it.
1743             styledNode = this->styledNode();
1744         }
1745
1746         renderer = styledNode->renderer();
1747
1748         if (propertyID == CSSPropertyDisplay && !renderer && is<SVGElement>(*styledNode) && !downcast<SVGElement>(*styledNode).isValid())
1749             return nullptr;
1750
1751         style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID);
1752
1753         // FIXME: Some of these cases could be narrowed down or optimized better.
1754         forceFullLayout = isLayoutDependent(propertyID, style.get(), renderer)
1755             || styledNode->isInShadowTree()
1756             || (document.styleResolverIfExists() && document.styleResolverIfExists()->hasViewportDependentMediaQueries() && document.ownerElement());
1757
1758         if (forceFullLayout) {
1759             document.updateLayoutIgnorePendingStylesheets();
1760             styledNode = this->styledNode();
1761         }
1762     }
1763
1764     if (!updateLayout || forceFullLayout) {
1765         style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID);
1766         renderer = styledNode->renderer();
1767     }
1768
1769     if (!style)
1770         return nullptr;
1771
1772     propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction(), style->writingMode());
1773
1774     switch (propertyID) {
1775         case CSSPropertyInvalid:
1776             break;
1777
1778         case CSSPropertyBackgroundColor:
1779             return cssValuePool().createColorValue(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb());
1780         case CSSPropertyBackgroundImage:
1781         case CSSPropertyWebkitMaskImage: {
1782             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskImage ? style->maskLayers() : style->backgroundLayers();
1783             if (!layers)
1784                 return cssValuePool().createIdentifierValue(CSSValueNone);
1785
1786             if (!layers->next()) {
1787                 if (layers->image())
1788                     return layers->image()->cssValue();
1789
1790                 return cssValuePool().createIdentifierValue(CSSValueNone);
1791             }
1792
1793             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1794             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1795                 if (currLayer->image())
1796                     list->append(*currLayer->image()->cssValue());
1797                 else
1798                     list->append(cssValuePool().createIdentifierValue(CSSValueNone));
1799             }
1800             return list.release();
1801         }
1802         case CSSPropertyBackgroundSize:
1803         case CSSPropertyWebkitBackgroundSize:
1804         case CSSPropertyWebkitMaskSize: {
1805             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskSize ? style->maskLayers() : style->backgroundLayers();
1806             if (!layers->next())
1807                 return fillSizeToCSSValue(layers->size(), style.get());
1808
1809             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1810             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1811                 list->append(fillSizeToCSSValue(currLayer->size(), style.get()));
1812
1813             return list.release();
1814         }
1815         case CSSPropertyBackgroundRepeat:
1816         case CSSPropertyWebkitMaskRepeat: {
1817             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskRepeat ? style->maskLayers() : style->backgroundLayers();
1818             if (!layers->next())
1819                 return fillRepeatToCSSValue(layers->repeatX(), layers->repeatY());
1820
1821             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1822             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1823                 list->append(fillRepeatToCSSValue(currLayer->repeatX(), currLayer->repeatY()));
1824
1825             return list.release();
1826         }
1827         case CSSPropertyWebkitMaskSourceType: {
1828             const FillLayer* layers = style->maskLayers();
1829
1830             if (!layers)
1831                 return cssValuePool().createIdentifierValue(CSSValueNone);
1832
1833             if (!layers->next())
1834                 return fillSourceTypeToCSSValue(layers->maskSourceType());
1835
1836             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1837             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1838                 list->append(fillSourceTypeToCSSValue(currLayer->maskSourceType()));
1839
1840             return list.release();
1841         }
1842         case CSSPropertyWebkitBackgroundComposite:
1843         case CSSPropertyWebkitMaskComposite: {
1844             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskComposite ? style->maskLayers() : style->backgroundLayers();
1845             if (!layers->next())
1846                 return cssValuePool().createValue(layers->composite());
1847
1848             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1849             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1850                 list->append(cssValuePool().createValue(currLayer->composite()));
1851
1852             return list.release();
1853         }
1854         case CSSPropertyBackgroundAttachment: {
1855             const FillLayer* layers = style->backgroundLayers();
1856             if (!layers->next())
1857                 return cssValuePool().createValue(layers->attachment());
1858
1859             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1860             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1861                 list->append(cssValuePool().createValue(currLayer->attachment()));
1862
1863             return list.release();
1864         }
1865         case CSSPropertyBackgroundClip:
1866         case CSSPropertyBackgroundOrigin:
1867         case CSSPropertyWebkitBackgroundClip:
1868         case CSSPropertyWebkitBackgroundOrigin:
1869         case CSSPropertyWebkitMaskClip:
1870         case CSSPropertyWebkitMaskOrigin: {
1871             const FillLayer* layers = (propertyID == CSSPropertyWebkitMaskClip || propertyID == CSSPropertyWebkitMaskOrigin) ? style->maskLayers() : style->backgroundLayers();
1872             bool isClip = propertyID == CSSPropertyBackgroundClip || propertyID == CSSPropertyWebkitBackgroundClip || propertyID == CSSPropertyWebkitMaskClip;
1873             if (!layers->next()) {
1874                 EFillBox box = isClip ? layers->clip() : layers->origin();
1875                 return cssValuePool().createValue(box);
1876             }
1877
1878             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1879             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1880                 EFillBox box = isClip ? currLayer->clip() : currLayer->origin();
1881                 list->append(cssValuePool().createValue(box));
1882             }
1883
1884             return list.release();
1885         }
1886         case CSSPropertyBackgroundPosition:
1887         case CSSPropertyWebkitMaskPosition: {
1888             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPosition ? style->maskLayers() : style->backgroundLayers();
1889             if (!layers->next())
1890                 return createPositionListForLayer(propertyID, layers, style.get());
1891
1892             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1893             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1894                 list->append(createPositionListForLayer(propertyID, currLayer, style.get()));
1895             return list.release();
1896         }
1897         case CSSPropertyBackgroundPositionX:
1898         case CSSPropertyWebkitMaskPositionX: {
1899             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionX ? style->maskLayers() : style->backgroundLayers();
1900             if (!layers->next())
1901                 return cssValuePool().createValue(layers->xPosition());
1902
1903             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1904             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1905                 list->append(cssValuePool().createValue(currLayer->xPosition()));
1906
1907             return list.release();
1908         }
1909         case CSSPropertyBackgroundPositionY:
1910         case CSSPropertyWebkitMaskPositionY: {
1911             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionY ? style->maskLayers() : style->backgroundLayers();
1912             if (!layers->next())
1913                 return cssValuePool().createValue(layers->yPosition());
1914
1915             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1916             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1917                 list->append(cssValuePool().createValue(currLayer->yPosition()));
1918
1919             return list.release();
1920         }
1921         case CSSPropertyBorderCollapse:
1922             if (style->borderCollapse())
1923                 return cssValuePool().createIdentifierValue(CSSValueCollapse);
1924             return cssValuePool().createIdentifierValue(CSSValueSeparate);
1925         case CSSPropertyBorderSpacing: {
1926             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1927             list->append(zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get()));
1928             list->append(zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get()));
1929             return list.release();
1930         }
1931         case CSSPropertyWebkitBorderHorizontalSpacing:
1932             return zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get());
1933         case CSSPropertyWebkitBorderVerticalSpacing:
1934             return zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get());
1935         case CSSPropertyBorderImageSource:
1936             if (style->borderImageSource())
1937                 return style->borderImageSource()->cssValue();
1938             return cssValuePool().createIdentifierValue(CSSValueNone);
1939         case CSSPropertyBorderTopColor:
1940             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor());
1941         case CSSPropertyBorderRightColor:
1942             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor());
1943         case CSSPropertyBorderBottomColor:
1944             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor());
1945         case CSSPropertyBorderLeftColor:
1946             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor());
1947         case CSSPropertyBorderTopStyle:
1948             return cssValuePool().createValue(style->borderTopStyle());
1949         case CSSPropertyBorderRightStyle:
1950             return cssValuePool().createValue(style->borderRightStyle());
1951         case CSSPropertyBorderBottomStyle:
1952             return cssValuePool().createValue(style->borderBottomStyle());
1953         case CSSPropertyBorderLeftStyle:
1954             return cssValuePool().createValue(style->borderLeftStyle());
1955         case CSSPropertyBorderTopWidth:
1956             return zoomAdjustedPixelValue(style->borderTopWidth(), style.get());
1957         case CSSPropertyBorderRightWidth:
1958             return zoomAdjustedPixelValue(style->borderRightWidth(), style.get());
1959         case CSSPropertyBorderBottomWidth:
1960             return zoomAdjustedPixelValue(style->borderBottomWidth(), style.get());
1961         case CSSPropertyBorderLeftWidth:
1962             return zoomAdjustedPixelValue(style->borderLeftWidth(), style.get());
1963         case CSSPropertyBottom:
1964             return positionOffsetValue(style.get(), CSSPropertyBottom);
1965         case CSSPropertyWebkitBoxAlign:
1966             return cssValuePool().createValue(style->boxAlign());
1967 #if ENABLE(CSS_BOX_DECORATION_BREAK)
1968         case CSSPropertyWebkitBoxDecorationBreak:
1969             if (style->boxDecorationBreak() == DSLICE)
1970                 return cssValuePool().createIdentifierValue(CSSValueSlice);
1971         return cssValuePool().createIdentifierValue(CSSValueClone);
1972 #endif
1973         case CSSPropertyWebkitBoxDirection:
1974             return cssValuePool().createValue(style->boxDirection());
1975         case CSSPropertyWebkitBoxFlex:
1976             return cssValuePool().createValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
1977         case CSSPropertyWebkitBoxFlexGroup:
1978             return cssValuePool().createValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
1979         case CSSPropertyWebkitBoxLines:
1980             return cssValuePool().createValue(style->boxLines());
1981         case CSSPropertyWebkitBoxOrdinalGroup:
1982             return cssValuePool().createValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
1983         case CSSPropertyWebkitBoxOrient:
1984             return cssValuePool().createValue(style->boxOrient());
1985         case CSSPropertyWebkitBoxPack:
1986             return cssValuePool().createValue(style->boxPack());
1987         case CSSPropertyWebkitBoxReflect:
1988             return valueForReflection(style->boxReflect(), style.get());
1989         case CSSPropertyBoxShadow:
1990         case CSSPropertyWebkitBoxShadow:
1991             return valueForShadow(style->boxShadow(), propertyID, style.get());
1992         case CSSPropertyCaptionSide:
1993             return cssValuePool().createValue(style->captionSide());
1994         case CSSPropertyClear:
1995             return cssValuePool().createValue(style->clear());
1996         case CSSPropertyColor:
1997             return cssValuePool().createColorValue(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb());
1998         case CSSPropertyWebkitPrintColorAdjust:
1999             return cssValuePool().createValue(style->printColorAdjust());
2000         case CSSPropertyWebkitColumnAxis:
2001             return cssValuePool().createValue(style->columnAxis());
2002         case CSSPropertyColumnCount:
2003             if (style->hasAutoColumnCount())
2004                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2005             return cssValuePool().createValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
2006         case CSSPropertyColumnFill:
2007             return cssValuePool().createValue(style->columnFill());
2008         case CSSPropertyColumnGap:
2009             if (style->hasNormalColumnGap())
2010                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2011             return zoomAdjustedPixelValue(style->columnGap(), style.get());
2012         case CSSPropertyColumnProgression:
2013             return cssValuePool().createValue(style->columnProgression());
2014         case CSSPropertyColumnRuleColor:
2015             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor());
2016         case CSSPropertyColumnRuleStyle:
2017             return cssValuePool().createValue(style->columnRuleStyle());
2018         case CSSPropertyColumnRuleWidth:
2019             return zoomAdjustedPixelValue(style->columnRuleWidth(), style.get());
2020         case CSSPropertyColumnSpan:
2021             return cssValuePool().createIdentifierValue(style->columnSpan() ? CSSValueAll : CSSValueNone);
2022         case CSSPropertyWebkitColumnBreakAfter:
2023             return cssValuePool().createValue(style->columnBreakAfter());
2024         case CSSPropertyWebkitColumnBreakBefore:
2025             return cssValuePool().createValue(style->columnBreakBefore());
2026         case CSSPropertyWebkitColumnBreakInside:
2027             return cssValuePool().createValue(style->columnBreakInside());
2028         case CSSPropertyColumnWidth:
2029             if (style->hasAutoColumnWidth())
2030                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2031             return zoomAdjustedPixelValue(style->columnWidth(), style.get());
2032         case CSSPropertyTabSize:
2033             return cssValuePool().createValue(style->tabSize(), CSSPrimitiveValue::CSS_NUMBER);
2034 #if ENABLE(CSS_REGIONS)
2035         case CSSPropertyWebkitRegionBreakAfter:
2036             return cssValuePool().createValue(style->regionBreakAfter());
2037         case CSSPropertyWebkitRegionBreakBefore:
2038             return cssValuePool().createValue(style->regionBreakBefore());
2039         case CSSPropertyWebkitRegionBreakInside:
2040             return cssValuePool().createValue(style->regionBreakInside());
2041 #endif
2042         case CSSPropertyCursor: {
2043             RefPtr<CSSValueList> list;
2044             CursorList* cursors = style->cursors();
2045             if (cursors && cursors->size() > 0) {
2046                 list = CSSValueList::createCommaSeparated();
2047                 for (unsigned i = 0; i < cursors->size(); ++i)
2048                     if (StyleImage* image = cursors->at(i).image())
2049                         list->append(*image->cssValue());
2050             }
2051             auto value = cssValuePool().createValue(style->cursor());
2052             if (list) {
2053                 list->append(WTF::move(value));
2054                 return list.release();
2055             }
2056             return WTF::move(value);
2057         }
2058 #if ENABLE(CURSOR_VISIBILITY)
2059         case CSSPropertyWebkitCursorVisibility:
2060             return cssValuePool().createValue(style->cursorVisibility());
2061 #endif
2062         case CSSPropertyDirection:
2063             return cssValuePool().createValue(style->direction());
2064         case CSSPropertyDisplay:
2065             return cssValuePool().createValue(style->display());
2066         case CSSPropertyEmptyCells:
2067             return cssValuePool().createValue(style->emptyCells());
2068         case CSSPropertyAlignContent:
2069             return cssValuePool().createValue(style->alignContent());
2070         case CSSPropertyAlignItems:
2071             return cssValuePool().createValue(style->alignItems());
2072         case CSSPropertyAlignSelf:
2073             if (style->alignSelf() == AlignAuto) {
2074                 Node* parent = styledNode->parentNode();
2075                 if (parent && parent->computedStyle())
2076                     return cssValuePool().createValue(parent->computedStyle()->alignItems());
2077                 return cssValuePool().createValue(AlignStretch);
2078             }
2079             return cssValuePool().createValue(style->alignSelf());
2080         case CSSPropertyFlex:
2081             return getCSSPropertyValuesForShorthandProperties(flexShorthand());
2082         case CSSPropertyFlexBasis:
2083             return cssValuePool().createValue(style->flexBasis());
2084         case CSSPropertyFlexDirection:
2085             return cssValuePool().createValue(style->flexDirection());
2086         case CSSPropertyFlexFlow:
2087             return getCSSPropertyValuesForShorthandProperties(flexFlowShorthand());
2088         case CSSPropertyFlexGrow:
2089             return cssValuePool().createValue(style->flexGrow());
2090         case CSSPropertyFlexShrink:
2091             return cssValuePool().createValue(style->flexShrink());
2092         case CSSPropertyFlexWrap:
2093             return cssValuePool().createValue(style->flexWrap());
2094         case CSSPropertyJustifyContent:
2095             return cssValuePool().createValue(style->justifyContent());
2096         case CSSPropertyWebkitJustifySelf: {
2097             RefPtr<CSSValueList> result = CSSValueList::createSpaceSeparated();
2098             result->append(CSSPrimitiveValue::create(style->justifySelf()));
2099             if (style->justifySelf() >= JustifySelfCenter && style->justifySelfOverflowAlignment() != JustifySelfOverflowAlignmentDefault)
2100                 result->append(CSSPrimitiveValue::create(style->justifySelfOverflowAlignment()));
2101             return result.release();
2102         }
2103         case CSSPropertyOrder:
2104             return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
2105         case CSSPropertyFloat:
2106             if (style->display() != NONE && style->hasOutOfFlowPosition())
2107                 return cssValuePool().createIdentifierValue(CSSValueNone);
2108             return cssValuePool().createValue(style->floating());
2109         case CSSPropertyFont: {
2110             RefPtr<CSSFontValue> computedFont = CSSFontValue::create();
2111             computedFont->style = fontStyleFromStyle(style.get());
2112             computedFont->variant = fontVariantFromStyle(style.get());
2113             computedFont->weight = fontWeightFromStyle(style.get());
2114             computedFont->size = fontSizeFromStyle(style.get());
2115             computedFont->lineHeight = lineHeightFromStyle(style.get());
2116             computedFont->family = fontFamilyFromStyle(style.get());
2117             return computedFont.release();
2118         }
2119         case CSSPropertyFontFamily: {
2120             RefPtr<CSSValueList> fontFamilyList = fontFamilyFromStyle(style.get());
2121             // If there's only a single family, return that as a CSSPrimitiveValue.
2122             // NOTE: Gecko always returns this as a comma-separated CSSPrimitiveValue string.
2123             if (fontFamilyList->length() == 1)
2124                 return fontFamilyList->item(0);
2125             return fontFamilyList.release();
2126         }
2127         case CSSPropertyFontSize:
2128             return fontSizeFromStyle(style.get());
2129         case CSSPropertyFontStyle:
2130             return fontStyleFromStyle(style.get());
2131         case CSSPropertyFontVariant:
2132             return fontVariantFromStyle(style.get());
2133         case CSSPropertyFontWeight:
2134             return fontWeightFromStyle(style.get());
2135         case CSSPropertyWebkitFontFeatureSettings: {
2136             const FontFeatureSettings* featureSettings = style->fontDescription().featureSettings();
2137             if (!featureSettings || !featureSettings->size())
2138                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2139             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2140             for (unsigned i = 0; i < featureSettings->size(); ++i) {
2141                 const FontFeature& feature = featureSettings->at(i);
2142                 list->append(CSSFontFeatureValue::create(feature.tag(), feature.value()));
2143             }
2144             return list.release();
2145         }
2146 #if ENABLE(CSS_GRID_LAYOUT)
2147         case CSSPropertyWebkitGridAutoFlow: {
2148             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2149             ASSERT(style->isGridAutoFlowDirectionRow() || style->isGridAutoFlowDirectionColumn());
2150             if (style->isGridAutoFlowDirectionRow())
2151                 list->append(cssValuePool().createIdentifierValue(CSSValueRow));
2152             else
2153                 list->append(cssValuePool().createIdentifierValue(CSSValueColumn));
2154
2155             if (style->isGridAutoFlowAlgorithmDense())
2156                 list->append(cssValuePool().createIdentifierValue(CSSValueDense));
2157             else if (style->isGridAutoFlowAlgorithmStack())
2158                 list->append(cssValuePool().createIdentifierValue(CSSValueStack));
2159
2160             return list.release();
2161         }
2162
2163         // Specs mention that getComputedStyle() should return the used value of the property instead of the computed
2164         // one for grid-definition-{rows|columns} but not for the grid-auto-{rows|columns} as things like
2165         // grid-auto-columns: 2fr; cannot be resolved to a value in pixels as the '2fr' means very different things
2166         // depending on the size of the explicit grid or the number of implicit tracks added to the grid. See
2167         // http://lists.w3.org/Archives/Public/www-style/2013Nov/0014.html
2168         case CSSPropertyWebkitGridAutoColumns:
2169             return specifiedValueForGridTrackSize(style->gridAutoColumns(), style.get());
2170         case CSSPropertyWebkitGridAutoRows:
2171             return specifiedValueForGridTrackSize(style->gridAutoRows(), style.get());
2172
2173         case CSSPropertyWebkitGridTemplateColumns:
2174             return valueForGridTrackList(ForColumns, renderer, style.get());
2175         case CSSPropertyWebkitGridTemplateRows:
2176             return valueForGridTrackList(ForRows, renderer, style.get());
2177
2178         case CSSPropertyWebkitGridColumnStart:
2179             return valueForGridPosition(style->gridItemColumnStart());
2180         case CSSPropertyWebkitGridColumnEnd:
2181             return valueForGridPosition(style->gridItemColumnEnd());
2182         case CSSPropertyWebkitGridRowStart:
2183             return valueForGridPosition(style->gridItemRowStart());
2184         case CSSPropertyWebkitGridRowEnd:
2185             return valueForGridPosition(style->gridItemRowEnd());
2186         case CSSPropertyWebkitGridArea:
2187             return getCSSPropertyValuesForGridShorthand(webkitGridAreaShorthand());
2188         case CSSPropertyWebkitGridTemplate:
2189             return getCSSPropertyValuesForGridShorthand(webkitGridTemplateShorthand());
2190         case CSSPropertyWebkitGrid:
2191             return getCSSPropertyValuesForGridShorthand(webkitGridShorthand());
2192         case CSSPropertyWebkitGridColumn:
2193             return getCSSPropertyValuesForGridShorthand(webkitGridColumnShorthand());
2194         case CSSPropertyWebkitGridRow:
2195             return getCSSPropertyValuesForGridShorthand(webkitGridRowShorthand());
2196
2197         case CSSPropertyWebkitGridTemplateAreas:
2198             if (!style->namedGridAreaRowCount()) {
2199                 ASSERT(!style->namedGridAreaColumnCount());
2200                 return cssValuePool().createIdentifierValue(CSSValueNone);
2201             }
2202
2203             return CSSGridTemplateAreasValue::create(style->namedGridArea(), style->namedGridAreaRowCount(), style->namedGridAreaColumnCount());
2204 #endif /* ENABLE(CSS_GRID_LAYOUT) */
2205         case CSSPropertyHeight:
2206             if (renderer && !renderer->isRenderSVGModelObject()) {
2207                 // According to http://www.w3.org/TR/CSS2/visudet.html#the-height-property,
2208                 // the "height" property does not apply for non-replaced inline elements.
2209                 if (!renderer->isReplaced() && renderer->isInline())
2210                     return cssValuePool().createIdentifierValue(CSSValueAuto);
2211                 return zoomAdjustedPixelValue(sizingBox(*renderer).height(), style.get());
2212             }
2213             return zoomAdjustedPixelValueForLength(style->height(), style.get());
2214         case CSSPropertyWebkitHyphens:
2215             return cssValuePool().createValue(style->hyphens());
2216         case CSSPropertyWebkitHyphenateCharacter:
2217             if (style->hyphenationString().isNull())
2218                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2219             return cssValuePool().createValue(style->hyphenationString(), CSSPrimitiveValue::CSS_STRING);
2220         case CSSPropertyWebkitHyphenateLimitAfter:
2221             if (style->hyphenationLimitAfter() < 0)
2222                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
2223             return CSSPrimitiveValue::create(style->hyphenationLimitAfter(), CSSPrimitiveValue::CSS_NUMBER);
2224         case CSSPropertyWebkitHyphenateLimitBefore:
2225             if (style->hyphenationLimitBefore() < 0)
2226                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
2227             return CSSPrimitiveValue::create(style->hyphenationLimitBefore(), CSSPrimitiveValue::CSS_NUMBER);
2228         case CSSPropertyWebkitHyphenateLimitLines:
2229             if (style->hyphenationLimitLines() < 0)
2230                 return CSSPrimitiveValue::createIdentifier(CSSValueNoLimit);
2231             return CSSPrimitiveValue::create(style->hyphenationLimitLines(), CSSPrimitiveValue::CSS_NUMBER);
2232         case CSSPropertyWebkitBorderFit:
2233             if (style->borderFit() == BorderFitBorder)
2234                 return cssValuePool().createIdentifierValue(CSSValueBorder);
2235             return cssValuePool().createIdentifierValue(CSSValueLines);
2236 #if ENABLE(CSS_IMAGE_ORIENTATION)
2237         case CSSPropertyImageOrientation:
2238             return cssValuePool().createValue(style->imageOrientation());
2239 #endif
2240         case CSSPropertyImageRendering:
2241             return CSSPrimitiveValue::create(style->imageRendering());
2242 #if ENABLE(CSS_IMAGE_RESOLUTION)
2243         case CSSPropertyImageResolution:
2244             return cssValuePool().createValue(style->imageResolution(), CSSPrimitiveValue::CSS_DPPX);
2245 #endif
2246         case CSSPropertyLeft:
2247             return positionOffsetValue(style.get(), CSSPropertyLeft);
2248         case CSSPropertyLetterSpacing:
2249             if (!style->letterSpacing())
2250                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2251             return zoomAdjustedPixelValue(style->letterSpacing(), style.get());
2252         case CSSPropertyWebkitLineClamp:
2253             if (style->lineClamp().isNone())
2254                 return cssValuePool().createIdentifierValue(CSSValueNone);
2255             return cssValuePool().createValue(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
2256         case CSSPropertyLineHeight:
2257             return lineHeightFromStyle(style.get());
2258         case CSSPropertyListStyleImage:
2259             if (style->listStyleImage())
2260                 return style->listStyleImage()->cssValue();
2261             return cssValuePool().createIdentifierValue(CSSValueNone);
2262         case CSSPropertyListStylePosition:
2263             return cssValuePool().createValue(style->listStylePosition());
2264         case CSSPropertyListStyleType:
2265             return cssValuePool().createValue(style->listStyleType());
2266         case CSSPropertyWebkitLocale:
2267             if (style->locale().isNull())
2268                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2269             return cssValuePool().createValue(style->locale(), CSSPrimitiveValue::CSS_STRING);
2270         case CSSPropertyMarginTop:
2271             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginTop, &RenderBoxModelObject::marginTop>(style.get(), renderer);
2272         case CSSPropertyMarginRight: {
2273             Length marginRight = style->marginRight();
2274             if (marginRight.isFixed() || !is<RenderBox>(renderer))
2275                 return zoomAdjustedPixelValueForLength(marginRight, style.get());
2276             float value;
2277             if (marginRight.isPercent()) {
2278                 // RenderBox gives a marginRight() that is the distance between the right-edge of the child box
2279                 // and the right-edge of the containing box, when display == BLOCK. Let's calculate the absolute
2280                 // value of the specified margin-right % instead of relying on RenderBox's marginRight() value.
2281                 value = minimumValueForLength(marginRight, downcast<RenderBox>(*renderer).containingBlockLogicalWidthForContent());
2282             } else
2283                 value = downcast<RenderBox>(*renderer).marginRight();
2284             return zoomAdjustedPixelValue(value, style.get());
2285         }
2286         case CSSPropertyMarginBottom:
2287             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginBottom, &RenderBoxModelObject::marginBottom>(style.get(), renderer);
2288         case CSSPropertyMarginLeft:
2289             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginLeft, &RenderBoxModelObject::marginLeft>(style.get(), renderer);
2290         case CSSPropertyWebkitMarqueeDirection:
2291             return cssValuePool().createValue(style->marqueeDirection());
2292         case CSSPropertyWebkitMarqueeIncrement:
2293             return cssValuePool().createValue(style->marqueeIncrement());
2294         case CSSPropertyWebkitMarqueeRepetition:
2295             if (style->marqueeLoopCount() < 0)
2296                 return cssValuePool().createIdentifierValue(CSSValueInfinite);
2297             return cssValuePool().createValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
2298         case CSSPropertyWebkitMarqueeStyle:
2299             return cssValuePool().createValue(style->marqueeBehavior());
2300         case CSSPropertyWebkitUserModify:
2301             return cssValuePool().createValue(style->userModify());
2302         case CSSPropertyMaxHeight: {
2303             const Length& maxHeight = style->maxHeight();
2304             if (maxHeight.isUndefined())
2305                 return cssValuePool().createIdentifierValue(CSSValueNone);
2306             return zoomAdjustedPixelValueForLength(maxHeight, style.get());
2307         }
2308         case CSSPropertyMaxWidth: {
2309             const Length& maxWidth = style->maxWidth();
2310             if (maxWidth.isUndefined())
2311                 return cssValuePool().createIdentifierValue(CSSValueNone);
2312             return zoomAdjustedPixelValueForLength(maxWidth, style.get());
2313         }
2314         case CSSPropertyMinHeight:
2315             // FIXME: For flex-items, min-height:auto should compute to min-content.
2316             if (style->minHeight().isAuto())
2317                 return zoomAdjustedPixelValue(0, style.get());
2318             return zoomAdjustedPixelValueForLength(style->minHeight(), style.get());
2319         case CSSPropertyMinWidth:
2320             // FIXME: For flex-items, min-width:auto should compute to min-content.
2321             if (style->minWidth().isAuto())
2322                 return zoomAdjustedPixelValue(0, style.get());
2323             return zoomAdjustedPixelValueForLength(style->minWidth(), style.get());
2324         case CSSPropertyObjectFit:
2325             return cssValuePool().createValue(style->objectFit());
2326         case CSSPropertyOpacity:
2327             return cssValuePool().createValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
2328         case CSSPropertyOrphans:
2329             if (style->hasAutoOrphans())
2330                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2331             return cssValuePool().createValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
2332         case CSSPropertyOutlineColor:
2333             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor());
2334         case CSSPropertyOutlineOffset:
2335             return zoomAdjustedPixelValue(style->outlineOffset(), style.get());
2336         case CSSPropertyOutlineStyle:
2337             if (style->outlineStyleIsAuto())
2338                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2339             return cssValuePool().createValue(style->outlineStyle());
2340         case CSSPropertyOutlineWidth:
2341             return zoomAdjustedPixelValue(style->outlineWidth(), style.get());
2342         case CSSPropertyOverflow:
2343             return cssValuePool().createValue(std::max(style->overflowX(), style->overflowY()));
2344         case CSSPropertyOverflowWrap:
2345             return cssValuePool().createValue(style->overflowWrap());
2346         case CSSPropertyOverflowX:
2347             return cssValuePool().createValue(style->overflowX());
2348         case CSSPropertyOverflowY:
2349             return cssValuePool().createValue(style->overflowY());
2350         case CSSPropertyPaddingTop:
2351             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingTop, &RenderBoxModelObject::computedCSSPaddingTop>(style.get(), renderer);
2352         case CSSPropertyPaddingRight:
2353             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingRight, &RenderBoxModelObject::computedCSSPaddingRight>(style.get(), renderer);
2354         case CSSPropertyPaddingBottom:
2355             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingBottom, &RenderBoxModelObject::computedCSSPaddingBottom>(style.get(), renderer);
2356         case CSSPropertyPaddingLeft:
2357             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingLeft, &RenderBoxModelObject::computedCSSPaddingLeft>(style.get(), renderer);
2358         case CSSPropertyPageBreakAfter:
2359             return cssValuePool().createValue(style->pageBreakAfter());
2360         case CSSPropertyPageBreakBefore:
2361             return cssValuePool().createValue(style->pageBreakBefore());
2362         case CSSPropertyPageBreakInside: {
2363             EPageBreak pageBreak = style->pageBreakInside();
2364             ASSERT(pageBreak != PBALWAYS);
2365             if (pageBreak == PBALWAYS)
2366                 return nullptr;
2367             return cssValuePool().createValue(style->pageBreakInside());
2368         }
2369         case CSSPropertyPosition:
2370             return cssValuePool().createValue(style->position());
2371         case CSSPropertyRight:
2372             return positionOffsetValue(style.get(), CSSPropertyRight);
2373         case CSSPropertyWebkitRubyPosition:
2374             return cssValuePool().createValue(style->rubyPosition());
2375         case CSSPropertyTableLayout:
2376             return cssValuePool().createValue(style->tableLayout());
2377         case CSSPropertyTextAlign:
2378             return cssValuePool().createValue(style->textAlign());
2379         case CSSPropertyTextDecoration:
2380             return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2381 #if ENABLE(CSS3_TEXT)
2382         case CSSPropertyWebkitTextAlignLast:
2383             return cssValuePool().createValue(style->textAlignLast());
2384         case CSSPropertyWebkitTextJustify:
2385             return cssValuePool().createValue(style->textJustify());
2386 #endif // CSS3_TEXT
2387         case CSSPropertyWebkitTextDecoration:
2388             return getCSSPropertyValuesForShorthandProperties(webkitTextDecorationShorthand());
2389         case CSSPropertyWebkitTextDecorationLine:
2390             return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2391         case CSSPropertyWebkitTextDecorationStyle:
2392             return renderTextDecorationStyleFlagsToCSSValue(style->textDecorationStyle());
2393         case CSSPropertyWebkitTextDecorationColor:
2394             return currentColorOrValidColor(style.get(), style->textDecorationColor());
2395         case CSSPropertyWebkitTextDecorationSkip:
2396             return renderTextDecorationSkipFlagsToCSSValue(style->textDecorationSkip());
2397         case CSSPropertyWebkitTextUnderlinePosition:
2398             return cssValuePool().createValue(style->textUnderlinePosition());
2399         case CSSPropertyWebkitTextDecorationsInEffect:
2400             return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect());
2401         case CSSPropertyWebkitTextFillColor:
2402             return currentColorOrValidColor(style.get(), style->textFillColor());
2403         case CSSPropertyWebkitTextEmphasisColor:
2404             return currentColorOrValidColor(style.get(), style->textEmphasisColor());
2405         case CSSPropertyWebkitTextEmphasisPosition:
2406             return renderEmphasisPositionFlagsToCSSValue(style->textEmphasisPosition());
2407         case CSSPropertyWebkitTextEmphasisStyle:
2408             switch (style->textEmphasisMark()) {
2409             case TextEmphasisMarkNone:
2410                 return cssValuePool().createIdentifierValue(CSSValueNone);
2411             case TextEmphasisMarkCustom:
2412                 return cssValuePool().createValue(style->textEmphasisCustomMark(), CSSPrimitiveValue::CSS_STRING);
2413             case TextEmphasisMarkAuto:
2414                 ASSERT_NOT_REACHED();
2415 #if ASSERT_DISABLED
2416                 FALLTHROUGH;
2417 #endif
2418             case TextEmphasisMarkDot:
2419             case TextEmphasisMarkCircle:
2420             case TextEmphasisMarkDoubleCircle:
2421             case TextEmphasisMarkTriangle:
2422             case TextEmphasisMarkSesame: {
2423                 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2424                 list->append(cssValuePool().createValue(style->textEmphasisFill()));
2425                 list->append(cssValuePool().createValue(style->textEmphasisMark()));
2426                 return list.release();
2427             }
2428             }
2429         case CSSPropertyTextIndent: {
2430             // If CSS3_TEXT is disabled or text-indent has only one value(<length> | <percentage>),
2431             // getPropertyCSSValue() returns CSSValue.
2432             RefPtr<CSSValue> textIndent = zoomAdjustedPixelValueForLength(style->textIndent(), style.get());
2433 #if ENABLE(CSS3_TEXT)
2434             // If CSS3_TEXT is enabled and text-indent has -webkit-each-line or -webkit-hanging,
2435             // getPropertyCSSValue() returns CSSValueList.
2436             if (style->textIndentLine() == TextIndentEachLine || style->textIndentType() == TextIndentHanging) {
2437                 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2438                 list->append(textIndent.releaseNonNull());
2439                 if (style->textIndentLine() == TextIndentEachLine)
2440                     list->append(cssValuePool().createIdentifierValue(CSSValueWebkitEachLine));
2441                 if (style->textIndentType() == TextIndentHanging)
2442                     list->append(cssValuePool().createIdentifierValue(CSSValueWebkitHanging));
2443                 return list.release();
2444             }
2445 #endif
2446             return textIndent.release();
2447         }
2448         case CSSPropertyTextShadow:
2449             return valueForShadow(style->textShadow(), propertyID, style.get());
2450         case CSSPropertyTextRendering:
2451             return cssValuePool().createValue(style->fontDescription().textRenderingMode());
2452         case CSSPropertyTextOverflow:
2453             if (style->textOverflow())
2454                 return cssValuePool().createIdentifierValue(CSSValueEllipsis);
2455             return cssValuePool().createIdentifierValue(CSSValueClip);
2456         case CSSPropertyWebkitTextSecurity:
2457             return cssValuePool().createValue(style->textSecurity());
2458 #if ENABLE(IOS_TEXT_AUTOSIZING)
2459         case CSSPropertyWebkitTextSizeAdjust:
2460             if (style->textSizeAdjust().isAuto())
2461                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2462             if (style->textSizeAdjust().isNone())
2463                 return cssValuePool().createIdentifierValue(CSSValueNone);
2464             return CSSPrimitiveValue::create(style->textSizeAdjust().percentage(), CSSPrimitiveValue::CSS_PERCENTAGE);
2465 #endif
2466         case CSSPropertyWebkitTextStrokeColor:
2467             return currentColorOrValidColor(style.get(), style->textStrokeColor());
2468         case CSSPropertyWebkitTextStrokeWidth:
2469             return zoomAdjustedPixelValue(style->textStrokeWidth(), style.get());
2470         case CSSPropertyTextTransform:
2471             return cssValuePool().createValue(style->textTransform());
2472         case CSSPropertyTop:
2473             return positionOffsetValue(style.get(), CSSPropertyTop);
2474         case CSSPropertyUnicodeBidi:
2475             return cssValuePool().createValue(style->unicodeBidi());
2476         case CSSPropertyVerticalAlign:
2477             switch (style->verticalAlign()) {
2478                 case BASELINE:
2479                     return cssValuePool().createIdentifierValue(CSSValueBaseline);
2480                 case MIDDLE:
2481                     return cssValuePool().createIdentifierValue(CSSValueMiddle);
2482                 case SUB:
2483                     return cssValuePool().createIdentifierValue(CSSValueSub);
2484                 case SUPER:
2485                     return cssValuePool().createIdentifierValue(CSSValueSuper);
2486                 case TEXT_TOP:
2487                     return cssValuePool().createIdentifierValue(CSSValueTextTop);
2488                 case TEXT_BOTTOM:
2489                     return cssValuePool().createIdentifierValue(CSSValueTextBottom);
2490                 case TOP:
2491                     return cssValuePool().createIdentifierValue(CSSValueTop);
2492                 case BOTTOM:
2493                     return cssValuePool().createIdentifierValue(CSSValueBottom);
2494                 case BASELINE_MIDDLE:
2495                     return cssValuePool().createIdentifierValue(CSSValueWebkitBaselineMiddle);
2496                 case LENGTH:
2497                     return cssValuePool().createValue(style->verticalAlignLength());
2498             }
2499             ASSERT_NOT_REACHED();
2500             return nullptr;
2501         case CSSPropertyVisibility:
2502             return cssValuePool().createValue(style->visibility());
2503         case CSSPropertyWhiteSpace:
2504             return cssValuePool().createValue(style->whiteSpace());
2505         case CSSPropertyWidows:
2506             if (style->hasAutoWidows())
2507                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2508             return cssValuePool().createValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
2509         case CSSPropertyWidth:
2510             if (renderer && !renderer->isRenderSVGModelObject()) {
2511                 // According to http://www.w3.org/TR/CSS2/visudet.html#the-width-property,
2512                 // the "width" property does not apply for non-replaced inline elements.
2513                 if (!renderer->isReplaced() && renderer->isInline())
2514                     return cssValuePool().createIdentifierValue(CSSValueAuto);
2515                 return zoomAdjustedPixelValue(sizingBox(*renderer).width(), style.get());
2516             }
2517             return zoomAdjustedPixelValueForLength(style->width(), style.get());
2518         case CSSPropertyWordBreak:
2519             return cssValuePool().createValue(style->wordBreak());
2520         case CSSPropertyWordSpacing:
2521             return zoomAdjustedPixelValue(style->font().wordSpacing(), style.get());
2522         case CSSPropertyWordWrap:
2523             return cssValuePool().createValue(style->overflowWrap());
2524         case CSSPropertyWebkitLineBreak:
2525             return cssValuePool().createValue(style->lineBreak());
2526         case CSSPropertyWebkitNbspMode:
2527             return cssValuePool().createValue(style->nbspMode());
2528         case CSSPropertyResize:
2529             return cssValuePool().createValue(style->resize());
2530         case CSSPropertyWebkitFontKerning:
2531             return cssValuePool().createValue(style->fontDescription().kerning());
2532         case CSSPropertyWebkitFontSmoothing:
2533             return cssValuePool().createValue(style->fontDescription().fontSmoothing());
2534         case CSSPropertyWebkitFontVariantLigatures: {
2535             FontDescription::LigaturesState commonLigaturesState = style->fontDescription().commonLigaturesState();
2536             FontDescription::LigaturesState discretionaryLigaturesState = style->fontDescription().discretionaryLigaturesState();
2537             FontDescription::LigaturesState historicalLigaturesState = style->fontDescription().historicalLigaturesState();
2538             if (commonLigaturesState == FontDescription::NormalLigaturesState && discretionaryLigaturesState == FontDescription::NormalLigaturesState
2539                 && historicalLigaturesState == FontDescription::NormalLigaturesState)
2540                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2541
2542             RefPtr<CSSValueList> valueList = CSSValueList::createSpaceSeparated();
2543             if (commonLigaturesState != FontDescription::NormalLigaturesState)
2544                 valueList->append(cssValuePool().createIdentifierValue(commonLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoCommonLigatures : CSSValueCommonLigatures));
2545             if (discretionaryLigaturesState != FontDescription::NormalLigaturesState)
2546                 valueList->append(cssValuePool().createIdentifierValue(discretionaryLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoDiscretionaryLigatures : CSSValueDiscretionaryLigatures));
2547             if (historicalLigaturesState != FontDescription::NormalLigaturesState)
2548                 valueList->append(cssValuePool().createIdentifierValue(historicalLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoHistoricalLigatures : CSSValueHistoricalLigatures));
2549             return valueList;
2550         }
2551         case CSSPropertyZIndex:
2552             if (style->hasAutoZIndex())
2553                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2554             return cssValuePool().createValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
2555         case CSSPropertyZoom:
2556             return cssValuePool().createValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
2557         case CSSPropertyBoxSizing:
2558             if (style->boxSizing() == CONTENT_BOX)
2559                 return cssValuePool().createIdentifierValue(CSSValueContentBox);
2560             return cssValuePool().createIdentifierValue(CSSValueBorderBox);
2561 #if ENABLE(DASHBOARD_SUPPORT)
2562         case CSSPropertyWebkitDashboardRegion:
2563         {
2564             const Vector<StyleDashboardRegion>& regions = style->dashboardRegions();
2565             unsigned count = regions.size();
2566             if (count == 1 && regions[0].type == StyleDashboardRegion::None)
2567                 return cssValuePool().createIdentifierValue(CSSValueNone);
2568
2569             RefPtr<DashboardRegion> firstRegion;
2570             DashboardRegion* previousRegion = nullptr;
2571             for (unsigned i = 0; i < count; i++) {
2572                 RefPtr<DashboardRegion> region = DashboardRegion::create();
2573                 StyleDashboardRegion styleRegion = regions[i];
2574
2575                 region->m_label = styleRegion.label;
2576                 LengthBox offset = styleRegion.offset;
2577                 region->setTop(zoomAdjustedPixelValue(offset.top().value(), style.get()));
2578                 region->setRight(zoomAdjustedPixelValue(offset.right().value(), style.get()));
2579                 region->setBottom(zoomAdjustedPixelValue(offset.bottom().value(), style.get()));
2580                 region->setLeft(zoomAdjustedPixelValue(offset.left().value(), style.get()));
2581                 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
2582                 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
2583
2584                 if (previousRegion)
2585                     previousRegion->m_next = region;
2586                 else
2587                     firstRegion = region;
2588                 previousRegion = region.get();
2589             }
2590             return cssValuePool().createValue(firstRegion.release());
2591         }
2592 #endif
2593         case CSSPropertyAnimationDelay:
2594         case CSSPropertyWebkitAnimationDelay:
2595             return getDelayValue(style->animations());
2596         case CSSPropertyAnimationDirection:
2597         case CSSPropertyWebkitAnimationDirection: {
2598             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2599             const AnimationList* t = style->animations();
2600             if (t) {
2601                 for (size_t i = 0; i < t->size(); ++i) {
2602                     switch (t->animation(i).direction()) {
2603                     case Animation::AnimationDirectionNormal:
2604                         list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2605                         break;
2606                     case Animation::AnimationDirectionAlternate:
2607                         list->append(cssValuePool().createIdentifierValue(CSSValueAlternate));
2608                         break;
2609                     case Animation::AnimationDirectionReverse:
2610                         list->append(cssValuePool().createIdentifierValue(CSSValueReverse));
2611                         break;
2612                     case Animation::AnimationDirectionAlternateReverse:
2613                         list->append(cssValuePool().createIdentifierValue(CSSValueAlternateReverse));
2614                         break;
2615                     }
2616                 }
2617             } else
2618                 list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2619             return list.release();
2620         }
2621         case CSSPropertyAnimationDuration:
2622         case CSSPropertyWebkitAnimationDuration:
2623             return getDurationValue(style->animations());
2624         case CSSPropertyAnimationFillMode:
2625         case CSSPropertyWebkitAnimationFillMode: {
2626             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2627             const AnimationList* t = style->animations();
2628             if (t) {
2629                 for (size_t i = 0; i < t->size(); ++i) {
2630                     switch (t->animation(i).fillMode()) {
2631                     case AnimationFillModeNone:
2632                         list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2633                         break;
2634                     case AnimationFillModeForwards:
2635                         list->append(cssValuePool().createIdentifierValue(CSSValueForwards));
2636                         break;
2637                     case AnimationFillModeBackwards:
2638                         list->append(cssValuePool().createIdentifierValue(CSSValueBackwards));
2639                         break;
2640                     case AnimationFillModeBoth:
2641                         list->append(cssValuePool().createIdentifierValue(CSSValueBoth));
2642                         break;
2643                     }
2644                 }
2645             } else
2646                 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2647             return list.release();
2648         }
2649         case CSSPropertyAnimationIterationCount:
2650         case CSSPropertyWebkitAnimationIterationCount: {
2651             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2652             const AnimationList* t = style->animations();
2653             if (t) {
2654                 for (size_t i = 0; i < t->size(); ++i) {
2655                     double iterationCount = t->animation(i).iterationCount();
2656                     if (iterationCount == Animation::IterationCountInfinite)
2657                         list->append(cssValuePool().createIdentifierValue(CSSValueInfinite));
2658                     else
2659                         list->append(cssValuePool().createValue(iterationCount, CSSPrimitiveValue::CSS_NUMBER));
2660                 }
2661             } else
2662                 list->append(cssValuePool().createValue(Animation::initialAnimationIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
2663             return list.release();
2664         }
2665         case CSSPropertyAnimationName:
2666         case CSSPropertyWebkitAnimationName: {
2667             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2668             const AnimationList* t = style->animations();
2669             if (t) {
2670                 for (size_t i = 0; i < t->size(); ++i)
2671                     list->append(cssValuePool().createValue(t->animation(i).name(), CSSPrimitiveValue::CSS_STRING));
2672             } else
2673                 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2674             return list.release();
2675         }
2676         case CSSPropertyAnimationPlayState:
2677         case CSSPropertyWebkitAnimationPlayState: {
2678             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2679             const AnimationList* t = style->animations();
2680             if (t) {
2681                 for (size_t i = 0; i < t->size(); ++i) {
2682                     int prop = t->animation(i).playState();
2683                     if (prop == AnimPlayStatePlaying)
2684                         list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2685                     else
2686                         list->append(cssValuePool().createIdentifierValue(CSSValuePaused));
2687                 }
2688             } else
2689                 list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2690             return list.release();
2691         }
2692         case CSSPropertyAnimationTimingFunction:
2693         case CSSPropertyWebkitAnimationTimingFunction:
2694             return getTimingFunctionValue(style->animations());
2695         case CSSPropertyWebkitAppearance:
2696             return cssValuePool().createValue(style->appearance());
2697         case CSSPropertyWebkitAspectRatio:
2698             if (style->aspectRatioType() == AspectRatioAuto)
2699                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2700             if (style->aspectRatioType() == AspectRatioFromDimensions)
2701                 return cssValuePool().createIdentifierValue(CSSValueFromDimensions);
2702             if (style->aspectRatioType() == AspectRatioFromIntrinsic)
2703                 return cssValuePool().createIdentifierValue(CSSValueFromIntrinsic);
2704             return CSSAspectRatioValue::create(style->aspectRatioNumerator(), style->aspectRatioDenominator());
2705         case CSSPropertyWebkitBackfaceVisibility:
2706             return cssValuePool().createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
2707         case CSSPropertyWebkitBorderImage:
2708             return valueForNinePieceImage(style->borderImage());
2709         case CSSPropertyBorderImageOutset:
2710             return valueForNinePieceImageQuad(style->borderImage().outset());
2711         case CSSPropertyBorderImageRepeat:
2712             return valueForNinePieceImageRepeat(style->borderImage());
2713         case CSSPropertyBorderImageSlice:
2714             return valueForNinePieceImageSlice(style->borderImage());
2715         case CSSPropertyBorderImageWidth:
2716             return valueForNinePieceImageQuad(style->borderImage().borderSlices());
2717         case CSSPropertyWebkitMaskBoxImage:
2718             return valueForNinePieceImage(style->maskBoxImage());
2719         case CSSPropertyWebkitMaskBoxImageOutset:
2720             return valueForNinePieceImageQuad(style->maskBoxImage().outset());
2721         case CSSPropertyWebkitMaskBoxImageRepeat:
2722             return valueForNinePieceImageRepeat(style->maskBoxImage());
2723         case CSSPropertyWebkitMaskBoxImageSlice:
2724             return valueForNinePieceImageSlice(style->maskBoxImage());
2725         case CSSPropertyWebkitMaskBoxImageWidth:
2726             return valueForNinePieceImageQuad(style->maskBoxImage().borderSlices());
2727         case CSSPropertyWebkitMaskBoxImageSource:
2728             if (style->maskBoxImageSource())
2729                 return style->maskBoxImageSource()->cssValue();
2730             return cssValuePool().createIdentifierValue(CSSValueNone);
2731         case CSSPropertyWebkitFontSizeDelta:
2732             // Not a real style property -- used by the editing engine -- so has no computed value.
2733             break;
2734         case CSSPropertyWebkitInitialLetter: {
2735             RefPtr<CSSPrimitiveValue> drop = !style->initialLetterDrop() ? cssValuePool().createIdentifierValue(CSSValueNormal) : cssValuePool().createValue(style->initialLetterDrop(), CSSPrimitiveValue::CSS_NUMBER);
2736             RefPtr<CSSPrimitiveValue> size = !style->initialLetterHeight() ? cssValuePool().createIdentifierValue(CSSValueNormal) : cssValuePool().createValue(style->initialLetterHeight(), CSSPrimitiveValue::CSS_NUMBER);
2737             return cssValuePool().createValue(Pair::create(drop.release(), size.release()));
2738         }
2739         case CSSPropertyWebkitMarginBottomCollapse:
2740         case CSSPropertyWebkitMarginAfterCollapse:
2741             return cssValuePool().createValue(style->marginAfterCollapse());
2742         case CSSPropertyWebkitMarginTopCollapse:
2743         case CSSPropertyWebkitMarginBeforeCollapse:
2744             return cssValuePool().createValue(style->marginBeforeCollapse());
2745 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
2746         case CSSPropertyWebkitOverflowScrolling:
2747             if (!style->useTouchOverflowScrolling())
2748                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2749             return cssValuePool().createIdentifierValue(CSSValueTouch);
2750 #endif
2751         case CSSPropertyWebkitPerspective:
2752             if (!style->hasPerspective())
2753                 return cssValuePool().createIdentifierValue(CSSValueNone);
2754             return zoomAdjustedPixelValue(style->perspective(), style.get());
2755         case CSSPropertyWebkitPerspectiveOrigin: {
2756             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2757             if (renderer) {
2758                 LayoutRect box;
2759                 if (is<RenderBox>(*renderer))
2760                     box = downcast<RenderBox>(*renderer).borderBoxRect();
2761
2762                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginX(), box.width()), style.get()));
2763                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginY(), box.height()), style.get()));
2764             }
2765             else {
2766                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginX(), style.get()));
2767                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginY(), style.get()));
2768
2769             }
2770             return list.release();
2771         }
2772         case CSSPropertyWebkitRtlOrdering:
2773             return cssValuePool().createIdentifierValue(style->rtlOrdering() ? CSSValueVisual : CSSValueLogical);
2774 #if ENABLE(TOUCH_EVENTS)
2775         case CSSPropertyWebkitTapHighlightColor:
2776             return currentColorOrValidColor(style.get(), style->tapHighlightColor());
2777 #endif
2778 #if PLATFORM(IOS)
2779         case CSSPropertyWebkitTouchCallout:
2780             return cssValuePool().createIdentifierValue(style->touchCalloutEnabled() ? CSSValueDefault : CSSValueNone);
2781 #endif
2782         case CSSPropertyWebkitUserDrag:
2783             return cssValuePool().createValue(style->userDrag());
2784         case CSSPropertyWebkitUserSelect:
2785             return cssValuePool().createValue(style->userSelect());
2786         case CSSPropertyBorderBottomLeftRadius:
2787             return getBorderRadiusCornerValue(style->borderBottomLeftRadius(), style.get());
2788         case CSSPropertyBorderBottomRightRadius:
2789             return getBorderRadiusCornerValue(style->borderBottomRightRadius(), style.get());
2790         case CSSPropertyBorderTopLeftRadius:
2791             return getBorderRadiusCornerValue(style->borderTopLeftRadius(), style.get());
2792         case CSSPropertyBorderTopRightRadius:
2793             return getBorderRadiusCornerValue(style->borderTopRightRadius(), style.get());
2794         case CSSPropertyClip: {
2795             if (!style->hasClip())
2796                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2797             RefPtr<Rect> rect = Rect::create();
2798             rect->setTop(autoOrZoomAdjustedValue(style->clip().top(), style.get()));
2799             rect->setRight(autoOrZoomAdjustedValue(style->clip().right(), style.get()));
2800             rect->setBottom(autoOrZoomAdjustedValue(style->clip().bottom(), style.get()));
2801             rect->setLeft(autoOrZoomAdjustedValue(style->clip().left(), style.get()));
2802             return cssValuePool().createValue(rect.release());
2803         }
2804         case CSSPropertySpeak:
2805             return cssValuePool().createValue(style->speak());
2806         case CSSPropertyWebkitTransform:
2807             return computedTransform(renderer, style.get());
2808         case CSSPropertyWebkitTransformOrigin: {
2809             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2810             if (renderer) {
2811                 LayoutRect box;
2812                 if (is<RenderBox>(*renderer))
2813                     box = downcast<RenderBox>(*renderer).borderBoxRect();
2814
2815                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginX(), box.width()), style.get()));
2816                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginY(), box.height()), style.get()));
2817                 if (style->transformOriginZ() != 0)
2818                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2819             } else {
2820                 list->append(zoomAdjustedPixelValueForLength(style->transformOriginX(), style.get()));
2821                 list->append(zoomAdjustedPixelValueForLength(style->transformOriginY(), style.get()));
2822                 if (style->transformOriginZ() != 0)
2823                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2824             }
2825             return list.release();
2826         }
2827         case CSSPropertyWebkitTransformStyle:
2828             return cssValuePool().createIdentifierValue((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat);
2829         case CSSPropertyTransitionDelay:
2830         case CSSPropertyWebkitTransitionDelay:
2831             return getDelayValue(style->transitions());
2832         case CSSPropertyTransitionDuration:
2833         case CSSPropertyWebkitTransitionDuration:
2834             return getDurationValue(style->transitions());
2835         case CSSPropertyTransitionProperty:
2836         case CSSPropertyWebkitTransitionProperty:
2837             return getTransitionPropertyValue(style->transitions());
2838         case CSSPropertyTransitionTimingFunction:
2839         case CSSPropertyWebkitTransitionTimingFunction:
2840             return getTimingFunctionValue(style->transitions());
2841         case CSSPropertyTransition:
2842         case CSSPropertyWebkitTransition: {
2843             const AnimationList* animList = style->transitions();
2844             if (animList) {
2845                 RefPtr<CSSValueList> transitionsList = CSSValueList::createCommaSeparated();
2846                 for (size_t i = 0; i < animList->size(); ++i) {
2847                     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2848                     const Animation& animation = animList->animation(i);
2849                     list->append(createTransitionPropertyValue(animation));
2850                     list->append(cssValuePool().createValue(animation.duration(), CSSPrimitiveValue::CSS_S));
2851                     list->append(createTimingFunctionValue(animation.timingFunction().get()));
2852                     list->append(cssValuePool().createValue(animation.delay(), CSSPrimitiveValue::CSS_S));
2853                     transitionsList->append(list.releaseNonNull());
2854                 }
2855                 return transitionsList.release();
2856             }
2857
2858             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2859             // transition-property default value.
2860             list->append(cssValuePool().createIdentifierValue(CSSValueAll));
2861             list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
2862             list->append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
2863             list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
2864             return list.release();
2865         }
2866         case CSSPropertyPointerEvents:
2867             return cssValuePool().createValue(style->pointerEvents());
2868         case CSSPropertyWebkitColorCorrection:
2869             return cssValuePool().createValue(style->colorSpace());
2870         case CSSPropertyWebkitLineGrid:
2871             if (style->lineGrid().isNull())
2872                 return cssValuePool().createIdentifierValue(CSSValueNone);
2873             return cssValuePool().createValue(style->lineGrid(), CSSPrimitiveValue::CSS_STRING);
2874         case CSSPropertyWebkitLineSnap:
2875             return CSSPrimitiveValue::create(style->lineSnap());
2876         case CSSPropertyWebkitLineAlign:
2877             return CSSPrimitiveValue::create(style->lineAlign());
2878         case CSSPropertyWebkitWritingMode:
2879             return cssValuePool().createValue(style->writingMode());
2880         case CSSPropertyWebkitTextCombine:
2881             return cssValuePool().createValue(style->textCombine());
2882         case CSSPropertyWebkitTextOrientation:
2883             return CSSPrimitiveValue::create(style->textOrientation());
2884         case CSSPropertyWebkitLineBoxContain:
2885             return createLineBoxContainValue(style->lineBoxContain());
2886         case CSSPropertyAlt:
2887             return altTextToCSSValue(style.get());
2888         case CSSPropertyContent:
2889             return contentToCSSValue(style.get());
2890         case CSSPropertyCounterIncrement:
2891             return counterToCSSValue(style.get(), propertyID);
2892         case CSSPropertyCounterReset:
2893             return counterToCSSValue(style.get(), propertyID);
2894         case CSSPropertyWebkitClipPath: {
2895             ClipPathOperation* operation = style->clipPath();
2896             if (!operation)
2897                 return cssValuePool().createIdentifierValue(CSSValueNone);
2898             if (is<ReferenceClipPathOperation>(*operation)) {
2899                 const auto& referenceOperation = downcast<ReferenceClipPathOperation>(*operation);
2900                 return CSSPrimitiveValue::create(referenceOperation.url(), CSSPrimitiveValue::CSS_URI);
2901             }
2902             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2903             if (is<ShapeClipPathOperation>(*operation)) {
2904                 const auto& shapeOperation = downcast<ShapeClipPathOperation>(*operation);
2905                 list->append(valueForBasicShape(style.get(), shapeOperation.basicShape()));
2906                 if (shapeOperation.referenceBox() != BoxMissing)
2907                     list->append(cssValuePool().createValue(shapeOperation.referenceBox()));
2908             }
2909             if (is<BoxClipPathOperation>(*operation)) {
2910                 const auto& boxOperation = downcast<BoxClipPathOperation>(*operation);
2911                 list->append(cssValuePool().createValue(boxOperation.referenceBox()));
2912             }
2913             return list.release();
2914         }
2915 #if ENABLE(CSS_REGIONS)
2916         case CSSPropertyWebkitFlowInto:
2917             if (!style->hasFlowInto())
2918                 return cssValuePool().createIdentifierValue(CSSValueNone);
2919             return cssValuePool().createValue(style->flowThread(), CSSPrimitiveValue::CSS_STRING);
2920         case CSSPropertyWebkitFlowFrom:
2921             if (!style->hasFlowFrom())
2922                 return cssValuePool().createIdentifierValue(CSSValueNone);
2923             return cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING);
2924         case CSSPropertyWebkitRegionFragment:
2925             return cssValuePool().createValue(style->regionFragment());
2926 #endif
2927 #if ENABLE(CSS_SHAPES)
2928         case CSSPropertyWebkitShapeMargin:
2929             return cssValuePool().createValue(style->shapeMargin(), style.get());
2930         case CSSPropertyWebkitShapeImageThreshold:
2931             return cssValuePool().createValue(style->shapeImageThreshold(), CSSPrimitiveValue::CSS_NUMBER);
2932         case CSSPropertyWebkitShapeOutside:
2933             return shapePropertyValue(style.get(), style->shapeOutside());
2934 #endif
2935         case CSSPropertyWebkitFilter:
2936             return valueForFilter(style.get(), style->filter());
2937 #if ENABLE(FILTERS_LEVEL_2)
2938         case CSSPropertyWebkitBackdropFilter:
2939             return valueForFilter(style.get(), style->backdropFilter());
2940 #endif
2941 #if ENABLE(CSS_COMPOSITING)
2942         case CSSPropertyMixBlendMode:
2943             return cssValuePool().createValue(style->blendMode());
2944         case CSSPropertyIsolation:
2945             return cssValuePool().createValue(style->isolation());
2946 #endif
2947         case CSSPropertyBackgroundBlendMode: {
2948             const FillLayer* layers = style->backgroundLayers();
2949             if (!layers->next())
2950                 return cssValuePool().createValue(layers->blendMode());
2951
2952             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2953             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
2954                 list->append(cssValuePool().createValue(currLayer->blendMode()));
2955
2956             return list.release();
2957         }
2958         case CSSPropertyBackground:
2959             return getBackgroundShorthandValue();
2960         case CSSPropertyBorder: {
2961             RefPtr<CSSValue> value = propertyValue(CSSPropertyBorderTop, DoNotUpdateLayout);
2962             const CSSPropertyID properties[3] = { CSSPropertyBorderRight, CSSPropertyBorderBottom, CSSPropertyBorderLeft };
2963             for (auto& property : properties) {
2964                 if (!compareCSSValuePtr<CSSValue>(value, propertyValue(property, DoNotUpdateLayout)))
2965                     return nullptr;
2966             }
2967             return value.release();
2968         }
2969         case CSSPropertyBorderBottom:
2970             return getCSSPropertyValuesForShorthandProperties(borderBottomShorthand());
2971         case CSSPropertyBorderColor:
2972             return getCSSPropertyValuesForSidesShorthand(borderColorShorthand());
2973         case CSSPropertyBorderLeft:
2974             return getCSSPropertyValuesForShorthandProperties(borderLeftShorthand());
2975         case CSSPropertyBorderImage:
2976             return valueForNinePieceImage(style->borderImage());
2977         case CSSPropertyBorderRadius:
2978             return getBorderRadiusShorthandValue(style.get());
2979         case CSSPropertyBorderRight:
2980             return getCSSPropertyValuesForShorthandProperties(borderRightShorthand());
2981         case CSSPropertyBorderStyle:
2982             return getCSSPropertyValuesForSidesShorthand(borderStyleShorthand());
2983         case CSSPropertyBorderTop:
2984             return getCSSPropertyValuesForShorthandProperties(borderTopShorthand());
2985         case CSSPropertyBorderWidth:
2986             return getCSSPropertyValuesForSidesShorthand(borderWidthShorthand());
2987         case CSSPropertyColumnRule:
2988             return getCSSPropertyValuesForShorthandProperties(webkitColumnRuleShorthand());
2989         case CSSPropertyColumns:
2990             return getCSSPropertyValuesForShorthandProperties(webkitColumnsShorthand());
2991         case CSSPropertyListStyle:
2992             return getCSSPropertyValuesForShorthandProperties(listStyleShorthand());
2993         case CSSPropertyMargin:
2994             return getCSSPropertyValuesForSidesShorthand(marginShorthand());
2995         case CSSPropertyOutline:
2996             return getCSSPropertyValuesForShorthandProperties(outlineShorthand());
2997         case CSSPropertyPadding:
2998             return getCSSPropertyValuesForSidesShorthand(paddingShorthand());
2999
3000 #if ENABLE(CSS_SCROLL_SNAP)
3001         case CSSPropertyWebkitScrollSnapType:
3002             return cssValuePool().createValue(style->scrollSnapType());
3003         case CSSPropertyWebkitScrollSnapDestination:
3004             return scrollSnapDestination(*style, style->scrollSnapDestination());
3005         case CSSPropertyWebkitScrollSnapPointsX:
3006             return scrollSnapPoints(*style, style->scrollSnapPointsX());
3007         case CSSPropertyWebkitScrollSnapPointsY:
3008             return scrollSnapPoints(*style, style->scrollSnapPointsY());
3009         case CSSPropertyWebkitScrollSnapCoordinate:
3010             return scrollSnapCoordinates(*style, style->scrollSnapCoordinates());
3011 #endif
3012
3013         /* Individual properties not part of the spec */
3014         case CSSPropertyBackgroundRepeatX:
3015         case CSSPropertyBackgroundRepeatY:
3016             break;
3017
3018         // Length properties for SVG.
3019         case CSSPropertyCx:
3020             return zoomAdjustedPixelValueForLength(style->svgStyle().cx(), style.get());
3021         case CSSPropertyCy:
3022             return zoomAdjustedPixelValueForLength(style->svgStyle().cy(), style.get());
3023         case CSSPropertyR:
3024             return zoomAdjustedPixelValueForLength(style->svgStyle().r(), style.get());
3025         case CSSPropertyRx:
3026             return zoomAdjustedPixelValueForLength(style->svgStyle().rx(), style.get());
3027         case CSSPropertyRy:
3028             return zoomAdjustedPixelValueForLength(style->svgStyle().ry(), style.get());
3029         case CSSPropertyStrokeWidth:
3030             return zoomAdjustedPixelValueForLength(style->svgStyle().strokeWidth(), style.get());
3031         case CSSPropertyStrokeDashoffset:
3032             return zoomAdjustedPixelValueForLength(style->svgStyle().strokeDashOffset(), style.get());
3033         case CSSPropertyX:
3034             return zoomAdjustedPixelValueForLength(style->svgStyle().x(), style.get());
3035         case CSSPropertyY:
3036             return zoomAdjustedPixelValueForLength(style->svgStyle().y(), style.get());
3037
3038         /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
3039         case CSSPropertyAnimation:
3040         case CSSPropertyWebkitTextEmphasis:
3041         case CSSPropertyTextLineThrough:
3042         case CSSPropertyTextLineThroughColor:
3043         case CSSPropertyTextLineThroughMode:
3044         case CSSPropertyTextLineThroughStyle:
3045         case CSSPropertyTextLineThroughWidth:
3046         case CSSPropertyTextOverline:
3047         case CSSPropertyTextOverlineColor:
3048         case CSSPropertyTextOverlineMode:
3049         case CSSPropertyTextOverlineStyle:
3050         case CSSPropertyTextOverlineWidth:
3051         case CSSPropertyTextUnderline:
3052         case CSSPropertyTextUnderlineColor:
3053         case CSSPropertyTextUnderlineMode:
3054         case CSSPropertyTextUnderlineStyle:
3055         case CSSPropertyTextUnderlineWidth:
3056             break;
3057
3058         /* Directional properties are resolved by resolveDirectionAwareProperty() before the switch. */
3059         case CSSPropertyWebkitBorderEnd:
3060         case CSSPropertyWebkitBorderEndColor:
3061         case CSSPropertyWebkitBorderEndStyle:
3062         case CSSPropertyWebkitBorderEndWidth:
3063         case CSSPropertyWebkitBorderStart:
3064         case CSSPropertyWebkitBorderStartColor:
3065         case CSSPropertyWebkitBorderStartStyle:
3066         case CSSPropertyWebkitBorderStartWidth:
3067         case CSSPropertyWebkitBorderAfter:
3068         case CSSPropertyWebkitBorderAfterColor:
3069         case CSSPropertyWebkitBorderAfterStyle:
3070         case CSSPropertyWebkitBorderAfterWidth:
3071         case CSSPropertyWebkitBorderBefore:
3072         case CSSPropertyWebkitBorderBeforeColor:
3073         case CSSPropertyWebkitBorderBeforeStyle:
3074         case CSSPropertyWebkitBorderBeforeWidth:
3075         case CSSPropertyWebkitMarginEnd:
3076         case CSSPropertyWebkitMarginStart:
3077         case CSSPropertyWebkitMarginAfter:
3078         case CSSPropertyWebkitMarginBefore:
3079         case CSSPropertyWebkitPaddingEnd:
3080         case CSSPropertyWebkitPaddingStart:
3081         case CSSPropertyWebkitPaddingAfter:
3082         case CSSPropertyWebkitPaddingBefore:
3083         case CSSPropertyWebkitLogicalWidth:
3084         case CSSPropertyWebkitLogicalHeight:
3085         case CSSPropertyWebkitMinLogicalWidth:
3086         case CSSPropertyWebkitMinLogicalHeight:
3087         case CSSPropertyWebkitMaxLogicalWidth:
3088         case CSSPropertyWebkitMaxLogicalHeight:
3089             ASSERT_NOT_REACHED();
3090             break;
3091
3092         /* Unimplemented @font-face properties */
3093         case CSSPropertyFontStretch:
3094         case CSSPropertySrc:
3095         case CSSPropertyUnicodeRange:
3096             break;
3097
3098         /* Other unimplemented properties */
3099         case CSSPropertyPage: // for @page
3100         case CSSPropertyQuotes: // FIXME: needs implementation
3101         case CSSPropertySize: // for @page
3102             break;
3103
3104         /* Unimplemented -webkit- properties */
3105         case CSSPropertyWebkitAnimation:
3106         case CSSPropertyWebkitBorderRadius:
3107         case CSSPropertyWebkitMarginCollapse:
3108         case CSSPropertyWebkitMarquee:
3109         case CSSPropertyWebkitMarqueeSpeed:
3110         case CSSPropertyWebkitMask:
3111         case CSSPropertyWebkitMaskRepeatX:
3112         case CSSPropertyWebkitMaskRepeatY:
3113         case CSSPropertyWebkitPerspectiveOriginX:
3114         case CSSPropertyWebkitPerspectiveOriginY:
3115         case CSSPropertyWebkitTextStroke:
3116         case CSSPropertyWebkitTransformOriginX:
3117         case CSSPropertyWebkitTransformOriginY:
3118         case CSSPropertyWebkitTransformOriginZ:
3119             break;
3120
3121 #if ENABLE(CSS_DEVICE_ADAPTATION)
3122         case CSSPropertyMaxZoom:
3123         case CSSPropertyMinZoom:
3124         case CSSPropertyOrientation:
3125         case CSSPropertyUserZoom:
3126             break;
3127 #endif
3128
3129         case CSSPropertyBufferedRendering:
3130         case CSSPropertyClipPath: