2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
4 * Copyright (C) 2013 Intel Corporation. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 #include "StylePropertyShorthand.h"
25 #include <wtf/StdLibExtras.h>
27 // FIXME: How much of this file can we generate?
31 StylePropertyShorthand backgroundShorthand()
33 static const CSSPropertyID backgroundProperties[] = {
34 CSSPropertyBackgroundImage,
35 CSSPropertyBackgroundPositionX,
36 CSSPropertyBackgroundPositionY,
37 CSSPropertyBackgroundSize,
38 CSSPropertyBackgroundRepeatX,
39 CSSPropertyBackgroundRepeatY,
40 CSSPropertyBackgroundAttachment,
41 CSSPropertyBackgroundOrigin,
42 CSSPropertyBackgroundClip,
43 CSSPropertyBackgroundColor
45 return StylePropertyShorthand(CSSPropertyBackground, backgroundProperties, WTF_ARRAY_LENGTH(backgroundProperties));
48 StylePropertyShorthand backgroundPositionShorthand()
50 static const CSSPropertyID backgroundPositionProperties[] = { CSSPropertyBackgroundPositionX, CSSPropertyBackgroundPositionY };
51 return StylePropertyShorthand(CSSPropertyBackgroundPosition, backgroundPositionProperties, WTF_ARRAY_LENGTH(backgroundPositionProperties));
54 StylePropertyShorthand backgroundRepeatShorthand()
56 static const CSSPropertyID backgroundRepeatProperties[] = { CSSPropertyBackgroundRepeatX, CSSPropertyBackgroundRepeatY };
57 return StylePropertyShorthand(CSSPropertyBackgroundRepeat, backgroundRepeatProperties, WTF_ARRAY_LENGTH(backgroundRepeatProperties));
60 StylePropertyShorthand borderShorthand()
62 // Do not change the order of the following four shorthands, and keep them together.
63 static const CSSPropertyID borderProperties[4][3] = {
64 { CSSPropertyBorderTopColor, CSSPropertyBorderTopStyle, CSSPropertyBorderTopWidth },
65 { CSSPropertyBorderRightColor, CSSPropertyBorderRightStyle, CSSPropertyBorderRightWidth },
66 { CSSPropertyBorderBottomColor, CSSPropertyBorderBottomStyle, CSSPropertyBorderBottomWidth },
67 { CSSPropertyBorderLeftColor, CSSPropertyBorderLeftStyle, CSSPropertyBorderLeftWidth }
69 return StylePropertyShorthand(CSSPropertyBorder, borderProperties[0], sizeof(borderProperties) / sizeof(borderProperties[0][0]));
72 StylePropertyShorthand borderAbridgedShorthand()
74 static const CSSPropertyID borderAbridgedProperties[] = { CSSPropertyBorderWidth, CSSPropertyBorderStyle, CSSPropertyBorderColor };
75 static const StylePropertyShorthand propertiesForInitialization[] = { borderWidthShorthand(), borderStyleShorthand(), borderColorShorthand() };
76 return StylePropertyShorthand(CSSPropertyBorder, borderAbridgedProperties, propertiesForInitialization, WTF_ARRAY_LENGTH(borderAbridgedProperties));
79 StylePropertyShorthand borderBottomShorthand()
81 static const CSSPropertyID borderBottomProperties[] = { CSSPropertyBorderBottomWidth, CSSPropertyBorderBottomStyle, CSSPropertyBorderBottomColor };
82 return StylePropertyShorthand(CSSPropertyBorderBottom, borderBottomProperties, WTF_ARRAY_LENGTH(borderBottomProperties));
85 StylePropertyShorthand borderColorShorthand()
87 static const CSSPropertyID borderColorProperties[] = {
88 CSSPropertyBorderTopColor,
89 CSSPropertyBorderRightColor,
90 CSSPropertyBorderBottomColor,
91 CSSPropertyBorderLeftColor
93 return StylePropertyShorthand(CSSPropertyBorderColor, borderColorProperties, WTF_ARRAY_LENGTH(borderColorProperties));
96 StylePropertyShorthand borderImageShorthand()
98 static const CSSPropertyID borderImageProperties[] = {
99 CSSPropertyBorderImageSource,
100 CSSPropertyBorderImageSlice,
101 CSSPropertyBorderImageWidth,
102 CSSPropertyBorderImageOutset,
103 CSSPropertyBorderImageRepeat
105 return StylePropertyShorthand(CSSPropertyBorderImage, borderImageProperties, WTF_ARRAY_LENGTH(borderImageProperties));
108 StylePropertyShorthand borderLeftShorthand()
110 static const CSSPropertyID borderLeftProperties[] = { CSSPropertyBorderLeftWidth, CSSPropertyBorderLeftStyle, CSSPropertyBorderLeftColor };
111 return StylePropertyShorthand(CSSPropertyBorderLeft, borderLeftProperties, WTF_ARRAY_LENGTH(borderLeftProperties));
114 StylePropertyShorthand borderRadiusShorthand()
116 static const CSSPropertyID borderRadiusProperties[] = {
117 CSSPropertyBorderTopLeftRadius,
118 CSSPropertyBorderTopRightRadius,
119 CSSPropertyBorderBottomRightRadius,
120 CSSPropertyBorderBottomLeftRadius
122 return StylePropertyShorthand(CSSPropertyBorderRadius, borderRadiusProperties, WTF_ARRAY_LENGTH(borderRadiusProperties));
125 StylePropertyShorthand webkitBorderRadiusShorthand()
127 static const CSSPropertyID borderRadiusProperties[] = {
128 CSSPropertyBorderTopLeftRadius,
129 CSSPropertyBorderTopRightRadius,
130 CSSPropertyBorderBottomRightRadius,
131 CSSPropertyBorderBottomLeftRadius
133 return StylePropertyShorthand(CSSPropertyWebkitBorderRadius, borderRadiusProperties, WTF_ARRAY_LENGTH(borderRadiusProperties));
136 StylePropertyShorthand borderRightShorthand()
138 static const CSSPropertyID borderRightProperties[] = { CSSPropertyBorderRightWidth, CSSPropertyBorderRightStyle, CSSPropertyBorderRightColor };
139 return StylePropertyShorthand(CSSPropertyBorderRight, borderRightProperties, WTF_ARRAY_LENGTH(borderRightProperties));
142 StylePropertyShorthand borderSpacingShorthand()
144 static const CSSPropertyID borderSpacingProperties[] = { CSSPropertyWebkitBorderHorizontalSpacing, CSSPropertyWebkitBorderVerticalSpacing };
145 return StylePropertyShorthand(CSSPropertyBorderSpacing, borderSpacingProperties, WTF_ARRAY_LENGTH(borderSpacingProperties));
148 StylePropertyShorthand borderStyleShorthand()
150 static const CSSPropertyID borderStyleProperties[] = {
151 CSSPropertyBorderTopStyle,
152 CSSPropertyBorderRightStyle,
153 CSSPropertyBorderBottomStyle,
154 CSSPropertyBorderLeftStyle
156 return StylePropertyShorthand(CSSPropertyBorderStyle, borderStyleProperties, WTF_ARRAY_LENGTH(borderStyleProperties));
159 StylePropertyShorthand borderTopShorthand()
161 static const CSSPropertyID borderTopProperties[] = { CSSPropertyBorderTopWidth, CSSPropertyBorderTopStyle, CSSPropertyBorderTopColor };
162 return StylePropertyShorthand(CSSPropertyBorderTop, borderTopProperties, WTF_ARRAY_LENGTH(borderTopProperties));
165 StylePropertyShorthand borderWidthShorthand()
167 static const CSSPropertyID borderWidthProperties[] = {
168 CSSPropertyBorderTopWidth,
169 CSSPropertyBorderRightWidth,
170 CSSPropertyBorderBottomWidth,
171 CSSPropertyBorderLeftWidth
173 return StylePropertyShorthand(CSSPropertyBorderWidth, borderWidthProperties, WTF_ARRAY_LENGTH(borderWidthProperties));
176 StylePropertyShorthand listStyleShorthand()
178 static const CSSPropertyID listStyleProperties[] = {
179 CSSPropertyListStyleType,
180 CSSPropertyListStylePosition,
181 CSSPropertyListStyleImage
183 return StylePropertyShorthand(CSSPropertyListStyle, listStyleProperties, WTF_ARRAY_LENGTH(listStyleProperties));
186 StylePropertyShorthand fontShorthand()
188 static const CSSPropertyID fontProperties[] = {
189 CSSPropertyFontFamily,
191 CSSPropertyFontStyle,
192 CSSPropertyFontVariant,
193 CSSPropertyFontWeight,
194 CSSPropertyLineHeight
196 return StylePropertyShorthand(CSSPropertyFont, fontProperties, WTF_ARRAY_LENGTH(fontProperties));
199 StylePropertyShorthand marginShorthand()
201 static const CSSPropertyID marginProperties[] = {
202 CSSPropertyMarginTop,
203 CSSPropertyMarginRight,
204 CSSPropertyMarginBottom,
205 CSSPropertyMarginLeft
207 return StylePropertyShorthand(CSSPropertyMargin, marginProperties, WTF_ARRAY_LENGTH(marginProperties));
210 StylePropertyShorthand markerShorthand()
212 static const CSSPropertyID markerProperties[] = {
213 CSSPropertyMarkerStart,
214 CSSPropertyMarkerMid,
217 return StylePropertyShorthand(CSSPropertyMarker, markerProperties, WTF_ARRAY_LENGTH(markerProperties));
220 StylePropertyShorthand outlineShorthand()
222 static const CSSPropertyID outlineProperties[] = {
223 CSSPropertyOutlineColor,
224 CSSPropertyOutlineStyle,
225 CSSPropertyOutlineWidth
227 return StylePropertyShorthand(CSSPropertyOutline, outlineProperties, WTF_ARRAY_LENGTH(outlineProperties));
230 StylePropertyShorthand overflowShorthand()
232 static const CSSPropertyID overflowProperties[] = { CSSPropertyOverflowX, CSSPropertyOverflowY };
233 return StylePropertyShorthand(CSSPropertyOverflow, overflowProperties, WTF_ARRAY_LENGTH(overflowProperties));
236 StylePropertyShorthand paddingShorthand()
238 static const CSSPropertyID paddingProperties[] = {
239 CSSPropertyPaddingTop,
240 CSSPropertyPaddingRight,
241 CSSPropertyPaddingBottom,
242 CSSPropertyPaddingLeft
244 return StylePropertyShorthand(CSSPropertyPadding, paddingProperties, WTF_ARRAY_LENGTH(paddingProperties));
247 StylePropertyShorthand transitionShorthand()
249 static const CSSPropertyID transitionProperties[] = {
250 CSSPropertyTransitionProperty,
251 CSSPropertyTransitionDuration,
252 CSSPropertyTransitionTimingFunction,
253 CSSPropertyTransitionDelay
255 return StylePropertyShorthand(CSSPropertyTransition, transitionProperties, WTF_ARRAY_LENGTH(transitionProperties));
258 StylePropertyShorthand webkitAnimationShorthand()
260 static const CSSPropertyID animationProperties[] = {
261 CSSPropertyWebkitAnimationName,
262 CSSPropertyWebkitAnimationDuration,
263 CSSPropertyWebkitAnimationTimingFunction,
264 CSSPropertyWebkitAnimationDelay,
265 CSSPropertyWebkitAnimationIterationCount,
266 CSSPropertyWebkitAnimationDirection,
267 CSSPropertyWebkitAnimationFillMode
269 return StylePropertyShorthand(CSSPropertyWebkitAnimation, animationProperties, WTF_ARRAY_LENGTH(animationProperties));
272 StylePropertyShorthand webkitAnimationShorthandForParsing()
274 // When we parse the animation shorthand we need to look for animation-name
275 // last because otherwise it might match against the keywords for fill mode,
276 // timing functions and infinite iteration. This means that animation names
277 // that are the same as keywords (e.g. 'forwards') won't always match in the
278 // shorthand. In that case the authors should be using longhands (or
279 // reconsidering their approach). This is covered by the animations spec
280 // bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=14790
281 // And in the spec (editor's draft) at:
282 // http://dev.w3.org/csswg/css3-animations/#animation-shorthand-property
283 static const CSSPropertyID animationPropertiesForParsing[] = {
284 CSSPropertyWebkitAnimationDuration,
285 CSSPropertyWebkitAnimationTimingFunction,
286 CSSPropertyWebkitAnimationDelay,
287 CSSPropertyWebkitAnimationIterationCount,
288 CSSPropertyWebkitAnimationDirection,
289 CSSPropertyWebkitAnimationFillMode,
290 CSSPropertyWebkitAnimationName
293 return StylePropertyShorthand(CSSPropertyWebkitAnimation, animationPropertiesForParsing, WTF_ARRAY_LENGTH(animationPropertiesForParsing));
296 StylePropertyShorthand webkitBorderAfterShorthand()
298 static const CSSPropertyID borderAfterProperties[] = { CSSPropertyWebkitBorderAfterWidth, CSSPropertyWebkitBorderAfterStyle, CSSPropertyWebkitBorderAfterColor };
299 return StylePropertyShorthand(CSSPropertyWebkitBorderAfter, borderAfterProperties, WTF_ARRAY_LENGTH(borderAfterProperties));
302 StylePropertyShorthand webkitBorderBeforeShorthand()
304 static const CSSPropertyID borderBeforeProperties[] = { CSSPropertyWebkitBorderBeforeWidth, CSSPropertyWebkitBorderBeforeStyle, CSSPropertyWebkitBorderBeforeColor };
305 return StylePropertyShorthand(CSSPropertyWebkitBorderBefore, borderBeforeProperties, WTF_ARRAY_LENGTH(borderBeforeProperties));
308 StylePropertyShorthand webkitBorderEndShorthand()
310 static const CSSPropertyID borderEndProperties[] = { CSSPropertyWebkitBorderEndWidth, CSSPropertyWebkitBorderEndStyle, CSSPropertyWebkitBorderEndColor };
311 return StylePropertyShorthand(CSSPropertyWebkitBorderEnd, borderEndProperties, WTF_ARRAY_LENGTH(borderEndProperties));
314 StylePropertyShorthand webkitBorderStartShorthand()
316 static const CSSPropertyID borderStartProperties[] = { CSSPropertyWebkitBorderStartWidth, CSSPropertyWebkitBorderStartStyle, CSSPropertyWebkitBorderStartColor };
317 return StylePropertyShorthand(CSSPropertyWebkitBorderStart, borderStartProperties, WTF_ARRAY_LENGTH(borderStartProperties));
320 StylePropertyShorthand webkitColumnsShorthand()
322 static const CSSPropertyID columnsProperties[] = { CSSPropertyWebkitColumnWidth, CSSPropertyWebkitColumnCount };
323 return StylePropertyShorthand(CSSPropertyWebkitColumns, columnsProperties, WTF_ARRAY_LENGTH(columnsProperties));
326 StylePropertyShorthand webkitColumnRuleShorthand()
328 static const CSSPropertyID columnRuleProperties[] = {
329 CSSPropertyWebkitColumnRuleWidth,
330 CSSPropertyWebkitColumnRuleStyle,
331 CSSPropertyWebkitColumnRuleColor,
333 return StylePropertyShorthand(CSSPropertyWebkitColumnRule, columnRuleProperties, WTF_ARRAY_LENGTH(columnRuleProperties));
336 StylePropertyShorthand webkitFlexFlowShorthand()
338 static const CSSPropertyID flexFlowProperties[] = { CSSPropertyWebkitFlexDirection, CSSPropertyWebkitFlexWrap };
339 return StylePropertyShorthand(CSSPropertyWebkitFlexFlow, flexFlowProperties, WTF_ARRAY_LENGTH(flexFlowProperties));
342 StylePropertyShorthand webkitFlexShorthand()
344 static const CSSPropertyID flexProperties[] = { CSSPropertyWebkitFlexGrow, CSSPropertyWebkitFlexShrink, CSSPropertyWebkitFlexBasis };
345 return StylePropertyShorthand(CSSPropertyWebkitFlex, flexProperties, WTF_ARRAY_LENGTH(flexProperties));
348 StylePropertyShorthand webkitMarginCollapseShorthand()
350 static const CSSPropertyID marginCollapseProperties[] = { CSSPropertyWebkitMarginBeforeCollapse, CSSPropertyWebkitMarginAfterCollapse };
351 return StylePropertyShorthand(CSSPropertyWebkitMarginCollapse, marginCollapseProperties, WTF_ARRAY_LENGTH(marginCollapseProperties));
354 #if ENABLE(CSS_GRID_LAYOUT)
355 StylePropertyShorthand webkitGridTemplateShorthand()
357 static const CSSPropertyID webkitGridTemplateProperties[] = {
358 CSSPropertyWebkitGridTemplateColumns,
359 CSSPropertyWebkitGridTemplateRows,
360 CSSPropertyWebkitGridTemplateAreas
362 return StylePropertyShorthand(CSSPropertyWebkitGridTemplate, webkitGridTemplateProperties, WTF_ARRAY_LENGTH(webkitGridTemplateProperties));
365 StylePropertyShorthand webkitGridAreaShorthand()
367 static const CSSPropertyID webkitGridAreaProperties[] = {
368 CSSPropertyWebkitGridRowStart,
369 CSSPropertyWebkitGridColumnStart,
370 CSSPropertyWebkitGridRowEnd,
371 CSSPropertyWebkitGridColumnEnd
373 return StylePropertyShorthand(CSSPropertyWebkitGridArea, webkitGridAreaProperties, WTF_ARRAY_LENGTH(webkitGridAreaProperties));
376 StylePropertyShorthand webkitGridColumnShorthand()
378 static const CSSPropertyID webkitGridColumnProperties[] = {
379 CSSPropertyWebkitGridColumnStart,
380 CSSPropertyWebkitGridColumnEnd
382 return StylePropertyShorthand(CSSPropertyWebkitGridColumn, webkitGridColumnProperties, WTF_ARRAY_LENGTH(webkitGridColumnProperties));
386 StylePropertyShorthand webkitGridRowShorthand()
388 static const CSSPropertyID webkitGridRowProperties[] = {
389 CSSPropertyWebkitGridRowStart,
390 CSSPropertyWebkitGridRowEnd
392 return StylePropertyShorthand(CSSPropertyWebkitGridRow, webkitGridRowProperties, WTF_ARRAY_LENGTH(webkitGridRowProperties));
395 #endif /* ENABLE(CSS_GRID_LAYOUT) */
397 StylePropertyShorthand webkitMarqueeShorthand()
399 static const CSSPropertyID marqueeProperties[] = {
400 CSSPropertyWebkitMarqueeDirection,
401 CSSPropertyWebkitMarqueeIncrement,
402 CSSPropertyWebkitMarqueeRepetition,
403 CSSPropertyWebkitMarqueeStyle,
404 CSSPropertyWebkitMarqueeSpeed
406 return StylePropertyShorthand(CSSPropertyWebkitMarquee, marqueeProperties, WTF_ARRAY_LENGTH(marqueeProperties));
409 StylePropertyShorthand webkitMaskShorthand()
411 static const CSSPropertyID maskProperties[] = {
412 CSSPropertyWebkitMaskImage,
413 CSSPropertyWebkitMaskSourceType,
414 CSSPropertyWebkitMaskPositionX,
415 CSSPropertyWebkitMaskPositionY,
416 CSSPropertyWebkitMaskSize,
417 CSSPropertyWebkitMaskRepeatX,
418 CSSPropertyWebkitMaskRepeatY,
419 CSSPropertyWebkitMaskOrigin,
420 CSSPropertyWebkitMaskClip
422 return StylePropertyShorthand(CSSPropertyWebkitMask, maskProperties, WTF_ARRAY_LENGTH(maskProperties));
425 StylePropertyShorthand webkitMaskPositionShorthand()
427 static const CSSPropertyID maskPositionProperties[] = { CSSPropertyWebkitMaskPositionX, CSSPropertyWebkitMaskPositionY };
428 return StylePropertyShorthand(CSSPropertyWebkitMaskPosition, maskPositionProperties, WTF_ARRAY_LENGTH(maskPositionProperties));
431 StylePropertyShorthand webkitMaskRepeatShorthand()
433 static const CSSPropertyID maskRepeatProperties[] = { CSSPropertyWebkitMaskRepeatX, CSSPropertyWebkitMaskRepeatY };
434 return StylePropertyShorthand(CSSPropertyWebkitMaskRepeat, maskRepeatProperties, WTF_ARRAY_LENGTH(maskRepeatProperties));
437 StylePropertyShorthand webkitTextDecorationShorthand()
439 static const CSSPropertyID textDecorationProperties[] = {
440 CSSPropertyWebkitTextDecorationLine,
441 CSSPropertyWebkitTextDecorationStyle,
442 CSSPropertyWebkitTextDecorationColor
444 return StylePropertyShorthand(CSSPropertyWebkitTextDecoration, textDecorationProperties, WTF_ARRAY_LENGTH(textDecorationProperties));
447 StylePropertyShorthand webkitTextEmphasisShorthand()
449 static const CSSPropertyID textEmphasisProperties[] = {
450 CSSPropertyWebkitTextEmphasisStyle,
451 CSSPropertyWebkitTextEmphasisColor
453 return StylePropertyShorthand(CSSPropertyWebkitTextEmphasis, textEmphasisProperties, WTF_ARRAY_LENGTH(textEmphasisProperties));
456 StylePropertyShorthand webkitTextStrokeShorthand()
458 static const CSSPropertyID textStrokeProperties[] = { CSSPropertyWebkitTextStrokeWidth, CSSPropertyWebkitTextStrokeColor };
459 return StylePropertyShorthand(CSSPropertyWebkitTextStroke, textStrokeProperties, WTF_ARRAY_LENGTH(textStrokeProperties));
462 StylePropertyShorthand webkitTransitionShorthand()
464 static const CSSPropertyID transitionProperties[] = {
465 CSSPropertyWebkitTransitionProperty,
466 CSSPropertyWebkitTransitionDuration,
467 CSSPropertyWebkitTransitionTimingFunction,
468 CSSPropertyWebkitTransitionDelay
470 return StylePropertyShorthand(CSSPropertyWebkitTransition, transitionProperties, WTF_ARRAY_LENGTH(transitionProperties));
473 StylePropertyShorthand webkitTransformOriginShorthand()
475 static const CSSPropertyID transformOriginProperties[] = {
476 CSSPropertyWebkitTransformOriginX,
477 CSSPropertyWebkitTransformOriginY,
478 CSSPropertyWebkitTransformOriginZ
480 return StylePropertyShorthand(CSSPropertyWebkitTransformOrigin, transformOriginProperties, WTF_ARRAY_LENGTH(transformOriginProperties));
483 StylePropertyShorthand widthShorthand()
485 static const CSSPropertyID widthProperties[] = {
489 return StylePropertyShorthand(CSSPropertyWidth, widthProperties, WTF_ARRAY_LENGTH(widthProperties));
492 StylePropertyShorthand heightShorthand()
494 static const CSSPropertyID heightProperties[] = {
495 CSSPropertyMinHeight,
498 return StylePropertyShorthand(CSSPropertyHeight, heightProperties, WTF_ARRAY_LENGTH(heightProperties));
501 // Returns an empty list if the property is not a shorthand.
502 StylePropertyShorthand shorthandForProperty(CSSPropertyID propertyID)
504 switch (propertyID) {
505 case CSSPropertyBackground:
506 return backgroundShorthand();
507 case CSSPropertyBackgroundPosition:
508 return backgroundPositionShorthand();
509 case CSSPropertyBackgroundRepeat:
510 return backgroundRepeatShorthand();
511 case CSSPropertyBorder:
512 return borderShorthand();
513 case CSSPropertyBorderBottom:
514 return borderBottomShorthand();
515 case CSSPropertyBorderColor:
516 return borderColorShorthand();
517 case CSSPropertyBorderImage:
518 return borderImageShorthand();
519 case CSSPropertyBorderLeft:
520 return borderLeftShorthand();
521 case CSSPropertyBorderRadius:
522 return borderRadiusShorthand();
523 case CSSPropertyBorderRight:
524 return borderRightShorthand();
525 case CSSPropertyBorderSpacing:
526 return borderSpacingShorthand();
527 case CSSPropertyBorderStyle:
528 return borderStyleShorthand();
529 case CSSPropertyBorderTop:
530 return borderTopShorthand();
531 case CSSPropertyBorderWidth:
532 return borderWidthShorthand();
533 case CSSPropertyListStyle:
534 return listStyleShorthand();
535 case CSSPropertyFont:
536 return fontShorthand();
537 case CSSPropertyMargin:
538 return marginShorthand();
539 case CSSPropertyOutline:
540 return outlineShorthand();
541 case CSSPropertyOverflow:
542 return overflowShorthand();
543 case CSSPropertyPadding:
544 return paddingShorthand();
545 case CSSPropertyTransition:
546 return transitionShorthand();
547 case CSSPropertyWebkitAnimation:
548 return webkitAnimationShorthand();
549 case CSSPropertyWebkitBorderAfter:
550 return webkitBorderAfterShorthand();
551 case CSSPropertyWebkitBorderBefore:
552 return webkitBorderBeforeShorthand();
553 case CSSPropertyWebkitBorderEnd:
554 return webkitBorderEndShorthand();
555 case CSSPropertyWebkitBorderStart:
556 return webkitBorderStartShorthand();
557 case CSSPropertyWebkitBorderRadius:
558 return borderRadiusShorthand();
559 case CSSPropertyWebkitColumns:
560 return webkitColumnsShorthand();
561 case CSSPropertyWebkitColumnRule:
562 return webkitColumnRuleShorthand();
563 case CSSPropertyWebkitFlex:
564 return webkitFlexShorthand();
565 case CSSPropertyWebkitFlexFlow:
566 return webkitFlexFlowShorthand();
567 #if ENABLE(CSS_GRID_LAYOUT)
568 case CSSPropertyWebkitGridArea:
569 return webkitGridAreaShorthand();
570 case CSSPropertyWebkitGridColumn:
571 return webkitGridColumnShorthand();
572 case CSSPropertyWebkitGridRow:
573 return webkitGridRowShorthand();
575 case CSSPropertyWebkitMarginCollapse:
576 return webkitMarginCollapseShorthand();
577 case CSSPropertyWebkitMarquee:
578 return webkitMarqueeShorthand();
579 case CSSPropertyWebkitMask:
580 return webkitMaskShorthand();
581 case CSSPropertyWebkitMaskPosition:
582 return webkitMaskPositionShorthand();
583 case CSSPropertyWebkitMaskRepeat:
584 return webkitMaskRepeatShorthand();
585 case CSSPropertyWebkitTextEmphasis:
586 return webkitTextEmphasisShorthand();
587 case CSSPropertyWebkitTextStroke:
588 return webkitTextStrokeShorthand();
589 case CSSPropertyWebkitTransition:
590 return webkitTransitionShorthand();
591 case CSSPropertyWebkitTransformOrigin:
592 return webkitTransformOriginShorthand();
593 case CSSPropertyWebkitTextDecoration:
594 return webkitTextDecorationShorthand();
595 case CSSPropertyMarker:
596 return markerShorthand();
598 return StylePropertyShorthand();
602 bool isExpandedShorthand(CSSPropertyID id)
604 // The system fonts bypass the normal style resolution by using RenderTheme,
605 // thus we need to special case it here. FIXME: This is a violation of CSS 3 Fonts
606 // as we should still be able to change the longhands.
607 // DON'T ADD ANY SHORTHAND HERE UNLESS IT ISN'T ALWAYS EXPANDED AT PARSE TIME (which is wrong).
608 if (id == CSSPropertyFont)
611 return shorthandForProperty(id).length();
614 static Vector<StylePropertyShorthand> makeVector(const StylePropertyShorthand& a)
616 return Vector<StylePropertyShorthand>(1, a);
619 static Vector<StylePropertyShorthand> makeVector(const StylePropertyShorthand& a, const StylePropertyShorthand& b)
621 Vector<StylePropertyShorthand> vector;
622 vector.reserveInitialCapacity(2);
623 vector.uncheckedAppend(a);
624 vector.uncheckedAppend(b);
628 static Vector<StylePropertyShorthand> makeVector(const StylePropertyShorthand& a, const StylePropertyShorthand& b, const StylePropertyShorthand& c)
630 Vector<StylePropertyShorthand> vector;
631 vector.reserveInitialCapacity(3);
632 vector.uncheckedAppend(a);
633 vector.uncheckedAppend(b);
634 vector.uncheckedAppend(c);
638 Vector<StylePropertyShorthand> matchingShorthandsForLonghand(CSSPropertyID propertyID)
640 switch (propertyID) {
641 case CSSPropertyBackgroundImage:
642 case CSSPropertyBackgroundSize:
643 case CSSPropertyBackgroundAttachment:
644 case CSSPropertyBackgroundOrigin:
645 case CSSPropertyBackgroundClip:
646 case CSSPropertyBackgroundColor:
647 return makeVector(backgroundShorthand());
648 case CSSPropertyBackgroundPositionX:
649 case CSSPropertyBackgroundPositionY:
650 return makeVector(backgroundShorthand(), backgroundPositionShorthand());
651 case CSSPropertyBackgroundRepeatX:
652 case CSSPropertyBackgroundRepeatY:
653 return makeVector(backgroundShorthand(), backgroundRepeatShorthand());
654 case CSSPropertyBorderBottomWidth:
655 return makeVector(borderShorthand(), borderBottomShorthand(), borderWidthShorthand());
656 case CSSPropertyBorderTopColor:
657 return makeVector(borderShorthand(), borderTopShorthand(), borderColorShorthand());
658 case CSSPropertyBorderRightColor:
659 return makeVector(borderShorthand(), borderRightShorthand(), borderColorShorthand());
660 case CSSPropertyBorderLeftColor:
661 return makeVector(borderShorthand(), borderLeftShorthand(), borderColorShorthand());
662 case CSSPropertyBorderBottomColor:
663 return makeVector(borderShorthand(), borderBottomShorthand(), borderColorShorthand());
664 case CSSPropertyBorderImageSource:
665 case CSSPropertyBorderImageSlice:
666 case CSSPropertyBorderImageWidth:
667 case CSSPropertyBorderImageOutset:
668 case CSSPropertyBorderImageRepeat:
669 return makeVector(borderImageShorthand());
670 case CSSPropertyBorderLeftWidth:
671 return makeVector(borderShorthand(), borderLeftShorthand(), borderWidthShorthand());
672 case CSSPropertyBorderTopLeftRadius:
673 case CSSPropertyBorderTopRightRadius:
674 case CSSPropertyBorderBottomRightRadius:
675 case CSSPropertyBorderBottomLeftRadius:
676 return makeVector(borderRadiusShorthand(), webkitBorderRadiusShorthand());
677 case CSSPropertyBorderRightWidth:
678 return makeVector(borderShorthand(), borderRightShorthand(), borderWidthShorthand());
679 case CSSPropertyWebkitBorderHorizontalSpacing:
680 case CSSPropertyWebkitBorderVerticalSpacing:
681 return makeVector(borderSpacingShorthand());
682 case CSSPropertyBorderTopStyle:
683 return makeVector(borderShorthand(), borderTopShorthand(), borderStyleShorthand());
684 case CSSPropertyBorderBottomStyle:
685 return makeVector(borderShorthand(), borderBottomShorthand(), borderStyleShorthand());
686 case CSSPropertyBorderLeftStyle:
687 return makeVector(borderShorthand(), borderLeftShorthand(), borderStyleShorthand());
688 case CSSPropertyBorderRightStyle:
689 return makeVector(borderShorthand(), borderRightShorthand(), borderStyleShorthand());
690 case CSSPropertyBorderTopWidth:
691 return makeVector(borderShorthand(), borderTopShorthand(), borderWidthShorthand());
692 case CSSPropertyListStyleType:
693 case CSSPropertyListStylePosition:
694 case CSSPropertyListStyleImage:
695 return makeVector(listStyleShorthand());
696 case CSSPropertyFontFamily:
697 case CSSPropertyFontSize:
698 case CSSPropertyFontStyle:
699 case CSSPropertyFontVariant:
700 case CSSPropertyFontWeight:
701 case CSSPropertyLineHeight:
702 return makeVector(fontShorthand());
703 case CSSPropertyMarginTop:
704 case CSSPropertyMarginRight:
705 case CSSPropertyMarginBottom:
706 case CSSPropertyMarginLeft:
707 return makeVector(marginShorthand());
708 case CSSPropertyOutlineColor:
709 case CSSPropertyOutlineStyle:
710 case CSSPropertyOutlineWidth:
711 return makeVector(outlineShorthand());
712 case CSSPropertyPaddingTop:
713 case CSSPropertyPaddingRight:
714 case CSSPropertyPaddingBottom:
715 case CSSPropertyPaddingLeft:
716 return makeVector(paddingShorthand());
717 case CSSPropertyOverflowX:
718 case CSSPropertyOverflowY:
719 return makeVector(overflowShorthand());
720 case CSSPropertyTransitionProperty:
721 case CSSPropertyTransitionDuration:
722 case CSSPropertyTransitionTimingFunction:
723 case CSSPropertyTransitionDelay:
724 return makeVector(transitionShorthand());
725 case CSSPropertyWebkitAnimationName:
726 case CSSPropertyWebkitAnimationDuration:
727 case CSSPropertyWebkitAnimationTimingFunction:
728 case CSSPropertyWebkitAnimationDelay:
729 case CSSPropertyWebkitAnimationIterationCount:
730 case CSSPropertyWebkitAnimationDirection:
731 case CSSPropertyWebkitAnimationFillMode:
732 return makeVector(webkitAnimationShorthand());
733 case CSSPropertyWebkitBorderAfterWidth:
734 case CSSPropertyWebkitBorderAfterStyle:
735 case CSSPropertyWebkitBorderAfterColor:
736 return makeVector(webkitBorderAfterShorthand());
737 case CSSPropertyWebkitBorderBeforeWidth:
738 case CSSPropertyWebkitBorderBeforeStyle:
739 case CSSPropertyWebkitBorderBeforeColor:
740 return makeVector(webkitBorderBeforeShorthand());
741 case CSSPropertyWebkitBorderEndWidth:
742 case CSSPropertyWebkitBorderEndStyle:
743 case CSSPropertyWebkitBorderEndColor:
744 return makeVector(webkitBorderEndShorthand());
745 case CSSPropertyWebkitBorderStartWidth:
746 case CSSPropertyWebkitBorderStartStyle:
747 case CSSPropertyWebkitBorderStartColor:
748 return makeVector(webkitBorderStartShorthand());
749 case CSSPropertyWebkitColumnWidth:
750 case CSSPropertyWebkitColumnCount:
751 return makeVector(webkitColumnsShorthand());
752 case CSSPropertyWebkitColumnRuleWidth:
753 case CSSPropertyWebkitColumnRuleStyle:
754 case CSSPropertyWebkitColumnRuleColor:
755 return makeVector(webkitColumnRuleShorthand());
756 case CSSPropertyWebkitFlexGrow:
757 case CSSPropertyWebkitFlexShrink:
758 case CSSPropertyWebkitFlexBasis:
759 return makeVector(webkitFlexShorthand());
760 case CSSPropertyWebkitFlexDirection:
761 case CSSPropertyWebkitFlexWrap:
762 return makeVector(webkitFlexFlowShorthand());
763 #if ENABLE(CSS_GRID_LAYOUT)
764 case CSSPropertyWebkitGridColumnStart:
765 case CSSPropertyWebkitGridColumnEnd:
766 return makeVector(webkitGridColumnShorthand());
767 case CSSPropertyWebkitGridRowStart:
768 case CSSPropertyWebkitGridRowEnd:
769 return makeVector(webkitGridRowShorthand());
771 case CSSPropertyWebkitMarginBeforeCollapse:
772 case CSSPropertyWebkitMarginAfterCollapse:
773 return makeVector(webkitMarginCollapseShorthand());
774 case CSSPropertyWebkitMarqueeDirection:
775 case CSSPropertyWebkitMarqueeIncrement:
776 case CSSPropertyWebkitMarqueeRepetition:
777 case CSSPropertyWebkitMarqueeStyle:
778 case CSSPropertyWebkitMarqueeSpeed:
779 return makeVector(webkitMarqueeShorthand());
780 case CSSPropertyWebkitMaskImage:
781 case CSSPropertyWebkitMaskSourceType:
782 case CSSPropertyWebkitMaskSize:
783 case CSSPropertyWebkitMaskOrigin:
784 case CSSPropertyWebkitMaskClip:
785 return makeVector(webkitMaskShorthand());
786 case CSSPropertyWebkitMaskPositionX:
787 case CSSPropertyWebkitMaskPositionY:
788 return makeVector(webkitMaskPositionShorthand());
789 case CSSPropertyWebkitMaskRepeatX:
790 case CSSPropertyWebkitMaskRepeatY:
791 return makeVector(webkitMaskRepeatShorthand());
792 case CSSPropertyWebkitTextEmphasisStyle:
793 case CSSPropertyWebkitTextEmphasisColor:
794 return makeVector(webkitTextEmphasisShorthand());
795 case CSSPropertyWebkitTextStrokeWidth:
796 case CSSPropertyWebkitTextStrokeColor:
797 return makeVector(webkitTextStrokeShorthand());
798 case CSSPropertyWebkitTransitionProperty:
799 case CSSPropertyWebkitTransitionDuration:
800 case CSSPropertyWebkitTransitionTimingFunction:
801 case CSSPropertyWebkitTransitionDelay:
802 return makeVector(webkitTransitionShorthand());
803 case CSSPropertyWebkitTransformOriginX:
804 case CSSPropertyWebkitTransformOriginY:
805 case CSSPropertyWebkitTransformOriginZ:
806 return makeVector(webkitTransformOriginShorthand());
807 case CSSPropertyMinWidth:
808 case CSSPropertyMaxWidth:
809 return makeVector(widthShorthand());
810 case CSSPropertyMinHeight:
811 case CSSPropertyMaxHeight:
812 return makeVector(heightShorthand());
813 case CSSPropertyWebkitTextDecorationLine:
814 case CSSPropertyWebkitTextDecorationStyle:
815 case CSSPropertyWebkitTextDecorationColor:
816 return makeVector(webkitTextDecorationShorthand());
817 case CSSPropertyMarkerStart:
818 case CSSPropertyMarkerMid:
819 case CSSPropertyMarkerEnd:
820 return makeVector(markerShorthand());
825 return Vector<StylePropertyShorthand>();
828 unsigned indexOfShorthandForLonghand(CSSPropertyID shorthandID, const Vector<StylePropertyShorthand>& shorthands)
830 for (unsigned i = 0, size = shorthands.size(); i < size; ++i) {
831 if (shorthands[i].id() == shorthandID)
834 ASSERT_NOT_REACHED();
838 } // namespace WebCore