| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
| 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| (...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 StyleResolverState& state = m_state; | 1133 StyleResolverState& state = m_state; |
| 1134 ASSERT(!state.style()); | 1134 ASSERT(!state.style()); |
| 1135 | 1135 |
| 1136 // Create the style | 1136 // Create the style |
| 1137 state.setStyle(RenderStyle::clone(elementStyle)); | 1137 state.setStyle(RenderStyle::clone(elementStyle)); |
| 1138 state.setLineHeightValue(0); | 1138 state.setLineHeightValue(0); |
| 1139 | 1139 |
| 1140 // We don't need to bother with !important. Since there is only ever one | 1140 // We don't need to bother with !important. Since there is only ever one |
| 1141 // decl, there's nothing to override. So just add the first properties. | 1141 // decl, there's nothing to override. So just add the first properties. |
| 1142 bool inheritedOnly = false; | 1142 bool inheritedOnly = false; |
| 1143 if (keyframe->properties()) | 1143 if (keyframe->properties()) { |
| 1144 // FIXME: Can't keyframes contain variables? |
| 1145 applyMatchedProperties<AnimationProperties>(result, false, 0, result.mat
chedProperties.size() - 1, inheritedOnly); |
| 1144 applyMatchedProperties<HighPriorityProperties>(result, false, 0, result.
matchedProperties.size() - 1, inheritedOnly); | 1146 applyMatchedProperties<HighPriorityProperties>(result, false, 0, result.
matchedProperties.size() - 1, inheritedOnly); |
| 1147 } |
| 1145 | 1148 |
| 1146 // If our font got dirtied, go ahead and update it now. | 1149 // If our font got dirtied, go ahead and update it now. |
| 1147 updateFont(); | 1150 updateFont(); |
| 1148 | 1151 |
| 1149 // Line-height is set when we are sure we decided on the font-size | 1152 // Line-height is set when we are sure we decided on the font-size |
| 1150 if (state.lineHeightValue()) | 1153 if (state.lineHeightValue()) |
| 1151 applyProperty(CSSPropertyLineHeight, state.lineHeightValue()); | 1154 applyProperty(CSSPropertyLineHeight, state.lineHeightValue()); |
| 1152 | 1155 |
| 1153 // Now do rest of the properties. | 1156 // Now do rest of the properties. |
| 1154 if (keyframe->properties()) | 1157 if (keyframe->properties()) |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1782 } | 1785 } |
| 1783 | 1786 |
| 1784 Length StyleResolver::convertToFloatLength(CSSPrimitiveValue* primitiveValue, Re
nderStyle* style, RenderStyle* rootStyle, double multiplier) | 1787 Length StyleResolver::convertToFloatLength(CSSPrimitiveValue* primitiveValue, Re
nderStyle* style, RenderStyle* rootStyle, double multiplier) |
| 1785 { | 1788 { |
| 1786 return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion
| PercentConversion | CalculatedConversion | FractionConversion | ViewportPerce
ntageConversion>(style, rootStyle, multiplier) : Length(Undefined); | 1789 return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion
| PercentConversion | CalculatedConversion | FractionConversion | ViewportPerce
ntageConversion>(style, rootStyle, multiplier) : Length(Undefined); |
| 1787 } | 1790 } |
| 1788 | 1791 |
| 1789 template <StyleResolver::StyleApplicationPass pass> | 1792 template <StyleResolver::StyleApplicationPass pass> |
| 1790 void StyleResolver::applyAnimatedProperties(const Element* target) | 1793 void StyleResolver::applyAnimatedProperties(const Element* target) |
| 1791 { | 1794 { |
| 1795 ASSERT(pass != VariableDefinitions); |
| 1796 ASSERT(pass != AnimationProperties); |
| 1792 if (!target->hasActiveAnimations()) | 1797 if (!target->hasActiveAnimations()) |
| 1793 return; | 1798 return; |
| 1794 | 1799 |
| 1795 Vector<Animation*>* animations = target->activeAnimations(); | 1800 Vector<Animation*>* animations = target->activeAnimations(); |
| 1796 | 1801 |
| 1797 for (size_t i = 0; i < animations->size(); ++i) { | 1802 for (size_t i = 0; i < animations->size(); ++i) { |
| 1798 RefPtr<Animation> animation = animations->at(i); | 1803 RefPtr<Animation> animation = animations->at(i); |
| 1799 const AnimationEffect::CompositableValueMap* compositableValues = animat
ion->compositableValues(); | 1804 const AnimationEffect::CompositableValueMap* compositableValues = animat
ion->compositableValues(); |
| 1800 for (AnimationEffect::CompositableValueMap::const_iterator iter = compos
itableValues->begin(); iter != compositableValues->end(); ++iter) { | 1805 for (AnimationEffect::CompositableValueMap::const_iterator iter = compos
itableValues->begin(); iter != compositableValues->end(); ++iter) { |
| 1801 CSSPropertyID property = iter->key; | 1806 CSSPropertyID property = iter->key; |
| 1802 switch (pass) { | 1807 if (!isPropertyForPass<pass>(property)) |
| 1803 case VariableDefinitions: | |
| 1804 ASSERT_NOT_REACHED(); | |
| 1805 continue; | 1808 continue; |
| 1806 case HighPriorityProperties: | |
| 1807 if (property > CSSPropertyLineHeight) | |
| 1808 continue; | |
| 1809 break; | |
| 1810 case LowPriorityProperties: | |
| 1811 if (property <= CSSPropertyLineHeight) | |
| 1812 continue; | |
| 1813 break; | |
| 1814 } | |
| 1815 // FIXME: Composite onto the underlying value. | |
| 1816 RefPtr<CSSValue> value = iter->value->compositeOnto(AnimatableValue:
:neutralValue())->toCSSValue(); | 1809 RefPtr<CSSValue> value = iter->value->compositeOnto(AnimatableValue:
:neutralValue())->toCSSValue(); |
| 1817 if (property == CSSPropertyLineHeight) | 1810 if (pass == HighPriorityProperties && property == CSSPropertyLineHei
ght) |
| 1818 m_state.setLineHeightValue(value.get()); | 1811 m_state.setLineHeightValue(value.get()); |
| 1819 else | 1812 else |
| 1820 applyProperty(property, value.get()); | 1813 applyProperty(property, value.get()); |
| 1821 } | 1814 } |
| 1822 } | 1815 } |
| 1823 } | 1816 } |
| 1824 | 1817 |
| 1825 static inline bool isValidVisitedLinkProperty(CSSPropertyID id) | 1818 static inline bool isValidVisitedLinkProperty(CSSPropertyID id) |
| 1826 { | 1819 { |
| 1827 switch (id) { | 1820 switch (id) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 case CSSPropertyTextShadow: | 1891 case CSSPropertyTextShadow: |
| 1899 case CSSPropertyBorderStyle: | 1892 case CSSPropertyBorderStyle: |
| 1900 return true; | 1893 return true; |
| 1901 default: | 1894 default: |
| 1902 break; | 1895 break; |
| 1903 } | 1896 } |
| 1904 return false; | 1897 return false; |
| 1905 } | 1898 } |
| 1906 | 1899 |
| 1907 template <StyleResolver::StyleApplicationPass pass> | 1900 template <StyleResolver::StyleApplicationPass pass> |
| 1901 bool StyleResolver::isPropertyForPass(CSSPropertyID property) |
| 1902 { |
| 1903 COMPILE_ASSERT(CSSPropertyVariable < firstCSSProperty, CSS_variable_is_befor
e_first_property); |
| 1904 const CSSPropertyID firstAnimationProperty = CSSPropertyWebkitAnimation; |
| 1905 const CSSPropertyID lastAnimationProperty = CSSPropertyTransitionTimingFunct
ion; |
| 1906 COMPILE_ASSERT(firstCSSProperty == firstAnimationProperty, CSS_first_animati
on_property_should_be_first_property); |
| 1907 const CSSPropertyID firstHighPriorityProperty = CSSPropertyColor; |
| 1908 const CSSPropertyID lastHighPriorityProperty = CSSPropertyLineHeight; |
| 1909 COMPILE_ASSERT(lastAnimationProperty + 1 == firstHighPriorityProperty, CSS_c
olor_is_first_high_priority_property); |
| 1910 COMPILE_ASSERT(CSSPropertyLineHeight == firstHighPriorityProperty + 18, CSS_
line_height_is_end_of_high_prioity_property_range); |
| 1911 COMPILE_ASSERT(CSSPropertyZoom == lastHighPriorityProperty - 1, CSS_zoom_is_
before_line_height); |
| 1912 switch (pass) { |
| 1913 case VariableDefinitions: |
| 1914 return property == CSSPropertyVariable; |
| 1915 case AnimationProperties: |
| 1916 return property >= firstAnimationProperty && property <= lastAnimationPr
operty; |
| 1917 case HighPriorityProperties: |
| 1918 return property >= firstHighPriorityProperty && property <= lastHighPrio
rityProperty; |
| 1919 case LowPriorityProperties: |
| 1920 return property > lastHighPriorityProperty; |
| 1921 } |
| 1922 ASSERT_NOT_REACHED(); |
| 1923 return false; |
| 1924 } |
| 1925 |
| 1926 template <StyleResolver::StyleApplicationPass pass> |
| 1908 void StyleResolver::applyProperties(const StylePropertySet* properties, StyleRul
e* rule, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhi
telistType) | 1927 void StyleResolver::applyProperties(const StylePropertySet* properties, StyleRul
e* rule, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhi
telistType) |
| 1909 { | 1928 { |
| 1910 ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || m_state.regionF
orStyling()); | 1929 ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || m_state.regionF
orStyling()); |
| 1911 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProces
sRule(document(), rule, this); | 1930 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProces
sRule(document(), rule, this); |
| 1912 | 1931 |
| 1913 unsigned propertyCount = properties->propertyCount(); | 1932 unsigned propertyCount = properties->propertyCount(); |
| 1914 for (unsigned i = 0; i < propertyCount; ++i) { | 1933 for (unsigned i = 0; i < propertyCount; ++i) { |
| 1915 StylePropertySet::PropertyReference current = properties->propertyAt(i); | 1934 StylePropertySet::PropertyReference current = properties->propertyAt(i); |
| 1916 if (isImportant != current.isImportant()) | 1935 if (isImportant != current.isImportant()) |
| 1917 continue; | 1936 continue; |
| 1918 if (inheritedOnly && !current.isInherited()) { | 1937 if (inheritedOnly && !current.isInherited()) { |
| 1919 // If the property value is explicitly inherited, we need to apply f
urther non-inherited properties | 1938 // If the property value is explicitly inherited, we need to apply f
urther non-inherited properties |
| 1920 // as they might override the value inherited here. For this reason
we don't allow declarations with | 1939 // as they might override the value inherited here. For this reason
we don't allow declarations with |
| 1921 // explicitly inherited properties to be cached. | 1940 // explicitly inherited properties to be cached. |
| 1922 ASSERT(!current.value()->isInheritedValue()); | 1941 ASSERT(!current.value()->isInheritedValue()); |
| 1923 continue; | 1942 continue; |
| 1924 } | 1943 } |
| 1925 CSSPropertyID property = current.id(); | 1944 CSSPropertyID property = current.id(); |
| 1926 | 1945 |
| 1927 if (propertyWhitelistType == PropertyWhitelistRegion && !isValidRegionSt
yleProperty(property)) | 1946 if (propertyWhitelistType == PropertyWhitelistRegion && !isValidRegionSt
yleProperty(property)) |
| 1928 continue; | 1947 continue; |
| 1929 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro
perty(property)) | 1948 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro
perty(property)) |
| 1930 continue; | 1949 continue; |
| 1931 switch (pass) { | 1950 if (!isPropertyForPass<pass>(property)) |
| 1932 case VariableDefinitions: | 1951 continue; |
| 1933 COMPILE_ASSERT(CSSPropertyVariable < firstCSSProperty, CSS_variable_
is_before_first_property); | 1952 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) |
| 1934 if (property == CSSPropertyVariable) | 1953 m_state.setLineHeightValue(current.value()); |
| 1935 applyProperty(current.id(), current.value()); | 1954 else |
| 1936 break; | 1955 applyProperty(current.id(), current.value()); |
| 1937 case HighPriorityProperties: | |
| 1938 COMPILE_ASSERT(firstCSSProperty == CSSPropertyColor, CSS_color_is_fi
rst_property); | |
| 1939 COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 17, CSS_zoom_is
_end_of_first_prop_range); | |
| 1940 COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyZoom + 1, CSS_lin
e_height_is_after_zoom); | |
| 1941 if (property == CSSPropertyVariable) | |
| 1942 continue; | |
| 1943 // give special priority to font-xxx, color properties, etc | |
| 1944 if (property < CSSPropertyLineHeight) | |
| 1945 applyProperty(current.id(), current.value()); | |
| 1946 // we apply line-height later | |
| 1947 else if (property == CSSPropertyLineHeight) | |
| 1948 m_state.setLineHeightValue(current.value()); | |
| 1949 break; | |
| 1950 case LowPriorityProperties: | |
| 1951 if (property > CSSPropertyLineHeight) | |
| 1952 applyProperty(current.id(), current.value()); | |
| 1953 } | |
| 1954 } | 1956 } |
| 1955 InspectorInstrumentation::didProcessRule(cookie); | 1957 InspectorInstrumentation::didProcessRule(cookie); |
| 1956 } | 1958 } |
| 1957 | 1959 |
| 1958 template <StyleResolver::StyleApplicationPass pass> | 1960 template <StyleResolver::StyleApplicationPass pass> |
| 1959 void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, bool
isImportant, int startIndex, int endIndex, bool inheritedOnly) | 1961 void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, bool
isImportant, int startIndex, int endIndex, bool inheritedOnly) |
| 1960 { | 1962 { |
| 1961 if (startIndex == -1) | 1963 if (startIndex == -1) |
| 1962 return; | 1964 return; |
| 1963 | 1965 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2041 } | 2043 } |
| 2042 applyInheritedOnly = true; | 2044 applyInheritedOnly = true; |
| 2043 } | 2045 } |
| 2044 | 2046 |
| 2045 // First apply all variable definitions, as they may be used during applicat
ion of later properties. | 2047 // First apply all variable definitions, as they may be used during applicat
ion of later properties. |
| 2046 applyMatchedProperties<VariableDefinitions>(matchResult, false, 0, matchResu
lt.matchedProperties.size() - 1, applyInheritedOnly); | 2048 applyMatchedProperties<VariableDefinitions>(matchResult, false, 0, matchResu
lt.matchedProperties.size() - 1, applyInheritedOnly); |
| 2047 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.r
anges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); | 2049 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.r
anges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); |
| 2048 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.r
anges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); | 2050 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.r
anges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); |
| 2049 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.r
anges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 2051 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.r
anges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
| 2050 | 2052 |
| 2053 // Apply animation properties in order to apply animation results and trigge
r transitions below. |
| 2054 applyMatchedProperties<AnimationProperties>(matchResult, false, 0, matchResu
lt.matchedProperties.size() - 1, applyInheritedOnly); |
| 2055 applyMatchedProperties<AnimationProperties>(matchResult, true, matchResult.r
anges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); |
| 2056 applyMatchedProperties<AnimationProperties>(matchResult, true, matchResult.r
anges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); |
| 2057 applyMatchedProperties<AnimationProperties>(matchResult, true, matchResult.r
anges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
| 2058 // FIXME: animations should be triggered here |
| 2059 |
| 2051 // Now we have all of the matched rules in the appropriate order. Walk the r
ules and apply | 2060 // Now we have all of the matched rules in the appropriate order. Walk the r
ules and apply |
| 2052 // high-priority properties first, i.e., those properties that other propert
ies depend on. | 2061 // high-priority properties first, i.e., those properties that other propert
ies depend on. |
| 2053 // The order is (1) high-priority not important, (2) high-priority important
, (3) normal not important | 2062 // The order is (1) high-priority not important, (2) high-priority important
, (3) normal not important |
| 2054 // and (4) normal important. | 2063 // and (4) normal important. |
| 2055 state.setLineHeightValue(0); | 2064 state.setLineHeightValue(0); |
| 2056 applyMatchedProperties<HighPriorityProperties>(matchResult, false, 0, matchR
esult.matchedProperties.size() - 1, applyInheritedOnly); | 2065 applyMatchedProperties<HighPriorityProperties>(matchResult, false, 0, matchR
esult.matchedProperties.size() - 1, applyInheritedOnly); |
| 2057 // Animation contributions are processed here because CSS Animations are ove
rridable by user !important rules. | 2066 // Animation contributions are processed here because CSS Animations are ove
rridable by user !important rules. |
| 2058 if (RuntimeEnabledFeatures::webAnimationsEnabled()) | 2067 if (RuntimeEnabledFeatures::webAnimationsEnabled()) |
| 2059 applyAnimatedProperties<HighPriorityProperties>(element); | 2068 applyAnimatedProperties<HighPriorityProperties>(element); |
| 2060 applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResul
t.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly)
; | 2069 applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResul
t.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly)
; |
| (...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3447 void CachedMatchedProperties::reportMemoryUsage(MemoryObjectInfo* memoryObjectIn
fo) const | 3456 void CachedMatchedProperties::reportMemoryUsage(MemoryObjectInfo* memoryObjectIn
fo) const |
| 3448 { | 3457 { |
| 3449 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); | 3458 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); |
| 3450 info.addMember(matchedProperties, "matchedProperties"); | 3459 info.addMember(matchedProperties, "matchedProperties"); |
| 3451 info.addMember(ranges, "ranges"); | 3460 info.addMember(ranges, "ranges"); |
| 3452 info.addMember(renderStyle, "renderStyle"); | 3461 info.addMember(renderStyle, "renderStyle"); |
| 3453 info.addMember(parentRenderStyle, "parentRenderStyle"); | 3462 info.addMember(parentRenderStyle, "parentRenderStyle"); |
| 3454 } | 3463 } |
| 3455 | 3464 |
| 3456 } // namespace WebCore | 3465 } // namespace WebCore |
| OLD | NEW |