8667687425ea92104b9dcdec9cdf1850174e4078
[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 PassRefPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(double value, const RenderStyle* style)
604 {
605     return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style), CSSPrimitiveValue::CSS_PX);
606 }
607
608 inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedNumberValue(double value, const RenderStyle* style)
609 {
610     return cssValuePool().createValue(value / style->effectiveZoom(), CSSPrimitiveValue::CSS_NUMBER);
611 }
612
613 static PassRefPtr<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 PassRefPtr<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 PassRefPtr<CSSValueList> createPositionListForLayer(CSSPropertyID propertyID, const FillLayer* layer, const RenderStyle* style)
651 {
652     RefPtr<CSSValueList> positionList = CSSValueList::createSpaceSeparated();
653     if (layer->isBackgroundOriginSet()) {
654         ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
655         positionList->append(cssValuePool().createValue(layer->backgroundXOrigin()));
656     }
657     positionList->append(zoomAdjustedPixelValueForLength(layer->xPosition(), style));
658     if (layer->isBackgroundOriginSet()) {
659         ASSERT(propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
660         positionList->append(cssValuePool().createValue(layer->backgroundYOrigin()));
661     }
662     positionList->append(zoomAdjustedPixelValueForLength(layer->yPosition(), style));
663     return positionList.release();
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 PassRefPtr<CSSValueList> getBorderRadiusCornerValues(const LengthSize& radius, const RenderStyle* style, RenderView* renderView)
716 {
717     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
718     if (radius.width().type() == Percent)
719         list->append(cssValuePool().createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
720     else
721         list->append(zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style));
722     if (radius.height().type() == Percent)
723         list->append(cssValuePool().createValue(radius.height().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
724     else
725         list->append(zoomAdjustedPixelValue(valueForLength(radius.height(), 0, renderView), style));
726     return list.release();
727 }
728
729 static PassRefPtr<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 PassRefPtr<CSSValueList> getBorderRadiusShorthandValue(const RenderStyle* style, RenderView* renderView)
740 {
741     RefPtr<CSSValueList> 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     bool showVerticalTopLeft = (style->borderTopLeftRadius().width() != style->borderTopLeftRadius().height());
750
751     RefPtr<CSSValueList> topLeftRadius = getBorderRadiusCornerValues(style->borderTopLeftRadius(), style, renderView);
752     RefPtr<CSSValueList> topRightRadius = getBorderRadiusCornerValues(style->borderTopRightRadius(), style, renderView);
753     RefPtr<CSSValueList> bottomRightRadius = getBorderRadiusCornerValues(style->borderBottomRightRadius(), style, renderView);
754     RefPtr<CSSValueList> bottomLeftRadius = getBorderRadiusCornerValues(style->borderBottomLeftRadius(), style, renderView);
755
756     RefPtr<CSSValueList> horizontalRadii = CSSValueList::createSpaceSeparated();
757     horizontalRadii->append(topLeftRadius->item(0));
758     if (showHorizontalTopRight)
759         horizontalRadii->append(topRightRadius->item(0));
760     if (showHorizontalBottomRight)
761         horizontalRadii->append(bottomRightRadius->item(0));
762     if (showHorizontalBottomLeft)
763         horizontalRadii->append(bottomLeftRadius->item(0));
764
765     list->append(horizontalRadii.release());
766
767     if (showVerticalTopLeft) {
768         RefPtr<CSSValueList> verticalRadii = CSSValueList::createSpaceSeparated();
769         verticalRadii->append(topLeftRadius->item(1));
770         if (showVerticalTopRight)
771             verticalRadii->append(topRightRadius->item(1));
772         if (showVerticalBottomRight)
773             verticalRadii->append(bottomRightRadius->item(1));
774         if (showVerticalBottomLeft)
775             verticalRadii->append(bottomLeftRadius->item(1));
776         list->append(verticalRadii.release());
777     }
778     return list.release();
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 PassRefPtr<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.release();
827 }
828
829 static PassRefPtr<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     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
844     list->append(matrixTransformValue(transform, style));
845
846     return list.release();
847 }
848
849 #if ENABLE(CSS_SHADERS)
850 static PassRefPtr<CSSValue> valueForCustomFilterArrayParameter(const CustomFilterArrayParameter* arrayParameter)
851 {
852     RefPtr<WebKitCSSArrayFunctionValue> arrayParameterValue = WebKitCSSArrayFunctionValue::create();
853     for (unsigned i = 0, size = arrayParameter->size(); i < size; ++i)
854         arrayParameterValue->append(cssValuePool().createValue(arrayParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
855     return arrayParameterValue.release();
856 }
857
858 static PassRefPtr<CSSValue> valueForCustomFilterMatParameter(const CustomFilterArrayParameter* matrixParameter)
859 {
860     RefPtr<WebKitCSSMatFunctionValue> matrixParameterValue = WebKitCSSMatFunctionValue::create();
861     for (unsigned i = 0, size = matrixParameter->size(); i < size; ++i)
862         matrixParameterValue->append(cssValuePool().createValue(matrixParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
863     return matrixParameterValue.release();
864 }
865
866 static PassRefPtr<CSSValue> valueForCustomFilterColorParameter(const CustomFilterColorParameter* colorParameter)
867 {
868     RefPtr<CSSValueList> colorParameterValue = CSSValueList::createSpaceSeparated();
869     colorParameterValue->append(cssValuePool().createColorValue(colorParameter->color().rgb()));
870     return colorParameterValue.release();
871 }
872
873 static PassRefPtr<CSSValue> valueForCustomFilterNumberParameter(const CustomFilterNumberParameter* numberParameter)
874 {
875     RefPtr<CSSValueList> numberParameterValue = CSSValueList::createSpaceSeparated();
876     for (unsigned i = 0; i < numberParameter->size(); ++i)
877         numberParameterValue->append(cssValuePool().createValue(numberParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
878     return numberParameterValue.release();
879 }
880
881 static PassRefPtr<CSSValue> valueForCustomFilterTransformParameter(const RenderObject* renderer, const RenderStyle* style, const CustomFilterTransformParameter* transformParameter)
882 {
883     IntSize size;
884     if (renderer && renderer->isBox())
885         size = pixelSnappedIntRect(toRenderBox(renderer)->borderBoxRect()).size();
886
887     TransformationMatrix transform;
888     transformParameter->applyTransform(transform, size);
889     // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
890     return matrixTransformValue(transform, style);
891 }
892
893 static PassRefPtr<CSSValue> valueForCustomFilterParameter(const RenderObject* renderer, const RenderStyle* style, const CustomFilterParameter* parameter)
894 {
895     // FIXME: Add here computed style for the other types: boolean, transform, matrix, texture.
896     ASSERT(parameter);
897     switch (parameter->parameterType()) {
898     case CustomFilterParameter::ARRAY:
899         return valueForCustomFilterArrayParameter(static_cast<const CustomFilterArrayParameter*>(parameter));
900     case CustomFilterParameter::COLOR:
901         return valueForCustomFilterColorParameter(static_cast<const CustomFilterColorParameter*>(parameter));
902     case CustomFilterParameter::MATRIX:
903         return valueForCustomFilterMatParameter(static_cast<const CustomFilterArrayParameter*>(parameter));
904     case CustomFilterParameter::NUMBER:
905         return valueForCustomFilterNumberParameter(static_cast<const CustomFilterNumberParameter*>(parameter));
906     case CustomFilterParameter::TRANSFORM:
907         return valueForCustomFilterTransformParameter(renderer, style, static_cast<const CustomFilterTransformParameter*>(parameter));
908     }
909     
910     ASSERT_NOT_REACHED();
911     return 0;
912 }
913 #endif // ENABLE(CSS_SHADERS)
914
915 static inline PassRefPtr<CSSPrimitiveValue> adjustLengthForZoom(double length, const RenderStyle* style, AdjustPixelValuesForComputedStyle adjust)
916 {
917     return adjust == AdjustPixelValues ? zoomAdjustedPixelValue(length, style) : cssValuePool().createValue(length, CSSPrimitiveValue::CSS_PX);
918 }
919
920 static inline PassRefPtr<CSSPrimitiveValue> adjustLengthForZoom(const Length& length, const RenderStyle* style, AdjustPixelValuesForComputedStyle adjust)
921 {
922     return adjust == AdjustPixelValues ? zoomAdjustedPixelValue(length.value(), style) : cssValuePool().createValue(length);
923 }
924
925 PassRefPtr<CSSValue> ComputedStyleExtractor::valueForShadow(const ShadowData* shadow, CSSPropertyID propertyID, const RenderStyle* style, AdjustPixelValuesForComputedStyle adjust)
926 {
927     if (!shadow)
928         return cssValuePool().createIdentifierValue(CSSValueNone);
929
930     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
931     for (const ShadowData* currShadowData = shadow; currShadowData; currShadowData = currShadowData->next()) {
932         RefPtr<CSSPrimitiveValue> x = adjustLengthForZoom(currShadowData->x(), style, adjust);
933         RefPtr<CSSPrimitiveValue> y = adjustLengthForZoom(currShadowData->y(), style, adjust);
934         RefPtr<CSSPrimitiveValue> blur = adjustLengthForZoom(currShadowData->radius(), style, adjust);
935         RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? PassRefPtr<CSSPrimitiveValue>() : adjustLengthForZoom(currShadowData->spread(), style, adjust);
936         RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || currShadowData->style() == Normal ? PassRefPtr<CSSPrimitiveValue>() : cssValuePool().createIdentifierValue(CSSValueInset);
937         RefPtr<CSSPrimitiveValue> color = cssValuePool().createColorValue(currShadowData->color().rgb());
938         list->prepend(CSSShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release()));
939     }
940     return list.release();
941 }
942
943 #if ENABLE(CSS_FILTERS)
944 PassRefPtr<CSSValue> ComputedStyleExtractor::valueForFilter(const RenderObject* renderer, const RenderStyle* style, const FilterOperations& filterOperations, AdjustPixelValuesForComputedStyle adjust)
945 {
946 #if !ENABLE(CSS_SHADERS)
947     UNUSED_PARAM(renderer);
948 #endif
949     if (filterOperations.operations().isEmpty())
950         return cssValuePool().createIdentifierValue(CSSValueNone);
951
952     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
953
954     RefPtr<WebKitCSSFilterValue> filterValue;
955
956     Vector<RefPtr<FilterOperation>>::const_iterator end = filterOperations.operations().end();
957     for (Vector<RefPtr<FilterOperation>>::const_iterator it = filterOperations.operations().begin(); it != end; ++it) {
958         FilterOperation* filterOperation = (*it).get();
959         switch (filterOperation->type()) {
960         case FilterOperation::REFERENCE: {
961             ReferenceFilterOperation* referenceOperation = static_cast<ReferenceFilterOperation*>(filterOperation);
962             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ReferenceFilterOperation);
963             filterValue->append(cssValuePool().createValue(referenceOperation->url(), CSSPrimitiveValue::CSS_STRING));
964             break;
965         }
966         case FilterOperation::GRAYSCALE: {
967             BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
968             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::GrayscaleFilterOperation);
969             filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
970             break;
971         }
972         case FilterOperation::SEPIA: {
973             BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
974             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SepiaFilterOperation);
975             filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
976             break;
977         }
978         case FilterOperation::SATURATE: {
979             BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
980             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SaturateFilterOperation);
981             filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
982             break;
983         }
984         case FilterOperation::HUE_ROTATE: {
985             BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
986             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::HueRotateFilterOperation);
987             filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_DEG));
988             break;
989         }
990         case FilterOperation::INVERT: {
991             BasicComponentTransferFilterOperation* componentTransferOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
992             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::InvertFilterOperation);
993             filterValue->append(cssValuePool().createValue(componentTransferOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
994             break;
995         }
996         case FilterOperation::OPACITY: {
997             BasicComponentTransferFilterOperation* componentTransferOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
998             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::OpacityFilterOperation);
999             filterValue->append(cssValuePool().createValue(componentTransferOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
1000             break;
1001         }
1002         case FilterOperation::BRIGHTNESS: {
1003             BasicComponentTransferFilterOperation* brightnessOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
1004             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BrightnessFilterOperation);
1005             filterValue->append(cssValuePool().createValue(brightnessOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
1006             break;
1007         }
1008         case FilterOperation::CONTRAST: {
1009             BasicComponentTransferFilterOperation* contrastOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
1010             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ContrastFilterOperation);
1011             filterValue->append(cssValuePool().createValue(contrastOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
1012             break;
1013         }
1014         case FilterOperation::BLUR: {
1015             BlurFilterOperation* blurOperation = static_cast<BlurFilterOperation*>(filterOperation);
1016             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BlurFilterOperation);
1017             filterValue->append(adjustLengthForZoom(blurOperation->stdDeviation(), style, adjust));
1018             break;
1019         }
1020         case FilterOperation::DROP_SHADOW: {
1021             DropShadowFilterOperation* dropShadowOperation = static_cast<DropShadowFilterOperation*>(filterOperation);
1022             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::DropShadowFilterOperation);
1023             // We want our computed style to look like that of a text shadow (has neither spread nor inset style).
1024             ShadowData shadowData = ShadowData(dropShadowOperation->location(), dropShadowOperation->stdDeviation(), 0, Normal, false, dropShadowOperation->color());
1025             filterValue->append(valueForShadow(&shadowData, CSSPropertyTextShadow, style, adjust));
1026             break;
1027         }
1028 #if ENABLE(CSS_SHADERS)
1029         case FilterOperation::VALIDATED_CUSTOM:
1030             // ValidatedCustomFilterOperation is not supposed to end up in the RenderStyle.
1031             ASSERT_NOT_REACHED();
1032             break;
1033         case FilterOperation::CUSTOM: {
1034             CustomFilterOperation* customOperation = static_cast<CustomFilterOperation*>(filterOperation);
1035             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::CustomFilterOperation);
1036             
1037             // The output should be verbose, even if the values are the default ones.
1038             
1039             ASSERT(customOperation->program());
1040             StyleCustomFilterProgram* program = static_cast<StyleCustomFilterProgram*>(customOperation->program());
1041             
1042             RefPtr<CSSValueList> shadersList = CSSValueList::createSpaceSeparated();
1043             if (program->vertexShader())
1044                 shadersList->append(program->vertexShader()->cssValue());
1045             else
1046                 shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone));
1047
1048             const CustomFilterProgramMixSettings mixSettings = program->mixSettings();
1049             if (program->fragmentShader()) {
1050                 if (program->programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE) {
1051                     RefPtr<WebKitCSSMixFunctionValue> mixFunction = WebKitCSSMixFunctionValue::create();
1052                     mixFunction->append(program->fragmentShader()->cssValue());
1053                     mixFunction->append(cssValuePool().createValue(mixSettings.blendMode));
1054                     mixFunction->append(cssValuePool().createValue(mixSettings.compositeOperator));
1055                     shadersList->append(mixFunction.release());
1056                 } else
1057                     shadersList->append(program->fragmentShader()->cssValue());
1058             }
1059             else
1060                 shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone));
1061
1062             filterValue->append(shadersList.release());
1063             
1064             RefPtr<CSSValueList> meshParameters = CSSValueList::createSpaceSeparated();
1065             meshParameters->append(cssValuePool().createValue(customOperation->meshColumns(), CSSPrimitiveValue::CSS_NUMBER));
1066             meshParameters->append(cssValuePool().createValue(customOperation->meshRows(), CSSPrimitiveValue::CSS_NUMBER));
1067             
1068             // FIXME: The specification doesn't have any "attached" identifier. Should we add one?
1069             // https://bugs.webkit.org/show_bug.cgi?id=72700
1070             if (customOperation->meshType() == MeshTypeDetached)
1071                 meshParameters->append(cssValuePool().createIdentifierValue(CSSValueDetached));
1072             
1073             filterValue->append(meshParameters.release());
1074             
1075             const CustomFilterParameterList& parameters = customOperation->parameters();
1076             size_t parametersSize = parameters.size();
1077             if (!parametersSize)
1078                 break;
1079             RefPtr<CSSValueList> parametersCSSValue = CSSValueList::createCommaSeparated();
1080             for (size_t i = 0; i < parametersSize; ++i) {
1081                 const CustomFilterParameter* parameter = parameters.at(i).get();
1082                 RefPtr<CSSValueList> parameterCSSNameAndValue = CSSValueList::createSpaceSeparated();
1083                 parameterCSSNameAndValue->append(cssValuePool().createValue(parameter->name(), CSSPrimitiveValue::CSS_STRING));
1084                 parameterCSSNameAndValue->append(valueForCustomFilterParameter(renderer, style, parameter));
1085                 parametersCSSValue->append(parameterCSSNameAndValue.release());
1086             }
1087             
1088             filterValue->append(parametersCSSValue.release());
1089             break;
1090         }
1091 #endif
1092         default:
1093             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::UnknownFilterOperation);
1094             break;
1095         }
1096         list->append(filterValue.release());
1097     }
1098
1099     return list.release();
1100 }
1101 #endif
1102
1103 static PassRefPtr<CSSValue> valueForGridTrackBreadth(const GridLength& trackBreadth, const RenderStyle* style, RenderView* renderView)
1104 {
1105     if (!trackBreadth.isLength())
1106         return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue::CSS_FR);
1107
1108     const Length& trackBreadthLength = trackBreadth.length();
1109     if (trackBreadthLength.isAuto())
1110         return cssValuePool().createIdentifierValue(CSSValueAuto);
1111     if (trackBreadthLength.isViewportPercentage())
1112         return zoomAdjustedPixelValue(valueForLength(trackBreadthLength, 0, renderView), style);
1113     return zoomAdjustedPixelValueForLength(trackBreadthLength, style);
1114 }
1115
1116 static PassRefPtr<CSSValue> valueForGridTrackSize(const GridTrackSize& trackSize, const RenderStyle* style, RenderView* renderView)
1117 {
1118     switch (trackSize.type()) {
1119     case LengthTrackSizing:
1120         return valueForGridTrackBreadth(trackSize.length(), style, renderView);
1121     case MinMaxTrackSizing:
1122         RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSeparated();
1123         minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.minTrackBreadth(), style, renderView));
1124         minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.maxTrackBreadth(), style, renderView));
1125         return CSSFunctionValue::create("minmax(", minMaxTrackBreadths);
1126     }
1127     ASSERT_NOT_REACHED();
1128     return 0;
1129 }
1130
1131 static void addValuesForNamedGridLinesAtIndex(const NamedGridLinesMap& namedGridLines, size_t i, CSSValueList& list)
1132 {
1133     // Note that this won't return the results in the order specified in the style sheet,
1134     // which is probably fine as we still *do* return all the expected values.
1135     NamedGridLinesMap::const_iterator it = namedGridLines.begin();
1136     NamedGridLinesMap::const_iterator end = namedGridLines.end();
1137     for (; it != end; ++it) {
1138         const Vector<size_t>& linesIndexes = it->value;
1139         for (size_t j = 0; j < linesIndexes.size(); ++j) {
1140             if (linesIndexes[j] != i)
1141                 continue;
1142
1143             list.append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
1144             break;
1145         }
1146     }
1147 }
1148
1149 static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& trackSizes, const NamedGridLinesMap& namedGridLines, const RenderStyle* style, RenderView* renderView)
1150 {
1151     // Handle the 'none' case here.
1152     if (!trackSizes.size()) {
1153         ASSERT(namedGridLines.isEmpty());
1154         return cssValuePool().createIdentifierValue(CSSValueNone);
1155     }
1156
1157     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1158     for (size_t i = 0; i < trackSizes.size(); ++i) {
1159         addValuesForNamedGridLinesAtIndex(namedGridLines, i, *list);
1160         list->append(valueForGridTrackSize(trackSizes[i], style, renderView));
1161     }
1162     // Those are the trailing <string>* allowed in the syntax.
1163     addValuesForNamedGridLinesAtIndex(namedGridLines, trackSizes.size(), *list);
1164     return list.release();
1165 }
1166
1167 static PassRefPtr<CSSValue> valueForGridPosition(const GridPosition& position)
1168 {
1169     if (position.isAuto())
1170         return cssValuePool().createIdentifierValue(CSSValueAuto);
1171
1172     if (position.isNamedGridArea())
1173         return cssValuePool().createValue(position.namedGridLine(), CSSPrimitiveValue::CSS_STRING);
1174
1175     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1176     if (position.isSpan()) {
1177         list->append(cssValuePool().createIdentifierValue(CSSValueSpan));
1178         list->append(cssValuePool().createValue(position.spanPosition(), CSSPrimitiveValue::CSS_NUMBER));
1179     } else
1180         list->append(cssValuePool().createValue(position.integerPosition(), CSSPrimitiveValue::CSS_NUMBER));
1181
1182     if (!position.namedGridLine().isNull())
1183         list->append(cssValuePool().createValue(position.namedGridLine(), CSSPrimitiveValue::CSS_STRING));
1184     return list.release();
1185 }
1186
1187 static PassRefPtr<CSSValue> createTransitionPropertyValue(const Animation& animation)
1188 {
1189     RefPtr<CSSValue> propertyValue;
1190     if (animation.animationMode() == Animation::AnimateNone)
1191         propertyValue = cssValuePool().createIdentifierValue(CSSValueNone);
1192     else if (animation.animationMode() == Animation::AnimateAll)
1193         propertyValue = cssValuePool().createIdentifierValue(CSSValueAll);
1194     else
1195         propertyValue = cssValuePool().createValue(getPropertyNameString(animation.property()), CSSPrimitiveValue::CSS_STRING);
1196     return propertyValue.release();
1197 }
1198
1199 static PassRefPtr<CSSValue> getTransitionPropertyValue(const AnimationList* animList)
1200 {
1201     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1202     if (animList) {
1203         for (size_t i = 0; i < animList->size(); ++i)
1204             list->append(createTransitionPropertyValue(animList->animation(i)));
1205     } else
1206         list->append(cssValuePool().createIdentifierValue(CSSValueAll));
1207     return list.release();
1208 }
1209
1210 static PassRefPtr<CSSValue> getDelayValue(const AnimationList* animList)
1211 {
1212     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1213     if (animList) {
1214         for (size_t i = 0; i < animList->size(); ++i)
1215             list->append(cssValuePool().createValue(animList->animation(i).delay(), CSSPrimitiveValue::CSS_S));
1216     } else {
1217         // Note that initialAnimationDelay() is used for both transitions and animations
1218         list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
1219     }
1220     return list.release();
1221 }
1222
1223 static PassRefPtr<CSSValue> getDurationValue(const AnimationList* animList)
1224 {
1225     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1226     if (animList) {
1227         for (size_t i = 0; i < animList->size(); ++i)
1228             list->append(cssValuePool().createValue(animList->animation(i).duration(), CSSPrimitiveValue::CSS_S));
1229     } else {
1230         // Note that initialAnimationDuration() is used for both transitions and animations
1231         list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
1232     }
1233     return list.release();
1234 }
1235
1236 static PassRefPtr<CSSValue> createTimingFunctionValue(const TimingFunction* timingFunction)
1237 {
1238     switch (timingFunction->type()) {
1239     case TimingFunction::CubicBezierFunction: {
1240         const CubicBezierTimingFunction* bezierTimingFunction = static_cast<const CubicBezierTimingFunction*>(timingFunction);
1241         if (bezierTimingFunction->timingFunctionPreset() != CubicBezierTimingFunction::Custom) {
1242             CSSValueID valueId = CSSValueInvalid;
1243             switch (bezierTimingFunction->timingFunctionPreset()) {
1244             case CubicBezierTimingFunction::Ease:
1245                 valueId = CSSValueEase;
1246                 break;
1247             case CubicBezierTimingFunction::EaseIn:
1248                 valueId = CSSValueEaseIn;
1249                 break;
1250             case CubicBezierTimingFunction::EaseOut:
1251                 valueId = CSSValueEaseOut;
1252                 break;
1253             case CubicBezierTimingFunction::EaseInOut:
1254                 valueId = CSSValueEaseInOut;
1255                 break;
1256             default:
1257                 ASSERT_NOT_REACHED();
1258                 return 0;
1259             }
1260             return cssValuePool().createIdentifierValue(valueId);
1261         }
1262         return CSSCubicBezierTimingFunctionValue::create(bezierTimingFunction->x1(), bezierTimingFunction->y1(), bezierTimingFunction->x2(), bezierTimingFunction->y2());
1263     }
1264     case TimingFunction::StepsFunction: {
1265         const StepsTimingFunction* stepsTimingFunction = static_cast<const StepsTimingFunction*>(timingFunction);
1266         return CSSStepsTimingFunctionValue::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtStart());
1267     }
1268     case TimingFunction::LinearFunction:
1269         return cssValuePool().createIdentifierValue(CSSValueLinear);
1270     }
1271     ASSERT_NOT_REACHED();
1272     return 0;
1273 }
1274
1275 static PassRefPtr<CSSValue> getTimingFunctionValue(const AnimationList* animList)
1276 {
1277     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1278     if (animList) {
1279         for (size_t i = 0; i < animList->size(); ++i)
1280             list->append(createTimingFunctionValue(animList->animation(i).timingFunction().get()));
1281     } else
1282         // Note that initialAnimationTimingFunction() is used for both transitions and animations
1283         list->append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
1284     return list.release();
1285 }
1286
1287 static PassRefPtr<CSSValue> createLineBoxContainValue(unsigned lineBoxContain)
1288 {
1289     if (!lineBoxContain)
1290         return cssValuePool().createIdentifierValue(CSSValueNone);
1291     return CSSLineBoxContainValue::create(lineBoxContain);
1292 }
1293
1294 ComputedStyleExtractor::ComputedStyleExtractor(PassRefPtr<Node> node, bool allowVisitedStyle, PseudoId pseudoElementSpecifier)
1295     : m_node(node)
1296     , m_pseudoElementSpecifier(pseudoElementSpecifier)
1297     , m_allowVisitedStyle(allowVisitedStyle)
1298 {
1299 }
1300
1301
1302 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n, bool allowVisitedStyle, const String& pseudoElementName)
1303     : m_node(n)
1304     , m_allowVisitedStyle(allowVisitedStyle)
1305     , m_refCount(1)
1306 {
1307     unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoElementName[1] == ':' ? 2 : 1) : 0;
1308     m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoType(
1309         AtomicString(pseudoElementName.substring(nameWithoutColonsStart))));
1310 }
1311
1312 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
1313 {
1314 }
1315
1316 void CSSComputedStyleDeclaration::ref()
1317 {
1318     ++m_refCount;
1319 }
1320
1321 void CSSComputedStyleDeclaration::deref()
1322 {
1323     ASSERT(m_refCount);
1324     if (!--m_refCount)
1325         delete this;
1326 }
1327
1328 String CSSComputedStyleDeclaration::cssText() const
1329 {
1330     StringBuilder result;
1331
1332     for (unsigned i = 0; i < numComputedProperties; i++) {
1333         if (i)
1334             result.append(' ');
1335         result.append(getPropertyName(computedProperties[i]));
1336         result.append(": ", 2);
1337         result.append(getPropertyValue(computedProperties[i]));
1338         result.append(';');
1339     }
1340
1341     return result.toString();
1342 }
1343
1344 void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
1345 {
1346     ec = NO_MODIFICATION_ALLOWED_ERR;
1347 }
1348
1349 static CSSValueID cssIdentifierForFontSizeKeyword(int keywordSize)
1350 {
1351     ASSERT_ARG(keywordSize, keywordSize);
1352     ASSERT_ARG(keywordSize, keywordSize <= 8);
1353     return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1);
1354 }
1355
1356 PassRefPtr<CSSPrimitiveValue> ComputedStyleExtractor::getFontSizeCSSValuePreferringKeyword() const
1357 {
1358     if (!m_node)
1359         return 0;
1360
1361     m_node->document().updateLayoutIgnorePendingStylesheets();
1362
1363     RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1364     if (!style)
1365         return 0;
1366
1367     if (int keywordSize = style->fontDescription().keywordSize())
1368         return cssValuePool().createIdentifierValue(cssIdentifierForFontSizeKeyword(keywordSize));
1369
1370     return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style.get());
1371 }
1372
1373 bool ComputedStyleExtractor::useFixedFontDefaultSize() const
1374 {
1375     if (!m_node)
1376         return false;
1377
1378     RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1379     if (!style)
1380         return false;
1381
1382     return style->fontDescription().useFixedDefaultSize();
1383 }
1384
1385
1386 static CSSValueID identifierForFamily(const AtomicString& family)
1387 {
1388     if (family == cursiveFamily)
1389         return CSSValueCursive;
1390     if (family == fantasyFamily)
1391         return CSSValueFantasy;
1392     if (family == monospaceFamily)
1393         return CSSValueMonospace;
1394     if (family == pictographFamily)
1395         return CSSValueWebkitPictograph;
1396     if (family == sansSerifFamily)
1397         return CSSValueSansSerif;
1398     if (family == serifFamily)
1399         return CSSValueSerif;
1400     return CSSValueInvalid;
1401 }
1402
1403 static PassRefPtr<CSSPrimitiveValue> valueForFamily(const AtomicString& family)
1404 {
1405     if (CSSValueID familyIdentifier = identifierForFamily(family))
1406         return cssValuePool().createIdentifierValue(familyIdentifier);
1407     return cssValuePool().createValue(family.string(), CSSPrimitiveValue::CSS_STRING);
1408 }
1409
1410 static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration)
1411 {
1412     // Blink value is ignored.
1413     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1414     if (textDecoration & TextDecorationUnderline)
1415         list->append(cssValuePool().createIdentifierValue(CSSValueUnderline));
1416     if (textDecoration & TextDecorationOverline)
1417         list->append(cssValuePool().createIdentifierValue(CSSValueOverline));
1418     if (textDecoration & TextDecorationLineThrough)
1419         list->append(cssValuePool().createIdentifierValue(CSSValueLineThrough));
1420 #if ENABLE(LETTERPRESS)
1421     if (textDecoration & TextDecorationLetterpress)
1422         list->append(cssValuePool().createIdentifierValue(CSSValueWebkitLetterpress));
1423 #endif
1424
1425     if (!list->length())
1426         return cssValuePool().createIdentifierValue(CSSValueNone);
1427     return list.release();
1428 }
1429
1430 #if ENABLE(CSS3_TEXT_DECORATION)
1431 static PassRefPtr<CSSValue> renderTextDecorationStyleFlagsToCSSValue(TextDecorationStyle textDecorationStyle)
1432 {
1433     switch (textDecorationStyle) {
1434     case TextDecorationStyleSolid:
1435         return cssValuePool().createIdentifierValue(CSSValueSolid);
1436     case TextDecorationStyleDouble:
1437         return cssValuePool().createIdentifierValue(CSSValueDouble);
1438     case TextDecorationStyleDotted:
1439         return cssValuePool().createIdentifierValue(CSSValueDotted);
1440     case TextDecorationStyleDashed:
1441         return cssValuePool().createIdentifierValue(CSSValueDashed);
1442     case TextDecorationStyleWavy:
1443         return cssValuePool().createIdentifierValue(CSSValueWavy);
1444     }
1445
1446     ASSERT_NOT_REACHED();
1447     return cssValuePool().createExplicitInitialValue();
1448 }
1449
1450 static PassRefPtr<CSSValue> renderTextDecorationSkipFlagsToCSSValue(TextDecorationSkip textDecorationSkip)
1451 {
1452     switch (textDecorationSkip) {
1453     case TextDecorationSkipNone:
1454         return cssValuePool().createExplicitInitialValue();
1455     case TextDecorationSkipInk:
1456         return cssValuePool().createIdentifierValue(CSSValueInk);
1457     }
1458
1459     ASSERT_NOT_REACHED();
1460     return cssValuePool().createExplicitInitialValue();
1461 }
1462 #endif // CSS3_TEXT_DECORATION
1463
1464 static PassRefPtr<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat)
1465 {
1466     // For backwards compatibility, if both values are equal, just return one of them. And
1467     // if the two values are equivalent to repeat-x or repeat-y, just return the shorthand.
1468     if (xRepeat == yRepeat)
1469         return cssValuePool().createValue(xRepeat);
1470     if (xRepeat == RepeatFill && yRepeat == NoRepeatFill)
1471         return cssValuePool().createIdentifierValue(CSSValueRepeatX);
1472     if (xRepeat == NoRepeatFill && yRepeat == RepeatFill)
1473         return cssValuePool().createIdentifierValue(CSSValueRepeatY);
1474
1475     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1476     list->append(cssValuePool().createValue(xRepeat));
1477     list->append(cssValuePool().createValue(yRepeat));
1478     return list.release();
1479 }
1480
1481 static PassRefPtr<CSSValue> fillSourceTypeToCSSValue(EMaskSourceType type)
1482 {
1483     switch (type) {
1484     case MaskAlpha:
1485         return cssValuePool().createValue(CSSValueAlpha);
1486     case MaskLuminance:
1487         return cssValuePool().createValue(CSSValueLuminance);
1488     }
1489
1490     ASSERT_NOT_REACHED();
1491
1492     return 0;
1493 }
1494 static PassRefPtr<CSSValue> fillSizeToCSSValue(const FillSize& fillSize, const RenderStyle* style)
1495 {
1496     if (fillSize.type == Contain)
1497         return cssValuePool().createIdentifierValue(CSSValueContain);
1498
1499     if (fillSize.type == Cover)
1500         return cssValuePool().createIdentifierValue(CSSValueCover);
1501
1502     if (fillSize.size.height().isAuto())
1503         return zoomAdjustedPixelValueForLength(fillSize.size.width(), style);
1504
1505     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1506     list->append(zoomAdjustedPixelValueForLength(fillSize.size.width(), style));
1507     list->append(zoomAdjustedPixelValueForLength(fillSize.size.height(), style));
1508     return list.release();
1509 }
1510
1511 static PassRefPtr<CSSValue> altTextToCSSValue(const RenderStyle* style)
1512 {
1513     return cssValuePool().createValue(style->contentAltText(), CSSPrimitiveValue::CSS_STRING);
1514 }
1515     
1516 static PassRefPtr<CSSValue> contentToCSSValue(const RenderStyle* style)
1517 {
1518     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1519     for (const ContentData* contentData = style->contentData(); contentData; contentData = contentData->next()) {
1520         if (contentData->isCounter()) {
1521             const CounterContent* counter = static_cast<const CounterContentData*>(contentData)->counter();
1522             ASSERT(counter);
1523             list->append(cssValuePool().createValue(counter->identifier(), CSSPrimitiveValue::CSS_COUNTER_NAME));
1524         } else if (contentData->isImage()) {
1525             const StyleImage* image = static_cast<const ImageContentData*>(contentData)->image();
1526             ASSERT(image);
1527             list->append(image->cssValue());
1528         } else if (contentData->isText())
1529             list->append(cssValuePool().createValue(static_cast<const TextContentData*>(contentData)->text(), CSSPrimitiveValue::CSS_STRING));
1530     }
1531     if (style->hasFlowFrom())
1532         list->append(cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING));
1533     return list.release();
1534 }
1535
1536 static PassRefPtr<CSSValue> counterToCSSValue(const RenderStyle* style, CSSPropertyID propertyID)
1537 {
1538     const CounterDirectiveMap* map = style->counterDirectives();
1539     if (!map)
1540         return 0;
1541
1542     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1543     for (CounterDirectiveMap::const_iterator it = map->begin(); it != map->end(); ++it) {
1544         list->append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
1545         short number = propertyID == CSSPropertyCounterIncrement ? it->value.incrementValue() : it->value.resetValue();
1546         list->append(cssValuePool().createValue((double)number, CSSPrimitiveValue::CSS_NUMBER));
1547     }
1548     return list.release();
1549 }
1550
1551 static void logUnimplementedPropertyID(CSSPropertyID propertyID)
1552 {
1553     DEFINE_STATIC_LOCAL(HashSet<CSSPropertyID>, propertyIDSet, ());
1554     if (!propertyIDSet.add(propertyID).isNewEntry)
1555         return;
1556
1557     LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", getPropertyName(propertyID));
1558 }
1559
1560 static PassRefPtr<CSSValueList> fontFamilyFromStyle(RenderStyle* style)
1561     {
1562     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1563     for (unsigned i = 0; i < style->font().familyCount(); ++i)
1564         list->append(valueForFamily(style->font().familyAt(i)));
1565     return list.release();
1566 }
1567
1568 static PassRefPtr<CSSPrimitiveValue> lineHeightFromStyle(RenderStyle* style, RenderView* renderView)
1569 {
1570     Length length = style->lineHeight();
1571     if (length.isNegative())
1572         return cssValuePool().createIdentifierValue(CSSValueNormal);
1573     if (length.isPercent())
1574         // This is imperfect, because it doesn't include the zoom factor and the real computation
1575         // for how high to be in pixels does include things like minimum font size and the zoom factor.
1576         // On the other hand, since font-size doesn't include the zoom factor, we really can't do
1577         // that here either.
1578         return zoomAdjustedPixelValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, style);
1579     return zoomAdjustedPixelValue(floatValueForLength(length, 0, renderView), style);
1580 }
1581
1582 static PassRefPtr<CSSPrimitiveValue> fontSizeFromStyle(RenderStyle* style)
1583 {
1584     return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style);
1585 }
1586
1587 static PassRefPtr<CSSPrimitiveValue> fontStyleFromStyle(RenderStyle* style)
1588 {
1589     if (style->fontDescription().italic())
1590         return cssValuePool().createIdentifierValue(CSSValueItalic);
1591     return cssValuePool().createIdentifierValue(CSSValueNormal);
1592 }
1593
1594 static PassRefPtr<CSSPrimitiveValue> fontVariantFromStyle(RenderStyle* style)
1595 {
1596     if (style->fontDescription().smallCaps())
1597         return cssValuePool().createIdentifierValue(CSSValueSmallCaps);
1598     return cssValuePool().createIdentifierValue(CSSValueNormal);
1599 }
1600
1601 static PassRefPtr<CSSPrimitiveValue> fontWeightFromStyle(RenderStyle* style)
1602 {
1603     switch (style->fontDescription().weight()) {
1604     case FontWeight100:
1605         return cssValuePool().createIdentifierValue(CSSValue100);
1606     case FontWeight200:
1607         return cssValuePool().createIdentifierValue(CSSValue200);
1608     case FontWeight300:
1609         return cssValuePool().createIdentifierValue(CSSValue300);
1610     case FontWeightNormal:
1611         return cssValuePool().createIdentifierValue(CSSValueNormal);
1612     case FontWeight500:
1613         return cssValuePool().createIdentifierValue(CSSValue500);
1614     case FontWeight600:
1615         return cssValuePool().createIdentifierValue(CSSValue600);
1616     case FontWeightBold:
1617         return cssValuePool().createIdentifierValue(CSSValueBold);
1618     case FontWeight800:
1619         return cssValuePool().createIdentifierValue(CSSValue800);
1620     case FontWeight900:
1621         return cssValuePool().createIdentifierValue(CSSValue900);
1622     }
1623     ASSERT_NOT_REACHED();
1624     return cssValuePool().createIdentifierValue(CSSValueNormal);
1625 }
1626
1627 typedef const Length& (RenderStyle::*RenderStyleLengthGetter)() const;
1628 typedef LayoutUnit (RenderBoxModelObject::*RenderBoxComputedCSSValueGetter)() const;
1629
1630 template<RenderStyleLengthGetter lengthGetter, RenderBoxComputedCSSValueGetter computedCSSValueGetter>
1631 inline PassRefPtr<CSSValue> zoomAdjustedPaddingOrMarginPixelValue(RenderStyle* style, RenderObject* renderer)
1632 {
1633     Length unzoomzedLength = (style->*lengthGetter)();
1634     if (!renderer || !renderer->isBox() || unzoomzedLength.isFixed())
1635         return zoomAdjustedPixelValueForLength(unzoomzedLength, style);
1636     return zoomAdjustedPixelValue((toRenderBox(renderer)->*computedCSSValueGetter)(), style);
1637 }
1638
1639 template<RenderStyleLengthGetter lengthGetter>
1640 inline bool paddingOrMarginIsRendererDependent(RenderStyle* style, RenderObject* renderer)
1641 {
1642     if (!renderer || !renderer->isBox())
1643         return false;
1644     return !(style && (style->*lengthGetter)().isFixed());
1645 }
1646
1647 static bool isLayoutDependent(CSSPropertyID propertyID, RenderStyle* style, RenderObject* renderer)
1648 {
1649     switch (propertyID) {
1650     case CSSPropertyWidth:
1651     case CSSPropertyHeight:
1652     case CSSPropertyWebkitPerspectiveOrigin:
1653     case CSSPropertyWebkitTransformOrigin:
1654     case CSSPropertyWebkitTransform:
1655 #if ENABLE(CSS_FILTERS)
1656     case CSSPropertyWebkitFilter:
1657 #endif
1658         return true;
1659     case CSSPropertyMargin: {
1660         if (!renderer || !renderer->isBox())
1661             return false;
1662         return !(style && style->marginTop().isFixed() && style->marginRight().isFixed()
1663             && style->marginBottom().isFixed() && style->marginLeft().isFixed());
1664     }
1665     case CSSPropertyMarginTop:
1666         return paddingOrMarginIsRendererDependent<&RenderStyle::marginTop>(style, renderer);
1667     case CSSPropertyMarginRight:
1668         return paddingOrMarginIsRendererDependent<&RenderStyle::marginRight>(style, renderer);
1669     case CSSPropertyMarginBottom:
1670         return paddingOrMarginIsRendererDependent<&RenderStyle::marginBottom>(style, renderer);
1671     case CSSPropertyMarginLeft:
1672         return paddingOrMarginIsRendererDependent<&RenderStyle::marginLeft>(style, renderer);
1673     case CSSPropertyPadding: {
1674         if (!renderer || !renderer->isBox())
1675             return false;
1676         return !(style && style->paddingTop().isFixed() && style->paddingRight().isFixed()
1677             && style->paddingBottom().isFixed() && style->paddingLeft().isFixed());
1678     }
1679     case CSSPropertyPaddingTop:
1680         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingTop>(style, renderer);
1681     case CSSPropertyPaddingRight:
1682         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingRight>(style, renderer);
1683     case CSSPropertyPaddingBottom:
1684         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingBottom>(style, renderer);
1685     case CSSPropertyPaddingLeft:
1686         return paddingOrMarginIsRendererDependent<&RenderStyle::paddingLeft>(style, renderer); 
1687     default:
1688         return false;
1689     }
1690 }
1691
1692 Node* ComputedStyleExtractor::styledNode() const
1693 {
1694     if (!m_node)
1695         return 0;
1696     if (!m_node->isElementNode())
1697         return m_node.get();
1698     Element* element = toElement(m_node.get());
1699     PseudoElement* pseudoElement;
1700     if (m_pseudoElementSpecifier == BEFORE && (pseudoElement = element->beforePseudoElement()))
1701         return pseudoElement;
1702     if (m_pseudoElementSpecifier == AFTER && (pseudoElement = element->afterPseudoElement()))
1703         return pseudoElement;
1704     return element;
1705 }
1706
1707 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1708 {
1709     return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).propertyValue(propertyID, updateLayout);
1710 }
1711
1712 PassRef<MutableStyleProperties> CSSComputedStyleDeclaration::copyProperties() const
1713 {
1714     return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).copyProperties();
1715 }
1716
1717 static inline bool nodeOrItsAncestorNeedsStyleRecalc(Node* styledNode)
1718 {
1719     if (styledNode->document().hasPendingForcedStyleRecalc())
1720         return true;
1721     for (Node* n = styledNode; n; n = n->parentNode()) {// FIXME: Call parentOrShadowHostNode() instead
1722         if (n->needsStyleRecalc())
1723             return true;
1724     }
1725     return false;
1726 }
1727
1728 static inline PassRefPtr<RenderStyle> computeRenderStyleForProperty(Node* styledNode, PseudoId pseudoElementSpecifier, CSSPropertyID propertyID)
1729 {
1730     RenderObject* renderer = styledNode->renderer();
1731
1732     if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
1733         AnimationUpdateBlock animationUpdateBlock(&renderer->animation());
1734         RefPtr<RenderStyle> style = renderer->animation().getAnimatedStyleForRenderer(toRenderElement(renderer));
1735         if (pseudoElementSpecifier && !styledNode->isPseudoElement()) {
1736             // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
1737             return style->getCachedPseudoStyle(pseudoElementSpecifier);
1738         }
1739         return style.release();
1740     }
1741
1742     return styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : pseudoElementSpecifier);
1743 }
1744
1745 PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1746 {
1747     Node* styledNode = this->styledNode();
1748     if (!styledNode)
1749         return 0;
1750
1751     RefPtr<RenderStyle> style;
1752     RenderObject* renderer = 0;
1753     bool forceFullLayout = false;
1754     if (updateLayout) {
1755         Document& document = styledNode->document();
1756
1757         if (nodeOrItsAncestorNeedsStyleRecalc(styledNode)) {
1758             document.updateStyleIfNeeded();
1759             // The style recalc could have caused the styled node to be discarded or replaced
1760             // if it was a PseudoElement so we need to update it.
1761             styledNode = this->styledNode();
1762         }
1763
1764         style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID);
1765         renderer = styledNode->renderer();
1766
1767         // FIXME: Some of these cases could be narrowed down or optimized better.
1768         forceFullLayout = isLayoutDependent(propertyID, style.get(), renderer)
1769             || styledNode->isInShadowTree()
1770             || (document.styleResolverIfExists() && document.styleResolverIfExists()->hasViewportDependentMediaQueries() && document.ownerElement())
1771             || document.seamlessParentIFrame();
1772
1773         if (forceFullLayout) {
1774             document.updateLayoutIgnorePendingStylesheets();
1775             styledNode = this->styledNode();
1776         }
1777     }
1778
1779     if (!updateLayout || forceFullLayout) {
1780         style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID);
1781         renderer = styledNode->renderer();
1782     }
1783
1784     if (!style)
1785         return 0;
1786
1787     propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction(), style->writingMode());
1788
1789     switch (propertyID) {
1790         case CSSPropertyInvalid:
1791             break;
1792
1793         case CSSPropertyBackgroundColor:
1794             return cssValuePool().createColorValue(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb());
1795         case CSSPropertyBackgroundImage:
1796         case CSSPropertyWebkitMaskImage: {
1797             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskImage ? style->maskLayers() : style->backgroundLayers();
1798             if (!layers)
1799                 return cssValuePool().createIdentifierValue(CSSValueNone);
1800
1801             if (!layers->next()) {
1802                 if (layers->image())
1803                     return layers->image()->cssValue();
1804
1805                 return cssValuePool().createIdentifierValue(CSSValueNone);
1806             }
1807
1808             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1809             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1810                 if (currLayer->image())
1811                     list->append(currLayer->image()->cssValue());
1812                 else
1813                     list->append(cssValuePool().createIdentifierValue(CSSValueNone));
1814             }
1815             return list.release();
1816         }
1817         case CSSPropertyBackgroundSize:
1818         case CSSPropertyWebkitBackgroundSize:
1819         case CSSPropertyWebkitMaskSize: {
1820             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskSize ? style->maskLayers() : style->backgroundLayers();
1821             if (!layers->next())
1822                 return fillSizeToCSSValue(layers->size(), style.get());
1823
1824             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1825             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1826                 list->append(fillSizeToCSSValue(currLayer->size(), style.get()));
1827
1828             return list.release();
1829         }
1830         case CSSPropertyBackgroundRepeat:
1831         case CSSPropertyWebkitMaskRepeat: {
1832             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskRepeat ? style->maskLayers() : style->backgroundLayers();
1833             if (!layers->next())
1834                 return fillRepeatToCSSValue(layers->repeatX(), layers->repeatY());
1835
1836             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1837             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1838                 list->append(fillRepeatToCSSValue(currLayer->repeatX(), currLayer->repeatY()));
1839
1840             return list.release();
1841         }
1842         case CSSPropertyWebkitMaskSourceType: {
1843             const FillLayer* layers = style->maskLayers();
1844
1845             if (!layers)
1846                 return cssValuePool().createIdentifierValue(CSSValueNone);
1847
1848             if (!layers->next())
1849                 return fillSourceTypeToCSSValue(layers->maskSourceType());
1850
1851             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1852             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1853                 list->append(fillSourceTypeToCSSValue(currLayer->maskSourceType()));
1854
1855             return list.release();
1856         }
1857         case CSSPropertyWebkitBackgroundComposite:
1858         case CSSPropertyWebkitMaskComposite: {
1859             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskComposite ? style->maskLayers() : style->backgroundLayers();
1860             if (!layers->next())
1861                 return cssValuePool().createValue(layers->composite());
1862
1863             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1864             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1865                 list->append(cssValuePool().createValue(currLayer->composite()));
1866
1867             return list.release();
1868         }
1869         case CSSPropertyBackgroundAttachment: {
1870             const FillLayer* layers = style->backgroundLayers();
1871             if (!layers->next())
1872                 return cssValuePool().createValue(layers->attachment());
1873
1874             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1875             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1876                 list->append(cssValuePool().createValue(currLayer->attachment()));
1877
1878             return list.release();
1879         }
1880         case CSSPropertyBackgroundClip:
1881         case CSSPropertyBackgroundOrigin:
1882         case CSSPropertyWebkitBackgroundClip:
1883         case CSSPropertyWebkitBackgroundOrigin:
1884         case CSSPropertyWebkitMaskClip:
1885         case CSSPropertyWebkitMaskOrigin: {
1886             const FillLayer* layers = (propertyID == CSSPropertyWebkitMaskClip || propertyID == CSSPropertyWebkitMaskOrigin) ? style->maskLayers() : style->backgroundLayers();
1887             bool isClip = propertyID == CSSPropertyBackgroundClip || propertyID == CSSPropertyWebkitBackgroundClip || propertyID == CSSPropertyWebkitMaskClip;
1888             if (!layers->next()) {
1889                 EFillBox box = isClip ? layers->clip() : layers->origin();
1890                 return cssValuePool().createValue(box);
1891             }
1892
1893             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1894             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1895                 EFillBox box = isClip ? currLayer->clip() : currLayer->origin();
1896                 list->append(cssValuePool().createValue(box));
1897             }
1898
1899             return list.release();
1900         }
1901         case CSSPropertyBackgroundPosition:
1902         case CSSPropertyWebkitMaskPosition: {
1903             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPosition ? style->maskLayers() : style->backgroundLayers();
1904             if (!layers->next())
1905                 return createPositionListForLayer(propertyID, layers, style.get());
1906
1907             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1908             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1909                 list->append(createPositionListForLayer(propertyID, currLayer, style.get()));
1910             return list.release();
1911         }
1912         case CSSPropertyBackgroundPositionX:
1913         case CSSPropertyWebkitMaskPositionX: {
1914             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionX ? style->maskLayers() : style->backgroundLayers();
1915             if (!layers->next())
1916                 return cssValuePool().createValue(layers->xPosition());
1917
1918             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1919             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1920                 list->append(cssValuePool().createValue(currLayer->xPosition()));
1921
1922             return list.release();
1923         }
1924         case CSSPropertyBackgroundPositionY:
1925         case CSSPropertyWebkitMaskPositionY: {
1926             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionY ? style->maskLayers() : style->backgroundLayers();
1927             if (!layers->next())
1928                 return cssValuePool().createValue(layers->yPosition());
1929
1930             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1931             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1932                 list->append(cssValuePool().createValue(currLayer->yPosition()));
1933
1934             return list.release();
1935         }
1936         case CSSPropertyBorderCollapse:
1937             if (style->borderCollapse())
1938                 return cssValuePool().createIdentifierValue(CSSValueCollapse);
1939             return cssValuePool().createIdentifierValue(CSSValueSeparate);
1940         case CSSPropertyBorderSpacing: {
1941             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1942             list->append(zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get()));
1943             list->append(zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get()));
1944             return list.release();
1945         }
1946         case CSSPropertyWebkitBorderHorizontalSpacing:
1947             return zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get());
1948         case CSSPropertyWebkitBorderVerticalSpacing:
1949             return zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get());
1950         case CSSPropertyBorderImageSource:
1951             if (style->borderImageSource())
1952                 return style->borderImageSource()->cssValue();
1953             return cssValuePool().createIdentifierValue(CSSValueNone);
1954         case CSSPropertyBorderTopColor:
1955             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor());
1956         case CSSPropertyBorderRightColor:
1957             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor());
1958         case CSSPropertyBorderBottomColor:
1959             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor());
1960         case CSSPropertyBorderLeftColor:
1961             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor());
1962         case CSSPropertyBorderTopStyle:
1963             return cssValuePool().createValue(style->borderTopStyle());
1964         case CSSPropertyBorderRightStyle:
1965             return cssValuePool().createValue(style->borderRightStyle());
1966         case CSSPropertyBorderBottomStyle:
1967             return cssValuePool().createValue(style->borderBottomStyle());
1968         case CSSPropertyBorderLeftStyle:
1969             return cssValuePool().createValue(style->borderLeftStyle());
1970         case CSSPropertyBorderTopWidth:
1971             return zoomAdjustedPixelValue(style->borderTopWidth(), style.get());
1972         case CSSPropertyBorderRightWidth:
1973             return zoomAdjustedPixelValue(style->borderRightWidth(), style.get());
1974         case CSSPropertyBorderBottomWidth:
1975             return zoomAdjustedPixelValue(style->borderBottomWidth(), style.get());
1976         case CSSPropertyBorderLeftWidth:
1977             return zoomAdjustedPixelValue(style->borderLeftWidth(), style.get());
1978         case CSSPropertyBottom:
1979             return getPositionOffsetValue(style.get(), CSSPropertyBottom, m_node->document().renderView());
1980         case CSSPropertyWebkitBoxAlign:
1981             return cssValuePool().createValue(style->boxAlign());
1982 #if ENABLE(CSS_BOX_DECORATION_BREAK)
1983         case CSSPropertyWebkitBoxDecorationBreak:
1984             if (style->boxDecorationBreak() == DSLICE)
1985                 return cssValuePool().createIdentifierValue(CSSValueSlice);
1986         return cssValuePool().createIdentifierValue(CSSValueClone);
1987 #endif
1988         case CSSPropertyWebkitBoxDirection:
1989             return cssValuePool().createValue(style->boxDirection());
1990         case CSSPropertyWebkitBoxFlex:
1991             return cssValuePool().createValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
1992         case CSSPropertyWebkitBoxFlexGroup:
1993             return cssValuePool().createValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
1994         case CSSPropertyWebkitBoxLines:
1995             return cssValuePool().createValue(style->boxLines());
1996         case CSSPropertyWebkitBoxOrdinalGroup:
1997             return cssValuePool().createValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
1998         case CSSPropertyWebkitBoxOrient:
1999             return cssValuePool().createValue(style->boxOrient());
2000         case CSSPropertyWebkitBoxPack:
2001             return cssValuePool().createValue(style->boxPack());
2002         case CSSPropertyWebkitBoxReflect:
2003             return valueForReflection(style->boxReflect(), style.get());
2004         case CSSPropertyBoxShadow:
2005         case CSSPropertyWebkitBoxShadow:
2006             return valueForShadow(style->boxShadow(), propertyID, style.get());
2007         case CSSPropertyCaptionSide:
2008             return cssValuePool().createValue(style->captionSide());
2009         case CSSPropertyClear:
2010             return cssValuePool().createValue(style->clear());
2011         case CSSPropertyColor:
2012             return cssValuePool().createColorValue(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb());
2013         case CSSPropertyWebkitPrintColorAdjust:
2014             return cssValuePool().createValue(style->printColorAdjust());
2015         case CSSPropertyWebkitColumnAxis:
2016             return cssValuePool().createValue(style->columnAxis());
2017         case CSSPropertyWebkitColumnCount:
2018             if (style->hasAutoColumnCount())
2019                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2020             return cssValuePool().createValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
2021         case CSSPropertyWebkitColumnFill:
2022             return cssValuePool().createValue(style->columnFill());
2023         case CSSPropertyWebkitColumnGap:
2024             if (style->hasNormalColumnGap())
2025                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2026             return zoomAdjustedPixelValue(style->columnGap(), style.get());
2027         case CSSPropertyWebkitColumnProgression:
2028             return cssValuePool().createValue(style->columnProgression());
2029         case CSSPropertyWebkitColumnRuleColor:
2030             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor());
2031         case CSSPropertyWebkitColumnRuleStyle:
2032             return cssValuePool().createValue(style->columnRuleStyle());
2033         case CSSPropertyWebkitColumnRuleWidth:
2034             return zoomAdjustedPixelValue(style->columnRuleWidth(), style.get());
2035         case CSSPropertyWebkitColumnSpan:
2036             return cssValuePool().createIdentifierValue(style->columnSpan() ? CSSValueAll : CSSValueNone);
2037         case CSSPropertyWebkitColumnBreakAfter:
2038             return cssValuePool().createValue(style->columnBreakAfter());
2039         case CSSPropertyWebkitColumnBreakBefore:
2040             return cssValuePool().createValue(style->columnBreakBefore());
2041         case CSSPropertyWebkitColumnBreakInside:
2042             return cssValuePool().createValue(style->columnBreakInside());
2043         case CSSPropertyWebkitColumnWidth:
2044             if (style->hasAutoColumnWidth())
2045                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2046             return zoomAdjustedPixelValue(style->columnWidth(), style.get());
2047         case CSSPropertyTabSize:
2048             return cssValuePool().createValue(style->tabSize(), CSSPrimitiveValue::CSS_NUMBER);
2049 #if ENABLE(CSS_REGIONS)
2050         case CSSPropertyWebkitRegionBreakAfter:
2051             return cssValuePool().createValue(style->regionBreakAfter());
2052         case CSSPropertyWebkitRegionBreakBefore:
2053             return cssValuePool().createValue(style->regionBreakBefore());
2054         case CSSPropertyWebkitRegionBreakInside:
2055             return cssValuePool().createValue(style->regionBreakInside());
2056 #endif
2057         case CSSPropertyCursor: {
2058             RefPtr<CSSValueList> list;
2059             CursorList* cursors = style->cursors();
2060             if (cursors && cursors->size() > 0) {
2061                 list = CSSValueList::createCommaSeparated();
2062                 for (unsigned i = 0; i < cursors->size(); ++i)
2063                     if (StyleImage* image = cursors->at(i).image())
2064                         list->append(image->cssValue());
2065             }
2066             RefPtr<CSSValue> value = cssValuePool().createValue(style->cursor());
2067             if (list) {
2068                 list->append(value.release());
2069                 return list.release();
2070             }
2071             return value.release();
2072         }
2073 #if ENABLE(CURSOR_VISIBILITY)
2074         case CSSPropertyWebkitCursorVisibility:
2075             return cssValuePool().createValue(style->cursorVisibility());
2076 #endif
2077         case CSSPropertyDirection:
2078             return cssValuePool().createValue(style->direction());
2079         case CSSPropertyDisplay:
2080             return cssValuePool().createValue(style->display());
2081         case CSSPropertyEmptyCells:
2082             return cssValuePool().createValue(style->emptyCells());
2083         case CSSPropertyWebkitAlignContent:
2084             return cssValuePool().createValue(style->alignContent());
2085         case CSSPropertyWebkitAlignItems:
2086             return cssValuePool().createValue(style->alignItems());
2087         case CSSPropertyWebkitAlignSelf:
2088             if (style->alignSelf() == AlignAuto) {
2089                 Node* parent = styledNode->parentNode();
2090                 if (parent && parent->computedStyle())
2091                     return cssValuePool().createValue(parent->computedStyle()->alignItems());
2092                 return cssValuePool().createValue(AlignStretch);
2093             }
2094             return cssValuePool().createValue(style->alignSelf());
2095         case CSSPropertyWebkitFlex:
2096             return getCSSPropertyValuesForShorthandProperties(webkitFlexShorthand());
2097         case CSSPropertyWebkitFlexBasis:
2098             return cssValuePool().createValue(style->flexBasis());
2099         case CSSPropertyWebkitFlexDirection:
2100             return cssValuePool().createValue(style->flexDirection());
2101         case CSSPropertyWebkitFlexFlow:
2102             return getCSSPropertyValuesForShorthandProperties(webkitFlexFlowShorthand());
2103         case CSSPropertyWebkitFlexGrow:
2104             return cssValuePool().createValue(style->flexGrow());
2105         case CSSPropertyWebkitFlexShrink:
2106             return cssValuePool().createValue(style->flexShrink());
2107         case CSSPropertyWebkitFlexWrap:
2108             return cssValuePool().createValue(style->flexWrap());
2109         case CSSPropertyWebkitJustifyContent:
2110             return cssValuePool().createValue(style->justifyContent());
2111         case CSSPropertyWebkitOrder:
2112             return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
2113         case CSSPropertyFloat:
2114             if (style->display() != NONE && style->hasOutOfFlowPosition())
2115                 return cssValuePool().createIdentifierValue(CSSValueNone);
2116             return cssValuePool().createValue(style->floating());
2117         case CSSPropertyFont: {
2118             RefPtr<CSSFontValue> computedFont = CSSFontValue::create();
2119             computedFont->style = fontStyleFromStyle(style.get());
2120             computedFont->variant = fontVariantFromStyle(style.get());
2121             computedFont->weight = fontWeightFromStyle(style.get());
2122             computedFont->size = fontSizeFromStyle(style.get());
2123             computedFont->lineHeight = lineHeightFromStyle(style.get(), m_node->document().renderView());
2124             computedFont->family = fontFamilyFromStyle(style.get());
2125             return computedFont.release();
2126         }
2127         case CSSPropertyFontFamily: {
2128             RefPtr<CSSValueList> fontFamilyList = fontFamilyFromStyle(style.get());
2129             // If there's only a single family, return that as a CSSPrimitiveValue.
2130             // NOTE: Gecko always returns this as a comma-separated CSSPrimitiveValue string.
2131             if (fontFamilyList->length() == 1)
2132                 return fontFamilyList->item(0);
2133             return fontFamilyList.release();
2134         }
2135         case CSSPropertyFontSize:
2136             return fontSizeFromStyle(style.get());
2137         case CSSPropertyFontStyle:
2138             return fontStyleFromStyle(style.get());
2139         case CSSPropertyFontVariant:
2140             return fontVariantFromStyle(style.get());
2141         case CSSPropertyFontWeight:
2142             return fontWeightFromStyle(style.get());
2143         case CSSPropertyWebkitFontFeatureSettings: {
2144             const FontFeatureSettings* featureSettings = style->fontDescription().featureSettings();
2145             if (!featureSettings || !featureSettings->size())
2146                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2147             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2148             for (unsigned i = 0; i < featureSettings->size(); ++i) {
2149                 const FontFeature& feature = featureSettings->at(i);
2150                 list->append(CSSFontFeatureValue::create(feature.tag(), feature.value()));
2151             }
2152             return list.release();
2153         }
2154         case CSSPropertyWebkitGridAutoColumns:
2155             return valueForGridTrackSize(style->gridAutoColumns(), style.get(), m_node->document().renderView());
2156         case CSSPropertyWebkitGridAutoFlow:
2157             return cssValuePool().createValue(style->gridAutoFlow());
2158         case CSSPropertyWebkitGridAutoRows:
2159             return valueForGridTrackSize(style->gridAutoRows(), style.get(), m_node->document().renderView());
2160         case CSSPropertyWebkitGridDefinitionColumns:
2161             return valueForGridTrackList(style->gridColumns(), style->namedGridColumnLines(), style.get(), m_node->document().renderView());
2162         case CSSPropertyWebkitGridDefinitionRows:
2163             return valueForGridTrackList(style->gridRows(), style->namedGridRowLines(), style.get(), m_node->document().renderView());
2164
2165         case CSSPropertyWebkitGridColumnStart:
2166             return valueForGridPosition(style->gridItemColumnStart());
2167         case CSSPropertyWebkitGridColumnEnd:
2168             return valueForGridPosition(style->gridItemColumnEnd());
2169         case CSSPropertyWebkitGridRowStart:
2170             return valueForGridPosition(style->gridItemRowStart());
2171         case CSSPropertyWebkitGridRowEnd:
2172             return valueForGridPosition(style->gridItemRowEnd());
2173         case CSSPropertyWebkitGridArea:
2174             return getCSSPropertyValuesForGridShorthand(webkitGridAreaShorthand());
2175         case CSSPropertyWebkitGridColumn:
2176             return getCSSPropertyValuesForGridShorthand(webkitGridColumnShorthand());
2177         case CSSPropertyWebkitGridRow:
2178             return getCSSPropertyValuesForGridShorthand(webkitGridRowShorthand());
2179
2180         case CSSPropertyWebkitGridTemplate:
2181             if (!style->namedGridAreaRowCount()) {
2182                 ASSERT(!style->namedGridAreaColumnCount());
2183                 return cssValuePool().createIdentifierValue(CSSValueNone);
2184             }
2185
2186             return CSSGridTemplateValue::create(style->namedGridArea(), style->namedGridAreaRowCount(), style->namedGridAreaColumnCount());
2187
2188         case CSSPropertyHeight:
2189             if (renderer) {
2190                 // According to http://www.w3.org/TR/CSS2/visudet.html#the-height-property,
2191                 // the "height" property does not apply for non-replaced inline elements.
2192                 if (!renderer->isReplaced() && renderer->isInline())
2193                     return cssValuePool().createIdentifierValue(CSSValueAuto);
2194                 return zoomAdjustedPixelValue(sizingBox(renderer).height(), style.get());
2195             }
2196             return zoomAdjustedPixelValueForLength(style->height(), style.get());
2197         case CSSPropertyWebkitHighlight:
2198             if (style->highlight() == nullAtom)
2199                 return cssValuePool().createIdentifierValue(CSSValueNone);
2200             return cssValuePool().createValue(style->highlight(), CSSPrimitiveValue::CSS_STRING);
2201         case CSSPropertyWebkitHyphens:
2202             return cssValuePool().createValue(style->hyphens());
2203         case CSSPropertyWebkitHyphenateCharacter:
2204             if (style->hyphenationString().isNull())
2205                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2206             return cssValuePool().createValue(style->hyphenationString(), CSSPrimitiveValue::CSS_STRING);
2207         case CSSPropertyWebkitHyphenateLimitAfter:
2208             if (style->hyphenationLimitAfter() < 0)
2209                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
2210             return CSSPrimitiveValue::create(style->hyphenationLimitAfter(), CSSPrimitiveValue::CSS_NUMBER);
2211         case CSSPropertyWebkitHyphenateLimitBefore:
2212             if (style->hyphenationLimitBefore() < 0)
2213                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
2214             return CSSPrimitiveValue::create(style->hyphenationLimitBefore(), CSSPrimitiveValue::CSS_NUMBER);
2215         case CSSPropertyWebkitHyphenateLimitLines:
2216             if (style->hyphenationLimitLines() < 0)
2217                 return CSSPrimitiveValue::createIdentifier(CSSValueNoLimit);
2218             return CSSPrimitiveValue::create(style->hyphenationLimitLines(), CSSPrimitiveValue::CSS_NUMBER);
2219         case CSSPropertyWebkitBorderFit:
2220             if (style->borderFit() == BorderFitBorder)
2221                 return cssValuePool().createIdentifierValue(CSSValueBorder);
2222             return cssValuePool().createIdentifierValue(CSSValueLines);
2223 #if ENABLE(CSS_IMAGE_ORIENTATION)
2224         case CSSPropertyImageOrientation:
2225             return cssValuePool().createValue(style->imageOrientation());
2226 #endif
2227         case CSSPropertyImageRendering:
2228             return CSSPrimitiveValue::create(style->imageRendering());
2229 #if ENABLE(CSS_IMAGE_RESOLUTION)
2230         case CSSPropertyImageResolution:
2231             return cssValuePool().createValue(style->imageResolution(), CSSPrimitiveValue::CSS_DPPX);
2232 #endif
2233         case CSSPropertyLeft:
2234             return getPositionOffsetValue(style.get(), CSSPropertyLeft, m_node->document().renderView());
2235         case CSSPropertyLetterSpacing:
2236             if (!style->letterSpacing())
2237                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2238             return zoomAdjustedPixelValue(style->letterSpacing(), style.get());
2239         case CSSPropertyWebkitLineClamp:
2240             if (style->lineClamp().isNone())
2241                 return cssValuePool().createIdentifierValue(CSSValueNone);
2242             return cssValuePool().createValue(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
2243         case CSSPropertyLineHeight:
2244             return lineHeightFromStyle(style.get(), m_node->document().renderView());
2245         case CSSPropertyListStyleImage:
2246             if (style->listStyleImage())
2247                 return style->listStyleImage()->cssValue();
2248             return cssValuePool().createIdentifierValue(CSSValueNone);
2249         case CSSPropertyListStylePosition:
2250             return cssValuePool().createValue(style->listStylePosition());
2251         case CSSPropertyListStyleType:
2252             return cssValuePool().createValue(style->listStyleType());
2253         case CSSPropertyWebkitLocale:
2254             if (style->locale().isNull())
2255                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2256             return cssValuePool().createValue(style->locale(), CSSPrimitiveValue::CSS_STRING);
2257         case CSSPropertyMarginTop:
2258             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginTop, &RenderBoxModelObject::marginTop>(style.get(), renderer);
2259         case CSSPropertyMarginRight: {
2260             Length marginRight = style->marginRight();
2261             if (marginRight.isFixed() || !renderer || !renderer->isBox())
2262                 return zoomAdjustedPixelValueForLength(marginRight, style.get());
2263             float value;
2264             if (marginRight.isPercent() || marginRight.isViewportPercentage())
2265                 // RenderBox gives a marginRight() that is the distance between the right-edge of the child box
2266                 // and the right-edge of the containing box, when display == BLOCK. Let's calculate the absolute
2267                 // value of the specified margin-right % instead of relying on RenderBox's marginRight() value.
2268                 value = minimumValueForLength(marginRight, toRenderBox(renderer)->containingBlockLogicalWidthForContent(), m_node->document().renderView());
2269             else
2270                 value = toRenderBox(renderer)->marginRight();
2271             return zoomAdjustedPixelValue(value, style.get());
2272         }
2273         case CSSPropertyMarginBottom:
2274             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginBottom, &RenderBoxModelObject::marginBottom>(style.get(), renderer);
2275         case CSSPropertyMarginLeft:
2276             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginLeft, &RenderBoxModelObject::marginLeft>(style.get(), renderer);
2277         case CSSPropertyWebkitMarqueeDirection:
2278             return cssValuePool().createValue(style->marqueeDirection());
2279         case CSSPropertyWebkitMarqueeIncrement:
2280             return cssValuePool().createValue(style->marqueeIncrement());
2281         case CSSPropertyWebkitMarqueeRepetition:
2282             if (style->marqueeLoopCount() < 0)
2283                 return cssValuePool().createIdentifierValue(CSSValueInfinite);
2284             return cssValuePool().createValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
2285         case CSSPropertyWebkitMarqueeStyle:
2286             return cssValuePool().createValue(style->marqueeBehavior());
2287         case CSSPropertyWebkitUserModify:
2288             return cssValuePool().createValue(style->userModify());
2289         case CSSPropertyMaxHeight: {
2290             const Length& maxHeight = style->maxHeight();
2291             if (maxHeight.isUndefined())
2292                 return cssValuePool().createIdentifierValue(CSSValueNone);
2293             return zoomAdjustedPixelValueForLength(maxHeight, style.get());
2294         }
2295         case CSSPropertyMaxWidth: {
2296             const Length& maxWidth = style->maxWidth();
2297             if (maxWidth.isUndefined())
2298                 return cssValuePool().createIdentifierValue(CSSValueNone);
2299             return zoomAdjustedPixelValueForLength(maxWidth, style.get());
2300         }
2301         case CSSPropertyMinHeight:
2302             // FIXME: For flex-items, min-height:auto should compute to min-content.
2303             if (style->minHeight().isAuto())
2304                 return zoomAdjustedPixelValue(0, style.get());
2305             return zoomAdjustedPixelValueForLength(style->minHeight(), style.get());
2306         case CSSPropertyMinWidth:
2307             // FIXME: For flex-items, min-width:auto should compute to min-content.
2308             if (style->minWidth().isAuto())
2309                 return zoomAdjustedPixelValue(0, style.get());
2310             return zoomAdjustedPixelValueForLength(style->minWidth(), style.get());
2311         case CSSPropertyObjectFit:
2312             return cssValuePool().createValue(style->objectFit());
2313         case CSSPropertyOpacity:
2314             return cssValuePool().createValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
2315         case CSSPropertyOrphans:
2316             if (style->hasAutoOrphans())
2317                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2318             return cssValuePool().createValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
2319         case CSSPropertyOutlineColor:
2320             return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor());
2321         case CSSPropertyOutlineOffset:
2322             return zoomAdjustedPixelValue(style->outlineOffset(), style.get());
2323         case CSSPropertyOutlineStyle:
2324             if (style->outlineStyleIsAuto())
2325                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2326             return cssValuePool().createValue(style->outlineStyle());
2327         case CSSPropertyOutlineWidth:
2328             return zoomAdjustedPixelValue(style->outlineWidth(), style.get());
2329         case CSSPropertyOverflow:
2330             return cssValuePool().createValue(std::max(style->overflowX(), style->overflowY()));
2331         case CSSPropertyOverflowWrap:
2332             return cssValuePool().createValue(style->overflowWrap());
2333         case CSSPropertyOverflowX:
2334             return cssValuePool().createValue(style->overflowX());
2335         case CSSPropertyOverflowY:
2336             return cssValuePool().createValue(style->overflowY());
2337         case CSSPropertyPaddingTop:
2338             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingTop, &RenderBoxModelObject::computedCSSPaddingTop>(style.get(), renderer);
2339         case CSSPropertyPaddingRight:
2340             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingRight, &RenderBoxModelObject::computedCSSPaddingRight>(style.get(), renderer);
2341         case CSSPropertyPaddingBottom:
2342             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingBottom, &RenderBoxModelObject::computedCSSPaddingBottom>(style.get(), renderer);
2343         case CSSPropertyPaddingLeft:
2344             return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingLeft, &RenderBoxModelObject::computedCSSPaddingLeft>(style.get(), renderer);
2345         case CSSPropertyPageBreakAfter:
2346             return cssValuePool().createValue(style->pageBreakAfter());
2347         case CSSPropertyPageBreakBefore:
2348             return cssValuePool().createValue(style->pageBreakBefore());
2349         case CSSPropertyPageBreakInside: {
2350             EPageBreak pageBreak = style->pageBreakInside();
2351             ASSERT(pageBreak != PBALWAYS);
2352             if (pageBreak == PBALWAYS)
2353                 return 0;
2354             return cssValuePool().createValue(style->pageBreakInside());
2355         }
2356         case CSSPropertyPosition:
2357             return cssValuePool().createValue(style->position());
2358         case CSSPropertyRight:
2359             return getPositionOffsetValue(style.get(), CSSPropertyRight, m_node->document().renderView());
2360         case CSSPropertyWebkitRubyPosition:
2361             return cssValuePool().createValue(style->rubyPosition());
2362         case CSSPropertyTableLayout:
2363             return cssValuePool().createValue(style->tableLayout());
2364         case CSSPropertyTextAlign:
2365             return cssValuePool().createValue(style->textAlign());
2366         case CSSPropertyTextDecoration:
2367             return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2368 #if ENABLE(CSS3_TEXT)
2369         case CSSPropertyWebkitTextAlignLast:
2370             return cssValuePool().createValue(style->textAlignLast());
2371         case CSSPropertyWebkitTextJustify:
2372             return cssValuePool().createValue(style->textJustify());
2373 #endif // CSS3_TEXT
2374 #if ENABLE(CSS3_TEXT_DECORATION)
2375         case CSSPropertyWebkitTextDecoration:
2376             return getCSSPropertyValuesForShorthandProperties(webkitTextDecorationShorthand());
2377         case CSSPropertyWebkitTextDecorationLine:
2378             return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2379         case CSSPropertyWebkitTextDecorationStyle:
2380             return renderTextDecorationStyleFlagsToCSSValue(style->textDecorationStyle());
2381         case CSSPropertyWebkitTextDecorationColor:
2382             return currentColorOrValidColor(style.get(), style->textDecorationColor());
2383         case CSSPropertyWebkitTextDecorationSkip:
2384             return renderTextDecorationSkipFlagsToCSSValue(style->textDecorationSkip());
2385         case CSSPropertyWebkitTextUnderlinePosition:
2386             return cssValuePool().createValue(style->textUnderlinePosition());
2387 #endif
2388         case CSSPropertyWebkitTextDecorationsInEffect:
2389             return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect());
2390         case CSSPropertyWebkitTextFillColor:
2391             return currentColorOrValidColor(style.get(), style->textFillColor());
2392         case CSSPropertyWebkitTextEmphasisColor:
2393             return currentColorOrValidColor(style.get(), style->textEmphasisColor());
2394         case CSSPropertyWebkitTextEmphasisPosition:
2395             return cssValuePool().createValue(style->textEmphasisPosition());
2396         case CSSPropertyWebkitTextEmphasisStyle:
2397             switch (style->textEmphasisMark()) {
2398             case TextEmphasisMarkNone:
2399                 return cssValuePool().createIdentifierValue(CSSValueNone);
2400             case TextEmphasisMarkCustom:
2401                 return cssValuePool().createValue(style->textEmphasisCustomMark(), CSSPrimitiveValue::CSS_STRING);
2402             case TextEmphasisMarkAuto:
2403                 ASSERT_NOT_REACHED();
2404                 // Fall through
2405             case TextEmphasisMarkDot:
2406             case TextEmphasisMarkCircle:
2407             case TextEmphasisMarkDoubleCircle:
2408             case TextEmphasisMarkTriangle:
2409             case TextEmphasisMarkSesame: {
2410                 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2411                 list->append(cssValuePool().createValue(style->textEmphasisFill()));
2412                 list->append(cssValuePool().createValue(style->textEmphasisMark()));
2413                 return list.release();
2414             }
2415             }
2416         case CSSPropertyTextIndent: {
2417             // If CSS3_TEXT is disabled or text-indent has only one value(<length> | <percentage>),
2418             // getPropertyCSSValue() returns CSSValue.
2419             RefPtr<CSSValue> textIndent = zoomAdjustedPixelValueForLength(style->textIndent(), style.get());
2420 #if ENABLE(CSS3_TEXT)
2421             // If CSS3_TEXT is enabled and text-indent has -webkit-each-line or -webkit-hanging,
2422             // getPropertyCSSValue() returns CSSValueList.
2423             if (style->textIndentLine() == TextIndentEachLine || style->textIndentType() == TextIndentHanging) {
2424                 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2425                 list->append(textIndent.release());
2426                 if (style->textIndentLine() == TextIndentEachLine)
2427                     list->append(cssValuePool().createIdentifierValue(CSSValueWebkitEachLine));
2428                 if (style->textIndentType() == TextIndentHanging)
2429                     list->append(cssValuePool().createIdentifierValue(CSSValueWebkitHanging));
2430                 return list.release();
2431             }
2432 #endif
2433             return textIndent.release();
2434         }
2435         case CSSPropertyTextShadow:
2436             return valueForShadow(style->textShadow(), propertyID, style.get());
2437         case CSSPropertyTextRendering:
2438             return cssValuePool().createValue(style->fontDescription().textRenderingMode());
2439         case CSSPropertyTextOverflow:
2440             if (style->textOverflow())
2441                 return cssValuePool().createIdentifierValue(CSSValueEllipsis);
2442             return cssValuePool().createIdentifierValue(CSSValueClip);
2443         case CSSPropertyWebkitTextSecurity:
2444             return cssValuePool().createValue(style->textSecurity());
2445 #if ENABLE(IOS_TEXT_AUTOSIZING)
2446         case CSSPropertyWebkitTextSizeAdjust:
2447             if (style->textSizeAdjust().isAuto())
2448                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2449             if (style->textSizeAdjust().isNone())
2450                 return cssValuePool().createIdentifierValue(CSSValueNone);
2451             return CSSPrimitiveValue::create(style->textSizeAdjust().percentage(), CSSPrimitiveValue::CSS_PERCENTAGE);
2452 #endif
2453         case CSSPropertyWebkitTextStrokeColor:
2454             return currentColorOrValidColor(style.get(), style->textStrokeColor());
2455         case CSSPropertyWebkitTextStrokeWidth:
2456             return zoomAdjustedPixelValue(style->textStrokeWidth(), style.get());
2457         case CSSPropertyTextTransform:
2458             return cssValuePool().createValue(style->textTransform());
2459         case CSSPropertyTop:
2460             return getPositionOffsetValue(style.get(), CSSPropertyTop, m_node->document().renderView());
2461         case CSSPropertyUnicodeBidi:
2462             return cssValuePool().createValue(style->unicodeBidi());
2463         case CSSPropertyVerticalAlign:
2464             switch (style->verticalAlign()) {
2465                 case BASELINE:
2466                     return cssValuePool().createIdentifierValue(CSSValueBaseline);
2467                 case MIDDLE:
2468                     return cssValuePool().createIdentifierValue(CSSValueMiddle);
2469                 case SUB:
2470                     return cssValuePool().createIdentifierValue(CSSValueSub);
2471                 case SUPER:
2472                     return cssValuePool().createIdentifierValue(CSSValueSuper);
2473                 case TEXT_TOP:
2474                     return cssValuePool().createIdentifierValue(CSSValueTextTop);
2475                 case TEXT_BOTTOM:
2476                     return cssValuePool().createIdentifierValue(CSSValueTextBottom);
2477                 case TOP:
2478                     return cssValuePool().createIdentifierValue(CSSValueTop);
2479                 case BOTTOM:
2480                     return cssValuePool().createIdentifierValue(CSSValueBottom);
2481                 case BASELINE_MIDDLE:
2482                     return cssValuePool().createIdentifierValue(CSSValueWebkitBaselineMiddle);
2483                 case LENGTH:
2484                     return cssValuePool().createValue(style->verticalAlignLength());
2485             }
2486             ASSERT_NOT_REACHED();
2487             return 0;
2488         case CSSPropertyVisibility:
2489             return cssValuePool().createValue(style->visibility());
2490         case CSSPropertyWhiteSpace:
2491             return cssValuePool().createValue(style->whiteSpace());
2492         case CSSPropertyWidows:
2493             if (style->hasAutoWidows())
2494                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2495             return cssValuePool().createValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
2496         case CSSPropertyWidth:
2497             if (renderer) {
2498                 // According to http://www.w3.org/TR/CSS2/visudet.html#the-width-property,
2499                 // the "width" property does not apply for non-replaced inline elements.
2500                 if (!renderer->isReplaced() && renderer->isInline())
2501                     return cssValuePool().createIdentifierValue(CSSValueAuto);
2502                 return zoomAdjustedPixelValue(sizingBox(renderer).width(), style.get());
2503             }
2504             return zoomAdjustedPixelValueForLength(style->width(), style.get());
2505         case CSSPropertyWordBreak:
2506             return cssValuePool().createValue(style->wordBreak());
2507         case CSSPropertyWordSpacing:
2508             return zoomAdjustedPixelValue(style->wordSpacing(), style.get());
2509         case CSSPropertyWordWrap:
2510             return cssValuePool().createValue(style->overflowWrap());
2511         case CSSPropertyWebkitLineBreak:
2512             return cssValuePool().createValue(style->lineBreak());
2513         case CSSPropertyWebkitNbspMode:
2514             return cssValuePool().createValue(style->nbspMode());
2515         case CSSPropertyResize:
2516             return cssValuePool().createValue(style->resize());
2517         case CSSPropertyWebkitFontKerning:
2518             return cssValuePool().createValue(style->fontDescription().kerning());
2519         case CSSPropertyWebkitFontSmoothing:
2520             return cssValuePool().createValue(style->fontDescription().fontSmoothing());
2521         case CSSPropertyWebkitFontVariantLigatures: {
2522             FontDescription::LigaturesState commonLigaturesState = style->fontDescription().commonLigaturesState();
2523             FontDescription::LigaturesState discretionaryLigaturesState = style->fontDescription().discretionaryLigaturesState();
2524             FontDescription::LigaturesState historicalLigaturesState = style->fontDescription().historicalLigaturesState();
2525             if (commonLigaturesState == FontDescription::NormalLigaturesState && discretionaryLigaturesState == FontDescription::NormalLigaturesState
2526                 && historicalLigaturesState == FontDescription::NormalLigaturesState)
2527                 return cssValuePool().createIdentifierValue(CSSValueNormal);
2528
2529             RefPtr<CSSValueList> valueList = CSSValueList::createSpaceSeparated();
2530             if (commonLigaturesState != FontDescription::NormalLigaturesState)
2531                 valueList->append(cssValuePool().createIdentifierValue(commonLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoCommonLigatures : CSSValueCommonLigatures));
2532             if (discretionaryLigaturesState != FontDescription::NormalLigaturesState)
2533                 valueList->append(cssValuePool().createIdentifierValue(discretionaryLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoDiscretionaryLigatures : CSSValueDiscretionaryLigatures));
2534             if (historicalLigaturesState != FontDescription::NormalLigaturesState)
2535                 valueList->append(cssValuePool().createIdentifierValue(historicalLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoHistoricalLigatures : CSSValueHistoricalLigatures));
2536             return valueList;
2537         }
2538         case CSSPropertyZIndex:
2539             if (style->hasAutoZIndex())
2540                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2541             return cssValuePool().createValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
2542         case CSSPropertyZoom:
2543             return cssValuePool().createValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
2544         case CSSPropertyBoxSizing:
2545             if (style->boxSizing() == CONTENT_BOX)
2546                 return cssValuePool().createIdentifierValue(CSSValueContentBox);
2547             return cssValuePool().createIdentifierValue(CSSValueBorderBox);
2548 #if ENABLE(DASHBOARD_SUPPORT)
2549         case CSSPropertyWebkitDashboardRegion:
2550         {
2551             const Vector<StyleDashboardRegion>& regions = style->dashboardRegions();
2552             unsigned count = regions.size();
2553             if (count == 1 && regions[0].type == StyleDashboardRegion::None)
2554                 return cssValuePool().createIdentifierValue(CSSValueNone);
2555
2556             RefPtr<DashboardRegion> firstRegion;
2557             DashboardRegion* previousRegion = 0;
2558             for (unsigned i = 0; i < count; i++) {
2559                 RefPtr<DashboardRegion> region = DashboardRegion::create();
2560                 StyleDashboardRegion styleRegion = regions[i];
2561
2562                 region->m_label = styleRegion.label;
2563                 LengthBox offset = styleRegion.offset;
2564                 region->setTop(zoomAdjustedPixelValue(offset.top().value(), style.get()));
2565                 region->setRight(zoomAdjustedPixelValue(offset.right().value(), style.get()));
2566                 region->setBottom(zoomAdjustedPixelValue(offset.bottom().value(), style.get()));
2567                 region->setLeft(zoomAdjustedPixelValue(offset.left().value(), style.get()));
2568                 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
2569                 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
2570
2571                 if (previousRegion)
2572                     previousRegion->m_next = region;
2573                 else
2574                     firstRegion = region;
2575                 previousRegion = region.get();
2576             }
2577             return cssValuePool().createValue(firstRegion.release());
2578         }
2579 #endif
2580 #if ENABLE(DRAGGABLE_REGION)
2581         case CSSPropertyWebkitAppRegion:
2582             return cssValuePool().createIdentifierValue(style->getDraggableRegionMode() == DraggableRegionDrag ? CSSValueDrag : CSSValueNoDrag);
2583 #endif
2584         case CSSPropertyWebkitAnimationDelay:
2585             return getDelayValue(style->animations());
2586         case CSSPropertyWebkitAnimationDirection: {
2587             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2588             const AnimationList* t = style->animations();
2589             if (t) {
2590                 for (size_t i = 0; i < t->size(); ++i) {
2591                     if (t->animation(i).direction())
2592                         list->append(cssValuePool().createIdentifierValue(CSSValueAlternate));
2593                     else
2594                         list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2595                 }
2596             } else
2597                 list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2598             return list.release();
2599         }
2600         case CSSPropertyWebkitAnimationDuration:
2601             return getDurationValue(style->animations());
2602         case CSSPropertyWebkitAnimationFillMode: {
2603             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2604             const AnimationList* t = style->animations();
2605             if (t) {
2606                 for (size_t i = 0; i < t->size(); ++i) {
2607                     switch (t->animation(i).fillMode()) {
2608                     case AnimationFillModeNone:
2609                         list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2610                         break;
2611                     case AnimationFillModeForwards:
2612                         list->append(cssValuePool().createIdentifierValue(CSSValueForwards));
2613                         break;
2614                     case AnimationFillModeBackwards:
2615                         list->append(cssValuePool().createIdentifierValue(CSSValueBackwards));
2616                         break;
2617                     case AnimationFillModeBoth:
2618                         list->append(cssValuePool().createIdentifierValue(CSSValueBoth));
2619                         break;
2620                     }
2621                 }
2622             } else
2623                 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2624             return list.release();
2625         }
2626         case CSSPropertyWebkitAnimationIterationCount: {
2627             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2628             const AnimationList* t = style->animations();
2629             if (t) {
2630                 for (size_t i = 0; i < t->size(); ++i) {
2631                     double iterationCount = t->animation(i).iterationCount();
2632                     if (iterationCount == Animation::IterationCountInfinite)
2633                         list->append(cssValuePool().createIdentifierValue(CSSValueInfinite));
2634                     else
2635                         list->append(cssValuePool().createValue(iterationCount, CSSPrimitiveValue::CSS_NUMBER));
2636                 }
2637             } else
2638                 list->append(cssValuePool().createValue(Animation::initialAnimationIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
2639             return list.release();
2640         }
2641         case CSSPropertyWebkitAnimationName: {
2642             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2643             const AnimationList* t = style->animations();
2644             if (t) {
2645                 for (size_t i = 0; i < t->size(); ++i)
2646                     list->append(cssValuePool().createValue(t->animation(i).name(), CSSPrimitiveValue::CSS_STRING));
2647             } else
2648                 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2649             return list.release();
2650         }
2651         case CSSPropertyWebkitAnimationPlayState: {
2652             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2653             const AnimationList* t = style->animations();
2654             if (t) {
2655                 for (size_t i = 0; i < t->size(); ++i) {
2656                     int prop = t->animation(i).playState();
2657                     if (prop == AnimPlayStatePlaying)
2658                         list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2659                     else
2660                         list->append(cssValuePool().createIdentifierValue(CSSValuePaused));
2661                 }
2662             } else
2663                 list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2664             return list.release();
2665         }
2666         case CSSPropertyWebkitAnimationTimingFunction:
2667             return getTimingFunctionValue(style->animations());
2668         case CSSPropertyWebkitAppearance:
2669             return cssValuePool().createValue(style->appearance());
2670         case CSSPropertyWebkitAspectRatio:
2671             if (!style->hasAspectRatio())
2672                 return cssValuePool().createIdentifierValue(CSSValueNone);
2673             return CSSAspectRatioValue::create(style->aspectRatioNumerator(), style->aspectRatioDenominator());
2674         case CSSPropertyWebkitBackfaceVisibility:
2675             return cssValuePool().createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
2676         case CSSPropertyWebkitBorderImage:
2677             return valueForNinePieceImage(style->borderImage());
2678         case CSSPropertyBorderImageOutset:
2679             return valueForNinePieceImageQuad(style->borderImage().outset());
2680         case CSSPropertyBorderImageRepeat:
2681             return valueForNinePieceImageRepeat(style->borderImage());
2682         case CSSPropertyBorderImageSlice:
2683             return valueForNinePieceImageSlice(style->borderImage());
2684         case CSSPropertyBorderImageWidth:
2685             return valueForNinePieceImageQuad(style->borderImage().borderSlices());
2686         case CSSPropertyWebkitMaskBoxImage:
2687             return valueForNinePieceImage(style->maskBoxImage());
2688         case CSSPropertyWebkitMaskBoxImageOutset:
2689             return valueForNinePieceImageQuad(style->maskBoxImage().outset());
2690         case CSSPropertyWebkitMaskBoxImageRepeat:
2691             return valueForNinePieceImageRepeat(style->maskBoxImage());
2692         case CSSPropertyWebkitMaskBoxImageSlice:
2693             return valueForNinePieceImageSlice(style->maskBoxImage());
2694         case CSSPropertyWebkitMaskBoxImageWidth:
2695             return valueForNinePieceImageQuad(style->maskBoxImage().borderSlices());
2696         case CSSPropertyWebkitMaskBoxImageSource:
2697             if (style->maskBoxImageSource())
2698                 return style->maskBoxImageSource()->cssValue();
2699             return cssValuePool().createIdentifierValue(CSSValueNone);
2700         case CSSPropertyWebkitFontSizeDelta:
2701             // Not a real style property -- used by the editing engine -- so has no computed value.
2702             break;
2703         case CSSPropertyWebkitMarginBottomCollapse:
2704         case CSSPropertyWebkitMarginAfterCollapse:
2705             return cssValuePool().createValue(style->marginAfterCollapse());
2706         case CSSPropertyWebkitMarginTopCollapse:
2707         case CSSPropertyWebkitMarginBeforeCollapse:
2708             return cssValuePool().createValue(style->marginBeforeCollapse());
2709 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
2710         case CSSPropertyWebkitOverflowScrolling:
2711             if (!style->useTouchOverflowScrolling())
2712                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2713             return cssValuePool().createIdentifierValue(CSSValueTouch);
2714 #endif
2715         case CSSPropertyWebkitPerspective:
2716             if (!style->hasPerspective())
2717                 return cssValuePool().createIdentifierValue(CSSValueNone);
2718             return zoomAdjustedPixelValue(style->perspective(), style.get());
2719         case CSSPropertyWebkitPerspectiveOrigin: {
2720             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2721             if (renderer) {
2722                 LayoutRect box;
2723                 if (renderer->isBox())
2724                     box = toRenderBox(renderer)->borderBoxRect();
2725
2726                 RenderView* renderView = m_node->document().renderView();
2727                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginX(), box.width(), renderView), style.get()));
2728                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginY(), box.height(), renderView), style.get()));
2729             }
2730             else {
2731                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginX(), style.get()));
2732                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginY(), style.get()));
2733
2734             }
2735             return list.release();
2736         }
2737         case CSSPropertyWebkitRtlOrdering:
2738             return cssValuePool().createIdentifierValue(style->rtlOrdering() ? CSSValueVisual : CSSValueLogical);
2739 #if ENABLE(TOUCH_EVENTS)
2740         case CSSPropertyWebkitTapHighlightColor:
2741             return currentColorOrValidColor(style.get(), style->tapHighlightColor());
2742 #endif
2743 #if PLATFORM(IOS)
2744         case CSSPropertyWebkitTouchCallout:
2745             return cssValuePool().createIdentifierValue(style->touchCalloutEnabled() ? CSSValueDefault : CSSValueNone);
2746 #endif
2747         case CSSPropertyWebkitUserDrag:
2748             return cssValuePool().createValue(style->userDrag());
2749         case CSSPropertyWebkitUserSelect:
2750             return cssValuePool().createValue(style->userSelect());
2751         case CSSPropertyBorderBottomLeftRadius:
2752             return getBorderRadiusCornerValue(style->borderBottomLeftRadius(), style.get(), m_node->document().renderView());
2753         case CSSPropertyBorderBottomRightRadius:
2754             return getBorderRadiusCornerValue(style->borderBottomRightRadius(), style.get(), m_node->document().renderView());
2755         case CSSPropertyBorderTopLeftRadius:
2756             return getBorderRadiusCornerValue(style->borderTopLeftRadius(), style.get(), m_node->document().renderView());
2757         case CSSPropertyBorderTopRightRadius:
2758             return getBorderRadiusCornerValue(style->borderTopRightRadius(), style.get(), m_node->document().renderView());
2759         case CSSPropertyClip: {
2760             if (!style->hasClip())
2761                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2762             RefPtr<Rect> rect = Rect::create();
2763             rect->setTop(zoomAdjustedPixelValue(style->clip().top().value(), style.get()));
2764             rect->setRight(zoomAdjustedPixelValue(style->clip().right().value(), style.get()));
2765             rect->setBottom(zoomAdjustedPixelValue(style->clip().bottom().value(), style.get()));
2766             rect->setLeft(zoomAdjustedPixelValue(style->clip().left().value(), style.get()));
2767             return cssValuePool().createValue(rect.release());
2768         }
2769         case CSSPropertySpeak:
2770             return cssValuePool().createValue(style->speak());
2771         case CSSPropertyWebkitTransform:
2772             return computedTransform(renderer, style.get());
2773         case CSSPropertyWebkitTransformOrigin: {
2774             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2775             if (renderer) {
2776                 LayoutRect box;
2777                 if (renderer->isBox())
2778                     box = toRenderBox(renderer)->borderBoxRect();
2779
2780                 RenderView* renderView = m_node->document().renderView();
2781                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginX(), box.width(), renderView), style.get()));
2782                 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginY(), box.height(), renderView), style.get()));
2783                 if (style->transformOriginZ() != 0)
2784                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2785             } else {
2786                 list->append(zoomAdjustedPixelValueForLength(style->transformOriginX(), style.get()));
2787                 list->append(zoomAdjustedPixelValueForLength(style->transformOriginY(), style.get()));
2788                 if (style->transformOriginZ() != 0)
2789                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2790             }
2791             return list.release();
2792         }
2793         case CSSPropertyWebkitTransformStyle:
2794             return cssValuePool().createIdentifierValue((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat);
2795         case CSSPropertyTransitionDelay:
2796         case CSSPropertyWebkitTransitionDelay:
2797             return getDelayValue(style->transitions());
2798         case CSSPropertyTransitionDuration:
2799         case CSSPropertyWebkitTransitionDuration:
2800             return getDurationValue(style->transitions());
2801         case CSSPropertyTransitionProperty:
2802         case CSSPropertyWebkitTransitionProperty:
2803             return getTransitionPropertyValue(style->transitions());
2804         case CSSPropertyTransitionTimingFunction:
2805         case CSSPropertyWebkitTransitionTimingFunction:
2806             return getTimingFunctionValue(style->transitions());
2807         case CSSPropertyTransition:
2808         case CSSPropertyWebkitTransition: {
2809             const AnimationList* animList = style->transitions();
2810             if (animList) {
2811                 RefPtr<CSSValueList> transitionsList = CSSValueList::createCommaSeparated();
2812                 for (size_t i = 0; i < animList->size(); ++i) {
2813                     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2814                     const Animation& animation = animList->animation(i);
2815                     list->append(createTransitionPropertyValue(animation));
2816                     list->append(cssValuePool().createValue(animation.duration(), CSSPrimitiveValue::CSS_S));
2817                     list->append(createTimingFunctionValue(animation.timingFunction().get()));
2818                     list->append(cssValuePool().createValue(animation.delay(), CSSPrimitiveValue::CSS_S));
2819                     transitionsList->append(list);
2820                 }
2821                 return transitionsList.release();
2822             }
2823
2824             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2825             // transition-property default value.
2826             list->append(cssValuePool().createIdentifierValue(CSSValueAll));
2827             list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
2828             list->append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
2829             list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
2830             return list.release();
2831         }
2832         case CSSPropertyPointerEvents:
2833             return cssValuePool().createValue(style->pointerEvents());
2834         case CSSPropertyWebkitColorCorrection:
2835             return cssValuePool().createValue(style->colorSpace());
2836         case CSSPropertyWebkitLineGrid:
2837             if (style->lineGrid().isNull())
2838                 return cssValuePool().createIdentifierValue(CSSValueNone);
2839             return cssValuePool().createValue(style->lineGrid(), CSSPrimitiveValue::CSS_STRING);
2840         case CSSPropertyWebkitLineSnap:
2841             return CSSPrimitiveValue::create(style->lineSnap());
2842         case CSSPropertyWebkitLineAlign:
2843             return CSSPrimitiveValue::create(style->lineAlign());
2844         case CSSPropertyWebkitWritingMode:
2845             return cssValuePool().createValue(style->writingMode());
2846         case CSSPropertyWebkitTextCombine:
2847             return cssValuePool().createValue(style->textCombine());
2848         case CSSPropertyWebkitTextOrientation:
2849             return CSSPrimitiveValue::create(style->textOrientation());
2850         case CSSPropertyWebkitLineBoxContain:
2851             return createLineBoxContainValue(style->lineBoxContain());
2852         case CSSPropertyWebkitAlt:
2853             return altTextToCSSValue(style.get());
2854         case CSSPropertyContent:
2855             return contentToCSSValue(style.get());
2856         case CSSPropertyCounterIncrement:
2857             return counterToCSSValue(style.get(), propertyID);
2858         case CSSPropertyCounterReset:
2859             return counterToCSSValue(style.get(), propertyID);
2860         case CSSPropertyWebkitClipPath:
2861             if (ClipPathOperation* operation = style->clipPath()) {
2862                 if (operation->type() == ClipPathOperation::SHAPE)
2863                     return valueForBasicShape(style.get(), static_cast<ShapeClipPathOperation*>(operation)->basicShape());
2864 #if ENABLE(SVG)
2865                 if (operation->type() == ClipPathOperation::REFERENCE) {
2866                     ReferenceClipPathOperation* referenceOperation = static_cast<ReferenceClipPathOperation*>(operation);
2867                     return CSSPrimitiveValue::create(referenceOperation->url(), CSSPrimitiveValue::CSS_URI);
2868                 }
2869 #endif
2870             }
2871             return cssValuePool().createIdentifierValue(CSSValueNone);
2872 #if ENABLE(CSS_REGIONS)
2873         case CSSPropertyWebkitFlowInto:
2874             if (style->flowThread().isNull())
2875                 return cssValuePool().createIdentifierValue(CSSValueNone);
2876             return cssValuePool().createValue(style->flowThread(), CSSPrimitiveValue::CSS_STRING);
2877         case CSSPropertyWebkitFlowFrom:
2878             if (!style->hasFlowFrom())
2879                 return cssValuePool().createIdentifierValue(CSSValueNone);
2880             return cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING);
2881         case CSSPropertyWebkitRegionFragment:
2882             return cssValuePool().createValue(style->regionFragment());
2883 #endif
2884 #if ENABLE(CSS_EXCLUSIONS)
2885         case CSSPropertyWebkitWrapFlow:
2886             return cssValuePool().createValue(style->wrapFlow());
2887         case CSSPropertyWebkitWrapThrough:
2888             return cssValuePool().createValue(style->wrapThrough());
2889 #endif
2890 #if ENABLE(CSS_SHAPES)
2891         case CSSPropertyWebkitShapeMargin:
2892             return cssValuePool().createValue(style->shapeMargin());
2893         case CSSPropertyWebkitShapePadding:
2894             return cssValuePool().createValue(style->shapePadding());
2895         case CSSPropertyWebkitShapeImageThreshold:
2896             return cssValuePool().createValue(style->shapeImageThreshold(), CSSPrimitiveValue::CSS_NUMBER);
2897         case CSSPropertyWebkitShapeInside:
2898             if (!style->shapeInside())
2899                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2900             if (style->shapeInside()->type() == ShapeValue::Box)
2901                 return valueForBox(style->shapeInside()->box());
2902             if (style->shapeInside()->type() == ShapeValue::Outside)
2903                 return cssValuePool().createIdentifierValue(CSSValueOutsideShape);
2904             if (style->shapeInside()->type() == ShapeValue::Image) {
2905                 if (style->shapeInside()->image())
2906                     return style->shapeInside()->image()->cssValue();
2907                 return cssValuePool().createIdentifierValue(CSSValueNone);
2908             }
2909             ASSERT(style->shapeInside()->type() == ShapeValue::Shape);
2910             return valueForBasicShape(style.get(), style->shapeInside()->shape());
2911         case CSSPropertyWebkitShapeOutside:
2912             if (!style->shapeOutside())
2913                 return cssValuePool().createIdentifierValue(CSSValueAuto);
2914             if (style->shapeOutside()->type() == ShapeValue::Box)
2915                 return valueForBox(style->shapeOutside()->box());
2916             if (style->shapeOutside()->type() == ShapeValue::Image) {
2917                 if (style->shapeOutside()->image())
2918                     return style->shapeOutside()->image()->cssValue();
2919                 return cssValuePool().createIdentifierValue(CSSValueNone);
2920             }
2921             ASSERT(style->shapeOutside()->type() == ShapeValue::Shape);
2922             return valueForBasicShape(style.get(), style->shapeOutside()->shape());
2923 #endif
2924 #if ENABLE(CSS_FILTERS)
2925         case CSSPropertyWebkitFilter:
2926             return valueForFilter(renderer, style.get(), style->filter());
2927 #endif
2928 #if ENABLE(CSS_COMPOSITING)
2929         case CSSPropertyWebkitBlendMode:
2930             return cssValuePool().createValue(style->blendMode());
2931 #endif
2932         case CSSPropertyWebkitBackgroundBlendMode: {
2933             const FillLayer* layers = style->backgroundLayers();
2934             if (!layers->next())
2935                 return cssValuePool().createValue(layers->blendMode());
2936
2937             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2938             for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
2939                 list->append(cssValuePool().createValue(currLayer->blendMode()));
2940
2941             return list.release();
2942         }
2943         case CSSPropertyBackground:
2944             return getBackgroundShorthandValue();
2945         case CSSPropertyBorder: {
2946             RefPtr<CSSValue> value = propertyValue(CSSPropertyBorderTop, DoNotUpdateLayout);
2947             const CSSPropertyID properties[3] = { CSSPropertyBorderRight, CSSPropertyBorderBottom,
2948                                         CSSPropertyBorderLeft };
2949             for (size_t i = 0; i < WTF_ARRAY_LENGTH(properties); ++i) {
2950                 if (!compareCSSValuePtr<CSSValue>(value, propertyValue(properties[i], DoNotUpdateLayout)))
2951                     return 0;
2952             }
2953             return value.release();
2954         }
2955         case CSSPropertyBorderBottom:
2956             return getCSSPropertyValuesForShorthandProperties(borderBottomShorthand());
2957         case CSSPropertyBorderColor:
2958             return getCSSPropertyValuesForSidesShorthand(borderColorShorthand());
2959         case CSSPropertyBorderLeft:
2960             return getCSSPropertyValuesForShorthandProperties(borderLeftShorthand());
2961         case CSSPropertyBorderImage:
2962             return valueForNinePieceImage(style->borderImage());
2963         case CSSPropertyBorderRadius:
2964             return getBorderRadiusShorthandValue(style.get(), m_node->document().renderView());
2965         case CSSPropertyBorderRight:
2966             return getCSSPropertyValuesForShorthandProperties(borderRightShorthand());
2967         case CSSPropertyBorderStyle:
2968             return getCSSPropertyValuesForSidesShorthand(borderStyleShorthand());
2969         case CSSPropertyBorderTop:
2970             return getCSSPropertyValuesForShorthandProperties(borderTopShorthand());
2971         case CSSPropertyBorderWidth:
2972             return getCSSPropertyValuesForSidesShorthand(borderWidthShorthand());
2973         case CSSPropertyWebkitColumnRule:
2974             return getCSSPropertyValuesForShorthandProperties(webkitColumnRuleShorthand());
2975         case CSSPropertyWebkitColumns:
2976             return getCSSPropertyValuesForShorthandProperties(webkitColumnsShorthand());
2977         case CSSPropertyListStyle:
2978             return getCSSPropertyValuesForShorthandProperties(listStyleShorthand());
2979         case CSSPropertyMargin:
2980             return getCSSPropertyValuesForSidesShorthand(marginShorthand());
2981         case CSSPropertyOutline:
2982             return getCSSPropertyValuesForShorthandProperties(outlineShorthand());
2983         case CSSPropertyPadding:
2984             return getCSSPropertyValuesForSidesShorthand(paddingShorthand());
2985         /* Individual properties not part of the spec */
2986         case CSSPropertyBackgroundRepeatX:
2987         case CSSPropertyBackgroundRepeatY:
2988             break;
2989
2990         /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
2991         case CSSPropertyWebkitTextEmphasis:
2992         case CSSPropertyTextLineThrough:
2993         case CSSPropertyTextLineThroughColor:
2994         case CSSPropertyTextLineThroughMode:
2995         case CSSPropertyTextLineThroughStyle:
2996         case CSSPropertyTextLineThroughWidth:
2997         case CSSPropertyTextOverline:
2998         case CSSPropertyTextOverlineColor:
2999         case CSSPropertyTextOverlineMode:
3000         case CSSPropertyTextOverlineStyle:
3001         case CSSPropertyTextOverlineWidth:
3002         case CSSPropertyTextUnderline:
3003         case CSSPropertyTextUnderlineColor:
3004         case CSSPropertyTextUnderlineMode:
3005         case CSSPropertyTextUnderlineStyle:
3006         case CSSPropertyTextUnderlineWidth:
3007             break;
3008
3009         /* Directional properties are resolved by resolveDirectionAwareProperty() before the switch. */
3010         case CSSPropertyWebkitBorderEnd:
3011         case CSSPropertyWebkitBorderEndColor:
3012         case CSSPropertyWebkitBorderEndStyle:
3013         case CSSPropertyWebkitBorderEndWidth:
3014         case CSSPropertyWebkitBorderStart:
3015         case CSSPropertyWebkitBorderStartColor:
3016         case CSSPropertyWebkitBorderStartStyle:
3017         case CSSPropertyWebkitBorderStartWidth:
3018         case CSSPropertyWebkitBorderAfter:
3019         case CSSPropertyWebkitBorderAfterColor:
3020         case CSSPropertyWebkitBorderAfterStyle:
3021         case CSSPropertyWebkitBorderAfterWidth:
3022         case CSSPropertyWebkitBorderBefore:
3023         case CSSPropertyWebkitBorderBeforeColor:
3024         case CSSPropertyWebkitBorderBeforeStyle:
3025         case CSSPropertyWebkitBorderBeforeWidth:
3026         case CSSPropertyWebkitMarginEnd:
3027         case CSSPropertyWebkitMarginStart:
3028         case CSSPropertyWebkitMarginAfter:
3029         case CSSPropertyWebkitMarginBefore:
3030         case CSSPropertyWebkitPaddingEnd:
3031         case CSSPropertyWebkitPaddingStart:
3032         case CSSPropertyWebkitPaddingAfter:
3033         case CSSPropertyWebkitPaddingBefore:
3034         case CSSPropertyWebkitLogicalWidth:
3035         case CSSPropertyWebkitLogicalHeight:
3036         case CSSPropertyWebkitMinLogicalWidth:
3037         case CSSPropertyWebkitMinLogicalHeight:
3038         case CSSPropertyWebkitMaxLogicalWidth:
3039         case CSSPropertyWebkitMaxLogicalHeight:
3040             ASSERT_NOT_REACHED();
3041             break;
3042
3043         /* Unimplemented @font-face properties */
3044         case CSSPropertyFontStretch:
3045         case CSSPropertySrc:
3046         case CSSPropertyUnicodeRange:
3047             break;
3048
3049         /* Other unimplemented properties */
3050 #if ENABLE(CSS_SHADERS)
3051         case CSSPropertyGeometry:
3052 #endif
3053         case CSSPropertyPage: // for @page
3054         case CSSPropertyQuotes: // FIXME: needs implementation
3055         case CSSPropertySize: // for @page
3056             break;
3057
3058         /* Unimplemented -webkit- properties */
3059         case CSSPropertyWebkitAnimation:
3060         case CSSPropertyWebkitBorderRadius:
3061         case CSSPropertyWebkitMarginCollapse:
3062         case CSSPropertyWebkitMarquee:
3063         case CSSPropertyWebkitMarqueeSpeed:
3064         case CSSPropertyWebkitMask:
3065         case CSSPropertyWebkitMaskRepeatX:
3066         case CSSPropertyWebkitMaskRepeatY:
3067         case CSSPropertyWebkitPerspectiveOriginX:
3068         case CSSPropertyWebkitPerspectiveOriginY:
3069         case CSSPropertyWebkitTextStroke:
3070         case CSSPropertyWebkitTransformOriginX:
3071         case CSSPropertyWebkitTransformOriginY:
3072         case CSSPropertyWebkitTransformOriginZ:
3073 #if ENABLE(CSS_SHADERS)
3074         case CSSPropertyMix:
3075         case CSSPropertyParameters:
3076 #endif
3077             break;
3078
3079 #if ENABLE(CSS_DEVICE_ADAPTATION)
3080         case CSSPropertyMaxZoom:
3081         case CSSPropertyMinZoom:
3082         case CSSPropertyOrientation:
3083         case CSSPropertyUserZoom:
3084             break;
3085 #endif
3086
3087 #if ENABLE(SVG)
3088         case CSSPropertyBufferedRendering:
3089         case CSSPropertyClipPath:
3090         case CSSPropertyClipRule:
3091         case CSSPropertyMask:
3092         case CSSPropertyEnableBackground:
3093         case CSSPropertyFilter:
3094         case CSSPropertyFloodColor:
3095         case CSSPropertyFloodOpacity:
3096         case CSSPropertyLightingColor:
3097         case CSSPropertyStopColor:
3098         case CSSPropertyStopOpacity:
3099         case CSSPropertyColorInterpolation:
3100         case CSSPropertyColorInterpolationFilters:
3101         case CSSPropertyColorProfile:
3102         case CSSPropertyColorRendering:
3103         case CSSPropertyFill:
3104         case CSSPropertyFillOpacity:
3105         case CSSPropertyFillRule:
3106         case CSSPropertyMarker:
3107         case CSSPropertyMarkerEnd:
3108         case CSSPropertyMarkerMid:
3109         case CSSPropertyMarkerStart:
3110         case CSSPropertyMaskType:
3111         case CSSPropertyShapeRendering:
3112         case CSSPropertyStroke:
3113         case CSSPropertyStrokeDasharray:
3114         case CSSPropertyStrokeDashoffset:
3115         case CSSPropertyStrokeLinecap:
3116         case CSSPropertyStrokeLinejoin:
3117         case CSSPropertyStrokeMiterlimit:
3118         case CSSPropertyStrokeOpacity:
3119         case CSSPropertyStrokeWidth:
3120         case CSSPropertyAlignmentBaseline:
3121         case CSSPropertyBaselineShift:
3122         case CSSPropertyDominantBaseline:
3123         case CSSPropertyGlyphOrientationHorizontal:
3124         case CSSPropertyGlyphOrientationVertical:
3125         case CSSPropertyKerning:
3126         case CSSPropertyTextAnchor:
3127         case CSSPropertyVectorEffect:
3128         case CSSPropertyWritingMode:
3129         case CSSPropertyWebkitSvgShadow:
3130             return svgPropertyValue(propertyID, DoNotUpdateLayout);
3131 #endif
3132     }
3133
3134     logUnimplementedPropertyID(propertyID);
3135     return 0;
3136 }
3137
3138 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) const
3139 {
3140     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
3141     if (value)
3142         return value->cssText();
3143     return "";
3144 }
3145
3146 unsigned CSSComputedStyleDeclaration::length() const
3147 {
3148     Node* node = m_node.get();
3149     if (!node)
3150         return 0;
3151
3152     RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier);
3153     if (!style)
3154         return 0;
3155
3156     return numComputedProperties;
3157 }
3158
3159 String CSSComputedStyleDeclaration::item(unsigned i) const
3160 {
3161     if (i >= length())
3162         return "";
3163
3164     return getPropertyNameString(computedProperties[i]);
3165 }
3166
3167 bool ComputedStyleExtractor::propertyMatches(CSSPropertyID propertyID, const CSSValue* value) const
3168 {
3169     if (propertyID == CSSPropertyFontSize && value->isPrimitiveValue() && m_node) {
3170         m_node->document().updateLayoutIgnorePendingStylesheets();
3171         RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier);
3172         if (style && style->fontDescription().keywordSize()) {
3173             CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize());
3174             const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
3175             if (primitiveValue->isValueID() && primitiveValue->getValueID() == sizeValue)
3176                 return true;
3177         }
3178     }
3179     RefPtr<CSSValue> computedValue = propertyValue(propertyID);
3180     return computedValue && value && computedValue->equals(*value);
3181 }
3182
3183 PassRef<MutableStyleProperties> ComputedStyleExtractor::copyProperties() const
3184 {
3185     return copyPropertiesInSet(computedProperties, numComputedProperties);
3186 }
3187
3188 PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand& shorthand) const
3189 {
3190     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
3191     for (size_t i = 0; i < shorthand.length(); ++i) {
3192         RefPtr<CSSValue> value = propertyValue(shorthand.properties()[i], DoNotUpdateLayout);
3193         list->append(value);
3194     }
3195     return list.release();
3196 }
3197
3198 PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand& shorthand) const
3199 {
3200     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
3201     // Assume the properties are in the usual order top, right, bottom, left.
3202     RefPtr<CSSValue> topValue = propertyValue(shorthand.properties()[0], DoNotUpdateLayout);
3203     RefPtr<CSSValue> rightValue = propertyValue(shorthand.properties()[1], DoNotUpdateLayout);
3204     RefPtr<CSSValue> bottomValue = propertyValue(shorthand.properties()[2], DoNotUpdateLayout);
3205     RefPtr<CSSValue> leftValue = propertyValue(shorthand.properties()[3], DoNotUpdateLayout);
3206
3207     // All 4 properties must be specified.
3208     if (!topValue || !rightValue || !bottomValue || !leftValue)
3209         return 0;
3210
3211     bool showLeft = !compareCSSValuePtr(rightValue, leftValue);
3212     bool showBottom = !compareCSSValuePtr(topValue, bottomValue) || showLeft;
3213     bool showRight = !compareCSSValuePtr(topValue, rightValue) || showBottom;
3214
3215     list->append(topValue.release());
3216     if (showRight)
3217         list->append(rightValue.release());
3218     if (showBottom)
3219         list->append(bottomValue.release());
3220     if (showLeft)
3221         list->append(leftValue.release());
3222
3223     return list.release();
3224 }
3225
3226 PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForGridShorthand(const StylePropertyShorthand& shorthand) const
3227 {
3228     RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3229     for (size_t i = 0; i < shorthand.length(); ++i) {
3230         RefPtr<CSSValue> value = propertyValue(shorthand.properties()[i], DoNotUpdateLayout);
3231         list->append(value.release());
3232     }
3233     return list.release();
3234 }
3235
3236 PassRef<MutableStyleProperties> ComputedStyleExtractor::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const
3237 {
3238     Vector<CSSProperty, 256> list;
3239     list.reserveInitialCapacity(length);
3240     for (unsigned i = 0; i < length; ++i) {
3241         RefPtr<CSSValue> value = propertyValue(set[i]);
3242         if (value)
3243             list.append(CSSProperty(set[i], value.release(), false));
3244     }
3245     return MutableStyleProperties::create(list.data(), list.size());
3246 }
3247
3248 CSSRule* CSSComputedStyleDeclaration::parentRule() const
3249 {
3250     return 0;
3251 }
3252
3253 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(const String& propertyName)
3254 {
3255     CSSPropertyID propertyID = cssPropertyID(propertyName);
3256     if (!propertyID)
3257         return 0;
3258     RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
3259     return value ? value->cloneForCSSOM() : 0;
3260 }
3261
3262 String CSSComputedStyleDeclaration::getPropertyValue(const String &propertyName)
3263 {
3264     CSSPropertyID propertyID = cssPropertyID(propertyName);
3265     if (!propertyID)
3266         return String();
3267     return getPropertyValue(propertyID);
3268 }
3269
3270 String CSSComputedStyleDeclaration::getPropertyPriority(const String&)
3271 {
3272     // All computed styles have a priority of not "important".
3273     return "";
3274 }
3275
3276 String CSSComputedStyleDeclaration::getPropertyShorthand(const String&)
3277 {
3278     return "";
3279 }
3280
3281 bool CSSComputedStyleDeclaration::isPropertyImplicit(const String&)
3282 {
3283     return false;
3284 }
3285
3286 void CSSComputedStyleDeclaration::setProperty(const String&, const String&, const String&, ExceptionCode& ec)
3287 {
3288     ec = NO_MODIFICATION_ALLOWED_ERR;
3289 }
3290
3291 String CSSComputedStyleDeclaration::removeProperty(const String&, ExceptionCode& ec)
3292 {
3293     ec = NO_MODIFICATION_ALLOWED_ERR;
3294     return String();
3295 }
3296     
3297 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
3298 {
3299     return getPropertyCSSValue(propertyID);
3300 }
3301
3302 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
3303 {
3304     return getPropertyValue(propertyID);
3305 }
3306
3307 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const String&, bool, ExceptionCode& ec)
3308 {
3309     ec = NO_MODIFICATION_ALLOWED_ERR;
3310 }
3311
3312 PassRefPtr<CSSValueList> ComputedStyleExtractor::getBackgroundShorthandValue() const
3313 {
3314     static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage,
3315                                                                      CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment,  
3316                                                                      CSSPropertyBackgroundPosition };
3317     static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyBackgroundSize, CSSPropertyBackgroundOrigin, 
3318                                                                     CSSPropertyBackgroundClip };
3319
3320     RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3321     list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(CSSPropertyBackground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperator))));
3322     list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(CSSPropertyBackground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator))));
3323     return list.release();
3324 }
3325
3326 } // namespace WebCore