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