Chromium Code Reviews| Index: Source/core/css/resolver/StyleResolver.cpp |
| diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp |
| index e5c0b78ff21de5f3fc88c352454bc68da19c30da..e287b36b1fbb6bc09505ca0ecd20329c117547e7 100644 |
| --- a/Source/core/css/resolver/StyleResolver.cpp |
| +++ b/Source/core/css/resolver/StyleResolver.cpp |
| @@ -51,6 +51,7 @@ |
| #include "core/css/CSSSelector.h" |
| #include "core/css/CSSStyleRule.h" |
| #include "core/css/CSSValueList.h" |
| +#include "core/css/CSSValuePool.h" |
| #include "core/css/ElementRuleCollector.h" |
| #include "core/css/FontFace.h" |
| #include "core/css/MediaQueryEvaluator.h" |
| @@ -1231,27 +1232,81 @@ static inline bool isValidFirstLetterStyleProperty(CSSPropertyID id) |
| } |
| } |
| +template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::AnimationProperties>() |
| +{ |
| + COMPILE_ASSERT(firstCSSProperty == CSSPropertyDisplay, CSS_first_animation_property_should_be_first_property); |
| + return CSSPropertyDisplay; |
|
esprehn
2014/06/12 00:36:45
These all need comments.
|
| +} |
| + |
| +template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::AnimationProperties>() |
| +{ |
| + return CSSPropertyTransitionTimingFunction; |
| +} |
| + |
| +template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::HighPriorityProperties>() |
| +{ |
| + COMPILE_ASSERT(CSSPropertyTransitionTimingFunction + 1 == CSSPropertyColor, CSS_color_is_first_high_priority_property); |
| + return CSSPropertyColor; |
| +} |
| + |
| +template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::HighPriorityProperties>() |
| +{ |
| + COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyColor + 17, CSS_line_height_is_end_of_high_prioity_property_range); |
| + COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyLineHeight - 1, CSS_zoom_is_before_line_height); |
| + return CSSPropertyLineHeight; |
| +} |
| + |
| +template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::LowPriorityProperties>() |
| +{ |
| + COMPILE_ASSERT(CSSPropertyBackground == CSSPropertyLineHeight + 1, CSS_background_is_first_low_priority_property); |
| + return CSSPropertyBackground; |
| +} |
| + |
| +template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::LowPriorityProperties>() |
| +{ |
| + return static_cast<CSSPropertyID>(lastCSSProperty); |
|
esprehn
2014/06/12 00:36:45
Can you comment this?
|
| +} |
| + |
| template <StyleResolver::StyleApplicationPass pass> |
| bool StyleResolver::isPropertyForPass(CSSPropertyID property) |
| { |
| - const CSSPropertyID firstAnimationProperty = CSSPropertyDisplay; |
| - const CSSPropertyID lastAnimationProperty = CSSPropertyTransitionTimingFunction; |
| - COMPILE_ASSERT(firstCSSProperty == firstAnimationProperty, CSS_first_animation_property_should_be_first_property); |
| - const CSSPropertyID firstHighPriorityProperty = CSSPropertyColor; |
| - const CSSPropertyID lastHighPriorityProperty = CSSPropertyLineHeight; |
| - COMPILE_ASSERT(lastAnimationProperty + 1 == firstHighPriorityProperty, CSS_color_is_first_high_priority_property); |
| - COMPILE_ASSERT(CSSPropertyLineHeight == firstHighPriorityProperty + 17, CSS_line_height_is_end_of_high_prioity_property_range); |
| - COMPILE_ASSERT(CSSPropertyZoom == lastHighPriorityProperty - 1, CSS_zoom_is_before_line_height); |
| - switch (pass) { |
| - case AnimationProperties: |
| - return property >= firstAnimationProperty && property <= lastAnimationProperty; |
| - case HighPriorityProperties: |
| - return property >= firstHighPriorityProperty && property <= lastHighPriorityProperty; |
| - case LowPriorityProperties: |
| - return property > lastHighPriorityProperty; |
| + return firstCSSPropertyId<pass>() <= property && property <= lastCSSPropertyId<pass>(); |
| +} |
| + |
| +template <StyleResolver::StyleApplicationPass pass> |
| +void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allValue) |
|
esprehn
2014/06/12 00:36:45
Your patch description needs to explain what this
|
| +{ |
| + bool isUnsetValue = !allValue->isInitialValue() && !allValue->isInheritedValue(); |
| + unsigned startCSSProperty = firstCSSPropertyId<pass>(); |
| + unsigned endCSSProperty = lastCSSPropertyId<pass>(); |
| + |
| + for (unsigned i = startCSSProperty; i <= endCSSProperty; ++i) { |
| + CSSPropertyID propertyId = static_cast<CSSPropertyID>(i); |
| + |
| + // StyleBuilder does not allow any expanded shorthands. |
| + if (isExpandedShorthandForAll(propertyId)) |
| + continue; |
| + |
| + // all shorthand spec says: |
| + // The all property is a shorthand that resets all CSS properties |
| + // except direction and unicode-bidi. |
| + // c.f. http://dev.w3.org/csswg/css-cascade/#all-shorthand |
| + // We skip applyProperty when a given property is unicode-bidi or |
| + // direction. |
| + if (!CSSProperty::isAffectedByAllProperty(propertyId)) |
| + continue; |
| + |
| + CSSValue* value; |
| + if (!isUnsetValue) { |
| + value = allValue; |
| + } else { |
| + if (CSSProperty::isInheritedProperty(propertyId)) |
| + value = cssValuePool().createInheritedValue().get(); |
| + else |
| + value = cssValuePool().createExplicitInitialValue().get(); |
| + } |
| + StyleBuilder::applyProperty(propertyId, state, value); |
| } |
| - ASSERT_NOT_REACHED(); |
| - return false; |
| } |
| template <StyleResolver::StyleApplicationPass pass> |
| @@ -1264,6 +1319,13 @@ void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper |
| StylePropertySet::PropertyReference current = properties->propertyAt(i); |
| if (isImportant != current.isImportant()) |
| continue; |
| + |
| + CSSPropertyID property = current.id(); |
| + if (property == CSSPropertyAll) { |
| + applyAllProperty<pass>(state, current.value()); |
| + continue; |
| + } |
| + |
| if (inheritedOnly && !current.isInherited()) { |
| // If the property value is explicitly inherited, we need to apply further non-inherited properties |
| // as they might override the value inherited here. For this reason we don't allow declarations with |
| @@ -1271,7 +1333,6 @@ void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper |
| ASSERT(!current.value()->isInheritedValue()); |
| continue; |
| } |
| - CSSPropertyID property = current.id(); |
| if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStyleProperty(property)) |
| continue; |