Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(846)

Side by Side Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 18686005: Style resolution: Apply animation properties earlier in a separate pass (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 StyleResolverState& state = m_state; 1131 StyleResolverState& state = m_state;
1132 ASSERT(!state.style()); 1132 ASSERT(!state.style());
1133 1133
1134 // Create the style 1134 // Create the style
1135 state.setStyle(RenderStyle::clone(elementStyle)); 1135 state.setStyle(RenderStyle::clone(elementStyle));
1136 state.setLineHeightValue(0); 1136 state.setLineHeightValue(0);
1137 1137
1138 // We don't need to bother with !important. Since there is only ever one 1138 // We don't need to bother with !important. Since there is only ever one
1139 // decl, there's nothing to override. So just add the first properties. 1139 // decl, there's nothing to override. So just add the first properties.
1140 bool inheritedOnly = false; 1140 bool inheritedOnly = false;
1141 if (keyframe->properties()) 1141 if (keyframe->properties()) {
1142 // FIXME: Can't keyframes contain variables?
1143 applyMatchedProperties<AnimationProperties>(result, false, 0, result.mat chedProperties.size() - 1, inheritedOnly);
1142 applyMatchedProperties<HighPriorityProperties>(result, false, 0, result. matchedProperties.size() - 1, inheritedOnly); 1144 applyMatchedProperties<HighPriorityProperties>(result, false, 0, result. matchedProperties.size() - 1, inheritedOnly);
1145 }
1143 1146
1144 // If our font got dirtied, go ahead and update it now. 1147 // If our font got dirtied, go ahead and update it now.
1145 updateFont(); 1148 updateFont();
1146 1149
1147 // Line-height is set when we are sure we decided on the font-size 1150 // Line-height is set when we are sure we decided on the font-size
1148 if (state.lineHeightValue()) 1151 if (state.lineHeightValue())
1149 applyProperty(CSSPropertyLineHeight, state.lineHeightValue()); 1152 applyProperty(CSSPropertyLineHeight, state.lineHeightValue());
1150 1153
1151 // Now do rest of the properties. 1154 // Now do rest of the properties.
1152 if (keyframe->properties()) 1155 if (keyframe->properties())
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 } 1783 }
1781 1784
1782 Length StyleResolver::convertToFloatLength(CSSPrimitiveValue* primitiveValue, Re nderStyle* style, RenderStyle* rootStyle, double multiplier) 1785 Length StyleResolver::convertToFloatLength(CSSPrimitiveValue* primitiveValue, Re nderStyle* style, RenderStyle* rootStyle, double multiplier)
1783 { 1786 {
1784 return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPerce ntageConversion>(style, rootStyle, multiplier) : Length(Undefined); 1787 return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPerce ntageConversion>(style, rootStyle, multiplier) : Length(Undefined);
1785 } 1788 }
1786 1789
1787 template <StyleResolver::StyleApplicationPass pass> 1790 template <StyleResolver::StyleApplicationPass pass>
1788 void StyleResolver::applyAnimatedProperties(const Element* target) 1791 void StyleResolver::applyAnimatedProperties(const Element* target)
1789 { 1792 {
1793 ASSERT(pass != VariableDefinitions);
1794 ASSERT(pass != AnimationProperties);
1790 if (!target->hasActiveAnimations()) 1795 if (!target->hasActiveAnimations())
1791 return; 1796 return;
1792 1797
1793 Vector<Animation*>* animations = target->activeAnimations(); 1798 Vector<Animation*>* animations = target->activeAnimations();
1794 1799
1795 for (size_t i = 0; i < animations->size(); ++i) { 1800 for (size_t i = 0; i < animations->size(); ++i) {
1796 RefPtr<Animation> animation = animations->at(i); 1801 RefPtr<Animation> animation = animations->at(i);
1797 const AnimationEffect::CompositableValueMap* compositableValues = animat ion->compositableValues(); 1802 const AnimationEffect::CompositableValueMap* compositableValues = animat ion->compositableValues();
1798 for (AnimationEffect::CompositableValueMap::const_iterator iter = compos itableValues->begin(); iter != compositableValues->end(); ++iter) { 1803 for (AnimationEffect::CompositableValueMap::const_iterator iter = compos itableValues->begin(); iter != compositableValues->end(); ++iter) {
1799 CSSPropertyID property = iter->key; 1804 CSSPropertyID property = iter->key;
1800 switch (pass) { 1805 if (!isPropertyForPass<pass>(property))
1801 case VariableDefinitions:
1802 ASSERT_NOT_REACHED();
1803 continue; 1806 continue;
1804 case HighPriorityProperties:
1805 if (property > CSSPropertyLineHeight)
1806 continue;
1807 break;
1808 case LowPriorityProperties:
1809 if (property <= CSSPropertyLineHeight)
1810 continue;
1811 break;
1812 }
1813 // FIXME: Composite onto the underlying value.
1814 RefPtr<CSSValue> value = iter->value->compositeOnto(AnimatableValue: :neutralValue())->toCSSValue(); 1807 RefPtr<CSSValue> value = iter->value->compositeOnto(AnimatableValue: :neutralValue())->toCSSValue();
1815 if (property == CSSPropertyLineHeight) 1808 if (pass == HighPriorityProperties && property == CSSPropertyLineHei ght)
1816 m_state.setLineHeightValue(value.get()); 1809 m_state.setLineHeightValue(value.get());
1817 else 1810 else
1818 applyProperty(property, value.get()); 1811 applyProperty(property, value.get());
1819 } 1812 }
1820 } 1813 }
1821 } 1814 }
1822 1815
1823 static inline bool isValidVisitedLinkProperty(CSSPropertyID id) 1816 static inline bool isValidVisitedLinkProperty(CSSPropertyID id)
1824 { 1817 {
1825 switch (id) { 1818 switch (id) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 // explicitly inherited properties to be cached. 1912 // explicitly inherited properties to be cached.
1920 ASSERT(!current.value()->isInheritedValue()); 1913 ASSERT(!current.value()->isInheritedValue());
1921 continue; 1914 continue;
1922 } 1915 }
1923 CSSPropertyID property = current.id(); 1916 CSSPropertyID property = current.id();
1924 1917
1925 if (propertyWhitelistType == PropertyWhitelistRegion && !isValidRegionSt yleProperty(property)) 1918 if (propertyWhitelistType == PropertyWhitelistRegion && !isValidRegionSt yleProperty(property))
1926 continue; 1919 continue;
1927 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro perty(property)) 1920 if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStylePro perty(property))
1928 continue; 1921 continue;
1929 switch (pass) { 1922 if (!isPropertyForPass<pass>(property))
1930 case VariableDefinitions: 1923 continue;
1931 COMPILE_ASSERT(CSSPropertyVariable < firstCSSProperty, CSS_variable_ is_before_first_property); 1924 if (property == CSSPropertyLineHeight)
1932 if (property == CSSPropertyVariable) 1925 m_state.setLineHeightValue(current.value());
1933 applyProperty(current.id(), current.value()); 1926 else
1934 break; 1927 applyProperty(current.id(), current.value());
1935 case HighPriorityProperties:
1936 COMPILE_ASSERT(firstCSSProperty == CSSPropertyColor, CSS_color_is_fi rst_property);
1937 COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 17, CSS_zoom_is _end_of_first_prop_range);
1938 COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyZoom + 1, CSS_lin e_height_is_after_zoom);
1939 if (property == CSSPropertyVariable)
1940 continue;
1941 // give special priority to font-xxx, color properties, etc
1942 if (property < CSSPropertyLineHeight)
1943 applyProperty(current.id(), current.value());
1944 // we apply line-height later
1945 else if (property == CSSPropertyLineHeight)
1946 m_state.setLineHeightValue(current.value());
1947 break;
1948 case LowPriorityProperties:
1949 if (property > CSSPropertyLineHeight)
1950 applyProperty(current.id(), current.value());
1951 }
1952 } 1928 }
1953 InspectorInstrumentation::didProcessRule(cookie); 1929 InspectorInstrumentation::didProcessRule(cookie);
1954 } 1930 }
1955 1931
1956 template <StyleResolver::StyleApplicationPass pass> 1932 template <StyleResolver::StyleApplicationPass pass>
1957 void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inheritedOnly) 1933 void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inheritedOnly)
1958 { 1934 {
1959 if (startIndex == -1) 1935 if (startIndex == -1)
1960 return; 1936 return;
1961 1937
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 } 2015 }
2040 applyInheritedOnly = true; 2016 applyInheritedOnly = true;
2041 } 2017 }
2042 2018
2043 // First apply all variable definitions, as they may be used during applicat ion of later properties. 2019 // First apply all variable definitions, as they may be used during applicat ion of later properties.
2044 applyMatchedProperties<VariableDefinitions>(matchResult, false, 0, matchResu lt.matchedProperties.size() - 1, applyInheritedOnly); 2020 applyMatchedProperties<VariableDefinitions>(matchResult, false, 0, matchResu lt.matchedProperties.size() - 1, applyInheritedOnly);
2045 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.r anges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); 2021 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.r anges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
2046 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.r anges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); 2022 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.r anges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
2047 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.r anges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 2023 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.r anges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
2048 2024
2025 // Apply animation properties in order to apply animation results and trigge r transitions below.
2026 applyMatchedProperties<AnimationProperties>(matchResult, false, 0, matchResu lt.matchedProperties.size() - 1, applyInheritedOnly);
2027 applyMatchedProperties<AnimationProperties>(matchResult, true, matchResult.r anges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
2028 applyMatchedProperties<AnimationProperties>(matchResult, true, matchResult.r anges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
2029 applyMatchedProperties<AnimationProperties>(matchResult, true, matchResult.r anges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
2030 // FIXME: animations should be triggered here
2031
2049 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply 2032 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply
2050 // high-priority properties first, i.e., those properties that other propert ies depend on. 2033 // high-priority properties first, i.e., those properties that other propert ies depend on.
2051 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important 2034 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important
2052 // and (4) normal important. 2035 // and (4) normal important.
2053 state.setLineHeightValue(0); 2036 state.setLineHeightValue(0);
2054 applyMatchedProperties<HighPriorityProperties>(matchResult, false, 0, matchR esult.matchedProperties.size() - 1, applyInheritedOnly); 2037 applyMatchedProperties<HighPriorityProperties>(matchResult, false, 0, matchR esult.matchedProperties.size() - 1, applyInheritedOnly);
2055 // Animation contributions are processed here because CSS Animations are ove rridable by user !important rules. 2038 // Animation contributions are processed here because CSS Animations are ove rridable by user !important rules.
2056 if (RuntimeEnabledFeatures::webAnimationsEnabled()) 2039 if (RuntimeEnabledFeatures::webAnimationsEnabled())
2057 applyAnimatedProperties<HighPriorityProperties>(element); 2040 applyAnimatedProperties<HighPriorityProperties>(element);
2058 applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResul t.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly) ; 2041 applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResul t.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly) ;
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after
3431 void CachedMatchedProperties::reportMemoryUsage(MemoryObjectInfo* memoryObjectIn fo) const 3414 void CachedMatchedProperties::reportMemoryUsage(MemoryObjectInfo* memoryObjectIn fo) const
3432 { 3415 {
3433 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); 3416 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
3434 info.addMember(matchedProperties, "matchedProperties"); 3417 info.addMember(matchedProperties, "matchedProperties");
3435 info.addMember(ranges, "ranges"); 3418 info.addMember(ranges, "ranges");
3436 info.addMember(renderStyle, "renderStyle"); 3419 info.addMember(renderStyle, "renderStyle");
3437 info.addMember(parentRenderStyle, "parentRenderStyle"); 3420 info.addMember(parentRenderStyle, "parentRenderStyle");
3438 } 3421 }
3439 3422
3440 } // namespace WebCore 3423 } // namespace WebCore
OLDNEW
« Source/core/css/resolver/StyleResolver.h ('K') | « Source/core/css/resolver/StyleResolver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698