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