Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 4 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 static const CSSPropertyID borderShorthandProperties[] = { CSSPropertyBorder Width, CSSPropertyBorderStyle, CSSPropertyBorderColor }; | 29 static const CSSPropertyID borderShorthandProperties[] = { CSSPropertyBorder Width, CSSPropertyBorderStyle, CSSPropertyBorderColor }; |
| 30 static const StylePropertyShorthand* propertiesForInitialization[] = { | 30 static const StylePropertyShorthand* propertiesForInitialization[] = { |
| 31 &borderWidthShorthand(), | 31 &borderWidthShorthand(), |
| 32 &borderStyleShorthand(), | 32 &borderStyleShorthand(), |
| 33 &borderColorShorthand(), | 33 &borderColorShorthand(), |
| 34 }; | 34 }; |
| 35 DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderForParsingLonghands, (CSSP ropertyBorder, borderShorthandProperties, propertiesForInitialization, WTF_ARRAY _LENGTH(borderShorthandProperties))); | 35 DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderForParsingLonghands, (CSSP ropertyBorder, borderShorthandProperties, propertiesForInitialization, WTF_ARRAY _LENGTH(borderShorthandProperties))); |
| 36 return borderForParsingLonghands; | 36 return borderForParsingLonghands; |
| 37 } | 37 } |
| 38 | 38 |
| 39 const StylePropertyShorthand& animationShorthandForParsing() | |
| 40 { | |
| 41 // When we parse the animation shorthand we need to look for animation-name | |
| 42 // last because otherwise it might match against the keywords for fill mode, | |
| 43 // timing functions and infinite iteration. This means that animation names | |
| 44 // that are the same as keywords (e.g. 'forwards') won't always match in the | |
| 45 // shorthand. In that case the authors should be using longhands (or | |
| 46 // reconsidering their approach). This is covered by the animations spec | |
| 47 // bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=14790 | |
| 48 // And in the spec (editor's draft) at: | |
| 49 // http://dev.w3.org/csswg/css3-animations/#animation-shorthand-property | |
| 50 static const CSSPropertyID animationPropertiesForParsing[] = { | |
| 51 CSSPropertyAnimationDuration, | |
| 52 CSSPropertyAnimationTimingFunction, | |
| 53 CSSPropertyAnimationDelay, | |
| 54 CSSPropertyAnimationIterationCount, | |
| 55 CSSPropertyAnimationDirection, | |
| 56 CSSPropertyAnimationFillMode, | |
| 57 CSSPropertyAnimationName | |
| 58 }; | |
| 59 DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitAnimationLonghandsForParsi ng, (CSSPropertyAnimation, animationPropertiesForParsing, WTF_ARRAY_LENGTH(anima tionPropertiesForParsing))); | |
| 60 return webkitAnimationLonghandsForParsing; | |
| 61 } | |
| 62 | |
| 39 const StylePropertyShorthand& webkitAnimationShorthandForParsing() | 63 const StylePropertyShorthand& webkitAnimationShorthandForParsing() |
| 40 { | 64 { |
| 41 // When we parse the animation shorthand we need to look for animation-name | 65 // When we parse the animation shorthand we need to look for animation-name |
| 42 // last because otherwise it might match against the keywords for fill mode, | 66 // last because otherwise it might match against the keywords for fill mode, |
| 43 // timing functions and infinite iteration. This means that animation names | 67 // timing functions and infinite iteration. This means that animation names |
| 44 // that are the same as keywords (e.g. 'forwards') won't always match in the | 68 // that are the same as keywords (e.g. 'forwards') won't always match in the |
| 45 // shorthand. In that case the authors should be using longhands (or | 69 // shorthand. In that case the authors should be using longhands (or |
| 46 // reconsidering their approach). This is covered by the animations spec | 70 // reconsidering their approach). This is covered by the animations spec |
| 47 // bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=14790 | 71 // bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=14790 |
| 48 // And in the spec (editor's draft) at: | 72 // And in the spec (editor's draft) at: |
| 49 // http://dev.w3.org/csswg/css3-animations/#animation-shorthand-property | 73 // http://dev.w3.org/csswg/css3-animations/#animation-shorthand-property |
| 50 static const CSSPropertyID animationPropertiesForParsing[] = { | 74 static const CSSPropertyID animationPropertiesForParsing[] = { |
| 51 CSSPropertyWebkitAnimationDuration, | 75 CSSPropertyWebkitAnimationDuration, |
| 52 CSSPropertyWebkitAnimationTimingFunction, | 76 CSSPropertyWebkitAnimationTimingFunction, |
| 53 CSSPropertyWebkitAnimationDelay, | 77 CSSPropertyWebkitAnimationDelay, |
| 54 CSSPropertyWebkitAnimationIterationCount, | 78 CSSPropertyWebkitAnimationIterationCount, |
| 55 CSSPropertyWebkitAnimationDirection, | 79 CSSPropertyWebkitAnimationDirection, |
| 56 CSSPropertyWebkitAnimationFillMode, | 80 CSSPropertyWebkitAnimationFillMode, |
| 57 CSSPropertyWebkitAnimationName | 81 CSSPropertyWebkitAnimationName |
| 58 }; | 82 }; |
| 59 DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitAnimationLonghandsForParsi ng, (CSSPropertyWebkitAnimation, animationPropertiesForParsing, WTF_ARRAY_LENGTH (animationPropertiesForParsing))); | 83 DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitAnimationLonghandsForParsi ng, (CSSPropertyWebkitAnimation, animationPropertiesForParsing, WTF_ARRAY_LENGTH (animationPropertiesForParsing))); |
| 60 return webkitAnimationLonghandsForParsing; | 84 return webkitAnimationLonghandsForParsing; |
| 61 } | 85 } |
| 62 | 86 |
| 87 // Returns an empty list if the property is not a shorthand, otherwise the list of longhands for parsing. | |
| 88 const StylePropertyShorthand& parsingShorthandForProperty(CSSPropertyID property ID) | |
|
eseidel
2013/08/13 17:49:15
I'm confused by this new wrapper around shorthandF
darktears
2013/08/13 18:08:54
No. When we parse the shorthand properties we star
| |
| 89 { | |
| 90 switch (propertyID) { | |
| 91 case CSSPropertyAnimation: | |
| 92 return animationShorthandForParsing(); | |
| 93 case CSSPropertyBorder: | |
| 94 return borderShorthandForParsing(); | |
| 95 case CSSPropertyWebkitAnimation: | |
| 96 return webkitAnimationShorthandForParsing(); | |
| 97 default: | |
| 98 return shorthandForProperty(propertyID); | |
| 99 } | |
| 100 } | |
| 101 | |
| 63 bool isExpandedShorthand(CSSPropertyID id) | 102 bool isExpandedShorthand(CSSPropertyID id) |
| 64 { | 103 { |
| 65 // The system fonts bypass the normal style resolution by using RenderTheme, | 104 // The system fonts bypass the normal style resolution by using RenderTheme, |
| 66 // thus we need to special case it here. FIXME: This is a violation of CSS 3 Fonts | 105 // thus we need to special case it here. FIXME: This is a violation of CSS 3 Fonts |
| 67 // as we should still be able to change the longhands. | 106 // as we should still be able to change the longhands. |
| 68 // DON'T ADD ANY SHORTHAND HERE UNLESS IT ISN'T ALWAYS EXPANDED AT PARSE TIM E (which is wrong). | 107 // DON'T ADD ANY SHORTHAND HERE UNLESS IT ISN'T ALWAYS EXPANDED AT PARSE TIM E (which is wrong). |
| 69 if (id == CSSPropertyFont) | 108 if (id == CSSPropertyFont) |
| 70 return false; | 109 return false; |
| 71 | 110 |
| 72 return shorthandForProperty(id).length(); | 111 return shorthandForProperty(id).length(); |
| 73 } | 112 } |
| 74 | 113 |
| 75 unsigned indexOfShorthandForLonghand(CSSPropertyID shorthandID, const Vector<Sty lePropertyShorthand>& shorthands) | 114 unsigned indexOfShorthandForLonghand(CSSPropertyID shorthandID, const Vector<Sty lePropertyShorthand>& shorthands) |
| 76 { | 115 { |
| 77 for (unsigned i = 0; i < shorthands.size(); ++i) { | 116 for (unsigned i = 0; i < shorthands.size(); ++i) { |
| 78 if (shorthands.at(i).id() == shorthandID) | 117 if (shorthands.at(i).id() == shorthandID) |
| 79 return i; | 118 return i; |
| 80 } | 119 } |
| 81 ASSERT_NOT_REACHED(); | 120 ASSERT_NOT_REACHED(); |
| 82 return 0; | 121 return 0; |
| 83 } | 122 } |
| 84 | 123 |
| 85 } // namespace WebCore | 124 } // namespace WebCore |
| OLD | NEW |