1/*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB.  If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#include "config.h"
22#include "StylePropertyShorthand.h"
23
24#include <wtf/StdLibExtras.h>
25
26namespace WebCore {
27
28const StylePropertyShorthand& backgroundShorthand()
29{
30    static const CSSPropertyID backgroundProperties[] = {
31        CSSPropertyBackgroundImage,
32        CSSPropertyBackgroundPositionX,
33        CSSPropertyBackgroundPositionY,
34        CSSPropertyBackgroundSize,
35        CSSPropertyBackgroundRepeatX,
36        CSSPropertyBackgroundRepeatY,
37        CSSPropertyBackgroundAttachment,
38        CSSPropertyBackgroundOrigin,
39        CSSPropertyBackgroundClip,
40        CSSPropertyBackgroundColor
41    };
42    DEFINE_STATIC_LOCAL(StylePropertyShorthand, backgroundShorthand, (backgroundProperties, WTF_ARRAY_LENGTH(backgroundProperties)));
43    return backgroundShorthand;
44}
45
46const StylePropertyShorthand& backgroundPositionShorthand()
47{
48    static const CSSPropertyID backgroundPositionProperties[] = { CSSPropertyBackgroundPositionX, CSSPropertyBackgroundPositionY };
49    DEFINE_STATIC_LOCAL(StylePropertyShorthand, backgroundPositionLonghands, (backgroundPositionProperties, WTF_ARRAY_LENGTH(backgroundPositionProperties)));
50    return backgroundPositionLonghands;
51}
52
53const StylePropertyShorthand& backgroundRepeatShorthand()
54{
55    static const CSSPropertyID backgroundRepeatProperties[] = { CSSPropertyBackgroundRepeatX, CSSPropertyBackgroundRepeatY };
56    DEFINE_STATIC_LOCAL(StylePropertyShorthand, backgroundRepeatLonghands, (backgroundRepeatProperties, WTF_ARRAY_LENGTH(backgroundRepeatProperties)));
57    return backgroundRepeatLonghands;
58}
59
60const StylePropertyShorthand& borderShorthand()
61{
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 }
68    };
69    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderLonghands, (borderProperties[0], sizeof(borderProperties) / sizeof(borderProperties[0][0])));
70    return borderLonghands;
71}
72
73const StylePropertyShorthand& borderAbridgedShorthand()
74{
75    static const CSSPropertyID borderAbridgedProperties[] = { CSSPropertyBorderWidth, CSSPropertyBorderStyle, CSSPropertyBorderColor };
76    static const StylePropertyShorthand* propertiesForInitialization[] = {
77        &borderWidthShorthand(),
78        &borderStyleShorthand(),
79        &borderColorShorthand(),
80    };
81    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderAbridgedLonghands,
82        (borderAbridgedProperties, propertiesForInitialization, WTF_ARRAY_LENGTH(borderAbridgedProperties)));
83    return borderAbridgedLonghands;
84}
85
86const StylePropertyShorthand& borderBottomShorthand()
87{
88    static const CSSPropertyID borderBottomProperties[] = { CSSPropertyBorderBottomWidth, CSSPropertyBorderBottomStyle, CSSPropertyBorderBottomColor };
89    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderBottomLonghands, (borderBottomProperties, WTF_ARRAY_LENGTH(borderBottomProperties)));
90    return borderBottomLonghands;
91}
92
93const StylePropertyShorthand& borderColorShorthand()
94{
95    static const CSSPropertyID borderColorProperties[] = {
96        CSSPropertyBorderTopColor,
97        CSSPropertyBorderRightColor,
98        CSSPropertyBorderBottomColor,
99        CSSPropertyBorderLeftColor
100    };
101    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderColorLonghands, (borderColorProperties, WTF_ARRAY_LENGTH(borderColorProperties)));
102    return borderColorLonghands;
103}
104
105const StylePropertyShorthand& borderImageShorthand()
106{
107    static const CSSPropertyID borderImageProperties[] = {
108        CSSPropertyBorderImageSource,
109        CSSPropertyBorderImageSlice,
110        CSSPropertyBorderImageWidth,
111        CSSPropertyBorderImageOutset,
112        CSSPropertyBorderImageRepeat
113    };
114    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderImageLonghands, (borderImageProperties, WTF_ARRAY_LENGTH(borderImageProperties)));
115    return borderImageLonghands;
116}
117
118const StylePropertyShorthand& borderLeftShorthand()
119{
120    static const CSSPropertyID borderLeftProperties[] = { CSSPropertyBorderLeftWidth, CSSPropertyBorderLeftStyle, CSSPropertyBorderLeftColor };
121    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderLeftLonghands, (borderLeftProperties, WTF_ARRAY_LENGTH(borderLeftProperties)));
122    return borderLeftLonghands;
123}
124
125const StylePropertyShorthand& borderRadiusShorthand()
126{
127    static const CSSPropertyID borderRadiusProperties[] = {
128        CSSPropertyBorderTopLeftRadius,
129        CSSPropertyBorderTopRightRadius,
130        CSSPropertyBorderBottomRightRadius,
131        CSSPropertyBorderBottomLeftRadius
132    };
133    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderRadiusLonghands, (borderRadiusProperties, WTF_ARRAY_LENGTH(borderRadiusProperties)));
134    return borderRadiusLonghands;
135}
136
137const StylePropertyShorthand& borderRightShorthand()
138{
139    static const CSSPropertyID borderRightProperties[] = { CSSPropertyBorderRightWidth, CSSPropertyBorderRightStyle, CSSPropertyBorderRightColor };
140    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderRightLonghands, (borderRightProperties, WTF_ARRAY_LENGTH(borderRightProperties)));
141    return borderRightLonghands;
142}
143
144const StylePropertyShorthand& borderSpacingShorthand()
145{
146    static const CSSPropertyID borderSpacingProperties[] = { CSSPropertyWebkitBorderHorizontalSpacing, CSSPropertyWebkitBorderVerticalSpacing };
147    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderSpacingLonghands, (borderSpacingProperties, WTF_ARRAY_LENGTH(borderSpacingProperties)));
148    return borderSpacingLonghands;
149}
150
151const StylePropertyShorthand& borderStyleShorthand()
152{
153    static const CSSPropertyID borderStyleProperties[] = {
154        CSSPropertyBorderTopStyle,
155        CSSPropertyBorderRightStyle,
156        CSSPropertyBorderBottomStyle,
157        CSSPropertyBorderLeftStyle
158    };
159    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderStyleLonghands, (borderStyleProperties, WTF_ARRAY_LENGTH(borderStyleProperties)));
160    return borderStyleLonghands;
161}
162
163const StylePropertyShorthand& borderTopShorthand()
164{
165    static const CSSPropertyID borderTopProperties[] = { CSSPropertyBorderTopWidth, CSSPropertyBorderTopStyle, CSSPropertyBorderTopColor };
166    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderTopLonghands, (borderTopProperties, WTF_ARRAY_LENGTH(borderTopProperties)));
167    return borderTopLonghands;
168}
169
170const StylePropertyShorthand& borderWidthShorthand()
171{
172    static const CSSPropertyID borderWidthProperties[] = {
173        CSSPropertyBorderTopWidth,
174        CSSPropertyBorderRightWidth,
175        CSSPropertyBorderBottomWidth,
176        CSSPropertyBorderLeftWidth
177    };
178    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderWidthLonghands, (borderWidthProperties, WTF_ARRAY_LENGTH(borderWidthProperties)));
179    return borderWidthLonghands;
180}
181
182const StylePropertyShorthand& listStyleShorthand()
183{
184    static const CSSPropertyID listStyleProperties[] = {
185        CSSPropertyListStyleType,
186        CSSPropertyListStylePosition,
187        CSSPropertyListStyleImage
188    };
189    DEFINE_STATIC_LOCAL(StylePropertyShorthand, listStyleLonghands, (listStyleProperties, WTF_ARRAY_LENGTH(listStyleProperties)));
190    return listStyleLonghands;
191}
192
193const StylePropertyShorthand& fontShorthand()
194{
195    static const CSSPropertyID fontProperties[] = {
196        CSSPropertyFontFamily,
197        CSSPropertyFontSize,
198        CSSPropertyFontStyle,
199        CSSPropertyFontVariant,
200        CSSPropertyFontWeight,
201        CSSPropertyLineHeight
202    };
203    DEFINE_STATIC_LOCAL(StylePropertyShorthand, fontLonghands, (fontProperties, WTF_ARRAY_LENGTH(fontProperties)));
204    return fontLonghands;
205}
206
207const StylePropertyShorthand& marginShorthand()
208{
209    static const CSSPropertyID marginProperties[] = {
210        CSSPropertyMarginTop,
211        CSSPropertyMarginRight,
212        CSSPropertyMarginBottom,
213        CSSPropertyMarginLeft
214    };
215    DEFINE_STATIC_LOCAL(StylePropertyShorthand, marginLonghands, (marginProperties, WTF_ARRAY_LENGTH(marginProperties)));
216    return marginLonghands;
217}
218
219const StylePropertyShorthand& outlineShorthand()
220{
221    static const CSSPropertyID outlineProperties[] = {
222        CSSPropertyOutlineColor,
223        CSSPropertyOutlineStyle,
224        CSSPropertyOutlineWidth
225    };
226    DEFINE_STATIC_LOCAL(StylePropertyShorthand, outlineLonghands, (outlineProperties, WTF_ARRAY_LENGTH(outlineProperties)));
227    return outlineLonghands;
228}
229
230const StylePropertyShorthand& overflowShorthand()
231{
232    static const CSSPropertyID overflowProperties[] = { CSSPropertyOverflowX, CSSPropertyOverflowY };
233    DEFINE_STATIC_LOCAL(StylePropertyShorthand, overflowLonghands, (overflowProperties, WTF_ARRAY_LENGTH(overflowProperties)));
234    return overflowLonghands;
235}
236
237const StylePropertyShorthand& paddingShorthand()
238{
239    static const CSSPropertyID paddingProperties[] = {
240        CSSPropertyPaddingTop,
241        CSSPropertyPaddingRight,
242        CSSPropertyPaddingBottom,
243        CSSPropertyPaddingLeft
244    };
245    DEFINE_STATIC_LOCAL(StylePropertyShorthand, paddingLonghands, (paddingProperties, WTF_ARRAY_LENGTH(paddingProperties)));
246    return paddingLonghands;
247}
248
249const StylePropertyShorthand& transitionShorthand()
250{
251    static const CSSPropertyID transitionProperties[] = {
252        CSSPropertyTransitionProperty,
253        CSSPropertyTransitionDuration,
254        CSSPropertyTransitionTimingFunction,
255        CSSPropertyTransitionDelay
256    };
257    DEFINE_STATIC_LOCAL(StylePropertyShorthand, transitionLonghands, (transitionProperties, WTF_ARRAY_LENGTH(transitionProperties)));
258    return transitionLonghands;
259}
260
261const StylePropertyShorthand& webkitAnimationShorthand()
262{
263    static const CSSPropertyID animationProperties[] = {
264        CSSPropertyWebkitAnimationName,
265        CSSPropertyWebkitAnimationDuration,
266        CSSPropertyWebkitAnimationTimingFunction,
267        CSSPropertyWebkitAnimationDelay,
268        CSSPropertyWebkitAnimationIterationCount,
269        CSSPropertyWebkitAnimationDirection,
270        CSSPropertyWebkitAnimationFillMode
271    };
272    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitAnimationLonghands, (animationProperties, WTF_ARRAY_LENGTH(animationProperties)));
273    return webkitAnimationLonghands;
274}
275
276const StylePropertyShorthand& webkitAnimationShorthandForParsing()
277{
278    // When we parse the animation shorthand we need to look for animation-name
279    // last because otherwise it might match against the keywords for fill mode,
280    // timing functions and infinite iteration. This means that animation names
281    // that are the same as keywords (e.g. 'forwards') won't always match in the
282    // shorthand. In that case the authors should be using longhands (or
283    // reconsidering their approach). This is covered by the animations spec
284    // bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=14790
285    // And in the spec (editor's draft) at:
286    // http://dev.w3.org/csswg/css3-animations/#animation-shorthand-property
287    static const CSSPropertyID animationPropertiesForParsing[] = {
288        CSSPropertyWebkitAnimationDuration,
289        CSSPropertyWebkitAnimationTimingFunction,
290        CSSPropertyWebkitAnimationDelay,
291        CSSPropertyWebkitAnimationIterationCount,
292        CSSPropertyWebkitAnimationDirection,
293        CSSPropertyWebkitAnimationFillMode,
294        CSSPropertyWebkitAnimationName
295    };
296
297    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitAnimationLonghandsForParsing, (animationPropertiesForParsing, WTF_ARRAY_LENGTH(animationPropertiesForParsing)));
298    return webkitAnimationLonghandsForParsing;
299}
300
301const StylePropertyShorthand& webkitBorderAfterShorthand()
302{
303    static const CSSPropertyID borderAfterProperties[] = { CSSPropertyWebkitBorderAfterWidth, CSSPropertyWebkitBorderAfterStyle, CSSPropertyWebkitBorderAfterColor  };
304    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderAfterLonghands, (borderAfterProperties, WTF_ARRAY_LENGTH(borderAfterProperties)));
305    return webkitBorderAfterLonghands;
306}
307
308const StylePropertyShorthand& webkitBorderBeforeShorthand()
309{
310    static const CSSPropertyID borderBeforeProperties[] = { CSSPropertyWebkitBorderBeforeWidth, CSSPropertyWebkitBorderBeforeStyle, CSSPropertyWebkitBorderBeforeColor  };
311    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderBeforeLonghands, (borderBeforeProperties, WTF_ARRAY_LENGTH(borderBeforeProperties)));
312    return webkitBorderBeforeLonghands;
313}
314
315const StylePropertyShorthand& webkitBorderEndShorthand()
316{
317    static const CSSPropertyID borderEndProperties[] = { CSSPropertyWebkitBorderEndWidth, CSSPropertyWebkitBorderEndStyle, CSSPropertyWebkitBorderEndColor };
318    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderEndLonghands, (borderEndProperties, WTF_ARRAY_LENGTH(borderEndProperties)));
319    return webkitBorderEndLonghands;
320}
321
322const StylePropertyShorthand& webkitBorderStartShorthand()
323{
324    static const CSSPropertyID borderStartProperties[] = { CSSPropertyWebkitBorderStartWidth, CSSPropertyWebkitBorderStartStyle, CSSPropertyWebkitBorderStartColor };
325    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderStartLonghands, (borderStartProperties, WTF_ARRAY_LENGTH(borderStartProperties)));
326    return webkitBorderStartLonghands;
327}
328
329const StylePropertyShorthand& webkitColumnsShorthand()
330{
331    static const CSSPropertyID columnsProperties[] = { CSSPropertyWebkitColumnWidth, CSSPropertyWebkitColumnCount };
332    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitColumnsLonghands, (columnsProperties, WTF_ARRAY_LENGTH(columnsProperties)));
333    return webkitColumnsLonghands;
334}
335
336const StylePropertyShorthand& webkitColumnRuleShorthand()
337{
338    static const CSSPropertyID columnRuleProperties[] = {
339        CSSPropertyWebkitColumnRuleWidth,
340        CSSPropertyWebkitColumnRuleStyle,
341        CSSPropertyWebkitColumnRuleColor,
342    };
343    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitColumnRuleLonghands, (columnRuleProperties, WTF_ARRAY_LENGTH(columnRuleProperties)));
344    return webkitColumnRuleLonghands;
345}
346
347const StylePropertyShorthand& webkitFlexFlowShorthand()
348{
349    static const CSSPropertyID flexFlowProperties[] = { CSSPropertyWebkitFlexDirection, CSSPropertyWebkitFlexWrap };
350    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitFlexFlowLonghands, (flexFlowProperties, WTF_ARRAY_LENGTH(flexFlowProperties)));
351    return webkitFlexFlowLonghands;
352}
353
354const StylePropertyShorthand& webkitFlexShorthand()
355{
356    static const CSSPropertyID flexProperties[] = { CSSPropertyWebkitFlexGrow, CSSPropertyWebkitFlexShrink, CSSPropertyWebkitFlexBasis };
357    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitFlexLonghands, (flexProperties, WTF_ARRAY_LENGTH(flexProperties)));
358    return webkitFlexLonghands;
359}
360
361const StylePropertyShorthand& webkitMarginCollapseShorthand()
362{
363    static const CSSPropertyID marginCollapseProperties[] = { CSSPropertyWebkitMarginBeforeCollapse, CSSPropertyWebkitMarginAfterCollapse };
364    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMarginCollapseLonghands, (marginCollapseProperties, WTF_ARRAY_LENGTH(marginCollapseProperties)));
365    return webkitMarginCollapseLonghands;
366}
367
368const StylePropertyShorthand& webkitGridColumnShorthand()
369{
370    static const CSSPropertyID webkitGridColumnProperties[] = {
371        CSSPropertyWebkitGridStart,
372        CSSPropertyWebkitGridEnd
373    };
374    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitGridColumnLonghands, (webkitGridColumnProperties, WTF_ARRAY_LENGTH(webkitGridColumnProperties)));
375    return webkitGridColumnLonghands;
376
377}
378
379const StylePropertyShorthand& webkitGridRowShorthand()
380{
381    static const CSSPropertyID webkitGridRowProperties[] = {
382        CSSPropertyWebkitGridBefore,
383        CSSPropertyWebkitGridAfter
384    };
385    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitGridRowLonghands, (webkitGridRowProperties, WTF_ARRAY_LENGTH(webkitGridRowProperties)));
386    return webkitGridRowLonghands;
387
388}
389
390const StylePropertyShorthand& webkitMarqueeShorthand()
391{
392    static const CSSPropertyID marqueeProperties[] = {
393        CSSPropertyWebkitMarqueeDirection,
394        CSSPropertyWebkitMarqueeIncrement,
395        CSSPropertyWebkitMarqueeRepetition,
396        CSSPropertyWebkitMarqueeStyle,
397        CSSPropertyWebkitMarqueeSpeed
398    };
399    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMarqueeLonghands, (marqueeProperties, WTF_ARRAY_LENGTH(marqueeProperties)));
400    return webkitMarqueeLonghands;
401}
402
403const StylePropertyShorthand& webkitMaskShorthand()
404{
405    static const CSSPropertyID maskProperties[] = {
406        CSSPropertyWebkitMaskImage,
407        CSSPropertyWebkitMaskPositionX,
408        CSSPropertyWebkitMaskPositionY,
409        CSSPropertyWebkitMaskSize,
410        CSSPropertyWebkitMaskRepeatX,
411        CSSPropertyWebkitMaskRepeatY,
412        CSSPropertyWebkitMaskOrigin,
413        CSSPropertyWebkitMaskClip
414    };
415    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMaskLonghands, (maskProperties, WTF_ARRAY_LENGTH(maskProperties)));
416    return webkitMaskLonghands;
417}
418
419const StylePropertyShorthand& webkitMaskPositionShorthand()
420{
421    static const CSSPropertyID maskPositionProperties[] = { CSSPropertyWebkitMaskPositionX, CSSPropertyWebkitMaskPositionY };
422    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMaskPositionLonghands, (maskPositionProperties, WTF_ARRAY_LENGTH(maskPositionProperties)));
423    return webkitMaskPositionLonghands;
424}
425
426const StylePropertyShorthand& webkitMaskRepeatShorthand()
427{
428    static const CSSPropertyID maskRepeatProperties[] = { CSSPropertyWebkitMaskRepeatX, CSSPropertyWebkitMaskRepeatY };
429    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMaskRepeatLonghands, (maskRepeatProperties, WTF_ARRAY_LENGTH(maskRepeatProperties)));
430    return webkitMaskRepeatLonghands;
431}
432
433const StylePropertyShorthand& webkitTextEmphasisShorthand()
434{
435    static const CSSPropertyID textEmphasisProperties[] = {
436        CSSPropertyWebkitTextEmphasisStyle,
437        CSSPropertyWebkitTextEmphasisColor
438    };
439    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTextEmphasisLonghands, (textEmphasisProperties, WTF_ARRAY_LENGTH(textEmphasisProperties)));
440    return webkitTextEmphasisLonghands;
441}
442
443const StylePropertyShorthand& webkitTextStrokeShorthand()
444{
445    static const CSSPropertyID textStrokeProperties[] = { CSSPropertyWebkitTextStrokeWidth, CSSPropertyWebkitTextStrokeColor };
446    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTextStrokeLonghands, (textStrokeProperties, WTF_ARRAY_LENGTH(textStrokeProperties)));
447    return webkitTextStrokeLonghands;
448}
449
450const StylePropertyShorthand& webkitTransitionShorthand()
451{
452    static const CSSPropertyID transitionProperties[] = {
453        CSSPropertyWebkitTransitionProperty,
454        CSSPropertyWebkitTransitionDuration,
455        CSSPropertyWebkitTransitionTimingFunction,
456        CSSPropertyWebkitTransitionDelay
457    };
458    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTransitionLonghands, (transitionProperties, WTF_ARRAY_LENGTH(transitionProperties)));
459    return webkitTransitionLonghands;
460}
461
462const StylePropertyShorthand& webkitTransformOriginShorthand()
463{
464    static const CSSPropertyID transformOriginProperties[] = {
465        CSSPropertyWebkitTransformOriginX,
466        CSSPropertyWebkitTransformOriginY,
467        CSSPropertyWebkitTransformOriginZ
468    };
469    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTransformOriginLonghands, (transformOriginProperties, WTF_ARRAY_LENGTH(transformOriginProperties)));
470    return webkitTransformOriginLonghands;
471}
472
473// Returns an empty list if the property is not a shorthand
474const StylePropertyShorthand& shorthandForProperty(CSSPropertyID propertyID)
475{
476    switch (propertyID) {
477    case CSSPropertyBackground:
478        return backgroundShorthand();
479    case CSSPropertyBackgroundPosition:
480        return backgroundPositionShorthand();
481    case CSSPropertyBackgroundRepeat:
482        return backgroundRepeatShorthand();
483    case CSSPropertyBorder:
484        return borderShorthand();
485    case CSSPropertyBorderBottom:
486        return borderBottomShorthand();
487    case CSSPropertyBorderColor:
488        return borderColorShorthand();
489    case CSSPropertyBorderImage:
490        return borderImageShorthand();
491    case CSSPropertyBorderLeft:
492        return borderLeftShorthand();
493    case CSSPropertyBorderRadius:
494        return borderRadiusShorthand();
495    case CSSPropertyBorderRight:
496        return borderRightShorthand();
497    case CSSPropertyBorderSpacing:
498        return borderSpacingShorthand();
499    case CSSPropertyBorderStyle:
500        return borderStyleShorthand();
501    case CSSPropertyBorderTop:
502        return borderTopShorthand();
503    case CSSPropertyBorderWidth:
504        return borderWidthShorthand();
505    case CSSPropertyListStyle:
506        return listStyleShorthand();
507    case CSSPropertyFont:
508        return fontShorthand();
509    case CSSPropertyMargin:
510        return marginShorthand();
511    case CSSPropertyOutline:
512        return outlineShorthand();
513    case CSSPropertyOverflow:
514        return overflowShorthand();
515    case CSSPropertyPadding:
516        return paddingShorthand();
517    case CSSPropertyTransition:
518        return transitionShorthand();
519    case CSSPropertyWebkitAnimation:
520        return webkitAnimationShorthand();
521    case CSSPropertyWebkitBorderAfter:
522        return webkitBorderAfterShorthand();
523    case CSSPropertyWebkitBorderBefore:
524        return webkitBorderBeforeShorthand();
525    case CSSPropertyWebkitBorderEnd:
526        return webkitBorderEndShorthand();
527    case CSSPropertyWebkitBorderStart:
528        return webkitBorderStartShorthand();
529    case CSSPropertyWebkitBorderRadius:
530        return borderRadiusShorthand();
531    case CSSPropertyWebkitColumns:
532        return webkitColumnsShorthand();
533    case CSSPropertyWebkitColumnRule:
534        return webkitColumnRuleShorthand();
535    case CSSPropertyWebkitFlex:
536        return webkitFlexShorthand();
537    case CSSPropertyWebkitFlexFlow:
538        return webkitFlexFlowShorthand();
539    case CSSPropertyWebkitGridColumn:
540        return webkitGridColumnShorthand();
541    case CSSPropertyWebkitGridRow:
542        return webkitGridRowShorthand();
543    case CSSPropertyWebkitMarginCollapse:
544        return webkitMarginCollapseShorthand();
545    case CSSPropertyWebkitMarquee:
546        return webkitMarqueeShorthand();
547    case CSSPropertyWebkitMask:
548        return webkitMaskShorthand();
549    case CSSPropertyWebkitMaskPosition:
550        return webkitMaskPositionShorthand();
551    case CSSPropertyWebkitMaskRepeat:
552        return webkitMaskRepeatShorthand();
553    case CSSPropertyWebkitTextEmphasis:
554        return webkitTextEmphasisShorthand();
555    case CSSPropertyWebkitTextStroke:
556        return webkitTextStrokeShorthand();
557    case CSSPropertyWebkitTransition:
558        return webkitTransitionShorthand();
559    case CSSPropertyWebkitTransformOrigin:
560        return webkitTransformOriginShorthand();
561    default: {
562        DEFINE_STATIC_LOCAL(StylePropertyShorthand, emptyShorthand, ());
563        return emptyShorthand;
564    }
565    }
566}
567
568bool isExpandedShorthand(CSSPropertyID id)
569{
570    // The system fonts bypass the normal style resolution by using RenderTheme,
571    // thus we need to special case it here. FIXME: This is a violation of CSS 3 Fonts
572    // as we should still be able to change the longhands.
573    // DON'T ADD ANY SHORTHAND HERE UNLESS IT ISN'T ALWAYS EXPANDED AT PARSE TIME (which is wrong).
574    if (id == CSSPropertyFont)
575        return false;
576
577    return shorthandForProperty(id).length();
578}
579
580} // namespace WebCore
581