2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
11 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are
16 * * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * * Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following disclaimer
20 * in the documentation and/or other materials provided with the
22 * * Neither the name of Google Inc. nor the names of its
23 * contributors may be used to endorse or promote products derived from
24 * this software without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 #include "StyleBuilderFunctions.h"
42 #include "CSSPropertyNames.h"
43 #include "CSSValueKeywords.h"
44 #include "StylePropertyShorthand.h"
45 #include "core/css/BasicShapeFunctions.h"
46 #include "core/css/CSSAspectRatioValue.h"
47 #include "core/css/CSSCursorImageValue.h"
48 #include "core/css/CSSFontValue.h"
49 #include "core/css/CSSFunctionValue.h"
50 #include "core/css/CSSGradientValue.h"
51 #include "core/css/CSSGridLineNamesValue.h"
52 #include "core/css/CSSGridTemplateAreasValue.h"
53 #include "core/css/CSSHelper.h"
54 #include "core/css/CSSImageSetValue.h"
55 #include "core/css/CSSLineBoxContainValue.h"
56 #include "core/css/parser/BisonCSSParser.h"
57 #include "core/css/CSSPrimitiveValueMappings.h"
58 #include "core/css/CSSProperty.h"
59 #include "core/css/CSSReflectValue.h"
60 #include "core/css/Counter.h"
61 #include "core/css/Pair.h"
62 #include "core/css/Rect.h"
63 #include "core/css/StylePropertySet.h"
64 #include "core/css/StyleRule.h"
65 #include "core/css/resolver/ElementStyleResources.h"
66 #include "core/css/resolver/FilterOperationResolver.h"
67 #include "core/css/resolver/FontBuilder.h"
68 #include "core/css/resolver/StyleBuilder.h"
69 #include "core/css/resolver/TransformBuilder.h"
70 #include "core/frame/Frame.h"
71 #include "core/frame/Settings.h"
72 #include "core/rendering/style/CounterContent.h"
73 #include "core/rendering/style/CursorList.h"
74 #include "core/rendering/style/QuotesData.h"
75 #include "core/rendering/style/RenderStyle.h"
76 #include "core/rendering/style/RenderStyleConstants.h"
77 #include "core/rendering/style/SVGRenderStyle.h"
78 #include "core/rendering/style/SVGRenderStyleDefs.h"
79 #include "core/rendering/style/StyleGeneratedImage.h"
80 #include "core/svg/SVGColor.h"
81 #include "core/svg/SVGPaint.h"
82 #include "platform/fonts/FontDescription.h"
83 #include "wtf/MathExtras.h"
84 #include "wtf/StdLibExtras.h"
85 #include "wtf/Vector.h"
89 static Length clipConvertToLength(StyleResolverState& state, CSSPrimitiveValue* value)
91 return value->convertToLength<FixedConversion | PercentConversion | AutoConversion>(state.cssToLengthConversionData());
94 void StyleBuilderFunctions::applyInitialCSSPropertyClip(StyleResolverState& state)
96 state.style()->setClip(Length(), Length(), Length(), Length());
97 state.style()->setHasClip(false);
100 void StyleBuilderFunctions::applyInheritCSSPropertyClip(StyleResolverState& state)
102 RenderStyle* parentStyle = state.parentStyle();
103 if (!parentStyle->hasClip())
104 return applyInitialCSSPropertyClip(state);
105 state.style()->setClip(parentStyle->clipTop(), parentStyle->clipRight(), parentStyle->clipBottom(), parentStyle->clipLeft());
106 state.style()->setHasClip(true);
109 void StyleBuilderFunctions::applyValueCSSPropertyClip(StyleResolverState& state, CSSValue* value)
111 if (!value->isPrimitiveValue())
114 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
116 if (Rect* rect = primitiveValue->getRectValue()) {
117 Length top = clipConvertToLength(state, rect->top());
118 Length right = clipConvertToLength(state, rect->right());
119 Length bottom = clipConvertToLength(state, rect->bottom());
120 Length left = clipConvertToLength(state, rect->left());
121 state.style()->setClip(top, right, bottom, left);
122 state.style()->setHasClip(true);
123 } else if (primitiveValue->getValueID() == CSSValueAuto) {
124 state.style()->setClip(Length(), Length(), Length(), Length());
125 state.style()->setHasClip(false);
129 void StyleBuilderFunctions::applyInitialCSSPropertyColor(StyleResolverState& state)
131 Color color = RenderStyle::initialColor();
132 if (state.applyPropertyToRegularStyle())
133 state.style()->setColor(color);
134 if (state.applyPropertyToVisitedLinkStyle())
135 state.style()->setVisitedLinkColor(color);
138 void StyleBuilderFunctions::applyInheritCSSPropertyColor(StyleResolverState& state)
140 Color color = state.parentStyle()->color();
141 if (state.applyPropertyToRegularStyle())
142 state.style()->setColor(color);
143 if (state.applyPropertyToVisitedLinkStyle())
144 state.style()->setVisitedLinkColor(color);
147 void StyleBuilderFunctions::applyValueCSSPropertyColor(StyleResolverState& state, CSSValue* value)
149 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
150 // As per the spec, 'color: currentColor' is treated as 'color: inherit'
151 if (primitiveValue->getValueID() == CSSValueCurrentcolor) {
152 applyInheritCSSPropertyColor(state);
156 if (state.applyPropertyToRegularStyle())
157 state.style()->setColor(state.document().textLinkColors().colorFromPrimitiveValue(primitiveValue, state.style()->color()));
158 if (state.applyPropertyToVisitedLinkStyle())
159 state.style()->setVisitedLinkColor(state.document().textLinkColors().colorFromPrimitiveValue(primitiveValue, state.style()->color(), state.element()->isLink() /* forVisitedLink */));
162 void StyleBuilderFunctions::applyInitialCSSPropertyCursor(StyleResolverState& state)
164 state.style()->clearCursorList();
165 state.style()->setCursor(RenderStyle::initialCursor());
168 void StyleBuilderFunctions::applyInheritCSSPropertyCursor(StyleResolverState& state)
170 state.style()->setCursor(state.parentStyle()->cursor());
171 state.style()->setCursorList(state.parentStyle()->cursors());
174 void StyleBuilderFunctions::applyValueCSSPropertyCursor(StyleResolverState& state, CSSValue* value)
176 state.style()->clearCursorList();
177 if (value->isValueList()) {
178 CSSValueList* list = toCSSValueList(value);
179 int len = list->length();
180 state.style()->setCursor(CURSOR_AUTO);
181 for (int i = 0; i < len; i++) {
182 CSSValue* item = list->itemWithoutBoundsCheck(i);
183 if (item->isCursorImageValue()) {
184 CSSCursorImageValue* image = toCSSCursorImageValue(item);
185 if (image->updateIfSVGCursorIsUsed(state.element())) // Elements with SVG cursors are not allowed to share style.
186 state.style()->setUnique();
187 state.style()->addCursor(state.styleImage(CSSPropertyCursor, image), image->hotSpot());
188 } else if (item->isPrimitiveValue()) {
189 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(item);
190 if (primitiveValue->isValueID())
191 state.style()->setCursor(*primitiveValue);
194 } else if (value->isPrimitiveValue()) {
195 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
196 if (primitiveValue->isValueID() && state.style()->cursor() != ECursor(*primitiveValue))
197 state.style()->setCursor(*primitiveValue);
201 void StyleBuilderFunctions::applyValueCSSPropertyDirection(StyleResolverState& state, CSSValue* value)
203 state.style()->setDirection(*toCSSPrimitiveValue(value));
204 Element* element = state.element();
205 if (element && element == element->document().documentElement())
206 element->document().setDirectionSetOnDocumentElement(true);
209 static inline bool isValidDisplayValue(StyleResolverState& state, EDisplay displayPropertyValue)
211 if (state.element() && state.element()->isSVGElement() && state.style()->styleType() == NOPSEUDO)
212 return (displayPropertyValue == INLINE || displayPropertyValue == BLOCK || displayPropertyValue == NONE);
216 void StyleBuilderFunctions::applyInheritCSSPropertyDisplay(StyleResolverState& state)
218 EDisplay display = state.parentStyle()->display();
219 if (!isValidDisplayValue(state, display))
221 state.style()->setDisplay(display);
224 void StyleBuilderFunctions::applyValueCSSPropertyDisplay(StyleResolverState& state, CSSValue* value)
226 if (!value->isPrimitiveValue())
229 EDisplay display = *toCSSPrimitiveValue(value);
231 if (!isValidDisplayValue(state, display))
234 state.style()->setDisplay(display);
237 void StyleBuilderFunctions::applyInitialCSSPropertyFontFamily(StyleResolverState& state)
239 state.fontBuilder().setFontFamilyInitial(state.style()->effectiveZoom());
242 void StyleBuilderFunctions::applyInheritCSSPropertyFontFamily(StyleResolverState& state)
244 state.fontBuilder().setFontFamilyInherit(state.parentFontDescription());
247 void StyleBuilderFunctions::applyValueCSSPropertyFontFamily(StyleResolverState& state, CSSValue* value)
249 state.fontBuilder().setFontFamilyValue(value, state.style()->effectiveZoom());
252 void StyleBuilderFunctions::applyInitialCSSPropertyFontSize(StyleResolverState& state)
254 state.fontBuilder().setFontSizeInitial(state.style()->effectiveZoom());
257 void StyleBuilderFunctions::applyInheritCSSPropertyFontSize(StyleResolverState& state)
259 state.fontBuilder().setFontSizeInherit(state.parentFontDescription(), state.style()->effectiveZoom());
262 void StyleBuilderFunctions::applyValueCSSPropertyFontSize(StyleResolverState& state, CSSValue* value)
264 state.fontBuilder().setFontSizeValue(value, state.parentStyle(), state.rootElementStyle(), state.style()->effectiveZoom());
267 void StyleBuilderFunctions::applyInitialCSSPropertyFontWeight(StyleResolverState& state)
269 state.fontBuilder().setWeight(FontWeightNormal);
272 void StyleBuilderFunctions::applyInheritCSSPropertyFontWeight(StyleResolverState& state)
274 state.fontBuilder().setWeight(state.parentFontDescription().weight());
277 void StyleBuilderFunctions::applyValueCSSPropertyFontWeight(StyleResolverState& state, CSSValue* value)
279 if (!value->isPrimitiveValue())
281 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
282 switch (primitiveValue->getValueID()) {
283 case CSSValueInvalid:
284 ASSERT_NOT_REACHED();
287 state.fontBuilder().setWeight(state.parentStyle()->fontDescription().weight());
288 state.fontBuilder().setWeightBolder();
290 case CSSValueLighter:
291 state.fontBuilder().setWeight(state.parentStyle()->fontDescription().weight());
292 state.fontBuilder().setWeightLighter();
295 state.fontBuilder().setWeight(*primitiveValue);
299 void StyleBuilderFunctions::applyValueCSSPropertyLineHeight(StyleResolverState& state, CSSValue* value)
301 if (!value->isPrimitiveValue())
304 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
307 if (primitiveValue->getValueID() == CSSValueNormal) {
308 lineHeight = RenderStyle::initialLineHeight();
309 } else if (primitiveValue->isLength()) {
310 float multiplier = state.style()->effectiveZoom();
311 if (Frame* frame = state.document().frame())
312 multiplier *= frame->textZoomFactor();
313 lineHeight = primitiveValue->computeLength<Length>(state.cssToLengthConversionData().copyWithAdjustedZoom(multiplier));
314 } else if (primitiveValue->isPercentage()) {
315 lineHeight = Length((state.style()->computedFontSize() * primitiveValue->getIntValue()) / 100.0, Fixed);
316 } else if (primitiveValue->isNumber()) {
317 lineHeight = Length(primitiveValue->getDoubleValue() * 100.0, Percent);
318 } else if (primitiveValue->isCalculated()) {
319 double multiplier = state.style()->effectiveZoom();
320 if (Frame* frame = state.document().frame())
321 multiplier *= frame->textZoomFactor();
322 Length zoomedLength = Length(primitiveValue->cssCalcValue()->toCalcValue(state.cssToLengthConversionData().copyWithAdjustedZoom(multiplier)));
323 lineHeight = Length(valueForLength(zoomedLength, state.style()->fontSize()), Fixed);
327 state.style()->setLineHeight(lineHeight);
330 void StyleBuilderFunctions::applyValueCSSPropertyListStyleImage(StyleResolverState& state, CSSValue* value)
332 state.style()->setListStyleImage(state.styleImage(CSSPropertyListStyleImage, value));
335 void StyleBuilderFunctions::applyInitialCSSPropertyOutlineStyle(StyleResolverState& state)
337 state.style()->setOutlineStyleIsAuto(RenderStyle::initialOutlineStyleIsAuto());
338 state.style()->setOutlineStyle(RenderStyle::initialBorderStyle());
341 void StyleBuilderFunctions::applyInheritCSSPropertyOutlineStyle(StyleResolverState& state)
343 state.style()->setOutlineStyleIsAuto(state.parentStyle()->outlineStyleIsAuto());
344 state.style()->setOutlineStyle(state.parentStyle()->outlineStyle());
347 void StyleBuilderFunctions::applyValueCSSPropertyOutlineStyle(StyleResolverState& state, CSSValue* value)
349 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
350 state.style()->setOutlineStyleIsAuto(*primitiveValue);
351 state.style()->setOutlineStyle(*primitiveValue);
354 void StyleBuilderFunctions::applyValueCSSPropertyResize(StyleResolverState& state, CSSValue* value)
356 if (!value->isPrimitiveValue())
359 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
361 EResize r = RESIZE_NONE;
362 switch (primitiveValue->getValueID()) {
366 if (Settings* settings = state.document().settings())
367 r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE;
372 state.style()->setResize(r);
375 static Length mmLength(double mm) { return Length(mm * cssPixelsPerMillimeter, Fixed); }
376 static Length inchLength(double inch) { return Length(inch * cssPixelsPerInch, Fixed); }
377 static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height)
379 DEFINE_STATIC_LOCAL(Length, a5Width, (mmLength(148)));
380 DEFINE_STATIC_LOCAL(Length, a5Height, (mmLength(210)));
381 DEFINE_STATIC_LOCAL(Length, a4Width, (mmLength(210)));
382 DEFINE_STATIC_LOCAL(Length, a4Height, (mmLength(297)));
383 DEFINE_STATIC_LOCAL(Length, a3Width, (mmLength(297)));
384 DEFINE_STATIC_LOCAL(Length, a3Height, (mmLength(420)));
385 DEFINE_STATIC_LOCAL(Length, b5Width, (mmLength(176)));
386 DEFINE_STATIC_LOCAL(Length, b5Height, (mmLength(250)));
387 DEFINE_STATIC_LOCAL(Length, b4Width, (mmLength(250)));
388 DEFINE_STATIC_LOCAL(Length, b4Height, (mmLength(353)));
389 DEFINE_STATIC_LOCAL(Length, letterWidth, (inchLength(8.5)));
390 DEFINE_STATIC_LOCAL(Length, letterHeight, (inchLength(11)));
391 DEFINE_STATIC_LOCAL(Length, legalWidth, (inchLength(8.5)));
392 DEFINE_STATIC_LOCAL(Length, legalHeight, (inchLength(14)));
393 DEFINE_STATIC_LOCAL(Length, ledgerWidth, (inchLength(11)));
394 DEFINE_STATIC_LOCAL(Length, ledgerHeight, (inchLength(17)));
399 switch (pageSizeName->getValueID()) {
422 height = letterHeight;
426 height = legalHeight;
430 height = ledgerHeight;
436 if (pageOrientation) {
437 switch (pageOrientation->getValueID()) {
438 case CSSValueLandscape:
439 std::swap(width, height);
441 case CSSValuePortrait:
451 void StyleBuilderFunctions::applyInitialCSSPropertySize(StyleResolverState&) { }
452 void StyleBuilderFunctions::applyInheritCSSPropertySize(StyleResolverState&) { }
453 void StyleBuilderFunctions::applyValueCSSPropertySize(StyleResolverState& state, CSSValue* value)
455 state.style()->resetPageSizeType();
458 PageSizeType pageSizeType = PAGE_SIZE_AUTO;
459 CSSValueListInspector inspector(value);
460 switch (inspector.length()) {
462 // <length>{2} | <page-size> <orientation>
463 if (!inspector.first()->isPrimitiveValue() || !inspector.second()->isPrimitiveValue())
465 CSSPrimitiveValue* first = toCSSPrimitiveValue(inspector.first());
466 CSSPrimitiveValue* second = toCSSPrimitiveValue(inspector.second());
467 if (first->isLength()) {
469 if (!second->isLength())
471 width = first->computeLength<Length>(state.cssToLengthConversionData().copyWithAdjustedZoom(1.0));
472 height = second->computeLength<Length>(state.cssToLengthConversionData().copyWithAdjustedZoom(1.0));
474 // <page-size> <orientation>
475 // The value order is guaranteed. See BisonCSSParser::parseSizeParameter.
476 if (!getPageSizeFromName(first, second, width, height))
479 pageSizeType = PAGE_SIZE_RESOLVED;
483 // <length> | auto | <page-size> | [ portrait | landscape]
484 if (!inspector.first()->isPrimitiveValue())
486 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(inspector.first());
487 if (primitiveValue->isLength()) {
489 pageSizeType = PAGE_SIZE_RESOLVED;
490 width = height = primitiveValue->computeLength<Length>(state.cssToLengthConversionData().copyWithAdjustedZoom(1.0));
492 switch (primitiveValue->getValueID()) {
496 pageSizeType = PAGE_SIZE_AUTO;
498 case CSSValuePortrait:
499 pageSizeType = PAGE_SIZE_AUTO_PORTRAIT;
501 case CSSValueLandscape:
502 pageSizeType = PAGE_SIZE_AUTO_LANDSCAPE;
506 pageSizeType = PAGE_SIZE_RESOLVED;
507 if (!getPageSizeFromName(primitiveValue, 0, width, height))
516 state.style()->setPageSizeType(pageSizeType);
517 state.style()->setPageSize(LengthSize(width, height));
520 void StyleBuilderFunctions::applyValueCSSPropertyTextAlign(StyleResolverState& state, CSSValue* value)
522 if (!value->isPrimitiveValue())
525 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
526 // FIXME : Per http://www.w3.org/TR/css3-text/#text-align0 can now take <string> but this is not implemented in the
528 if (primitiveValue->isString())
531 if (primitiveValue->isValueID() && primitiveValue->getValueID() != CSSValueWebkitMatchParent)
532 state.style()->setTextAlign(*primitiveValue);
533 else if (state.parentStyle()->textAlign() == TASTART)
534 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT);
535 else if (state.parentStyle()->textAlign() == TAEND)
536 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection() ? RIGHT : LEFT);
538 state.style()->setTextAlign(state.parentStyle()->textAlign());
541 void StyleBuilderFunctions::applyValueCSSPropertyTextDecoration(StyleResolverState& state, CSSValue* value)
543 TextDecoration t = RenderStyle::initialTextDecoration();
544 for (CSSValueListIterator i(value); i.hasMore(); i.advance()) {
545 CSSValue* item = i.value();
546 t |= *toCSSPrimitiveValue(item);
548 state.style()->setTextDecoration(t);
551 void StyleBuilderFunctions::applyInheritCSSPropertyTextIndent(StyleResolverState& state)
553 state.style()->setTextIndent(state.parentStyle()->textIndent());
554 state.style()->setTextIndentLine(state.parentStyle()->textIndentLine());
557 void StyleBuilderFunctions::applyInitialCSSPropertyTextIndent(StyleResolverState& state)
559 state.style()->setTextIndent(RenderStyle::initialTextIndent());
560 state.style()->setTextIndentLine(RenderStyle::initialTextIndentLine());
563 void StyleBuilderFunctions::applyValueCSSPropertyTextIndent(StyleResolverState& state, CSSValue* value)
565 if (!value->isValueList())
568 // [ <length> | <percentage> ] each-line
569 // The order is guaranteed. See BisonCSSParser::parseTextIndent.
570 // The second value, each-line is handled only when css3TextEnabled() returns true.
572 CSSValueList* valueList = toCSSValueList(value);
573 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->itemWithoutBoundsCheck(0));
574 Length lengthOrPercentageValue = primitiveValue->convertToLength<FixedConversion | PercentConversion>(state.cssToLengthConversionData());
575 state.style()->setTextIndent(lengthOrPercentageValue);
577 ASSERT(valueList->length() <= 2);
578 CSSPrimitiveValue* eachLineValue = toCSSPrimitiveValue(valueList->item(1));
580 ASSERT(eachLineValue->getValueID() == CSSValueEachLine);
581 state.style()->setTextIndentLine(TextIndentEachLine);
583 state.style()->setTextIndentLine(TextIndentFirstLine);
586 void StyleBuilderFunctions::applyValueCSSPropertyVerticalAlign(StyleResolverState& state, CSSValue* value)
588 if (!value->isPrimitiveValue())
591 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
593 if (primitiveValue->getValueID())
594 return state.style()->setVerticalAlign(*primitiveValue);
596 state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedConversion | PercentConversion>(state.cssToLengthConversionData()));
599 void StyleBuilderFunctions::applyValueCSSPropertyTouchAction(StyleResolverState& state, CSSValue* value)
601 TouchAction action = RenderStyle::initialTouchAction();
602 for (CSSValueListIterator i(value); i.hasMore(); i.advance())
603 action |= *toCSSPrimitiveValue(i.value());
605 state.style()->setTouchAction(action);
608 static void resetEffectiveZoom(StyleResolverState& state)
610 // Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect.
611 state.setEffectiveZoom(state.parentStyle() ? state.parentStyle()->effectiveZoom() : RenderStyle::initialZoom());
614 void StyleBuilderFunctions::applyInitialCSSPropertyZoom(StyleResolverState& state)
616 resetEffectiveZoom(state);
617 state.setZoom(RenderStyle::initialZoom());
620 void StyleBuilderFunctions::applyInheritCSSPropertyZoom(StyleResolverState& state)
622 resetEffectiveZoom(state);
623 state.setZoom(state.parentStyle()->zoom());
626 void StyleBuilderFunctions::applyValueCSSPropertyZoom(StyleResolverState& state, CSSValue* value)
628 ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue());
629 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
631 if (primitiveValue->getValueID() == CSSValueNormal) {
632 resetEffectiveZoom(state);
633 state.setZoom(RenderStyle::initialZoom());
634 } else if (primitiveValue->getValueID() == CSSValueReset) {
635 state.setEffectiveZoom(RenderStyle::initialZoom());
636 state.setZoom(RenderStyle::initialZoom());
637 } else if (primitiveValue->getValueID() == CSSValueDocument) {
638 float docZoom = state.rootElementStyle() ? state.rootElementStyle()->zoom() : RenderStyle::initialZoom();
639 state.setEffectiveZoom(docZoom);
640 state.setZoom(docZoom);
641 } else if (primitiveValue->isPercentage()) {
642 resetEffectiveZoom(state);
643 if (float percent = primitiveValue->getFloatValue())
644 state.setZoom(percent / 100.0f);
645 } else if (primitiveValue->isNumber()) {
646 resetEffectiveZoom(state);
647 if (float number = primitiveValue->getFloatValue())
648 state.setZoom(number);
652 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitAspectRatio(StyleResolverState& state)
654 state.style()->setHasAspectRatio(RenderStyle::initialHasAspectRatio());
655 state.style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDenominator());
656 state.style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumerator());
659 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitAspectRatio(StyleResolverState& state)
661 if (!state.parentStyle()->hasAspectRatio())
663 state.style()->setHasAspectRatio(true);
664 state.style()->setAspectRatioDenominator(state.parentStyle()->aspectRatioDenominator());
665 state.style()->setAspectRatioNumerator(state.parentStyle()->aspectRatioNumerator());
668 void StyleBuilderFunctions::applyValueCSSPropertyWebkitAspectRatio(StyleResolverState& state, CSSValue* value)
670 if (!value->isAspectRatioValue()) {
671 state.style()->setHasAspectRatio(false);
674 CSSAspectRatioValue* aspectRatioValue = toCSSAspectRatioValue(value);
675 state.style()->setHasAspectRatio(true);
676 state.style()->setAspectRatioDenominator(aspectRatioValue->denominatorValue());
677 state.style()->setAspectRatioNumerator(aspectRatioValue->numeratorValue());
680 void StyleBuilderFunctions::applyValueCSSPropertyWebkitBorderImage(StyleResolverState& state, CSSValue* value)
682 NinePieceImage image;
683 state.styleMap().mapNinePieceImage(state.style(), CSSPropertyWebkitBorderImage, value, image);
684 state.style()->setBorderImage(image);
687 void StyleBuilderFunctions::applyValueCSSPropertyWebkitClipPath(StyleResolverState& state, CSSValue* value)
689 if (value->isPrimitiveValue()) {
690 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
691 if (primitiveValue->getValueID() == CSSValueNone) {
692 state.style()->setClipPath(0);
693 } else if (primitiveValue->isShape()) {
694 state.style()->setClipPath(ShapeClipPathOperation::create(basicShapeForValue(state, primitiveValue->getShapeValue())));
695 } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_URI) {
696 String cssURLValue = primitiveValue->getStringValue();
697 KURL url = state.document().completeURL(cssURLValue);
698 // FIXME: It doesn't work with forward or external SVG references (see https://bugs.webkit.org/show_bug.cgi?id=90405)
699 state.style()->setClipPath(ReferenceClipPathOperation::create(cssURLValue, AtomicString(url.fragmentIdentifier())));
704 void StyleBuilderFunctions::applyInitialCSSPropertyFontVariantLigatures(StyleResolverState& state)
706 state.fontBuilder().setFontVariantLigaturesInitial();
709 void StyleBuilderFunctions::applyInheritCSSPropertyFontVariantLigatures(StyleResolverState& state)
711 state.fontBuilder().setFontVariantLigaturesInherit(state.parentFontDescription());
714 void StyleBuilderFunctions::applyValueCSSPropertyFontVariantLigatures(StyleResolverState& state, CSSValue* value)
716 state.fontBuilder().setFontVariantLigaturesValue(value);
719 void StyleBuilderFunctions::applyValueCSSPropertyInternalMarqueeIncrement(StyleResolverState& state, CSSValue* value)
721 if (!value->isPrimitiveValue())
724 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
725 if (primitiveValue->getValueID()) {
726 switch (primitiveValue->getValueID()) {
728 state.style()->setMarqueeIncrement(Length(1, Fixed)); // 1px.
731 state.style()->setMarqueeIncrement(Length(6, Fixed)); // 6px. The WinIE default.
734 state.style()->setMarqueeIncrement(Length(36, Fixed)); // 36px.
740 Length marqueeLength = primitiveValue->convertToLength<FixedConversion | PercentConversion>(state.cssToLengthConversionData());
741 state.style()->setMarqueeIncrement(marqueeLength);
745 void StyleBuilderFunctions::applyValueCSSPropertyInternalMarqueeSpeed(StyleResolverState& state, CSSValue* value)
747 if (!value->isPrimitiveValue())
750 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
751 if (CSSValueID valueID = primitiveValue->getValueID()) {
754 state.style()->setMarqueeSpeed(500); // 500 msec.
757 state.style()->setMarqueeSpeed(85); // 85msec. The WinIE default.
760 state.style()->setMarqueeSpeed(10); // 10msec. Super fast.
765 } else if (primitiveValue->isTime()) {
766 state.style()->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimitiveValue::Milliseconds>());
767 } else if (primitiveValue->isNumber()) { // For scrollamount support.
768 state.style()->setMarqueeSpeed(primitiveValue->getIntValue());
772 // FIXME: We should use the same system for this as the rest of the pseudo-shorthands (e.g. background-position)
773 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitPerspectiveOrigin(StyleResolverState& state)
775 applyInitialCSSPropertyWebkitPerspectiveOriginX(state);
776 applyInitialCSSPropertyWebkitPerspectiveOriginY(state);
779 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitPerspectiveOrigin(StyleResolverState& state)
781 applyInheritCSSPropertyWebkitPerspectiveOriginX(state);
782 applyInheritCSSPropertyWebkitPerspectiveOriginY(state);
785 void StyleBuilderFunctions::applyValueCSSPropertyWebkitPerspectiveOrigin(StyleResolverState&, CSSValue* value)
787 // This is expanded in the parser
788 ASSERT_NOT_REACHED();
791 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitTextEmphasisStyle(StyleResolverState& state)
793 state.style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill());
794 state.style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark());
795 state.style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCustomMark());
798 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitTextEmphasisStyle(StyleResolverState& state)
800 state.style()->setTextEmphasisFill(state.parentStyle()->textEmphasisFill());
801 state.style()->setTextEmphasisMark(state.parentStyle()->textEmphasisMark());
802 state.style()->setTextEmphasisCustomMark(state.parentStyle()->textEmphasisCustomMark());
805 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextEmphasisStyle(StyleResolverState& state, CSSValue* value)
807 if (value->isValueList()) {
808 CSSValueList* list = toCSSValueList(value);
809 ASSERT(list->length() == 2);
810 if (list->length() != 2)
812 for (unsigned i = 0; i < 2; ++i) {
813 CSSValue* item = list->itemWithoutBoundsCheck(i);
814 if (!item->isPrimitiveValue())
817 CSSPrimitiveValue* value = toCSSPrimitiveValue(item);
818 if (value->getValueID() == CSSValueFilled || value->getValueID() == CSSValueOpen)
819 state.style()->setTextEmphasisFill(*value);
821 state.style()->setTextEmphasisMark(*value);
823 state.style()->setTextEmphasisCustomMark(nullAtom);
827 if (!value->isPrimitiveValue())
829 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
831 if (primitiveValue->isString()) {
832 state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
833 state.style()->setTextEmphasisMark(TextEmphasisMarkCustom);
834 state.style()->setTextEmphasisCustomMark(AtomicString(primitiveValue->getStringValue()));
838 state.style()->setTextEmphasisCustomMark(nullAtom);
840 if (primitiveValue->getValueID() == CSSValueFilled || primitiveValue->getValueID() == CSSValueOpen) {
841 state.style()->setTextEmphasisFill(*primitiveValue);
842 state.style()->setTextEmphasisMark(TextEmphasisMarkAuto);
844 state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
845 state.style()->setTextEmphasisMark(*primitiveValue);
849 void StyleBuilderFunctions::applyValueCSSPropertyTextUnderlinePosition(StyleResolverState& state, CSSValue* value)
851 // This is true if value is 'auto' or 'alphabetic'.
852 if (value->isPrimitiveValue()) {
853 TextUnderlinePosition t = *toCSSPrimitiveValue(value);
854 state.style()->setTextUnderlinePosition(t);
859 for (CSSValueListIterator i(value); i.hasMore(); i.advance()) {
860 CSSValue* item = i.value();
861 TextUnderlinePosition t2 = *toCSSPrimitiveValue(item);
864 state.style()->setTextUnderlinePosition(static_cast<TextUnderlinePosition>(t));
867 // Everything below this line is from the old StyleResolver::applyProperty
868 // and eventually needs to move into new StyleBuilderFunctions calls intead.
870 #define HANDLE_INHERIT(prop, Prop) \
872 state.style()->set##Prop(state.parentStyle()->prop()); \
876 #define HANDLE_INHERIT_AND_INITIAL(prop, Prop) \
877 HANDLE_INHERIT(prop, Prop) \
879 state.style()->set##Prop(RenderStyle::initial##Prop()); \
883 #define HANDLE_SVG_INHERIT(prop, Prop) \
885 state.style()->accessSVGStyle()->set##Prop(state.parentStyle()->svgStyle()->prop()); \
889 #define HANDLE_SVG_INHERIT_AND_INITIAL(prop, Prop) \
890 HANDLE_SVG_INHERIT(prop, Prop) \
892 state.style()->accessSVGStyle()->set##Prop(SVGRenderStyle::initial##Prop()); \
896 static GridLength createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, const StyleResolverState& state)
898 if (primitiveValue->getValueID() == CSSValueMinContent)
899 return Length(MinContent);
901 if (primitiveValue->getValueID() == CSSValueMaxContent)
902 return Length(MaxContent);
905 if (primitiveValue->isFlex())
906 return GridLength(primitiveValue->getDoubleValue());
908 return primitiveValue->convertToLength<FixedConversion | PercentConversion | AutoConversion>(state.cssToLengthConversionData());
911 static GridTrackSize createGridTrackSize(CSSValue* value, const StyleResolverState& state)
913 if (value->isPrimitiveValue())
914 return GridTrackSize(createGridTrackBreadth(toCSSPrimitiveValue(value), state));
916 CSSFunctionValue* minmaxFunction = toCSSFunctionValue(value);
917 CSSValueList* arguments = minmaxFunction->arguments();
918 ASSERT_WITH_SECURITY_IMPLICATION(arguments->length() == 2);
919 GridLength minTrackBreadth(createGridTrackBreadth(toCSSPrimitiveValue(arguments->itemWithoutBoundsCheck(0)), state));
920 GridLength maxTrackBreadth(createGridTrackBreadth(toCSSPrimitiveValue(arguments->itemWithoutBoundsCheck(1)), state));
921 return GridTrackSize(minTrackBreadth, maxTrackBreadth);
924 static bool createGridTrackList(CSSValue* value, Vector<GridTrackSize>& trackSizes, NamedGridLinesMap& namedGridLines, OrderedNamedGridLines& orderedNamedGridLines, const StyleResolverState& state)
927 if (value->isPrimitiveValue()) {
928 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
929 return primitiveValue->getValueID() == CSSValueNone;
932 if (!value->isValueList())
935 size_t currentNamedGridLine = 0;
936 for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
937 CSSValue* currValue = i.value();
938 if (currValue->isGridLineNamesValue()) {
939 CSSGridLineNamesValue* lineNamesValue = toCSSGridLineNamesValue(currValue);
940 for (CSSValueListIterator j = lineNamesValue; j.hasMore(); j.advance()) {
941 String namedGridLine = toCSSPrimitiveValue(j.value())->getStringValue();
942 NamedGridLinesMap::AddResult result = namedGridLines.add(namedGridLine, Vector<size_t>());
943 result.storedValue->value.append(currentNamedGridLine);
944 OrderedNamedGridLines::AddResult orderedInsertionResult = orderedNamedGridLines.add(currentNamedGridLine, Vector<String>());
945 orderedInsertionResult.storedValue->value.append(namedGridLine);
950 ++currentNamedGridLine;
951 trackSizes.append(createGridTrackSize(currValue, state));
954 // The parser should have rejected any <track-list> without any <track-size> as
955 // this is not conformant to the syntax.
956 ASSERT(!trackSizes.isEmpty());
960 static bool createGridPosition(CSSValue* value, GridPosition& position)
962 // We accept the specification's grammar:
963 // 'auto' | [ <integer> || <string> ] | [ span && [ <integer> || string ] ] | <ident>
965 if (value->isPrimitiveValue()) {
966 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
967 // We translate <ident> to <string> during parsing as it
968 // makes handling it more simple.
969 if (primitiveValue->isString()) {
970 position.setNamedGridArea(primitiveValue->getStringValue());
974 ASSERT(primitiveValue->getValueID() == CSSValueAuto);
978 CSSValueList* values = toCSSValueList(value);
979 ASSERT(values->length());
981 bool isSpanPosition = false;
982 // The specification makes the <integer> optional, in which case it default to '1'.
983 int gridLineNumber = 1;
986 CSSValueListIterator it = values;
987 CSSPrimitiveValue* currentValue = toCSSPrimitiveValue(it.value());
988 if (currentValue->getValueID() == CSSValueSpan) {
989 isSpanPosition = true;
991 currentValue = it.hasMore() ? toCSSPrimitiveValue(it.value()) : 0;
994 if (currentValue && currentValue->isNumber()) {
995 gridLineNumber = currentValue->getIntValue();
997 currentValue = it.hasMore() ? toCSSPrimitiveValue(it.value()) : 0;
1000 if (currentValue && currentValue->isString()) {
1001 gridLineName = currentValue->getStringValue();
1005 ASSERT(!it.hasMore());
1007 position.setSpanPosition(gridLineNumber, gridLineName);
1009 position.setExplicitPosition(gridLineNumber, gridLineName);
1014 static bool degreeToGlyphOrientation(CSSPrimitiveValue* primitiveValue, EGlyphOrientation& orientation)
1016 if (!primitiveValue)
1019 if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_DEG)
1022 float angle = fabsf(fmodf(primitiveValue->getFloatValue(), 360.0f));
1024 if (angle <= 45.0f || angle > 315.0f) {
1025 orientation = GO_0DEG;
1028 if (angle > 45.0f && angle <= 135.0f) {
1029 orientation = GO_90DEG;
1032 if (angle > 135.0f && angle <= 225.0f) {
1033 orientation = GO_180DEG;
1036 orientation = GO_270DEG;
1040 static Color colorFromSVGColorCSSValue(SVGColor* svgColor, const Color& fgColor)
1043 if (svgColor->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR)
1046 color = svgColor->color();
1050 static EPaintOrder paintOrderFlattened(CSSValue* cssPaintOrder)
1052 if (cssPaintOrder->isValueList()) {
1054 CSSValueListInspector iter(cssPaintOrder);
1055 for (size_t i = 0; i < iter.length(); i++) {
1056 CSSPrimitiveValue* value = toCSSPrimitiveValue(iter.item(i));
1058 EPaintOrderType paintOrderType = PT_NONE;
1059 switch (value->getValueID()) {
1061 paintOrderType = PT_FILL;
1063 case CSSValueStroke:
1064 paintOrderType = PT_STROKE;
1066 case CSSValueMarkers:
1067 paintOrderType = PT_MARKERS;
1070 ASSERT_NOT_REACHED();
1074 paintOrder |= (paintOrderType << kPaintOrderBitwidth*i);
1076 return (EPaintOrder)paintOrder;
1082 static inline bool isValidVisitedLinkProperty(CSSPropertyID id)
1085 case CSSPropertyBackgroundColor:
1086 case CSSPropertyBorderLeftColor:
1087 case CSSPropertyBorderRightColor:
1088 case CSSPropertyBorderTopColor:
1089 case CSSPropertyBorderBottomColor:
1090 case CSSPropertyColor:
1091 case CSSPropertyFill:
1092 case CSSPropertyOutlineColor:
1093 case CSSPropertyStroke:
1094 case CSSPropertyTextDecorationColor:
1095 case CSSPropertyWebkitColumnRuleColor:
1096 case CSSPropertyWebkitTextEmphasisColor:
1097 case CSSPropertyWebkitTextFillColor:
1098 case CSSPropertyWebkitTextStrokeColor:
1108 void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CSSValue* value)
1110 ASSERT_WITH_MESSAGE(!isExpandedShorthand(id), "Shorthand property id = %d wasn't expanded at parsing time", id);
1112 bool isInherit = state.parentNode() && value->isInheritedValue();
1113 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->isInheritedValue());
1115 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit
1116 ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInherit -> (state.parentNode() && state.parentStyle())
1118 if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLinkStyle() || !isValidVisitedLinkProperty(id))) {
1119 // Limit the properties that can be applied to only the ones honored by :visited.
1123 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimitiveValue(value) : 0;
1124 if (primitiveValue && primitiveValue->getValueID() == CSSValueCurrentcolor)
1125 state.style()->setHasCurrentColor();
1127 if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id))
1128 state.parentStyle()->setHasExplicitlyInheritedProperties();
1130 if (StyleBuilder::applyProperty(id, state, value, isInitial, isInherit))
1133 // Fall back to the old switch statement, which is now in StyleBuilderCustom.cpp
1134 StyleBuilder::oldApplyProperty(id, state, value, isInitial, isInherit);
1138 void StyleBuilder::oldApplyProperty(CSSPropertyID id, StyleResolverState& state, CSSValue* value, bool isInitial, bool isInherit)
1140 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimitiveValue(value) : 0;
1142 // What follows is a list that maps the CSS properties into their corresponding front-end
1143 // RenderStyle values.
1145 case CSSPropertyContent:
1146 // list of string, uri, counter, attr, i
1148 // FIXME: In CSS3, it will be possible to inherit content. In CSS2 it is not. This
1149 // note is a reminder that eventually "inherit" needs to be supported.
1152 state.style()->clearContent();
1156 if (!value->isValueList())
1159 bool didSet = false;
1160 for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
1161 CSSValue* item = i.value();
1162 if (item->isImageGeneratorValue()) {
1163 if (item->isGradientValue())
1164 state.style()->setContent(StyleGeneratedImage::create(toCSSGradientValue(item)->gradientWithStylesResolved(state.document().textLinkColors(), state.style()->color()).get()), didSet);
1166 state.style()->setContent(StyleGeneratedImage::create(toCSSImageGeneratorValue(item)), didSet);
1168 } else if (item->isImageSetValue()) {
1169 state.style()->setContent(state.elementStyleResources().setOrPendingFromValue(CSSPropertyContent, toCSSImageSetValue(item)), didSet);
1173 if (item->isImageValue()) {
1174 state.style()->setContent(state.elementStyleResources().cachedOrPendingFromValue(CSSPropertyContent, toCSSImageValue(item)), didSet);
1179 if (!item->isPrimitiveValue())
1182 CSSPrimitiveValue* contentValue = toCSSPrimitiveValue(item);
1184 if (contentValue->isString()) {
1185 state.style()->setContent(contentValue->getStringValue().impl(), didSet);
1187 } else if (contentValue->isAttr()) {
1188 // FIXME: Can a namespace be specified for an attr(foo)?
1189 if (state.style()->styleType() == NOPSEUDO)
1190 state.style()->setUnique();
1192 state.parentStyle()->setUnique();
1193 QualifiedName attr(nullAtom, AtomicString(contentValue->getStringValue()), nullAtom);
1194 const AtomicString& value = state.element()->getAttribute(attr);
1195 state.style()->setContent(value.isNull() ? emptyString() : value.string(), didSet);
1197 // register the fact that the attribute value affects the style
1198 state.contentAttrValues().append(attr.localName());
1199 } else if (contentValue->isCounter()) {
1200 Counter* counterValue = contentValue->getCounterValue();
1201 EListStyleType listStyleType = NoneListStyle;
1202 CSSValueID listStyleIdent = counterValue->listStyleIdent();
1203 if (listStyleIdent != CSSValueNone)
1204 listStyleType = static_cast<EListStyleType>(listStyleIdent - CSSValueDisc);
1205 OwnPtr<CounterContent> counter = adoptPtr(new CounterContent(AtomicString(counterValue->identifier()), listStyleType, AtomicString(counterValue->separator())));
1206 state.style()->setContent(counter.release(), didSet);
1209 switch (contentValue->getValueID()) {
1210 case CSSValueOpenQuote:
1211 state.style()->setContent(OPEN_QUOTE, didSet);
1214 case CSSValueCloseQuote:
1215 state.style()->setContent(CLOSE_QUOTE, didSet);
1218 case CSSValueNoOpenQuote:
1219 state.style()->setContent(NO_OPEN_QUOTE, didSet);
1222 case CSSValueNoCloseQuote:
1223 state.style()->setContent(NO_CLOSE_QUOTE, didSet);
1227 // normal and none do not have any effect.
1233 state.style()->clearContent();
1236 case CSSPropertyQuotes:
1237 HANDLE_INHERIT_AND_INITIAL(quotes, Quotes);
1238 if (value->isValueList()) {
1239 CSSValueList* list = toCSSValueList(value);
1240 RefPtr<QuotesData> quotes = QuotesData::create();
1241 for (size_t i = 0; i < list->length(); i += 2) {
1242 CSSValue* first = list->itemWithoutBoundsCheck(i);
1243 // item() returns null if out of bounds so this is safe.
1244 CSSValue* second = list->item(i + 1);
1247 String startQuote = toCSSPrimitiveValue(first)->getStringValue();
1248 String endQuote = toCSSPrimitiveValue(second)->getStringValue();
1249 quotes->addPair(std::make_pair(startQuote, endQuote));
1251 state.style()->setQuotes(quotes);
1254 if (primitiveValue) {
1255 if (primitiveValue->getValueID() == CSSValueNone)
1256 state.style()->setQuotes(QuotesData::create());
1259 // Shorthand properties.
1260 case CSSPropertyFont:
1261 // Only System Font identifiers should come through this method
1262 // all other values should have been handled when the shorthand
1263 // was expanded by the parser.
1264 // FIXME: System Font identifiers should not hijack this
1265 // short-hand CSSProperty like this.
1268 ASSERT(primitiveValue);
1269 state.style()->setLineHeight(RenderStyle::initialLineHeight());
1270 state.setLineHeightValue(0);
1271 state.fontBuilder().fromSystemFont(primitiveValue->getValueID(), state.style()->effectiveZoom());
1273 case CSSPropertyAnimation:
1274 case CSSPropertyBackground:
1275 case CSSPropertyBackgroundPosition:
1276 case CSSPropertyBackgroundRepeat:
1277 case CSSPropertyBorder:
1278 case CSSPropertyBorderBottom:
1279 case CSSPropertyBorderColor:
1280 case CSSPropertyBorderImage:
1281 case CSSPropertyBorderLeft:
1282 case CSSPropertyBorderRadius:
1283 case CSSPropertyBorderRight:
1284 case CSSPropertyBorderSpacing:
1285 case CSSPropertyBorderStyle:
1286 case CSSPropertyBorderTop:
1287 case CSSPropertyBorderWidth:
1288 case CSSPropertyListStyle:
1289 case CSSPropertyMargin:
1290 case CSSPropertyObjectPosition:
1291 case CSSPropertyOutline:
1292 case CSSPropertyOverflow:
1293 case CSSPropertyPadding:
1294 case CSSPropertyTransition:
1295 case CSSPropertyWebkitAnimation:
1296 case CSSPropertyWebkitBorderAfter:
1297 case CSSPropertyWebkitBorderBefore:
1298 case CSSPropertyWebkitBorderEnd:
1299 case CSSPropertyWebkitBorderStart:
1300 case CSSPropertyWebkitBorderRadius:
1301 case CSSPropertyWebkitColumns:
1302 case CSSPropertyWebkitColumnRule:
1303 case CSSPropertyFlex:
1304 case CSSPropertyFlexFlow:
1305 case CSSPropertyGridColumn:
1306 case CSSPropertyGridRow:
1307 case CSSPropertyGridArea:
1308 case CSSPropertyWebkitMarginCollapse:
1309 case CSSPropertyWebkitMask:
1310 case CSSPropertyWebkitMaskPosition:
1311 case CSSPropertyWebkitMaskRepeat:
1312 case CSSPropertyWebkitTextEmphasis:
1313 case CSSPropertyWebkitTextStroke:
1314 case CSSPropertyWebkitTransition:
1315 case CSSPropertyWebkitTransformOrigin:
1316 ASSERT(isExpandedShorthand(id));
1317 ASSERT_NOT_REACHED();
1321 case CSSPropertyWebkitBoxReflect: {
1322 HANDLE_INHERIT_AND_INITIAL(boxReflect, BoxReflect)
1323 if (primitiveValue) {
1324 state.style()->setBoxReflect(RenderStyle::initialBoxReflect());
1328 if (!value->isReflectValue())
1331 CSSReflectValue* reflectValue = toCSSReflectValue(value);
1332 RefPtr<StyleReflection> reflection = StyleReflection::create();
1333 reflection->setDirection(*reflectValue->direction());
1334 if (reflectValue->offset())
1335 reflection->setOffset(reflectValue->offset()->convertToLength<FixedConversion | PercentConversion>(state.cssToLengthConversionData()));
1336 NinePieceImage mask;
1337 mask.setMaskDefaults();
1338 state.styleMap().mapNinePieceImage(state.style(), id, reflectValue->mask(), mask);
1339 reflection->setMask(mask);
1341 state.style()->setBoxReflect(reflection.release());
1344 case CSSPropertySrc: // Only used in @font-face rules.
1346 case CSSPropertyUnicodeRange: // Only used in @font-face rules.
1348 case CSSPropertyWebkitLocale: {
1349 HANDLE_INHERIT_AND_INITIAL(locale, Locale);
1350 if (!primitiveValue)
1352 if (primitiveValue->getValueID() == CSSValueAuto)
1353 state.style()->setLocale(nullAtom);
1355 state.style()->setLocale(AtomicString(primitiveValue->getStringValue()));
1356 state.fontBuilder().setScript(state.style()->locale());
1359 case CSSPropertyWebkitAppRegion: {
1360 if (!primitiveValue || !primitiveValue->getValueID())
1362 state.style()->setDraggableRegionMode(primitiveValue->getValueID() == CSSValueDrag ? DraggableRegionDrag : DraggableRegionNoDrag);
1363 state.document().setHasAnnotatedRegions(true);
1366 case CSSPropertyWebkitTextStrokeWidth: {
1367 HANDLE_INHERIT_AND_INITIAL(textStrokeWidth, TextStrokeWidth)
1369 switch (primitiveValue->getValueID()) {
1371 case CSSValueMedium:
1372 case CSSValueThick: {
1373 double result = 1.0 / 48;
1374 if (primitiveValue->getValueID() == CSSValueMedium)
1376 else if (primitiveValue->getValueID() == CSSValueThick)
1378 width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLength<float>(state.cssToLengthConversionData());
1382 width = primitiveValue->computeLength<float>(state.cssToLengthConversionData());
1385 state.style()->setTextStrokeWidth(width);
1388 case CSSPropertyWebkitTransform: {
1389 HANDLE_INHERIT_AND_INITIAL(transform, Transform);
1390 TransformOperations operations;
1391 TransformBuilder::createTransformOperations(value, state.cssToLengthConversionData(), operations);
1392 state.style()->setTransform(operations);
1395 case CSSPropertyWebkitPerspective: {
1396 HANDLE_INHERIT_AND_INITIAL(perspective, Perspective)
1398 if (!primitiveValue)
1401 if (primitiveValue->getValueID() == CSSValueNone) {
1402 state.style()->setPerspective(0);
1406 float perspectiveValue;
1407 if (primitiveValue->isLength()) {
1408 perspectiveValue = primitiveValue->computeLength<float>(state.cssToLengthConversionData());
1409 } else if (primitiveValue->isNumber()) {
1410 // For backward compatibility, treat valueless numbers as px.
1411 perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(state.cssToLengthConversionData());
1416 if (perspectiveValue >= 0.0f)
1417 state.style()->setPerspective(perspectiveValue);
1420 case CSSPropertyWebkitTapHighlightColor: {
1421 HANDLE_INHERIT_AND_INITIAL(tapHighlightColor, TapHighlightColor);
1422 if (!primitiveValue)
1425 Color col = state.document().textLinkColors().colorFromPrimitiveValue(primitiveValue, state.style()->color());
1426 state.style()->setTapHighlightColor(col);
1429 case CSSPropertyInternalCallback: {
1430 if (isInherit || isInitial)
1432 if (primitiveValue && primitiveValue->getValueID() == CSSValueInternalPresence) {
1433 state.style()->addCallbackSelector(state.currentRule()->selectorList().selectorsText());
1438 case CSSPropertyInvalid:
1440 // Directional properties are resolved by resolveDirectionAwareProperty() before the switch.
1441 case CSSPropertyWebkitBorderEndColor:
1442 case CSSPropertyWebkitBorderEndStyle:
1443 case CSSPropertyWebkitBorderEndWidth:
1444 case CSSPropertyWebkitBorderStartColor:
1445 case CSSPropertyWebkitBorderStartStyle:
1446 case CSSPropertyWebkitBorderStartWidth:
1447 case CSSPropertyWebkitBorderBeforeColor:
1448 case CSSPropertyWebkitBorderBeforeStyle:
1449 case CSSPropertyWebkitBorderBeforeWidth:
1450 case CSSPropertyWebkitBorderAfterColor:
1451 case CSSPropertyWebkitBorderAfterStyle:
1452 case CSSPropertyWebkitBorderAfterWidth:
1453 case CSSPropertyWebkitMarginEnd:
1454 case CSSPropertyWebkitMarginStart:
1455 case CSSPropertyWebkitMarginBefore:
1456 case CSSPropertyWebkitMarginAfter:
1457 case CSSPropertyWebkitMarginBeforeCollapse:
1458 case CSSPropertyWebkitMarginTopCollapse:
1459 case CSSPropertyWebkitMarginAfterCollapse:
1460 case CSSPropertyWebkitMarginBottomCollapse:
1461 case CSSPropertyWebkitPaddingEnd:
1462 case CSSPropertyWebkitPaddingStart:
1463 case CSSPropertyWebkitPaddingBefore:
1464 case CSSPropertyWebkitPaddingAfter:
1465 case CSSPropertyWebkitLogicalWidth:
1466 case CSSPropertyWebkitLogicalHeight:
1467 case CSSPropertyWebkitMinLogicalWidth:
1468 case CSSPropertyWebkitMinLogicalHeight:
1469 case CSSPropertyWebkitMaxLogicalWidth:
1470 case CSSPropertyWebkitMaxLogicalHeight:
1472 CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, state.style()->direction(), state.style()->writingMode());
1473 ASSERT(newId != id);
1474 return applyProperty(newId, state, value);
1476 case CSSPropertyFontStretch:
1477 case CSSPropertyPage:
1478 case CSSPropertyTextLineThroughColor:
1479 case CSSPropertyTextLineThroughMode:
1480 case CSSPropertyTextLineThroughStyle:
1481 case CSSPropertyTextLineThroughWidth:
1482 case CSSPropertyTextOverlineColor:
1483 case CSSPropertyTextOverlineMode:
1484 case CSSPropertyTextOverlineStyle:
1485 case CSSPropertyTextOverlineWidth:
1486 case CSSPropertyTextUnderlineColor:
1487 case CSSPropertyTextUnderlineMode:
1488 case CSSPropertyTextUnderlineStyle:
1489 case CSSPropertyTextUnderlineWidth:
1490 case CSSPropertyWebkitFontSizeDelta:
1491 case CSSPropertyWebkitTextDecorationsInEffect:
1494 // CSS Text Layout Module Level 3: Vertical writing support
1495 case CSSPropertyWebkitWritingMode: {
1496 HANDLE_INHERIT_AND_INITIAL(writingMode, WritingMode);
1499 state.setWritingMode(*primitiveValue);
1501 // FIXME: It is not ok to modify document state while applying style.
1502 if (state.element() && state.element() == state.document().documentElement())
1503 state.document().setWritingModeSetOnDocumentElement(true);
1507 case CSSPropertyWebkitTextOrientation: {
1508 HANDLE_INHERIT_AND_INITIAL(textOrientation, TextOrientation);
1511 state.setTextOrientation(*primitiveValue);
1516 case CSSPropertyWebkitLineBoxContain: {
1517 HANDLE_INHERIT_AND_INITIAL(lineBoxContain, LineBoxContain)
1518 if (primitiveValue && primitiveValue->getValueID() == CSSValueNone) {
1519 state.style()->setLineBoxContain(LineBoxContainNone);
1523 if (!value->isLineBoxContainValue())
1526 state.style()->setLineBoxContain(toCSSLineBoxContainValue(value)->value());
1530 // CSS Fonts Module Level 3
1531 case CSSPropertyWebkitFontFeatureSettings: {
1532 if (primitiveValue && primitiveValue->getValueID() == CSSValueNormal) {
1533 state.fontBuilder().setFeatureSettingsNormal();
1537 if (!value->isValueList())
1540 state.fontBuilder().setFeatureSettingsValue(value);
1544 case CSSPropertyWebkitFilter: {
1545 HANDLE_INHERIT_AND_INITIAL(filter, Filter);
1546 FilterOperations operations;
1547 if (FilterOperationResolver::createFilterOperations(value, state.cssToLengthConversionData(), operations, state))
1548 state.style()->setFilter(operations);
1551 case CSSPropertyGridAutoColumns: {
1552 HANDLE_INHERIT_AND_INITIAL(gridAutoColumns, GridAutoColumns);
1553 state.style()->setGridAutoColumns(createGridTrackSize(value, state));
1556 case CSSPropertyGridAutoRows: {
1557 HANDLE_INHERIT_AND_INITIAL(gridAutoRows, GridAutoRows);
1558 state.style()->setGridAutoRows(createGridTrackSize(value, state));
1561 case CSSPropertyGridTemplateColumns: {
1563 state.style()->setGridTemplateColumns(state.parentStyle()->gridTemplateColumns());
1564 state.style()->setNamedGridColumnLines(state.parentStyle()->namedGridColumnLines());
1565 state.style()->setOrderedNamedGridColumnLines(state.parentStyle()->orderedNamedGridColumnLines());
1569 state.style()->setGridTemplateColumns(RenderStyle::initialGridTemplateColumns());
1570 state.style()->setNamedGridColumnLines(RenderStyle::initialNamedGridColumnLines());
1571 state.style()->setOrderedNamedGridColumnLines(RenderStyle::initialOrderedNamedGridColumnLines());
1575 Vector<GridTrackSize> trackSizes;
1576 NamedGridLinesMap namedGridLines;
1577 OrderedNamedGridLines orderedNamedGridLines;
1578 if (!createGridTrackList(value, trackSizes, namedGridLines, orderedNamedGridLines, state))
1580 state.style()->setGridTemplateColumns(trackSizes);
1581 state.style()->setNamedGridColumnLines(namedGridLines);
1582 state.style()->setOrderedNamedGridColumnLines(orderedNamedGridLines);
1585 case CSSPropertyGridTemplateRows: {
1587 state.style()->setGridTemplateRows(state.parentStyle()->gridTemplateRows());
1588 state.style()->setNamedGridRowLines(state.parentStyle()->namedGridRowLines());
1589 state.style()->setOrderedNamedGridRowLines(state.parentStyle()->orderedNamedGridRowLines());
1593 state.style()->setGridTemplateRows(RenderStyle::initialGridTemplateRows());
1594 state.style()->setNamedGridRowLines(RenderStyle::initialNamedGridRowLines());
1595 state.style()->setOrderedNamedGridRowLines(RenderStyle::initialOrderedNamedGridRowLines());
1599 Vector<GridTrackSize> trackSizes;
1600 NamedGridLinesMap namedGridLines;
1601 OrderedNamedGridLines orderedNamedGridLines;
1602 if (!createGridTrackList(value, trackSizes, namedGridLines, orderedNamedGridLines, state))
1604 state.style()->setGridTemplateRows(trackSizes);
1605 state.style()->setNamedGridRowLines(namedGridLines);
1606 state.style()->setOrderedNamedGridRowLines(orderedNamedGridLines);
1610 case CSSPropertyGridColumnStart: {
1611 HANDLE_INHERIT_AND_INITIAL(gridColumnStart, GridColumnStart);
1612 GridPosition startPosition;
1613 if (!createGridPosition(value, startPosition))
1615 state.style()->setGridColumnStart(startPosition);
1618 case CSSPropertyGridColumnEnd: {
1619 HANDLE_INHERIT_AND_INITIAL(gridColumnEnd, GridColumnEnd);
1620 GridPosition endPosition;
1621 if (!createGridPosition(value, endPosition))
1623 state.style()->setGridColumnEnd(endPosition);
1627 case CSSPropertyGridRowStart: {
1628 HANDLE_INHERIT_AND_INITIAL(gridRowStart, GridRowStart);
1629 GridPosition beforePosition;
1630 if (!createGridPosition(value, beforePosition))
1632 state.style()->setGridRowStart(beforePosition);
1635 case CSSPropertyGridRowEnd: {
1636 HANDLE_INHERIT_AND_INITIAL(gridRowEnd, GridRowEnd);
1637 GridPosition afterPosition;
1638 if (!createGridPosition(value, afterPosition))
1640 state.style()->setGridRowEnd(afterPosition);
1644 case CSSPropertyGridTemplateAreas: {
1646 state.style()->setNamedGridArea(state.parentStyle()->namedGridArea());
1647 state.style()->setNamedGridAreaRowCount(state.parentStyle()->namedGridAreaRowCount());
1648 state.style()->setNamedGridAreaColumnCount(state.parentStyle()->namedGridAreaColumnCount());
1652 state.style()->setNamedGridArea(RenderStyle::initialNamedGridArea());
1653 state.style()->setNamedGridAreaRowCount(RenderStyle::initialNamedGridAreaCount());
1654 state.style()->setNamedGridAreaColumnCount(RenderStyle::initialNamedGridAreaCount());
1658 if (value->isPrimitiveValue()) {
1659 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone);
1663 CSSGridTemplateAreasValue* gridTemplateAreasValue = toCSSGridTemplateAreasValue(value);
1664 state.style()->setNamedGridArea(gridTemplateAreasValue->gridAreaMap());
1665 state.style()->setNamedGridAreaRowCount(gridTemplateAreasValue->rowCount());
1666 state.style()->setNamedGridAreaColumnCount(gridTemplateAreasValue->columnCount());
1670 case CSSPropertyJustifySelf: {
1671 HANDLE_INHERIT_AND_INITIAL(justifySelf, JustifySelf);
1672 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1673 if (Pair* pairValue = primitiveValue->getPairValue()) {
1674 state.style()->setJustifySelf(*pairValue->first());
1675 state.style()->setJustifySelfOverflowAlignment(*pairValue->second());
1677 state.style()->setJustifySelf(*primitiveValue);
1682 case CSSPropertyAlignSelf: {
1683 HANDLE_INHERIT_AND_INITIAL(alignSelf, AlignSelf);
1684 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1685 if (Pair* pairValue = primitiveValue->getPairValue()) {
1686 state.style()->setAlignSelf(*pairValue->first());
1687 state.style()->setAlignSelfOverflowAlignment(*pairValue->second());
1689 state.style()->setAlignSelf(*primitiveValue);
1694 case CSSPropertyAlignItems: {
1695 HANDLE_INHERIT_AND_INITIAL(alignItems, AlignItems);
1696 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1697 if (Pair* pairValue = primitiveValue->getPairValue()) {
1698 state.style()->setAlignItems(*pairValue->first());
1699 state.style()->setAlignItemsOverflowAlignment(*pairValue->second());
1701 state.style()->setAlignItems(*primitiveValue);
1706 // These properties are aliased and we already applied the property on the prefixed version.
1707 case CSSPropertyAnimationDelay:
1708 case CSSPropertyAnimationDirection:
1709 case CSSPropertyAnimationDuration:
1710 case CSSPropertyAnimationFillMode:
1711 case CSSPropertyAnimationIterationCount:
1712 case CSSPropertyAnimationName:
1713 case CSSPropertyAnimationPlayState:
1714 case CSSPropertyAnimationTimingFunction:
1715 case CSSPropertyTransitionDelay:
1716 case CSSPropertyTransitionDuration:
1717 case CSSPropertyTransitionProperty:
1718 case CSSPropertyTransitionTimingFunction:
1720 // These properties are implemented in StyleBuilder::applyProperty.
1721 case CSSPropertyBackgroundAttachment:
1722 case CSSPropertyBackgroundBlendMode:
1723 case CSSPropertyBackgroundClip:
1724 case CSSPropertyBackgroundColor:
1725 case CSSPropertyBackgroundImage:
1726 case CSSPropertyBackgroundOrigin:
1727 case CSSPropertyBackgroundPositionX:
1728 case CSSPropertyBackgroundPositionY:
1729 case CSSPropertyBackgroundRepeatX:
1730 case CSSPropertyBackgroundRepeatY:
1731 case CSSPropertyBackgroundSize:
1732 case CSSPropertyBorderBottomColor:
1733 case CSSPropertyBorderBottomLeftRadius:
1734 case CSSPropertyBorderBottomRightRadius:
1735 case CSSPropertyBorderBottomStyle:
1736 case CSSPropertyBorderBottomWidth:
1737 case CSSPropertyBorderCollapse:
1738 case CSSPropertyBorderImageOutset:
1739 case CSSPropertyBorderImageRepeat:
1740 case CSSPropertyBorderImageSlice:
1741 case CSSPropertyBorderImageSource:
1742 case CSSPropertyBorderImageWidth:
1743 case CSSPropertyBorderLeftColor:
1744 case CSSPropertyBorderLeftStyle:
1745 case CSSPropertyBorderLeftWidth:
1746 case CSSPropertyBorderRightColor:
1747 case CSSPropertyBorderRightStyle:
1748 case CSSPropertyBorderRightWidth:
1749 case CSSPropertyBorderTopColor:
1750 case CSSPropertyBorderTopLeftRadius:
1751 case CSSPropertyBorderTopRightRadius:
1752 case CSSPropertyBorderTopStyle:
1753 case CSSPropertyBorderTopWidth:
1754 case CSSPropertyBottom:
1755 case CSSPropertyBoxShadow:
1756 case CSSPropertyBoxSizing:
1757 case CSSPropertyCaptionSide:
1758 case CSSPropertyClear:
1759 case CSSPropertyClip:
1760 case CSSPropertyColor:
1761 case CSSPropertyCounterIncrement:
1762 case CSSPropertyCounterReset:
1763 case CSSPropertyCursor:
1764 case CSSPropertyDirection:
1765 case CSSPropertyDisplay:
1766 case CSSPropertyEmptyCells:
1767 case CSSPropertyFloat:
1768 case CSSPropertyFontKerning:
1769 case CSSPropertyFontSize:
1770 case CSSPropertyFontStyle:
1771 case CSSPropertyFontVariant:
1772 case CSSPropertyFontVariantLigatures:
1773 case CSSPropertyFontWeight:
1774 case CSSPropertyHeight:
1775 case CSSPropertyImageRendering:
1776 case CSSPropertyIsolation:
1777 case CSSPropertyLeft:
1778 case CSSPropertyLetterSpacing:
1779 case CSSPropertyLineHeight:
1780 case CSSPropertyListStyleImage:
1781 case CSSPropertyListStylePosition:
1782 case CSSPropertyListStyleType:
1783 case CSSPropertyMarginBottom:
1784 case CSSPropertyMarginLeft:
1785 case CSSPropertyMarginRight:
1786 case CSSPropertyMarginTop:
1787 case CSSPropertyMaxHeight:
1788 case CSSPropertyMaxWidth:
1789 case CSSPropertyMinHeight:
1790 case CSSPropertyMixBlendMode:
1791 case CSSPropertyMinWidth:
1792 case CSSPropertyObjectFit:
1793 case CSSPropertyOpacity:
1794 case CSSPropertyOrphans:
1795 case CSSPropertyOutlineColor:
1796 case CSSPropertyOutlineOffset:
1797 case CSSPropertyOutlineStyle:
1798 case CSSPropertyOutlineWidth:
1799 case CSSPropertyOverflowWrap:
1800 case CSSPropertyOverflowX:
1801 case CSSPropertyOverflowY:
1802 case CSSPropertyPaddingBottom:
1803 case CSSPropertyPaddingLeft:
1804 case CSSPropertyPaddingRight:
1805 case CSSPropertyPaddingTop:
1806 case CSSPropertyPageBreakAfter:
1807 case CSSPropertyPageBreakBefore:
1808 case CSSPropertyPageBreakInside:
1809 case CSSPropertyPointerEvents:
1810 case CSSPropertyPosition:
1811 case CSSPropertyResize:
1812 case CSSPropertyRight:
1813 case CSSPropertyScrollBehavior:
1814 case CSSPropertySize:
1815 case CSSPropertySpeak:
1816 case CSSPropertyTabSize:
1817 case CSSPropertyTableLayout:
1818 case CSSPropertyTextAlign:
1819 case CSSPropertyTextAlignLast:
1820 case CSSPropertyTextDecoration:
1821 case CSSPropertyTextDecorationLine:
1822 case CSSPropertyTextDecorationStyle:
1823 case CSSPropertyTextDecorationColor:
1824 case CSSPropertyTextIndent:
1825 case CSSPropertyTextJustify:
1826 case CSSPropertyTextOverflow:
1827 case CSSPropertyTextRendering:
1828 case CSSPropertyTextShadow:
1829 case CSSPropertyTextTransform:
1830 case CSSPropertyTop:
1831 case CSSPropertyTouchAction:
1832 case CSSPropertyTouchActionDelay:
1833 case CSSPropertyUnicodeBidi:
1834 case CSSPropertyVerticalAlign:
1835 case CSSPropertyVisibility:
1836 case CSSPropertyWebkitAnimationDelay:
1837 case CSSPropertyWebkitAnimationDirection:
1838 case CSSPropertyWebkitAnimationDuration:
1839 case CSSPropertyWebkitAnimationFillMode:
1840 case CSSPropertyWebkitAnimationIterationCount:
1841 case CSSPropertyWebkitAnimationName:
1842 case CSSPropertyWebkitAnimationPlayState:
1843 case CSSPropertyWebkitAnimationTimingFunction:
1844 case CSSPropertyWebkitAppearance:
1845 case CSSPropertyWebkitAspectRatio:
1846 case CSSPropertyWebkitBackfaceVisibility:
1847 case CSSPropertyWebkitBackgroundClip:
1848 case CSSPropertyWebkitBackgroundComposite:
1849 case CSSPropertyWebkitBackgroundOrigin:
1850 case CSSPropertyWebkitBackgroundSize:
1851 case CSSPropertyWebkitBorderFit:
1852 case CSSPropertyWebkitBorderHorizontalSpacing:
1853 case CSSPropertyWebkitBorderImage:
1854 case CSSPropertyWebkitBorderVerticalSpacing:
1855 case CSSPropertyWebkitBoxAlign:
1856 case CSSPropertyWebkitBoxDecorationBreak:
1857 case CSSPropertyWebkitBoxDirection:
1858 case CSSPropertyWebkitBoxFlex:
1859 case CSSPropertyWebkitBoxFlexGroup:
1860 case CSSPropertyWebkitBoxLines:
1861 case CSSPropertyWebkitBoxOrdinalGroup:
1862 case CSSPropertyWebkitBoxOrient:
1863 case CSSPropertyWebkitBoxPack:
1864 case CSSPropertyWebkitBoxShadow:
1865 case CSSPropertyWebkitColumnAxis:
1866 case CSSPropertyWebkitColumnBreakAfter:
1867 case CSSPropertyWebkitColumnBreakBefore:
1868 case CSSPropertyWebkitColumnBreakInside:
1869 case CSSPropertyWebkitColumnCount:
1870 case CSSPropertyColumnFill:
1871 case CSSPropertyWebkitColumnGap:
1872 case CSSPropertyWebkitColumnProgression:
1873 case CSSPropertyWebkitColumnRuleColor:
1874 case CSSPropertyWebkitColumnRuleStyle:
1875 case CSSPropertyWebkitColumnRuleWidth:
1876 case CSSPropertyWebkitColumnSpan:
1877 case CSSPropertyWebkitColumnWidth:
1878 case CSSPropertyAlignContent:
1879 case CSSPropertyFlexBasis:
1880 case CSSPropertyFlexDirection:
1881 case CSSPropertyFlexGrow:
1882 case CSSPropertyFlexShrink:
1883 case CSSPropertyFlexWrap:
1884 case CSSPropertyJustifyContent:
1885 case CSSPropertyOrder:
1886 case CSSPropertyWebkitFontSmoothing:
1887 case CSSPropertyWebkitHighlight:
1888 case CSSPropertyWebkitHyphenateCharacter:
1889 case CSSPropertyWebkitLineBreak:
1890 case CSSPropertyWebkitLineClamp:
1891 case CSSPropertyInternalMarqueeDirection:
1892 case CSSPropertyInternalMarqueeIncrement:
1893 case CSSPropertyInternalMarqueeRepetition:
1894 case CSSPropertyInternalMarqueeSpeed:
1895 case CSSPropertyInternalMarqueeStyle:
1896 case CSSPropertyWebkitMaskBoxImage:
1897 case CSSPropertyWebkitMaskBoxImageOutset:
1898 case CSSPropertyWebkitMaskBoxImageRepeat:
1899 case CSSPropertyWebkitMaskBoxImageSlice:
1900 case CSSPropertyWebkitMaskBoxImageSource:
1901 case CSSPropertyWebkitMaskBoxImageWidth:
1902 case CSSPropertyWebkitMaskClip:
1903 case CSSPropertyWebkitMaskComposite:
1904 case CSSPropertyWebkitMaskImage:
1905 case CSSPropertyWebkitMaskOrigin:
1906 case CSSPropertyWebkitMaskPositionX:
1907 case CSSPropertyWebkitMaskPositionY:
1908 case CSSPropertyWebkitMaskRepeatX:
1909 case CSSPropertyWebkitMaskRepeatY:
1910 case CSSPropertyWebkitMaskSize:
1911 case CSSPropertyWebkitPerspectiveOrigin:
1912 case CSSPropertyWebkitPerspectiveOriginX:
1913 case CSSPropertyWebkitPerspectiveOriginY:
1914 case CSSPropertyWebkitPrintColorAdjust:
1915 case CSSPropertyWebkitRtlOrdering:
1916 case CSSPropertyWebkitRubyPosition:
1917 case CSSPropertyWebkitTextCombine:
1918 case CSSPropertyTextUnderlinePosition:
1919 case CSSPropertyWebkitTextEmphasisColor:
1920 case CSSPropertyWebkitTextEmphasisPosition:
1921 case CSSPropertyWebkitTextEmphasisStyle:
1922 case CSSPropertyWebkitTextFillColor:
1923 case CSSPropertyWebkitTextSecurity:
1924 case CSSPropertyWebkitTextStrokeColor:
1925 case CSSPropertyWebkitTransformOriginX:
1926 case CSSPropertyWebkitTransformOriginY:
1927 case CSSPropertyWebkitTransformOriginZ:
1928 case CSSPropertyWebkitTransformStyle:
1929 case CSSPropertyWebkitTransitionDelay:
1930 case CSSPropertyWebkitTransitionDuration:
1931 case CSSPropertyWebkitTransitionProperty:
1932 case CSSPropertyWebkitTransitionTimingFunction:
1933 case CSSPropertyWebkitUserDrag:
1934 case CSSPropertyWebkitUserModify:
1935 case CSSPropertyWebkitUserSelect:
1936 case CSSPropertyWebkitClipPath:
1937 case CSSPropertyWebkitWrapFlow:
1938 case CSSPropertyShapeMargin:
1939 case CSSPropertyShapePadding:
1940 case CSSPropertyShapeImageThreshold:
1941 case CSSPropertyWebkitWrapThrough:
1942 case CSSPropertyShapeInside:
1943 case CSSPropertyShapeOutside:
1944 case CSSPropertyWhiteSpace:
1945 case CSSPropertyWidows:
1946 case CSSPropertyWidth:
1947 case CSSPropertyWordBreak:
1948 case CSSPropertyWordSpacing:
1949 case CSSPropertyWordWrap:
1950 case CSSPropertyZIndex:
1951 case CSSPropertyZoom:
1952 case CSSPropertyFontFamily:
1953 case CSSPropertyGridAutoFlow:
1954 case CSSPropertyMarker:
1955 case CSSPropertyAlignmentBaseline:
1956 case CSSPropertyBufferedRendering:
1957 case CSSPropertyClipRule:
1958 case CSSPropertyColorInterpolation:
1959 case CSSPropertyColorInterpolationFilters:
1960 case CSSPropertyColorRendering:
1961 case CSSPropertyDominantBaseline:
1962 case CSSPropertyFillRule:
1963 case CSSPropertyMaskSourceType:
1964 case CSSPropertyMaskType:
1965 case CSSPropertyShapeRendering:
1966 case CSSPropertyStrokeLinecap:
1967 case CSSPropertyStrokeLinejoin:
1968 case CSSPropertyTextAnchor:
1969 case CSSPropertyVectorEffect:
1970 case CSSPropertyWritingMode:
1971 case CSSPropertyClipPath:
1972 case CSSPropertyFillOpacity:
1973 case CSSPropertyFilter:
1974 case CSSPropertyFloodOpacity:
1975 case CSSPropertyKerning:
1976 case CSSPropertyMarkerEnd:
1977 case CSSPropertyMarkerMid:
1978 case CSSPropertyMarkerStart:
1979 case CSSPropertyMask:
1980 case CSSPropertyStopOpacity:
1981 case CSSPropertyStrokeDashoffset:
1982 case CSSPropertyStrokeMiterlimit:
1983 case CSSPropertyStrokeOpacity:
1984 case CSSPropertyStrokeWidth:
1985 ASSERT_NOT_REACHED();
1987 // Only used in @viewport rules
1988 case CSSPropertyMaxZoom:
1989 case CSSPropertyMinZoom:
1990 case CSSPropertyOrientation:
1991 case CSSPropertyUserZoom:
1994 case CSSPropertyBaselineShift:
1996 HANDLE_SVG_INHERIT_AND_INITIAL(baselineShift, BaselineShift);
1997 if (!primitiveValue)
2000 SVGRenderStyle* svgStyle = state.style()->accessSVGStyle();
2001 if (primitiveValue->getValueID()) {
2002 switch (primitiveValue->getValueID()) {
2003 case CSSValueBaseline:
2004 svgStyle->setBaselineShift(BS_BASELINE);
2007 svgStyle->setBaselineShift(BS_SUB);
2010 svgStyle->setBaselineShift(BS_SUPER);
2016 svgStyle->setBaselineShift(BS_LENGTH);
2017 svgStyle->setBaselineShiftValue(SVGLength::fromCSSPrimitiveValue(primitiveValue));
2022 case CSSPropertyColorProfile:
2027 // end of ident only properties
2028 case CSSPropertyFill:
2030 SVGRenderStyle* svgStyle = state.style()->accessSVGStyle();
2032 const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle();
2033 svgStyle->setFillPaint(svgParentStyle->fillPaintType(), svgParentStyle->fillPaintColor(), svgParentStyle->fillPaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle());
2037 svgStyle->setFillPaint(SVGRenderStyle::initialFillPaintType(), SVGRenderStyle::initialFillPaintColor(), SVGRenderStyle::initialFillPaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle());
2040 if (value->isSVGPaint()) {
2041 SVGPaint* svgPaint = toSVGPaint(value);
2042 svgStyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle());
2046 case CSSPropertyStroke:
2048 SVGRenderStyle* svgStyle = state.style()->accessSVGStyle();
2050 const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle();
2051 svgStyle->setStrokePaint(svgParentStyle->strokePaintType(), svgParentStyle->strokePaintColor(), svgParentStyle->strokePaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle());
2055 svgStyle->setStrokePaint(SVGRenderStyle::initialStrokePaintType(), SVGRenderStyle::initialStrokePaintColor(), SVGRenderStyle::initialStrokePaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle());
2058 if (value->isSVGPaint()) {
2059 SVGPaint* svgPaint = toSVGPaint(value);
2060 svgStyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle());
2064 case CSSPropertyStrokeDasharray:
2066 HANDLE_SVG_INHERIT_AND_INITIAL(strokeDashArray, StrokeDashArray)
2067 if (!value->isValueList()) {
2068 state.style()->accessSVGStyle()->setStrokeDashArray(SVGRenderStyle::initialStrokeDashArray());
2072 CSSValueList* dashes = toCSSValueList(value);
2074 RefPtr<SVGLengthList> array = SVGLengthList::create();
2075 size_t length = dashes->length();
2076 for (size_t i = 0; i < length; ++i) {
2077 CSSValue* currValue = dashes->itemWithoutBoundsCheck(i);
2078 if (!currValue->isPrimitiveValue())
2081 CSSPrimitiveValue* dash = toCSSPrimitiveValue(dashes->itemWithoutBoundsCheck(i));
2082 array->append(SVGLength::fromCSSPrimitiveValue(dash));
2085 state.style()->accessSVGStyle()->setStrokeDashArray(array.release());
2088 case CSSPropertyStopColor:
2090 HANDLE_SVG_INHERIT_AND_INITIAL(stopColor, StopColor);
2091 if (value->isSVGColor())
2092 state.style()->accessSVGStyle()->setStopColor(colorFromSVGColorCSSValue(toSVGColor(value), state.style()->color()));
2095 case CSSPropertyLightingColor:
2097 HANDLE_SVG_INHERIT_AND_INITIAL(lightingColor, LightingColor);
2098 if (value->isSVGColor())
2099 state.style()->accessSVGStyle()->setLightingColor(colorFromSVGColorCSSValue(toSVGColor(value), state.style()->color()));
2102 case CSSPropertyFloodColor:
2104 HANDLE_SVG_INHERIT_AND_INITIAL(floodColor, FloodColor);
2105 if (value->isSVGColor())
2106 state.style()->accessSVGStyle()->setFloodColor(colorFromSVGColorCSSValue(toSVGColor(value), state.style()->color()));
2109 case CSSPropertyGlyphOrientationHorizontal:
2111 HANDLE_SVG_INHERIT_AND_INITIAL(glyphOrientationHorizontal, GlyphOrientationHorizontal)
2112 EGlyphOrientation orientation;
2113 if (degreeToGlyphOrientation(primitiveValue, orientation))
2114 state.style()->accessSVGStyle()->setGlyphOrientationHorizontal(orientation);
2117 case CSSPropertyPaintOrder: {
2118 HANDLE_SVG_INHERIT_AND_INITIAL(paintOrder, PaintOrder)
2119 if (value->isValueList())
2120 state.style()->accessSVGStyle()->setPaintOrder(paintOrderFlattened(value));
2123 case CSSPropertyGlyphOrientationVertical:
2125 HANDLE_SVG_INHERIT_AND_INITIAL(glyphOrientationVertical, GlyphOrientationVertical)
2126 if (primitiveValue->getValueID() == CSSValueAuto) {
2127 state.style()->accessSVGStyle()->setGlyphOrientationVertical(GO_AUTO);
2130 EGlyphOrientation orientation;
2131 if (degreeToGlyphOrientation(primitiveValue, orientation))
2132 state.style()->accessSVGStyle()->setGlyphOrientationVertical(orientation);
2135 case CSSPropertyEnableBackground:
2136 // Silently ignoring this property for now
2137 // http://bugs.webkit.org/show_bug.cgi?id=6022
2142 } // namespace WebCore