00a32e22e94648b5ef489c6d1e5920ffc96add9c
[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 "StyleProperties.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     CSSPropertyWebkitAlt,
226     CSSPropertyWebkitAnimationDelay,
227     CSSPropertyWebkitAnimationDirection,
228     CSSPropertyWebkitAnimationDuration,
229     CSSPropertyWebkitAnimationFillMode,
230     CSSPropertyWebkitAnimationIterationCount,
231     CSSPropertyWebkitAnimationName,
232     CSSPropertyWebkitAnimationPlayState,
233     CSSPropertyWebkitAnimationTimingFunction,
234     CSSPropertyWebkitAppearance,
235     CSSPropertyWebkitBackfaceVisibility,
236     CSSPropertyWebkitBackgroundBlendMode,
237     CSSPropertyWebkitBackgroundClip,
238     CSSPropertyWebkitBackgroundComposite,
239     CSSPropertyWebkitBackgroundOrigin,
240     CSSPropertyWebkitBackgroundSize,
241 #if ENABLE(CSS_COMPOSITING)
242     CSSPropertyWebkitBlendMode,
243 #endif
244     CSSPropertyWebkitBorderFit,
245     CSSPropertyWebkitBorderHorizontalSpacing,
246     CSSPropertyWebkitBorderImage,
247     CSSPropertyWebkitBorderVerticalSpacing,
248     CSSPropertyWebkitBoxAlign,
249 #if ENABLE(CSS_BOX_DECORATION_BREAK)
250     CSSPropertyWebkitBoxDecorationBreak,
251 #endif
252     CSSPropertyWebkitBoxDirection,
253     CSSPropertyWebkitBoxFlex,
254     CSSPropertyWebkitBoxFlexGroup,
255     CSSPropertyWebkitBoxLines,
256     CSSPropertyWebkitBoxOrdinalGroup,
257     CSSPropertyWebkitBoxOrient,
258     CSSPropertyWebkitBoxPack,
259     CSSPropertyWebkitBoxReflect,
260     CSSPropertyWebkitBoxShadow,
261     CSSPropertyWebkitClipPath,
262     CSSPropertyWebkitColorCorrection,
263     CSSPropertyWebkitColumnBreakAfter,
264     CSSPropertyWebkitColumnBreakBefore,
265     CSSPropertyWebkitColumnBreakInside,
266     CSSPropertyWebkitColumnAxis,
267     CSSPropertyWebkitColumnCount,
268     CSSPropertyWebkitColumnGap,
269     CSSPropertyWebkitColumnProgression,
270     CSSPropertyWebkitColumnRuleColor,
271     CSSPropertyWebkitColumnRuleStyle,
272     CSSPropertyWebkitColumnRuleWidth,
273     CSSPropertyWebkitColumnSpan,
274     CSSPropertyWebkitColumnWidth,
275 #if ENABLE(CURSOR_VISIBILITY)
276     CSSPropertyWebkitCursorVisibility,
277 #endif
278 #if ENABLE(DASHBOARD_SUPPORT)
279     CSSPropertyWebkitDashboardRegion,
280 #endif
281 #if ENABLE(CSS_FILTERS)
282     CSSPropertyWebkitFilter,
283 #endif
284     CSSPropertyWebkitAlignContent,
285     CSSPropertyWebkitAlignItems,
286     CSSPropertyWebkitAlignSelf,
287     CSSPropertyWebkitFlexBasis,
288     CSSPropertyWebkitFlexGrow,
289     CSSPropertyWebkitFlexShrink,
290     CSSPropertyWebkitFlexDirection,
291     CSSPropertyWebkitFlexWrap,
292     CSSPropertyWebkitJustifyContent,
293     CSSPropertyWebkitFontKerning,
294     CSSPropertyWebkitFontSmoothing,
295     CSSPropertyWebkitFontVariantLigatures,
296     CSSPropertyWebkitGridAutoColumns,
297     CSSPropertyWebkitGridAutoFlow,
298     CSSPropertyWebkitGridAutoRows,
299     CSSPropertyWebkitGridColumnEnd,
300     CSSPropertyWebkitGridColumnStart,
301     CSSPropertyWebkitGridDefinitionColumns,
302     CSSPropertyWebkitGridDefinitionRows,
303     CSSPropertyWebkitGridRowEnd,
304     CSSPropertyWebkitGridRowStart,
305     CSSPropertyWebkitHighlight,
306     CSSPropertyWebkitHyphenateCharacter,
307     CSSPropertyWebkitHyphenateLimitAfter,
308     CSSPropertyWebkitHyphenateLimitBefore,
309     CSSPropertyWebkitHyphenateLimitLines,
310     CSSPropertyWebkitHyphens,
311     CSSPropertyWebkitLineAlign,
312     CSSPropertyWebkitLineBoxContain,
313     CSSPropertyWebkitLineBreak,
314     CSSPropertyWebkitLineClamp,
315     CSSPropertyWebkitLineGrid,
316     CSSPropertyWebkitLineSnap,
317     CSSPropertyWebkitLocale,
318     CSSPropertyWebkitMarginBeforeCollapse,
319     CSSPropertyWebkitMarginAfterCollapse,
320     CSSPropertyWebkitMarqueeDirection,
321     CSSPropertyWebkitMarqueeIncrement,
322     CSSPropertyWebkitMarqueeRepetition,
323     CSSPropertyWebkitMarqueeStyle,
324     CSSPropertyWebkitMaskBoxImage,
325     CSSPropertyWebkitMaskBoxImageOutset,
326     CSSPropertyWebkitMaskBoxImageRepeat,
327     CSSPropertyWebkitMaskBoxImageSlice,
328     CSSPropertyWebkitMaskBoxImageSource,
329     CSSPropertyWebkitMaskBoxImageWidth,
330     CSSPropertyWebkitMaskClip,
331     CSSPropertyWebkitMaskComposite,
332     CSSPropertyWebkitMaskImage,
333     CSSPropertyWebkitMaskOrigin,
334     CSSPropertyWebkitMaskPosition,
335     CSSPropertyWebkitMaskRepeat,
336     CSSPropertyWebkitMaskSize,
337     CSSPropertyWebkitMaskSourceType,
338     CSSPropertyWebkitNbspMode,
339     CSSPropertyWebkitOrder,
340 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
341     CSSPropertyWebkitOverflowScrolling,
342 #endif
343     CSSPropertyWebkitPerspective,
344     CSSPropertyWebkitPerspectiveOrigin,
345     CSSPropertyWebkitPrintColorAdjust,
346     CSSPropertyWebkitRtlOrdering,
347 #if PLATFORM(IOS)
348     CSSPropertyWebkitTouchCallout,
349 #endif
350 #if ENABLE(CSS_SHAPES)
351     CSSPropertyWebkitShapeInside,
352     CSSPropertyWebkitShapeOutside,
353 #endif
354 #if ENABLE(TOUCH_EVENTS)
355     CSSPropertyWebkitTapHighlightColor,
356 #endif
357     CSSPropertyWebkitTextCombine,
358     CSSPropertyWebkitTextDecorationsInEffect,
359     CSSPropertyWebkitTextEmphasisColor,
360     CSSPropertyWebkitTextEmphasisPosition,
361     CSSPropertyWebkitTextEmphasisStyle,
362     CSSPropertyWebkitTextFillColor,
363     CSSPropertyWebkitTextOrientation,
364     CSSPropertyWebkitTextSecurity,
365 #if ENABLE(IOS_TEXT_AUTOSIZING)
366     CSSPropertyWebkitTextSizeAdjust,
367 #endif
368     CSSPropertyWebkitTextStrokeColor,
369     CSSPropertyWebkitTextStrokeWidth,
370     CSSPropertyWebkitTransform,
371     CSSPropertyWebkitTransformOrigin,
372     CSSPropertyWebkitTransformStyle,
373     CSSPropertyWebkitTransitionDelay,
374     CSSPropertyWebkitTransitionDuration,
375     CSSPropertyWebkitTransitionProperty,
376     CSSPropertyWebkitTransitionTimingFunction,
377     CSSPropertyWebkitUserDrag,
378     CSSPropertyWebkitUserModify,
379     CSSPropertyWebkitUserSelect,
380     CSSPropertyWebkitWritingMode,
381 #if ENABLE(CSS_REGIONS)
382     CSSPropertyWebkitFlowInto,
383     CSSPropertyWebkitFlowFrom,
384     CSSPropertyWebkitRegionBreakAfter,
385     CSSPropertyWebkitRegionBreakBefore,
386     CSSPropertyWebkitRegionBreakInside,
387     CSSPropertyWebkitRegionFragment,
388 #endif
389 #if ENABLE(DRAGGABLE_REGION)
390     CSSPropertyWebkitAppRegion,
391 #endif
392 #if ENABLE(CSS_EXCLUSIONS)
393     CSSPropertyWebkitWrapFlow,
394     CSSPropertyWebkitWrapThrough,
395 #endif
396 #if ENABLE(CSS_SHAPES)
397     CSSPropertyWebkitShapeMargin,
398     CSSPropertyWebkitShapePadding,
399     CSSPropertyWebkitShapeImageThreshold,
400 #endif
401 #if ENABLE(SVG)
402     CSSPropertyBufferedRendering,
403     CSSPropertyClipPath,
404     CSSPropertyClipRule,
405     CSSPropertyMask,
406     CSSPropertyFilter,
407     CSSPropertyFloodColor,
408     CSSPropertyFloodOpacity,
409     CSSPropertyLightingColor,
410     CSSPropertyStopColor,
411     CSSPropertyStopOpacity,
412     CSSPropertyColorInterpolation,
413     CSSPropertyColorInterpolationFilters,
414     CSSPropertyColorRendering,
415     CSSPropertyFill,
416     CSSPropertyFillOpacity,
417     CSSPropertyFillRule,
418     CSSPropertyMarkerEnd,
419     CSSPropertyMarkerMid,
420     CSSPropertyMarkerStart,
421     CSSPropertyMaskType,
422     CSSPropertyShapeRendering,
423     CSSPropertyStroke,
424     CSSPropertyStrokeDasharray,
425     CSSPropertyStrokeDashoffset,
426     CSSPropertyStrokeLinecap,
427     CSSPropertyStrokeLinejoin,
428     CSSPropertyStrokeMiterlimit,
429     CSSPropertyStrokeOpacity,
430     CSSPropertyStrokeWidth,
431     CSSPropertyAlignmentBaseline,
432     CSSPropertyBaselineShift,
433     CSSPropertyDominantBaseline,
434     CSSPropertyKerning,
435     CSSPropertyTextAnchor,
436     CSSPropertyWritingMode,
437     CSSPropertyGlyphOrientationHorizontal,
438     CSSPropertyGlyphOrientationVertical,
439     CSSPropertyWebkitSvgShadow,
440     CSSPropertyVectorEffect
441 #endif
442 };
443
444 const unsigned numComputedProperties = WTF_ARRAY_LENGTH(computedProperties);
445
446 static CSSValueID valueForRepeatRule(int rule)
447 {
448     switch (rule) {
449         case RepeatImageRule:
450             return CSSValueRepeat;
451         case RoundImageRule:
452             return CSSValueRound;
453         case SpaceImageRule:
454             return CSSValueSpace;
455         default:
456             return CSSValueStretch;
457     }
458 }
459
460 static PassRefPtr<CSSBorderImageSliceValue> valueForNinePieceImageSlice(const NinePieceImage& image)
461 {
462     // Create the slices.
463     RefPtr<CSSPrimitiveValue> top;
464     RefPtr<CSSPrimitiveValue> right;
465     RefPtr<CSSPrimitiveValue> bottom;
466     RefPtr<CSSPrimitiveValue> left;
467
468     if (image.imageSlices().top().isPercent())
469         top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
470     else
471         top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_NUMBER);
472
473     if (image.imageSlices().right() == image.imageSlices().top() && image.imageSlices().bottom() == image.imageSlices().top()
474         && image.imageSlices().left() == image.imageSlices().top()) {
475         right = top;
476         bottom = top;
477         left = top;
478     } else {
479         if (image.imageSlices().right().isPercent())
480             right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
481         else
482             right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_NUMBER);
483
484         if (image.imageSlices().bottom() == image.imageSlices().top() && image.imageSlices().right() == image.imageSlices().left()) {
485             bottom = top;
486             left = right;
487         } else {
488             if (image.imageSlices().bottom().isPercent())
489                 bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
490             else
491                 bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
492
493             if (image.imageSlices().left() == image.imageSlices().right())
494                 left = right;
495             else {
496                 if (image.imageSlices().left().isPercent())
497                     left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
498                 else
499                     left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_NUMBER);
500             }
501         }
502     }
503
504     RefPtr<Quad> quad = Quad::create();
505     quad->setTop(top);
506     quad->setRight(right);
507     quad->setBottom(bottom);
508     quad->setLeft(left);
509
510     return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.release()), image.fill());
511 }
512
513 static PassRefPtr<CSSPrimitiveValue> valueForNinePieceImageQuad(const LengthBox& box)
514 {
515     // Create the slices.
516     RefPtr<CSSPrimitiveValue> top;
517     RefPtr<CSSPrimitiveValue> right;
518     RefPtr<CSSPrimitiveValue> bottom;
519     RefPtr<CSSPrimitiveValue> left;
520
521     if (box.top().isRelative())
522         top = cssValuePool().createValue(box.top().value(), CSSPrimitiveValue::CSS_NUMBER);
523     else
524         top = cssValuePool().createValue(box.top());
525
526     if (box.right() == box.top() && box.bottom() == box.top() && box.left() == box.top()) {
527         right = top;
528         bottom = top;
529         left = top;
530     } else {
531         if (box.right().isRelative())
532             right = cssValuePool().createValue(box.right().value(), CSSPrimitiveValue::CSS_NUMBER);
533         else
534             right = cssValuePool().createValue(box.right());
535
536         if (box.bottom() == box.top() && box.right() == box.left()) {
537             bottom = top;
538             left = right;
539         } else {
540             if (box.bottom().isRelative())
541                 bottom = cssValuePool().createValue(box.bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
542             else
543                 bottom = cssValuePool().createValue(box.bottom());
544
545             if (box.left() == box.right())
546                 left = right;
547             else {
548                 if (box.left().isRelative())
549                     left = cssValuePool().createValue(box.left().value(), CSSPrimitiveValue::CSS_NUMBER);
550                 else
551                     left = cssValuePool().createValue(box.left());
552             }
553         }
554     }
555
556     RefPtr<Quad> quad = Quad::create();
557     quad->setTop(top);
558     quad->setRight(right);
559     quad->setBottom(bottom);
560     quad->setLeft(left);
561
562     return cssValuePool().createValue(quad.release());
563 }
564
565 static PassRefPtr<CSSValue> valueForNinePieceImageRepeat(const NinePieceImage& image)
566 {
567     RefPtr<CSSPrimitiveValue> horizontalRepeat;
568     RefPtr<CSSPrimitiveValue> verticalRepeat;
569
570     horizontalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.horizontalRule()));
571     if (image.horizontalRule() == image.verticalRule())
572         verticalRepeat = horizontalRepeat;
573     else
574         verticalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.verticalRule()));
575     return cssValuePool().createValue(Pair::create(horizontalRepeat.release(), verticalRepeat.release()));
576 }
577
578 static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
579 {
580     if (!image.hasImage())
581         return cssValuePool().createIdentifierValue(CSSValueNone);
582
583     // Image first.
584     RefPtr<CSSValue> imageValue;
585     if (image.image())
586         imageValue = image.image()->cssValue();
587
588     // Create the image slice.
589     RefPtr<CSSBorderImageSliceValue> imageSlices = valueForNinePieceImageSlice(image);
590
591     // Create the border area slices.
592     RefPtr<CSSValue> borderSlices = valueForNinePieceImageQuad(image.borderSlices());
593
594     // Create the border outset.
595     RefPtr<CSSValue> outset = valueForNinePieceImageQuad(image.outset());
596
597     // Create the repeat rules.
598     RefPtr<CSSValue> repeat = valueForNinePieceImageRepeat(image);
599
600     return createBorderImageValue(imageValue.release(), imageSlices.release(), borderSlices.release(), outset.release(), repeat.release());
601 }
602
603 inline static PassRef<CSSPrimitiveValue> zoomAdjustedPixelValue(double value, const RenderStyle* style)
604 {
605     return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style), CSSPrimitiveValue::CSS_PX);
606 }
607
608 inline static PassRef<CSSPrimitiveValue> zoomAdjustedNumberValue(double value, const RenderStyle* style)
609 {
610     return cssValuePool().createValue(value / style->effectiveZoom(), CSSPrimitiveValue::CSS_NUMBER);
611 }
612
613 static PassRef<CSSValue> zoomAdjustedPixelValueForLength(const Length& length, const RenderStyle* style)
614 {
615     if (length.isFixed())
616         return zoomAdjustedPixelValue(length.value(), style);
617     return cssValuePool().createValue(length);
618 }
619
620 static PassRef<CSSValue> valueForReflection(const StyleReflection* reflection, const RenderStyle* style)
621 {
622     if (!reflection)
623         return cssValuePool().createIdentifierValue(CSSValueNone);
624
625     RefPtr<CSSPrimitiveValue> offset;
626     if (reflection->offset().isPercent())
627         offset = cssValuePool().createValue(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
628     else
629         offset = zoomAdjustedPixelValue(reflection->offset().value(), style);
630
631     RefPtr<CSSPrimitiveValue> direction;
632     switch (reflection->direction()) {
633     case ReflectionBelow:
634         direction = cssValuePool().createIdentifierValue(CSSValueBelow);
635         break;
636     case ReflectionAbove:
637         direction = cssValuePool().createIdentifierValue(CSSValueAbove);
638         break;
639     case ReflectionLeft:
640         direction = cssValuePool().createIdentifierValue(CSSValueLeft);
641         break;
642     case ReflectionRight:
643         direction = cssValuePool().createIdentifierValue(CSSValueRight);
644         break;
645     }
646
647     return CSSReflectValue::create(direction.release(), offset.release(), valueForNinePieceImage(reflection->mask()));
648 }
649
650 static PassRef<CSSValueList> createPositionListForLayer(CSSPropertyID propertyID, const FillLayer* layer, const RenderStyle* style)
651 {
652     auto positionList = CSSValueList::createSpaceSeparated();
653     if (layer->isBackgroundOriginSet()) {
654         ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
655         positionList.get().append(cssValuePool().createValue(layer->backgroundXOrigin()));
656     }
657     positionList.get().append(zoomAdjustedPixelValueForLength(layer->xPosition(), style));
658     if (layer->isBackgroundOriginSet()) {
659         ASSERT(propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
660         positionList.get().append(cssValuePool().createValue(layer->backgroundYOrigin()));
661     }
662     positionList.get().append(zoomAdjustedPixelValueForLength(layer->yPosition(), style));
663     return positionList;
664 }
665
666 static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, CSSPropertyID propertyID, RenderView* renderView)
667 {
668     if (!style)
669         return 0;
670
671     Length l;
672     switch (propertyID) {
673         case CSSPropertyLeft:
674             l = style->left();
675             break;
676         case CSSPropertyRight:
677             l = style->right();
678             break;
679         case CSSPropertyTop:
680             l = style->top();
681             break;
682         case CSSPropertyBottom:
683             l = style->bottom();
684             break;
685         default:
686             return 0;
687     }
688
689     if (style->hasOutOfFlowPosition()) {
690         if (l.type() == WebCore::Fixed)
691             return zoomAdjustedPixelValue(l.value(), style);
692         else if (l.isViewportPercentage())
693             return zoomAdjustedPixelValue(valueForLength(l, 0, renderView), style);
694         return cssValuePool().createValue(l);
695     }
696
697     if (style->hasInFlowPosition()) {
698         // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
699         // In other words if left is auto and right is not auto, then left's computed value is negative right().
700         // So we should get the opposite length unit and see if it is auto.
701         return cssValuePool().createValue(l);
702     }
703
704     return cssValuePool().createIdentifierValue(CSSValueAuto);
705 }
706
707 PassRefPtr<CSSPrimitiveValue> ComputedStyleExtractor::currentColorOrValidColor(RenderStyle* style, const Color& color) const
708 {
709     // This function does NOT look at visited information, so that computed style doesn't expose that.
710     if (!color.isValid())
711         return cssValuePool().createColorValue(style->color().rgb());
712     return cssValuePool().createColorValue(color.rgb());
713 }
714
715 static PassRef<CSSValueList> getBorderRadiusCornerValues(const LengthSize& radius, const RenderStyle* style, RenderView* renderView)
716 {
717     auto list = CSSValueList::createSpaceSeparated();
718     if (radius.width().type() == Percent)
719         list.get().append(cssValuePool().createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
720     else
721         list.get().append(zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style));
722     if (radius.height().type() == Percent)
723         list.get().append(cssValuePool().createValue(radius.height().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
724     else
725         list.get().append(zoomAdjustedPixelValue(valueForLength(radius.height(), 0, renderView), style));
726     return list;
727 }
728
729 static PassRef<CSSValue> getBorderRadiusCornerValue(const LengthSize& radius, const RenderStyle* style, RenderView* renderView)
730 {
731     if (radius.width() == radius.height()) {
732         if (radius.width().type() == Percent)
733             return cssValuePool().createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
734         return zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style);
735     }
736     return getBorderRadiusCornerValues(radius, style, renderView);
737 }
738
739 static PassRef<CSSValueList> getBorderRadiusShorthandValue(const RenderStyle* style, RenderView* renderView)
740 {
741     auto list = CSSValueList::createSlashSeparated();
742     bool showHorizontalBottomLeft = style->borderTopRightRadius().width() != style->borderBottomLeftRadius().width();
743     bool showHorizontalBottomRight = showHorizontalBottomLeft || (style->borderBottomRightRadius().width() != style->borderTopLeftRadius().width());
744     bool showHorizontalTopRight = showHorizontalBottomRight || (style->borderTopRightRadius().width() != style->borderTopLeftRadius().width());
745
746     bool showVerticalBottomLeft = style->borderTopRightRadius().height() != style->borderBottomLeftRadius().height();
747     bool showVerticalBottomRight = showVerticalBottomLeft || (style->borderBottomRightRadius().height() != style->borderTopLeftRadius().height());
748     bool showVerticalTopRight = showVerticalBottomRight || (style->borderTopRightRadius().height() != 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.get().append(horizontalRadii.release());
765
766     RefPtr<CSSValueList> verticalRadiiList = CSSValueList::createSpaceSeparated();
767     verticalRadiiList->append(topLeftRadius->item(1));
768     if (showVerticalTopRight)
769         verticalRadiiList->append(topRightRadius->item(1));
770     if (showVerticalBottomRight)
771         verticalRadiiList->append(bottomRightRadius->item(1));
772     if (showVerticalBottomLeft)
773         verticalRadiiList->append(bottomLeftRadius->item(1));
774
775     if (!verticalRadiiList->equals(*toCSSValueList(list.get().item(0))))
776         list.get().append(verticalRadiiList.release());
777
778     return list;
779 }
780
781 static LayoutRect sizingBox(RenderObject* renderer)
782 {
783     if (!renderer->isBox())
784         return LayoutRect();
785
786     RenderBox* box = toRenderBox(renderer);
787     return box->style().boxSizing() == BORDER_BOX ? box->borderBoxRect() : box->computedCSSContentBoxRect();
788 }
789
790 static PassRef<WebKitCSSTransformValue> matrixTransformValue(const TransformationMatrix& transform, const RenderStyle* style)
791 {
792     RefPtr<WebKitCSSTransformValue> transformValue;
793     if (transform.isAffine()) {
794         transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::MatrixTransformOperation);
795
796         transformValue->append(cssValuePool().createValue(transform.a(), CSSPrimitiveValue::CSS_NUMBER));
797         transformValue->append(cssValuePool().createValue(transform.b(), CSSPrimitiveValue::CSS_NUMBER));
798         transformValue->append(cssValuePool().createValue(transform.c(), CSSPrimitiveValue::CSS_NUMBER));
799         transformValue->append(cssValuePool().createValue(transform.d(), CSSPrimitiveValue::CSS_NUMBER));
800         transformValue->append(zoomAdjustedNumberValue(transform.e(), style));
801         transformValue->append(zoomAdjustedNumberValue(transform.f(), style));
802     } else {
803         transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::Matrix3DTransformOperation);
804
805         transformValue->append(cssValuePool().createValue(transform.m11(), CSSPrimitiveValue::CSS_NUMBER));
806         transformValue->append(cssValuePool().createValue(transform.m12(), CSSPrimitiveValue::CSS_NUMBER));
807         transformValue->append(cssValuePool().createValue(transform.m13(), CSSPrimitiveValue::CSS_NUMBER));
808         transformValue->append(cssValuePool().createValue(transform.m14(), CSSPrimitiveValue::CSS_NUMBER));
809
810         transformValue->append(cssValuePool().createValue(transform.m21(), CSSPrimitiveValue::CSS_NUMBER));
811         transformValue->append(cssValuePool().createValue(transform.m22(), CSSPrimitiveValue::CSS_NUMBER));
812         transformValue->append(cssValuePool().createValue(transform.m23(), CSSPrimitiveValue::CSS_NUMBER));
813         transformValue->append(cssValuePool().createValue(transform.m24(), CSSPrimitiveValue::CSS_NUMBER));
814
815         transformValue->append(cssValuePool().createValue(transform.m31(), CSSPrimitiveValue::CSS_NUMBER));
816         transformValue->append(cssValuePool().createValue(transform.m32(), CSSPrimitiveValue::CSS_NUMBER));
817         transformValue->append(cssValuePool().createValue(transform.m33(), CSSPrimitiveValue::CSS_NUMBER));
818         transformValue->append(cssValuePool().createValue(transform.m34(), CSSPrimitiveValue::CSS_NUMBER));
819
820         transformValue->append(zoomAdjustedNumberValue(transform.m41(), style));
821         transformValue->append(zoomAdjustedNumberValue(transform.m42(), style));
822         transformValue->append(zoomAdjustedNumberValue(transform.m43(), style));
823         transformValue->append(cssValuePool().createValue(transform.m44(), CSSPrimitiveValue::CSS_NUMBER));
824     }
825
826     return transformValue.releaseNonNull();
827 }
828
829 static PassRef<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle* style)
830 {
831     if (!renderer || !renderer->hasTransform() || !style->hasTransform())
832         return cssValuePool().createIdentifierValue(CSSValueNone);
833
834     IntRect box;
835     if (renderer->isBox())
836         box = pixelSnappedIntRect(toRenderBox(renderer)->borderBoxRect());
837
838     TransformationMatrix transform;
839     style->applyTransform(transform, box.size(), RenderStyle::ExcludeTransformOrigin);
840     // Note that this does not flatten to an affine transform if ENABLE(3D_RENDERING) is off, by design.
841
842     // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
843     auto list = CSSValueList::createSpaceSeparated();
844     list.get().append(matrixTransformValue(transform, style));
845     return std::move(list);
846 }
847
848 #if ENABLE(CSS_SHADERS)
849 static PassRef<WebKitCSSArrayFunctionValue> valueForCustomFilterArrayParameter(const CustomFilterArrayParameter* arrayParameter)
850 {
851     auto arrayParameterValue = WebKitCSSArrayFunctionValue::create();
852     for (unsigned i = 0, size = arrayParameter->size(); i < size; ++i)
853         arrayParameterValue.get().append(cssValuePool().createValue(arrayParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
854     return arrayParameterValue;
855 }
856
857 static PassRef<WebKitCSSMatFunctionValue> valueForCustomFilterMatParameter(const CustomFilterArrayParameter* matrixParameter)
858 {
859     auto matrixParameterValue = WebKitCSSMatFunctionValue::create();
860     for (unsigned i = 0, size = matrixParameter->size(); i < size; ++i)
861         matrixParameterValue.get().append(cssValuePool().createValue(matrixParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
862     return matrixParameterValue;
863 }
864
865 static PassRef<CSSValueList> valueForCustomFilterColorParameter(const CustomFilterColorParameter* colorParameter)
866 {
867     auto colorParameterValue = CSSValueList::createSpaceSeparated();
868     colorParameterValue.get().append(cssValuePool().createColorValue(colorParameter->color().rgb()));
869     return colorParameterValue;
870 }
871
872 static PassRef<CSSValueList> valueForCustomFilterNumberParameter(const CustomFilterNumberParameter* numberParameter)
873 {
874     auto numberParameterValue = CSSValueList::createSpaceSeparated();
875     for (unsigned i = 0; i < numberParameter->size(); ++i)
876         numberParameterValue.get().append(cssValuePool().createValue(numberParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
877     return numberParameterValue;
878 }
879
880 static PassRef<WebKitCSSTransformValue> 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 PassRef<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 PassRef<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 PassRef<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 PassRef<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     auto list = CSSValueList::createSpaceSeparated();
1157     for (size_t i = 0; i < trackSizes.size(); ++i) {
1158         addValuesForNamedGridLinesAtIndex(namedGridLines, i, list.get());
1159         list.get().append(valueForGridTrackSize(trackSizes[i], style, renderView));
1160     }
1161     // Those are the trailing <string>* allowed in the syntax.
1162     addValuesForNamedGridLinesAtIndex(namedGridLines, trackSizes.size(), list.get());
1163     return std::move(list);
1164 }
1165
1166 static PassRef<CSSValue> valueForGridPosition(const GridPosition& position)
1167 {
1168     if (position.isAuto())
1169         return cssValuePool().createIdentifierValue(CSSValueAuto);
1170
1171     if (position.isNamedGridArea())
1172         return cssValuePool().createValue(position.namedGridLine(), CSSPrimitiveValue::CSS_STRING);
1173
1174     auto list = CSSValueList::createSpaceSeparated();
1175     if (position.isSpan()) {
1176         list.get().append(cssValuePool().createIdentifierValue(CSSValueSpan));
1177         list.get().append(cssValuePool().createValue(position.spanPosition(), CSSPrimitiveValue::CSS_NUMBER));
1178     } else
1179         list.get().append(cssValuePool().createValue(position.integerPosition(), CSSPrimitiveValue::CSS_NUMBER));
1180
1181     if (!position.namedGridLine().isNull())
1182         list.get().append(cssValuePool().createValue(position.namedGridLine(), CSSPrimitiveValue::CSS_STRING));
1183     return std::move(list);
1184 }
1185
1186 static PassRef<CSSValue> createTransitionPropertyValue(const Animation& animation)
1187 {
1188     if (animation.animationMode() == Animation::AnimateNone)
1189         return cssValuePool().createIdentifierValue(CSSValueNone);
1190     if (animation.animationMode() == Animation::AnimateAll)
1191         return cssValuePool().createIdentifierValue(CSSValueAll);
1192     return cssValuePool().createValue(getPropertyNameString(animation.property()), CSSPrimitiveValue::CSS_STRING);
1193 }
1194
1195 static PassRef<CSSValueList> getTransitionPropertyValue(const AnimationList* animList)
1196 {
1197     auto list = CSSValueList::createCommaSeparated();
1198     if (animList) {
1199         for (size_t i = 0; i < animList->size(); ++i)
1200             list.get().append(createTransitionPropertyValue(animList->animation(i)));
1201     } else
1202         list.get().append(cssValuePool().createIdentifierValue(CSSValueAll));
1203     return list;
1204 }
1205
1206 static PassRef<CSSValueList> getDelayValue(const AnimationList* animList)
1207 {
1208     auto list = CSSValueList::createCommaSeparated();
1209     if (animList) {
1210         for (size_t i = 0; i < animList->size(); ++i)
1211             list.get().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.get().append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
1215     }
1216     return list;
1217 }
1218
1219 static PassRef<CSSValueList> getDurationValue(const AnimationList* animList)
1220 {
1221     auto list = CSSValueList::createCommaSeparated();
1222     if (animList) {
1223         for (size_t i = 0; i < animList->size(); ++i)
1224             list.get().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.get().append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
1228     }
1229     return list;
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 PassRef<CSSValueList> getTimingFunctionValue(const AnimationList* animList)
1272 {
1273     auto list = CSSValueList::createCommaSeparated();
1274     if (animList) {
1275         for (size_t i = 0; i < animList->size(); ++i)
1276             list.get().append(createTimingFunctionValue(animList->animation(i).timingFunction().get()));
1277     } else
1278         // Note that initialAnimationTimingFunction() is used for both transitions and animations
1279         list.get().append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
1280     return list;
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 #if ENABLE(LETTERPRESS)
1417     if (textDecoration & TextDecorationLetterpress)
1418         list->append(cssValuePool().createIdentifierValue(CSSValueWebkitLetterpress));
1419 #endif
1420
1421     if (!list->length())
1422         return cssValuePool().createIdentifierValue(CSSValueNone);
1423     return list.release();
1424 }
1425
1426 #if ENABLE(CSS3_TEXT_DECORATION)
1427 static PassRefPtr<CSSValue> renderTextDecorationStyleFlagsToCSSValue(TextDecorationStyle textDecorationStyle)
1428 {
1429     switch (textDecorationStyle) {
1430     case TextDecorationStyleSolid:
1431         return cssValuePool().createIdentifierValue(CSSValueSolid);
1432     case TextDecorationStyleDouble:
1433         return cssValuePool().createIdentifierValue(CSSValueDouble);
1434     case TextDecorationStyleDotted:
1435         return cssValuePool().createIdentifierValue(CSSValueDotted);
1436     case TextDecorationStyleDashed:
1437         return cssValuePool().createIdentifierValue(CSSValueDashed);
1438     case TextDecorationStyleWavy:
1439         return cssValuePool().createIdentifierValue(CSSValueWavy);
1440     }
1441
1442     ASSERT_NOT_REACHED();
1443     return cssValuePool().createExplicitInitialValue();
1444 }
1445
1446 static PassRefPtr<CSSValue> renderTextDecorationSkipFlagsToCSSValue(TextDecorationSkip textDecorationSkip)
1447 {
1448     switch (textDecorationSkip) {
1449     case TextDecorationSkipNone:
1450         return cssValuePool().createExplicitInitialValue();
1451     case TextDecorationSkipInk:
1452         return cssValuePool().createIdentifierValue(CSSValueInk);
1453     }
1454
1455     ASSERT_NOT_REACHED();
1456     return cssValuePool().createExplicitInitialValue();
1457 }
1458 #endif // CSS3_TEXT_DECORATION
1459
1460 static PassRefPtr<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat)
1461 {
1462     // For backwards compatibility, if both values are equal, just return one of them. And
1463     // if the two values are equivalent to repeat-x or repeat-y, just return the shorthand.
1464     if (xRepeat == yRepeat)
1465         return cssValuePool().createValue(xRepeat);
1466     if (xRepeat == RepeatFill && yRepeat == NoRepeatFill)
1467         return cssValuePool().createIdentifierValue(CSSValueRepeatX);
1468     if (xRepeat == NoRepeatFill && yRepeat == RepeatFill)
1469         return cssValuePool().createIdentifierValue(CSSValueRepeatY);
1470
1471     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1472     list->append(cssValuePool().createValue(xRepeat));
1473     list->append(cssValuePool().createValue(yRepeat));
1474     return list.release();
1475 }
1476
1477 static PassRefPtr<CSSValue> fillSourceTypeToCSSValue(EMaskSourceType type)
1478 {
1479     switch (type) {
1480     case MaskAlpha:
1481         return cssValuePool().createValue(CSSValueAlpha);
1482     case MaskLuminance:
1483         return cssValuePool().createValue(CSSValueLuminance);
1484     }
1485
1486     ASSERT_NOT_REACHED();
1487
1488     return 0;
1489 }
1490 static PassRefPtr<CSSValue> fillSizeToCSSValue(const FillSize& fillSize, const RenderStyle* style)
1491 {
1492     if (fillSize.type == Contain)
1493         return cssValuePool().createIdentifierValue(CSSValueContain);
1494
1495     if (fillSize.type == Cover)
1496         return cssValuePool().createIdentifierValue(CSSValueCover);
1497
1498     if (fillSize.size.height().isAuto())
1499         return zoomAdjustedPixelValueForLength(fillSize.size.width(), style);
1500
1501     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1502     list->append(zoomAdjustedPixelValueForLength(fillSize.size.width(), style));
1503     list->append(zoomAdjustedPixelValueForLength(fillSize.size.height(), style));
1504     return list.release();
1505 }
1506
1507 static PassRefPtr<CSSValue> altTextToCSSValue(const RenderStyle* style)
1508 {
1509     return cssValuePool().createValue(style->contentAltText(), CSSPrimitiveValue::CSS_STRING);
1510 }
1511     
1512 static PassRefPtr<CSSValue> contentToCSSValue(const RenderStyle* style)
1513 {
1514     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1515     for (const ContentData* contentData = style->contentData(); contentData; contentData = contentData->next()) {
1516         if (contentData->isCounter()) {
1517             const CounterContent* counter = static_cast<const CounterContentData*>(contentData)->counter();
1518             ASSERT(counter);
1519             list->append(cssValuePool().createValue(counter->identifier(), CSSPrimitiveValue::CSS_COUNTER_NAME));
1520         } else if (contentData->isImage()) {
1521             const StyleImage* image = static_cast<const ImageContentData*>(contentData)->image();
1522             ASSERT(image);
1523             list->append(image->cssValue());
1524         } else if (contentData->isText())
1525             list->append(cssValuePool().createValue(static_cast<const TextContentData*>(contentData)->text(), CSSPrimitiveValue::CSS_STRING));
1526     }
1527     if (style->hasFlowFrom())
1528         list->append(cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING));
1529     return list.release();
1530 }
1531
1532 static PassRefPtr<CSSValue> counterToCSSValue(const RenderStyle* style, CSSPropertyID propertyID)
1533 {
1534     const CounterDirectiveMap* map = style->counterDirectives();
1535     if (!map)
1536         return 0;
1537
1538     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1539     for (CounterDirectiveMap::const_iterator it = map->begin(); it != map->end(); ++it) {
1540         list->append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
1541         short number = propertyID == CSSPropertyCounterIncrement ? it->value.incrementValue() : it->value.resetValue();
1542         list->append(cssValuePool().createValue((double)number, CSSPrimitiveValue::CSS_NUMBER));
1543     }
1544     return list.release();
1545 }
1546
1547 static void logUnimplementedPropertyID(CSSPropertyID propertyID)
1548 {
1549     DEFINE_STATIC_LOCAL(HashSet<CSSPropertyID>, propertyIDSet, ());
1550     if (!propertyIDSet.add(propertyID).isNewEntry)
1551         return;
1552
1553     LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", getPropertyName(propertyID));
1554 }
1555
1556 static PassRefPtr<CSSValueList> fontFamilyFromStyle(RenderStyle* style)
1557     {
1558     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1559     for (unsigned i = 0; i < style->font().familyCount(); ++i)
1560         list->append(valueForFamily(style->font().familyAt(i)));
1561     return list.release();
1562 }
1563
1564 static PassRefPtr<CSSPrimitiveValue> lineHeightFromStyle(RenderStyle* style, RenderView* renderView)
1565 {
1566     Length length = style->lineHeight();
1567     if (length.isNegative())
1568         return cssValuePool().createIdentifierValue(CSSValueNormal);
1569     if (length.isPercent())
1570         // This is imperfect, because it doesn't include the zoom factor and the real computation
1571         // for how high to be in pixels does include things like minimum font size and the zoom factor.
1572         // On the other hand, since font-size doesn't include the zoom factor, we really can't do
1573         // that here either.
1574         return zoomAdjustedPixelValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, style);
1575     return zoomAdjustedPixelValue(floatValueForLength(length, 0, renderView), style);
1576 }
1577
1578 static PassRefPtr<CSSPrimitiveValue> fontSizeFromStyle(RenderStyle* style)
1579 {
1580     return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style);
1581 }
1582
1583 static PassRefPtr<CSSPrimitiveValue> fontStyleFromStyle(RenderStyle* style)
1584 {
1585     if (style->fontDescription().italic())
1586         return cssValuePool().createIdentifierValue(CSSValueItalic);
1587     return cssValuePool().createIdentifierValue(CSSValueNormal);
1588 }
1589
1590 static PassRefPtr<CSSPrimitiveValue> fontVariantFromStyle(RenderStyle* style)
1591 {
1592     if (style->fontDescription().smallCaps())
1593         return cssValuePool().createIdentifierValue(CSSValueSmallCaps);
1594     return cssValuePool().createIdentifierValue(CSSValueNormal);
1595 }
1596
1597 static PassRefPtr<CSSPrimitiveValue> fontWeightFromStyle(RenderStyle* style)
1598 {
1599     switch (style->fontDescription().weight()) {
1600     case FontWeight100:
1601         return cssValuePool().createIdentifierValue(CSSValue100);
1602     case FontWeight200:
1603         return cssValuePool().createIdentifierValue(CSSValue200);
1604     case FontWeight300:
1605         return cssValuePool().createIdentifierValue(CSSValue300);
1606     case FontWeightNormal:
1607         return cssValuePool().createIdentifierValue(CSSValueNormal);
1608     case FontWeight500:
1609         return cssValuePool().createIdentifierValue(CSSValue500);
1610     case FontWeight600:
1611         return cssValuePool().createIdentifierValue(CSSValue600);
1612     case FontWeightBold:
1613         return cssValuePool().createIdentifierValue(CSSValueBold);
1614     case FontWeight800:
1615         return cssValuePool().createIdentifierValue(CSSValue800);
1616     case FontWeight900:
1617         return cssValuePool().createIdentifierValue(CSSValue900);
1618     }
1619     ASSERT_NOT_REACHED();
1620     return cssValuePool().createIdentifierValue(CSSValueNormal);
1621 }
1622
1623 typedef const Length& (RenderStyle::*RenderStyleLengthGetter)() const;
1624 typedef LayoutUnit (RenderBoxModelObject::*RenderBoxComputedCSSValueGetter)() const;
1625
1626 template<RenderStyleLengthGetter lengthGetter, RenderBoxComputedCSSValueGetter computedCSSValueGetter>
1627 inline PassRefPtr<CSSValue> zoomAdjustedPaddingOrMarginPixelValue(RenderStyle* style, RenderObject* renderer)
1628 {
1629     Length unzoomzedLength = (style->*lengthGetter)();
1630     if (!renderer || !renderer->isBox() || unzoomzedLength.isFixed())
1631         return zoomAdjustedPixelValueForLength(unzoomzedLength, style);
1632     return zoomAdjustedPixelValue((toRenderBox(renderer)->*computedCSSValueGetter)(), style);
1633 }
1634
1635 template<RenderStyleLengthGetter lengthGetter>
1636 inline bool paddingOrMarginIsRendererDependent(RenderStyle* style, RenderObject* renderer)
1637 {
1638     if (!renderer || !renderer->isBox())
1639         return false;
1640     return !(style && (style->*lengthGetter)().isFixed());
1641 }
1642
1643 static bool isLayoutDependent(CSSPropertyID propertyID, RenderStyle* style, RenderObject* renderer)
1644 {
1645     switch (propertyID) {
1646     case CSSPropertyWidth:
1647     case CSSPropertyHeight:
1648     case CSSPropertyWebkitPerspectiveOrigin:
1649     case CSSPropertyWebkitTransformOrigin:
1650     case CSSPropertyWebkitTransform:
1651 #if ENABLE(CSS_FILTERS)
1652     case CSSPropertyWebkitFilter:
1653 #endif
1654         return true;
1655     case CSSPropertyMargin: {
1656         if (!renderer || !renderer->isBox())
1657             return false;
1658         return !(style && style->marginTop().isFixed() && style->marginRight().isFixed()
1659             && style->marginBottom().isFixed() && style->marginLeft().isFixed());
1660     }
1661     case CSSPropertyMarginTop:
1662         return paddingOrMarginIsRendererDependent<&RenderStyle::marginTop>(style, renderer);
1663     case CSSPropertyMarginRight:
1664         return paddingOrMarginIsRendererDependent<&RenderStyle::marginRight>(style, renderer);
1665     case CSSPropertyMarginBottom:
1666         return paddingOrMarginIsRendererDependent<&RenderStyle::marginBottom>(style, renderer);
1667     case CSSPropertyMarginLeft:
1668         return paddingOrMarginIsRendererDependent<&RenderStyle::marginLeft>(style, renderer);
1669     case CSSPropertyPadding: {
1670         if (!renderer || !renderer->isBox())
1671             return false;
1672         return !(style && style->paddingTop().isFixed() && style->paddingRight().isFixed()
1673             && style->paddingBottom().isFixed() && style->paddingLeft().isFixed());
1674     }
1675     case CSSPropertyPaddingTop:
1676         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingTop>(style, renderer);
1677     case CSSPropertyPaddingRight:
1678         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingRight>(style, renderer);
1679     case CSSPropertyPaddingBottom:
1680         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingBottom>(style, renderer);
1681     case CSSPropertyPaddingLeft:
1682         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingLeft>(style, renderer); 
1683     default:
1684         return false;
1685     }
1686 }
1687
1688 Node* ComputedStyleExtractor::styledNode() const
1689 {
1690     if (!m_node)
1691         return 0;
1692     if (!m_node->isElementNode())
1693         return m_node.get();
1694     Element* element = toElement(m_node.get());
1695     PseudoElement* pseudoElement;
1696     if (m_pseudoElementSpecifier == BEFORE && (pseudoElement = element->beforePseudoElement()))
1697         return pseudoElement;
1698     if (m_pseudoElementSpecifier == AFTER && (pseudoElement = element->afterPseudoElement()))
1699         return pseudoElement;
1700     return element;
1701 }
1702
1703 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1704 {
1705     return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).propertyValue(propertyID, updateLayout);
1706 }
1707
1708 PassRef<MutableStyleProperties> CSSComputedStyleDeclaration::copyProperties() const
1709 {
1710     return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).copyProperties();
1711 }
1712
1713 static inline bool nodeOrItsAncestorNeedsStyleRecalc(Node* styledNode)
1714 {
1715     if (styledNode->document().hasPendingForcedStyleRecalc())
1716         return true;
1717     for (Node* n = styledNode; n; n = n->parentNode()) {// FIXME: Call parentOrShadowHostNode() instead
1718         if (n->needsStyleRecalc())
1719             return true;
1720     }
1721     return false;
1722 }
1723
1724 static inline PassRefPtr<RenderStyle> computeRenderStyleForProperty(Node* styledNode, PseudoId pseudoElementSpecifier, CSSPropertyID propertyID)
1725 {
1726     RenderObject* renderer = styledNode->renderer();
1727
1728     if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
1729         AnimationUpdateBlock animationUpdateBlock(&renderer->animation());
1730         RefPtr<RenderStyle> style = renderer->animation().getAnimatedStyleForRenderer(toRenderElement(renderer));
1731         if (pseudoElementSpecifier && !styledNode->isPseudoElement()) {
1732             // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
1733             return style->getCachedPseudoStyle(pseudoElementSpecifier);
1734         }
1735         return style.release();
1736     }
1737
1738     return styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : pseudoElementSpecifier);
1739 }
1740
1741 PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1742 {
1743     Node* styledNode = this->styledNode();
1744     if (!styledNode)
1745         return 0;
1746
1747     RefPtr<RenderStyle> style;
1748     RenderObject* renderer = 0;
1749     bool forceFullLayout = false;
1750     if (updateLayout) {
1751         Document& document = styledNode->document();
1752
1753         if (nodeOrItsAncestorNeedsStyleRecalc(styledNode)) {
1754             document.updateStyleIfNeeded();
1755             // The style recalc could have caused the styled node to be discarded or replaced
1756             // if it was a PseudoElement so we need to update it.
1757             styledNode = this->styledNode();
1758         }
1759
1760         style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID);
1761         renderer = styledNode->renderer();
1762
1763         // FIXME: Some of these cases could be narrowed down or optimized better.
1764         forceFullLayout = isLayoutDependent(propertyID, style.get(), renderer)
1765             || styledNode->isInShadowTree()
1766             || (document.styleResolverIfExists() && document.styleResolverIfExists()->hasViewportDependentMediaQueries() && document.ownerElement())
1767             || document.seamlessParentIFrame();
1768
1769         if (forceFullLayout) {
1770             document.updateLayoutIgnorePendingStylesheets();
1771             styledNode = this->styledNode();
1772         }
1773     }
1774
1775     if (!updateLayout || forceFullLayout) {
1776         style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID);
1777         renderer = styledNode->renderer();
1778     }
1779
1780     if (!style)
1781         return 0;
1782
1783     propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction(), style->writingMode());
1784
1785     switch (propertyID) {
1786         case CSSPropertyInvalid:
1787             break;
1788
1789         case CSSPropertyBackgroundColor:
1790             return cssValuePool().createColorValue(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb());
1791         case CSSPropertyBackgroundImage:
1792         case CSSPropertyWebkitMaskImage: {
1793             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskImage ? style->maskLayers() : style->backgroundLayers();
1794             if (!layers)
1795                 return cssValuePool().createIdentifierValue(CSSValueNone);
1796
1797             if (!layers->next()) {
1798                 if (layers->image())
1799                     return layers->image()->cssValue();
1800
1801                 return cssValuePool().createIdentifierValue(CSSValueNone);
1802             }
1803
1804             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1805             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1806                 if (currLayer->image())
1807                     list->append(currLayer->image()->cssValue());
1808                 else
1809                     list->append(cssValuePool().createIdentifierValue(CSSValueNone));
1810             }
1811             return list.release();
1812         }
1813         case CSSPropertyBackgroundSize:
1814         case CSSPropertyWebkitBackgroundSize:
1815         case CSSPropertyWebkitMaskSize: {
1816             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskSize ? style->maskLayers() : style->backgroundLayers();
1817             if (!layers->next())
1818                 return fillSizeToCSSValue(layers->size(), style.get());
1819
1820             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1821             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1822                 list->append(fillSizeToCSSValue(currLayer->size(), style.get()));
1823
1824             return list.release();
1825         }
1826         case CSSPropertyBackgroundRepeat:
1827         case CSSPropertyWebkitMaskRepeat: {
1828             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskRepeat ? style->maskLayers() : style->backgroundLayers();
1829             if (!layers->next())
1830                 return fillRepeatToCSSValue(layers->repeatX(), layers->repeatY());
1831
1832             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1833             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1834                 list->append(fillRepeatToCSSValue(currLayer->repeatX(), currLayer->repeatY()));
1835
1836             return list.release();
1837         }
1838         case CSSPropertyWebkitMaskSourceType: {
1839             const FillLayer* layers = style->maskLayers();
1840
1841             if (!layers)
1842                 return cssValuePool().createIdentifierValue(CSSValueNone);
1843
1844             if (!layers->next())
1845                 return fillSourceTypeToCSSValue(layers->maskSourceType());
1846
1847             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1848             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1849                 list->append(fillSourceTypeToCSSValue(currLayer->maskSourceType()));
1850
1851             return list.release();
1852         }
1853         case CSSPropertyWebkitBackgroundComposite:
1854         case CSSPropertyWebkitMaskComposite: {
1855             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskComposite ? style->maskLayers() : style->backgroundLayers();
1856             if (!layers->next())
1857                 return cssValuePool().createValue(layers->composite());
1858
1859             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1860             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1861                 list->append(cssValuePool().createValue(currLayer->composite()));
1862
1863             return list.release();
1864         }
1865         case CSSPropertyBackgroundAttachment: {
1866             const FillLayer* layers = style->backgroundLayers();
1867             if (!layers->next())
1868                 return cssValuePool().createValue(layers->attachment());
1869
1870             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1871             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1872                 list->append(cssValuePool().createValue(currLayer->attachment()));
1873
1874             return list.release();
1875         }
1876         case CSSPropertyBackgroundClip:
1877         case CSSPropertyBackgroundOrigin:
1878         case CSSPropertyWebkitBackgroundClip:
1879         case CSSPropertyWebkitBackgroundOrigin:
1880         case CSSPropertyWebkitMaskClip:
1881         case CSSPropertyWebkitMaskOrigin: {
1882             const FillLayer* layers = (propertyID == CSSPropertyWebkitMaskClip || propertyID == CSSPropertyWebkitMaskOrigin) ? style->maskLayers() : style->backgroundLayers();
1883             bool isClip = propertyID == CSSPropertyBackgroundClip || propertyID == CSSPropertyWebkitBackgroundClip || propertyID == CSSPropertyWebkitMaskClip;
1884             if (!layers->next()) {
1885                 EFillBox box = isClip ? layers->clip() : layers->origin();
1886                 return cssValuePool().createValue(box);
1887             }
1888
1889             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1890             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1891                 EFillBox box = isClip ? currLayer->clip() : currLayer->origin();
1892                 list->append(cssValuePool().createValue(box));
1893             }
1894
1895             return list.release();
1896         }
1897         case CSSPropertyBackgroundPosition:
1898         case CSSPropertyWebkitMaskPosition: {
1899             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPosition ? style->maskLayers() : style->backgroundLayers();
1900             if (!layers->next())
1901                 return createPositionListForLayer(propertyID, layers, style.get());
1902
1903             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1904             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1905                 list->append(createPositionListForLayer(propertyID, currLayer, style.get()));
1906             return list.release();
1907         }
1908         case CSSPropertyBackgroundPositionX:
1909         case CSSPropertyWebkitMaskPositionX: {
1910             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionX ? style->maskLayers() : style->backgroundLayers();
1911             if (!layers->next())
1912                 return cssValuePool().createValue(layers->xPosition());
1913
1914             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1915             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1916                 list->append(cssValuePool().createValue(currLayer->xPosition()));
1917
1918             return list.release();
1919         }
1920         case CSSPropertyBackgroundPositionY:
1921         case CSSPropertyWebkitMaskPositionY: {
1922             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionY ? style->maskLayers() : style->backgroundLayers();
1923             if (!layers->next())
1924                 return cssValuePool().createValue(layers->yPosition());
1925
1926             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1927             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1928                 list->append(cssValuePool().createValue(currLayer->yPosition()));
1929
1930             return list.release();
1931         }
1932         case CSSPropertyBorderCollapse:
1933             if (style->borderCollapse())
1934                 return cssValuePool().createIdentifierValue(CSSValueCollapse);
1935             return cssValuePool().createIdentifierValue(CSSValueSeparate);
1936         case CSSPropertyBorderSpacing: {
1937             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1938             list->append(zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get()));
1939             list->append(zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get()));
1940             return list.release();
1941         }
1942         case CSSPropertyWebkitBorderHorizontalSpacing:
1943             return zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get());
1944         case CSSPropertyWebkitBorderVerticalSpacing:
1945             return zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get());
1946         case CSSPropertyBorderImageSource:
1947             if (style->borderImageSource())
1948                 return style->borderImageSource()->cssValue();
1949             return cssValuePool().createIdentifierValue(CSSValueNone);
1950         case CSSPropertyBorderTopColor:
1951             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor());
1952         case CSSPropertyBorderRightColor:
1953             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor());
1954         case CSSPropertyBorderBottomColor:
1955             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor());
1956         case CSSPropertyBorderLeftColor:
1957             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor());
1958         case CSSPropertyBorderTopStyle:
1959             return cssValuePool().createValue(style->borderTopStyle());
1960         case CSSPropertyBorderRightStyle:
1961             return cssValuePool().createValue(style->borderRightStyle());
1962         case CSSPropertyBorderBottomStyle:
1963             return cssValuePool().createValue(style->borderBottomStyle());
1964         case CSSPropertyBorderLeftStyle:
1965             return cssValuePool().createValue(style->borderLeftStyle());
1966         case CSSPropertyBorderTopWidth:
1967             return zoomAdjustedPixelValue(style->borderTopWidth(), style.get());
1968         case CSSPropertyBorderRightWidth:
1969             return zoomAdjustedPixelValue(style->borderRightWidth(), style.get());
1970         case CSSPropertyBorderBottomWidth:
1971             return zoomAdjustedPixelValue(style->borderBottomWidth(), style.get());
1972         case CSSPropertyBorderLeftWidth:
1973             return zoomAdjustedPixelValue(style->borderLeftWidth(), style.get());
1974         case CSSPropertyBottom:
1975             return getPositionOffsetValue(style.get(), CSSPropertyBottom, m_node->document().renderView());
1976         case CSSPropertyWebkitBoxAlign:
1977             return cssValuePool().createValue(style->boxAlign());
1978 #if ENABLE(CSS_BOX_DECORATION_BREAK)
1979         case CSSPropertyWebkitBoxDecorationBreak:
1980             if (style->boxDecorationBreak() == DSLICE)
1981                 return cssValuePool().createIdentifierValue(CSSValueSlice);
1982         return cssValuePool().createIdentifierValue(CSSValueClone);
1983 #endif
1984         case CSSPropertyWebkitBoxDirection:
1985             return cssValuePool().createValue(style->boxDirection());
1986         case CSSPropertyWebkitBoxFlex:
1987             return cssValuePool().createValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
1988         case CSSPropertyWebkitBoxFlexGroup:
1989             return cssValuePool().createValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
1990         case CSSPropertyWebkitBoxLines:
1991             return cssValuePool().createValue(style->boxLines());
1992         case CSSPropertyWebkitBoxOrdinalGroup:
1993             return cssValuePool().createValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
1994         case CSSPropertyWebkitBoxOrient:
1995             return cssValuePool().createValue(style->boxOrient());
1996         case CSSPropertyWebkitBoxPack:
1997             return cssValuePool().createValue(style->boxPack());
1998         case CSSPropertyWebkitBoxReflect:
1999             return valueForReflection(style->boxReflect(), style.get());
2000         case CSSPropertyBoxShadow:
2001         case CSSPropertyWebkitBoxShadow:
2002             return valueForShadow(style->boxShadow(), propertyID, style.get());
2003         case CSSPropertyCaptionSide:
2004             return cssValuePool().createValue(style->captionSide());
2005         case CSSPropertyClear:
2006             return cssValuePool().createValue(style->clear());
2007         case CSSPropertyColor:
2008             return cssValuePool().createColorValue(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb());
2009         case CSSPropertyWebkitPrintColorAdjust:
2010             return cssValuePool().createValue(style->printColorAdjust());
2011         case CSSPropertyWebkitColumnAxis:
2012             return cssValuePool().createValue(style->columnAxis());
2013         case CSSPropertyWebkitColumnCount:
2014             if (style->hasAutoColumnCount())
2015                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2016             return cssValuePool().createValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
2017         case CSSPropertyWebkitColumnFill:
2018             return cssValuePool().createValue(style->columnFill());
2019         case CSSPropertyWebkitColumnGap:
2020             if (style->hasNormalColumnGap())
2021                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2022             return zoomAdjustedPixelValue(style->columnGap(), style.get());
2023         case CSSPropertyWebkitColumnProgression:
2024             return cssValuePool().createValue(style->columnProgression());
2025         case CSSPropertyWebkitColumnRuleColor:
2026             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor());
2027         case CSSPropertyWebkitColumnRuleStyle:
2028             return cssValuePool().createValue(style->columnRuleStyle());
2029         case CSSPropertyWebkitColumnRuleWidth:
2030             return zoomAdjustedPixelValue(style->columnRuleWidth(), style.get());
2031         case CSSPropertyWebkitColumnSpan:
2032             return cssValuePool().createIdentifierValue(style->columnSpan() ? CSSValueAll : CSSValueNone);
2033         case CSSPropertyWebkitColumnBreakAfter:
2034             return cssValuePool().createValue(style->columnBreakAfter());
2035         case CSSPropertyWebkitColumnBreakBefore:
2036             return cssValuePool().createValue(style->columnBreakBefore());
2037         case CSSPropertyWebkitColumnBreakInside:
2038             return cssValuePool().createValue(style->columnBreakInside());
2039         case CSSPropertyWebkitColumnWidth:
2040             if (style->hasAutoColumnWidth())
2041                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2042             return zoomAdjustedPixelValue(style->columnWidth(), style.get());
2043         case CSSPropertyTabSize:
2044             return cssValuePool().createValue(style->tabSize(), CSSPrimitiveValue::CSS_NUMBER);
2045 #if ENABLE(CSS_REGIONS)
2046         case CSSPropertyWebkitRegionBreakAfter:
2047             return cssValuePool().createValue(style->regionBreakAfter());
2048         case CSSPropertyWebkitRegionBreakBefore:
2049             return cssValuePool().createValue(style->regionBreakBefore());
2050         case CSSPropertyWebkitRegionBreakInside:
2051             return cssValuePool().createValue(style->regionBreakInside());
2052 #endif
2053         case CSSPropertyCursor: {
2054             RefPtr<CSSValueList> list;
2055             CursorList* cursors = style->cursors();
2056             if (cursors && cursors->size() > 0) {
2057                 list = CSSValueList::createCommaSeparated();
2058                 for (unsigned i = 0; i < cursors->size(); ++i)
2059                     if (StyleImage* image = cursors->at(i).image())
2060                         list->append(image->cssValue());
2061             }
2062             RefPtr<CSSValue> value = cssValuePool().createValue(style->cursor());
2063             if (list) {
2064                 list->append(value.release());
2065                 return list.release();
2066             }
2067             return value.release();
2068         }
2069 #if ENABLE(CURSOR_VISIBILITY)
2070         case CSSPropertyWebkitCursorVisibility:
2071             return cssValuePool().createValue(style->cursorVisibility());
2072 #endif
2073         case CSSPropertyDirection:
2074             return cssValuePool().createValue(style->direction());
2075         case CSSPropertyDisplay:
2076             return cssValuePool().createValue(style->display());
2077         case CSSPropertyEmptyCells:
2078             return cssValuePool().createValue(style->emptyCells());
2079         case CSSPropertyWebkitAlignContent:
2080             return cssValuePool().createValue(style->alignContent());
2081         case CSSPropertyWebkitAlignItems:
2082             return cssValuePool().createValue(style->alignItems());
2083         case CSSPropertyWebkitAlignSelf:
2084             if (style->alignSelf() == AlignAuto) {
2085                 Node* parent = styledNode->parentNode();
2086                 if (parent && parent->computedStyle())
2087                     return cssValuePool().createValue(parent->computedStyle()->alignItems());
2088                 return cssValuePool().createValue(AlignStretch);
2089             }
2090             return cssValuePool().createValue(style->alignSelf());
2091         case CSSPropertyWebkitFlex:
2092             return getCSSPropertyValuesForShorthandProperties(webkitFlexShorthand());
2093         case CSSPropertyWebkitFlexBasis:
2094             return cssValuePool().createValue(style->flexBasis());
2095         case CSSPropertyWebkitFlexDirection:
2096             return cssValuePool().createValue(style->flexDirection());
2097         case CSSPropertyWebkitFlexFlow:
2098             return getCSSPropertyValuesForShorthandProperties(webkitFlexFlowShorthand());
2099         case CSSPropertyWebkitFlexGrow:
2100             return cssValuePool().createValue(style->flexGrow());
2101         case CSSPropertyWebkitFlexShrink:
2102             return cssValuePool().createValue(style->flexShrink());
2103         case CSSPropertyWebkitFlexWrap:
2104             return cssValuePool().createValue(style->flexWrap());
2105         case CSSPropertyWebkitJustifyContent:
2106             return cssValuePool().createValue(style->justifyContent());
2107         case CSSPropertyWebkitOrder:
2108             return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
2109         case CSSPropertyFloat:
2110             if (style->display() != NONE && style->hasOutOfFlowPosition())
2111                 return cssValuePool().createIdentifierValue(CSSValueNone);
2112             return cssValuePool().createValue(style->floating());
2113         case CSSPropertyFont: {
2114             RefPtr<CSSFontValue> computedFont = CSSFontValue::create();
2115             computedFont->style = fontStyleFromStyle(style.get());
2116             computedFont->variant = fontVariantFromStyle(style.get());
2117             computedFont->weight = fontWeightFromStyle(style.get());
2118             computedFont->size = fontSizeFromStyle(style.get());
2119             computedFont->lineHeight = lineHeightFromStyle(style.get(), m_node->document().renderView());
2120             computedFont->family = fontFamilyFromStyle(style.get());
2121             return computedFont.release();
2122         }
2123         case CSSPropertyFontFamily: {
2124             RefPtr<CSSValueList> fontFamilyList = fontFamilyFromStyle(style.get());
2125             // If there's only a single family, return that as a CSSPrimitiveValue.
2126             // NOTE: Gecko always returns this as a comma-separated CSSPrimitiveValue string.
2127             if (fontFamilyList->length() == 1)
2128                 return fontFamilyList->item(0);
2129             return fontFamilyList.release();
2130         }
2131         case CSSPropertyFontSize:
2132             return fontSizeFromStyle(style.get());
2133         case CSSPropertyFontStyle:
2134             return fontStyleFromStyle(style.get());
2135         case CSSPropertyFontVariant:
2136             return fontVariantFromStyle(style.get());
2137         case CSSPropertyFontWeight:
2138             return fontWeightFromStyle(style.get());
2139         case CSSPropertyWebkitFontFeatureSettings: {
2140             const FontFeatureSettings* featureSettings = style->fontDescription().featureSettings();
2141             if (!featureSettings || !featureSettings->size())
2142                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2143             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2144             for (unsigned i = 0; i < featureSettings->size(); ++i) {
2145                 const FontFeature& feature = featureSettings->at(i);
2146                 list->append(CSSFontFeatureValue::create(feature.tag(), feature.value()));
2147             }
2148             return list.release();
2149         }
2150         case CSSPropertyWebkitGridAutoColumns:
2151             return valueForGridTrackSize(style->gridAutoColumns(), style.get(), m_node->document().renderView());
2152         case CSSPropertyWebkitGridAutoFlow:
2153             return cssValuePool().createValue(style->gridAutoFlow());
2154         case CSSPropertyWebkitGridAutoRows:
2155             return valueForGridTrackSize(style->gridAutoRows(), style.get(), m_node->document().renderView());
2156         case CSSPropertyWebkitGridDefinitionColumns:
2157             return valueForGridTrackList(style->gridColumns(), style->namedGridColumnLines(), style.get(), m_node->document().renderView());
2158         case CSSPropertyWebkitGridDefinitionRows:
2159             return valueForGridTrackList(style->gridRows(), style->namedGridRowLines(), style.get(), m_node->document().renderView());
2160
2161         case CSSPropertyWebkitGridColumnStart:
2162             return valueForGridPosition(style->gridItemColumnStart());
2163         case CSSPropertyWebkitGridColumnEnd:
2164             return valueForGridPosition(style->gridItemColumnEnd());
2165         case CSSPropertyWebkitGridRowStart:
2166             return valueForGridPosition(style->gridItemRowStart());
2167         case CSSPropertyWebkitGridRowEnd:
2168             return valueForGridPosition(style->gridItemRowEnd());
2169         case CSSPropertyWebkitGridArea:
2170             return getCSSPropertyValuesForGridShorthand(webkitGridAreaShorthand());
2171         case CSSPropertyWebkitGridColumn:
2172             return getCSSPropertyValuesForGridShorthand(webkitGridColumnShorthand());
2173         case CSSPropertyWebkitGridRow:
2174             return getCSSPropertyValuesForGridShorthand(webkitGridRowShorthand());
2175
2176         case CSSPropertyWebkitGridTemplate:
2177             if (!style->namedGridAreaRowCount()) {
2178                 ASSERT(!style->namedGridAreaColumnCount());
2179                 return cssValuePool().createIdentifierValue(CSSValueNone);
2180             }
2181
2182             return CSSGridTemplateValue::create(style->namedGridArea(), style->namedGridAreaRowCount(), style->namedGridAreaColumnCount());
2183
2184         case CSSPropertyHeight:
2185             if (renderer) {
2186                 // According to http://www.w3.org/TR/CSS2/visudet.html#the-height-property,
2187                 // the "height" property does not apply for non-replaced inline elements.
2188                 if (!renderer->isReplaced() && renderer->isInline())
2189                     return cssValuePool().createIdentifierValue(CSSValueAuto);
2190                 return zoomAdjustedPixelValue(sizingBox(renderer).height(), style.get());
2191             }
2192             return zoomAdjustedPixelValueForLength(style->height(), style.get());
2193         case CSSPropertyWebkitHighlight:
2194             if (style->highlight() == nullAtom)
2195                 return cssValuePool().createIdentifierValue(CSSValueNone);
2196             return cssValuePool().createValue(style->highlight(), CSSPrimitiveValue::CSS_STRING);
2197         case CSSPropertyWebkitHyphens:
2198             return cssValuePool().createValue(style->hyphens());
2199         case CSSPropertyWebkitHyphenateCharacter:
2200             if (style->hyphenationString().isNull())
2201                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2202             return cssValuePool().createValue(style->hyphenationString(), CSSPrimitiveValue::CSS_STRING);
2203         case CSSPropertyWebkitHyphenateLimitAfter:
2204             if (style->hyphenationLimitAfter() < 0)
2205                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
2206             return CSSPrimitiveValue::create(style->hyphenationLimitAfter(), CSSPrimitiveValue::CSS_NUMBER);
2207         case CSSPropertyWebkitHyphenateLimitBefore:
2208             if (style->hyphenationLimitBefore() < 0)
2209                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
2210             return CSSPrimitiveValue::create(style->hyphenationLimitBefore(), CSSPrimitiveValue::CSS_NUMBER);
2211         case CSSPropertyWebkitHyphenateLimitLines:
2212             if (style->hyphenationLimitLines() < 0)
2213                 return CSSPrimitiveValue::createIdentifier(CSSValueNoLimit);
2214             return CSSPrimitiveValue::create(style->hyphenationLimitLines(), CSSPrimitiveValue::CSS_NUMBER);
2215         case CSSPropertyWebkitBorderFit:
2216             if (style->borderFit() == BorderFitBorder)
2217                 return cssValuePool().createIdentifierValue(CSSValueBorder);
2218             return cssValuePool().createIdentifierValue(CSSValueLines);
2219 #if ENABLE(CSS_IMAGE_ORIENTATION)
2220         case CSSPropertyImageOrientation:
2221             return cssValuePool().createValue(style->imageOrientation());
2222 #endif
2223         case CSSPropertyImageRendering:
2224             return CSSPrimitiveValue::create(style->imageRendering());
2225 #if ENABLE(CSS_IMAGE_RESOLUTION)
2226         case CSSPropertyImageResolution:
2227             return cssValuePool().createValue(style->imageResolution(), CSSPrimitiveValue::CSS_DPPX);
2228 #endif
2229         case CSSPropertyLeft:
2230             return getPositionOffsetValue(style.get(), CSSPropertyLeft, m_node->document().renderView());
2231         case CSSPropertyLetterSpacing:
2232             if (!style->letterSpacing())
2233                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2234             return zoomAdjustedPixelValue(style->letterSpacing(), style.get());
2235         case CSSPropertyWebkitLineClamp:
2236             if (style->lineClamp().isNone())
2237                 return cssValuePool().createIdentifierValue(CSSValueNone);
2238             return cssValuePool().createValue(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
2239         case CSSPropertyLineHeight:
2240             return lineHeightFromStyle(style.get(), m_node->document().renderView());
2241         case CSSPropertyListStyleImage:
2242             if (style->listStyleImage())
2243                 return style->listStyleImage()->cssValue();
2244             return cssValuePool().createIdentifierValue(CSSValueNone);
2245         case CSSPropertyListStylePosition:
2246             return cssValuePool().createValue(style->listStylePosition());
2247         case CSSPropertyListStyleType:
2248             return cssValuePool().createValue(style->listStyleType());
2249         case CSSPropertyWebkitLocale:
2250             if (style->locale().isNull())
2251                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2252             return cssValuePool().createValue(style->locale(), CSSPrimitiveValue::CSS_STRING);
2253         case CSSPropertyMarginTop:
2254             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginTop, &RenderBoxModelObject::marginTop>(style.get(), renderer);
2255         case CSSPropertyMarginRight: {
2256             Length marginRight = style->marginRight();
2257             if (marginRight.isFixed() || !renderer || !renderer->isBox())
2258                 return zoomAdjustedPixelValueForLength(marginRight, style.get());
2259             float value;
2260             if (marginRight.isPercent() || marginRight.isViewportPercentage())
2261                 // RenderBox gives a marginRight() that is the distance between the right-edge of the child box
2262                 // and the right-edge of the containing box, when display == BLOCK. Let's calculate the absolute
2263                 // value of the specified margin-right % instead of relying on RenderBox's marginRight() value.
2264                 value = minimumValueForLength(marginRight, toRenderBox(renderer)->containingBlockLogicalWidthForContent(), m_node->document().renderView());
2265             else
2266                 value = toRenderBox(renderer)->marginRight();
2267             return zoomAdjustedPixelValue(value, style.get());
2268         }
2269         case CSSPropertyMarginBottom:
2270             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginBottom, &RenderBoxModelObject::marginBottom>(style.get(), renderer);
2271         case CSSPropertyMarginLeft:
2272             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginLeft, &RenderBoxModelObject::marginLeft>(style.get(), renderer);
2273         case CSSPropertyWebkitMarqueeDirection:
2274             return cssValuePool().createValue(style->marqueeDirection());
2275         case CSSPropertyWebkitMarqueeIncrement:
2276             return cssValuePool().createValue(style->marqueeIncrement());
2277         case CSSPropertyWebkitMarqueeRepetition:
2278             if (style->marqueeLoopCount() < 0)
2279                 return cssValuePool().createIdentifierValue(CSSValueInfinite);
2280             return cssValuePool().createValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
2281         case CSSPropertyWebkitMarqueeStyle:
2282             return cssValuePool().createValue(style->marqueeBehavior());
2283         case CSSPropertyWebkitUserModify:
2284             return cssValuePool().createValue(style->userModify());
2285         case CSSPropertyMaxHeight: {
2286             const Length& maxHeight = style->maxHeight();
2287             if (maxHeight.isUndefined())
2288                 return cssValuePool().createIdentifierValue(CSSValueNone);
2289             return zoomAdjustedPixelValueForLength(maxHeight, style.get());
2290         }
2291         case CSSPropertyMaxWidth: {
2292             const Length& maxWidth = style->maxWidth();
2293             if (maxWidth.isUndefined())
2294                 return cssValuePool().createIdentifierValue(CSSValueNone);
2295             return zoomAdjustedPixelValueForLength(maxWidth, style.get());
2296         }
2297         case CSSPropertyMinHeight:
2298             // FIXME: For flex-items, min-height:auto should compute to min-content.
2299             if (style->minHeight().isAuto())
2300                 return zoomAdjustedPixelValue(0, style.get());
2301             return zoomAdjustedPixelValueForLength(style->minHeight(), style.get());
2302         case CSSPropertyMinWidth:
2303             // FIXME: For flex-items, min-width:auto should compute to min-content.
2304             if (style->minWidth().isAuto())
2305                 return zoomAdjustedPixelValue(0, style.get());
2306             return zoomAdjustedPixelValueForLength(style->minWidth(), style.get());
2307         case CSSPropertyObjectFit:
2308             return cssValuePool().createValue(style->objectFit());
2309         case CSSPropertyOpacity:
2310             return cssValuePool().createValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
2311         case CSSPropertyOrphans:
2312             if (style->hasAutoOrphans())
2313                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2314             return cssValuePool().createValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
2315         case CSSPropertyOutlineColor:
2316             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor());
2317         case CSSPropertyOutlineOffset:
2318             return zoomAdjustedPixelValue(style->outlineOffset(), style.get());
2319         case CSSPropertyOutlineStyle:
2320             if (style->outlineStyleIsAuto())
2321                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2322             return cssValuePool().createValue(style->outlineStyle());
2323         case CSSPropertyOutlineWidth:
2324             return zoomAdjustedPixelValue(style->outlineWidth(), style.get());
2325         case CSSPropertyOverflow:
2326             return cssValuePool().createValue(std::max(style->overflowX(), style->overflowY()));
2327         case CSSPropertyOverflowWrap:
2328             return cssValuePool().createValue(style->overflowWrap());
2329         case CSSPropertyOverflowX:
2330             return cssValuePool().createValue(style->overflowX());
2331         case CSSPropertyOverflowY:
2332             return cssValuePool().createValue(style->overflowY());
2333         case CSSPropertyPaddingTop:
2334             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingTop, &RenderBoxModelObject::computedCSSPaddingTop>(style.get(), renderer);
2335         case CSSPropertyPaddingRight:
2336             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingRight, &RenderBoxModelObject::computedCSSPaddingRight>(style.get(), renderer);
2337         case CSSPropertyPaddingBottom:
2338             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingBottom, &RenderBoxModelObject::computedCSSPaddingBottom>(style.get(), renderer);
2339         case CSSPropertyPaddingLeft:
2340             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingLeft, &RenderBoxModelObject::computedCSSPaddingLeft>(style.get(), renderer);
2341         case CSSPropertyPageBreakAfter:
2342             return cssValuePool().createValue(style->pageBreakAfter());
2343         case CSSPropertyPageBreakBefore:
2344             return cssValuePool().createValue(style->pageBreakBefore());
2345         case CSSPropertyPageBreakInside: {
2346             EPageBreak pageBreak = style->pageBreakInside();
2347             ASSERT(pageBreak != PBALWAYS);
2348             if (pageBreak == PBALWAYS)
2349                 return 0;
2350             return cssValuePool().createValue(style->pageBreakInside());
2351         }
2352         case CSSPropertyPosition:
2353             return cssValuePool().createValue(style->position());
2354         case CSSPropertyRight:
2355             return getPositionOffsetValue(style.get(), CSSPropertyRight, m_node->document().renderView());
2356         case CSSPropertyWebkitRubyPosition:
2357             return cssValuePool().createValue(style->rubyPosition());
2358         case CSSPropertyTableLayout:
2359             return cssValuePool().createValue(style->tableLayout());
2360         case CSSPropertyTextAlign:
2361             return cssValuePool().createValue(style->textAlign());
2362         case CSSPropertyTextDecoration:
2363             return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2364 #if ENABLE(CSS3_TEXT)
2365         case CSSPropertyWebkitTextAlignLast:
2366             return cssValuePool().createValue(style->textAlignLast());
2367         case CSSPropertyWebkitTextJustify:
2368             return cssValuePool().createValue(style->textJustify());
2369 #endif // CSS3_TEXT
2370 #if ENABLE(CSS3_TEXT_DECORATION)
2371         case CSSPropertyWebkitTextDecoration:
2372             return getCSSPropertyValuesForShorthandProperties(webkitTextDecorationShorthand());
2373         case CSSPropertyWebkitTextDecorationLine:
2374             return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2375         case CSSPropertyWebkitTextDecorationStyle:
2376             return renderTextDecorationStyleFlagsToCSSValue(style->textDecorationStyle());
2377         case CSSPropertyWebkitTextDecorationColor:
2378             return currentColorOrValidColor(style.get(), style->textDecorationColor());
2379         case CSSPropertyWebkitTextDecorationSkip:
2380             return renderTextDecorationSkipFlagsToCSSValue(style->textDecorationSkip());
2381         case CSSPropertyWebkitTextUnderlinePosition:
2382             return cssValuePool().createValue(style->textUnderlinePosition());
2383 #endif
2384         case CSSPropertyWebkitTextDecorationsInEffect:
2385             return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect());
2386         case CSSPropertyWebkitTextFillColor:
2387             return currentColorOrValidColor(style.get(), style->textFillColor());
2388         case CSSPropertyWebkitTextEmphasisColor:
2389             return currentColorOrValidColor(style.get(), style->textEmphasisColor());
2390         case CSSPropertyWebkitTextEmphasisPosition:
2391             return cssValuePool().createValue(style->textEmphasisPosition());
2392         case CSSPropertyWebkitTextEmphasisStyle:
2393             switch (style->textEmphasisMark()) {
2394             case TextEmphasisMarkNone:
2395                 return cssValuePool().createIdentifierValue(CSSValueNone);
2396             case TextEmphasisMarkCustom:
2397                 return cssValuePool().createValue(style->textEmphasisCustomMark(), CSSPrimitiveValue::CSS_STRING);
2398             case TextEmphasisMarkAuto:
2399                 ASSERT_NOT_REACHED();
2400                 // Fall through
2401             case TextEmphasisMarkDot:
2402             case TextEmphasisMarkCircle:
2403             case TextEmphasisMarkDoubleCircle:
2404             case TextEmphasisMarkTriangle:
2405             case TextEmphasisMarkSesame: {
2406                 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2407                 list->append(cssValuePool().createValue(style->textEmphasisFill()));
2408                 list->append(cssValuePool().createValue(style->textEmphasisMark()));
2409                 return list.release();
2410             }
2411             }
2412         case CSSPropertyTextIndent: {
2413             // If CSS3_TEXT is disabled or text-indent has only one value(<length> | <percentage>),
2414             // getPropertyCSSValue() returns CSSValue.
2415             RefPtr<CSSValue> textIndent = zoomAdjustedPixelValueForLength(style->textIndent(), style.get());
2416 #if ENABLE(CSS3_TEXT)
2417             // If CSS3_TEXT is enabled and text-indent has -webkit-each-line or -webkit-hanging,
2418             // getPropertyCSSValue() returns CSSValueList.
2419             if (style->textIndentLine() == TextIndentEachLine || style->textIndentType() == TextIndentHanging) {
2420                 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2421                 list->append(textIndent.release());
2422                 if (style->textIndentLine() == TextIndentEachLine)
2423                     list->append(cssValuePool().createIdentifierValue(CSSValueWebkitEachLine));
2424                 if (style->textIndentType() == TextIndentHanging)
2425                     list->append(cssValuePool().createIdentifierValue(CSSValueWebkitHanging));
2426                 return list.release();
2427             }
2428 #endif
2429             return textIndent.release();
2430         }
2431         case CSSPropertyTextShadow:
2432             return valueForShadow(style->textShadow(), propertyID, style.get());
2433         case CSSPropertyTextRendering:
2434             return cssValuePool().createValue(style->fontDescription().textRenderingMode());
2435         case CSSPropertyTextOverflow:
2436             if (style->textOverflow())
2437                 return cssValuePool().createIdentifierValue(CSSValueEllipsis);
2438             return cssValuePool().createIdentifierValue(CSSValueClip);
2439         case CSSPropertyWebkitTextSecurity:
2440             return cssValuePool().createValue(style->textSecurity());
2441 #if ENABLE(IOS_TEXT_AUTOSIZING)
2442         case CSSPropertyWebkitTextSizeAdjust:
2443             if (style->textSizeAdjust().isAuto())
2444                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2445             if (style->textSizeAdjust().isNone())
2446                 return cssValuePool().createIdentifierValue(CSSValueNone);
2447             return CSSPrimitiveValue::create(style->textSizeAdjust().percentage(), CSSPrimitiveValue::CSS_PERCENTAGE);
2448 #endif
2449         case CSSPropertyWebkitTextStrokeColor:
2450             return currentColorOrValidColor(style.get(), style->textStrokeColor());
2451         case CSSPropertyWebkitTextStrokeWidth:
2452             return zoomAdjustedPixelValue(style->textStrokeWidth(), style.get());
2453         case CSSPropertyTextTransform:
2454             return cssValuePool().createValue(style->textTransform());
2455         case CSSPropertyTop:
2456             return getPositionOffsetValue(style.get(), CSSPropertyTop, m_node->document().renderView());
2457         case CSSPropertyUnicodeBidi:
2458             return cssValuePool().createValue(style->unicodeBidi());
2459         case CSSPropertyVerticalAlign:
2460             switch (style->verticalAlign()) {
2461                 case BASELINE:
2462                     return cssValuePool().createIdentifierValue(CSSValueBaseline);
2463                 case MIDDLE:
2464                     return cssValuePool().createIdentifierValue(CSSValueMiddle);
2465                 case SUB:
2466                     return cssValuePool().createIdentifierValue(CSSValueSub);
2467                 case SUPER:
2468                     return cssValuePool().createIdentifierValue(CSSValueSuper);
2469                 case TEXT_TOP:
2470                     return cssValuePool().createIdentifierValue(CSSValueTextTop);
2471                 case TEXT_BOTTOM:
2472                     return cssValuePool().createIdentifierValue(CSSValueTextBottom);
2473                 case TOP:
2474                     return cssValuePool().createIdentifierValue(CSSValueTop);
2475                 case BOTTOM:
2476                     return cssValuePool().createIdentifierValue(CSSValueBottom);
2477                 case BASELINE_MIDDLE:
2478                     return cssValuePool().createIdentifierValue(CSSValueWebkitBaselineMiddle);
2479                 case LENGTH:
2480                     return cssValuePool().createValue(style->verticalAlignLength());
2481             }
2482             ASSERT_NOT_REACHED();
2483             return 0;
2484         case CSSPropertyVisibility:
2485             return cssValuePool().createValue(style->visibility());
2486         case CSSPropertyWhiteSpace:
2487             return cssValuePool().createValue(style->whiteSpace());
2488         case CSSPropertyWidows:
2489             if (style->hasAutoWidows())
2490                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2491             return cssValuePool().createValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
2492         case CSSPropertyWidth:
2493             if (renderer) {
2494                 // According to http://www.w3.org/TR/CSS2/visudet.html#the-width-property,
2495                 // the "width" property does not apply for non-replaced inline elements.
2496                 if (!renderer->isReplaced() && renderer->isInline())
2497                     return cssValuePool().createIdentifierValue(CSSValueAuto);
2498                 return zoomAdjustedPixelValue(sizingBox(renderer).width(), style.get());
2499             }
2500             return zoomAdjustedPixelValueForLength(style->width(), style.get());
2501         case CSSPropertyWordBreak:
2502             return cssValuePool().createValue(style->wordBreak());
2503         case CSSPropertyWordSpacing:
2504             return zoomAdjustedPixelValue(style->wordSpacing(), style.get());
2505         case CSSPropertyWordWrap:
2506             return cssValuePool().createValue(style->overflowWrap());
2507         case CSSPropertyWebkitLineBreak:
2508             return cssValuePool().createValue(style->lineBreak());
2509         case CSSPropertyWebkitNbspMode:
2510             return cssValuePool().createValue(style->nbspMode());
2511         case CSSPropertyResize:
2512             return cssValuePool().createValue(style->resize());
2513         case CSSPropertyWebkitFontKerning:
2514             return cssValuePool().createValue(style->fontDescription().kerning());
2515         case CSSPropertyWebkitFontSmoothing:
2516             return cssValuePool().createValue(style->fontDescription().fontSmoothing());
2517         case CSSPropertyWebkitFontVariantLigatures: {
2518             FontDescription::LigaturesState commonLigaturesState = style->fontDescription().commonLigaturesState();
2519             FontDescription::LigaturesState discretionaryLigaturesState = style->fontDescription().discretionaryLigaturesState();
2520             FontDescription::LigaturesState historicalLigaturesState = style->fontDescription().historicalLigaturesState();
2521             if (commonLigaturesState == FontDescription::NormalLigaturesState && discretionaryLigaturesState == FontDescription::NormalLigaturesState
2522                 && historicalLigaturesState == FontDescription::NormalLigaturesState)
2523                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2524
2525             RefPtr<CSSValueList> valueList = CSSValueList::createSpaceSeparated();
2526             if (commonLigaturesState != FontDescription::NormalLigaturesState)
2527                 valueList->append(cssValuePool().createIdentifierValue(commonLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoCommonLigatures : CSSValueCommonLigatures));
2528             if (discretionaryLigaturesState != FontDescription::NormalLigaturesState)
2529                 valueList->append(cssValuePool().createIdentifierValue(discretionaryLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoDiscretionaryLigatures : CSSValueDiscretionaryLigatures));
2530             if (historicalLigaturesState != FontDescription::NormalLigaturesState)
2531                 valueList->append(cssValuePool().createIdentifierValue(historicalLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoHistoricalLigatures : CSSValueHistoricalLigatures));
2532             return valueList;
2533         }
2534         case CSSPropertyZIndex:
2535             if (style->hasAutoZIndex())
2536                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2537             return cssValuePool().createValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
2538         case CSSPropertyZoom:
2539             return cssValuePool().createValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
2540         case CSSPropertyBoxSizing:
2541             if (style->boxSizing() == CONTENT_BOX)
2542                 return cssValuePool().createIdentifierValue(CSSValueContentBox);
2543             return cssValuePool().createIdentifierValue(CSSValueBorderBox);
2544 #if ENABLE(DASHBOARD_SUPPORT)
2545         case CSSPropertyWebkitDashboardRegion:
2546         {
2547             const Vector<StyleDashboardRegion>& regions = style->dashboardRegions();
2548             unsigned count = regions.size();
2549             if (count == 1 && regions[0].type == StyleDashboardRegion::None)
2550                 return cssValuePool().createIdentifierValue(CSSValueNone);
2551
2552             RefPtr<DashboardRegion> firstRegion;
2553             DashboardRegion* previousRegion = 0;
2554             for (unsigned i = 0; i < count; i++) {
2555                 RefPtr<DashboardRegion> region = DashboardRegion::create();
2556                 StyleDashboardRegion styleRegion = regions[i];
2557
2558                 region->m_label = styleRegion.label;
2559                 LengthBox offset = styleRegion.offset;
2560                 region->setTop(zoomAdjustedPixelValue(offset.top().value(), style.get()));
2561                 region->setRight(zoomAdjustedPixelValue(offset.right().value(), style.get()));
2562                 region->setBottom(zoomAdjustedPixelValue(offset.bottom().value(), style.get()));
2563                 region->setLeft(zoomAdjustedPixelValue(offset.left().value(), style.get()));
2564                 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
2565                 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
2566
2567                 if (previousRegion)
2568                     previousRegion->m_next = region;
2569                 else
2570                     firstRegion = region;
2571                 previousRegion = region.get();
2572             }
2573             return cssValuePool().createValue(firstRegion.release());
2574         }
2575 #endif
2576 #if ENABLE(DRAGGABLE_REGION)
2577         case CSSPropertyWebkitAppRegion:
2578             return cssValuePool().createIdentifierValue(style->getDraggableRegionMode() == DraggableRegionDrag ? CSSValueDrag : CSSValueNoDrag);
2579 #endif
2580         case CSSPropertyWebkitAnimationDelay:
2581             return getDelayValue(style->animations());
2582         case CSSPropertyWebkitAnimationDirection: {
2583             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2584             const AnimationList* t = style->animations();
2585             if (t) {
2586                 for (size_t i = 0; i < t->size(); ++i) {
2587                     if (t->animation(i).direction())
2588                         list->append(cssValuePool().createIdentifierValue(CSSValueAlternate));
2589                     else
2590                         list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2591                 }
2592             } else
2593                 list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2594             return list.release();
2595         }
2596         case CSSPropertyWebkitAnimationDuration:
2597             return getDurationValue(style->animations());
2598         case CSSPropertyWebkitAnimationFillMode: {
2599             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2600             const AnimationList* t = style->animations();
2601             if (t) {
2602                 for (size_t i = 0; i < t->size(); ++i) {
2603                     switch (t->animation(i).fillMode()) {
2604                     case AnimationFillModeNone:
2605                         list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2606                         break;
2607                     case AnimationFillModeForwards:
2608                         list->append(cssValuePool().createIdentifierValue(CSSValueForwards));
2609                         break;
2610                     case AnimationFillModeBackwards:
2611                         list->append(cssValuePool().createIdentifierValue(CSSValueBackwards));
2612                         break;
2613                     case AnimationFillModeBoth:
2614                         list->append(cssValuePool().createIdentifierValue(CSSValueBoth));
2615                         break;
2616                     }
2617                 }
2618             } else
2619                 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2620             return list.release();
2621         }
2622         case CSSPropertyWebkitAnimationIterationCount: {
2623             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2624             const AnimationList* t = style->animations();
2625             if (t) {
2626                 for (size_t i = 0; i < t->size(); ++i) {
2627                     double iterationCount = t->animation(i).iterationCount();
2628                     if (iterationCount == Animation::IterationCountInfinite)
2629                         list->append(cssValuePool().createIdentifierValue(CSSValueInfinite));
2630                     else
2631                         list->append(cssValuePool().createValue(iterationCount, CSSPrimitiveValue::CSS_NUMBER));
2632                 }
2633             } else
2634                 list->append(cssValuePool().createValue(Animation::initialAnimationIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
2635             return list.release();
2636         }
2637         case CSSPropertyWebkitAnimationName: {
2638             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2639             const AnimationList* t = style->animations();
2640             if (t) {
2641                 for (size_t i = 0; i < t->size(); ++i)
2642                     list->append(cssValuePool().createValue(t->animation(i).name(), CSSPrimitiveValue::CSS_STRING));
2643             } else
2644                 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2645             return list.release();
2646         }
2647         case CSSPropertyWebkitAnimationPlayState: {
2648             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2649             const AnimationList* t = style->animations();
2650             if (t) {
2651                 for (size_t i = 0; i < t->size(); ++i) {
2652                     int prop = t->animation(i).playState();
2653                     if (prop == AnimPlayStatePlaying)
2654                         list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2655                     else
2656                         list->append(cssValuePool().createIdentifierValue(CSSValuePaused));
2657                 }
2658             } else
2659                 list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2660             return list.release();
2661         }
2662         case CSSPropertyWebkitAnimationTimingFunction:
2663             return getTimingFunctionValue(style->animations());
2664         case CSSPropertyWebkitAppearance:
2665             return cssValuePool().createValue(style->appearance());
2666         case CSSPropertyWebkitAspectRatio:
2667             if (!style->hasAspectRatio())
2668                 return cssValuePool().createIdentifierValue(CSSValueNone);
2669             return CSSAspectRatioValue::create(style->aspectRatioNumerator(), style->aspectRatioDenominator());
2670         case CSSPropertyWebkitBackfaceVisibility:
2671             return cssValuePool().createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
2672         case CSSPropertyWebkitBorderImage:
2673             return valueForNinePieceImage(style->borderImage());
2674         case CSSPropertyBorderImageOutset:
2675             return valueForNinePieceImageQuad(style->borderImage().outset());
2676         case CSSPropertyBorderImageRepeat:
2677             return valueForNinePieceImageRepeat(style->borderImage());
2678         case CSSPropertyBorderImageSlice:
2679             return valueForNinePieceImageSlice(style->borderImage());
2680         case CSSPropertyBorderImageWidth:
2681             return valueForNinePieceImageQuad(style->borderImage().borderSlices());
2682         case CSSPropertyWebkitMaskBoxImage:
2683             return valueForNinePieceImage(style->maskBoxImage());
2684         case CSSPropertyWebkitMaskBoxImageOutset:
2685             return valueForNinePieceImageQuad(style->maskBoxImage().outset());
2686         case CSSPropertyWebkitMaskBoxImageRepeat:
2687             return valueForNinePieceImageRepeat(style->maskBoxImage());
2688         case CSSPropertyWebkitMaskBoxImageSlice:
2689             return valueForNinePieceImageSlice(style->maskBoxImage());
2690         case CSSPropertyWebkitMaskBoxImageWidth:
2691             return valueForNinePieceImageQuad(style->maskBoxImage().borderSlices());
2692         case CSSPropertyWebkitMaskBoxImageSource:
2693             if (style->maskBoxImageSource())
2694                 return style->maskBoxImageSource()->cssValue();
2695             return cssValuePool().createIdentifierValue(CSSValueNone);
2696         case CSSPropertyWebkitFontSizeDelta:
2697             // Not a real style property -- used by the editing engine -- so has no computed value.
2698             break;
2699         case CSSPropertyWebkitMarginBottomCollapse:
2700         case CSSPropertyWebkitMarginAfterCollapse:
2701             return cssValuePool().createValue(style->marginAfterCollapse());
2702         case CSSPropertyWebkitMarginTopCollapse:
2703         case CSSPropertyWebkitMarginBeforeCollapse:
2704             return cssValuePool().createValue(style->marginBeforeCollapse());
2705 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
2706         case CSSPropertyWebkitOverflowScrolling:
2707             if (!style->useTouchOverflowScrolling())
2708                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2709             return cssValuePool().createIdentifierValue(CSSValueTouch);
2710 #endif
2711         case CSSPropertyWebkitPerspective:
2712             if (!style->hasPerspective())
2713                 return cssValuePool().createIdentifierValue(CSSValueNone);
2714             return zoomAdjustedPixelValue(style->perspective(), style.get());
2715         case CSSPropertyWebkitPerspectiveOrigin: {
2716             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2717             if (renderer) {
2718                 LayoutRect box;
2719                 if (renderer->isBox())
2720                     box = toRenderBox(renderer)->borderBoxRect();
2721
2722                 RenderView* renderView = m_node->document().renderView();
2723                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginX(), box.width(), renderView), style.get()));
2724                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginY(), box.height(), renderView), style.get()));
2725             }
2726             else {
2727                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginX(), style.get()));
2728                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginY(), style.get()));
2729
2730             }
2731             return list.release();
2732         }
2733         case CSSPropertyWebkitRtlOrdering:
2734             return cssValuePool().createIdentifierValue(style->rtlOrdering() ? CSSValueVisual : CSSValueLogical);
2735 #if ENABLE(TOUCH_EVENTS)
2736         case CSSPropertyWebkitTapHighlightColor:
2737             return currentColorOrValidColor(style.get(), style->tapHighlightColor());
2738 #endif
2739 #if PLATFORM(IOS)
2740         case CSSPropertyWebkitTouchCallout:
2741             return cssValuePool().createIdentifierValue(style->touchCalloutEnabled() ? CSSValueDefault : CSSValueNone);
2742 #endif
2743         case CSSPropertyWebkitUserDrag:
2744             return cssValuePool().createValue(style->userDrag());
2745         case CSSPropertyWebkitUserSelect:
2746             return cssValuePool().createValue(style->userSelect());
2747         case CSSPropertyBorderBottomLeftRadius:
2748             return getBorderRadiusCornerValue(style->borderBottomLeftRadius(), style.get(), m_node->document().renderView());
2749         case CSSPropertyBorderBottomRightRadius:
2750             return getBorderRadiusCornerValue(style->borderBottomRightRadius(), style.get(), m_node->document().renderView());
2751         case CSSPropertyBorderTopLeftRadius:
2752             return getBorderRadiusCornerValue(style->borderTopLeftRadius(), style.get(), m_node->document().renderView());
2753         case CSSPropertyBorderTopRightRadius:
2754             return getBorderRadiusCornerValue(style->borderTopRightRadius(), style.get(), m_node->document().renderView());
2755         case CSSPropertyClip: {
2756             if (!style->hasClip())
2757                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2758             RefPtr<Rect> rect = Rect::create();
2759             rect->setTop(zoomAdjustedPixelValue(style->clip().top().value(), style.get()));
2760             rect->setRight(zoomAdjustedPixelValue(style->clip().right().value(), style.get()));
2761             rect->setBottom(zoomAdjustedPixelValue(style->clip().bottom().value(), style.get()));
2762             rect->setLeft(zoomAdjustedPixelValue(style->clip().left().value(), style.get()));
2763             return cssValuePool().createValue(rect.release());
2764         }
2765         case CSSPropertySpeak:
2766             return cssValuePool().createValue(style->speak());
2767         case CSSPropertyWebkitTransform:
2768             return computedTransform(renderer, style.get());
2769         case CSSPropertyWebkitTransformOrigin: {
2770             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2771             if (renderer) {
2772                 LayoutRect box;
2773                 if (renderer->isBox())
2774                     box = toRenderBox(renderer)->borderBoxRect();
2775
2776                 RenderView* renderView = m_node->document().renderView();
2777                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginX(), box.width(), renderView), style.get()));
2778                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginY(), box.height(), renderView), style.get()));
2779                 if (style->transformOriginZ() != 0)
2780                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2781             } else {
2782                 list->append(zoomAdjustedPixelValueForLength(style->transformOriginX(), style.get()));
2783                 list->append(zoomAdjustedPixelValueForLength(style->transformOriginY(), style.get()));
2784                 if (style->transformOriginZ() != 0)
2785                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2786             }
2787             return list.release();
2788         }
2789         case CSSPropertyWebkitTransformStyle:
2790             return cssValuePool().createIdentifierValue((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat);
2791         case CSSPropertyTransitionDelay:
2792         case CSSPropertyWebkitTransitionDelay:
2793             return getDelayValue(style->transitions());
2794         case CSSPropertyTransitionDuration:
2795         case CSSPropertyWebkitTransitionDuration:
2796             return getDurationValue(style->transitions());
2797         case CSSPropertyTransitionProperty:
2798         case CSSPropertyWebkitTransitionProperty:
2799             return getTransitionPropertyValue(style->transitions());
2800         case CSSPropertyTransitionTimingFunction:
2801         case CSSPropertyWebkitTransitionTimingFunction:
2802             return getTimingFunctionValue(style->transitions());
2803         case CSSPropertyTransition:
2804         case CSSPropertyWebkitTransition: {
2805             const AnimationList* animList = style->transitions();
2806             if (animList) {
2807                 RefPtr<CSSValueList> transitionsList = CSSValueList::createCommaSeparated();
2808                 for (size_t i = 0; i < animList->size(); ++i) {
2809                     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2810                     const Animation& animation = animList->animation(i);
2811                     list->append(createTransitionPropertyValue(animation));
2812                     list->append(cssValuePool().createValue(animation.duration(), CSSPrimitiveValue::CSS_S));
2813                     list->append(createTimingFunctionValue(animation.timingFunction().get()));
2814                     list->append(cssValuePool().createValue(animation.delay(), CSSPrimitiveValue::CSS_S));
2815                     transitionsList->append(list);
2816                 }
2817                 return transitionsList.release();
2818             }
2819
2820             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2821             // transition-property default value.
2822             list->append(cssValuePool().createIdentifierValue(CSSValueAll));
2823             list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
2824             list->append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
2825             list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
2826             return list.release();
2827         }
2828         case CSSPropertyPointerEvents:
2829             return cssValuePool().createValue(style->pointerEvents());
2830         case CSSPropertyWebkitColorCorrection:
2831             return cssValuePool().createValue(style->colorSpace());
2832         case CSSPropertyWebkitLineGrid:
2833             if (style->lineGrid().isNull())
2834                 return cssValuePool().createIdentifierValue(CSSValueNone);
2835             return cssValuePool().createValue(style->lineGrid(), CSSPrimitiveValue::CSS_STRING);
2836         case CSSPropertyWebkitLineSnap:
2837             return CSSPrimitiveValue::create(style->lineSnap());
2838         case CSSPropertyWebkitLineAlign:
2839             return CSSPrimitiveValue::create(style->lineAlign());
2840         case CSSPropertyWebkitWritingMode:
2841             return cssValuePool().createValue(style->writingMode());
2842         case CSSPropertyWebkitTextCombine:
2843             return cssValuePool().createValue(style->textCombine());
2844         case CSSPropertyWebkitTextOrientation:
2845             return CSSPrimitiveValue::create(style->textOrientation());
2846         case CSSPropertyWebkitLineBoxContain:
2847             return createLineBoxContainValue(style->lineBoxContain());
2848         case CSSPropertyWebkitAlt:
2849             return altTextToCSSValue(style.get());
2850         case CSSPropertyContent:
2851             return contentToCSSValue(style.get());
2852         case CSSPropertyCounterIncrement:
2853             return counterToCSSValue(style.get(), propertyID);
2854         case CSSPropertyCounterReset:
2855             return counterToCSSValue(style.get(), propertyID);
2856         case CSSPropertyWebkitClipPath:
2857             if (ClipPathOperation* operation = style->clipPath()) {
2858                 if (operation->type() == ClipPathOperation::SHAPE)
2859                     return valueForBasicShape(style.get(), static_cast<ShapeClipPathOperation*>(operation)->basicShape());
2860 #if ENABLE(SVG)
2861                 if (operation->type() == ClipPathOperation::REFERENCE) {
2862                     ReferenceClipPathOperation* referenceOperation = static_cast<ReferenceClipPathOperation*>(operation);
2863                     return CSSPrimitiveValue::create(referenceOperation->url(), CSSPrimitiveValue::CSS_URI);
2864                 }
2865 #endif
2866             }
2867             return cssValuePool().createIdentifierValue(CSSValueNone);
2868 #if ENABLE(CSS_REGIONS)
2869         case CSSPropertyWebkitFlowInto:
2870             if (style->flowThread().isNull())
2871                 return cssValuePool().createIdentifierValue(CSSValueNone);
2872             return cssValuePool().createValue(style->flowThread(), CSSPrimitiveValue::CSS_STRING);
2873         case CSSPropertyWebkitFlowFrom:
2874             if (!style->hasFlowFrom())
2875                 return cssValuePool().createIdentifierValue(CSSValueNone);
2876             return cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING);
2877         case CSSPropertyWebkitRegionFragment:
2878             return cssValuePool().createValue(style->regionFragment());
2879 #endif
2880 #if ENABLE(CSS_EXCLUSIONS)
2881         case CSSPropertyWebkitWrapFlow:
2882             return cssValuePool().createValue(style->wrapFlow());
2883         case CSSPropertyWebkitWrapThrough:
2884             return cssValuePool().createValue(style->wrapThrough());
2885 #endif
2886 #if ENABLE(CSS_SHAPES)
2887         case CSSPropertyWebkitShapeMargin:
2888             return cssValuePool().createValue(style->shapeMargin());
2889         case CSSPropertyWebkitShapePadding:
2890             return cssValuePool().createValue(style->shapePadding());
2891         case CSSPropertyWebkitShapeImageThreshold:
2892             return cssValuePool().createValue(style->shapeImageThreshold(), CSSPrimitiveValue::CSS_NUMBER);
2893         case CSSPropertyWebkitShapeInside:
2894             if (!style->shapeInside())
2895                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2896             if (style->shapeInside()->type() == ShapeValue::Box)
2897                 return valueForBox(style->shapeInside()->box());
2898             if (style->shapeInside()->type() == ShapeValue::Outside)
2899                 return cssValuePool().createIdentifierValue(CSSValueOutsideShape);
2900             if (style->shapeInside()->type() == ShapeValue::Image) {
2901                 if (style->shapeInside()->image())
2902                     return style->shapeInside()->image()->cssValue();
2903                 return cssValuePool().createIdentifierValue(CSSValueNone);
2904             }
2905             ASSERT(style->shapeInside()->type() == ShapeValue::Shape);
2906             return valueForBasicShape(style.get(), style->shapeInside()->shape());
2907         case CSSPropertyWebkitShapeOutside:
2908             if (!style->shapeOutside())
2909                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2910             if (style->shapeOutside()->type() == ShapeValue::Box)
2911                 return valueForBox(style->shapeOutside()->box());
2912             if (style->shapeOutside()->type() == ShapeValue::Image) {
2913                 if (style->shapeOutside()->image())
2914                     return style->shapeOutside()->image()->cssValue();
2915                 return cssValuePool().createIdentifierValue(CSSValueNone);
2916             }
2917             ASSERT(style->shapeOutside()->type() == ShapeValue::Shape);
2918             return valueForBasicShape(style.get(), style->shapeOutside()->shape());
2919 #endif
2920 #if ENABLE(CSS_FILTERS)
2921         case CSSPropertyWebkitFilter:
2922             return valueForFilter(renderer, style.get(), style->filter());
2923 #endif
2924 #if ENABLE(CSS_COMPOSITING)
2925         case CSSPropertyWebkitBlendMode:
2926             return cssValuePool().createValue(style->blendMode());
2927 #endif
2928         case CSSPropertyWebkitBackgroundBlendMode: {
2929             const FillLayer* layers = style->backgroundLayers();
2930             if (!layers->next())
2931                 return cssValuePool().createValue(layers->blendMode());
2932
2933             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2934             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
2935                 list->append(cssValuePool().createValue(currLayer->blendMode()));
2936
2937             return list.release();
2938         }
2939         case CSSPropertyBackground:
2940             return getBackgroundShorthandValue();
2941         case CSSPropertyBorder: {
2942             RefPtr<CSSValue> value = propertyValue(CSSPropertyBorderTop, DoNotUpdateLayout);
2943             const CSSPropertyID properties[3] = { CSSPropertyBorderRight, CSSPropertyBorderBottom,
2944                                         CSSPropertyBorderLeft };
2945             for (size_t i = 0; i < WTF_ARRAY_LENGTH(properties); ++i) {
2946                 if (!compareCSSValuePtr<CSSValue>(value, propertyValue(properties[i], DoNotUpdateLayout)))
2947                     return 0;
2948             }
2949             return value.release();
2950         }
2951         case CSSPropertyBorderBottom:
2952             return getCSSPropertyValuesForShorthandProperties(borderBottomShorthand());
2953         case CSSPropertyBorderColor:
2954             return getCSSPropertyValuesForSidesShorthand(borderColorShorthand());
2955         case CSSPropertyBorderLeft:
2956             return getCSSPropertyValuesForShorthandProperties(borderLeftShorthand());
2957         case CSSPropertyBorderImage:
2958             return valueForNinePieceImage(style->borderImage());
2959         case CSSPropertyBorderRadius:
2960             return getBorderRadiusShorthandValue(style.get(), m_node->document().renderView());
2961         case CSSPropertyBorderRight:
2962             return getCSSPropertyValuesForShorthandProperties(borderRightShorthand());
2963         case CSSPropertyBorderStyle:
2964             return getCSSPropertyValuesForSidesShorthand(borderStyleShorthand());
2965         case CSSPropertyBorderTop:
2966             return getCSSPropertyValuesForShorthandProperties(borderTopShorthand());
2967         case CSSPropertyBorderWidth:
2968             return getCSSPropertyValuesForSidesShorthand(borderWidthShorthand());
2969         case CSSPropertyWebkitColumnRule:
2970             return getCSSPropertyValuesForShorthandProperties(webkitColumnRuleShorthand());
2971         case CSSPropertyWebkitColumns:
2972             return getCSSPropertyValuesForShorthandProperties(webkitColumnsShorthand());
2973         case CSSPropertyListStyle:
2974             return getCSSPropertyValuesForShorthandProperties(listStyleShorthand());
2975         case CSSPropertyMargin:
2976             return getCSSPropertyValuesForSidesShorthand(marginShorthand());
2977         case CSSPropertyOutline:
2978             return getCSSPropertyValuesForShorthandProperties(outlineShorthand());
2979         case CSSPropertyPadding:
2980             return getCSSPropertyValuesForSidesShorthand(paddingShorthand());
2981         /* Individual properties not part of the spec */
2982         case CSSPropertyBackgroundRepeatX:
2983         case CSSPropertyBackgroundRepeatY:
2984             break;
2985
2986         /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
2987         case CSSPropertyWebkitTextEmphasis:
2988         case CSSPropertyTextLineThrough:
2989         case CSSPropertyTextLineThroughColor:
2990         case CSSPropertyTextLineThroughMode:
2991         case CSSPropertyTextLineThroughStyle:
2992         case CSSPropertyTextLineThroughWidth:
2993         case CSSPropertyTextOverline:
2994         case CSSPropertyTextOverlineColor:
2995         case CSSPropertyTextOverlineMode:
2996         case CSSPropertyTextOverlineStyle:
2997         case CSSPropertyTextOverlineWidth:
2998         case CSSPropertyTextUnderline:
2999         case CSSPropertyTextUnderlineColor:
3000         case CSSPropertyTextUnderlineMode:
3001         case CSSPropertyTextUnderlineStyle:
3002         case CSSPropertyTextUnderlineWidth:
3003             break;
3004
3005         /* Directional properties are resolved by resolveDirectionAwareProperty() before the switch. */
3006         case CSSPropertyWebkitBorderEnd:
3007         case CSSPropertyWebkitBorderEndColor:
3008         case CSSPropertyWebkitBorderEndStyle:
3009         case CSSPropertyWebkitBorderEndWidth:
3010         case CSSPropertyWebkitBorderStart:
3011         case CSSPropertyWebkitBorderStartColor:
3012         case CSSPropertyWebkitBorderStartStyle:
3013         case CSSPropertyWebkitBorderStartWidth:
3014         case CSSPropertyWebkitBorderAfter:
3015         case CSSPropertyWebkitBorderAfterColor:
3016         case CSSPropertyWebkitBorderAfterStyle:
3017         case CSSPropertyWebkitBorderAfterWidth:
3018         case CSSPropertyWebkitBorderBefore:
3019         case CSSPropertyWebkitBorderBeforeColor:
3020         case CSSPropertyWebkitBorderBeforeStyle:
3021         case CSSPropertyWebkitBorderBeforeWidth:
3022         case CSSPropertyWebkitMarginEnd:
3023         case CSSPropertyWebkitMarginStart:
3024         case CSSPropertyWebkitMarginAfter:
3025         case CSSPropertyWebkitMarginBefore:
3026         case CSSPropertyWebkitPaddingEnd:
3027         case CSSPropertyWebkitPaddingStart:
3028         case CSSPropertyWebkitPaddingAfter:
3029         case CSSPropertyWebkitPaddingBefore:
3030         case CSSPropertyWebkitLogicalWidth:
3031         case CSSPropertyWebkitLogicalHeight:
3032         case CSSPropertyWebkitMinLogicalWidth:
3033         case CSSPropertyWebkitMinLogicalHeight:
3034         case CSSPropertyWebkitMaxLogicalWidth:
3035         case CSSPropertyWebkitMaxLogicalHeight:
3036             ASSERT_NOT_REACHED();
3037             break;
3038
3039         /* Unimplemented @font-face properties */
3040         case CSSPropertyFontStretch:
3041         case CSSPropertySrc:
3042         case CSSPropertyUnicodeRange:
3043             break;
3044
3045         /* Other unimplemented properties */
3046 #if ENABLE(CSS_SHADERS)
3047         case CSSPropertyGeometry:
3048 #endif
3049         case CSSPropertyPage: // for @page
3050         case CSSPropertyQuotes: // FIXME: needs implementation
3051         case CSSPropertySize: // for @page
3052             break;
3053
3054         /* Unimplemented -webkit- properties */
3055         case CSSPropertyWebkitAnimation:
3056         case CSSPropertyWebkitBorderRadius:
3057         case CSSPropertyWebkitMarginCollapse:
3058         case CSSPropertyWebkitMarquee:
3059         case CSSPropertyWebkitMarqueeSpeed:
3060         case CSSPropertyWebkitMask:
3061         case CSSPropertyWebkitMaskRepeatX:
3062         case CSSPropertyWebkitMaskRepeatY:
3063         case CSSPropertyWebkitPerspectiveOriginX:
3064         case CSSPropertyWebkitPerspectiveOriginY:
3065         case CSSPropertyWebkitTextStroke:
3066         case CSSPropertyWebkitTransformOriginX:
3067         case CSSPropertyWebkitTransformOriginY:
3068         case CSSPropertyWebkitTransformOriginZ:
3069 #if ENABLE(CSS_SHADERS)
3070         case CSSPropertyMix:
3071         case CSSPropertyParameters:
3072 #endif
3073             break;
3074
3075 #if ENABLE(CSS_DEVICE_ADAPTATION)
3076         case CSSPropertyMaxZoom:
3077         case CSSPropertyMinZoom:
3078         case CSSPropertyOrientation:
3079         case CSSPropertyUserZoom:
3080             break;
3081 #endif
3082
3083 #if ENABLE(SVG)
3084         case CSSPropertyBufferedRendering:
3085         case CSSPropertyClipPath:
3086         case CSSPropertyClipRule:
3087         case CSSPropertyMask:
3088         case CSSPropertyEnableBackground:
3089         case CSSPropertyFilter:
3090         case CSSPropertyFloodColor:
3091         case CSSPropertyFloodOpacity:
3092         case CSSPropertyLightingColor:
3093         case CSSPropertyStopColor:
3094         case CSSPropertyStopOpacity:
3095         case CSSPropertyColorInterpolation:
3096         case CSSPropertyColorInterpolationFilters:
3097         case CSSPropertyColorProfile:
3098         case CSSPropertyColorRendering:
3099         case CSSPropertyFill:
3100         case CSSPropertyFillOpacity:
3101         case CSSPropertyFillRule:
3102         case CSSPropertyMarker:
3103         case CSSPropertyMarkerEnd:
3104         case CSSPropertyMarkerMid:
3105         case CSSPropertyMarkerStart:
3106         case CSSPropertyMaskType:
3107         case CSSPropertyShapeRendering:
3108         case CSSPropertyStroke:
3109         case CSSPropertyStrokeDasharray:
3110         case CSSPropertyStrokeDashoffset:
3111         case CSSPropertyStrokeLinecap:
3112         case CSSPropertyStrokeLinejoin:
3113         case CSSPropertyStrokeMiterlimit:
3114         case CSSPropertyStrokeOpacity:
3115         case CSSPropertyStrokeWidth:
3116         case CSSPropertyAlignmentBaseline:
3117         case CSSPropertyBaselineShift:
3118         case CSSPropertyDominantBaseline:
3119         case CSSPropertyGlyphOrientationHorizontal:
3120         case CSSPropertyGlyphOrientationVertical:
3121         case CSSPropertyKerning:
3122         case CSSPropertyTextAnchor:
3123         case CSSPropertyVectorEffect:
3124         case CSSPropertyWritingMode:
3125         case CSSPropertyWebkitSvgShadow:
3126             return svgPropertyValue(propertyID, DoNotUpdateLayout);
3127 #endif
3128     }
3129
3130     logUnimplementedPropertyID(propertyID);
3131     return 0;
3132 }
3133
3134 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) const
3135 {
3136     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
3137     if (value)
3138         return value->cssText();
3139     return "";
3140 }
3141
3142 unsigned CSSComputedStyleDeclaration::length() const
3143 {
3144     Node* node = m_node.get();
3145     if (!node)
3146         return 0;
3147
3148     RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier);
3149     if (!style)
3150         return 0;
3151
3152     return numComputedProperties;
3153 }
3154
3155 String CSSComputedStyleDeclaration::item(unsigned i) const
3156 {
3157     if (i >= length())
3158         return "";
3159
3160     return getPropertyNameString(computedProperties[i]);
3161 }
3162
3163 bool ComputedStyleExtractor::propertyMatches(CSSPropertyID propertyID, const CSSValue* value) const
3164 {
3165     if (propertyID == CSSPropertyFontSize && value->isPrimitiveValue() && m_node) {
3166         m_node->document().updateLayoutIgnorePendingStylesheets();
3167         RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier);
3168         if (style && style->fontDescription().keywordSize()) {
3169             CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize());
3170             const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
3171             if (primitiveValue->isValueID() && primitiveValue->getValueID() == sizeValue)
3172                 return true;
3173         }
3174     }
3175     RefPtr<CSSValue> computedValue = propertyValue(propertyID);
3176     return computedValue && value && computedValue->equals(*value);
3177 }
3178
3179 PassRef<MutableStyleProperties> ComputedStyleExtractor::copyProperties() const
3180 {
3181     return copyPropertiesInSet(computedProperties, numComputedProperties);
3182 }
3183
3184 PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand& shorthand) const
3185 {
3186     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
3187     for (size_t i = 0; i < shorthand.length(); ++i) {
3188         RefPtr<CSSValue> value = propertyValue(shorthand.properties()[i], DoNotUpdateLayout);
3189         list->append(value);
3190     }
3191     return list.release();
3192 }
3193
3194 PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand& shorthand) const
3195 {
3196     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
3197     // Assume the properties are in the usual order top, right, bottom, left.
3198     RefPtr<CSSValue> topValue = propertyValue(shorthand.properties()[0], DoNotUpdateLayout);
3199     RefPtr<CSSValue> rightValue = propertyValue(shorthand.properties()[1], DoNotUpdateLayout);
3200     RefPtr<CSSValue> bottomValue = propertyValue(shorthand.properties()[2], DoNotUpdateLayout);
3201     RefPtr<CSSValue> leftValue = propertyValue(shorthand.properties()[3], DoNotUpdateLayout);
3202
3203     // All 4 properties must be specified.
3204     if (!topValue || !rightValue || !bottomValue || !leftValue)
3205         return 0;
3206
3207     bool showLeft = !compareCSSValuePtr(rightValue, leftValue);
3208     bool showBottom = !compareCSSValuePtr(topValue, bottomValue) || showLeft;
3209     bool showRight = !compareCSSValuePtr(topValue, rightValue) || showBottom;
3210
3211     list->append(topValue.release());
3212     if (showRight)
3213         list->append(rightValue.release());
3214     if (showBottom)
3215         list->append(bottomValue.release());
3216     if (showLeft)
3217         list->append(leftValue.release());
3218
3219     return list.release();
3220 }
3221
3222 PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForGridShorthand(const StylePropertyShorthand& shorthand) const
3223 {
3224     RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3225     for (size_t i = 0; i < shorthand.length(); ++i) {
3226         RefPtr<CSSValue> value = propertyValue(shorthand.properties()[i], DoNotUpdateLayout);
3227         list->append(value.release());
3228     }
3229     return list.release();
3230 }
3231
3232 PassRef<MutableStyleProperties> ComputedStyleExtractor::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const
3233 {
3234     Vector<CSSProperty, 256> list;
3235     list.reserveInitialCapacity(length);
3236     for (unsigned i = 0; i < length; ++i) {
3237         RefPtr<CSSValue> value = propertyValue(set[i]);
3238         if (value)
3239             list.append(CSSProperty(set[i], value.release(), false));
3240     }
3241     return MutableStyleProperties::create(list.data(), list.size());
3242 }
3243
3244 CSSRule* CSSComputedStyleDeclaration::parentRule() const
3245 {
3246     return 0;
3247 }
3248
3249 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(const String& propertyName)
3250 {
3251     CSSPropertyID propertyID = cssPropertyID(propertyName);
3252     if (!propertyID)
3253         return 0;
3254     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
3255     return value ? value->cloneForCSSOM() : 0;
3256 }
3257
3258 String CSSComputedStyleDeclaration::getPropertyValue(const String &propertyName)
3259 {
3260     CSSPropertyID propertyID = cssPropertyID(propertyName);
3261     if (!propertyID)
3262         return String();
3263     return getPropertyValue(propertyID);
3264 }
3265
3266 String CSSComputedStyleDeclaration::getPropertyPriority(const String&)
3267 {
3268     // All computed styles have a priority of not "important".
3269     return "";
3270 }
3271
3272 String CSSComputedStyleDeclaration::getPropertyShorthand(const String&)
3273 {
3274     return "";
3275 }
3276
3277 bool CSSComputedStyleDeclaration::isPropertyImplicit(const String&)
3278 {
3279     return false;
3280 }
3281
3282 void CSSComputedStyleDeclaration::setProperty(const String&, const String&, const String&, ExceptionCode& ec)
3283 {
3284     ec = NO_MODIFICATION_ALLOWED_ERR;
3285 }
3286
3287 String CSSComputedStyleDeclaration::removeProperty(const String&, ExceptionCode& ec)
3288 {
3289     ec = NO_MODIFICATION_ALLOWED_ERR;
3290     return String();
3291 }
3292     
3293 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
3294 {
3295     return getPropertyCSSValue(propertyID);
3296 }
3297
3298 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
3299 {
3300     return getPropertyValue(propertyID);
3301 }
3302
3303 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const String&, bool, ExceptionCode& ec)
3304 {
3305     ec = NO_MODIFICATION_ALLOWED_ERR;
3306 }
3307
3308 PassRefPtr<CSSValueList> ComputedStyleExtractor::getBackgroundShorthandValue() const
3309 {
3310     static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage,
3311                                                                      CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment,  
3312                                                                      CSSPropertyBackgroundPosition };
3313     static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyBackgroundSize, CSSPropertyBackgroundOrigin, 
3314                                                                     CSSPropertyBackgroundClip };
3315
3316     RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3317     list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(CSSPropertyBackground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperator))));
3318     list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(CSSPropertyBackground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator))));
3319     return list.release();
3320 }
3321
3322 } // namespace WebCore