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 "CSSFontFeatureValue.h"
34 #include "CSSFontValue.h"
35 #include "CSSFunctionValue.h"
36 #include "CSSGridTemplateValue.h"
37 #include "CSSLineBoxContainValue.h"
38 #include "CSSParser.h"
39 #include "CSSPrimitiveValue.h"
40 #include "CSSPrimitiveValueMappings.h"
41 #include "CSSPropertyNames.h"
42 #include "CSSReflectValue.h"
43 #include "CSSSelector.h"
44 #include "CSSShadowValue.h"
45 #include "CSSTimingFunctionValue.h"
46 #include "CSSValueList.h"
47 #include "CSSValuePool.h"
48 #include "ContentData.h"
49 #include "CounterContent.h"
50 #include "CursorList.h"
52 #include "ExceptionCode.h"
53 #include "FontFeatureSettings.h"
54 #include "HTMLFrameOwnerElement.h"
56 #include "PseudoElement.h"
58 #include "RenderBox.h"
59 #include "RenderStyle.h"
60 #include "RenderView.h"
61 #include "StyleInheritedData.h"
62 #include "StyleProperties.h"
63 #include "StylePropertyShorthand.h"
64 #include "StyleResolver.h"
65 #include "WebKitCSSTransformValue.h"
66 #include "WebKitFontFamilyNames.h"
67 #include <wtf/text/StringBuilder.h>
69 #if ENABLE(CSS_SHAPES)
70 #include "ShapeValue.h"
73 #if ENABLE(CSS_SHADERS)
74 #include "CustomFilterArrayParameter.h"
75 #include "CustomFilterColorParameter.h"
76 #include "CustomFilterNumberParameter.h"
77 #include "CustomFilterOperation.h"
78 #include "CustomFilterParameter.h"
79 #include "CustomFilterTransformParameter.h"
80 #include "WebKitCSSArrayFunctionValue.h"
81 #include "WebKitCSSMatFunctionValue.h"
82 #include "WebKitCSSMixFunctionValue.h"
85 #if ENABLE(CSS_FILTERS)
86 #include "StyleCustomFilterProgram.h"
87 #include "WebKitCSSFilterValue.h"
90 #if ENABLE(DASHBOARD_SUPPORT)
91 #include "DashboardRegion.h"
96 // List of all properties we know how to compute, omitting shorthands.
97 static const CSSPropertyID computedProperties[] = {
98 CSSPropertyBackgroundAttachment,
99 CSSPropertyBackgroundClip,
100 CSSPropertyBackgroundColor,
101 CSSPropertyBackgroundImage,
102 CSSPropertyBackgroundOrigin,
103 CSSPropertyBackgroundPosition, // more-specific background-position-x/y are non-standard
104 CSSPropertyBackgroundRepeat,
105 CSSPropertyBackgroundSize,
106 CSSPropertyBorderBottomColor,
107 CSSPropertyBorderBottomLeftRadius,
108 CSSPropertyBorderBottomRightRadius,
109 CSSPropertyBorderBottomStyle,
110 CSSPropertyBorderBottomWidth,
111 CSSPropertyBorderCollapse,
112 CSSPropertyBorderImageOutset,
113 CSSPropertyBorderImageRepeat,
114 CSSPropertyBorderImageSlice,
115 CSSPropertyBorderImageSource,
116 CSSPropertyBorderImageWidth,
117 CSSPropertyBorderLeftColor,
118 CSSPropertyBorderLeftStyle,
119 CSSPropertyBorderLeftWidth,
120 CSSPropertyBorderRightColor,
121 CSSPropertyBorderRightStyle,
122 CSSPropertyBorderRightWidth,
123 CSSPropertyBorderTopColor,
124 CSSPropertyBorderTopLeftRadius,
125 CSSPropertyBorderTopRightRadius,
126 CSSPropertyBorderTopStyle,
127 CSSPropertyBorderTopWidth,
129 CSSPropertyBoxShadow,
130 CSSPropertyBoxSizing,
131 CSSPropertyCaptionSide,
136 CSSPropertyDirection,
138 CSSPropertyEmptyCells,
140 CSSPropertyFontFamily,
142 CSSPropertyFontStyle,
143 CSSPropertyFontVariant,
144 CSSPropertyFontWeight,
146 #if ENABLE(CSS_IMAGE_ORIENTATION)
147 CSSPropertyImageOrientation,
149 CSSPropertyImageRendering,
150 #if ENABLE(CSS_IMAGE_RESOLUTION)
151 CSSPropertyImageResolution,
154 CSSPropertyLetterSpacing,
155 CSSPropertyLineHeight,
156 CSSPropertyListStyleImage,
157 CSSPropertyListStylePosition,
158 CSSPropertyListStyleType,
159 CSSPropertyMarginBottom,
160 CSSPropertyMarginLeft,
161 CSSPropertyMarginRight,
162 CSSPropertyMarginTop,
163 CSSPropertyMaxHeight,
165 CSSPropertyMinHeight,
169 CSSPropertyOutlineColor,
170 CSSPropertyOutlineOffset,
171 CSSPropertyOutlineStyle,
172 CSSPropertyOutlineWidth,
173 CSSPropertyOverflowWrap,
174 CSSPropertyOverflowX,
175 CSSPropertyOverflowY,
176 CSSPropertyPaddingBottom,
177 CSSPropertyPaddingLeft,
178 CSSPropertyPaddingRight,
179 CSSPropertyPaddingTop,
180 CSSPropertyPageBreakAfter,
181 CSSPropertyPageBreakBefore,
182 CSSPropertyPageBreakInside,
183 CSSPropertyPointerEvents,
188 CSSPropertyTableLayout,
190 CSSPropertyTextAlign,
191 CSSPropertyTextDecoration,
192 #if ENABLE(CSS3_TEXT)
193 CSSPropertyWebkitTextAlignLast,
194 CSSPropertyWebkitTextJustify,
196 #if ENABLE(CSS3_TEXT_DECORATION)
197 CSSPropertyWebkitTextDecorationLine,
198 CSSPropertyWebkitTextDecorationStyle,
199 CSSPropertyWebkitTextDecorationColor,
200 CSSPropertyWebkitTextDecorationSkip,
201 CSSPropertyWebkitTextUnderlinePosition,
202 #endif // CSS3_TEXT_DECORATION
203 CSSPropertyTextIndent,
204 CSSPropertyTextRendering,
205 CSSPropertyTextShadow,
206 CSSPropertyTextOverflow,
207 CSSPropertyTextTransform,
209 CSSPropertyTransitionDelay,
210 CSSPropertyTransitionDuration,
211 CSSPropertyTransitionProperty,
212 CSSPropertyTransitionTimingFunction,
213 CSSPropertyUnicodeBidi,
214 CSSPropertyVerticalAlign,
215 CSSPropertyVisibility,
216 CSSPropertyWhiteSpace,
219 CSSPropertyWordBreak,
220 CSSPropertyWordSpacing,
225 CSSPropertyWebkitAlt,
226 CSSPropertyWebkitAnimationDelay,
227 CSSPropertyWebkitAnimationDirection,
228 CSSPropertyWebkitAnimationDuration,
229 CSSPropertyWebkitAnimationFillMode,
230 CSSPropertyWebkitAnimationIterationCount,
231 CSSPropertyWebkitAnimationName,
232 CSSPropertyWebkitAnimationPlayState,
233 CSSPropertyWebkitAnimationTimingFunction,
234 CSSPropertyWebkitAppearance,
235 CSSPropertyWebkitBackfaceVisibility,
236 CSSPropertyWebkitBackgroundBlendMode,
237 CSSPropertyWebkitBackgroundClip,
238 CSSPropertyWebkitBackgroundComposite,
239 CSSPropertyWebkitBackgroundOrigin,
240 CSSPropertyWebkitBackgroundSize,
241 #if ENABLE(CSS_COMPOSITING)
242 CSSPropertyWebkitBlendMode,
244 CSSPropertyWebkitBorderFit,
245 CSSPropertyWebkitBorderHorizontalSpacing,
246 CSSPropertyWebkitBorderImage,
247 CSSPropertyWebkitBorderVerticalSpacing,
248 CSSPropertyWebkitBoxAlign,
249 #if ENABLE(CSS_BOX_DECORATION_BREAK)
250 CSSPropertyWebkitBoxDecorationBreak,
252 CSSPropertyWebkitBoxDirection,
253 CSSPropertyWebkitBoxFlex,
254 CSSPropertyWebkitBoxFlexGroup,
255 CSSPropertyWebkitBoxLines,
256 CSSPropertyWebkitBoxOrdinalGroup,
257 CSSPropertyWebkitBoxOrient,
258 CSSPropertyWebkitBoxPack,
259 CSSPropertyWebkitBoxReflect,
260 CSSPropertyWebkitBoxShadow,
261 CSSPropertyWebkitClipPath,
262 CSSPropertyWebkitColorCorrection,
263 CSSPropertyWebkitColumnBreakAfter,
264 CSSPropertyWebkitColumnBreakBefore,
265 CSSPropertyWebkitColumnBreakInside,
266 CSSPropertyWebkitColumnAxis,
267 CSSPropertyWebkitColumnCount,
268 CSSPropertyWebkitColumnGap,
269 CSSPropertyWebkitColumnProgression,
270 CSSPropertyWebkitColumnRuleColor,
271 CSSPropertyWebkitColumnRuleStyle,
272 CSSPropertyWebkitColumnRuleWidth,
273 CSSPropertyWebkitColumnSpan,
274 CSSPropertyWebkitColumnWidth,
275 #if ENABLE(CURSOR_VISIBILITY)
276 CSSPropertyWebkitCursorVisibility,
278 #if ENABLE(DASHBOARD_SUPPORT)
279 CSSPropertyWebkitDashboardRegion,
281 #if ENABLE(CSS_FILTERS)
282 CSSPropertyWebkitFilter,
284 CSSPropertyWebkitAlignContent,
285 CSSPropertyWebkitAlignItems,
286 CSSPropertyWebkitAlignSelf,
287 CSSPropertyWebkitFlexBasis,
288 CSSPropertyWebkitFlexGrow,
289 CSSPropertyWebkitFlexShrink,
290 CSSPropertyWebkitFlexDirection,
291 CSSPropertyWebkitFlexWrap,
292 CSSPropertyWebkitJustifyContent,
293 CSSPropertyWebkitFontKerning,
294 CSSPropertyWebkitFontSmoothing,
295 CSSPropertyWebkitFontVariantLigatures,
296 CSSPropertyWebkitGridAutoColumns,
297 CSSPropertyWebkitGridAutoFlow,
298 CSSPropertyWebkitGridAutoRows,
299 CSSPropertyWebkitGridColumnEnd,
300 CSSPropertyWebkitGridColumnStart,
301 CSSPropertyWebkitGridDefinitionColumns,
302 CSSPropertyWebkitGridDefinitionRows,
303 CSSPropertyWebkitGridRowEnd,
304 CSSPropertyWebkitGridRowStart,
305 CSSPropertyWebkitHighlight,
306 CSSPropertyWebkitHyphenateCharacter,
307 CSSPropertyWebkitHyphenateLimitAfter,
308 CSSPropertyWebkitHyphenateLimitBefore,
309 CSSPropertyWebkitHyphenateLimitLines,
310 CSSPropertyWebkitHyphens,
311 CSSPropertyWebkitLineAlign,
312 CSSPropertyWebkitLineBoxContain,
313 CSSPropertyWebkitLineBreak,
314 CSSPropertyWebkitLineClamp,
315 CSSPropertyWebkitLineGrid,
316 CSSPropertyWebkitLineSnap,
317 CSSPropertyWebkitLocale,
318 CSSPropertyWebkitMarginBeforeCollapse,
319 CSSPropertyWebkitMarginAfterCollapse,
320 CSSPropertyWebkitMarqueeDirection,
321 CSSPropertyWebkitMarqueeIncrement,
322 CSSPropertyWebkitMarqueeRepetition,
323 CSSPropertyWebkitMarqueeStyle,
324 CSSPropertyWebkitMaskBoxImage,
325 CSSPropertyWebkitMaskBoxImageOutset,
326 CSSPropertyWebkitMaskBoxImageRepeat,
327 CSSPropertyWebkitMaskBoxImageSlice,
328 CSSPropertyWebkitMaskBoxImageSource,
329 CSSPropertyWebkitMaskBoxImageWidth,
330 CSSPropertyWebkitMaskClip,
331 CSSPropertyWebkitMaskComposite,
332 CSSPropertyWebkitMaskImage,
333 CSSPropertyWebkitMaskOrigin,
334 CSSPropertyWebkitMaskPosition,
335 CSSPropertyWebkitMaskRepeat,
336 CSSPropertyWebkitMaskSize,
337 CSSPropertyWebkitMaskSourceType,
338 CSSPropertyWebkitNbspMode,
339 CSSPropertyWebkitOrder,
340 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
341 CSSPropertyWebkitOverflowScrolling,
343 CSSPropertyWebkitPerspective,
344 CSSPropertyWebkitPerspectiveOrigin,
345 CSSPropertyWebkitPrintColorAdjust,
346 CSSPropertyWebkitRtlOrdering,
348 CSSPropertyWebkitTouchCallout,
350 #if ENABLE(CSS_SHAPES)
351 CSSPropertyWebkitShapeInside,
352 CSSPropertyWebkitShapeOutside,
354 #if ENABLE(TOUCH_EVENTS)
355 CSSPropertyWebkitTapHighlightColor,
357 CSSPropertyWebkitTextCombine,
358 CSSPropertyWebkitTextDecorationsInEffect,
359 CSSPropertyWebkitTextEmphasisColor,
360 CSSPropertyWebkitTextEmphasisPosition,
361 CSSPropertyWebkitTextEmphasisStyle,
362 CSSPropertyWebkitTextFillColor,
363 CSSPropertyWebkitTextOrientation,
364 CSSPropertyWebkitTextSecurity,
365 #if ENABLE(IOS_TEXT_AUTOSIZING)
366 CSSPropertyWebkitTextSizeAdjust,
368 CSSPropertyWebkitTextStrokeColor,
369 CSSPropertyWebkitTextStrokeWidth,
370 CSSPropertyWebkitTransform,
371 CSSPropertyWebkitTransformOrigin,
372 CSSPropertyWebkitTransformStyle,
373 CSSPropertyWebkitTransitionDelay,
374 CSSPropertyWebkitTransitionDuration,
375 CSSPropertyWebkitTransitionProperty,
376 CSSPropertyWebkitTransitionTimingFunction,
377 CSSPropertyWebkitUserDrag,
378 CSSPropertyWebkitUserModify,
379 CSSPropertyWebkitUserSelect,
380 CSSPropertyWebkitWritingMode,
381 #if ENABLE(CSS_REGIONS)
382 CSSPropertyWebkitFlowInto,
383 CSSPropertyWebkitFlowFrom,
384 CSSPropertyWebkitRegionBreakAfter,
385 CSSPropertyWebkitRegionBreakBefore,
386 CSSPropertyWebkitRegionBreakInside,
387 CSSPropertyWebkitRegionFragment,
389 #if ENABLE(DRAGGABLE_REGION)
390 CSSPropertyWebkitAppRegion,
392 #if ENABLE(CSS_EXCLUSIONS)
393 CSSPropertyWebkitWrapFlow,
394 CSSPropertyWebkitWrapThrough,
396 #if ENABLE(CSS_SHAPES)
397 CSSPropertyWebkitShapeMargin,
398 CSSPropertyWebkitShapePadding,
399 CSSPropertyWebkitShapeImageThreshold,
402 CSSPropertyBufferedRendering,
407 CSSPropertyFloodColor,
408 CSSPropertyFloodOpacity,
409 CSSPropertyLightingColor,
410 CSSPropertyStopColor,
411 CSSPropertyStopOpacity,
412 CSSPropertyColorInterpolation,
413 CSSPropertyColorInterpolationFilters,
414 CSSPropertyColorRendering,
416 CSSPropertyFillOpacity,
418 CSSPropertyMarkerEnd,
419 CSSPropertyMarkerMid,
420 CSSPropertyMarkerStart,
422 CSSPropertyShapeRendering,
424 CSSPropertyStrokeDasharray,
425 CSSPropertyStrokeDashoffset,
426 CSSPropertyStrokeLinecap,
427 CSSPropertyStrokeLinejoin,
428 CSSPropertyStrokeMiterlimit,
429 CSSPropertyStrokeOpacity,
430 CSSPropertyStrokeWidth,
431 CSSPropertyAlignmentBaseline,
432 CSSPropertyBaselineShift,
433 CSSPropertyDominantBaseline,
435 CSSPropertyTextAnchor,
436 CSSPropertyWritingMode,
437 CSSPropertyGlyphOrientationHorizontal,
438 CSSPropertyGlyphOrientationVertical,
439 CSSPropertyWebkitSvgShadow,
440 CSSPropertyVectorEffect
444 const unsigned numComputedProperties = WTF_ARRAY_LENGTH(computedProperties);
446 static CSSValueID valueForRepeatRule(int rule)
449 case RepeatImageRule:
450 return CSSValueRepeat;
452 return CSSValueRound;
454 return CSSValueSpace;
456 return CSSValueStretch;
460 static PassRefPtr<CSSBorderImageSliceValue> valueForNinePieceImageSlice(const NinePieceImage& image)
462 // Create the slices.
463 RefPtr<CSSPrimitiveValue> top;
464 RefPtr<CSSPrimitiveValue> right;
465 RefPtr<CSSPrimitiveValue> bottom;
466 RefPtr<CSSPrimitiveValue> left;
468 if (image.imageSlices().top().isPercent())
469 top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
471 top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_NUMBER);
473 if (image.imageSlices().right() == image.imageSlices().top() && image.imageSlices().bottom() == image.imageSlices().top()
474 && image.imageSlices().left() == image.imageSlices().top()) {
479 if (image.imageSlices().right().isPercent())
480 right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
482 right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_NUMBER);
484 if (image.imageSlices().bottom() == image.imageSlices().top() && image.imageSlices().right() == image.imageSlices().left()) {
488 if (image.imageSlices().bottom().isPercent())
489 bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
491 bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
493 if (image.imageSlices().left() == image.imageSlices().right())
496 if (image.imageSlices().left().isPercent())
497 left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
499 left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_NUMBER);
504 RefPtr<Quad> quad = Quad::create();
506 quad->setRight(right);
507 quad->setBottom(bottom);
510 return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.release()), image.fill());
513 static PassRefPtr<CSSPrimitiveValue> valueForNinePieceImageQuad(const LengthBox& box)
515 // Create the slices.
516 RefPtr<CSSPrimitiveValue> top;
517 RefPtr<CSSPrimitiveValue> right;
518 RefPtr<CSSPrimitiveValue> bottom;
519 RefPtr<CSSPrimitiveValue> left;
521 if (box.top().isRelative())
522 top = cssValuePool().createValue(box.top().value(), CSSPrimitiveValue::CSS_NUMBER);
524 top = cssValuePool().createValue(box.top());
526 if (box.right() == box.top() && box.bottom() == box.top() && box.left() == box.top()) {
531 if (box.right().isRelative())
532 right = cssValuePool().createValue(box.right().value(), CSSPrimitiveValue::CSS_NUMBER);
534 right = cssValuePool().createValue(box.right());
536 if (box.bottom() == box.top() && box.right() == box.left()) {
540 if (box.bottom().isRelative())
541 bottom = cssValuePool().createValue(box.bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
543 bottom = cssValuePool().createValue(box.bottom());
545 if (box.left() == box.right())
548 if (box.left().isRelative())
549 left = cssValuePool().createValue(box.left().value(), CSSPrimitiveValue::CSS_NUMBER);
551 left = cssValuePool().createValue(box.left());
556 RefPtr<Quad> quad = Quad::create();
558 quad->setRight(right);
559 quad->setBottom(bottom);
562 return cssValuePool().createValue(quad.release());
565 static PassRefPtr<CSSValue> valueForNinePieceImageRepeat(const NinePieceImage& image)
567 RefPtr<CSSPrimitiveValue> horizontalRepeat;
568 RefPtr<CSSPrimitiveValue> verticalRepeat;
570 horizontalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.horizontalRule()));
571 if (image.horizontalRule() == image.verticalRule())
572 verticalRepeat = horizontalRepeat;
574 verticalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.verticalRule()));
575 return cssValuePool().createValue(Pair::create(horizontalRepeat.release(), verticalRepeat.release()));
578 static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
580 if (!image.hasImage())
581 return cssValuePool().createIdentifierValue(CSSValueNone);
584 RefPtr<CSSValue> imageValue;
586 imageValue = image.image()->cssValue();
588 // Create the image slice.
589 RefPtr<CSSBorderImageSliceValue> imageSlices = valueForNinePieceImageSlice(image);
591 // Create the border area slices.
592 RefPtr<CSSValue> borderSlices = valueForNinePieceImageQuad(image.borderSlices());
594 // Create the border outset.
595 RefPtr<CSSValue> outset = valueForNinePieceImageQuad(image.outset());
597 // Create the repeat rules.
598 RefPtr<CSSValue> repeat = valueForNinePieceImageRepeat(image);
600 return createBorderImageValue(imageValue.release(), imageSlices.release(), borderSlices.release(), outset.release(), repeat.release());
603 inline static PassRef<CSSPrimitiveValue> zoomAdjustedPixelValue(double value, const RenderStyle* style)
605 return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style), CSSPrimitiveValue::CSS_PX);
608 inline static PassRef<CSSPrimitiveValue> zoomAdjustedNumberValue(double value, const RenderStyle* style)
610 return cssValuePool().createValue(value / style->effectiveZoom(), CSSPrimitiveValue::CSS_NUMBER);
613 static PassRef<CSSValue> zoomAdjustedPixelValueForLength(const Length& length, const RenderStyle* style)
615 if (length.isFixed())
616 return zoomAdjustedPixelValue(length.value(), style);
617 return cssValuePool().createValue(length);
620 static PassRef<CSSValue> valueForReflection(const StyleReflection* reflection, const RenderStyle* style)
623 return cssValuePool().createIdentifierValue(CSSValueNone);
625 RefPtr<CSSPrimitiveValue> offset;
626 if (reflection->offset().isPercent())
627 offset = cssValuePool().createValue(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
629 offset = zoomAdjustedPixelValue(reflection->offset().value(), style);
631 RefPtr<CSSPrimitiveValue> direction;
632 switch (reflection->direction()) {
633 case ReflectionBelow:
634 direction = cssValuePool().createIdentifierValue(CSSValueBelow);
636 case ReflectionAbove:
637 direction = cssValuePool().createIdentifierValue(CSSValueAbove);
640 direction = cssValuePool().createIdentifierValue(CSSValueLeft);
642 case ReflectionRight:
643 direction = cssValuePool().createIdentifierValue(CSSValueRight);
647 return CSSReflectValue::create(direction.release(), offset.release(), valueForNinePieceImage(reflection->mask()));
650 static PassRef<CSSValueList> createPositionListForLayer(CSSPropertyID propertyID, const FillLayer* layer, const RenderStyle* style)
652 auto positionList = CSSValueList::createSpaceSeparated();
653 if (layer->isBackgroundOriginSet()) {
654 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
655 positionList.get().append(cssValuePool().createValue(layer->backgroundXOrigin()));
657 positionList.get().append(zoomAdjustedPixelValueForLength(layer->xPosition(), style));
658 if (layer->isBackgroundOriginSet()) {
659 ASSERT(propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
660 positionList.get().append(cssValuePool().createValue(layer->backgroundYOrigin()));
662 positionList.get().append(zoomAdjustedPixelValueForLength(layer->yPosition(), style));
666 static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, CSSPropertyID propertyID, RenderView* renderView)
672 switch (propertyID) {
673 case CSSPropertyLeft:
676 case CSSPropertyRight:
682 case CSSPropertyBottom:
689 if (style->hasOutOfFlowPosition()) {
690 if (l.type() == WebCore::Fixed)
691 return zoomAdjustedPixelValue(l.value(), style);
692 else if (l.isViewportPercentage())
693 return zoomAdjustedPixelValue(valueForLength(l, 0, renderView), style);
694 return cssValuePool().createValue(l);
697 if (style->hasInFlowPosition()) {
698 // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
699 // In other words if left is auto and right is not auto, then left's computed value is negative right().
700 // So we should get the opposite length unit and see if it is auto.
701 return cssValuePool().createValue(l);
704 return cssValuePool().createIdentifierValue(CSSValueAuto);
707 PassRefPtr<CSSPrimitiveValue> ComputedStyleExtractor::currentColorOrValidColor(RenderStyle* style, const Color& color) const
709 // This function does NOT look at visited information, so that computed style doesn't expose that.
710 if (!color.isValid())
711 return cssValuePool().createColorValue(style->color().rgb());
712 return cssValuePool().createColorValue(color.rgb());
715 static PassRef<CSSValueList> getBorderRadiusCornerValues(const LengthSize& radius, const RenderStyle* style, RenderView* renderView)
717 auto list = CSSValueList::createSpaceSeparated();
718 if (radius.width().type() == Percent)
719 list.get().append(cssValuePool().createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
721 list.get().append(zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style));
722 if (radius.height().type() == Percent)
723 list.get().append(cssValuePool().createValue(radius.height().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
725 list.get().append(zoomAdjustedPixelValue(valueForLength(radius.height(), 0, renderView), style));
729 static PassRef<CSSValue> getBorderRadiusCornerValue(const LengthSize& radius, const RenderStyle* style, RenderView* renderView)
731 if (radius.width() == radius.height()) {
732 if (radius.width().type() == Percent)
733 return cssValuePool().createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
734 return zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style);
736 return getBorderRadiusCornerValues(radius, style, renderView);
739 static PassRef<CSSValueList> getBorderRadiusShorthandValue(const RenderStyle* style, RenderView* renderView)
741 auto list = CSSValueList::createSlashSeparated();
742 bool showHorizontalBottomLeft = style->borderTopRightRadius().width() != style->borderBottomLeftRadius().width();
743 bool showHorizontalBottomRight = showHorizontalBottomLeft || (style->borderBottomRightRadius().width() != style->borderTopLeftRadius().width());
744 bool showHorizontalTopRight = showHorizontalBottomRight || (style->borderTopRightRadius().width() != style->borderTopLeftRadius().width());
746 bool showVerticalBottomLeft = style->borderTopRightRadius().height() != style->borderBottomLeftRadius().height();
747 bool showVerticalBottomRight = showVerticalBottomLeft || (style->borderBottomRightRadius().height() != style->borderTopLeftRadius().height());
748 bool showVerticalTopRight = showVerticalBottomRight || (style->borderTopRightRadius().height() != style->borderTopLeftRadius().height());
750 RefPtr<CSSValueList> topLeftRadius = getBorderRadiusCornerValues(style->borderTopLeftRadius(), style, renderView);
751 RefPtr<CSSValueList> topRightRadius = getBorderRadiusCornerValues(style->borderTopRightRadius(), style, renderView);
752 RefPtr<CSSValueList> bottomRightRadius = getBorderRadiusCornerValues(style->borderBottomRightRadius(), style, renderView);
753 RefPtr<CSSValueList> bottomLeftRadius = getBorderRadiusCornerValues(style->borderBottomLeftRadius(), style, renderView);
755 RefPtr<CSSValueList> horizontalRadii = CSSValueList::createSpaceSeparated();
756 horizontalRadii->append(topLeftRadius->item(0));
757 if (showHorizontalTopRight)
758 horizontalRadii->append(topRightRadius->item(0));
759 if (showHorizontalBottomRight)
760 horizontalRadii->append(bottomRightRadius->item(0));
761 if (showHorizontalBottomLeft)
762 horizontalRadii->append(bottomLeftRadius->item(0));
764 list.get().append(horizontalRadii.release());
766 RefPtr<CSSValueList> verticalRadiiList = CSSValueList::createSpaceSeparated();
767 verticalRadiiList->append(topLeftRadius->item(1));
768 if (showVerticalTopRight)
769 verticalRadiiList->append(topRightRadius->item(1));
770 if (showVerticalBottomRight)
771 verticalRadiiList->append(bottomRightRadius->item(1));
772 if (showVerticalBottomLeft)
773 verticalRadiiList->append(bottomLeftRadius->item(1));
775 if (!verticalRadiiList->equals(*toCSSValueList(list.get().item(0))))
776 list.get().append(verticalRadiiList.release());
781 static LayoutRect sizingBox(RenderObject* renderer)
783 if (!renderer->isBox())
786 RenderBox* box = toRenderBox(renderer);
787 return box->style().boxSizing() == BORDER_BOX ? box->borderBoxRect() : box->computedCSSContentBoxRect();
790 static PassRef<WebKitCSSTransformValue> matrixTransformValue(const TransformationMatrix& transform, const RenderStyle* style)
792 RefPtr<WebKitCSSTransformValue> transformValue;
793 if (transform.isAffine()) {
794 transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::MatrixTransformOperation);
796 transformValue->append(cssValuePool().createValue(transform.a(), CSSPrimitiveValue::CSS_NUMBER));
797 transformValue->append(cssValuePool().createValue(transform.b(), CSSPrimitiveValue::CSS_NUMBER));
798 transformValue->append(cssValuePool().createValue(transform.c(), CSSPrimitiveValue::CSS_NUMBER));
799 transformValue->append(cssValuePool().createValue(transform.d(), CSSPrimitiveValue::CSS_NUMBER));
800 transformValue->append(zoomAdjustedNumberValue(transform.e(), style));
801 transformValue->append(zoomAdjustedNumberValue(transform.f(), style));
803 transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::Matrix3DTransformOperation);
805 transformValue->append(cssValuePool().createValue(transform.m11(), CSSPrimitiveValue::CSS_NUMBER));
806 transformValue->append(cssValuePool().createValue(transform.m12(), CSSPrimitiveValue::CSS_NUMBER));
807 transformValue->append(cssValuePool().createValue(transform.m13(), CSSPrimitiveValue::CSS_NUMBER));
808 transformValue->append(cssValuePool().createValue(transform.m14(), CSSPrimitiveValue::CSS_NUMBER));
810 transformValue->append(cssValuePool().createValue(transform.m21(), CSSPrimitiveValue::CSS_NUMBER));
811 transformValue->append(cssValuePool().createValue(transform.m22(), CSSPrimitiveValue::CSS_NUMBER));
812 transformValue->append(cssValuePool().createValue(transform.m23(), CSSPrimitiveValue::CSS_NUMBER));
813 transformValue->append(cssValuePool().createValue(transform.m24(), CSSPrimitiveValue::CSS_NUMBER));
815 transformValue->append(cssValuePool().createValue(transform.m31(), CSSPrimitiveValue::CSS_NUMBER));
816 transformValue->append(cssValuePool().createValue(transform.m32(), CSSPrimitiveValue::CSS_NUMBER));
817 transformValue->append(cssValuePool().createValue(transform.m33(), CSSPrimitiveValue::CSS_NUMBER));
818 transformValue->append(cssValuePool().createValue(transform.m34(), CSSPrimitiveValue::CSS_NUMBER));
820 transformValue->append(zoomAdjustedNumberValue(transform.m41(), style));
821 transformValue->append(zoomAdjustedNumberValue(transform.m42(), style));
822 transformValue->append(zoomAdjustedNumberValue(transform.m43(), style));
823 transformValue->append(cssValuePool().createValue(transform.m44(), CSSPrimitiveValue::CSS_NUMBER));
826 return transformValue.releaseNonNull();
829 static PassRef<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle* style)
831 if (!renderer || !renderer->hasTransform() || !style->hasTransform())
832 return cssValuePool().createIdentifierValue(CSSValueNone);
835 if (renderer->isBox())
836 box = pixelSnappedIntRect(toRenderBox(renderer)->borderBoxRect());
838 TransformationMatrix transform;
839 style->applyTransform(transform, box.size(), RenderStyle::ExcludeTransformOrigin);
840 // Note that this does not flatten to an affine transform if ENABLE(3D_RENDERING) is off, by design.
842 // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
843 auto list = CSSValueList::createSpaceSeparated();
844 list.get().append(matrixTransformValue(transform, style));
845 return std::move(list);
848 #if ENABLE(CSS_SHADERS)
849 static PassRef<WebKitCSSArrayFunctionValue> valueForCustomFilterArrayParameter(const CustomFilterArrayParameter* arrayParameter)
851 auto arrayParameterValue = WebKitCSSArrayFunctionValue::create();
852 for (unsigned i = 0, size = arrayParameter->size(); i < size; ++i)
853 arrayParameterValue.get().append(cssValuePool().createValue(arrayParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
854 return arrayParameterValue;
857 static PassRef<WebKitCSSMatFunctionValue> valueForCustomFilterMatParameter(const CustomFilterArrayParameter* matrixParameter)
859 auto matrixParameterValue = WebKitCSSMatFunctionValue::create();
860 for (unsigned i = 0, size = matrixParameter->size(); i < size; ++i)
861 matrixParameterValue.get().append(cssValuePool().createValue(matrixParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
862 return matrixParameterValue;
865 static PassRef<CSSValueList> valueForCustomFilterColorParameter(const CustomFilterColorParameter* colorParameter)
867 auto colorParameterValue = CSSValueList::createSpaceSeparated();
868 colorParameterValue.get().append(cssValuePool().createColorValue(colorParameter->color().rgb()));
869 return colorParameterValue;
872 static PassRef<CSSValueList> valueForCustomFilterNumberParameter(const CustomFilterNumberParameter* numberParameter)
874 auto numberParameterValue = CSSValueList::createSpaceSeparated();
875 for (unsigned i = 0; i < numberParameter->size(); ++i)
876 numberParameterValue.get().append(cssValuePool().createValue(numberParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
877 return numberParameterValue;
880 static PassRef<WebKitCSSTransformValue> valueForCustomFilterTransformParameter(const RenderObject* renderer, const RenderStyle* style, const CustomFilterTransformParameter* transformParameter)
883 if (renderer && renderer->isBox())
884 size = pixelSnappedIntRect(toRenderBox(renderer)->borderBoxRect()).size();
886 TransformationMatrix transform;
887 transformParameter->applyTransform(transform, size);
888 // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
889 return matrixTransformValue(transform, style);
892 static PassRefPtr<CSSValue> valueForCustomFilterParameter(const RenderObject* renderer, const RenderStyle* style, const CustomFilterParameter* parameter)
894 // FIXME: Add here computed style for the other types: boolean, transform, matrix, texture.
896 switch (parameter->parameterType()) {
897 case CustomFilterParameter::ARRAY:
898 return valueForCustomFilterArrayParameter(static_cast<const CustomFilterArrayParameter*>(parameter));
899 case CustomFilterParameter::COLOR:
900 return valueForCustomFilterColorParameter(static_cast<const CustomFilterColorParameter*>(parameter));
901 case CustomFilterParameter::MATRIX:
902 return valueForCustomFilterMatParameter(static_cast<const CustomFilterArrayParameter*>(parameter));
903 case CustomFilterParameter::NUMBER:
904 return valueForCustomFilterNumberParameter(static_cast<const CustomFilterNumberParameter*>(parameter));
905 case CustomFilterParameter::TRANSFORM:
906 return valueForCustomFilterTransformParameter(renderer, style, static_cast<const CustomFilterTransformParameter*>(parameter));
909 ASSERT_NOT_REACHED();
912 #endif // ENABLE(CSS_SHADERS)
914 static inline PassRef<CSSPrimitiveValue> adjustLengthForZoom(double length, const RenderStyle* style, AdjustPixelValuesForComputedStyle adjust)
916 return adjust == AdjustPixelValues ? zoomAdjustedPixelValue(length, style) : cssValuePool().createValue(length, CSSPrimitiveValue::CSS_PX);
919 static inline PassRef<CSSPrimitiveValue> adjustLengthForZoom(const Length& length, const RenderStyle* style, AdjustPixelValuesForComputedStyle adjust)
921 return adjust == AdjustPixelValues ? zoomAdjustedPixelValue(length.value(), style) : cssValuePool().createValue(length);
924 PassRefPtr<CSSValue> ComputedStyleExtractor::valueForShadow(const ShadowData* shadow, CSSPropertyID propertyID, const RenderStyle* style, AdjustPixelValuesForComputedStyle adjust)
927 return cssValuePool().createIdentifierValue(CSSValueNone);
929 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
930 for (const ShadowData* currShadowData = shadow; currShadowData; currShadowData = currShadowData->next()) {
931 RefPtr<CSSPrimitiveValue> x = adjustLengthForZoom(currShadowData->x(), style, adjust);
932 RefPtr<CSSPrimitiveValue> y = adjustLengthForZoom(currShadowData->y(), style, adjust);
933 RefPtr<CSSPrimitiveValue> blur = adjustLengthForZoom(currShadowData->radius(), style, adjust);
934 RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? PassRefPtr<CSSPrimitiveValue>() : adjustLengthForZoom(currShadowData->spread(), style, adjust);
935 RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || currShadowData->style() == Normal ? PassRefPtr<CSSPrimitiveValue>() : cssValuePool().createIdentifierValue(CSSValueInset);
936 RefPtr<CSSPrimitiveValue> color = cssValuePool().createColorValue(currShadowData->color().rgb());
937 list->prepend(CSSShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release()));
939 return list.release();
942 #if ENABLE(CSS_FILTERS)
943 PassRef<CSSValue> ComputedStyleExtractor::valueForFilter(const RenderObject* renderer, const RenderStyle* style, const FilterOperations& filterOperations, AdjustPixelValuesForComputedStyle adjust)
945 #if !ENABLE(CSS_SHADERS)
946 UNUSED_PARAM(renderer);
948 if (filterOperations.operations().isEmpty())
949 return cssValuePool().createIdentifierValue(CSSValueNone);
951 auto list = CSSValueList::createSpaceSeparated();
953 RefPtr<WebKitCSSFilterValue> filterValue;
955 Vector<RefPtr<FilterOperation>>::const_iterator end = filterOperations.operations().end();
956 for (Vector<RefPtr<FilterOperation>>::const_iterator it = filterOperations.operations().begin(); it != end; ++it) {
957 FilterOperation* filterOperation = (*it).get();
958 switch (filterOperation->type()) {
959 case FilterOperation::REFERENCE: {
960 ReferenceFilterOperation* referenceOperation = static_cast<ReferenceFilterOperation*>(filterOperation);
961 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ReferenceFilterOperation);
962 filterValue->append(cssValuePool().createValue(referenceOperation->url(), CSSPrimitiveValue::CSS_STRING));
965 case FilterOperation::GRAYSCALE: {
966 BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
967 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::GrayscaleFilterOperation);
968 filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
971 case FilterOperation::SEPIA: {
972 BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
973 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SepiaFilterOperation);
974 filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
977 case FilterOperation::SATURATE: {
978 BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
979 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SaturateFilterOperation);
980 filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
983 case FilterOperation::HUE_ROTATE: {
984 BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
985 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::HueRotateFilterOperation);
986 filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_DEG));
989 case FilterOperation::INVERT: {
990 BasicComponentTransferFilterOperation* componentTransferOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
991 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::InvertFilterOperation);
992 filterValue->append(cssValuePool().createValue(componentTransferOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
995 case FilterOperation::OPACITY: {
996 BasicComponentTransferFilterOperation* componentTransferOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
997 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::OpacityFilterOperation);
998 filterValue->append(cssValuePool().createValue(componentTransferOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
1001 case FilterOperation::BRIGHTNESS: {
1002 BasicComponentTransferFilterOperation* brightnessOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
1003 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BrightnessFilterOperation);
1004 filterValue->append(cssValuePool().createValue(brightnessOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
1007 case FilterOperation::CONTRAST: {
1008 BasicComponentTransferFilterOperation* contrastOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
1009 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ContrastFilterOperation);
1010 filterValue->append(cssValuePool().createValue(contrastOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
1013 case FilterOperation::BLUR: {
1014 BlurFilterOperation* blurOperation = static_cast<BlurFilterOperation*>(filterOperation);
1015 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BlurFilterOperation);
1016 filterValue->append(adjustLengthForZoom(blurOperation->stdDeviation(), style, adjust));
1019 case FilterOperation::DROP_SHADOW: {
1020 DropShadowFilterOperation* dropShadowOperation = static_cast<DropShadowFilterOperation*>(filterOperation);
1021 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::DropShadowFilterOperation);
1022 // We want our computed style to look like that of a text shadow (has neither spread nor inset style).
1023 ShadowData shadowData = ShadowData(dropShadowOperation->location(), dropShadowOperation->stdDeviation(), 0, Normal, false, dropShadowOperation->color());
1024 filterValue->append(valueForShadow(&shadowData, CSSPropertyTextShadow, style, adjust));
1027 #if ENABLE(CSS_SHADERS)
1028 case FilterOperation::VALIDATED_CUSTOM:
1029 // ValidatedCustomFilterOperation is not supposed to end up in the RenderStyle.
1030 ASSERT_NOT_REACHED();
1032 case FilterOperation::CUSTOM: {
1033 CustomFilterOperation* customOperation = static_cast<CustomFilterOperation*>(filterOperation);
1034 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::CustomFilterOperation);
1036 // The output should be verbose, even if the values are the default ones.
1038 ASSERT(customOperation->program());
1039 StyleCustomFilterProgram* program = static_cast<StyleCustomFilterProgram*>(customOperation->program());
1041 RefPtr<CSSValueList> shadersList = CSSValueList::createSpaceSeparated();
1042 if (program->vertexShader())
1043 shadersList->append(program->vertexShader()->cssValue());
1045 shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone));
1047 const CustomFilterProgramMixSettings mixSettings = program->mixSettings();
1048 if (program->fragmentShader()) {
1049 if (program->programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE) {
1050 RefPtr<WebKitCSSMixFunctionValue> mixFunction = WebKitCSSMixFunctionValue::create();
1051 mixFunction->append(program->fragmentShader()->cssValue());
1052 mixFunction->append(cssValuePool().createValue(mixSettings.blendMode));
1053 mixFunction->append(cssValuePool().createValue(mixSettings.compositeOperator));
1054 shadersList->append(mixFunction.release());
1056 shadersList->append(program->fragmentShader()->cssValue());
1059 shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone));
1061 filterValue->append(shadersList.release());
1063 RefPtr<CSSValueList> meshParameters = CSSValueList::createSpaceSeparated();
1064 meshParameters->append(cssValuePool().createValue(customOperation->meshColumns(), CSSPrimitiveValue::CSS_NUMBER));
1065 meshParameters->append(cssValuePool().createValue(customOperation->meshRows(), CSSPrimitiveValue::CSS_NUMBER));
1067 // FIXME: The specification doesn't have any "attached" identifier. Should we add one?
1068 // https://bugs.webkit.org/show_bug.cgi?id=72700
1069 if (customOperation->meshType() == MeshTypeDetached)
1070 meshParameters->append(cssValuePool().createIdentifierValue(CSSValueDetached));
1072 filterValue->append(meshParameters.release());
1074 const CustomFilterParameterList& parameters = customOperation->parameters();
1075 size_t parametersSize = parameters.size();
1076 if (!parametersSize)
1078 RefPtr<CSSValueList> parametersCSSValue = CSSValueList::createCommaSeparated();
1079 for (size_t i = 0; i < parametersSize; ++i) {
1080 const CustomFilterParameter* parameter = parameters.at(i).get();
1081 RefPtr<CSSValueList> parameterCSSNameAndValue = CSSValueList::createSpaceSeparated();
1082 parameterCSSNameAndValue->append(cssValuePool().createValue(parameter->name(), CSSPrimitiveValue::CSS_STRING));
1083 parameterCSSNameAndValue->append(valueForCustomFilterParameter(renderer, style, parameter));
1084 parametersCSSValue->append(parameterCSSNameAndValue.release());
1087 filterValue->append(parametersCSSValue.release());
1092 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::UnknownFilterOperation);
1095 list.get().append(filterValue.release());
1098 return std::move(list);
1102 static PassRef<CSSValue> valueForGridTrackBreadth(const GridLength& trackBreadth, const RenderStyle* style, RenderView* renderView)
1104 if (!trackBreadth.isLength())
1105 return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue::CSS_FR);
1107 const Length& trackBreadthLength = trackBreadth.length();
1108 if (trackBreadthLength.isAuto())
1109 return cssValuePool().createIdentifierValue(CSSValueAuto);
1110 if (trackBreadthLength.isViewportPercentage())
1111 return zoomAdjustedPixelValue(valueForLength(trackBreadthLength, 0, renderView), style);
1112 return zoomAdjustedPixelValueForLength(trackBreadthLength, style);
1115 static PassRefPtr<CSSValue> valueForGridTrackSize(const GridTrackSize& trackSize, const RenderStyle* style, RenderView* renderView)
1117 switch (trackSize.type()) {
1118 case LengthTrackSizing:
1119 return valueForGridTrackBreadth(trackSize.length(), style, renderView);
1120 case MinMaxTrackSizing:
1121 RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSeparated();
1122 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.minTrackBreadth(), style, renderView));
1123 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.maxTrackBreadth(), style, renderView));
1124 return CSSFunctionValue::create("minmax(", minMaxTrackBreadths);
1126 ASSERT_NOT_REACHED();
1130 static void addValuesForNamedGridLinesAtIndex(const NamedGridLinesMap& namedGridLines, size_t i, CSSValueList& list)
1132 // Note that this won't return the results in the order specified in the style sheet,
1133 // which is probably fine as we still *do* return all the expected values.
1134 NamedGridLinesMap::const_iterator it = namedGridLines.begin();
1135 NamedGridLinesMap::const_iterator end = namedGridLines.end();
1136 for (; it != end; ++it) {
1137 const Vector<size_t>& linesIndexes = it->value;
1138 for (size_t j = 0; j < linesIndexes.size(); ++j) {
1139 if (linesIndexes[j] != i)
1142 list.append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
1148 static PassRef<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& trackSizes, const NamedGridLinesMap& namedGridLines, const RenderStyle* style, RenderView* renderView)
1150 // Handle the 'none' case here.
1151 if (!trackSizes.size()) {
1152 ASSERT(namedGridLines.isEmpty());
1153 return cssValuePool().createIdentifierValue(CSSValueNone);
1156 auto list = CSSValueList::createSpaceSeparated();
1157 for (size_t i = 0; i < trackSizes.size(); ++i) {
1158 addValuesForNamedGridLinesAtIndex(namedGridLines, i, list.get());
1159 list.get().append(valueForGridTrackSize(trackSizes[i], style, renderView));
1161 // Those are the trailing <string>* allowed in the syntax.
1162 addValuesForNamedGridLinesAtIndex(namedGridLines, trackSizes.size(), list.get());
1163 return std::move(list);
1166 static PassRef<CSSValue> valueForGridPosition(const GridPosition& position)
1168 if (position.isAuto())
1169 return cssValuePool().createIdentifierValue(CSSValueAuto);
1171 if (position.isNamedGridArea())
1172 return cssValuePool().createValue(position.namedGridLine(), CSSPrimitiveValue::CSS_STRING);
1174 auto list = CSSValueList::createSpaceSeparated();
1175 if (position.isSpan()) {
1176 list.get().append(cssValuePool().createIdentifierValue(CSSValueSpan));
1177 list.get().append(cssValuePool().createValue(position.spanPosition(), CSSPrimitiveValue::CSS_NUMBER));
1179 list.get().append(cssValuePool().createValue(position.integerPosition(), CSSPrimitiveValue::CSS_NUMBER));
1181 if (!position.namedGridLine().isNull())
1182 list.get().append(cssValuePool().createValue(position.namedGridLine(), CSSPrimitiveValue::CSS_STRING));
1183 return std::move(list);
1186 static PassRef<CSSValue> createTransitionPropertyValue(const Animation& animation)
1188 if (animation.animationMode() == Animation::AnimateNone)
1189 return cssValuePool().createIdentifierValue(CSSValueNone);
1190 if (animation.animationMode() == Animation::AnimateAll)
1191 return cssValuePool().createIdentifierValue(CSSValueAll);
1192 return cssValuePool().createValue(getPropertyNameString(animation.property()), CSSPrimitiveValue::CSS_STRING);
1195 static PassRef<CSSValueList> getTransitionPropertyValue(const AnimationList* animList)
1197 auto list = CSSValueList::createCommaSeparated();
1199 for (size_t i = 0; i < animList->size(); ++i)
1200 list.get().append(createTransitionPropertyValue(animList->animation(i)));
1202 list.get().append(cssValuePool().createIdentifierValue(CSSValueAll));
1206 static PassRef<CSSValueList> getDelayValue(const AnimationList* animList)
1208 auto list = CSSValueList::createCommaSeparated();
1210 for (size_t i = 0; i < animList->size(); ++i)
1211 list.get().append(cssValuePool().createValue(animList->animation(i).delay(), CSSPrimitiveValue::CSS_S));
1213 // Note that initialAnimationDelay() is used for both transitions and animations
1214 list.get().append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
1219 static PassRef<CSSValueList> getDurationValue(const AnimationList* animList)
1221 auto list = CSSValueList::createCommaSeparated();
1223 for (size_t i = 0; i < animList->size(); ++i)
1224 list.get().append(cssValuePool().createValue(animList->animation(i).duration(), CSSPrimitiveValue::CSS_S));
1226 // Note that initialAnimationDuration() is used for both transitions and animations
1227 list.get().append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
1232 static PassRefPtr<CSSValue> createTimingFunctionValue(const TimingFunction* timingFunction)
1234 switch (timingFunction->type()) {
1235 case TimingFunction::CubicBezierFunction: {
1236 const CubicBezierTimingFunction* bezierTimingFunction = static_cast<const CubicBezierTimingFunction*>(timingFunction);
1237 if (bezierTimingFunction->timingFunctionPreset() != CubicBezierTimingFunction::Custom) {
1238 CSSValueID valueId = CSSValueInvalid;
1239 switch (bezierTimingFunction->timingFunctionPreset()) {
1240 case CubicBezierTimingFunction::Ease:
1241 valueId = CSSValueEase;
1243 case CubicBezierTimingFunction::EaseIn:
1244 valueId = CSSValueEaseIn;
1246 case CubicBezierTimingFunction::EaseOut:
1247 valueId = CSSValueEaseOut;
1249 case CubicBezierTimingFunction::EaseInOut:
1250 valueId = CSSValueEaseInOut;
1253 ASSERT_NOT_REACHED();
1256 return cssValuePool().createIdentifierValue(valueId);
1258 return CSSCubicBezierTimingFunctionValue::create(bezierTimingFunction->x1(), bezierTimingFunction->y1(), bezierTimingFunction->x2(), bezierTimingFunction->y2());
1260 case TimingFunction::StepsFunction: {
1261 const StepsTimingFunction* stepsTimingFunction = static_cast<const StepsTimingFunction*>(timingFunction);
1262 return CSSStepsTimingFunctionValue::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtStart());
1264 case TimingFunction::LinearFunction:
1265 return cssValuePool().createIdentifierValue(CSSValueLinear);
1267 ASSERT_NOT_REACHED();
1271 static PassRef<CSSValueList> getTimingFunctionValue(const AnimationList* animList)
1273 auto list = CSSValueList::createCommaSeparated();
1275 for (size_t i = 0; i < animList->size(); ++i)
1276 list.get().append(createTimingFunctionValue(animList->animation(i).timingFunction().get()));
1278 // Note that initialAnimationTimingFunction() is used for both transitions and animations
1279 list.get().append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
1283 static PassRefPtr<CSSValue> createLineBoxContainValue(unsigned lineBoxContain)
1285 if (!lineBoxContain)
1286 return cssValuePool().createIdentifierValue(CSSValueNone);
1287 return CSSLineBoxContainValue::create(lineBoxContain);
1290 ComputedStyleExtractor::ComputedStyleExtractor(PassRefPtr<Node> node, bool allowVisitedStyle, PseudoId pseudoElementSpecifier)
1292 , m_pseudoElementSpecifier(pseudoElementSpecifier)
1293 , m_allowVisitedStyle(allowVisitedStyle)
1298 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n, bool allowVisitedStyle, const String& pseudoElementName)
1300 , m_allowVisitedStyle(allowVisitedStyle)
1303 unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoElementName[1] == ':' ? 2 : 1) : 0;
1304 m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoType(
1305 AtomicString(pseudoElementName.substring(nameWithoutColonsStart))));
1308 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
1312 void CSSComputedStyleDeclaration::ref()
1317 void CSSComputedStyleDeclaration::deref()
1324 String CSSComputedStyleDeclaration::cssText() const
1326 StringBuilder result;
1328 for (unsigned i = 0; i < numComputedProperties; i++) {
1331 result.append(getPropertyName(computedProperties[i]));
1332 result.append(": ", 2);
1333 result.append(getPropertyValue(computedProperties[i]));
1337 return result.toString();
1340 void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
1342 ec = NO_MODIFICATION_ALLOWED_ERR;
1345 static CSSValueID cssIdentifierForFontSizeKeyword(int keywordSize)
1347 ASSERT_ARG(keywordSize, keywordSize);
1348 ASSERT_ARG(keywordSize, keywordSize <= 8);
1349 return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1);
1352 PassRefPtr<CSSPrimitiveValue> ComputedStyleExtractor::getFontSizeCSSValuePreferringKeyword() const
1357 m_node->document().updateLayoutIgnorePendingStylesheets();
1359 RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1363 if (int keywordSize = style->fontDescription().keywordSize())
1364 return cssValuePool().createIdentifierValue(cssIdentifierForFontSizeKeyword(keywordSize));
1366 return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style.get());
1369 bool ComputedStyleExtractor::useFixedFontDefaultSize() const
1374 RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
1378 return style->fontDescription().useFixedDefaultSize();
1382 static CSSValueID identifierForFamily(const AtomicString& family)
1384 if (family == cursiveFamily)
1385 return CSSValueCursive;
1386 if (family == fantasyFamily)
1387 return CSSValueFantasy;
1388 if (family == monospaceFamily)
1389 return CSSValueMonospace;
1390 if (family == pictographFamily)
1391 return CSSValueWebkitPictograph;
1392 if (family == sansSerifFamily)
1393 return CSSValueSansSerif;
1394 if (family == serifFamily)
1395 return CSSValueSerif;
1396 return CSSValueInvalid;
1399 static PassRefPtr<CSSPrimitiveValue> valueForFamily(const AtomicString& family)
1401 if (CSSValueID familyIdentifier = identifierForFamily(family))
1402 return cssValuePool().createIdentifierValue(familyIdentifier);
1403 return cssValuePool().createValue(family.string(), CSSPrimitiveValue::CSS_STRING);
1406 static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration)
1408 // Blink value is ignored.
1409 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1410 if (textDecoration & TextDecorationUnderline)
1411 list->append(cssValuePool().createIdentifierValue(CSSValueUnderline));
1412 if (textDecoration & TextDecorationOverline)
1413 list->append(cssValuePool().createIdentifierValue(CSSValueOverline));
1414 if (textDecoration & TextDecorationLineThrough)
1415 list->append(cssValuePool().createIdentifierValue(CSSValueLineThrough));
1416 #if ENABLE(LETTERPRESS)
1417 if (textDecoration & TextDecorationLetterpress)
1418 list->append(cssValuePool().createIdentifierValue(CSSValueWebkitLetterpress));
1421 if (!list->length())
1422 return cssValuePool().createIdentifierValue(CSSValueNone);
1423 return list.release();
1426 #if ENABLE(CSS3_TEXT_DECORATION)
1427 static PassRefPtr<CSSValue> renderTextDecorationStyleFlagsToCSSValue(TextDecorationStyle textDecorationStyle)
1429 switch (textDecorationStyle) {
1430 case TextDecorationStyleSolid:
1431 return cssValuePool().createIdentifierValue(CSSValueSolid);
1432 case TextDecorationStyleDouble:
1433 return cssValuePool().createIdentifierValue(CSSValueDouble);
1434 case TextDecorationStyleDotted:
1435 return cssValuePool().createIdentifierValue(CSSValueDotted);
1436 case TextDecorationStyleDashed:
1437 return cssValuePool().createIdentifierValue(CSSValueDashed);
1438 case TextDecorationStyleWavy:
1439 return cssValuePool().createIdentifierValue(CSSValueWavy);
1442 ASSERT_NOT_REACHED();
1443 return cssValuePool().createExplicitInitialValue();
1446 static PassRefPtr<CSSValue> renderTextDecorationSkipFlagsToCSSValue(TextDecorationSkip textDecorationSkip)
1448 switch (textDecorationSkip) {
1449 case TextDecorationSkipNone:
1450 return cssValuePool().createExplicitInitialValue();
1451 case TextDecorationSkipInk:
1452 return cssValuePool().createIdentifierValue(CSSValueInk);
1455 ASSERT_NOT_REACHED();
1456 return cssValuePool().createExplicitInitialValue();
1458 #endif // CSS3_TEXT_DECORATION
1460 static PassRefPtr<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat)
1462 // For backwards compatibility, if both values are equal, just return one of them. And
1463 // if the two values are equivalent to repeat-x or repeat-y, just return the shorthand.
1464 if (xRepeat == yRepeat)
1465 return cssValuePool().createValue(xRepeat);
1466 if (xRepeat == RepeatFill && yRepeat == NoRepeatFill)
1467 return cssValuePool().createIdentifierValue(CSSValueRepeatX);
1468 if (xRepeat == NoRepeatFill && yRepeat == RepeatFill)
1469 return cssValuePool().createIdentifierValue(CSSValueRepeatY);
1471 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1472 list->append(cssValuePool().createValue(xRepeat));
1473 list->append(cssValuePool().createValue(yRepeat));
1474 return list.release();
1477 static PassRefPtr<CSSValue> fillSourceTypeToCSSValue(EMaskSourceType type)
1481 return cssValuePool().createValue(CSSValueAlpha);
1483 return cssValuePool().createValue(CSSValueLuminance);
1486 ASSERT_NOT_REACHED();
1490 static PassRefPtr<CSSValue> fillSizeToCSSValue(const FillSize& fillSize, const RenderStyle* style)
1492 if (fillSize.type == Contain)
1493 return cssValuePool().createIdentifierValue(CSSValueContain);
1495 if (fillSize.type == Cover)
1496 return cssValuePool().createIdentifierValue(CSSValueCover);
1498 if (fillSize.size.height().isAuto())
1499 return zoomAdjustedPixelValueForLength(fillSize.size.width(), style);
1501 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1502 list->append(zoomAdjustedPixelValueForLength(fillSize.size.width(), style));
1503 list->append(zoomAdjustedPixelValueForLength(fillSize.size.height(), style));
1504 return list.release();
1507 static PassRefPtr<CSSValue> altTextToCSSValue(const RenderStyle* style)
1509 return cssValuePool().createValue(style->contentAltText(), CSSPrimitiveValue::CSS_STRING);
1512 static PassRefPtr<CSSValue> contentToCSSValue(const RenderStyle* style)
1514 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1515 for (const ContentData* contentData = style->contentData(); contentData; contentData = contentData->next()) {
1516 if (contentData->isCounter()) {
1517 const CounterContent* counter = static_cast<const CounterContentData*>(contentData)->counter();
1519 list->append(cssValuePool().createValue(counter->identifier(), CSSPrimitiveValue::CSS_COUNTER_NAME));
1520 } else if (contentData->isImage()) {
1521 const StyleImage* image = static_cast<const ImageContentData*>(contentData)->image();
1523 list->append(image->cssValue());
1524 } else if (contentData->isText())
1525 list->append(cssValuePool().createValue(static_cast<const TextContentData*>(contentData)->text(), CSSPrimitiveValue::CSS_STRING));
1527 if (style->hasFlowFrom())
1528 list->append(cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING));
1529 return list.release();
1532 static PassRefPtr<CSSValue> counterToCSSValue(const RenderStyle* style, CSSPropertyID propertyID)
1534 const CounterDirectiveMap* map = style->counterDirectives();
1538 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1539 for (CounterDirectiveMap::const_iterator it = map->begin(); it != map->end(); ++it) {
1540 list->append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
1541 short number = propertyID == CSSPropertyCounterIncrement ? it->value.incrementValue() : it->value.resetValue();
1542 list->append(cssValuePool().createValue((double)number, CSSPrimitiveValue::CSS_NUMBER));
1544 return list.release();
1547 static void logUnimplementedPropertyID(CSSPropertyID propertyID)
1549 DEFINE_STATIC_LOCAL(HashSet<CSSPropertyID>, propertyIDSet, ());
1550 if (!propertyIDSet.add(propertyID).isNewEntry)
1553 LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", getPropertyName(propertyID));
1556 static PassRefPtr<CSSValueList> fontFamilyFromStyle(RenderStyle* style)
1558 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1559 for (unsigned i = 0; i < style->font().familyCount(); ++i)
1560 list->append(valueForFamily(style->font().familyAt(i)));
1561 return list.release();
1564 static PassRefPtr<CSSPrimitiveValue> lineHeightFromStyle(RenderStyle* style, RenderView* renderView)
1566 Length length = style->lineHeight();
1567 if (length.isNegative())
1568 return cssValuePool().createIdentifierValue(CSSValueNormal);
1569 if (length.isPercent())
1570 // This is imperfect, because it doesn't include the zoom factor and the real computation
1571 // for how high to be in pixels does include things like minimum font size and the zoom factor.
1572 // On the other hand, since font-size doesn't include the zoom factor, we really can't do
1573 // that here either.
1574 return zoomAdjustedPixelValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, style);
1575 return zoomAdjustedPixelValue(floatValueForLength(length, 0, renderView), style);
1578 static PassRefPtr<CSSPrimitiveValue> fontSizeFromStyle(RenderStyle* style)
1580 return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style);
1583 static PassRefPtr<CSSPrimitiveValue> fontStyleFromStyle(RenderStyle* style)
1585 if (style->fontDescription().italic())
1586 return cssValuePool().createIdentifierValue(CSSValueItalic);
1587 return cssValuePool().createIdentifierValue(CSSValueNormal);
1590 static PassRefPtr<CSSPrimitiveValue> fontVariantFromStyle(RenderStyle* style)
1592 if (style->fontDescription().smallCaps())
1593 return cssValuePool().createIdentifierValue(CSSValueSmallCaps);
1594 return cssValuePool().createIdentifierValue(CSSValueNormal);
1597 static PassRefPtr<CSSPrimitiveValue> fontWeightFromStyle(RenderStyle* style)
1599 switch (style->fontDescription().weight()) {
1601 return cssValuePool().createIdentifierValue(CSSValue100);
1603 return cssValuePool().createIdentifierValue(CSSValue200);
1605 return cssValuePool().createIdentifierValue(CSSValue300);
1606 case FontWeightNormal:
1607 return cssValuePool().createIdentifierValue(CSSValueNormal);
1609 return cssValuePool().createIdentifierValue(CSSValue500);
1611 return cssValuePool().createIdentifierValue(CSSValue600);
1612 case FontWeightBold:
1613 return cssValuePool().createIdentifierValue(CSSValueBold);
1615 return cssValuePool().createIdentifierValue(CSSValue800);
1617 return cssValuePool().createIdentifierValue(CSSValue900);
1619 ASSERT_NOT_REACHED();
1620 return cssValuePool().createIdentifierValue(CSSValueNormal);
1623 typedef const Length& (RenderStyle::*RenderStyleLengthGetter)() const;
1624 typedef LayoutUnit (RenderBoxModelObject::*RenderBoxComputedCSSValueGetter)() const;
1626 template<RenderStyleLengthGetter lengthGetter, RenderBoxComputedCSSValueGetter computedCSSValueGetter>
1627 inline PassRefPtr<CSSValue> zoomAdjustedPaddingOrMarginPixelValue(RenderStyle* style, RenderObject* renderer)
1629 Length unzoomzedLength = (style->*lengthGetter)();
1630 if (!renderer || !renderer->isBox() || unzoomzedLength.isFixed())
1631 return zoomAdjustedPixelValueForLength(unzoomzedLength, style);
1632 return zoomAdjustedPixelValue((toRenderBox(renderer)->*computedCSSValueGetter)(), style);
1635 template<RenderStyleLengthGetter lengthGetter>
1636 inline bool paddingOrMarginIsRendererDependent(RenderStyle* style, RenderObject* renderer)
1638 if (!renderer || !renderer->isBox())
1640 return !(style && (style->*lengthGetter)().isFixed());
1643 static bool isLayoutDependent(CSSPropertyID propertyID, RenderStyle* style, RenderObject* renderer)
1645 switch (propertyID) {
1646 case CSSPropertyWidth:
1647 case CSSPropertyHeight:
1648 case CSSPropertyWebkitPerspectiveOrigin:
1649 case CSSPropertyWebkitTransformOrigin:
1650 case CSSPropertyWebkitTransform:
1651 #if ENABLE(CSS_FILTERS)
1652 case CSSPropertyWebkitFilter:
1655 case CSSPropertyMargin: {
1656 if (!renderer || !renderer->isBox())
1658 return !(style && style->marginTop().isFixed() && style->marginRight().isFixed()
1659 && style->marginBottom().isFixed() && style->marginLeft().isFixed());
1661 case CSSPropertyMarginTop:
1662 return paddingOrMarginIsRendererDependent<&RenderStyle::marginTop>(style, renderer);
1663 case CSSPropertyMarginRight:
1664 return paddingOrMarginIsRendererDependent<&RenderStyle::marginRight>(style, renderer);
1665 case CSSPropertyMarginBottom:
1666 return paddingOrMarginIsRendererDependent<&RenderStyle::marginBottom>(style, renderer);
1667 case CSSPropertyMarginLeft:
1668 return paddingOrMarginIsRendererDependent<&RenderStyle::marginLeft>(style, renderer);
1669 case CSSPropertyPadding: {
1670 if (!renderer || !renderer->isBox())
1672 return !(style && style->paddingTop().isFixed() && style->paddingRight().isFixed()
1673 && style->paddingBottom().isFixed() && style->paddingLeft().isFixed());
1675 case CSSPropertyPaddingTop:
1676 return paddingOrMarginIsRendererDependent<&RenderStyle::paddingTop>(style, renderer);
1677 case CSSPropertyPaddingRight:
1678 return paddingOrMarginIsRendererDependent<&RenderStyle::paddingRight>(style, renderer);
1679 case CSSPropertyPaddingBottom:
1680 return paddingOrMarginIsRendererDependent<&RenderStyle::paddingBottom>(style, renderer);
1681 case CSSPropertyPaddingLeft:
1682 return paddingOrMarginIsRendererDependent<&RenderStyle::paddingLeft>(style, renderer);
1688 Node* ComputedStyleExtractor::styledNode() const
1692 if (!m_node->isElementNode())
1693 return m_node.get();
1694 Element* element = toElement(m_node.get());
1695 PseudoElement* pseudoElement;
1696 if (m_pseudoElementSpecifier == BEFORE && (pseudoElement = element->beforePseudoElement()))
1697 return pseudoElement;
1698 if (m_pseudoElementSpecifier == AFTER && (pseudoElement = element->afterPseudoElement()))
1699 return pseudoElement;
1703 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1705 return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).propertyValue(propertyID, updateLayout);
1708 PassRef<MutableStyleProperties> CSSComputedStyleDeclaration::copyProperties() const
1710 return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).copyProperties();
1713 static inline bool nodeOrItsAncestorNeedsStyleRecalc(Node* styledNode)
1715 if (styledNode->document().hasPendingForcedStyleRecalc())
1717 for (Node* n = styledNode; n; n = n->parentNode()) {// FIXME: Call parentOrShadowHostNode() instead
1718 if (n->needsStyleRecalc())
1724 static inline PassRefPtr<RenderStyle> computeRenderStyleForProperty(Node* styledNode, PseudoId pseudoElementSpecifier, CSSPropertyID propertyID)
1726 RenderObject* renderer = styledNode->renderer();
1728 if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
1729 AnimationUpdateBlock animationUpdateBlock(&renderer->animation());
1730 RefPtr<RenderStyle> style = renderer->animation().getAnimatedStyleForRenderer(toRenderElement(renderer));
1731 if (pseudoElementSpecifier && !styledNode->isPseudoElement()) {
1732 // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
1733 return style->getCachedPseudoStyle(pseudoElementSpecifier);
1735 return style.release();
1738 return styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : pseudoElementSpecifier);
1741 PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1743 Node* styledNode = this->styledNode();
1747 RefPtr<RenderStyle> style;
1748 RenderObject* renderer = 0;
1749 bool forceFullLayout = false;
1751 Document& document = styledNode->document();
1753 if (nodeOrItsAncestorNeedsStyleRecalc(styledNode)) {
1754 document.updateStyleIfNeeded();
1755 // The style recalc could have caused the styled node to be discarded or replaced
1756 // if it was a PseudoElement so we need to update it.
1757 styledNode = this->styledNode();
1760 style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID);
1761 renderer = styledNode->renderer();
1763 // FIXME: Some of these cases could be narrowed down or optimized better.
1764 forceFullLayout = isLayoutDependent(propertyID, style.get(), renderer)
1765 || styledNode->isInShadowTree()
1766 || (document.styleResolverIfExists() && document.styleResolverIfExists()->hasViewportDependentMediaQueries() && document.ownerElement())
1767 || document.seamlessParentIFrame();
1769 if (forceFullLayout) {
1770 document.updateLayoutIgnorePendingStylesheets();
1771 styledNode = this->styledNode();
1775 if (!updateLayout || forceFullLayout) {
1776 style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID);
1777 renderer = styledNode->renderer();
1783 propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction(), style->writingMode());
1785 switch (propertyID) {
1786 case CSSPropertyInvalid:
1789 case CSSPropertyBackgroundColor:
1790 return cssValuePool().createColorValue(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb());
1791 case CSSPropertyBackgroundImage:
1792 case CSSPropertyWebkitMaskImage: {
1793 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskImage ? style->maskLayers() : style->backgroundLayers();
1795 return cssValuePool().createIdentifierValue(CSSValueNone);
1797 if (!layers->next()) {
1798 if (layers->image())
1799 return layers->image()->cssValue();
1801 return cssValuePool().createIdentifierValue(CSSValueNone);
1804 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1805 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1806 if (currLayer->image())
1807 list->append(currLayer->image()->cssValue());
1809 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
1811 return list.release();
1813 case CSSPropertyBackgroundSize:
1814 case CSSPropertyWebkitBackgroundSize:
1815 case CSSPropertyWebkitMaskSize: {
1816 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskSize ? style->maskLayers() : style->backgroundLayers();
1817 if (!layers->next())
1818 return fillSizeToCSSValue(layers->size(), style.get());
1820 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1821 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1822 list->append(fillSizeToCSSValue(currLayer->size(), style.get()));
1824 return list.release();
1826 case CSSPropertyBackgroundRepeat:
1827 case CSSPropertyWebkitMaskRepeat: {
1828 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskRepeat ? style->maskLayers() : style->backgroundLayers();
1829 if (!layers->next())
1830 return fillRepeatToCSSValue(layers->repeatX(), layers->repeatY());
1832 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1833 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1834 list->append(fillRepeatToCSSValue(currLayer->repeatX(), currLayer->repeatY()));
1836 return list.release();
1838 case CSSPropertyWebkitMaskSourceType: {
1839 const FillLayer* layers = style->maskLayers();
1842 return cssValuePool().createIdentifierValue(CSSValueNone);
1844 if (!layers->next())
1845 return fillSourceTypeToCSSValue(layers->maskSourceType());
1847 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1848 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1849 list->append(fillSourceTypeToCSSValue(currLayer->maskSourceType()));
1851 return list.release();
1853 case CSSPropertyWebkitBackgroundComposite:
1854 case CSSPropertyWebkitMaskComposite: {
1855 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskComposite ? style->maskLayers() : style->backgroundLayers();
1856 if (!layers->next())
1857 return cssValuePool().createValue(layers->composite());
1859 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1860 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1861 list->append(cssValuePool().createValue(currLayer->composite()));
1863 return list.release();
1865 case CSSPropertyBackgroundAttachment: {
1866 const FillLayer* layers = style->backgroundLayers();
1867 if (!layers->next())
1868 return cssValuePool().createValue(layers->attachment());
1870 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1871 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1872 list->append(cssValuePool().createValue(currLayer->attachment()));
1874 return list.release();
1876 case CSSPropertyBackgroundClip:
1877 case CSSPropertyBackgroundOrigin:
1878 case CSSPropertyWebkitBackgroundClip:
1879 case CSSPropertyWebkitBackgroundOrigin:
1880 case CSSPropertyWebkitMaskClip:
1881 case CSSPropertyWebkitMaskOrigin: {
1882 const FillLayer* layers = (propertyID == CSSPropertyWebkitMaskClip || propertyID == CSSPropertyWebkitMaskOrigin) ? style->maskLayers() : style->backgroundLayers();
1883 bool isClip = propertyID == CSSPropertyBackgroundClip || propertyID == CSSPropertyWebkitBackgroundClip || propertyID == CSSPropertyWebkitMaskClip;
1884 if (!layers->next()) {
1885 EFillBox box = isClip ? layers->clip() : layers->origin();
1886 return cssValuePool().createValue(box);
1889 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1890 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
1891 EFillBox box = isClip ? currLayer->clip() : currLayer->origin();
1892 list->append(cssValuePool().createValue(box));
1895 return list.release();
1897 case CSSPropertyBackgroundPosition:
1898 case CSSPropertyWebkitMaskPosition: {
1899 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPosition ? style->maskLayers() : style->backgroundLayers();
1900 if (!layers->next())
1901 return createPositionListForLayer(propertyID, layers, style.get());
1903 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1904 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1905 list->append(createPositionListForLayer(propertyID, currLayer, style.get()));
1906 return list.release();
1908 case CSSPropertyBackgroundPositionX:
1909 case CSSPropertyWebkitMaskPositionX: {
1910 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionX ? style->maskLayers() : style->backgroundLayers();
1911 if (!layers->next())
1912 return cssValuePool().createValue(layers->xPosition());
1914 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1915 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1916 list->append(cssValuePool().createValue(currLayer->xPosition()));
1918 return list.release();
1920 case CSSPropertyBackgroundPositionY:
1921 case CSSPropertyWebkitMaskPositionY: {
1922 const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionY ? style->maskLayers() : style->backgroundLayers();
1923 if (!layers->next())
1924 return cssValuePool().createValue(layers->yPosition());
1926 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1927 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
1928 list->append(cssValuePool().createValue(currLayer->yPosition()));
1930 return list.release();
1932 case CSSPropertyBorderCollapse:
1933 if (style->borderCollapse())
1934 return cssValuePool().createIdentifierValue(CSSValueCollapse);
1935 return cssValuePool().createIdentifierValue(CSSValueSeparate);
1936 case CSSPropertyBorderSpacing: {
1937 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1938 list->append(zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get()));
1939 list->append(zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get()));
1940 return list.release();
1942 case CSSPropertyWebkitBorderHorizontalSpacing:
1943 return zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get());
1944 case CSSPropertyWebkitBorderVerticalSpacing:
1945 return zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get());
1946 case CSSPropertyBorderImageSource:
1947 if (style->borderImageSource())
1948 return style->borderImageSource()->cssValue();
1949 return cssValuePool().createIdentifierValue(CSSValueNone);
1950 case CSSPropertyBorderTopColor:
1951 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor());
1952 case CSSPropertyBorderRightColor:
1953 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor());
1954 case CSSPropertyBorderBottomColor:
1955 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor());
1956 case CSSPropertyBorderLeftColor:
1957 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor());
1958 case CSSPropertyBorderTopStyle:
1959 return cssValuePool().createValue(style->borderTopStyle());
1960 case CSSPropertyBorderRightStyle:
1961 return cssValuePool().createValue(style->borderRightStyle());
1962 case CSSPropertyBorderBottomStyle:
1963 return cssValuePool().createValue(style->borderBottomStyle());
1964 case CSSPropertyBorderLeftStyle:
1965 return cssValuePool().createValue(style->borderLeftStyle());
1966 case CSSPropertyBorderTopWidth:
1967 return zoomAdjustedPixelValue(style->borderTopWidth(), style.get());
1968 case CSSPropertyBorderRightWidth:
1969 return zoomAdjustedPixelValue(style->borderRightWidth(), style.get());
1970 case CSSPropertyBorderBottomWidth:
1971 return zoomAdjustedPixelValue(style->borderBottomWidth(), style.get());
1972 case CSSPropertyBorderLeftWidth:
1973 return zoomAdjustedPixelValue(style->borderLeftWidth(), style.get());
1974 case CSSPropertyBottom:
1975 return getPositionOffsetValue(style.get(), CSSPropertyBottom, m_node->document().renderView());
1976 case CSSPropertyWebkitBoxAlign:
1977 return cssValuePool().createValue(style->boxAlign());
1978 #if ENABLE(CSS_BOX_DECORATION_BREAK)
1979 case CSSPropertyWebkitBoxDecorationBreak:
1980 if (style->boxDecorationBreak() == DSLICE)
1981 return cssValuePool().createIdentifierValue(CSSValueSlice);
1982 return cssValuePool().createIdentifierValue(CSSValueClone);
1984 case CSSPropertyWebkitBoxDirection:
1985 return cssValuePool().createValue(style->boxDirection());
1986 case CSSPropertyWebkitBoxFlex:
1987 return cssValuePool().createValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
1988 case CSSPropertyWebkitBoxFlexGroup:
1989 return cssValuePool().createValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
1990 case CSSPropertyWebkitBoxLines:
1991 return cssValuePool().createValue(style->boxLines());
1992 case CSSPropertyWebkitBoxOrdinalGroup:
1993 return cssValuePool().createValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
1994 case CSSPropertyWebkitBoxOrient:
1995 return cssValuePool().createValue(style->boxOrient());
1996 case CSSPropertyWebkitBoxPack:
1997 return cssValuePool().createValue(style->boxPack());
1998 case CSSPropertyWebkitBoxReflect:
1999 return valueForReflection(style->boxReflect(), style.get());
2000 case CSSPropertyBoxShadow:
2001 case CSSPropertyWebkitBoxShadow:
2002 return valueForShadow(style->boxShadow(), propertyID, style.get());
2003 case CSSPropertyCaptionSide:
2004 return cssValuePool().createValue(style->captionSide());
2005 case CSSPropertyClear:
2006 return cssValuePool().createValue(style->clear());
2007 case CSSPropertyColor:
2008 return cssValuePool().createColorValue(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb());
2009 case CSSPropertyWebkitPrintColorAdjust:
2010 return cssValuePool().createValue(style->printColorAdjust());
2011 case CSSPropertyWebkitColumnAxis:
2012 return cssValuePool().createValue(style->columnAxis());
2013 case CSSPropertyWebkitColumnCount:
2014 if (style->hasAutoColumnCount())
2015 return cssValuePool().createIdentifierValue(CSSValueAuto);
2016 return cssValuePool().createValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
2017 case CSSPropertyWebkitColumnFill:
2018 return cssValuePool().createValue(style->columnFill());
2019 case CSSPropertyWebkitColumnGap:
2020 if (style->hasNormalColumnGap())
2021 return cssValuePool().createIdentifierValue(CSSValueNormal);
2022 return zoomAdjustedPixelValue(style->columnGap(), style.get());
2023 case CSSPropertyWebkitColumnProgression:
2024 return cssValuePool().createValue(style->columnProgression());
2025 case CSSPropertyWebkitColumnRuleColor:
2026 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor());
2027 case CSSPropertyWebkitColumnRuleStyle:
2028 return cssValuePool().createValue(style->columnRuleStyle());
2029 case CSSPropertyWebkitColumnRuleWidth:
2030 return zoomAdjustedPixelValue(style->columnRuleWidth(), style.get());
2031 case CSSPropertyWebkitColumnSpan:
2032 return cssValuePool().createIdentifierValue(style->columnSpan() ? CSSValueAll : CSSValueNone);
2033 case CSSPropertyWebkitColumnBreakAfter:
2034 return cssValuePool().createValue(style->columnBreakAfter());
2035 case CSSPropertyWebkitColumnBreakBefore:
2036 return cssValuePool().createValue(style->columnBreakBefore());
2037 case CSSPropertyWebkitColumnBreakInside:
2038 return cssValuePool().createValue(style->columnBreakInside());
2039 case CSSPropertyWebkitColumnWidth:
2040 if (style->hasAutoColumnWidth())
2041 return cssValuePool().createIdentifierValue(CSSValueAuto);
2042 return zoomAdjustedPixelValue(style->columnWidth(), style.get());
2043 case CSSPropertyTabSize:
2044 return cssValuePool().createValue(style->tabSize(), CSSPrimitiveValue::CSS_NUMBER);
2045 #if ENABLE(CSS_REGIONS)
2046 case CSSPropertyWebkitRegionBreakAfter:
2047 return cssValuePool().createValue(style->regionBreakAfter());
2048 case CSSPropertyWebkitRegionBreakBefore:
2049 return cssValuePool().createValue(style->regionBreakBefore());
2050 case CSSPropertyWebkitRegionBreakInside:
2051 return cssValuePool().createValue(style->regionBreakInside());
2053 case CSSPropertyCursor: {
2054 RefPtr<CSSValueList> list;
2055 CursorList* cursors = style->cursors();
2056 if (cursors && cursors->size() > 0) {
2057 list = CSSValueList::createCommaSeparated();
2058 for (unsigned i = 0; i < cursors->size(); ++i)
2059 if (StyleImage* image = cursors->at(i).image())
2060 list->append(image->cssValue());
2062 RefPtr<CSSValue> value = cssValuePool().createValue(style->cursor());
2064 list->append(value.release());
2065 return list.release();
2067 return value.release();
2069 #if ENABLE(CURSOR_VISIBILITY)
2070 case CSSPropertyWebkitCursorVisibility:
2071 return cssValuePool().createValue(style->cursorVisibility());
2073 case CSSPropertyDirection:
2074 return cssValuePool().createValue(style->direction());
2075 case CSSPropertyDisplay:
2076 return cssValuePool().createValue(style->display());
2077 case CSSPropertyEmptyCells:
2078 return cssValuePool().createValue(style->emptyCells());
2079 case CSSPropertyWebkitAlignContent:
2080 return cssValuePool().createValue(style->alignContent());
2081 case CSSPropertyWebkitAlignItems:
2082 return cssValuePool().createValue(style->alignItems());
2083 case CSSPropertyWebkitAlignSelf:
2084 if (style->alignSelf() == AlignAuto) {
2085 Node* parent = styledNode->parentNode();
2086 if (parent && parent->computedStyle())
2087 return cssValuePool().createValue(parent->computedStyle()->alignItems());
2088 return cssValuePool().createValue(AlignStretch);
2090 return cssValuePool().createValue(style->alignSelf());
2091 case CSSPropertyWebkitFlex:
2092 return getCSSPropertyValuesForShorthandProperties(webkitFlexShorthand());
2093 case CSSPropertyWebkitFlexBasis:
2094 return cssValuePool().createValue(style->flexBasis());
2095 case CSSPropertyWebkitFlexDirection:
2096 return cssValuePool().createValue(style->flexDirection());
2097 case CSSPropertyWebkitFlexFlow:
2098 return getCSSPropertyValuesForShorthandProperties(webkitFlexFlowShorthand());
2099 case CSSPropertyWebkitFlexGrow:
2100 return cssValuePool().createValue(style->flexGrow());
2101 case CSSPropertyWebkitFlexShrink:
2102 return cssValuePool().createValue(style->flexShrink());
2103 case CSSPropertyWebkitFlexWrap:
2104 return cssValuePool().createValue(style->flexWrap());
2105 case CSSPropertyWebkitJustifyContent:
2106 return cssValuePool().createValue(style->justifyContent());
2107 case CSSPropertyWebkitOrder:
2108 return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
2109 case CSSPropertyFloat:
2110 if (style->display() != NONE && style->hasOutOfFlowPosition())
2111 return cssValuePool().createIdentifierValue(CSSValueNone);
2112 return cssValuePool().createValue(style->floating());
2113 case CSSPropertyFont: {
2114 RefPtr<CSSFontValue> computedFont = CSSFontValue::create();
2115 computedFont->style = fontStyleFromStyle(style.get());
2116 computedFont->variant = fontVariantFromStyle(style.get());
2117 computedFont->weight = fontWeightFromStyle(style.get());
2118 computedFont->size = fontSizeFromStyle(style.get());
2119 computedFont->lineHeight = lineHeightFromStyle(style.get(), m_node->document().renderView());
2120 computedFont->family = fontFamilyFromStyle(style.get());
2121 return computedFont.release();
2123 case CSSPropertyFontFamily: {
2124 RefPtr<CSSValueList> fontFamilyList = fontFamilyFromStyle(style.get());
2125 // If there's only a single family, return that as a CSSPrimitiveValue.
2126 // NOTE: Gecko always returns this as a comma-separated CSSPrimitiveValue string.
2127 if (fontFamilyList->length() == 1)
2128 return fontFamilyList->item(0);
2129 return fontFamilyList.release();
2131 case CSSPropertyFontSize:
2132 return fontSizeFromStyle(style.get());
2133 case CSSPropertyFontStyle:
2134 return fontStyleFromStyle(style.get());
2135 case CSSPropertyFontVariant:
2136 return fontVariantFromStyle(style.get());
2137 case CSSPropertyFontWeight:
2138 return fontWeightFromStyle(style.get());
2139 case CSSPropertyWebkitFontFeatureSettings: {
2140 const FontFeatureSettings* featureSettings = style->fontDescription().featureSettings();
2141 if (!featureSettings || !featureSettings->size())
2142 return cssValuePool().createIdentifierValue(CSSValueNormal);
2143 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2144 for (unsigned i = 0; i < featureSettings->size(); ++i) {
2145 const FontFeature& feature = featureSettings->at(i);
2146 list->append(CSSFontFeatureValue::create(feature.tag(), feature.value()));
2148 return list.release();
2150 case CSSPropertyWebkitGridAutoColumns:
2151 return valueForGridTrackSize(style->gridAutoColumns(), style.get(), m_node->document().renderView());
2152 case CSSPropertyWebkitGridAutoFlow:
2153 return cssValuePool().createValue(style->gridAutoFlow());
2154 case CSSPropertyWebkitGridAutoRows:
2155 return valueForGridTrackSize(style->gridAutoRows(), style.get(), m_node->document().renderView());
2156 case CSSPropertyWebkitGridDefinitionColumns:
2157 return valueForGridTrackList(style->gridColumns(), style->namedGridColumnLines(), style.get(), m_node->document().renderView());
2158 case CSSPropertyWebkitGridDefinitionRows:
2159 return valueForGridTrackList(style->gridRows(), style->namedGridRowLines(), style.get(), m_node->document().renderView());
2161 case CSSPropertyWebkitGridColumnStart:
2162 return valueForGridPosition(style->gridItemColumnStart());
2163 case CSSPropertyWebkitGridColumnEnd:
2164 return valueForGridPosition(style->gridItemColumnEnd());
2165 case CSSPropertyWebkitGridRowStart:
2166 return valueForGridPosition(style->gridItemRowStart());
2167 case CSSPropertyWebkitGridRowEnd:
2168 return valueForGridPosition(style->gridItemRowEnd());
2169 case CSSPropertyWebkitGridArea:
2170 return getCSSPropertyValuesForGridShorthand(webkitGridAreaShorthand());
2171 case CSSPropertyWebkitGridColumn:
2172 return getCSSPropertyValuesForGridShorthand(webkitGridColumnShorthand());
2173 case CSSPropertyWebkitGridRow:
2174 return getCSSPropertyValuesForGridShorthand(webkitGridRowShorthand());
2176 case CSSPropertyWebkitGridTemplate:
2177 if (!style->namedGridAreaRowCount()) {
2178 ASSERT(!style->namedGridAreaColumnCount());
2179 return cssValuePool().createIdentifierValue(CSSValueNone);
2182 return CSSGridTemplateValue::create(style->namedGridArea(), style->namedGridAreaRowCount(), style->namedGridAreaColumnCount());
2184 case CSSPropertyHeight:
2186 // According to http://www.w3.org/TR/CSS2/visudet.html#the-height-property,
2187 // the "height" property does not apply for non-replaced inline elements.
2188 if (!renderer->isReplaced() && renderer->isInline())
2189 return cssValuePool().createIdentifierValue(CSSValueAuto);
2190 return zoomAdjustedPixelValue(sizingBox(renderer).height(), style.get());
2192 return zoomAdjustedPixelValueForLength(style->height(), style.get());
2193 case CSSPropertyWebkitHighlight:
2194 if (style->highlight() == nullAtom)
2195 return cssValuePool().createIdentifierValue(CSSValueNone);
2196 return cssValuePool().createValue(style->highlight(), CSSPrimitiveValue::CSS_STRING);
2197 case CSSPropertyWebkitHyphens:
2198 return cssValuePool().createValue(style->hyphens());
2199 case CSSPropertyWebkitHyphenateCharacter:
2200 if (style->hyphenationString().isNull())
2201 return cssValuePool().createIdentifierValue(CSSValueAuto);
2202 return cssValuePool().createValue(style->hyphenationString(), CSSPrimitiveValue::CSS_STRING);
2203 case CSSPropertyWebkitHyphenateLimitAfter:
2204 if (style->hyphenationLimitAfter() < 0)
2205 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
2206 return CSSPrimitiveValue::create(style->hyphenationLimitAfter(), CSSPrimitiveValue::CSS_NUMBER);
2207 case CSSPropertyWebkitHyphenateLimitBefore:
2208 if (style->hyphenationLimitBefore() < 0)
2209 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
2210 return CSSPrimitiveValue::create(style->hyphenationLimitBefore(), CSSPrimitiveValue::CSS_NUMBER);
2211 case CSSPropertyWebkitHyphenateLimitLines:
2212 if (style->hyphenationLimitLines() < 0)
2213 return CSSPrimitiveValue::createIdentifier(CSSValueNoLimit);
2214 return CSSPrimitiveValue::create(style->hyphenationLimitLines(), CSSPrimitiveValue::CSS_NUMBER);
2215 case CSSPropertyWebkitBorderFit:
2216 if (style->borderFit() == BorderFitBorder)
2217 return cssValuePool().createIdentifierValue(CSSValueBorder);
2218 return cssValuePool().createIdentifierValue(CSSValueLines);
2219 #if ENABLE(CSS_IMAGE_ORIENTATION)
2220 case CSSPropertyImageOrientation:
2221 return cssValuePool().createValue(style->imageOrientation());
2223 case CSSPropertyImageRendering:
2224 return CSSPrimitiveValue::create(style->imageRendering());
2225 #if ENABLE(CSS_IMAGE_RESOLUTION)
2226 case CSSPropertyImageResolution:
2227 return cssValuePool().createValue(style->imageResolution(), CSSPrimitiveValue::CSS_DPPX);
2229 case CSSPropertyLeft:
2230 return getPositionOffsetValue(style.get(), CSSPropertyLeft, m_node->document().renderView());
2231 case CSSPropertyLetterSpacing:
2232 if (!style->letterSpacing())
2233 return cssValuePool().createIdentifierValue(CSSValueNormal);
2234 return zoomAdjustedPixelValue(style->letterSpacing(), style.get());
2235 case CSSPropertyWebkitLineClamp:
2236 if (style->lineClamp().isNone())
2237 return cssValuePool().createIdentifierValue(CSSValueNone);
2238 return cssValuePool().createValue(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
2239 case CSSPropertyLineHeight:
2240 return lineHeightFromStyle(style.get(), m_node->document().renderView());
2241 case CSSPropertyListStyleImage:
2242 if (style->listStyleImage())
2243 return style->listStyleImage()->cssValue();
2244 return cssValuePool().createIdentifierValue(CSSValueNone);
2245 case CSSPropertyListStylePosition:
2246 return cssValuePool().createValue(style->listStylePosition());
2247 case CSSPropertyListStyleType:
2248 return cssValuePool().createValue(style->listStyleType());
2249 case CSSPropertyWebkitLocale:
2250 if (style->locale().isNull())
2251 return cssValuePool().createIdentifierValue(CSSValueAuto);
2252 return cssValuePool().createValue(style->locale(), CSSPrimitiveValue::CSS_STRING);
2253 case CSSPropertyMarginTop:
2254 return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginTop, &RenderBoxModelObject::marginTop>(style.get(), renderer);
2255 case CSSPropertyMarginRight: {
2256 Length marginRight = style->marginRight();
2257 if (marginRight.isFixed() || !renderer || !renderer->isBox())
2258 return zoomAdjustedPixelValueForLength(marginRight, style.get());
2260 if (marginRight.isPercent() || marginRight.isViewportPercentage())
2261 // RenderBox gives a marginRight() that is the distance between the right-edge of the child box
2262 // and the right-edge of the containing box, when display == BLOCK. Let's calculate the absolute
2263 // value of the specified margin-right % instead of relying on RenderBox's marginRight() value.
2264 value = minimumValueForLength(marginRight, toRenderBox(renderer)->containingBlockLogicalWidthForContent(), m_node->document().renderView());
2266 value = toRenderBox(renderer)->marginRight();
2267 return zoomAdjustedPixelValue(value, style.get());
2269 case CSSPropertyMarginBottom:
2270 return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginBottom, &RenderBoxModelObject::marginBottom>(style.get(), renderer);
2271 case CSSPropertyMarginLeft:
2272 return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginLeft, &RenderBoxModelObject::marginLeft>(style.get(), renderer);
2273 case CSSPropertyWebkitMarqueeDirection:
2274 return cssValuePool().createValue(style->marqueeDirection());
2275 case CSSPropertyWebkitMarqueeIncrement:
2276 return cssValuePool().createValue(style->marqueeIncrement());
2277 case CSSPropertyWebkitMarqueeRepetition:
2278 if (style->marqueeLoopCount() < 0)
2279 return cssValuePool().createIdentifierValue(CSSValueInfinite);
2280 return cssValuePool().createValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
2281 case CSSPropertyWebkitMarqueeStyle:
2282 return cssValuePool().createValue(style->marqueeBehavior());
2283 case CSSPropertyWebkitUserModify:
2284 return cssValuePool().createValue(style->userModify());
2285 case CSSPropertyMaxHeight: {
2286 const Length& maxHeight = style->maxHeight();
2287 if (maxHeight.isUndefined())
2288 return cssValuePool().createIdentifierValue(CSSValueNone);
2289 return zoomAdjustedPixelValueForLength(maxHeight, style.get());
2291 case CSSPropertyMaxWidth: {
2292 const Length& maxWidth = style->maxWidth();
2293 if (maxWidth.isUndefined())
2294 return cssValuePool().createIdentifierValue(CSSValueNone);
2295 return zoomAdjustedPixelValueForLength(maxWidth, style.get());
2297 case CSSPropertyMinHeight:
2298 // FIXME: For flex-items, min-height:auto should compute to min-content.
2299 if (style->minHeight().isAuto())
2300 return zoomAdjustedPixelValue(0, style.get());
2301 return zoomAdjustedPixelValueForLength(style->minHeight(), style.get());
2302 case CSSPropertyMinWidth:
2303 // FIXME: For flex-items, min-width:auto should compute to min-content.
2304 if (style->minWidth().isAuto())
2305 return zoomAdjustedPixelValue(0, style.get());
2306 return zoomAdjustedPixelValueForLength(style->minWidth(), style.get());
2307 case CSSPropertyObjectFit:
2308 return cssValuePool().createValue(style->objectFit());
2309 case CSSPropertyOpacity:
2310 return cssValuePool().createValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
2311 case CSSPropertyOrphans:
2312 if (style->hasAutoOrphans())
2313 return cssValuePool().createIdentifierValue(CSSValueAuto);
2314 return cssValuePool().createValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
2315 case CSSPropertyOutlineColor:
2316 return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor());
2317 case CSSPropertyOutlineOffset:
2318 return zoomAdjustedPixelValue(style->outlineOffset(), style.get());
2319 case CSSPropertyOutlineStyle:
2320 if (style->outlineStyleIsAuto())
2321 return cssValuePool().createIdentifierValue(CSSValueAuto);
2322 return cssValuePool().createValue(style->outlineStyle());
2323 case CSSPropertyOutlineWidth:
2324 return zoomAdjustedPixelValue(style->outlineWidth(), style.get());
2325 case CSSPropertyOverflow:
2326 return cssValuePool().createValue(std::max(style->overflowX(), style->overflowY()));
2327 case CSSPropertyOverflowWrap:
2328 return cssValuePool().createValue(style->overflowWrap());
2329 case CSSPropertyOverflowX:
2330 return cssValuePool().createValue(style->overflowX());
2331 case CSSPropertyOverflowY:
2332 return cssValuePool().createValue(style->overflowY());
2333 case CSSPropertyPaddingTop:
2334 return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingTop, &RenderBoxModelObject::computedCSSPaddingTop>(style.get(), renderer);
2335 case CSSPropertyPaddingRight:
2336 return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingRight, &RenderBoxModelObject::computedCSSPaddingRight>(style.get(), renderer);
2337 case CSSPropertyPaddingBottom:
2338 return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingBottom, &RenderBoxModelObject::computedCSSPaddingBottom>(style.get(), renderer);
2339 case CSSPropertyPaddingLeft:
2340 return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingLeft, &RenderBoxModelObject::computedCSSPaddingLeft>(style.get(), renderer);
2341 case CSSPropertyPageBreakAfter:
2342 return cssValuePool().createValue(style->pageBreakAfter());
2343 case CSSPropertyPageBreakBefore:
2344 return cssValuePool().createValue(style->pageBreakBefore());
2345 case CSSPropertyPageBreakInside: {
2346 EPageBreak pageBreak = style->pageBreakInside();
2347 ASSERT(pageBreak != PBALWAYS);
2348 if (pageBreak == PBALWAYS)
2350 return cssValuePool().createValue(style->pageBreakInside());
2352 case CSSPropertyPosition:
2353 return cssValuePool().createValue(style->position());
2354 case CSSPropertyRight:
2355 return getPositionOffsetValue(style.get(), CSSPropertyRight, m_node->document().renderView());
2356 case CSSPropertyWebkitRubyPosition:
2357 return cssValuePool().createValue(style->rubyPosition());
2358 case CSSPropertyTableLayout:
2359 return cssValuePool().createValue(style->tableLayout());
2360 case CSSPropertyTextAlign:
2361 return cssValuePool().createValue(style->textAlign());
2362 case CSSPropertyTextDecoration:
2363 return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2364 #if ENABLE(CSS3_TEXT)
2365 case CSSPropertyWebkitTextAlignLast:
2366 return cssValuePool().createValue(style->textAlignLast());
2367 case CSSPropertyWebkitTextJustify:
2368 return cssValuePool().createValue(style->textJustify());
2370 #if ENABLE(CSS3_TEXT_DECORATION)
2371 case CSSPropertyWebkitTextDecoration:
2372 return getCSSPropertyValuesForShorthandProperties(webkitTextDecorationShorthand());
2373 case CSSPropertyWebkitTextDecorationLine:
2374 return renderTextDecorationFlagsToCSSValue(style->textDecoration());
2375 case CSSPropertyWebkitTextDecorationStyle:
2376 return renderTextDecorationStyleFlagsToCSSValue(style->textDecorationStyle());
2377 case CSSPropertyWebkitTextDecorationColor:
2378 return currentColorOrValidColor(style.get(), style->textDecorationColor());
2379 case CSSPropertyWebkitTextDecorationSkip:
2380 return renderTextDecorationSkipFlagsToCSSValue(style->textDecorationSkip());
2381 case CSSPropertyWebkitTextUnderlinePosition:
2382 return cssValuePool().createValue(style->textUnderlinePosition());
2384 case CSSPropertyWebkitTextDecorationsInEffect:
2385 return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect());
2386 case CSSPropertyWebkitTextFillColor:
2387 return currentColorOrValidColor(style.get(), style->textFillColor());
2388 case CSSPropertyWebkitTextEmphasisColor:
2389 return currentColorOrValidColor(style.get(), style->textEmphasisColor());
2390 case CSSPropertyWebkitTextEmphasisPosition:
2391 return cssValuePool().createValue(style->textEmphasisPosition());
2392 case CSSPropertyWebkitTextEmphasisStyle:
2393 switch (style->textEmphasisMark()) {
2394 case TextEmphasisMarkNone:
2395 return cssValuePool().createIdentifierValue(CSSValueNone);
2396 case TextEmphasisMarkCustom:
2397 return cssValuePool().createValue(style->textEmphasisCustomMark(), CSSPrimitiveValue::CSS_STRING);
2398 case TextEmphasisMarkAuto:
2399 ASSERT_NOT_REACHED();
2401 case TextEmphasisMarkDot:
2402 case TextEmphasisMarkCircle:
2403 case TextEmphasisMarkDoubleCircle:
2404 case TextEmphasisMarkTriangle:
2405 case TextEmphasisMarkSesame: {
2406 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2407 list->append(cssValuePool().createValue(style->textEmphasisFill()));
2408 list->append(cssValuePool().createValue(style->textEmphasisMark()));
2409 return list.release();
2412 case CSSPropertyTextIndent: {
2413 // If CSS3_TEXT is disabled or text-indent has only one value(<length> | <percentage>),
2414 // getPropertyCSSValue() returns CSSValue.
2415 RefPtr<CSSValue> textIndent = zoomAdjustedPixelValueForLength(style->textIndent(), style.get());
2416 #if ENABLE(CSS3_TEXT)
2417 // If CSS3_TEXT is enabled and text-indent has -webkit-each-line or -webkit-hanging,
2418 // getPropertyCSSValue() returns CSSValueList.
2419 if (style->textIndentLine() == TextIndentEachLine || style->textIndentType() == TextIndentHanging) {
2420 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2421 list->append(textIndent.release());
2422 if (style->textIndentLine() == TextIndentEachLine)
2423 list->append(cssValuePool().createIdentifierValue(CSSValueWebkitEachLine));
2424 if (style->textIndentType() == TextIndentHanging)
2425 list->append(cssValuePool().createIdentifierValue(CSSValueWebkitHanging));
2426 return list.release();
2429 return textIndent.release();
2431 case CSSPropertyTextShadow:
2432 return valueForShadow(style->textShadow(), propertyID, style.get());
2433 case CSSPropertyTextRendering:
2434 return cssValuePool().createValue(style->fontDescription().textRenderingMode());
2435 case CSSPropertyTextOverflow:
2436 if (style->textOverflow())
2437 return cssValuePool().createIdentifierValue(CSSValueEllipsis);
2438 return cssValuePool().createIdentifierValue(CSSValueClip);
2439 case CSSPropertyWebkitTextSecurity:
2440 return cssValuePool().createValue(style->textSecurity());
2441 #if ENABLE(IOS_TEXT_AUTOSIZING)
2442 case CSSPropertyWebkitTextSizeAdjust:
2443 if (style->textSizeAdjust().isAuto())
2444 return cssValuePool().createIdentifierValue(CSSValueAuto);
2445 if (style->textSizeAdjust().isNone())
2446 return cssValuePool().createIdentifierValue(CSSValueNone);
2447 return CSSPrimitiveValue::create(style->textSizeAdjust().percentage(), CSSPrimitiveValue::CSS_PERCENTAGE);
2449 case CSSPropertyWebkitTextStrokeColor:
2450 return currentColorOrValidColor(style.get(), style->textStrokeColor());
2451 case CSSPropertyWebkitTextStrokeWidth:
2452 return zoomAdjustedPixelValue(style->textStrokeWidth(), style.get());
2453 case CSSPropertyTextTransform:
2454 return cssValuePool().createValue(style->textTransform());
2455 case CSSPropertyTop:
2456 return getPositionOffsetValue(style.get(), CSSPropertyTop, m_node->document().renderView());
2457 case CSSPropertyUnicodeBidi:
2458 return cssValuePool().createValue(style->unicodeBidi());
2459 case CSSPropertyVerticalAlign:
2460 switch (style->verticalAlign()) {
2462 return cssValuePool().createIdentifierValue(CSSValueBaseline);
2464 return cssValuePool().createIdentifierValue(CSSValueMiddle);
2466 return cssValuePool().createIdentifierValue(CSSValueSub);
2468 return cssValuePool().createIdentifierValue(CSSValueSuper);
2470 return cssValuePool().createIdentifierValue(CSSValueTextTop);
2472 return cssValuePool().createIdentifierValue(CSSValueTextBottom);
2474 return cssValuePool().createIdentifierValue(CSSValueTop);
2476 return cssValuePool().createIdentifierValue(CSSValueBottom);
2477 case BASELINE_MIDDLE:
2478 return cssValuePool().createIdentifierValue(CSSValueWebkitBaselineMiddle);
2480 return cssValuePool().createValue(style->verticalAlignLength());
2482 ASSERT_NOT_REACHED();
2484 case CSSPropertyVisibility:
2485 return cssValuePool().createValue(style->visibility());
2486 case CSSPropertyWhiteSpace:
2487 return cssValuePool().createValue(style->whiteSpace());
2488 case CSSPropertyWidows:
2489 if (style->hasAutoWidows())
2490 return cssValuePool().createIdentifierValue(CSSValueAuto);
2491 return cssValuePool().createValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
2492 case CSSPropertyWidth:
2494 // According to http://www.w3.org/TR/CSS2/visudet.html#the-width-property,
2495 // the "width" property does not apply for non-replaced inline elements.
2496 if (!renderer->isReplaced() && renderer->isInline())
2497 return cssValuePool().createIdentifierValue(CSSValueAuto);
2498 return zoomAdjustedPixelValue(sizingBox(renderer).width(), style.get());
2500 return zoomAdjustedPixelValueForLength(style->width(), style.get());
2501 case CSSPropertyWordBreak:
2502 return cssValuePool().createValue(style->wordBreak());
2503 case CSSPropertyWordSpacing:
2504 return zoomAdjustedPixelValue(style->wordSpacing(), style.get());
2505 case CSSPropertyWordWrap:
2506 return cssValuePool().createValue(style->overflowWrap());
2507 case CSSPropertyWebkitLineBreak:
2508 return cssValuePool().createValue(style->lineBreak());
2509 case CSSPropertyWebkitNbspMode:
2510 return cssValuePool().createValue(style->nbspMode());
2511 case CSSPropertyResize:
2512 return cssValuePool().createValue(style->resize());
2513 case CSSPropertyWebkitFontKerning:
2514 return cssValuePool().createValue(style->fontDescription().kerning());
2515 case CSSPropertyWebkitFontSmoothing:
2516 return cssValuePool().createValue(style->fontDescription().fontSmoothing());
2517 case CSSPropertyWebkitFontVariantLigatures: {
2518 FontDescription::LigaturesState commonLigaturesState = style->fontDescription().commonLigaturesState();
2519 FontDescription::LigaturesState discretionaryLigaturesState = style->fontDescription().discretionaryLigaturesState();
2520 FontDescription::LigaturesState historicalLigaturesState = style->fontDescription().historicalLigaturesState();
2521 if (commonLigaturesState == FontDescription::NormalLigaturesState && discretionaryLigaturesState == FontDescription::NormalLigaturesState
2522 && historicalLigaturesState == FontDescription::NormalLigaturesState)
2523 return cssValuePool().createIdentifierValue(CSSValueNormal);
2525 RefPtr<CSSValueList> valueList = CSSValueList::createSpaceSeparated();
2526 if (commonLigaturesState != FontDescription::NormalLigaturesState)
2527 valueList->append(cssValuePool().createIdentifierValue(commonLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoCommonLigatures : CSSValueCommonLigatures));
2528 if (discretionaryLigaturesState != FontDescription::NormalLigaturesState)
2529 valueList->append(cssValuePool().createIdentifierValue(discretionaryLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoDiscretionaryLigatures : CSSValueDiscretionaryLigatures));
2530 if (historicalLigaturesState != FontDescription::NormalLigaturesState)
2531 valueList->append(cssValuePool().createIdentifierValue(historicalLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoHistoricalLigatures : CSSValueHistoricalLigatures));
2534 case CSSPropertyZIndex:
2535 if (style->hasAutoZIndex())
2536 return cssValuePool().createIdentifierValue(CSSValueAuto);
2537 return cssValuePool().createValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
2538 case CSSPropertyZoom:
2539 return cssValuePool().createValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
2540 case CSSPropertyBoxSizing:
2541 if (style->boxSizing() == CONTENT_BOX)
2542 return cssValuePool().createIdentifierValue(CSSValueContentBox);
2543 return cssValuePool().createIdentifierValue(CSSValueBorderBox);
2544 #if ENABLE(DASHBOARD_SUPPORT)
2545 case CSSPropertyWebkitDashboardRegion:
2547 const Vector<StyleDashboardRegion>& regions = style->dashboardRegions();
2548 unsigned count = regions.size();
2549 if (count == 1 && regions[0].type == StyleDashboardRegion::None)
2550 return cssValuePool().createIdentifierValue(CSSValueNone);
2552 RefPtr<DashboardRegion> firstRegion;
2553 DashboardRegion* previousRegion = 0;
2554 for (unsigned i = 0; i < count; i++) {
2555 RefPtr<DashboardRegion> region = DashboardRegion::create();
2556 StyleDashboardRegion styleRegion = regions[i];
2558 region->m_label = styleRegion.label;
2559 LengthBox offset = styleRegion.offset;
2560 region->setTop(zoomAdjustedPixelValue(offset.top().value(), style.get()));
2561 region->setRight(zoomAdjustedPixelValue(offset.right().value(), style.get()));
2562 region->setBottom(zoomAdjustedPixelValue(offset.bottom().value(), style.get()));
2563 region->setLeft(zoomAdjustedPixelValue(offset.left().value(), style.get()));
2564 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
2565 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
2568 previousRegion->m_next = region;
2570 firstRegion = region;
2571 previousRegion = region.get();
2573 return cssValuePool().createValue(firstRegion.release());
2576 #if ENABLE(DRAGGABLE_REGION)
2577 case CSSPropertyWebkitAppRegion:
2578 return cssValuePool().createIdentifierValue(style->getDraggableRegionMode() == DraggableRegionDrag ? CSSValueDrag : CSSValueNoDrag);
2580 case CSSPropertyWebkitAnimationDelay:
2581 return getDelayValue(style->animations());
2582 case CSSPropertyWebkitAnimationDirection: {
2583 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2584 const AnimationList* t = style->animations();
2586 for (size_t i = 0; i < t->size(); ++i) {
2587 if (t->animation(i).direction())
2588 list->append(cssValuePool().createIdentifierValue(CSSValueAlternate));
2590 list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2593 list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
2594 return list.release();
2596 case CSSPropertyWebkitAnimationDuration:
2597 return getDurationValue(style->animations());
2598 case CSSPropertyWebkitAnimationFillMode: {
2599 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2600 const AnimationList* t = style->animations();
2602 for (size_t i = 0; i < t->size(); ++i) {
2603 switch (t->animation(i).fillMode()) {
2604 case AnimationFillModeNone:
2605 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2607 case AnimationFillModeForwards:
2608 list->append(cssValuePool().createIdentifierValue(CSSValueForwards));
2610 case AnimationFillModeBackwards:
2611 list->append(cssValuePool().createIdentifierValue(CSSValueBackwards));
2613 case AnimationFillModeBoth:
2614 list->append(cssValuePool().createIdentifierValue(CSSValueBoth));
2619 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2620 return list.release();
2622 case CSSPropertyWebkitAnimationIterationCount: {
2623 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2624 const AnimationList* t = style->animations();
2626 for (size_t i = 0; i < t->size(); ++i) {
2627 double iterationCount = t->animation(i).iterationCount();
2628 if (iterationCount == Animation::IterationCountInfinite)
2629 list->append(cssValuePool().createIdentifierValue(CSSValueInfinite));
2631 list->append(cssValuePool().createValue(iterationCount, CSSPrimitiveValue::CSS_NUMBER));
2634 list->append(cssValuePool().createValue(Animation::initialAnimationIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
2635 return list.release();
2637 case CSSPropertyWebkitAnimationName: {
2638 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2639 const AnimationList* t = style->animations();
2641 for (size_t i = 0; i < t->size(); ++i)
2642 list->append(cssValuePool().createValue(t->animation(i).name(), CSSPrimitiveValue::CSS_STRING));
2644 list->append(cssValuePool().createIdentifierValue(CSSValueNone));
2645 return list.release();
2647 case CSSPropertyWebkitAnimationPlayState: {
2648 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2649 const AnimationList* t = style->animations();
2651 for (size_t i = 0; i < t->size(); ++i) {
2652 int prop = t->animation(i).playState();
2653 if (prop == AnimPlayStatePlaying)
2654 list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2656 list->append(cssValuePool().createIdentifierValue(CSSValuePaused));
2659 list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
2660 return list.release();
2662 case CSSPropertyWebkitAnimationTimingFunction:
2663 return getTimingFunctionValue(style->animations());
2664 case CSSPropertyWebkitAppearance:
2665 return cssValuePool().createValue(style->appearance());
2666 case CSSPropertyWebkitAspectRatio:
2667 if (!style->hasAspectRatio())
2668 return cssValuePool().createIdentifierValue(CSSValueNone);
2669 return CSSAspectRatioValue::create(style->aspectRatioNumerator(), style->aspectRatioDenominator());
2670 case CSSPropertyWebkitBackfaceVisibility:
2671 return cssValuePool().createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
2672 case CSSPropertyWebkitBorderImage:
2673 return valueForNinePieceImage(style->borderImage());
2674 case CSSPropertyBorderImageOutset:
2675 return valueForNinePieceImageQuad(style->borderImage().outset());
2676 case CSSPropertyBorderImageRepeat:
2677 return valueForNinePieceImageRepeat(style->borderImage());
2678 case CSSPropertyBorderImageSlice:
2679 return valueForNinePieceImageSlice(style->borderImage());
2680 case CSSPropertyBorderImageWidth:
2681 return valueForNinePieceImageQuad(style->borderImage().borderSlices());
2682 case CSSPropertyWebkitMaskBoxImage:
2683 return valueForNinePieceImage(style->maskBoxImage());
2684 case CSSPropertyWebkitMaskBoxImageOutset:
2685 return valueForNinePieceImageQuad(style->maskBoxImage().outset());
2686 case CSSPropertyWebkitMaskBoxImageRepeat:
2687 return valueForNinePieceImageRepeat(style->maskBoxImage());
2688 case CSSPropertyWebkitMaskBoxImageSlice:
2689 return valueForNinePieceImageSlice(style->maskBoxImage());
2690 case CSSPropertyWebkitMaskBoxImageWidth:
2691 return valueForNinePieceImageQuad(style->maskBoxImage().borderSlices());
2692 case CSSPropertyWebkitMaskBoxImageSource:
2693 if (style->maskBoxImageSource())
2694 return style->maskBoxImageSource()->cssValue();
2695 return cssValuePool().createIdentifierValue(CSSValueNone);
2696 case CSSPropertyWebkitFontSizeDelta:
2697 // Not a real style property -- used by the editing engine -- so has no computed value.
2699 case CSSPropertyWebkitMarginBottomCollapse:
2700 case CSSPropertyWebkitMarginAfterCollapse:
2701 return cssValuePool().createValue(style->marginAfterCollapse());
2702 case CSSPropertyWebkitMarginTopCollapse:
2703 case CSSPropertyWebkitMarginBeforeCollapse:
2704 return cssValuePool().createValue(style->marginBeforeCollapse());
2705 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
2706 case CSSPropertyWebkitOverflowScrolling:
2707 if (!style->useTouchOverflowScrolling())
2708 return cssValuePool().createIdentifierValue(CSSValueAuto);
2709 return cssValuePool().createIdentifierValue(CSSValueTouch);
2711 case CSSPropertyWebkitPerspective:
2712 if (!style->hasPerspective())
2713 return cssValuePool().createIdentifierValue(CSSValueNone);
2714 return zoomAdjustedPixelValue(style->perspective(), style.get());
2715 case CSSPropertyWebkitPerspectiveOrigin: {
2716 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2719 if (renderer->isBox())
2720 box = toRenderBox(renderer)->borderBoxRect();
2722 RenderView* renderView = m_node->document().renderView();
2723 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginX(), box.width(), renderView), style.get()));
2724 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginY(), box.height(), renderView), style.get()));
2727 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginX(), style.get()));
2728 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginY(), style.get()));
2731 return list.release();
2733 case CSSPropertyWebkitRtlOrdering:
2734 return cssValuePool().createIdentifierValue(style->rtlOrdering() ? CSSValueVisual : CSSValueLogical);
2735 #if ENABLE(TOUCH_EVENTS)
2736 case CSSPropertyWebkitTapHighlightColor:
2737 return currentColorOrValidColor(style.get(), style->tapHighlightColor());
2740 case CSSPropertyWebkitTouchCallout:
2741 return cssValuePool().createIdentifierValue(style->touchCalloutEnabled() ? CSSValueDefault : CSSValueNone);
2743 case CSSPropertyWebkitUserDrag:
2744 return cssValuePool().createValue(style->userDrag());
2745 case CSSPropertyWebkitUserSelect:
2746 return cssValuePool().createValue(style->userSelect());
2747 case CSSPropertyBorderBottomLeftRadius:
2748 return getBorderRadiusCornerValue(style->borderBottomLeftRadius(), style.get(), m_node->document().renderView());
2749 case CSSPropertyBorderBottomRightRadius:
2750 return getBorderRadiusCornerValue(style->borderBottomRightRadius(), style.get(), m_node->document().renderView());
2751 case CSSPropertyBorderTopLeftRadius:
2752 return getBorderRadiusCornerValue(style->borderTopLeftRadius(), style.get(), m_node->document().renderView());
2753 case CSSPropertyBorderTopRightRadius:
2754 return getBorderRadiusCornerValue(style->borderTopRightRadius(), style.get(), m_node->document().renderView());
2755 case CSSPropertyClip: {
2756 if (!style->hasClip())
2757 return cssValuePool().createIdentifierValue(CSSValueAuto);
2758 RefPtr<Rect> rect = Rect::create();
2759 rect->setTop(zoomAdjustedPixelValue(style->clip().top().value(), style.get()));
2760 rect->setRight(zoomAdjustedPixelValue(style->clip().right().value(), style.get()));
2761 rect->setBottom(zoomAdjustedPixelValue(style->clip().bottom().value(), style.get()));
2762 rect->setLeft(zoomAdjustedPixelValue(style->clip().left().value(), style.get()));
2763 return cssValuePool().createValue(rect.release());
2765 case CSSPropertySpeak:
2766 return cssValuePool().createValue(style->speak());
2767 case CSSPropertyWebkitTransform:
2768 return computedTransform(renderer, style.get());
2769 case CSSPropertyWebkitTransformOrigin: {
2770 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2773 if (renderer->isBox())
2774 box = toRenderBox(renderer)->borderBoxRect();
2776 RenderView* renderView = m_node->document().renderView();
2777 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginX(), box.width(), renderView), style.get()));
2778 list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginY(), box.height(), renderView), style.get()));
2779 if (style->transformOriginZ() != 0)
2780 list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2782 list->append(zoomAdjustedPixelValueForLength(style->transformOriginX(), style.get()));
2783 list->append(zoomAdjustedPixelValueForLength(style->transformOriginY(), style.get()));
2784 if (style->transformOriginZ() != 0)
2785 list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
2787 return list.release();
2789 case CSSPropertyWebkitTransformStyle:
2790 return cssValuePool().createIdentifierValue((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat);
2791 case CSSPropertyTransitionDelay:
2792 case CSSPropertyWebkitTransitionDelay:
2793 return getDelayValue(style->transitions());
2794 case CSSPropertyTransitionDuration:
2795 case CSSPropertyWebkitTransitionDuration:
2796 return getDurationValue(style->transitions());
2797 case CSSPropertyTransitionProperty:
2798 case CSSPropertyWebkitTransitionProperty:
2799 return getTransitionPropertyValue(style->transitions());
2800 case CSSPropertyTransitionTimingFunction:
2801 case CSSPropertyWebkitTransitionTimingFunction:
2802 return getTimingFunctionValue(style->transitions());
2803 case CSSPropertyTransition:
2804 case CSSPropertyWebkitTransition: {
2805 const AnimationList* animList = style->transitions();
2807 RefPtr<CSSValueList> transitionsList = CSSValueList::createCommaSeparated();
2808 for (size_t i = 0; i < animList->size(); ++i) {
2809 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2810 const Animation& animation = animList->animation(i);
2811 list->append(createTransitionPropertyValue(animation));
2812 list->append(cssValuePool().createValue(animation.duration(), CSSPrimitiveValue::CSS_S));
2813 list->append(createTimingFunctionValue(animation.timingFunction().get()));
2814 list->append(cssValuePool().createValue(animation.delay(), CSSPrimitiveValue::CSS_S));
2815 transitionsList->append(list);
2817 return transitionsList.release();
2820 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2821 // transition-property default value.
2822 list->append(cssValuePool().createIdentifierValue(CSSValueAll));
2823 list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
2824 list->append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
2825 list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
2826 return list.release();
2828 case CSSPropertyPointerEvents:
2829 return cssValuePool().createValue(style->pointerEvents());
2830 case CSSPropertyWebkitColorCorrection:
2831 return cssValuePool().createValue(style->colorSpace());
2832 case CSSPropertyWebkitLineGrid:
2833 if (style->lineGrid().isNull())
2834 return cssValuePool().createIdentifierValue(CSSValueNone);
2835 return cssValuePool().createValue(style->lineGrid(), CSSPrimitiveValue::CSS_STRING);
2836 case CSSPropertyWebkitLineSnap:
2837 return CSSPrimitiveValue::create(style->lineSnap());
2838 case CSSPropertyWebkitLineAlign:
2839 return CSSPrimitiveValue::create(style->lineAlign());
2840 case CSSPropertyWebkitWritingMode:
2841 return cssValuePool().createValue(style->writingMode());
2842 case CSSPropertyWebkitTextCombine:
2843 return cssValuePool().createValue(style->textCombine());
2844 case CSSPropertyWebkitTextOrientation:
2845 return CSSPrimitiveValue::create(style->textOrientation());
2846 case CSSPropertyWebkitLineBoxContain:
2847 return createLineBoxContainValue(style->lineBoxContain());
2848 case CSSPropertyWebkitAlt:
2849 return altTextToCSSValue(style.get());
2850 case CSSPropertyContent:
2851 return contentToCSSValue(style.get());
2852 case CSSPropertyCounterIncrement:
2853 return counterToCSSValue(style.get(), propertyID);
2854 case CSSPropertyCounterReset:
2855 return counterToCSSValue(style.get(), propertyID);
2856 case CSSPropertyWebkitClipPath:
2857 if (ClipPathOperation* operation = style->clipPath()) {
2858 if (operation->type() == ClipPathOperation::SHAPE)
2859 return valueForBasicShape(style.get(), static_cast<ShapeClipPathOperation*>(operation)->basicShape());
2861 if (operation->type() == ClipPathOperation::REFERENCE) {
2862 ReferenceClipPathOperation* referenceOperation = static_cast<ReferenceClipPathOperation*>(operation);
2863 return CSSPrimitiveValue::create(referenceOperation->url(), CSSPrimitiveValue::CSS_URI);
2867 return cssValuePool().createIdentifierValue(CSSValueNone);
2868 #if ENABLE(CSS_REGIONS)
2869 case CSSPropertyWebkitFlowInto:
2870 if (style->flowThread().isNull())
2871 return cssValuePool().createIdentifierValue(CSSValueNone);
2872 return cssValuePool().createValue(style->flowThread(), CSSPrimitiveValue::CSS_STRING);
2873 case CSSPropertyWebkitFlowFrom:
2874 if (!style->hasFlowFrom())
2875 return cssValuePool().createIdentifierValue(CSSValueNone);
2876 return cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING);
2877 case CSSPropertyWebkitRegionFragment:
2878 return cssValuePool().createValue(style->regionFragment());
2880 #if ENABLE(CSS_EXCLUSIONS)
2881 case CSSPropertyWebkitWrapFlow:
2882 return cssValuePool().createValue(style->wrapFlow());
2883 case CSSPropertyWebkitWrapThrough:
2884 return cssValuePool().createValue(style->wrapThrough());
2886 #if ENABLE(CSS_SHAPES)
2887 case CSSPropertyWebkitShapeMargin:
2888 return cssValuePool().createValue(style->shapeMargin());
2889 case CSSPropertyWebkitShapePadding:
2890 return cssValuePool().createValue(style->shapePadding());
2891 case CSSPropertyWebkitShapeImageThreshold:
2892 return cssValuePool().createValue(style->shapeImageThreshold(), CSSPrimitiveValue::CSS_NUMBER);
2893 case CSSPropertyWebkitShapeInside:
2894 if (!style->shapeInside())
2895 return cssValuePool().createIdentifierValue(CSSValueAuto);
2896 if (style->shapeInside()->type() == ShapeValue::Box)
2897 return valueForBox(style->shapeInside()->box());
2898 if (style->shapeInside()->type() == ShapeValue::Outside)
2899 return cssValuePool().createIdentifierValue(CSSValueOutsideShape);
2900 if (style->shapeInside()->type() == ShapeValue::Image) {
2901 if (style->shapeInside()->image())
2902 return style->shapeInside()->image()->cssValue();
2903 return cssValuePool().createIdentifierValue(CSSValueNone);
2905 ASSERT(style->shapeInside()->type() == ShapeValue::Shape);
2906 return valueForBasicShape(style.get(), style->shapeInside()->shape());
2907 case CSSPropertyWebkitShapeOutside:
2908 if (!style->shapeOutside())
2909 return cssValuePool().createIdentifierValue(CSSValueAuto);
2910 if (style->shapeOutside()->type() == ShapeValue::Box)
2911 return valueForBox(style->shapeOutside()->box());
2912 if (style->shapeOutside()->type() == ShapeValue::Image) {
2913 if (style->shapeOutside()->image())
2914 return style->shapeOutside()->image()->cssValue();
2915 return cssValuePool().createIdentifierValue(CSSValueNone);
2917 ASSERT(style->shapeOutside()->type() == ShapeValue::Shape);
2918 return valueForBasicShape(style.get(), style->shapeOutside()->shape());
2920 #if ENABLE(CSS_FILTERS)
2921 case CSSPropertyWebkitFilter:
2922 return valueForFilter(renderer, style.get(), style->filter());
2924 #if ENABLE(CSS_COMPOSITING)
2925 case CSSPropertyWebkitBlendMode:
2926 return cssValuePool().createValue(style->blendMode());
2928 case CSSPropertyWebkitBackgroundBlendMode: {
2929 const FillLayer* layers = style->backgroundLayers();
2930 if (!layers->next())
2931 return cssValuePool().createValue(layers->blendMode());
2933 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2934 for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
2935 list->append(cssValuePool().createValue(currLayer->blendMode()));
2937 return list.release();
2939 case CSSPropertyBackground:
2940 return getBackgroundShorthandValue();
2941 case CSSPropertyBorder: {
2942 RefPtr<CSSValue> value = propertyValue(CSSPropertyBorderTop, DoNotUpdateLayout);
2943 const CSSPropertyID properties[3] = { CSSPropertyBorderRight, CSSPropertyBorderBottom,
2944 CSSPropertyBorderLeft };
2945 for (size_t i = 0; i < WTF_ARRAY_LENGTH(properties); ++i) {
2946 if (!compareCSSValuePtr<CSSValue>(value, propertyValue(properties[i], DoNotUpdateLayout)))
2949 return value.release();
2951 case CSSPropertyBorderBottom:
2952 return getCSSPropertyValuesForShorthandProperties(borderBottomShorthand());
2953 case CSSPropertyBorderColor:
2954 return getCSSPropertyValuesForSidesShorthand(borderColorShorthand());
2955 case CSSPropertyBorderLeft:
2956 return getCSSPropertyValuesForShorthandProperties(borderLeftShorthand());
2957 case CSSPropertyBorderImage:
2958 return valueForNinePieceImage(style->borderImage());
2959 case CSSPropertyBorderRadius:
2960 return getBorderRadiusShorthandValue(style.get(), m_node->document().renderView());
2961 case CSSPropertyBorderRight:
2962 return getCSSPropertyValuesForShorthandProperties(borderRightShorthand());
2963 case CSSPropertyBorderStyle:
2964 return getCSSPropertyValuesForSidesShorthand(borderStyleShorthand());
2965 case CSSPropertyBorderTop:
2966 return getCSSPropertyValuesForShorthandProperties(borderTopShorthand());
2967 case CSSPropertyBorderWidth:
2968 return getCSSPropertyValuesForSidesShorthand(borderWidthShorthand());
2969 case CSSPropertyWebkitColumnRule:
2970 return getCSSPropertyValuesForShorthandProperties(webkitColumnRuleShorthand());
2971 case CSSPropertyWebkitColumns:
2972 return getCSSPropertyValuesForShorthandProperties(webkitColumnsShorthand());
2973 case CSSPropertyListStyle:
2974 return getCSSPropertyValuesForShorthandProperties(listStyleShorthand());
2975 case CSSPropertyMargin:
2976 return getCSSPropertyValuesForSidesShorthand(marginShorthand());
2977 case CSSPropertyOutline:
2978 return getCSSPropertyValuesForShorthandProperties(outlineShorthand());
2979 case CSSPropertyPadding:
2980 return getCSSPropertyValuesForSidesShorthand(paddingShorthand());
2981 /* Individual properties not part of the spec */
2982 case CSSPropertyBackgroundRepeatX:
2983 case CSSPropertyBackgroundRepeatY:
2986 /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
2987 case CSSPropertyWebkitTextEmphasis:
2988 case CSSPropertyTextLineThrough:
2989 case CSSPropertyTextLineThroughColor:
2990 case CSSPropertyTextLineThroughMode:
2991 case CSSPropertyTextLineThroughStyle:
2992 case CSSPropertyTextLineThroughWidth:
2993 case CSSPropertyTextOverline:
2994 case CSSPropertyTextOverlineColor:
2995 case CSSPropertyTextOverlineMode:
2996 case CSSPropertyTextOverlineStyle:
2997 case CSSPropertyTextOverlineWidth:
2998 case CSSPropertyTextUnderline:
2999 case CSSPropertyTextUnderlineColor:
3000 case CSSPropertyTextUnderlineMode:
3001 case CSSPropertyTextUnderlineStyle:
3002 case CSSPropertyTextUnderlineWidth:
3005 /* Directional properties are resolved by resolveDirectionAwareProperty() before the switch. */
3006 case CSSPropertyWebkitBorderEnd:
3007 case CSSPropertyWebkitBorderEndColor:
3008 case CSSPropertyWebkitBorderEndStyle:
3009 case CSSPropertyWebkitBorderEndWidth:
3010 case CSSPropertyWebkitBorderStart:
3011 case CSSPropertyWebkitBorderStartColor:
3012 case CSSPropertyWebkitBorderStartStyle:
3013 case CSSPropertyWebkitBorderStartWidth:
3014 case CSSPropertyWebkitBorderAfter:
3015 case CSSPropertyWebkitBorderAfterColor:
3016 case CSSPropertyWebkitBorderAfterStyle:
3017 case CSSPropertyWebkitBorderAfterWidth:
3018 case CSSPropertyWebkitBorderBefore:
3019 case CSSPropertyWebkitBorderBeforeColor:
3020 case CSSPropertyWebkitBorderBeforeStyle:
3021 case CSSPropertyWebkitBorderBeforeWidth:
3022 case CSSPropertyWebkitMarginEnd:
3023 case CSSPropertyWebkitMarginStart:
3024 case CSSPropertyWebkitMarginAfter:
3025 case CSSPropertyWebkitMarginBefore:
3026 case CSSPropertyWebkitPaddingEnd:
3027 case CSSPropertyWebkitPaddingStart:
3028 case CSSPropertyWebkitPaddingAfter:
3029 case CSSPropertyWebkitPaddingBefore:
3030 case CSSPropertyWebkitLogicalWidth:
3031 case CSSPropertyWebkitLogicalHeight:
3032 case CSSPropertyWebkitMinLogicalWidth:
3033 case CSSPropertyWebkitMinLogicalHeight:
3034 case CSSPropertyWebkitMaxLogicalWidth:
3035 case CSSPropertyWebkitMaxLogicalHeight:
3036 ASSERT_NOT_REACHED();
3039 /* Unimplemented @font-face properties */
3040 case CSSPropertyFontStretch:
3041 case CSSPropertySrc:
3042 case CSSPropertyUnicodeRange:
3045 /* Other unimplemented properties */
3046 #if ENABLE(CSS_SHADERS)
3047 case CSSPropertyGeometry:
3049 case CSSPropertyPage: // for @page
3050 case CSSPropertyQuotes: // FIXME: needs implementation
3051 case CSSPropertySize: // for @page
3054 /* Unimplemented -webkit- properties */
3055 case CSSPropertyWebkitAnimation:
3056 case CSSPropertyWebkitBorderRadius:
3057 case CSSPropertyWebkitMarginCollapse:
3058 case CSSPropertyWebkitMarquee:
3059 case CSSPropertyWebkitMarqueeSpeed:
3060 case CSSPropertyWebkitMask:
3061 case CSSPropertyWebkitMaskRepeatX:
3062 case CSSPropertyWebkitMaskRepeatY:
3063 case CSSPropertyWebkitPerspectiveOriginX:
3064 case CSSPropertyWebkitPerspectiveOriginY:
3065 case CSSPropertyWebkitTextStroke:
3066 case CSSPropertyWebkitTransformOriginX:
3067 case CSSPropertyWebkitTransformOriginY:
3068 case CSSPropertyWebkitTransformOriginZ:
3069 #if ENABLE(CSS_SHADERS)
3070 case CSSPropertyMix:
3071 case CSSPropertyParameters:
3075 #if ENABLE(CSS_DEVICE_ADAPTATION)
3076 case CSSPropertyMaxZoom:
3077 case CSSPropertyMinZoom:
3078 case CSSPropertyOrientation:
3079 case CSSPropertyUserZoom:
3084 case CSSPropertyBufferedRendering:
3085 case CSSPropertyClipPath:
3086 case CSSPropertyClipRule:
3087 case CSSPropertyMask:
3088 case CSSPropertyEnableBackground:
3089 case CSSPropertyFilter:
3090 case CSSPropertyFloodColor:
3091 case CSSPropertyFloodOpacity:
3092 case CSSPropertyLightingColor:
3093 case CSSPropertyStopColor:
3094 case CSSPropertyStopOpacity:
3095 case CSSPropertyColorInterpolation:
3096 case CSSPropertyColorInterpolationFilters:
3097 case CSSPropertyColorProfile:
3098 case CSSPropertyColorRendering:
3099 case CSSPropertyFill:
3100 case CSSPropertyFillOpacity:
3101 case CSSPropertyFillRule:
3102 case CSSPropertyMarker:
3103 case CSSPropertyMarkerEnd:
3104 case CSSPropertyMarkerMid:
3105 case CSSPropertyMarkerStart:
3106 case CSSPropertyMaskType:
3107 case CSSPropertyShapeRendering:
3108 case CSSPropertyStroke:
3109 case CSSPropertyStrokeDasharray:
3110 case CSSPropertyStrokeDashoffset:
3111 case CSSPropertyStrokeLinecap:
3112 case CSSPropertyStrokeLinejoin:
3113 case CSSPropertyStrokeMiterlimit:
3114 case CSSPropertyStrokeOpacity:
3115 case CSSPropertyStrokeWidth:
3116 case CSSPropertyAlignmentBaseline:
3117 case CSSPropertyBaselineShift:
3118 case CSSPropertyDominantBaseline:
3119 case CSSPropertyGlyphOrientationHorizontal:
3120 case CSSPropertyGlyphOrientationVertical:
3121 case CSSPropertyKerning:
3122 case CSSPropertyTextAnchor:
3123 case CSSPropertyVectorEffect:
3124 case CSSPropertyWritingMode:
3125 case CSSPropertyWebkitSvgShadow:
3126 return svgPropertyValue(propertyID, DoNotUpdateLayout);
3130 logUnimplementedPropertyID(propertyID);
3134 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) const
3136 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
3138 return value->cssText();
3142 unsigned CSSComputedStyleDeclaration::length() const
3144 Node* node = m_node.get();
3148 RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier);
3152 return numComputedProperties;
3155 String CSSComputedStyleDeclaration::item(unsigned i) const
3160 return getPropertyNameString(computedProperties[i]);
3163 bool ComputedStyleExtractor::propertyMatches(CSSPropertyID propertyID, const CSSValue* value) const
3165 if (propertyID == CSSPropertyFontSize && value->isPrimitiveValue() && m_node) {
3166 m_node->document().updateLayoutIgnorePendingStylesheets();
3167 RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier);
3168 if (style && style->fontDescription().keywordSize()) {
3169 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize());
3170 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
3171 if (primitiveValue->isValueID() && primitiveValue->getValueID() == sizeValue)
3175 RefPtr<CSSValue> computedValue = propertyValue(propertyID);
3176 return computedValue && value && computedValue->equals(*value);
3179 PassRef<MutableStyleProperties> ComputedStyleExtractor::copyProperties() const
3181 return copyPropertiesInSet(computedProperties, numComputedProperties);
3184 PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand& shorthand) const
3186 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
3187 for (size_t i = 0; i < shorthand.length(); ++i) {
3188 RefPtr<CSSValue> value = propertyValue(shorthand.properties()[i], DoNotUpdateLayout);
3189 list->append(value);
3191 return list.release();
3194 PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand& shorthand) const
3196 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
3197 // Assume the properties are in the usual order top, right, bottom, left.
3198 RefPtr<CSSValue> topValue = propertyValue(shorthand.properties()[0], DoNotUpdateLayout);
3199 RefPtr<CSSValue> rightValue = propertyValue(shorthand.properties()[1], DoNotUpdateLayout);
3200 RefPtr<CSSValue> bottomValue = propertyValue(shorthand.properties()[2], DoNotUpdateLayout);
3201 RefPtr<CSSValue> leftValue = propertyValue(shorthand.properties()[3], DoNotUpdateLayout);
3203 // All 4 properties must be specified.
3204 if (!topValue || !rightValue || !bottomValue || !leftValue)
3207 bool showLeft = !compareCSSValuePtr(rightValue, leftValue);
3208 bool showBottom = !compareCSSValuePtr(topValue, bottomValue) || showLeft;
3209 bool showRight = !compareCSSValuePtr(topValue, rightValue) || showBottom;
3211 list->append(topValue.release());
3213 list->append(rightValue.release());
3215 list->append(bottomValue.release());
3217 list->append(leftValue.release());
3219 return list.release();
3222 PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForGridShorthand(const StylePropertyShorthand& shorthand) const
3224 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3225 for (size_t i = 0; i < shorthand.length(); ++i) {
3226 RefPtr<CSSValue> value = propertyValue(shorthand.properties()[i], DoNotUpdateLayout);
3227 list->append(value.release());
3229 return list.release();
3232 PassRef<MutableStyleProperties> ComputedStyleExtractor::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const
3234 Vector<CSSProperty, 256> list;
3235 list.reserveInitialCapacity(length);
3236 for (unsigned i = 0; i < length; ++i) {
3237 RefPtr<CSSValue> value = propertyValue(set[i]);
3239 list.append(CSSProperty(set[i], value.release(), false));
3241 return MutableStyleProperties::create(list.data(), list.size());
3244 CSSRule* CSSComputedStyleDeclaration::parentRule() const
3249 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(const String& propertyName)
3251 CSSPropertyID propertyID = cssPropertyID(propertyName);
3254 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
3255 return value ? value->cloneForCSSOM() : 0;
3258 String CSSComputedStyleDeclaration::getPropertyValue(const String &propertyName)
3260 CSSPropertyID propertyID = cssPropertyID(propertyName);
3263 return getPropertyValue(propertyID);
3266 String CSSComputedStyleDeclaration::getPropertyPriority(const String&)
3268 // All computed styles have a priority of not "important".
3272 String CSSComputedStyleDeclaration::getPropertyShorthand(const String&)
3277 bool CSSComputedStyleDeclaration::isPropertyImplicit(const String&)
3282 void CSSComputedStyleDeclaration::setProperty(const String&, const String&, const String&, ExceptionCode& ec)
3284 ec = NO_MODIFICATION_ALLOWED_ERR;
3287 String CSSComputedStyleDeclaration::removeProperty(const String&, ExceptionCode& ec)
3289 ec = NO_MODIFICATION_ALLOWED_ERR;
3293 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
3295 return getPropertyCSSValue(propertyID);
3298 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
3300 return getPropertyValue(propertyID);
3303 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const String&, bool, ExceptionCode& ec)
3305 ec = NO_MODIFICATION_ALLOWED_ERR;
3308 PassRefPtr<CSSValueList> ComputedStyleExtractor::getBackgroundShorthandValue() const
3310 static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage,
3311 CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment,
3312 CSSPropertyBackgroundPosition };
3313 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyBackgroundSize, CSSPropertyBackgroundOrigin,
3314 CSSPropertyBackgroundClip };
3316 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3317 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(CSSPropertyBackground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperator))));
3318 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(CSSPropertyBackground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator))));
3319 return list.release();
3322 } // namespace WebCore