From: akling@apple.com Date: Wed, 4 Dec 2013 05:33:24 +0000 (+0000) Subject: Add a CSSProperty::isDirectionAwareProperty() helper. X-Git-Url: https://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=a83ab8cb2b7edcf4ddcd5af58d478948681f4101 Add a CSSProperty::isDirectionAwareProperty() helper. Move the block of case labels for checking whether a CSS property ID is a directional property into a separate function. Also removed an outdated comment about CSS variables. Reviewed by Antti Koivisto. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160070 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index cb730bee8708..a9de6fb800dc 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,14 @@ +2013-12-03 Andreas Kling + + Add a CSSProperty::isDirectionAwareProperty() helper. + + + Move the block of case labels for checking whether a CSS property ID + is a directional property into a separate function. Also removed an + outdated comment about CSS variables. + + Reviewed by Antti Koivisto. + 2013-12-03 Ryosuke Niwa Revert the inadvertently committed change. diff --git a/Source/WebCore/css/CSSProperty.cpp b/Source/WebCore/css/CSSProperty.cpp index 38ddefc6b07c..0dd27c10263b 100644 --- a/Source/WebCore/css/CSSProperty.cpp +++ b/Source/WebCore/css/CSSProperty.cpp @@ -257,4 +257,39 @@ CSSPropertyID CSSProperty::resolveDirectionAwareProperty(CSSPropertyID propertyI } } +bool CSSProperty::isDirectionAwareProperty(CSSPropertyID propertyID) +{ + switch (propertyID) { + case CSSPropertyWebkitBorderEndColor: + case CSSPropertyWebkitBorderEndStyle: + case CSSPropertyWebkitBorderEndWidth: + case CSSPropertyWebkitBorderStartColor: + case CSSPropertyWebkitBorderStartStyle: + case CSSPropertyWebkitBorderStartWidth: + case CSSPropertyWebkitBorderBeforeColor: + case CSSPropertyWebkitBorderBeforeStyle: + case CSSPropertyWebkitBorderBeforeWidth: + case CSSPropertyWebkitBorderAfterColor: + case CSSPropertyWebkitBorderAfterStyle: + case CSSPropertyWebkitBorderAfterWidth: + case CSSPropertyWebkitMarginEnd: + case CSSPropertyWebkitMarginStart: + case CSSPropertyWebkitMarginBefore: + case CSSPropertyWebkitMarginAfter: + case CSSPropertyWebkitPaddingEnd: + case CSSPropertyWebkitPaddingStart: + case CSSPropertyWebkitPaddingBefore: + case CSSPropertyWebkitPaddingAfter: + case CSSPropertyWebkitLogicalWidth: + case CSSPropertyWebkitLogicalHeight: + case CSSPropertyWebkitMinLogicalWidth: + case CSSPropertyWebkitMinLogicalHeight: + case CSSPropertyWebkitMaxLogicalWidth: + case CSSPropertyWebkitMaxLogicalHeight: + return true; + default: + return false; + } +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSProperty.h b/Source/WebCore/css/CSSProperty.h index 061e87038684..f5f1a6a05ebb 100644 --- a/Source/WebCore/css/CSSProperty.h +++ b/Source/WebCore/css/CSSProperty.h @@ -79,6 +79,7 @@ public: static CSSPropertyID resolveDirectionAwareProperty(CSSPropertyID, TextDirection, WritingMode); static bool isInheritedProperty(CSSPropertyID); + static bool isDirectionAwareProperty(CSSPropertyID); const StylePropertyMetadata& metadata() const { return m_metadata; } diff --git a/Source/WebCore/css/StyleResolver.cpp b/Source/WebCore/css/StyleResolver.cpp index e6031d332cc7..31257ad0d471 100644 --- a/Source/WebCore/css/StyleResolver.cpp +++ b/Source/WebCore/css/StyleResolver.cpp @@ -2027,10 +2027,16 @@ static bool createGridPosition(CSSValue* value, GridPosition& position) void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) { - // CSS variables don't resolve shorthands at parsing time, so this should be *after* handling variables. ASSERT_WITH_MESSAGE(!isExpandedShorthand(id), "Shorthand property id = %d wasn't expanded at parsing time", id); State& state = m_state; + + if (CSSProperty::isDirectionAwareProperty(id)) { + CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, state.style()->direction(), state.style()->writingMode()); + ASSERT(newId != id); + return applyProperty(newId, value); + } + bool isInherit = state.parentNode() && value->isInheritedValue(); bool isInitial = value->isInitialValue() || (!state.parentNode() && value->isInheritedValue()); @@ -2557,38 +2563,6 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) #endif case CSSPropertyInvalid: return; - // Directional properties are resolved by resolveDirectionAwareProperty() before the switch. - case CSSPropertyWebkitBorderEndColor: - case CSSPropertyWebkitBorderEndStyle: - case CSSPropertyWebkitBorderEndWidth: - case CSSPropertyWebkitBorderStartColor: - case CSSPropertyWebkitBorderStartStyle: - case CSSPropertyWebkitBorderStartWidth: - case CSSPropertyWebkitBorderBeforeColor: - case CSSPropertyWebkitBorderBeforeStyle: - case CSSPropertyWebkitBorderBeforeWidth: - case CSSPropertyWebkitBorderAfterColor: - case CSSPropertyWebkitBorderAfterStyle: - case CSSPropertyWebkitBorderAfterWidth: - case CSSPropertyWebkitMarginEnd: - case CSSPropertyWebkitMarginStart: - case CSSPropertyWebkitMarginBefore: - case CSSPropertyWebkitMarginAfter: - case CSSPropertyWebkitPaddingEnd: - case CSSPropertyWebkitPaddingStart: - case CSSPropertyWebkitPaddingBefore: - case CSSPropertyWebkitPaddingAfter: - case CSSPropertyWebkitLogicalWidth: - case CSSPropertyWebkitLogicalHeight: - case CSSPropertyWebkitMinLogicalWidth: - case CSSPropertyWebkitMinLogicalHeight: - case CSSPropertyWebkitMaxLogicalWidth: - case CSSPropertyWebkitMaxLogicalHeight: - { - CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, state.style()->direction(), state.style()->writingMode()); - ASSERT(newId != id); - return applyProperty(newId, value); - } case CSSPropertyFontStretch: case CSSPropertyPage: case CSSPropertyTextLineThrough: