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