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

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

Issue 2730683002: Add CSS Transition support to registered custom properties (Closed)
Patch Set: Rebased Created 3 years, 9 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
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. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
10 * (http://www.torchmobile.com/) 10 * (http://www.torchmobile.com/)
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 (animatingElement && animatingElement->hasAnimations())) { 1108 (animatingElement && animatingElement->hasAnimations())) {
1109 if (!state.isAnimationInterpolationMapReady()) 1109 if (!state.isAnimationInterpolationMapReady())
1110 calculateAnimationUpdate(state, animatingElement); 1110 calculateAnimationUpdate(state, animatingElement);
1111 } else if (!state.style()->transitions()) { 1111 } else if (!state.style()->transitions()) {
1112 return false; 1112 return false;
1113 } 1113 }
1114 1114
1115 CSSAnimations::calculateCompositorAnimationUpdate( 1115 CSSAnimations::calculateCompositorAnimationUpdate(
1116 state.animationUpdate(), animatingElement, *element, *state.style(), 1116 state.animationUpdate(), animatingElement, *element, *state.style(),
1117 state.parentStyle(), wasViewportResized()); 1117 state.parentStyle(), wasViewportResized());
1118 CSSAnimations::calculateTransitionUpdate(state.animationUpdate(), 1118 CSSAnimations::calculateTransitionUpdate(
1119 animatingElement, *state.style()); 1119 state.animationUpdate(), CSSAnimations::PropertyPass::Standard,
1120 animatingElement, *state.style());
1120 1121
1121 CSSAnimations::snapshotCompositorKeyframes( 1122 CSSAnimations::snapshotCompositorKeyframes(
1122 *element, state.animationUpdate(), *state.style(), state.parentStyle()); 1123 *element, state.animationUpdate(), *state.style(), state.parentStyle());
1123 1124
1124 if (state.animationUpdate().isEmpty()) 1125 if (state.animationUpdate().isEmpty())
1125 return false; 1126 return false;
1126 1127
1127 if (state.style()->insideLink() != EInsideLink::kNotInsideLink) { 1128 if (state.style()->insideLink() != EInsideLink::kNotInsideLink) {
1128 DCHECK(state.applyPropertyToRegularStyle()); 1129 DCHECK(state.applyPropertyToRegularStyle());
1129 state.setApplyPropertyToVisitedLinkStyle(true); 1130 state.setApplyPropertyToVisitedLinkStyle(true);
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 const MatchResult& matchResult, 1606 const MatchResult& matchResult,
1606 const Element* animatingElement) { 1607 const Element* animatingElement) {
1607 CacheSuccess cacheSuccess = applyMatchedCache(state, matchResult); 1608 CacheSuccess cacheSuccess = applyMatchedCache(state, matchResult);
1608 NeedsApplyPass needsApplyPass; 1609 NeedsApplyPass needsApplyPass;
1609 if (!cacheSuccess.isFullCacheHit()) { 1610 if (!cacheSuccess.isFullCacheHit()) {
1610 applyCustomProperties(state, matchResult, ExcludeAnimations, cacheSuccess, 1611 applyCustomProperties(state, matchResult, ExcludeAnimations, cacheSuccess,
1611 needsApplyPass); 1612 needsApplyPass);
1612 applyMatchedAnimationProperties(state, matchResult, cacheSuccess, 1613 applyMatchedAnimationProperties(state, matchResult, cacheSuccess,
1613 needsApplyPass); 1614 needsApplyPass);
1614 } 1615 }
1615 if (state.style()->animations() || 1616 if (state.style()->animations() || state.style()->transitions() ||
1616 (animatingElement && animatingElement->hasAnimations())) { 1617 (animatingElement && animatingElement->hasAnimations())) {
1617 calculateAnimationUpdate(state, animatingElement); 1618 calculateAnimationUpdate(state, animatingElement);
1618 if (state.isAnimatingCustomProperties()) { 1619 if (state.isAnimatingCustomProperties()) {
1619 cacheSuccess.setFailed(); 1620 cacheSuccess.setFailed();
1620 applyCustomProperties(state, matchResult, IncludeAnimations, cacheSuccess, 1621 applyCustomProperties(state, matchResult, IncludeAnimations, cacheSuccess,
1621 needsApplyPass); 1622 needsApplyPass);
1622 } 1623 }
1623 } 1624 }
1624 if (!cacheSuccess.isFullCacheHit()) { 1625 if (!cacheSuccess.isFullCacheHit()) {
1625 applyMatchedStandardProperties(state, matchResult, cacheSuccess, 1626 applyMatchedStandardProperties(state, matchResult, cacheSuccess,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 // this work. 1698 // this work.
1698 applyMatchedProperties<ResolveVariables, UpdateNeedsApplyPass>( 1699 applyMatchedProperties<ResolveVariables, UpdateNeedsApplyPass>(
1699 state, matchResult.authorRules(), false, applyInheritedOnly, 1700 state, matchResult.authorRules(), false, applyInheritedOnly,
1700 needsApplyPass); 1701 needsApplyPass);
1701 applyMatchedProperties<ResolveVariables, CheckNeedsApplyPass>( 1702 applyMatchedProperties<ResolveVariables, CheckNeedsApplyPass>(
1702 state, matchResult.authorRules(), true, applyInheritedOnly, 1703 state, matchResult.authorRules(), true, applyInheritedOnly,
1703 needsApplyPass); 1704 needsApplyPass);
1704 if (applyAnimations == IncludeAnimations) { 1705 if (applyAnimations == IncludeAnimations) {
1705 applyAnimatedProperties<ResolveVariables>( 1706 applyAnimatedProperties<ResolveVariables>(
1706 state, state.animationUpdate().activeInterpolationsForAnimations()); 1707 state, state.animationUpdate().activeInterpolationsForAnimations());
1708 applyAnimatedProperties<ResolveVariables>(
1709 state,
1710 state.animationUpdate().activeInterpolationsForCustomTransitions());
1707 } 1711 }
1708 // TODO(leviw): stop recalculating every time 1712 // TODO(leviw): stop recalculating every time
1709 CSSVariableResolver::resolveVariableDefinitions(state); 1713 CSSVariableResolver::resolveVariableDefinitions(state);
1710 1714
1711 if (RuntimeEnabledFeatures::cssApplyAtRulesEnabled()) { 1715 if (RuntimeEnabledFeatures::cssApplyAtRulesEnabled()) {
1712 if (cacheCustomPropertiesForApplyAtRules(state, 1716 if (cacheCustomPropertiesForApplyAtRules(state,
1713 matchResult.authorRules())) { 1717 matchResult.authorRules())) {
1714 applyMatchedProperties<ResolveVariables, UpdateNeedsApplyPass>( 1718 applyMatchedProperties<ResolveVariables, UpdateNeedsApplyPass>(
1715 state, matchResult.authorRules(), false, applyInheritedOnly, 1719 state, matchResult.authorRules(), false, applyInheritedOnly,
1716 needsApplyPass); 1720 needsApplyPass);
1717 applyMatchedProperties<ResolveVariables, CheckNeedsApplyPass>( 1721 applyMatchedProperties<ResolveVariables, CheckNeedsApplyPass>(
1718 state, matchResult.authorRules(), true, applyInheritedOnly, 1722 state, matchResult.authorRules(), true, applyInheritedOnly,
1719 needsApplyPass); 1723 needsApplyPass);
1720 if (applyAnimations == IncludeAnimations) { 1724 if (applyAnimations == IncludeAnimations) {
1721 applyAnimatedProperties<ResolveVariables>( 1725 applyAnimatedProperties<ResolveVariables>(
1722 state, state.animationUpdate().activeInterpolationsForAnimations()); 1726 state, state.animationUpdate().activeInterpolationsForAnimations());
1727 applyAnimatedProperties<ResolveVariables>(
1728 state,
1729 state.animationUpdate().activeInterpolationsForCustomTransitions());
1723 } 1730 }
1724 CSSVariableResolver::resolveVariableDefinitions(state); 1731 CSSVariableResolver::resolveVariableDefinitions(state);
1725 } 1732 }
1726 } 1733 }
1727 } 1734 }
1728 1735
1729 void StyleResolver::applyMatchedAnimationProperties( 1736 void StyleResolver::applyMatchedAnimationProperties(
1730 StyleResolverState& state, 1737 StyleResolverState& state,
1731 const MatchResult& matchResult, 1738 const MatchResult& matchResult,
1732 const CacheSuccess& cacheSuccess, 1739 const CacheSuccess& cacheSuccess,
1733 NeedsApplyPass& needsApplyPass) { 1740 NeedsApplyPass& needsApplyPass) {
1734 DCHECK(!cacheSuccess.isFullCacheHit()); 1741 DCHECK(!cacheSuccess.isFullCacheHit());
1735 bool applyInheritedOnly = cacheSuccess.shouldApplyInheritedOnly(); 1742 bool applyInheritedOnly = cacheSuccess.shouldApplyInheritedOnly();
1736 1743
1737 applyMatchedProperties<AnimationPropertyPriority, UpdateNeedsApplyPass>( 1744 applyMatchedProperties<AnimationPropertyPriority, UpdateNeedsApplyPass>(
1738 state, matchResult.allRules(), false, applyInheritedOnly, needsApplyPass); 1745 state, matchResult.allRules(), false, applyInheritedOnly, needsApplyPass);
1739 applyMatchedProperties<AnimationPropertyPriority, CheckNeedsApplyPass>( 1746 applyMatchedProperties<AnimationPropertyPriority, CheckNeedsApplyPass>(
1740 state, matchResult.allRules(), true, applyInheritedOnly, needsApplyPass); 1747 state, matchResult.allRules(), true, applyInheritedOnly, needsApplyPass);
1741 } 1748 }
1742 1749
1743 void StyleResolver::calculateAnimationUpdate(StyleResolverState& state, 1750 void StyleResolver::calculateAnimationUpdate(StyleResolverState& state,
1744 const Element* animatingElement) { 1751 const Element* animatingElement) {
1745 DCHECK(state.style()->animations() || 1752 DCHECK(state.style()->animations() || state.style()->transitions() ||
1746 (animatingElement && animatingElement->hasAnimations())); 1753 (animatingElement && animatingElement->hasAnimations()));
1747 DCHECK(!state.isAnimationInterpolationMapReady()); 1754 DCHECK(!state.isAnimationInterpolationMapReady());
1748 1755
1749 CSSAnimations::calculateAnimationUpdate( 1756 CSSAnimations::calculateAnimationUpdate(
1750 state.animationUpdate(), animatingElement, *state.element(), 1757 state.animationUpdate(), animatingElement, *state.element(),
1751 *state.style(), state.parentStyle(), this); 1758 *state.style(), state.parentStyle(), this);
1759 CSSAnimations::calculateTransitionUpdate(state.animationUpdate(),
1760 CSSAnimations::PropertyPass::Custom,
1761 animatingElement, *state.style());
1752 1762
1753 state.setIsAnimationInterpolationMapReady(); 1763 state.setIsAnimationInterpolationMapReady();
1754 1764
1755 if (state.isAnimatingCustomProperties()) 1765 if (state.isAnimatingCustomProperties()) {
1756 return; 1766 return;
1767 }
1768 if (!state.animationUpdate()
1769 .activeInterpolationsForCustomTransitions()
1770 .isEmpty()) {
1771 state.setIsAnimatingCustomProperties(true);
1772 return;
1773 }
1757 for (const auto& propertyHandle : 1774 for (const auto& propertyHandle :
1758 state.animationUpdate().activeInterpolationsForAnimations().keys()) { 1775 state.animationUpdate().activeInterpolationsForAnimations().keys()) {
1759 if (CSSAnimations::isCustomPropertyHandle(propertyHandle)) { 1776 if (CSSAnimations::isCustomPropertyHandle(propertyHandle)) {
1760 state.setIsAnimatingCustomProperties(true); 1777 state.setIsAnimatingCustomProperties(true);
1761 return; 1778 return;
1762 } 1779 }
1763 } 1780 }
1764 } 1781 }
1765 1782
1766 void StyleResolver::applyMatchedStandardProperties( 1783 void StyleResolver::applyMatchedStandardProperties(
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1946 1963
1947 DEFINE_TRACE(StyleResolver) { 1964 DEFINE_TRACE(StyleResolver) {
1948 visitor->trace(m_matchedPropertiesCache); 1965 visitor->trace(m_matchedPropertiesCache);
1949 visitor->trace(m_selectorFilter); 1966 visitor->trace(m_selectorFilter);
1950 visitor->trace(m_styleSharingLists); 1967 visitor->trace(m_styleSharingLists);
1951 visitor->trace(m_document); 1968 visitor->trace(m_document);
1952 visitor->trace(m_tracker); 1969 visitor->trace(m_tracker);
1953 } 1970 }
1954 1971
1955 } // namespace blink 1972 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698