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.
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.
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.
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
25 #include "CSSComputedStyleDeclaration.h"
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"
47 #include "ExceptionCode.h"
48 #include "FontFeatureSettings.h"
49 #include "FontFeatureValue.h"
50 #include "FontValue.h"
51 #include "HTMLFrameOwnerElement.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>
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"
77 #if ENABLE(CSS_FILTERS)
78 #include "StyleCustomFilterProgram.h"
79 #include "WebKitCSSFilterValue.h"
82 #if ENABLE(DASHBOARD_SUPPORT)
83 #include "DashboardRegion.h"
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,
121 CSSPropertyBoxShadow,
122 CSSPropertyBoxSizing,
123 CSSPropertyCaptionSide,
128 CSSPropertyDirection,
130 CSSPropertyEmptyCells,
132 CSSPropertyFontFamily,
134 CSSPropertyFontStyle,
135 CSSPropertyFontVariant,
136 CSSPropertyFontWeight,
138 #if ENABLE(CSS_IMAGE_ORIENTATION)
139 CSSPropertyImageOrientation,
141 CSSPropertyImageRendering,
142 #if ENABLE(CSS_IMAGE_RESOLUTION)
143 CSSPropertyImageResolution,
146 CSSPropertyLetterSpacing,
147 CSSPropertyLineHeight,
148 CSSPropertyListStyleImage,
149 CSSPropertyListStylePosition,
150 CSSPropertyListStyleType,
151 CSSPropertyMarginBottom,
152 CSSPropertyMarginLeft,
153 CSSPropertyMarginRight,
154 CSSPropertyMarginTop,
155 CSSPropertyMaxHeight,
157 CSSPropertyMinHeight,
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,
179 CSSPropertyTableLayout,
181 CSSPropertyTextAlign,
182 CSSPropertyTextDecoration,
183 #if ENABLE(CSS3_TEXT)
184 CSSPropertyWebkitTextDecorationLine,
185 CSSPropertyWebkitTextDecorationStyle,
186 CSSPropertyWebkitTextAlignLast,
188 CSSPropertyTextIndent,
189 CSSPropertyTextRendering,
190 CSSPropertyTextShadow,
191 CSSPropertyTextOverflow,
192 CSSPropertyTextTransform,
194 CSSPropertyUnicodeBidi,
195 CSSPropertyVerticalAlign,
196 CSSPropertyVisibility,
197 CSSPropertyWhiteSpace,
200 CSSPropertyWordBreak,
201 CSSPropertyWordSpacing,
206 CSSPropertyWebkitAnimationDelay,
207 CSSPropertyWebkitAnimationDirection,
208 CSSPropertyWebkitAnimationDuration,
209 CSSPropertyWebkitAnimationFillMode,
210 CSSPropertyWebkitAnimationIterationCount,
211 CSSPropertyWebkitAnimationName,
212 CSSPropertyWebkitAnimationPlayState,
213 CSSPropertyWebkitAnimationTimingFunction,
214 CSSPropertyWebkitAppearance,
215 CSSPropertyWebkitBackfaceVisibility,
216 CSSPropertyWebkitBackgroundClip,
217 CSSPropertyWebkitBackgroundComposite,
218 CSSPropertyWebkitBackgroundOrigin,
219 CSSPropertyWebkitBackgroundSize,
220 #if ENABLE(CSS_COMPOSITING)
221 CSSPropertyWebkitBlendMode,
223 CSSPropertyWebkitBorderFit,
224 CSSPropertyWebkitBorderHorizontalSpacing,
225 CSSPropertyWebkitBorderImage,
226 CSSPropertyWebkitBorderVerticalSpacing,
227 CSSPropertyWebkitBoxAlign,
228 #if ENABLE(CSS_BOX_DECORATION_BREAK)
229 CSSPropertyWebkitBoxDecorationBreak,
231 CSSPropertyWebkitBoxDirection,
232 CSSPropertyWebkitBoxFlex,
233 CSSPropertyWebkitBoxFlexGroup,
234 CSSPropertyWebkitBoxLines,
235 CSSPropertyWebkitBoxOrdinalGroup,
236 CSSPropertyWebkitBoxOrient,
237 CSSPropertyWebkitBoxPack,
238 CSSPropertyWebkitBoxReflect,
239 CSSPropertyWebkitBoxShadow,
240 CSSPropertyWebkitClipPath,
241 CSSPropertyWebkitColorCorrection,
242 CSSPropertyWebkitColumnBreakAfter,
243 CSSPropertyWebkitColumnBreakBefore,
244 CSSPropertyWebkitColumnBreakInside,
245 CSSPropertyWebkitColumnAxis,
246 CSSPropertyWebkitColumnCount,
247 CSSPropertyWebkitColumnGap,
248 CSSPropertyWebkitColumnProgression,
249 CSSPropertyWebkitColumnRuleColor,
250 CSSPropertyWebkitColumnRuleStyle,
251 CSSPropertyWebkitColumnRuleWidth,
252 CSSPropertyWebkitColumnSpan,
253 CSSPropertyWebkitColumnWidth,
254 #if ENABLE(DASHBOARD_SUPPORT)
255 CSSPropertyWebkitDashboardRegion,
257 #if ENABLE(CSS_FILTERS)
258 CSSPropertyWebkitFilter,
260 CSSPropertyWebkitAlignContent,
261 CSSPropertyWebkitAlignItems,
262 CSSPropertyWebkitAlignSelf,
263 CSSPropertyWebkitFlexBasis,
264 CSSPropertyWebkitFlexGrow,
265 CSSPropertyWebkitFlexShrink,
266 CSSPropertyWebkitFlexDirection,
267 CSSPropertyWebkitFlexWrap,
268 CSSPropertyWebkitJustifyContent,
269 CSSPropertyWebkitFontKerning,
270 CSSPropertyWebkitFontSmoothing,
271 CSSPropertyWebkitFontVariantLigatures,
272 CSSPropertyWebkitGridColumns,
273 CSSPropertyWebkitGridRows,
274 CSSPropertyWebkitGridColumn,
275 CSSPropertyWebkitGridRow,
276 CSSPropertyWebkitHighlight,
277 CSSPropertyWebkitHyphenateCharacter,
278 CSSPropertyWebkitHyphenateLimitAfter,
279 CSSPropertyWebkitHyphenateLimitBefore,
280 CSSPropertyWebkitHyphenateLimitLines,
281 CSSPropertyWebkitHyphens,
282 CSSPropertyWebkitLineAlign,
283 CSSPropertyWebkitLineBoxContain,
284 CSSPropertyWebkitLineBreak,
285 CSSPropertyWebkitLineClamp,
286 CSSPropertyWebkitLineGrid,
287 CSSPropertyWebkitLineSnap,
288 CSSPropertyWebkitLocale,
289 CSSPropertyWebkitMarginBeforeCollapse,
290 CSSPropertyWebkitMarginAfterCollapse,
291 CSSPropertyWebkitMarqueeDirection,
292 CSSPropertyWebkitMarqueeIncrement,
293 CSSPropertyWebkitMarqueeRepetition,
294 CSSPropertyWebkitMarqueeStyle,
295 CSSPropertyWebkitMaskAttachment,
296 CSSPropertyWebkitMaskBoxImage,
297 CSSPropertyWebkitMaskBoxImageOutset,
298 CSSPropertyWebkitMaskBoxImageRepeat,
299 CSSPropertyWebkitMaskBoxImageSlice,
300 CSSPropertyWebkitMaskBoxImageSource,
301 CSSPropertyWebkitMaskBoxImageWidth,
302 CSSPropertyWebkitMaskClip,
303 CSSPropertyWebkitMaskComposite,
304 CSSPropertyWebkitMaskImage,
305 CSSPropertyWebkitMaskOrigin,
306 CSSPropertyWebkitMaskPosition,
307 CSSPropertyWebkitMaskRepeat,
308 CSSPropertyWebkitMaskSize,
309 CSSPropertyWebkitNbspMode,
310 CSSPropertyWebkitOrder,
311 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
312 CSSPropertyWebkitOverflowScrolling,
314 CSSPropertyWebkitPerspective,
315 CSSPropertyWebkitPerspectiveOrigin,
316 CSSPropertyWebkitPrintColorAdjust,
317 CSSPropertyWebkitRtlOrdering,
318 #if ENABLE(CSS_EXCLUSIONS)
319 CSSPropertyWebkitShapeInside,
320 CSSPropertyWebkitShapeOutside,
322 #if ENABLE(TOUCH_EVENTS)
323 CSSPropertyWebkitTapHighlightColor,
325 CSSPropertyWebkitTextCombine,
326 CSSPropertyWebkitTextDecorationsInEffect,
327 CSSPropertyWebkitTextEmphasisColor,
328 CSSPropertyWebkitTextEmphasisPosition,
329 CSSPropertyWebkitTextEmphasisStyle,
330 CSSPropertyWebkitTextFillColor,
331 CSSPropertyWebkitTextOrientation,
332 CSSPropertyWebkitTextSecurity,
333 CSSPropertyWebkitTextStrokeColor,
334 CSSPropertyWebkitTextStrokeWidth,
335 CSSPropertyWebkitTransform,
336 CSSPropertyWebkitTransformOrigin,
337 CSSPropertyWebkitTransformStyle,
338 CSSPropertyWebkitTransitionDelay,
339 CSSPropertyWebkitTransitionDuration,
340 CSSPropertyWebkitTransitionProperty,
341 CSSPropertyWebkitTransitionTimingFunction,
342 CSSPropertyWebkitUserDrag,
343 CSSPropertyWebkitUserModify,
344 CSSPropertyWebkitUserSelect,
345 CSSPropertyWebkitWritingMode,
346 #if ENABLE(CSS_REGIONS)
347 CSSPropertyWebkitFlowInto,
348 CSSPropertyWebkitFlowFrom,
349 CSSPropertyWebkitRegionOverflow,
350 CSSPropertyWebkitRegionBreakAfter,
351 CSSPropertyWebkitRegionBreakBefore,
352 CSSPropertyWebkitRegionBreakInside,
354 #if ENABLE(DRAGGABLE_REGION)
355 CSSPropertyWebkitAppRegion,
357 #if ENABLE(CSS_EXCLUSIONS)
358 CSSPropertyWebkitWrapFlow,
359 CSSPropertyWebkitShapeMargin,
360 CSSPropertyWebkitShapePadding,
361 CSSPropertyWebkitWrapThrough,
368 CSSPropertyFloodColor,
369 CSSPropertyFloodOpacity,
370 CSSPropertyLightingColor,
371 CSSPropertyStopColor,
372 CSSPropertyStopOpacity,
373 CSSPropertyColorInterpolation,
374 CSSPropertyColorInterpolationFilters,
375 CSSPropertyColorRendering,
377 CSSPropertyFillOpacity,
379 CSSPropertyMarkerEnd,
380 CSSPropertyMarkerMid,
381 CSSPropertyMarkerStart,
383 CSSPropertyShapeRendering,
385 CSSPropertyStrokeDasharray,
386 CSSPropertyStrokeDashoffset,
387 CSSPropertyStrokeLinecap,
388 CSSPropertyStrokeLinejoin,
389 CSSPropertyStrokeMiterlimit,
390 CSSPropertyStrokeOpacity,
391 CSSPropertyStrokeWidth,
392 CSSPropertyAlignmentBaseline,
393 CSSPropertyBaselineShift,
394 CSSPropertyDominantBaseline,
396 CSSPropertyTextAnchor,
397 CSSPropertyWritingMode,
398 CSSPropertyGlyphOrientationHorizontal,
399 CSSPropertyGlyphOrientationVertical,
400 CSSPropertyWebkitSvgShadow,
401 CSSPropertyVectorEffect
405 const unsigned numComputedProperties = WTF_ARRAY_LENGTH(computedProperties);
407 static int valueForRepeatRule(int rule)
410 case RepeatImageRule:
411 return CSSValueRepeat;
413 return CSSValueRound;
415 return CSSValueSpace;
417 return CSSValueStretch;
421 static PassRefPtr<CSSBorderImageSliceValue> valueForNinePieceImageSlice(const NinePieceImage& image)
423 // Create the slices.
424 RefPtr<CSSPrimitiveValue> top;
425 RefPtr<CSSPrimitiveValue> right;
426 RefPtr<CSSPrimitiveValue> bottom;
427 RefPtr<CSSPrimitiveValue> left;
429 if (image.imageSlices().top().isPercent())
430 top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
432 top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_NUMBER);
434 if (image.imageSlices().right() == image.imageSlices().top() && image.imageSlices().bottom() == image.imageSlices().top()
435 && image.imageSlices().left() == image.imageSlices().top()) {
440 if (image.imageSlices().right().isPercent())
441 right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
443 right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_NUMBER);
445 if (image.imageSlices().bottom() == image.imageSlices().top() && image.imageSlices().right() == image.imageSlices().left()) {
449 if (image.imageSlices().bottom().isPercent())
450 bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
452 bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
454 if (image.imageSlices().left() == image.imageSlices().right())
457 if (image.imageSlices().left().isPercent())
458 left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
460 left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_NUMBER);
465 RefPtr<Quad> quad = Quad::create();
467 quad->setRight(right);
468 quad->setBottom(bottom);
471 return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.release()), image.fill());
474 static PassRefPtr<CSSPrimitiveValue> valueForNinePieceImageQuad(const LengthBox& box)
476 // Create the slices.
477 RefPtr<CSSPrimitiveValue> top;
478 RefPtr<CSSPrimitiveValue> right;
479 RefPtr<CSSPrimitiveValue> bottom;
480 RefPtr<CSSPrimitiveValue> left;
482 if (box.top().isRelative())
483 top = cssValuePool().createValue(box.top().value(), CSSPrimitiveValue::CSS_NUMBER);
485 top = cssValuePool().createValue(box.top());
487 if (box.right() == box.top() && box.bottom() == box.top() && box.left() == box.top()) {
492 if (box.right().isRelative())
493 right = cssValuePool().createValue(box.right().value(), CSSPrimitiveValue::CSS_NUMBER);
495 right = cssValuePool().createValue(box.right());
497 if (box.bottom() == box.top() && box.right() == box.left()) {
501 if (box.bottom().isRelative())
502 bottom = cssValuePool().createValue(box.bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
504 bottom = cssValuePool().createValue(box.bottom());
506 if (box.left() == box.right())
509 if (box.left().isRelative())
510 left = cssValuePool().createValue(box.left().value(), CSSPrimitiveValue::CSS_NUMBER);
512 left = cssValuePool().createValue(box.left());
517 RefPtr<Quad> quad = Quad::create();
519 quad->setRight(right);
520 quad->setBottom(bottom);
523 return cssValuePool().createValue(quad.release());
526 static PassRefPtr<CSSValue> valueForNinePieceImageRepeat(const NinePieceImage& image)
528 RefPtr<CSSPrimitiveValue> horizontalRepeat;
529 RefPtr<CSSPrimitiveValue> verticalRepeat;
531 horizontalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.horizontalRule()));
532 if (image.horizontalRule() == image.verticalRule())
533 verticalRepeat = horizontalRepeat;
535 verticalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.verticalRule()));
536 return cssValuePool().createValue(Pair::create(horizontalRepeat.release(), verticalRepeat.release()));
539 static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
541 if (!image.hasImage())
542 return cssValuePool().createIdentifierValue(CSSValueNone);
545 RefPtr<CSSValue> imageValue;
547 imageValue = image.image()->cssValue();
549 // Create the image slice.
550 RefPtr<CSSBorderImageSliceValue> imageSlices = valueForNinePieceImageSlice(image);
552 // Create the border area slices.
553 RefPtr<CSSValue> borderSlices = valueForNinePieceImageQuad(image.borderSlices());
555 // Create the border outset.
556 RefPtr<CSSValue> outset = valueForNinePieceImageQuad(image.outset());
558 // Create the repeat rules.
559 RefPtr<CSSValue> repeat = valueForNinePieceImageRepeat(image);
561 return createBorderImageValue(imageValue, imageSlices, borderSlices, outset, repeat);
564 inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(double value, const RenderStyle* style)
566 return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style), CSSPrimitiveValue::CSS_PX);
569 inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedNumberValue(double value, const RenderStyle* style)
571 return cssValuePool().createValue(value / style->effectiveZoom(), CSSPrimitiveValue::CSS_NUMBER);
574 static PassRefPtr<CSSValue> zoomAdjustedPixelValueForLength(const Length& length, const RenderStyle* style)
576 if (length.isFixed())
577 return zoomAdjustedPixelValue(length.value(), style);
578 return cssValuePool().createValue(length);
581 static PassRefPtr<CSSValue> valueForReflection(const StyleReflection* reflection, const RenderStyle* style)
584 return cssValuePool().createIdentifierValue(CSSValueNone);
586 RefPtr<CSSPrimitiveValue> offset;
587 if (reflection->offset().isPercent())
588 offset = cssValuePool().createValue(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
590 offset = zoomAdjustedPixelValue(reflection->offset().value(), style);
592 return CSSReflectValue::create(reflection->direction(), offset.release(), valueForNinePieceImage(reflection->mask()));
595 static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, CSSPropertyID propertyID, RenderView* renderView)
601 switch (propertyID) {
602 case CSSPropertyLeft:
605 case CSSPropertyRight:
611 case CSSPropertyBottom:
618 if (style->hasOutOfFlowPosition()) {
619 if (l.type() == WebCore::Fixed)
620 return zoomAdjustedPixelValue(l.value(), style);
621 else if (l.isViewportPercentage())
622 return zoomAdjustedPixelValue(valueForLength(l, 0, renderView), style);
623 return cssValuePool().createValue(l);
626 if (style->hasInFlowPosition()) {
627 // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
628 // In other words if left is auto and right is not auto, then left's computed value is negative right().
629 // So we should get the opposite length unit and see if it is auto.
630 return cssValuePool().createValue(l);
633 return cssValuePool().createIdentifierValue(CSSValueAuto);
636 PassRefPtr<CSSPrimitiveValue> CSSComputedStyleDeclaration::currentColorOrValidColor(RenderStyle* style, const Color& color) const
638 // This function does NOT look at visited information, so that computed style doesn't expose that.
639 if (!color.isValid())
640 return cssValuePool().createColorValue(style->color().rgb());
641 return cssValuePool().createColorValue(color.rgb());
644 static PassRefPtr<CSSValueList> getBorderRadiusCornerValues(LengthSize radius, const RenderStyle* style, RenderView* renderView)
646 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
647 if (radius.width().type() == Percent)
648 list->append(cssValuePool().createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
650 list->append(zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style));
651 if (radius.height().type() == Percent)
652 list->append(cssValuePool().createValue(radius.height().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
654 list->append(zoomAdjustedPixelValue(valueForLength(radius.height(), 0, renderView), style));
655 return list.release();
658 static PassRefPtr<CSSValue> getBorderRadiusCornerValue(LengthSize radius, const RenderStyle* style, RenderView* renderView)
660 if (radius.width() == radius.height()) {
661 if (radius.width().type() == Percent)
662 return cssValuePool().createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
663 return zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style);
665 return getBorderRadiusCornerValues(radius, style, renderView);
668 static PassRefPtr<CSSValueList> getBorderRadiusShorthandValue(const RenderStyle* style, RenderView* renderView)
670 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
671 bool showHorizontalBottomLeft = style->borderTopRightRadius().width() != style->borderBottomLeftRadius().width();
672 bool showHorizontalBottomRight = style->borderBottomRightRadius().width() != style->borderTopLeftRadius().width();
673 bool showHorizontalTopRight = style->borderTopRightRadius().width() != style->borderTopLeftRadius().width();
675 bool showVerticalBottomLeft = style->borderTopRightRadius().height() != style->borderBottomLeftRadius().height();
676 bool showVerticalBottomRight = (style->borderBottomRightRadius().height() != style->borderTopLeftRadius().height()) || showVerticalBottomLeft;
677 bool showVerticalTopRight = (style->borderTopRightRadius().height() != style->borderTopLeftRadius().height()) || showVerticalBottomRight;
678 bool showVerticalTopLeft = (style->borderTopLeftRadius().width() != style->borderTopLeftRadius().height());
680 RefPtr<CSSValueList> topLeftRadius = getBorderRadiusCornerValues(style->borderTopLeftRadius(), style, renderView);
681 RefPtr<CSSValueList> topRightRadius = getBorderRadiusCornerValues(style->borderTopRightRadius(), style, renderView);
682 RefPtr<CSSValueList> bottomRightRadius = getBorderRadiusCornerValues(style->borderBottomRightRadius(), style, renderView);
683 RefPtr<CSSValueList> bottomLeftRadius = getBorderRadiusCornerValues(style->borderBottomLeftRadius(), style, renderView);
685 RefPtr<CSSValueList> horizontalRadii = CSSValueList::createSpaceSeparated();
686 horizontalRadii->append(topLeftRadius->item(0));
687 if (showHorizontalTopRight)
688 horizontalRadii->append(topRightRadius->item(0));
689 if (showHorizontalBottomRight)
690 horizontalRadii->append(bottomRightRadius->item(0));
691 if (showHorizontalBottomLeft)
692 horizontalRadii->append(bottomLeftRadius->item(0));
694 list->append(horizontalRadii);
696 if (showVerticalTopLeft) {
697 RefPtr<CSSValueList> verticalRadii = CSSValueList::createSpaceSeparated();
698 verticalRadii->append(topLeftRadius->item(1));
699 if (showVerticalTopRight)
700 verticalRadii->append(topRightRadius->item(1));
701 if (showVerticalBottomRight)
702 verticalRadii->append(bottomRightRadius->item(1));
703 if (showVerticalBottomLeft)
704 verticalRadii->append(bottomLeftRadius->item(1));
705 list->append(verticalRadii);
707 return list.release();
710 static LayoutRect sizingBox(RenderObject* renderer)
712 if (!renderer->isBox())
715 RenderBox* box = toRenderBox(renderer);
716 return box->style()->boxSizing() == BORDER_BOX ? box->borderBoxRect() : box->computedCSSContentBoxRect();
719 static PassRefPtr<WebKitCSSTransformValue> matrixTransformValue(const TransformationMatrix& transform, const RenderStyle* style)
721 RefPtr<WebKitCSSTransformValue> transformValue;
722 if (transform.isAffine()) {
723 transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::MatrixTransformOperation);
725 transformValue->append(cssValuePool().createValue(transform.a(), CSSPrimitiveValue::CSS_NUMBER));
726 transformValue->append(cssValuePool().createValue(transform.b(), CSSPrimitiveValue::CSS_NUMBER));
727 transformValue->append(cssValuePool().createValue(transform.c(), CSSPrimitiveValue::CSS_NUMBER));
728 transformValue->append(cssValuePool().createValue(transform.d(), CSSPrimitiveValue::CSS_NUMBER));
729 transformValue->append(zoomAdjustedNumberValue(transform.e(), style));
730 transformValue->append(zoomAdjustedNumberValue(transform.f(), style));
732 transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::Matrix3DTransformOperation);
734 transformValue->append(cssValuePool().createValue(transform.m11(), CSSPrimitiveValue::CSS_NUMBER));
735 transformValue->append(cssValuePool().createValue(transform.m12(), CSSPrimitiveValue::CSS_NUMBER));
736 transformValue->append(cssValuePool().createValue(transform.m13(), CSSPrimitiveValue::CSS_NUMBER));
737 transformValue->append(cssValuePool().createValue(transform.m14(), CSSPrimitiveValue::CSS_NUMBER));
739 transformValue->append(cssValuePool().createValue(transform.m21(), CSSPrimitiveValue::CSS_NUMBER));
740 transformValue->append(cssValuePool().createValue(transform.m22(), CSSPrimitiveValue::CSS_NUMBER));
741 transformValue->append(cssValuePool().createValue(transform.m23(), CSSPrimitiveValue::CSS_NUMBER));
742 transformValue->append(cssValuePool().createValue(transform.m24(), CSSPrimitiveValue::CSS_NUMBER));
744 transformValue->append(cssValuePool().createValue(transform.m31(), CSSPrimitiveValue::CSS_NUMBER));
745 transformValue->append(cssValuePool().createValue(transform.m32(), CSSPrimitiveValue::CSS_NUMBER));
746 transformValue->append(cssValuePool().createValue(transform.m33(), CSSPrimitiveValue::CSS_NUMBER));
747 transformValue->append(cssValuePool().createValue(transform.m34(), CSSPrimitiveValue::CSS_NUMBER));
749 transformValue->append(zoomAdjustedNumberValue(transform.m41(), style));
750 transformValue->append(zoomAdjustedNumberValue(transform.m42(), style));
751 transformValue->append(zoomAdjustedNumberValue(transform.m43(), style));
752 transformValue->append(cssValuePool().createValue(transform.m44(), CSSPrimitiveValue::CSS_NUMBER));
755 return transformValue.release();
758 static PassRefPtr<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle* style)
760 if (!renderer || !renderer->hasTransform() || !style->hasTransform())
761 return cssValuePool().createIdentifierValue(CSSValueNone);
764 if (renderer->isBox())
765 box = pixelSnappedIntRect(toRenderBox(renderer)->borderBoxRect());
767 TransformationMatrix transform;
768 style->applyTransform(transform, box.size(), RenderStyle::ExcludeTransformOrigin);
769 // Note that this does not flatten to an affine transform if ENABLE(3D_RENDERING) is off, by design.
771 // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
772 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
773 list->append(matrixTransformValue(transform, style));
775 return list.release();
778 #if ENABLE(CSS_SHADERS)
779 static PassRefPtr<CSSValue> valueForCustomFilterArrayParameter(const CustomFilterArrayParameter* arrayParameter)
781 RefPtr<WebKitCSSArrayFunctionValue> arrayParameterValue = WebKitCSSArrayFunctionValue::create();
782 for (unsigned i = 0, size = arrayParameter->size(); i < size; ++i)
783 arrayParameterValue->append(cssValuePool().createValue(arrayParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
784 return arrayParameterValue.release();
787 static PassRefPtr<CSSValue> valueForCustomFilterNumberParameter(const CustomFilterNumberParameter* numberParameter)
789 RefPtr<CSSValueList> numberParameterValue = CSSValueList::createSpaceSeparated();
790 for (unsigned i = 0; i < numberParameter->size(); ++i)
791 numberParameterValue->append(cssValuePool().createValue(numberParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
792 return numberParameterValue.release();
795 static PassRefPtr<CSSValue> valueForCustomFilterTransformParameter(const RenderObject* renderer, const RenderStyle* style, const CustomFilterTransformParameter* transformParameter)
797 IntSize size = renderer ? pixelSnappedIntRect(toRenderBox(renderer)->borderBoxRect()).size() : IntSize();
798 TransformationMatrix transform;
799 transformParameter->applyTransform(transform, size);
800 // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
801 return matrixTransformValue(transform, style);
804 static PassRefPtr<CSSValue> valueForCustomFilterParameter(const RenderObject* renderer, const RenderStyle* style, const CustomFilterParameter* parameter)
806 // FIXME: Add here computed style for the other types: boolean, transform, matrix, texture.
808 switch (parameter->parameterType()) {
809 case CustomFilterParameter::ARRAY:
810 return valueForCustomFilterArrayParameter(static_cast<const CustomFilterArrayParameter*>(parameter));
811 case CustomFilterParameter::NUMBER:
812 return valueForCustomFilterNumberParameter(static_cast<const CustomFilterNumberParameter*>(parameter));
813 case CustomFilterParameter::TRANSFORM:
814 return valueForCustomFilterTransformParameter(renderer, style, static_cast<const CustomFilterTransformParameter*>(parameter));
817 ASSERT_NOT_REACHED();
820 #endif // ENABLE(CSS_SHADERS)
822 #if ENABLE(CSS_FILTERS)
823 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForFilter(const RenderObject* renderer, const RenderStyle* style) const
825 #if !ENABLE(CSS_SHADERS)
826 UNUSED_PARAM(renderer);
828 if (style->filter().operations().isEmpty())
829 return cssValuePool().createIdentifierValue(CSSValueNone);
831 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
833 RefPtr<WebKitCSSFilterValue> filterValue;
835 Vector<RefPtr<FilterOperation> >::const_iterator end = style->filter().operations().end();
836 for (Vector<RefPtr<FilterOperation> >::const_iterator it = style->filter().operations().begin(); it != end; ++it) {
837 FilterOperation* filterOperation = (*it).get();
838 switch (filterOperation->getOperationType()) {
839 case FilterOperation::REFERENCE: {
840 ReferenceFilterOperation* referenceOperation = static_cast<ReferenceFilterOperation*>(filterOperation);
841 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ReferenceFilterOperation);
842 filterValue->append(cssValuePool().createValue(referenceOperation->url(), CSSPrimitiveValue::CSS_STRING));
845 case FilterOperation::GRAYSCALE: {
846 BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
847 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::GrayscaleFilterOperation);
848 filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
851 case FilterOperation::SEPIA: {
852 BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
853 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SepiaFilterOperation);
854 filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
857 case FilterOperation::SATURATE: {
858 BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
859 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SaturateFilterOperation);
860 filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
863 case FilterOperation::HUE_ROTATE: {
864 BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
865 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::HueRotateFilterOperation);
866 filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_DEG));
869 case FilterOperation::INVERT: {
870 BasicComponentTransferFilterOperation* componentTransferOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
871 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::InvertFilterOperation);
872 filterValue->append(cssValuePool().createValue(componentTransferOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
875 case FilterOperation::OPACITY: {
876 BasicComponentTransferFilterOperation* componentTransferOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
877 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::OpacityFilterOperation);
878 filterValue->append(cssValuePool().createValue(componentTransferOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
881 case FilterOperation::BRIGHTNESS: {
882 BasicComponentTransferFilterOperation* brightnessOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
883 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BrightnessFilterOperation);
884 filterValue->append(cssValuePool().createValue(brightnessOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
887 case FilterOperation::CONTRAST: {
888 BasicComponentTransferFilterOperation* contrastOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
889 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ContrastFilterOperation);
890 filterValue->append(cssValuePool().createValue(contrastOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
893 case FilterOperation::BLUR: {
894 BlurFilterOperation* blurOperation = static_cast<BlurFilterOperation*>(filterOperation);
895 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BlurFilterOperation);
896 filterValue->append(zoomAdjustedPixelValue(blurOperation->stdDeviation().value(), style));
899 case FilterOperation::DROP_SHADOW: {
900 DropShadowFilterOperation* dropShadowOperation = static_cast<DropShadowFilterOperation*>(filterOperation);
901 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::DropShadowFilterOperation);
902 // We want our computed style to look like that of a text shadow (has neither spread nor inset style).
903 ShadowData shadowData = ShadowData(dropShadowOperation->location(), dropShadowOperation->stdDeviation(), 0, Normal, false, dropShadowOperation->color());
904 filterValue->append(valueForShadow(&shadowData, CSSPropertyTextShadow, style));
907 #if ENABLE(CSS_SHADERS)
908 case FilterOperation::VALIDATED_CUSTOM:
909 // ValidatedCustomFilterOperation is not supposed to end up in the RenderStyle.
910 ASSERT_NOT_REACHED();
912 case FilterOperation::CUSTOM: {
913 CustomFilterOperation* customOperation = static_cast<CustomFilterOperation*>(filterOperation);
914 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::CustomFilterOperation);
916 // The output should be verbose, even if the values are the default ones.
918 ASSERT(customOperation->program());
919 StyleCustomFilterProgram* program = static_cast<StyleCustomFilterProgram*>(customOperation->program());
921 RefPtr<CSSValueList> shadersList = CSSValueList::createSpaceSeparated();
922 if (program->vertexShader())
923 shadersList->append(program->vertexShader()->cssValue());
925 shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone));
927 const CustomFilterProgramMixSettings mixSettings = program->mixSettings();
928 if (program->fragmentShader()) {
929 if (program->programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE) {
930 RefPtr<WebKitCSSMixFunctionValue> mixFunction = WebKitCSSMixFunctionValue::create();
931 mixFunction->append(program->fragmentShader()->cssValue());
932 mixFunction->append(cssValuePool().createValue(mixSettings.blendMode));
933 mixFunction->append(cssValuePool().createValue(mixSettings.compositeOperator));
934 shadersList->append(mixFunction.release());
936 shadersList->append(program->fragmentShader()->cssValue());
939 shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone));
941 filterValue->append(shadersList.release());
943 RefPtr<CSSValueList> meshParameters = CSSValueList::createSpaceSeparated();
944 meshParameters->append(cssValuePool().createValue(customOperation->meshColumns(), CSSPrimitiveValue::CSS_NUMBER));
945 meshParameters->append(cssValuePool().createValue(customOperation->meshRows(), CSSPrimitiveValue::CSS_NUMBER));
946 meshParameters->append(cssValuePool().createValue(customOperation->meshBoxType()));
948 // FIXME: The specification doesn't have any "attached" identifier. Should we add one?
949 // https://bugs.webkit.org/show_bug.cgi?id=72700
950 if (customOperation->meshType() == MeshTypeDetached)
951 meshParameters->append(cssValuePool().createIdentifierValue(CSSValueDetached));
953 filterValue->append(meshParameters.release());
955 const CustomFilterParameterList& parameters = customOperation->parameters();
956 size_t parametersSize = parameters.size();
959 RefPtr<CSSValueList> parametersCSSValue = CSSValueList::createCommaSeparated();
960 for (size_t i = 0; i < parametersSize; ++i) {
961 const CustomFilterParameter* parameter = parameters.at(i).get();
962 RefPtr<CSSValueList> parameterCSSNameAndValue = CSSValueList::createSpaceSeparated();
963 parameterCSSNameAndValue->append(cssValuePool().createValue(parameter->name(), CSSPrimitiveValue::CSS_STRING));
964 parameterCSSNameAndValue->append(valueForCustomFilterParameter(renderer, style, parameter));
965 parametersCSSValue->append(parameterCSSNameAndValue.release());
968 filterValue->append(parametersCSSValue.release());
973 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::UnknownFilterOperation);
976 list->append(filterValue);
979 return list.release();
983 static PassRefPtr<CSSValue> valueForGridTrackBreadth(const Length& trackLength, const RenderStyle* style)
985 if (trackLength.isPercent())
986 return cssValuePool().createValue(trackLength);
987 if (trackLength.isAuto())
988 return cssValuePool().createIdentifierValue(CSSValueAuto);
989 return zoomAdjustedPixelValue(trackLength.value(), style);
992 static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<Length>& trackLengths, const RenderStyle* style)
994 // We should have at least an element!
995 ASSERT(trackLengths.size());
997 // Handle the 'none' case here.
998 if (trackLengths.size() == 1 && trackLengths[0].isUndefined())
999 return cssValuePool().createIdentifierValue(CSSValueNone);
1001 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1002 for (size_t i = 0; i < trackLengths.size(); ++i)
1003 list->append(valueForGridTrackBreadth(trackLengths[i], style));
1004 return list.release();
1007 static PassRefPtr<CSSValue> valueForGridPosition(const Length& position)
1009 if (position.isAuto())
1010 return cssValuePool().createIdentifierValue(CSSValueAuto);
1012 ASSERT(position.isFixed());
1013 return cssValuePool().createValue(position.value(), CSSPrimitiveValue::CSS_NUMBER);
1016 static PassRefPtr<CSSValue> getDelayValue(const AnimationList* animList)
1018 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1020 for (size_t i = 0; i < animList->size(); ++i)
1021 list->append(cssValuePool().createValue(animList->animation(i)->delay(), CSSPrimitiveValue::CSS_S));
1023 // Note that initialAnimationDelay() is used for both transitions and animations
1024 list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
1026 return list.release();
1029 static PassRefPtr<CSSValue> getDurationValue(const AnimationList* animList)
1031 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1033 for (size_t i = 0; i < animList->size(); ++i)
1034 list->append(cssValuePool().createValue(animList->animation(i)->duration(), CSSPrimitiveValue::CSS_S));
1036 // Note that initialAnimationDuration() is used for both transitions and animations
1037 list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
1039 return list.release();
1042 static PassRefPtr<CSSValue> getTimingFunctionValue(const AnimationList* animList)
1044 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1046 for (size_t i = 0; i < animList->size(); ++i) {
1047 const TimingFunction* tf = animList->animation(i)->timingFunction().get();
1048 if (tf->isCubicBezierTimingFunction()) {
1049 const CubicBezierTimingFunction* ctf = static_cast<const CubicBezierTimingFunction*>(tf);
1050 list->append(CSSCubicBezierTimingFunctionValue::create(ctf->x1(), ctf->y1(), ctf->x2(), ctf->y2()));
1051 } else if (tf->isStepsTimingFunction()) {
1052 const StepsTimingFunction* stf = static_cast<const StepsTimingFunction*>(tf);
1053 list->append(CSSStepsTimingFunctionValue::create(stf->numberOfSteps(), stf->stepAtStart()));
1055 list->append(CSSLinearTimingFunctionValue::create());
1059 // Note that initialAnimationTimingFunction() is used for both transitions and animations
1060 RefPtr<TimingFunction> tf = Animation::initialAnimationTimingFunction();
1061 if (tf->isCubicBezierTimingFunction()) {
1062 const CubicBezierTimingFunction* ctf = static_cast<const CubicBezierTimingFunction*>(tf.get());
1063 list->append(CSSCubicBezierTimingFunctionValue::create(ctf->x1(), ctf->y1(), ctf->x2(), ctf->y2()));
1064 } else if (tf->isStepsTimingFunction()) {
1065 const StepsTimingFunction* stf = static_cast<const StepsTimingFunction*>(tf.get());
1066 list->append(CSSStepsTimingFunctionValue::create(stf->numberOfSteps(), stf->stepAtStart()));
1068 list->append(CSSLinearTimingFunctionValue::create());
1071 return list.release();
1074 static PassRefPtr<CSSValue> createLineBoxContainValue(unsigned lineBoxContain)
1076 if (!lineBoxContain)
1077 return cssValuePool().createIdentifierValue(CSSValueNone);
1078 return CSSLineBoxContainValue::create(lineBoxContain);
1081 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n, bool allowVisitedStyle, const String& pseudoElementName)
1083 , m_allowVisitedStyle(allowVisitedStyle)
1086 unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoElementName[1] == ':' ? 2 : 1) : 0;
1087 m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoType(
1088 AtomicString(pseudoElementName.substring(nameWithoutColonsStart))));
1091 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
1095 void CSSComputedStyleDeclaration::ref()
1100 void CSSComputedStyleDeclaration::deref()
1107 String CSSComputedStyleDeclaration::cssText() const
1109 StringBuilder result;
1111 for (unsigned i = 0; i < numComputedProperties; i++) {
1114 result.append(getPropertyName(computedProperties[i]));
1115 result.append(": ", 2);
1116 result.append(getPropertyValue(computedProperties[i]));
1120 return result.toString();
1123 void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
1125 ec = NO_MODIFICATION_ALLOWED_ERR;
1128 static int cssIdentifierForFontSizeKeyword(int keywordSize)
1130 ASSERT_ARG(keywordSize, keywordSize);
1131 ASSERT_ARG(keywordSize, keywordSize <= 8);
1132 return CSSValueXxSmall + keywordSize - 1;
1135 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword() const
1140 m_node->document()->updateLayoutIgnorePendingStylesheets();
1142 RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1146 if (int keywordSize = style->fontDescription().keywordSize())
1147 return cssValuePool().createIdentifierValue(cssIdentifierForFontSizeKeyword(keywordSize));
1150 return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style.get());
1153 bool CSSComputedStyleDeclaration::useFixedFontDefaultSize() const
1158 RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1162 return style->fontDescription().useFixedDefaultSize();
1165 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadow(const ShadowData* shadow, CSSPropertyID propertyID, const RenderStyle* style) const
1168 return cssValuePool().createIdentifierValue(CSSValueNone);
1170 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1171 for (const ShadowData* s = shadow; s; s = s->next()) {
1172 RefPtr<CSSPrimitiveValue> x = zoomAdjustedPixelValue(s->x(), style);
1173 RefPtr<CSSPrimitiveValue> y = zoomAdjustedPixelValue(s->y(), style);
1174 RefPtr<CSSPrimitiveValue> blur = zoomAdjustedPixelValue(s->blur(), style);
1175 RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? PassRefPtr<CSSPrimitiveValue>() : zoomAdjustedPixelValue(s->spread(), style);
1176 RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || s->style() == Normal ? PassRefPtr<CSSPrimitiveValue>() : cssValuePool().createIdentifierValue(CSSValueInset);
1177 RefPtr<CSSPrimitiveValue> color = cssValuePool().createColorValue(s->color().rgb());
1178 list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release()));
1180 return list.release();
1183 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID) const
1185 return getPropertyCSSValue(propertyID, UpdateLayout);
1188 static int identifierForFamily(const AtomicString& family)
1190 if (family == cursiveFamily)
1191 return CSSValueCursive;
1192 if (family == fantasyFamily)
1193 return CSSValueFantasy;
1194 if (family == monospaceFamily)
1195 return CSSValueMonospace;
1196 if (family == pictographFamily)
1197 return CSSValueWebkitPictograph;
1198 if (family == sansSerifFamily)
1199 return CSSValueSansSerif;
1200 if (family == serifFamily)
1201 return CSSValueSerif;
1205 static PassRefPtr<CSSPrimitiveValue> valueForFamily(const AtomicString& family)
1207 if (int familyIdentifier = identifierForFamily(family))
1208 return cssValuePool().createIdentifierValue(familyIdentifier);
1209 return cssValuePool().createValue(family.string(), CSSPrimitiveValue::CSS_STRING);
1212 static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration)
1214 // Blink value is ignored.
1215 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1216 if (textDecoration & UNDERLINE)
1217 list->append(cssValuePool().createIdentifierValue(CSSValueUnderline));
1218 if (textDecoration & OVERLINE)
1219 list->append(cssValuePool().createIdentifierValue(CSSValueOverline));
1220 if (textDecoration & LINE_THROUGH)
1221 list->append(cssValuePool().createIdentifierValue(CSSValueLineThrough));
1223 if (!list->length())
1224 return cssValuePool().createIdentifierValue(CSSValueNone);
1228 #if ENABLE(CSS3_TEXT)
1229 static PassRefPtr<CSSValue> renderTextDecorationStyleFlagsToCSSValue(TextDecorationStyle textDecorationStyle)
1231 switch (textDecorationStyle) {
1232 case TextDecorationStyleSolid:
1233 return cssValuePool().createIdentifierValue(CSSValueSolid);
1234 case TextDecorationStyleDouble:
1235 return cssValuePool().createIdentifierValue(CSSValueDouble);
1236 case TextDecorationStyleDotted:
1237 return cssValuePool().createIdentifierValue(CSSValueDotted);
1238 case TextDecorationStyleDashed:
1239 return cssValuePool().createIdentifierValue(CSSValueDashed);
1240 case TextDecorationStyleWavy:
1241 return cssValuePool().createIdentifierValue(CSSValueWavy);
1244 ASSERT_NOT_REACHED();
1245 return cssValuePool().createExplicitInitialValue();
1249 static PassRefPtr<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat)
1251 // For backwards compatibility, if both values are equal, just return one of them. And
1252 // if the two values are equivalent to repeat-x or repeat-y, just return the shorthand.
1253 if (xRepeat == yRepeat)
1254 return cssValuePool().createValue(xRepeat);
1255 if (xRepeat == RepeatFill && yRepeat == NoRepeatFill)
1256 return cssValuePool().createIdentifierValue(CSSValueRepeatX);
1257 if (xRepeat == NoRepeatFill && yRepeat == RepeatFill)
1258 return cssValuePool().createIdentifierValue(CSSValueRepeatY);
1260 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1261 list->append(cssValuePool().createValue(xRepeat));
1262 list->append(cssValuePool().createValue(yRepeat));
1263 return list.release();
1266 static PassRefPtr<CSSValue> fillSizeToCSSValue(const FillSize& fillSize, const RenderStyle* style)
1268 if (fillSize.type == Contain)
1269 return cssValuePool().createIdentifierValue(CSSValueContain);
1271 if (fillSize.type == Cover)
1272 return cssValuePool().createIdentifierValue(CSSValueCover);
1274 if (fillSize.size.height().isAuto())
1275 return zoomAdjustedPixelValueForLength(fillSize.size.width(), style);
1277 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1278 list->append(zoomAdjustedPixelValueForLength(fillSize.size.width(), style));
1279 list->append(zoomAdjustedPixelValueForLength(fillSize.size.height(), style));
1280 return list.release();
1283 static PassRefPtr<CSSValue> contentToCSSValue(const RenderStyle* style)
1285 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1286 for (const ContentData* contentData = style->contentData(); contentData; contentData = contentData->next()) {
1287 if (contentData->isCounter()) {
1288 const CounterContent* counter = static_cast<const CounterContentData*>(contentData)->counter();
1290 list->append(cssValuePool().createValue(counter->identifier(), CSSPrimitiveValue::CSS_COUNTER_NAME));
1291 } else if (contentData->isImage()) {
1292 const StyleImage* image = static_cast<const ImageContentData*>(contentData)->image();
1294 list->append(image->cssValue());
1295 } else if (contentData->isText())
1296 list->append(cssValuePool().createValue(static_cast<const TextContentData*>(contentData)->text(), CSSPrimitiveValue::CSS_STRING));
1298 if (!style->regionThread().isNull())
1299 list->append(cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING));
1300 return list.release();
1303 static PassRefPtr<CSSValue> counterToCSSValue(const RenderStyle* style, CSSPropertyID propertyID)
1305 const CounterDirectiveMap* map = style->counterDirectives();
1309 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1310 for (CounterDirectiveMap::const_iterator it = map->begin(); it != map->end(); ++it) {
1311 list->append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
1312 short number = propertyID == CSSPropertyCounterIncrement ? it->value.incrementValue() : it->value.resetValue();
1313 list->append(cssValuePool().createValue((double)number, CSSPrimitiveValue::CSS_NUMBER));
1315 return list.release();
1318 static void logUnimplementedPropertyID(CSSPropertyID propertyID)
1320 DEFINE_STATIC_LOCAL(HashSet<CSSPropertyID>, propertyIDSet, ());
1321 if (!propertyIDSet.add(propertyID).isNewEntry)
1324 LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", getPropertyName(propertyID));
1327 static PassRefPtr<CSSValueList> fontFamilyFromStyle(RenderStyle* style)
1329 const FontFamily& firstFamily = style->fontDescription().family();
1330 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1331 for (const FontFamily* family = &firstFamily; family; family = family->next())
1332 list->append(valueForFamily(family->family()));
1333 return list.release();
1336 static PassRefPtr<CSSPrimitiveValue> lineHeightFromStyle(RenderStyle* style, RenderView* renderView)
1338 Length length = style->lineHeight();
1339 if (length.isNegative())
1340 return cssValuePool().createIdentifierValue(CSSValueNormal);
1341 if (length.isPercent())
1342 // This is imperfect, because it doesn't include the zoom factor and the real computation
1343 // for how high to be in pixels does include things like minimum font size and the zoom factor.
1344 // On the other hand, since font-size doesn't include the zoom factor, we really can't do
1345 // that here either.
1346 return zoomAdjustedPixelValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, style);
1347 return zoomAdjustedPixelValue(valueForLength(length, 0, renderView), style);
1350 static PassRefPtr<CSSPrimitiveValue> fontSizeFromStyle(RenderStyle* style)
1352 return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style);
1355 static PassRefPtr<CSSPrimitiveValue> fontStyleFromStyle(RenderStyle* style)
1357 if (style->fontDescription().italic())
1358 return cssValuePool().createIdentifierValue(CSSValueItalic);
1359 return cssValuePool().createIdentifierValue(CSSValueNormal);
1362 static PassRefPtr<CSSPrimitiveValue> fontVariantFromStyle(RenderStyle* style)
1364 if (style->fontDescription().smallCaps())
1365 return cssValuePool().createIdentifierValue(CSSValueSmallCaps);
1366 return cssValuePool().createIdentifierValue(CSSValueNormal);
1369 static PassRefPtr<CSSPrimitiveValue> fontWeightFromStyle(RenderStyle* style)
1371 switch (style->fontDescription().weight()) {
1373 return cssValuePool().createIdentifierValue(CSSValue100);
1375 return cssValuePool().createIdentifierValue(CSSValue200);
1377 return cssValuePool().createIdentifierValue(CSSValue300);
1378 case FontWeightNormal:
1379 return cssValuePool().createIdentifierValue(CSSValueNormal);
1381 return cssValuePool().createIdentifierValue(CSSValue500);
1383 return cssValuePool().createIdentifierValue(CSSValue600);
1384 case FontWeightBold:
1385 return cssValuePool().createIdentifierValue(CSSValueBold);
1387 return cssValuePool().createIdentifierValue(CSSValue800);
1389 return cssValuePool().createIdentifierValue(CSSValue900);
1391 ASSERT_NOT_REACHED();
1392 return cssValuePool().createIdentifierValue(CSSValueNormal);
1395 static bool isLayoutDependentProperty(CSSPropertyID propertyID)
1397 switch (propertyID) {
1398 case CSSPropertyWidth:
1399 case CSSPropertyHeight:
1400 case CSSPropertyMargin:
1401 case CSSPropertyMarginTop:
1402 case CSSPropertyMarginBottom:
1403 case CSSPropertyMarginLeft:
1404 case CSSPropertyMarginRight:
1405 case CSSPropertyPadding:
1406 case CSSPropertyPaddingTop:
1407 case CSSPropertyPaddingBottom:
1408 case CSSPropertyPaddingLeft:
1409 case CSSPropertyPaddingRight:
1410 case CSSPropertyWebkitPerspectiveOrigin:
1411 case CSSPropertyWebkitTransformOrigin:
1412 case CSSPropertyWebkitTransform:
1413 #if ENABLE(CSS_FILTERS)
1414 case CSSPropertyWebkitFilter:
1422 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1424 Node* node = m_node.get();
1429 Document* document = m_node->document();
1430 // FIXME: Some of these cases could be narrowed down or optimized better.
1431 bool forceFullLayout = isLayoutDependentProperty(propertyID)
1432 || node->isInShadowTree()
1433 || (document->styleResolverIfExists() && document->styleResolverIfExists()->hasViewportDependentMediaQueries() && document->ownerElement())
1434 || document->seamlessParentIFrame();
1436 if (forceFullLayout)
1437 document->updateLayoutIgnorePendingStylesheets();
1439 bool needsStyleRecalc = document->hasPendingForcedStyleRecalc();
1440 for (Node* n = m_node.get(); n && !needsStyleRecalc; n = n->parentNode())
1441 needsStyleRecalc = n->needsStyleRecalc();
1442 if (needsStyleRecalc)
1443 document->updateStyleIfNeeded();
1447 RenderObject* renderer = node->renderer();
1449 RefPtr<RenderStyle> style;
1450 if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
1451 AnimationUpdateBlock animationUpdateBlock(renderer->animation());
1452 style = renderer->animation()->getAnimatedStyleForRenderer(renderer);
1453 if (m_pseudoElementSpecifier) {
1454 // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
1455 style = style->getCachedPseudoStyle(m_pseudoElementSpecifier);
1458 style = node->computedStyle(m_pseudoElementSpecifier);
1464 if (m_pseudoElementSpecifier == AFTER)
1465 renderer = renderer->afterPseudoElementRenderer();
1466 else if (m_pseudoElementSpecifier == BEFORE)
1467 renderer = renderer->beforePseudoElementRenderer();
1470 propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction(), style->writingMode());
1472 switch (propertyID) {
1473 case CSSPropertyInvalid:
1474 #if ENABLE(CSS_VARIABLES)
1475 case CSSPropertyVariable:
1479 case CSSPropertyBackgroundColor:
1480 return cssValuePool().createColorValue(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb());
1481 case CSSPropertyBackgroundImage:
1482 case CSSPropertyWebkitMaskImage: {
1483 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskImage ? style->maskLayers() : style->backgroundLayers();
1485 return cssValuePool().createIdentifierValue(CSSValueNone);
1487 if (!layers->next()) {
1488 if (layers->image())
1489 return layers->image()->cssValue();
1491 return cssValuePool().createIdentifierValue(CSSValueNone);
1494 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1495 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1496 if (currLayer->image())
1497 list->append(currLayer->image()->cssValue());
1499 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
1501 return list.release();
1503 case CSSPropertyBackgroundSize:
1504 case CSSPropertyWebkitBackgroundSize:
1505 case CSSPropertyWebkitMaskSize: {
1506 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskSize ? style->maskLayers() : style->backgroundLayers();
1507 if (!layers->next())
1508 return fillSizeToCSSValue(layers->size(), style.get());
1510 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1511 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1512 list->append(fillSizeToCSSValue(currLayer->size(), style.get()));
1514 return list.release();
1516 case CSSPropertyBackgroundRepeat:
1517 case CSSPropertyWebkitMaskRepeat: {
1518 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskRepeat ? style->maskLayers() : style->backgroundLayers();
1519 if (!layers->next())
1520 return fillRepeatToCSSValue(layers->repeatX(), layers->repeatY());
1522 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1523 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1524 list->append(fillRepeatToCSSValue(currLayer->repeatX(), currLayer->repeatY()));
1526 return list.release();
1528 case CSSPropertyWebkitBackgroundComposite:
1529 case CSSPropertyWebkitMaskComposite: {
1530 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskComposite ? style->maskLayers() : style->backgroundLayers();
1531 if (!layers->next())
1532 return cssValuePool().createValue(layers->composite());
1534 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1535 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1536 list->append(cssValuePool().createValue(currLayer->composite()));
1538 return list.release();
1540 case CSSPropertyBackgroundAttachment:
1541 case CSSPropertyWebkitMaskAttachment: {
1542 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskAttachment ? style->maskLayers() : style->backgroundLayers();
1543 if (!layers->next())
1544 return cssValuePool().createValue(layers->attachment());
1546 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1547 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1548 list->append(cssValuePool().createValue(currLayer->attachment()));
1550 return list.release();
1552 case CSSPropertyBackgroundClip:
1553 case CSSPropertyBackgroundOrigin:
1554 case CSSPropertyWebkitBackgroundClip:
1555 case CSSPropertyWebkitBackgroundOrigin:
1556 case CSSPropertyWebkitMaskClip:
1557 case CSSPropertyWebkitMaskOrigin: {
1558 const FillLayer* layers = (propertyID == CSSPropertyWebkitMaskClip || propertyID == CSSPropertyWebkitMaskOrigin) ? style->maskLayers() : style->backgroundLayers();
1559 bool isClip = propertyID == CSSPropertyBackgroundClip || propertyID == CSSPropertyWebkitBackgroundClip || propertyID == CSSPropertyWebkitMaskClip;
1560 if (!layers->next()) {
1561 EFillBox box = isClip ? layers->clip() : layers->origin();
1562 return cssValuePool().createValue(box);
1565 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1566 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1567 EFillBox box = isClip ? currLayer->clip() : currLayer->origin();
1568 list->append(cssValuePool().createValue(box));
1571 return list.release();
1573 case CSSPropertyBackgroundPosition:
1574 case CSSPropertyWebkitMaskPosition: {
1575 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPosition ? style->maskLayers() : style->backgroundLayers();
1576 if (!layers->next()) {
1577 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1578 list->append(zoomAdjustedPixelValueForLength(layers->xPosition(), style.get()));
1579 list->append(zoomAdjustedPixelValueForLength(layers->yPosition(), style.get()));
1580 return list.release();
1583 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1584 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1585 RefPtr<CSSValueList> positionList = CSSValueList::createSpaceSeparated();
1586 positionList->append(zoomAdjustedPixelValueForLength(currLayer->xPosition(), style.get()));
1587 positionList->append(zoomAdjustedPixelValueForLength(currLayer->yPosition(), style.get()));
1588 list->append(positionList);
1591 return list.release();
1593 case CSSPropertyBackgroundPositionX:
1594 case CSSPropertyWebkitMaskPositionX: {
1595 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionX ? style->maskLayers() : style->backgroundLayers();
1596 if (!layers->next())
1597 return cssValuePool().createValue(layers->xPosition());
1599 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1600 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1601 list->append(cssValuePool().createValue(currLayer->xPosition()));
1603 return list.release();
1605 case CSSPropertyBackgroundPositionY:
1606 case CSSPropertyWebkitMaskPositionY: {
1607 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionY ? style->maskLayers() : style->backgroundLayers();
1608 if (!layers->next())
1609 return cssValuePool().createValue(layers->yPosition());
1611 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1612 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1613 list->append(cssValuePool().createValue(currLayer->yPosition()));
1615 return list.release();
1617 case CSSPropertyBorderCollapse:
1618 if (style->borderCollapse())
1619 return cssValuePool().createIdentifierValue(CSSValueCollapse);
1620 return cssValuePool().createIdentifierValue(CSSValueSeparate);
1621 case CSSPropertyBorderSpacing: {
1622 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1623 list->append(zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get()));
1624 list->append(zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get()));
1625 return list.release();
1627 case CSSPropertyWebkitBorderHorizontalSpacing:
1628 return zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get());
1629 case CSSPropertyWebkitBorderVerticalSpacing:
1630 return zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get());
1631 case CSSPropertyBorderImageSource:
1632 if (style->borderImageSource())
1633 return style->borderImageSource()->cssValue();
1634 return cssValuePool().createIdentifierValue(CSSValueNone);
1635 case CSSPropertyBorderTopColor:
1636 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor());
1637 case CSSPropertyBorderRightColor:
1638 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor());
1639 case CSSPropertyBorderBottomColor:
1640 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor());
1641 case CSSPropertyBorderLeftColor:
1642 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor());
1643 case CSSPropertyBorderTopStyle:
1644 return cssValuePool().createValue(style->borderTopStyle());
1645 case CSSPropertyBorderRightStyle:
1646 return cssValuePool().createValue(style->borderRightStyle());
1647 case CSSPropertyBorderBottomStyle:
1648 return cssValuePool().createValue(style->borderBottomStyle());
1649 case CSSPropertyBorderLeftStyle:
1650 return cssValuePool().createValue(style->borderLeftStyle());
1651 case CSSPropertyBorderTopWidth:
1652 return zoomAdjustedPixelValue(style->borderTopWidth(), style.get());
1653 case CSSPropertyBorderRightWidth:
1654 return zoomAdjustedPixelValue(style->borderRightWidth(), style.get());
1655 case CSSPropertyBorderBottomWidth:
1656 return zoomAdjustedPixelValue(style->borderBottomWidth(), style.get());
1657 case CSSPropertyBorderLeftWidth:
1658 return zoomAdjustedPixelValue(style->borderLeftWidth(), style.get());
1659 case CSSPropertyBottom:
1660 return getPositionOffsetValue(style.get(), CSSPropertyBottom, m_node->document()->renderView());
1661 case CSSPropertyWebkitBoxAlign:
1662 return cssValuePool().createValue(style->boxAlign());
1663 #if ENABLE(CSS_BOX_DECORATION_BREAK)
1664 case CSSPropertyWebkitBoxDecorationBreak:
1665 if (style->boxDecorationBreak() == DSLICE)
1666 return cssValuePool().createIdentifierValue(CSSValueSlice);
1667 return cssValuePool().createIdentifierValue(CSSValueClone);
1669 case CSSPropertyWebkitBoxDirection:
1670 return cssValuePool().createValue(style->boxDirection());
1671 case CSSPropertyWebkitBoxFlex:
1672 return cssValuePool().createValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
1673 case CSSPropertyWebkitBoxFlexGroup:
1674 return cssValuePool().createValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
1675 case CSSPropertyWebkitBoxLines:
1676 return cssValuePool().createValue(style->boxLines());
1677 case CSSPropertyWebkitBoxOrdinalGroup:
1678 return cssValuePool().createValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
1679 case CSSPropertyWebkitBoxOrient:
1680 return cssValuePool().createValue(style->boxOrient());
1681 case CSSPropertyWebkitBoxPack:
1682 return cssValuePool().createValue(style->boxPack());
1683 case CSSPropertyWebkitBoxReflect:
1684 return valueForReflection(style->boxReflect(), style.get());
1685 case CSSPropertyBoxShadow:
1686 case CSSPropertyWebkitBoxShadow:
1687 return valueForShadow(style->boxShadow(), propertyID, style.get());
1688 case CSSPropertyCaptionSide:
1689 return cssValuePool().createValue(style->captionSide());
1690 case CSSPropertyClear:
1691 return cssValuePool().createValue(style->clear());
1692 case CSSPropertyColor:
1693 return cssValuePool().createColorValue(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb());
1694 case CSSPropertyWebkitPrintColorAdjust:
1695 return cssValuePool().createValue(style->printColorAdjust());
1696 case CSSPropertyWebkitColumnAxis:
1697 return cssValuePool().createValue(style->columnAxis());
1698 case CSSPropertyWebkitColumnCount:
1699 if (style->hasAutoColumnCount())
1700 return cssValuePool().createIdentifierValue(CSSValueAuto);
1701 return cssValuePool().createValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
1702 case CSSPropertyWebkitColumnGap:
1703 if (style->hasNormalColumnGap())
1704 return cssValuePool().createIdentifierValue(CSSValueNormal);
1705 return zoomAdjustedPixelValue(style->columnGap(), style.get());
1706 case CSSPropertyWebkitColumnProgression:
1707 return cssValuePool().createValue(style->columnProgression());
1708 case CSSPropertyWebkitColumnRuleColor:
1709 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor());
1710 case CSSPropertyWebkitColumnRuleStyle:
1711 return cssValuePool().createValue(style->columnRuleStyle());
1712 case CSSPropertyWebkitColumnRuleWidth:
1713 return zoomAdjustedPixelValue(style->columnRuleWidth(), style.get());
1714 case CSSPropertyWebkitColumnSpan:
1715 if (style->columnSpan())
1716 return cssValuePool().createIdentifierValue(CSSValueAll);
1717 return cssValuePool().createValue(1, CSSPrimitiveValue::CSS_NUMBER);
1718 case CSSPropertyWebkitColumnBreakAfter:
1719 return cssValuePool().createValue(style->columnBreakAfter());
1720 case CSSPropertyWebkitColumnBreakBefore:
1721 return cssValuePool().createValue(style->columnBreakBefore());
1722 case CSSPropertyWebkitColumnBreakInside:
1723 return cssValuePool().createValue(style->columnBreakInside());
1724 case CSSPropertyWebkitColumnWidth:
1725 if (style->hasAutoColumnWidth())
1726 return cssValuePool().createIdentifierValue(CSSValueAuto);
1727 return zoomAdjustedPixelValue(style->columnWidth(), style.get());
1728 case CSSPropertyTabSize:
1729 return cssValuePool().createValue(style->tabSize(), CSSPrimitiveValue::CSS_NUMBER);
1730 #if ENABLE(CSS_REGIONS)
1731 case CSSPropertyWebkitRegionBreakAfter:
1732 return cssValuePool().createValue(style->regionBreakAfter());
1733 case CSSPropertyWebkitRegionBreakBefore:
1734 return cssValuePool().createValue(style->regionBreakBefore());
1735 case CSSPropertyWebkitRegionBreakInside:
1736 return cssValuePool().createValue(style->regionBreakInside());
1738 case CSSPropertyCursor: {
1739 RefPtr<CSSValueList> list;
1740 CursorList* cursors = style->cursors();
1741 if (cursors && cursors->size() > 0) {
1742 list = CSSValueList::createCommaSeparated();
1743 for (unsigned i = 0; i < cursors->size(); ++i)
1744 if (StyleImage* image = cursors->at(i).image())
1745 list->append(image->cssValue());
1747 RefPtr<CSSValue> value = cssValuePool().createValue(style->cursor());
1749 list->append(value);
1750 return list.release();
1752 return value.release();
1754 case CSSPropertyDirection:
1755 return cssValuePool().createValue(style->direction());
1756 case CSSPropertyDisplay:
1757 return cssValuePool().createValue(style->display());
1758 case CSSPropertyEmptyCells:
1759 return cssValuePool().createValue(style->emptyCells());
1760 case CSSPropertyWebkitAlignContent:
1761 return cssValuePool().createValue(style->alignContent());
1762 case CSSPropertyWebkitAlignItems:
1763 return cssValuePool().createValue(style->alignItems());
1764 case CSSPropertyWebkitAlignSelf:
1765 if (style->alignSelf() == AlignAuto) {
1766 if (m_node && m_node->parentNode() && m_node->parentNode()->computedStyle())
1767 return cssValuePool().createValue(m_node->parentNode()->computedStyle()->alignItems());
1768 return cssValuePool().createValue(AlignStretch);
1770 return cssValuePool().createValue(style->alignSelf());
1771 case CSSPropertyWebkitFlex:
1772 return getCSSPropertyValuesForShorthandProperties(webkitFlexShorthand());
1773 case CSSPropertyWebkitFlexBasis:
1774 return cssValuePool().createValue(style->flexBasis());
1775 case CSSPropertyWebkitFlexDirection:
1776 return cssValuePool().createValue(style->flexDirection());
1777 case CSSPropertyWebkitFlexFlow:
1778 return getCSSPropertyValuesForShorthandProperties(webkitFlexFlowShorthand());
1779 case CSSPropertyWebkitFlexGrow:
1780 return cssValuePool().createValue(style->flexGrow());
1781 case CSSPropertyWebkitFlexShrink:
1782 return cssValuePool().createValue(style->flexShrink());
1783 case CSSPropertyWebkitFlexWrap:
1784 return cssValuePool().createValue(style->flexWrap());
1785 case CSSPropertyWebkitJustifyContent:
1786 return cssValuePool().createValue(style->justifyContent());
1787 case CSSPropertyWebkitOrder:
1788 return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
1789 case CSSPropertyFloat:
1790 return cssValuePool().createValue(style->floating());
1791 case CSSPropertyFont: {
1792 RefPtr<FontValue> computedFont = FontValue::create();
1793 computedFont->style = fontStyleFromStyle(style.get());
1794 computedFont->variant = fontVariantFromStyle(style.get());
1795 computedFont->weight = fontWeightFromStyle(style.get());
1796 computedFont->size = fontSizeFromStyle(style.get());
1797 computedFont->lineHeight = lineHeightFromStyle(style.get(), m_node->document()->renderView());
1798 computedFont->family = fontFamilyFromStyle(style.get());
1799 return computedFont.release();
1801 case CSSPropertyFontFamily: {
1802 RefPtr<CSSValueList> fontFamilyList = fontFamilyFromStyle(style.get());
1803 // If there's only a single family, return that as a CSSPrimitiveValue.
1804 // NOTE: Gecko always returns this as a comma-separated CSSPrimitiveValue string.
1805 if (fontFamilyList->length() == 1)
1806 return fontFamilyList->item(0);
1807 return fontFamilyList.release();
1809 case CSSPropertyFontSize:
1810 return fontSizeFromStyle(style.get());
1811 case CSSPropertyFontStyle:
1812 return fontStyleFromStyle(style.get());
1813 case CSSPropertyFontVariant:
1814 return fontVariantFromStyle(style.get());
1815 case CSSPropertyFontWeight:
1816 return fontWeightFromStyle(style.get());
1817 case CSSPropertyWebkitFontFeatureSettings: {
1818 const FontFeatureSettings* featureSettings = style->fontDescription().featureSettings();
1819 if (!featureSettings || !featureSettings->size())
1820 return cssValuePool().createIdentifierValue(CSSValueNormal);
1821 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1822 for (unsigned i = 0; i < featureSettings->size(); ++i) {
1823 const FontFeature& feature = featureSettings->at(i);
1824 RefPtr<FontFeatureValue> featureValue = FontFeatureValue::create(feature.tag(), feature.value());
1825 list->append(featureValue.release());
1827 return list.release();
1829 case CSSPropertyWebkitGridColumns: {
1830 return valueForGridTrackList(style->gridColumns(), style.get());
1832 case CSSPropertyWebkitGridRows: {
1833 return valueForGridTrackList(style->gridRows(), style.get());
1836 case CSSPropertyWebkitGridColumn:
1837 return valueForGridPosition(style->gridItemColumn());
1838 case CSSPropertyWebkitGridRow:
1839 return valueForGridPosition(style->gridItemRow());
1841 case CSSPropertyHeight:
1843 // According to http://www.w3.org/TR/CSS2/visudet.html#the-height-property,
1844 // the "height" property does not apply for non-replaced inline elements.
1845 if (!renderer->isReplaced() && renderer->isInline())
1846 return cssValuePool().createIdentifierValue(CSSValueAuto);
1847 return zoomAdjustedPixelValue(sizingBox(renderer).height(), style.get());
1849 return zoomAdjustedPixelValueForLength(style->height(), style.get());
1850 case CSSPropertyWebkitHighlight:
1851 if (style->highlight() == nullAtom)
1852 return cssValuePool().createIdentifierValue(CSSValueNone);
1853 return cssValuePool().createValue(style->highlight(), CSSPrimitiveValue::CSS_STRING);
1854 case CSSPropertyWebkitHyphens:
1855 return cssValuePool().createValue(style->hyphens());
1856 case CSSPropertyWebkitHyphenateCharacter:
1857 if (style->hyphenationString().isNull())
1858 return cssValuePool().createIdentifierValue(CSSValueAuto);
1859 return cssValuePool().createValue(style->hyphenationString(), CSSPrimitiveValue::CSS_STRING);
1860 case CSSPropertyWebkitHyphenateLimitAfter:
1861 if (style->hyphenationLimitAfter() < 0)
1862 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
1863 return CSSPrimitiveValue::create(style->hyphenationLimitAfter(), CSSPrimitiveValue::CSS_NUMBER);
1864 case CSSPropertyWebkitHyphenateLimitBefore:
1865 if (style->hyphenationLimitBefore() < 0)
1866 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
1867 return CSSPrimitiveValue::create(style->hyphenationLimitBefore(), CSSPrimitiveValue::CSS_NUMBER);
1868 case CSSPropertyWebkitHyphenateLimitLines:
1869 if (style->hyphenationLimitLines() < 0)
1870 return CSSPrimitiveValue::createIdentifier(CSSValueNoLimit);
1871 return CSSPrimitiveValue::create(style->hyphenationLimitLines(), CSSPrimitiveValue::CSS_NUMBER);
1872 case CSSPropertyWebkitBorderFit:
1873 if (style->borderFit() == BorderFitBorder)
1874 return cssValuePool().createIdentifierValue(CSSValueBorder);
1875 return cssValuePool().createIdentifierValue(CSSValueLines);
1876 #if ENABLE(CSS_IMAGE_ORIENTATION)
1877 case CSSPropertyImageOrientation:
1878 return cssValuePool().createValue(style->imageOrientation());
1880 case CSSPropertyImageRendering:
1881 return CSSPrimitiveValue::create(style->imageRendering());
1882 #if ENABLE(CSS_IMAGE_RESOLUTION)
1883 case CSSPropertyImageResolution:
1884 return cssValuePool().createValue(style->imageResolution(), CSSPrimitiveValue::CSS_DPPX);
1886 case CSSPropertyLeft:
1887 return getPositionOffsetValue(style.get(), CSSPropertyLeft, m_node->document()->renderView());
1888 case CSSPropertyLetterSpacing:
1889 if (!style->letterSpacing())
1890 return cssValuePool().createIdentifierValue(CSSValueNormal);
1891 return zoomAdjustedPixelValue(style->letterSpacing(), style.get());
1892 case CSSPropertyWebkitLineClamp:
1893 if (style->lineClamp().isNone())
1894 return cssValuePool().createIdentifierValue(CSSValueNone);
1895 return cssValuePool().createValue(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
1896 case CSSPropertyLineHeight:
1897 return lineHeightFromStyle(style.get(), m_node->document()->renderView());
1898 case CSSPropertyListStyleImage:
1899 if (style->listStyleImage())
1900 return style->listStyleImage()->cssValue();
1901 return cssValuePool().createIdentifierValue(CSSValueNone);
1902 case CSSPropertyListStylePosition:
1903 return cssValuePool().createValue(style->listStylePosition());
1904 case CSSPropertyListStyleType:
1905 return cssValuePool().createValue(style->listStyleType());
1906 case CSSPropertyWebkitLocale:
1907 if (style->locale().isNull())
1908 return cssValuePool().createIdentifierValue(CSSValueAuto);
1909 return cssValuePool().createValue(style->locale(), CSSPrimitiveValue::CSS_STRING);
1910 case CSSPropertyMarginTop: {
1911 Length marginTop = style->marginTop();
1912 if (marginTop.isFixed() || !renderer || !renderer->isBox())
1913 return zoomAdjustedPixelValueForLength(marginTop, style.get());
1914 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginTop(), style.get());
1916 case CSSPropertyMarginRight: {
1917 Length marginRight = style->marginRight();
1918 if (marginRight.isFixed() || !renderer || !renderer->isBox())
1919 return zoomAdjustedPixelValueForLength(marginRight, style.get());
1921 if (marginRight.isPercent() || marginRight.isViewportPercentage())
1922 // RenderBox gives a marginRight() that is the distance between the right-edge of the child box
1923 // and the right-edge of the containing box, when display == BLOCK. Let's calculate the absolute
1924 // value of the specified margin-right % instead of relying on RenderBox's marginRight() value.
1925 value = minimumValueForLength(marginRight, toRenderBox(renderer)->containingBlockLogicalWidthForContent(), m_node->document()->renderView());
1927 value = toRenderBox(renderer)->marginRight();
1928 return zoomAdjustedPixelValue(value, style.get());
1930 case CSSPropertyMarginBottom: {
1931 Length marginBottom = style->marginBottom();
1932 if (marginBottom.isFixed() || !renderer || !renderer->isBox())
1933 return zoomAdjustedPixelValueForLength(marginBottom, style.get());
1934 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginBottom(), style.get());
1936 case CSSPropertyMarginLeft: {
1937 Length marginLeft = style->marginLeft();
1938 if (marginLeft.isFixed() || !renderer || !renderer->isBox())
1939 return zoomAdjustedPixelValueForLength(marginLeft, style.get());
1940 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginLeft(), style.get());
1942 case CSSPropertyWebkitMarqueeDirection:
1943 return cssValuePool().createValue(style->marqueeDirection());
1944 case CSSPropertyWebkitMarqueeIncrement:
1945 return cssValuePool().createValue(style->marqueeIncrement());
1946 case CSSPropertyWebkitMarqueeRepetition:
1947 if (style->marqueeLoopCount() < 0)
1948 return cssValuePool().createIdentifierValue(CSSValueInfinite);
1949 return cssValuePool().createValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
1950 case CSSPropertyWebkitMarqueeStyle:
1951 return cssValuePool().createValue(style->marqueeBehavior());
1952 case CSSPropertyWebkitUserModify:
1953 return cssValuePool().createValue(style->userModify());
1954 case CSSPropertyMaxHeight: {
1955 const Length& maxHeight = style->maxHeight();
1956 if (maxHeight.isUndefined())
1957 return cssValuePool().createIdentifierValue(CSSValueNone);
1958 return zoomAdjustedPixelValueForLength(maxHeight, style.get());
1960 case CSSPropertyMaxWidth: {
1961 const Length& maxWidth = style->maxWidth();
1962 if (maxWidth.isUndefined())
1963 return cssValuePool().createIdentifierValue(CSSValueNone);
1964 return zoomAdjustedPixelValueForLength(maxWidth, style.get());
1966 case CSSPropertyMinHeight:
1967 // FIXME: For flex-items, min-height:auto should compute to min-content.
1968 if (style->minHeight().isAuto())
1969 return zoomAdjustedPixelValue(0, style.get());
1970 return zoomAdjustedPixelValueForLength(style->minHeight(), style.get());
1971 case CSSPropertyMinWidth:
1972 // FIXME: For flex-items, min-width:auto should compute to min-content.
1973 if (style->minWidth().isAuto())
1974 return zoomAdjustedPixelValue(0, style.get());
1975 return zoomAdjustedPixelValueForLength(style->minWidth(), style.get());
1976 case CSSPropertyOpacity:
1977 return cssValuePool().createValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
1978 case CSSPropertyOrphans:
1979 return cssValuePool().createValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
1980 case CSSPropertyOutlineColor:
1981 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor());
1982 case CSSPropertyOutlineOffset:
1983 return zoomAdjustedPixelValue(style->outlineOffset(), style.get());
1984 case CSSPropertyOutlineStyle:
1985 if (style->outlineStyleIsAuto())
1986 return cssValuePool().createIdentifierValue(CSSValueAuto);
1987 return cssValuePool().createValue(style->outlineStyle());
1988 case CSSPropertyOutlineWidth:
1989 return zoomAdjustedPixelValue(style->outlineWidth(), style.get());
1990 case CSSPropertyOverflow:
1991 return cssValuePool().createValue(max(style->overflowX(), style->overflowY()));
1992 case CSSPropertyOverflowWrap:
1993 return cssValuePool().createValue(style->overflowWrap());
1994 case CSSPropertyOverflowX:
1995 return cssValuePool().createValue(style->overflowX());
1996 case CSSPropertyOverflowY:
1997 return cssValuePool().createValue(style->overflowY());
1998 case CSSPropertyPaddingTop:
1999 if (renderer && renderer->isBox())
2000 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingTop(), style.get());
2001 return zoomAdjustedPixelValueForLength(style->paddingTop(), style.get());
2002 case CSSPropertyPaddingRight:
2003 if (renderer && renderer->isBox())
2004 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingRight(), style.get());
2005 return zoomAdjustedPixelValueForLength(style->paddingRight(), style.get());
2006 case CSSPropertyPaddingBottom:
2007 if (renderer && renderer->isBox())
2008 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingBottom(), style.get());
2009 return zoomAdjustedPixelValueForLength(style->paddingBottom(), style.get());
2010 case CSSPropertyPaddingLeft:
2011 if (renderer && renderer->isBox())
2012 return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingLeft(), style.get());
2013 return zoomAdjustedPixelValueForLength(style->paddingLeft(), style.get());
2014 case CSSPropertyPageBreakAfter:
2015 return cssValuePool().createValue(style->pageBreakAfter());
2016 case CSSPropertyPageBreakBefore:
2017 return cssValuePool().createValue(style->pageBreakBefore());
2018 case CSSPropertyPageBreakInside: {
2019 EPageBreak pageBreak = style->pageBreakInside();
2020 ASSERT(pageBreak != PBALWAYS);
2021 if (pageBreak == PBALWAYS)
2023 return cssValuePool().createValue(style->pageBreakInside());
2025 case CSSPropertyPosition:
2026 return cssValuePool().createValue(style->position());
2027 case CSSPropertyRight:
2028 return getPositionOffsetValue(style.get(), CSSPropertyRight, m_node->document()->renderView());
2029 case CSSPropertyTableLayout:
2030 return cssValuePool().createValue(style->tableLayout());
2031 case CSSPropertyTextAlign:
2032 return cssValuePool().createValue(style->textAlign());
2033 case CSSPropertyTextDecoration:
2034 return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2035 #if ENABLE(CSS3_TEXT)
2036 case CSSPropertyWebkitTextDecorationLine:
2037 return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2038 case CSSPropertyWebkitTextDecorationStyle:
2039 return renderTextDecorationStyleFlagsToCSSValue(style->textDecorationStyle());
2040 case CSSPropertyWebkitTextAlignLast:
2041 return cssValuePool().createValue(style->textAlignLast());
2043 case CSSPropertyWebkitTextDecorationsInEffect:
2044 return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect());
2045 case CSSPropertyWebkitTextFillColor:
2046 return currentColorOrValidColor(style.get(), style->textFillColor());
2047 case CSSPropertyWebkitTextEmphasisColor:
2048 return currentColorOrValidColor(style.get(), style->textEmphasisColor());
2049 case CSSPropertyWebkitTextEmphasisPosition:
2050 return cssValuePool().createValue(style->textEmphasisPosition());
2051 case CSSPropertyWebkitTextEmphasisStyle:
2052 switch (style->textEmphasisMark()) {
2053 case TextEmphasisMarkNone:
2054 return cssValuePool().createIdentifierValue(CSSValueNone);
2055 case TextEmphasisMarkCustom:
2056 return cssValuePool().createValue(style->textEmphasisCustomMark(), CSSPrimitiveValue::CSS_STRING);
2057 case TextEmphasisMarkAuto:
2058 ASSERT_NOT_REACHED();
2060 case TextEmphasisMarkDot:
2061 case TextEmphasisMarkCircle:
2062 case TextEmphasisMarkDoubleCircle:
2063 case TextEmphasisMarkTriangle:
2064 case TextEmphasisMarkSesame: {
2065 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2066 list->append(cssValuePool().createValue(style->textEmphasisFill()));
2067 list->append(cssValuePool().createValue(style->textEmphasisMark()));
2068 return list.release();
2071 case CSSPropertyTextIndent:
2072 return zoomAdjustedPixelValueForLength(style->textIndent(), style.get());
2073 case CSSPropertyTextShadow:
2074 return valueForShadow(style->textShadow(), propertyID, style.get());
2075 case CSSPropertyTextRendering:
2076 return cssValuePool().createValue(style->fontDescription().textRenderingMode());
2077 case CSSPropertyTextOverflow:
2078 if (style->textOverflow())
2079 return cssValuePool().createIdentifierValue(CSSValueEllipsis);
2080 return cssValuePool().createIdentifierValue(CSSValueClip);
2081 case CSSPropertyWebkitTextSecurity:
2082 return cssValuePool().createValue(style->textSecurity());
2083 case CSSPropertyWebkitTextSizeAdjust:
2084 if (style->textSizeAdjust())
2085 return cssValuePool().createIdentifierValue(CSSValueAuto);
2086 return cssValuePool().createIdentifierValue(CSSValueNone);
2087 case CSSPropertyWebkitTextStrokeColor:
2088 return currentColorOrValidColor(style.get(), style->textStrokeColor());
2089 case CSSPropertyWebkitTextStrokeWidth:
2090 return zoomAdjustedPixelValue(style->textStrokeWidth(), style.get());
2091 case CSSPropertyTextTransform:
2092 return cssValuePool().createValue(style->textTransform());
2093 case CSSPropertyTop:
2094 return getPositionOffsetValue(style.get(), CSSPropertyTop, m_node->document()->renderView());
2095 case CSSPropertyUnicodeBidi:
2096 return cssValuePool().createValue(style->unicodeBidi());
2097 case CSSPropertyVerticalAlign:
2098 switch (style->verticalAlign()) {
2100 return cssValuePool().createIdentifierValue(CSSValueBaseline);
2102 return cssValuePool().createIdentifierValue(CSSValueMiddle);
2104 return cssValuePool().createIdentifierValue(CSSValueSub);
2106 return cssValuePool().createIdentifierValue(CSSValueSuper);
2108 return cssValuePool().createIdentifierValue(CSSValueTextTop);
2110 return cssValuePool().createIdentifierValue(CSSValueTextBottom);
2112 return cssValuePool().createIdentifierValue(CSSValueTop);
2114 return cssValuePool().createIdentifierValue(CSSValueBottom);
2115 case BASELINE_MIDDLE:
2116 return cssValuePool().createIdentifierValue(CSSValueWebkitBaselineMiddle);
2118 return cssValuePool().createValue(style->verticalAlignLength());
2120 ASSERT_NOT_REACHED();
2122 case CSSPropertyVisibility:
2123 return cssValuePool().createValue(style->visibility());
2124 case CSSPropertyWhiteSpace:
2125 return cssValuePool().createValue(style->whiteSpace());
2126 case CSSPropertyWidows:
2127 return cssValuePool().createValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
2128 case CSSPropertyWidth:
2130 // According to http://www.w3.org/TR/CSS2/visudet.html#the-width-property,
2131 // the "width" property does not apply for non-replaced inline elements.
2132 if (!renderer->isReplaced() && renderer->isInline())
2133 return cssValuePool().createIdentifierValue(CSSValueAuto);
2134 return zoomAdjustedPixelValue(sizingBox(renderer).width(), style.get());
2136 return zoomAdjustedPixelValueForLength(style->width(), style.get());
2137 case CSSPropertyWordBreak:
2138 return cssValuePool().createValue(style->wordBreak());
2139 case CSSPropertyWordSpacing:
2140 return zoomAdjustedPixelValue(style->wordSpacing(), style.get());
2141 case CSSPropertyWordWrap:
2142 return cssValuePool().createValue(style->overflowWrap());
2143 case CSSPropertyWebkitLineBreak:
2144 return cssValuePool().createValue(style->lineBreak());
2145 case CSSPropertyWebkitNbspMode:
2146 return cssValuePool().createValue(style->nbspMode());
2147 case CSSPropertyResize:
2148 return cssValuePool().createValue(style->resize());
2149 case CSSPropertyWebkitFontKerning:
2150 return cssValuePool().createValue(style->fontDescription().kerning());
2151 case CSSPropertyWebkitFontSmoothing:
2152 return cssValuePool().createValue(style->fontDescription().fontSmoothing());
2153 case CSSPropertyWebkitFontVariantLigatures: {
2154 FontDescription::LigaturesState commonLigaturesState = style->fontDescription().commonLigaturesState();
2155 FontDescription::LigaturesState discretionaryLigaturesState = style->fontDescription().discretionaryLigaturesState();
2156 FontDescription::LigaturesState historicalLigaturesState = style->fontDescription().historicalLigaturesState();
2157 if (commonLigaturesState == FontDescription::NormalLigaturesState && discretionaryLigaturesState == FontDescription::NormalLigaturesState
2158 && historicalLigaturesState == FontDescription::NormalLigaturesState)
2159 return cssValuePool().createIdentifierValue(CSSValueNormal);
2161 RefPtr<CSSValueList> valueList = CSSValueList::createSpaceSeparated();
2162 if (commonLigaturesState != FontDescription::NormalLigaturesState)
2163 valueList->append(cssValuePool().createIdentifierValue(commonLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoCommonLigatures : CSSValueCommonLigatures));
2164 if (discretionaryLigaturesState != FontDescription::NormalLigaturesState)
2165 valueList->append(cssValuePool().createIdentifierValue(discretionaryLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoDiscretionaryLigatures : CSSValueDiscretionaryLigatures));
2166 if (historicalLigaturesState != FontDescription::NormalLigaturesState)
2167 valueList->append(cssValuePool().createIdentifierValue(historicalLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoHistoricalLigatures : CSSValueHistoricalLigatures));
2170 case CSSPropertyZIndex:
2171 if (style->hasAutoZIndex())
2172 return cssValuePool().createIdentifierValue(CSSValueAuto);
2173 return cssValuePool().createValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
2174 case CSSPropertyZoom:
2175 return cssValuePool().createValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
2176 case CSSPropertyBoxSizing:
2177 if (style->boxSizing() == CONTENT_BOX)
2178 return cssValuePool().createIdentifierValue(CSSValueContentBox);
2179 return cssValuePool().createIdentifierValue(CSSValueBorderBox);
2180 #if ENABLE(DASHBOARD_SUPPORT)
2181 case CSSPropertyWebkitDashboardRegion:
2183 const Vector<StyleDashboardRegion>& regions = style->dashboardRegions();
2184 unsigned count = regions.size();
2185 if (count == 1 && regions[0].type == StyleDashboardRegion::None)
2186 return cssValuePool().createIdentifierValue(CSSValueNone);
2188 RefPtr<DashboardRegion> firstRegion;
2189 DashboardRegion* previousRegion = 0;
2190 for (unsigned i = 0; i < count; i++) {
2191 RefPtr<DashboardRegion> region = DashboardRegion::create();
2192 StyleDashboardRegion styleRegion = regions[i];
2194 region->m_label = styleRegion.label;
2195 LengthBox offset = styleRegion.offset;
2196 region->setTop(zoomAdjustedPixelValue(offset.top().value(), style.get()));
2197 region->setRight(zoomAdjustedPixelValue(offset.right().value(), style.get()));
2198 region->setBottom(zoomAdjustedPixelValue(offset.bottom().value(), style.get()));
2199 region->setLeft(zoomAdjustedPixelValue(offset.left().value(), style.get()));
2200 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
2201 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
2204 previousRegion->m_next = region;
2206 firstRegion = region;
2207 previousRegion = region.get();
2209 return cssValuePool().createValue(firstRegion.release());
2212 #if ENABLE(DRAGGABLE_REGION)
2213 case CSSPropertyWebkitAppRegion:
2214 return cssValuePool().createIdentifierValue(style->getDraggableRegionMode() == DraggableRegionDrag ? CSSValueDrag : CSSValueNoDrag);
2216 case CSSPropertyWebkitAnimationDelay:
2217 return getDelayValue(style->animations());
2218 case CSSPropertyWebkitAnimationDirection: {
2219 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2220 const AnimationList* t = style->animations();
2222 for (size_t i = 0; i < t->size(); ++i) {
2223 if (t->animation(i)->direction())
2224 list->append(cssValuePool().createIdentifierValue(CSSValueAlternate));
2226 list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2229 list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2230 return list.release();
2232 case CSSPropertyWebkitAnimationDuration:
2233 return getDurationValue(style->animations());
2234 case CSSPropertyWebkitAnimationFillMode: {
2235 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2236 const AnimationList* t = style->animations();
2238 for (size_t i = 0; i < t->size(); ++i) {
2239 switch (t->animation(i)->fillMode()) {
2240 case AnimationFillModeNone:
2241 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2243 case AnimationFillModeForwards:
2244 list->append(cssValuePool().createIdentifierValue(CSSValueForwards));
2246 case AnimationFillModeBackwards:
2247 list->append(cssValuePool().createIdentifierValue(CSSValueBackwards));
2249 case AnimationFillModeBoth:
2250 list->append(cssValuePool().createIdentifierValue(CSSValueBoth));
2255 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2256 return list.release();
2258 case CSSPropertyWebkitAnimationIterationCount: {
2259 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2260 const AnimationList* t = style->animations();
2262 for (size_t i = 0; i < t->size(); ++i) {
2263 double iterationCount = t->animation(i)->iterationCount();
2264 if (iterationCount == Animation::IterationCountInfinite)
2265 list->append(cssValuePool().createIdentifierValue(CSSValueInfinite));
2267 list->append(cssValuePool().createValue(iterationCount, CSSPrimitiveValue::CSS_NUMBER));
2270 list->append(cssValuePool().createValue(Animation::initialAnimationIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
2271 return list.release();
2273 case CSSPropertyWebkitAnimationName: {
2274 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2275 const AnimationList* t = style->animations();
2277 for (size_t i = 0; i < t->size(); ++i)
2278 list->append(cssValuePool().createValue(t->animation(i)->name(), CSSPrimitiveValue::CSS_STRING));
2280 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2281 return list.release();
2283 case CSSPropertyWebkitAnimationPlayState: {
2284 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2285 const AnimationList* t = style->animations();
2287 for (size_t i = 0; i < t->size(); ++i) {
2288 int prop = t->animation(i)->playState();
2289 if (prop == AnimPlayStatePlaying)
2290 list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2292 list->append(cssValuePool().createIdentifierValue(CSSValuePaused));
2295 list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2296 return list.release();
2298 case CSSPropertyWebkitAnimationTimingFunction:
2299 return getTimingFunctionValue(style->animations());
2300 case CSSPropertyWebkitAppearance:
2301 return cssValuePool().createValue(style->appearance());
2302 case CSSPropertyWebkitAspectRatio:
2303 if (!style->hasAspectRatio())
2304 return cssValuePool().createIdentifierValue(CSSValueNone);
2305 return CSSAspectRatioValue::create(style->aspectRatioNumerator(), style->aspectRatioDenominator());
2306 case CSSPropertyWebkitBackfaceVisibility:
2307 return cssValuePool().createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
2308 case CSSPropertyWebkitBorderImage:
2309 return valueForNinePieceImage(style->borderImage());
2310 case CSSPropertyBorderImageOutset:
2311 return valueForNinePieceImageQuad(style->borderImage().outset());
2312 case CSSPropertyBorderImageRepeat:
2313 return valueForNinePieceImageRepeat(style->borderImage());
2314 case CSSPropertyBorderImageSlice:
2315 return valueForNinePieceImageSlice(style->borderImage());
2316 case CSSPropertyBorderImageWidth:
2317 return valueForNinePieceImageQuad(style->borderImage().borderSlices());
2318 case CSSPropertyWebkitMaskBoxImage:
2319 return valueForNinePieceImage(style->maskBoxImage());
2320 case CSSPropertyWebkitMaskBoxImageOutset:
2321 return valueForNinePieceImageQuad(style->maskBoxImage().outset());
2322 case CSSPropertyWebkitMaskBoxImageRepeat:
2323 return valueForNinePieceImageRepeat(style->maskBoxImage());
2324 case CSSPropertyWebkitMaskBoxImageSlice:
2325 return valueForNinePieceImageSlice(style->maskBoxImage());
2326 case CSSPropertyWebkitMaskBoxImageWidth:
2327 return valueForNinePieceImageQuad(style->maskBoxImage().borderSlices());
2328 case CSSPropertyWebkitMaskBoxImageSource:
2329 if (style->maskBoxImageSource())
2330 return style->maskBoxImageSource()->cssValue();
2331 return cssValuePool().createIdentifierValue(CSSValueNone);
2332 case CSSPropertyWebkitFontSizeDelta:
2333 // Not a real style property -- used by the editing engine -- so has no computed value.
2335 case CSSPropertyWebkitMarginBottomCollapse:
2336 case CSSPropertyWebkitMarginAfterCollapse:
2337 return cssValuePool().createValue(style->marginAfterCollapse());
2338 case CSSPropertyWebkitMarginTopCollapse:
2339 case CSSPropertyWebkitMarginBeforeCollapse:
2340 return cssValuePool().createValue(style->marginBeforeCollapse());
2341 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
2342 case CSSPropertyWebkitOverflowScrolling:
2343 if (!style->useTouchOverflowScrolling())
2344 return cssValuePool().createIdentifierValue(CSSValueAuto);
2345 return cssValuePool().createIdentifierValue(CSSValueTouch);
2347 case CSSPropertyWebkitPerspective:
2348 if (!style->hasPerspective())
2349 return cssValuePool().createIdentifierValue(CSSValueNone);
2350 return zoomAdjustedPixelValue(style->perspective(), style.get());
2351 case CSSPropertyWebkitPerspectiveOrigin: {
2352 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2355 if (renderer->isBox())
2356 box = toRenderBox(renderer)->borderBoxRect();
2358 RenderView* renderView = m_node->document()->renderView();
2359 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginX(), box.width(), renderView), style.get()));
2360 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginY(), box.height(), renderView), style.get()));
2363 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginX(), style.get()));
2364 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginY(), style.get()));
2367 return list.release();
2369 case CSSPropertyWebkitRtlOrdering:
2370 return cssValuePool().createIdentifierValue(style->rtlOrdering() ? CSSValueVisual : CSSValueLogical);
2371 #if ENABLE(TOUCH_EVENTS)
2372 case CSSPropertyWebkitTapHighlightColor:
2373 return currentColorOrValidColor(style.get(), style->tapHighlightColor());
2375 case CSSPropertyWebkitUserDrag:
2376 return cssValuePool().createValue(style->userDrag());
2377 case CSSPropertyWebkitUserSelect:
2378 return cssValuePool().createValue(style->userSelect());
2379 case CSSPropertyBorderBottomLeftRadius:
2380 return getBorderRadiusCornerValue(style->borderBottomLeftRadius(), style.get(), m_node->document()->renderView());
2381 case CSSPropertyBorderBottomRightRadius:
2382 return getBorderRadiusCornerValue(style->borderBottomRightRadius(), style.get(), m_node->document()->renderView());
2383 case CSSPropertyBorderTopLeftRadius:
2384 return getBorderRadiusCornerValue(style->borderTopLeftRadius(), style.get(), m_node->document()->renderView());
2385 case CSSPropertyBorderTopRightRadius:
2386 return getBorderRadiusCornerValue(style->borderTopRightRadius(), style.get(), m_node->document()->renderView());
2387 case CSSPropertyClip: {
2388 if (!style->hasClip())
2389 return cssValuePool().createIdentifierValue(CSSValueAuto);
2390 RefPtr<Rect> rect = Rect::create();
2391 rect->setTop(zoomAdjustedPixelValue(style->clip().top().value(), style.get()));
2392 rect->setRight(zoomAdjustedPixelValue(style->clip().right().value(), style.get()));
2393 rect->setBottom(zoomAdjustedPixelValue(style->clip().bottom().value(), style.get()));
2394 rect->setLeft(zoomAdjustedPixelValue(style->clip().left().value(), style.get()));
2395 return cssValuePool().createValue(rect.release());
2397 case CSSPropertySpeak:
2398 return cssValuePool().createValue(style->speak());
2399 case CSSPropertyWebkitTransform:
2400 return computedTransform(renderer, style.get());
2401 case CSSPropertyWebkitTransformOrigin: {
2402 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2405 if (renderer->isBox())
2406 box = toRenderBox(renderer)->borderBoxRect();
2408 RenderView* renderView = m_node->document()->renderView();
2409 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginX(), box.width(), renderView), style.get()));
2410 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginY(), box.height(), renderView), style.get()));
2411 if (style->transformOriginZ() != 0)
2412 list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2414 list->append(zoomAdjustedPixelValueForLength(style->transformOriginX(), style.get()));
2415 list->append(zoomAdjustedPixelValueForLength(style->transformOriginY(), style.get()));
2416 if (style->transformOriginZ() != 0)
2417 list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2419 return list.release();
2421 case CSSPropertyWebkitTransformStyle:
2422 return cssValuePool().createIdentifierValue((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat);
2423 case CSSPropertyWebkitTransitionDelay:
2424 return getDelayValue(style->transitions());
2425 case CSSPropertyWebkitTransitionDuration:
2426 return getDurationValue(style->transitions());
2427 case CSSPropertyWebkitTransitionProperty: {
2428 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2429 const AnimationList* t = style->transitions();
2431 for (size_t i = 0; i < t->size(); ++i) {
2432 RefPtr<CSSValue> propertyValue;
2433 const Animation* animation = t->animation(i);
2434 if (animation->animationMode() == Animation::AnimateNone)
2435 propertyValue = cssValuePool().createIdentifierValue(CSSValueNone);
2436 else if (animation->animationMode() == Animation::AnimateAll)
2437 propertyValue = cssValuePool().createIdentifierValue(CSSValueAll);
2439 propertyValue = cssValuePool().createValue(getPropertyNameString(animation->property()), CSSPrimitiveValue::CSS_STRING);
2440 list->append(propertyValue);
2443 list->append(cssValuePool().createIdentifierValue(CSSValueAll));
2444 return list.release();
2446 case CSSPropertyWebkitTransitionTimingFunction:
2447 return getTimingFunctionValue(style->transitions());
2448 case CSSPropertyPointerEvents:
2449 return cssValuePool().createValue(style->pointerEvents());
2450 case CSSPropertyWebkitColorCorrection:
2451 return cssValuePool().createValue(style->colorSpace());
2452 case CSSPropertyWebkitLineGrid:
2453 if (style->lineGrid().isNull())
2454 return cssValuePool().createIdentifierValue(CSSValueNone);
2455 return cssValuePool().createValue(style->lineGrid(), CSSPrimitiveValue::CSS_STRING);
2456 case CSSPropertyWebkitLineSnap:
2457 return CSSPrimitiveValue::create(style->lineSnap());
2458 case CSSPropertyWebkitLineAlign:
2459 return CSSPrimitiveValue::create(style->lineAlign());
2460 case CSSPropertyWebkitWritingMode:
2461 return cssValuePool().createValue(style->writingMode());
2462 case CSSPropertyWebkitTextCombine:
2463 return cssValuePool().createValue(style->textCombine());
2464 case CSSPropertyWebkitTextOrientation:
2465 return CSSPrimitiveValue::create(style->fontDescription().textOrientation());
2466 case CSSPropertyWebkitLineBoxContain:
2467 return createLineBoxContainValue(style->lineBoxContain());
2468 case CSSPropertyContent:
2469 return contentToCSSValue(style.get());
2470 case CSSPropertyCounterIncrement:
2471 return counterToCSSValue(style.get(), propertyID);
2472 case CSSPropertyCounterReset:
2473 return counterToCSSValue(style.get(), propertyID);
2474 case CSSPropertyWebkitClipPath:
2475 if (ClipPathOperation* operation = style->clipPath()) {
2476 if (operation->getOperationType() == ClipPathOperation::SHAPE)
2477 return valueForBasicShape(static_cast<ShapeClipPathOperation*>(operation)->basicShape());
2479 else if (operation->getOperationType() == ClipPathOperation::REFERENCE) {
2480 ReferenceClipPathOperation* referenceOperation = static_cast<ReferenceClipPathOperation*>(operation);
2481 return CSSPrimitiveValue::create(referenceOperation->url(), CSSPrimitiveValue::CSS_URI);
2485 return cssValuePool().createIdentifierValue(CSSValueNone);
2486 #if ENABLE(CSS_REGIONS)
2487 case CSSPropertyWebkitFlowInto:
2488 if (style->flowThread().isNull())
2489 return cssValuePool().createIdentifierValue(CSSValueNone);
2490 return cssValuePool().createValue(style->flowThread(), CSSPrimitiveValue::CSS_STRING);
2491 case CSSPropertyWebkitFlowFrom:
2492 if (style->regionThread().isNull())
2493 return cssValuePool().createIdentifierValue(CSSValueNone);
2494 return cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING);
2495 case CSSPropertyWebkitRegionOverflow:
2496 return cssValuePool().createValue(style->regionOverflow());
2498 #if ENABLE(CSS_EXCLUSIONS)
2499 case CSSPropertyWebkitWrapFlow:
2500 return cssValuePool().createValue(style->wrapFlow());
2501 case CSSPropertyWebkitShapeMargin:
2502 return cssValuePool().createValue(style->shapeMargin());
2503 case CSSPropertyWebkitShapePadding:
2504 return cssValuePool().createValue(style->shapePadding());
2505 case CSSPropertyWebkitShapeInside:
2506 if (!style->shapeInside())
2507 return cssValuePool().createIdentifierValue(CSSValueAuto);
2508 return valueForBasicShape(style->shapeInside());
2509 case CSSPropertyWebkitShapeOutside:
2510 if (!style->shapeOutside())
2511 return cssValuePool().createIdentifierValue(CSSValueAuto);
2512 return valueForBasicShape(style->shapeOutside());
2513 case CSSPropertyWebkitWrapThrough:
2514 return cssValuePool().createValue(style->wrapThrough());
2516 #if ENABLE(CSS_FILTERS)
2517 case CSSPropertyWebkitFilter:
2518 return valueForFilter(renderer, style.get());
2520 #if ENABLE(CSS_COMPOSITING)
2521 case CSSPropertyWebkitBlendMode:
2522 return cssValuePool().createValue(style->blendMode());
2524 case CSSPropertyBackground:
2525 return getBackgroundShorthandValue();
2526 case CSSPropertyBorder: {
2527 RefPtr<CSSValue> value = getPropertyCSSValue(CSSPropertyBorderTop, DoNotUpdateLayout);
2528 const CSSPropertyID properties[3] = { CSSPropertyBorderRight, CSSPropertyBorderBottom,
2529 CSSPropertyBorderLeft };
2530 for (size_t i = 0; i < WTF_ARRAY_LENGTH(properties); ++i) {
2531 if (value->cssText() != getPropertyCSSValue(properties[i], DoNotUpdateLayout)->cssText())
2534 return value.release();
2536 case CSSPropertyBorderBottom:
2537 return getCSSPropertyValuesForShorthandProperties(borderBottomShorthand());
2538 case CSSPropertyBorderColor:
2539 return getCSSPropertyValuesForSidesShorthand(borderColorShorthand());
2540 case CSSPropertyBorderLeft:
2541 return getCSSPropertyValuesForShorthandProperties(borderLeftShorthand());
2542 case CSSPropertyBorderImage:
2543 return valueForNinePieceImage(style->borderImage());
2544 case CSSPropertyBorderRadius:
2545 return getBorderRadiusShorthandValue(style.get(), m_node->document()->renderView());
2546 case CSSPropertyBorderRight:
2547 return getCSSPropertyValuesForShorthandProperties(borderRightShorthand());
2548 case CSSPropertyBorderStyle:
2549 return getCSSPropertyValuesForSidesShorthand(borderStyleShorthand());
2550 case CSSPropertyBorderTop:
2551 return getCSSPropertyValuesForShorthandProperties(borderTopShorthand());
2552 case CSSPropertyBorderWidth:
2553 return getCSSPropertyValuesForSidesShorthand(borderWidthShorthand());
2554 case CSSPropertyListStyle:
2555 return getCSSPropertyValuesForShorthandProperties(listStyleShorthand());
2556 case CSSPropertyMargin:
2557 return getCSSPropertyValuesForSidesShorthand(marginShorthand());
2558 case CSSPropertyOutline:
2559 return getCSSPropertyValuesForShorthandProperties(outlineShorthand());
2560 case CSSPropertyPadding:
2561 return getCSSPropertyValuesForSidesShorthand(paddingShorthand());
2562 /* Individual properties not part of the spec */
2563 case CSSPropertyBackgroundRepeatX:
2564 case CSSPropertyBackgroundRepeatY:
2567 /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
2568 case CSSPropertyWebkitTextEmphasis:
2569 case CSSPropertyTextLineThrough:
2570 case CSSPropertyTextLineThroughColor:
2571 case CSSPropertyTextLineThroughMode:
2572 case CSSPropertyTextLineThroughStyle:
2573 case CSSPropertyTextLineThroughWidth:
2574 case CSSPropertyTextOverline:
2575 case CSSPropertyTextOverlineColor:
2576 case CSSPropertyTextOverlineMode:
2577 case CSSPropertyTextOverlineStyle:
2578 case CSSPropertyTextOverlineWidth:
2579 case CSSPropertyTextUnderline:
2580 case CSSPropertyTextUnderlineColor:
2581 case CSSPropertyTextUnderlineMode:
2582 case CSSPropertyTextUnderlineStyle:
2583 case CSSPropertyTextUnderlineWidth:
2586 /* Directional properties are resolved by resolveDirectionAwareProperty() before the switch. */
2587 case CSSPropertyWebkitBorderEnd:
2588 case CSSPropertyWebkitBorderEndColor:
2589 case CSSPropertyWebkitBorderEndStyle:
2590 case CSSPropertyWebkitBorderEndWidth:
2591 case CSSPropertyWebkitBorderStart:
2592 case CSSPropertyWebkitBorderStartColor:
2593 case CSSPropertyWebkitBorderStartStyle:
2594 case CSSPropertyWebkitBorderStartWidth:
2595 case CSSPropertyWebkitBorderAfter:
2596 case CSSPropertyWebkitBorderAfterColor:
2597 case CSSPropertyWebkitBorderAfterStyle:
2598 case CSSPropertyWebkitBorderAfterWidth:
2599 case CSSPropertyWebkitBorderBefore:
2600 case CSSPropertyWebkitBorderBeforeColor:
2601 case CSSPropertyWebkitBorderBeforeStyle:
2602 case CSSPropertyWebkitBorderBeforeWidth:
2603 case CSSPropertyWebkitMarginEnd:
2604 case CSSPropertyWebkitMarginStart:
2605 case CSSPropertyWebkitMarginAfter:
2606 case CSSPropertyWebkitMarginBefore:
2607 case CSSPropertyWebkitPaddingEnd:
2608 case CSSPropertyWebkitPaddingStart:
2609 case CSSPropertyWebkitPaddingAfter:
2610 case CSSPropertyWebkitPaddingBefore:
2611 case CSSPropertyWebkitLogicalWidth:
2612 case CSSPropertyWebkitLogicalHeight:
2613 case CSSPropertyWebkitMinLogicalWidth:
2614 case CSSPropertyWebkitMinLogicalHeight:
2615 case CSSPropertyWebkitMaxLogicalWidth:
2616 case CSSPropertyWebkitMaxLogicalHeight:
2617 ASSERT_NOT_REACHED();
2620 /* Unimplemented @font-face properties */
2621 case CSSPropertyFontStretch:
2622 case CSSPropertySrc:
2623 case CSSPropertyUnicodeRange:
2626 /* Other unimplemented properties */
2627 case CSSPropertyPage: // for @page
2628 case CSSPropertyQuotes: // FIXME: needs implementation
2629 case CSSPropertySize: // for @page
2632 /* Unimplemented -webkit- properties */
2633 case CSSPropertyWebkitAnimation:
2634 case CSSPropertyWebkitBorderRadius:
2635 case CSSPropertyWebkitColumns:
2636 case CSSPropertyWebkitColumnRule:
2637 case CSSPropertyWebkitMarginCollapse:
2638 case CSSPropertyWebkitMarquee:
2639 case CSSPropertyWebkitMarqueeSpeed:
2640 case CSSPropertyWebkitMask:
2641 case CSSPropertyWebkitMaskRepeatX:
2642 case CSSPropertyWebkitMaskRepeatY:
2643 case CSSPropertyWebkitPerspectiveOriginX:
2644 case CSSPropertyWebkitPerspectiveOriginY:
2645 case CSSPropertyWebkitTextStroke:
2646 case CSSPropertyWebkitTransformOriginX:
2647 case CSSPropertyWebkitTransformOriginY:
2648 case CSSPropertyWebkitTransformOriginZ:
2649 case CSSPropertyWebkitTransition:
2650 #if ENABLE(CSS_EXCLUSIONS)
2651 case CSSPropertyWebkitWrap:
2655 #if ENABLE(CSS_DEVICE_ADAPTATION)
2656 case CSSPropertyMaxZoom:
2657 case CSSPropertyMinZoom:
2658 case CSSPropertyOrientation:
2659 case CSSPropertyUserZoom:
2664 case CSSPropertyClipPath:
2665 case CSSPropertyClipRule:
2666 case CSSPropertyMask:
2667 case CSSPropertyEnableBackground:
2668 case CSSPropertyFilter:
2669 case CSSPropertyFloodColor:
2670 case CSSPropertyFloodOpacity:
2671 case CSSPropertyLightingColor:
2672 case CSSPropertyStopColor:
2673 case CSSPropertyStopOpacity:
2674 case CSSPropertyColorInterpolation:
2675 case CSSPropertyColorInterpolationFilters:
2676 case CSSPropertyColorProfile:
2677 case CSSPropertyColorRendering:
2678 case CSSPropertyFill:
2679 case CSSPropertyFillOpacity:
2680 case CSSPropertyFillRule:
2681 case CSSPropertyMarker:
2682 case CSSPropertyMarkerEnd:
2683 case CSSPropertyMarkerMid:
2684 case CSSPropertyMarkerStart:
2685 case CSSPropertyMaskType:
2686 case CSSPropertyShapeRendering:
2687 case CSSPropertyStroke:
2688 case CSSPropertyStrokeDasharray:
2689 case CSSPropertyStrokeDashoffset:
2690 case CSSPropertyStrokeLinecap:
2691 case CSSPropertyStrokeLinejoin:
2692 case CSSPropertyStrokeMiterlimit:
2693 case CSSPropertyStrokeOpacity:
2694 case CSSPropertyStrokeWidth:
2695 case CSSPropertyAlignmentBaseline:
2696 case CSSPropertyBaselineShift:
2697 case CSSPropertyDominantBaseline:
2698 case CSSPropertyGlyphOrientationHorizontal:
2699 case CSSPropertyGlyphOrientationVertical:
2700 case CSSPropertyKerning:
2701 case CSSPropertyTextAnchor:
2702 case CSSPropertyVectorEffect:
2703 case CSSPropertyWritingMode:
2704 case CSSPropertyWebkitSvgShadow:
2705 return getSVGPropertyCSSValue(propertyID, DoNotUpdateLayout);
2709 logUnimplementedPropertyID(propertyID);
2713 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) const
2715 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
2717 return value->cssText();
2722 unsigned CSSComputedStyleDeclaration::length() const
2724 Node* node = m_node.get();
2728 RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier);
2732 return numComputedProperties;
2735 String CSSComputedStyleDeclaration::item(unsigned i) const
2740 return getPropertyNameString(computedProperties[i]);
2743 bool CSSComputedStyleDeclaration::cssPropertyMatches(const StylePropertySet::PropertyReference& property) const
2745 if (property.id() == CSSPropertyFontSize && property.value()->isPrimitiveValue() && m_node) {
2746 m_node->document()->updateLayoutIgnorePendingStylesheets();
2747 RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier);
2748 if (style && style->fontDescription().keywordSize()) {
2749 int sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize());
2750 const CSSPrimitiveValue* primitiveValue = static_cast<const CSSPrimitiveValue*>(property.value());
2751 if (primitiveValue->isIdent() && primitiveValue->getIdent() == sizeValue)
2755 RefPtr<CSSValue> value = getPropertyCSSValue(property.id());
2756 return value && value->cssText() == property.value()->cssText();
2759 PassRefPtr<StylePropertySet> CSSComputedStyleDeclaration::copy() const
2761 return copyPropertiesInSet(computedProperties, numComputedProperties);
2764 PassRefPtr<StylePropertySet> CSSComputedStyleDeclaration::makeMutable()
2769 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand& shorthand) const
2771 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2772 for (size_t i = 0; i < shorthand.length(); ++i) {
2773 RefPtr<CSSValue> value = getPropertyCSSValue(shorthand.properties()[i], DoNotUpdateLayout);
2774 list->append(value);
2776 return list.release();
2779 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand& shorthand) const
2781 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2782 // Assume the properties are in the usual order top, right, bottom, left.
2783 RefPtr<CSSValue> topValue = getPropertyCSSValue(shorthand.properties()[0], DoNotUpdateLayout);
2784 RefPtr<CSSValue> rightValue = getPropertyCSSValue(shorthand.properties()[1], DoNotUpdateLayout);
2785 RefPtr<CSSValue> bottomValue = getPropertyCSSValue(shorthand.properties()[2], DoNotUpdateLayout);
2786 RefPtr<CSSValue> leftValue = getPropertyCSSValue(shorthand.properties()[3], DoNotUpdateLayout);
2788 // All 4 properties must be specified.
2789 if (!topValue || !rightValue || !bottomValue || !leftValue)
2792 bool showLeft = rightValue->cssText() != leftValue->cssText();
2793 bool showBottom = (topValue->cssText() != bottomValue->cssText()) || showLeft;
2794 bool showRight = (topValue->cssText() != rightValue->cssText()) || showBottom;
2796 list->append(topValue);
2798 list->append(rightValue);
2800 list->append(bottomValue);
2802 list->append(leftValue);
2804 return list.release();
2807 PassRefPtr<StylePropertySet> CSSComputedStyleDeclaration::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const
2809 Vector<CSSProperty, 256> list;
2810 list.reserveInitialCapacity(length);
2811 for (unsigned i = 0; i < length; ++i) {
2812 RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
2814 list.append(CSSProperty(set[i], value.release(), false));
2816 return StylePropertySet::create(list.data(), list.size());
2819 void CSSComputedStyleDeclaration::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
2821 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
2822 info.addMember(m_node);
2825 CSSRule* CSSComputedStyleDeclaration::parentRule() const
2830 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(const String& propertyName)
2832 CSSPropertyID propertyID = cssPropertyID(propertyName);
2835 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
2836 return value ? value->cloneForCSSOM() : 0;
2839 String CSSComputedStyleDeclaration::getPropertyValue(const String &propertyName)
2841 CSSPropertyID propertyID = cssPropertyID(propertyName);
2844 return getPropertyValue(propertyID);
2847 String CSSComputedStyleDeclaration::getPropertyPriority(const String&)
2849 // All computed styles have a priority of not "important".
2853 String CSSComputedStyleDeclaration::getPropertyShorthand(const String&)
2858 bool CSSComputedStyleDeclaration::isPropertyImplicit(const String&)
2863 void CSSComputedStyleDeclaration::setProperty(const String&, const String&, const String&, ExceptionCode& ec)
2865 ec = NO_MODIFICATION_ALLOWED_ERR;
2868 String CSSComputedStyleDeclaration::removeProperty(const String&, ExceptionCode& ec)
2870 ec = NO_MODIFICATION_ALLOWED_ERR;
2874 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
2876 return getPropertyCSSValue(propertyID);
2879 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
2881 return getPropertyValue(propertyID);
2884 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const String&, bool, ExceptionCode& ec)
2886 ec = NO_MODIFICATION_ALLOWED_ERR;
2889 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getBackgroundShorthandValue() const
2891 static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage,
2892 CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment,
2893 CSSPropertyBackgroundPosition };
2894 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyBackgroundSize, CSSPropertyBackgroundOrigin,
2895 CSSPropertyBackgroundClip };
2897 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
2898 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperator))));
2899 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator))));
2900 return list.release();
2903 } // namespace WebCore