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

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

Issue 2309963002: Apply custom property animation (Closed)
Patch Set: Rebase Created 4 years 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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 if (RuntimeEnabledFeatures::styleSharingEnabled() && 684 if (RuntimeEnabledFeatures::styleSharingEnabled() &&
685 sharingBehavior == AllowStyleSharing && 685 sharingBehavior == AllowStyleSharing &&
686 (defaultParent || elementContext.parentStyle())) { 686 (defaultParent || elementContext.parentStyle())) {
687 if (RefPtr<ComputedStyle> sharedStyle = 687 if (RefPtr<ComputedStyle> sharedStyle =
688 document().styleEngine().findSharedStyle(elementContext)) 688 document().styleEngine().findSharedStyle(elementContext))
689 return sharedStyle.release(); 689 return sharedStyle.release();
690 } 690 }
691 691
692 StyleResolverState state(document(), elementContext, defaultParent); 692 StyleResolverState state(document(), elementContext, defaultParent);
693 693
694 const ComputedStyle* baseComputedStyle = nullptr;
694 ElementAnimations* elementAnimations = element->elementAnimations(); 695 ElementAnimations* elementAnimations = element->elementAnimations();
695 const ComputedStyle* baseComputedStyle = 696 if (elementAnimations) {
696 elementAnimations ? elementAnimations->baseComputedStyle() : nullptr; 697 // TODO(alancutter): Use the base computed style optimisation in the
698 // presence of custom property animations that don't affect pre-animated
699 // computed values.
700 if (CSSAnimations::isAnimatingCustomProperties(elementAnimations)) {
701 state.setIsAnimatingCustomProperties(true);
702 } else {
703 baseComputedStyle = elementAnimations->baseComputedStyle();
704 }
705 }
697 706
698 if (baseComputedStyle) { 707 if (baseComputedStyle) {
699 state.setStyle(ComputedStyle::clone(*baseComputedStyle)); 708 state.setStyle(ComputedStyle::clone(*baseComputedStyle));
700 if (!state.parentStyle()) 709 if (!state.parentStyle())
701 state.setParentStyle(initialStyleForElement()); 710 state.setParentStyle(initialStyleForElement());
702 } else { 711 } else {
703 if (state.parentStyle()) { 712 if (state.parentStyle()) {
704 RefPtr<ComputedStyle> style = ComputedStyle::create(); 713 RefPtr<ComputedStyle> style = ComputedStyle::create();
705 style->inheritFrom(*state.parentStyle(), 714 style->inheritFrom(*state.parentStyle(),
706 isAtShadowBoundary(element) 715 isAtShadowBoundary(element)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 // NOTE: this must occur before applyMatchedProperties for correct 778 // NOTE: this must occur before applyMatchedProperties for correct
770 // computation of font-relative lengths. 779 // computation of font-relative lengths.
771 state.style()->setTextAutosizingMultiplier( 780 state.style()->setTextAutosizingMultiplier(
772 element->computedStyle()->textAutosizingMultiplier()); 781 element->computedStyle()->textAutosizingMultiplier());
773 state.style()->setUnique(); 782 state.style()->setUnique();
774 } 783 }
775 784
776 if (state.hasDirAutoAttribute()) 785 if (state.hasDirAutoAttribute())
777 state.style()->setSelfOrAncestorHasDirAutoAttribute(true); 786 state.style()->setSelfOrAncestorHasDirAutoAttribute(true);
778 787
779 applyMatchedProperties(state, collector.matchedResult()); 788 applyMatchedPropertiesAndCustomPropertyAnimations(
789 state, collector.matchedResult(), element);
780 applyCallbackSelectors(state); 790 applyCallbackSelectors(state);
781 791
782 // Cache our original display. 792 // Cache our original display.
783 state.style()->setOriginalDisplay(state.style()->display()); 793 state.style()->setOriginalDisplay(state.style()->display());
784 794
785 adjustComputedStyle(state, element); 795 adjustComputedStyle(state, element);
786 796
787 if (elementAnimations) 797 if (elementAnimations && !state.isAnimatingCustomProperties())
788 elementAnimations->updateBaseComputedStyle(state.style()); 798 elementAnimations->updateBaseComputedStyle(state.style());
789 } else { 799 } else {
790 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), baseStylesUsed, 1); 800 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), baseStylesUsed, 1);
791 } 801 }
792 802
793 // FIXME: The CSSWG wants to specify that the effects of animations are 803 // FIXME: The CSSWG wants to specify that the effects of animations are
794 // applied before important rules, but this currently happens here as we 804 // applied before important rules, but this currently happens here as we
795 // require adjustment to have happened before deciding which properties to 805 // require adjustment to have happened before deciding which properties to
796 // transition. 806 // transition.
797 if (applyAnimatedProperties(state, element)) { 807 if (applyAnimatedStandardProperties(state, element)) {
798 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesAnimated, 1); 808 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesAnimated, 1);
799 adjustComputedStyle(state, element); 809 adjustComputedStyle(state, element);
800 } 810 }
801 811
802 if (isHTMLBodyElement(*element)) 812 if (isHTMLBodyElement(*element))
803 document().textLinkColors().setTextColor(state.style()->color()); 813 document().textLinkColors().setTextColor(state.style()->color());
804 814
805 setAnimationUpdateIfNeeded(state, *element); 815 setAnimationUpdateIfNeeded(state, *element);
806 816
807 if (state.style()->hasViewportUnits()) 817 if (state.style()->hasViewportUnits())
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 matchUARules(collector); 944 matchUARules(collector);
935 matchAuthorRules(*state.element(), collector); 945 matchAuthorRules(*state.element(), collector);
936 collector.finishAddingAuthorRulesForTreeScope(); 946 collector.finishAddingAuthorRulesForTreeScope();
937 947
938 if (m_tracker) 948 if (m_tracker)
939 addMatchedRulesToTracker(collector); 949 addMatchedRulesToTracker(collector);
940 950
941 if (!collector.matchedResult().hasMatchedProperties()) 951 if (!collector.matchedResult().hasMatchedProperties())
942 return false; 952 return false;
943 953
944 applyMatchedProperties(state, collector.matchedResult()); 954 applyMatchedPropertiesAndCustomPropertyAnimations(
955 state, collector.matchedResult(), pseudoElement);
945 applyCallbackSelectors(state); 956 applyCallbackSelectors(state);
946 957
947 // Cache our original display. 958 // Cache our original display.
948 state.style()->setOriginalDisplay(state.style()->display()); 959 state.style()->setOriginalDisplay(state.style()->display());
949 960
950 // FIXME: Passing 0 as the Element* introduces a lot of complexity 961 // FIXME: Passing 0 as the Element* introduces a lot of complexity
951 // in the adjustComputedStyle code. 962 // in the adjustComputedStyle code.
952 adjustComputedStyle(state, 0); 963 adjustComputedStyle(state, 0);
953 964
954 if (elementAnimations) 965 if (elementAnimations)
955 elementAnimations->updateBaseComputedStyle(state.style()); 966 elementAnimations->updateBaseComputedStyle(state.style());
956 } 967 }
957 968
958 // FIXME: The CSSWG wants to specify that the effects of animations are 969 // FIXME: The CSSWG wants to specify that the effects of animations are
959 // applied before important rules, but this currently happens here as we 970 // applied before important rules, but this currently happens here as we
960 // require adjustment to have happened before deciding which properties to 971 // require adjustment to have happened before deciding which properties to
961 // transition. 972 // transition.
962 if (applyAnimatedProperties(state, pseudoElement)) 973 if (applyAnimatedStandardProperties(state, pseudoElement))
963 adjustComputedStyle(state, 0); 974 adjustComputedStyle(state, 0);
964 975
965 document().styleEngine().incStyleForElementCount(); 976 document().styleEngine().incStyleForElementCount();
966 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), pseudoElementsStyled, 977 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), pseudoElementsStyled,
967 1); 978 1);
968 979
969 if (state.style()->hasViewportUnits()) 980 if (state.style()->hasViewportUnits())
970 document().setHasViewportUnits(); 981 document().setHasViewportUnits();
971 982
972 return true; 983 return true;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 if (rulesToInclude & UAAndUserCSSRules) 1121 if (rulesToInclude & UAAndUserCSSRules)
1111 matchUARules(collector); 1122 matchUARules(collector);
1112 1123
1113 if (rulesToInclude & AuthorCSSRules) { 1124 if (rulesToInclude & AuthorCSSRules) {
1114 collector.setSameOriginOnly(!(rulesToInclude & CrossOriginCSSRules)); 1125 collector.setSameOriginOnly(!(rulesToInclude & CrossOriginCSSRules));
1115 collector.setIncludeEmptyRules(rulesToInclude & EmptyCSSRules); 1126 collector.setIncludeEmptyRules(rulesToInclude & EmptyCSSRules);
1116 matchAuthorRules(element, collector); 1127 matchAuthorRules(element, collector);
1117 } 1128 }
1118 } 1129 }
1119 1130
1120 bool StyleResolver::applyAnimatedProperties(StyleResolverState& state, 1131 bool StyleResolver::applyAnimatedStandardProperties(
1121 const Element* animatingElement) { 1132 StyleResolverState& state,
1133 const Element* animatingElement) {
1122 Element* element = state.element(); 1134 Element* element = state.element();
1123 DCHECK(element); 1135 DCHECK(element);
1124 1136
1125 // The animating element may be this element, or its pseudo element. It is 1137 // The animating element may be this element, or its pseudo element. It is
1126 // null when calculating the style for a potential pseudo element that has 1138 // null when calculating the style for a potential pseudo element that has
1127 // yet to be created. 1139 // yet to be created.
1128 DCHECK(animatingElement == element || !animatingElement || 1140 DCHECK(animatingElement == element || !animatingElement ||
1129 animatingElement->parentOrShadowHostElement() == element); 1141 animatingElement->parentOrShadowHostElement() == element);
1130 1142
1131 if (!(animatingElement && animatingElement->hasAnimations()) && 1143 if (!(animatingElement && animatingElement->hasAnimations()) &&
1132 !state.style()->transitions() && !state.style()->animations()) 1144 !state.style()->transitions() && !state.style()->animations())
1133 return false; 1145 return false;
1134 1146
1135 CSSAnimations::calculateUpdate(animatingElement, *element, *state.style(), 1147 CSSAnimations::calculateCompositorAndTransitionUpdate(
1136 state.parentStyle(), state.animationUpdate(), 1148 animatingElement, *element, *state.style(), state.parentStyle(),
1137 this); 1149 state.animationUpdate());
1138 1150
1139 CSSAnimations::snapshotCompositorKeyframes( 1151 CSSAnimations::snapshotCompositorKeyframes(
1140 *element, state.animationUpdate(), *state.style(), state.parentStyle()); 1152 *element, state.animationUpdate(), *state.style(), state.parentStyle());
1141 1153
1142 if (state.animationUpdate().isEmpty()) 1154 if (state.animationUpdate().isEmpty())
1143 return false; 1155 return false;
1144 1156
1145 if (state.style()->insideLink() != NotInsideLink) { 1157 if (state.style()->insideLink() != NotInsideLink) {
1146 DCHECK(state.applyPropertyToRegularStyle()); 1158 DCHECK(state.applyPropertyToRegularStyle());
1147 state.setApplyPropertyToVisitedLinkStyle(true); 1159 state.setApplyPropertyToVisitedLinkStyle(true);
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 } 1607 }
1596 1608
1597 void StyleResolver::invalidateMatchedPropertiesCache() { 1609 void StyleResolver::invalidateMatchedPropertiesCache() {
1598 m_matchedPropertiesCache.clear(); 1610 m_matchedPropertiesCache.clear();
1599 } 1611 }
1600 1612
1601 void StyleResolver::notifyResizeForViewportUnits() { 1613 void StyleResolver::notifyResizeForViewportUnits() {
1602 m_matchedPropertiesCache.clearViewportDependent(); 1614 m_matchedPropertiesCache.clearViewportDependent();
1603 } 1615 }
1604 1616
1605 void StyleResolver::applyMatchedProperties(StyleResolverState& state, 1617 void StyleResolver::applyMatchedPropertiesAndCustomPropertyAnimations(
1606 const MatchResult& matchResult) { 1618 StyleResolverState& state,
1619 const MatchResult& matchResult,
1620 const Element* animatingElement) {
1621 CacheSuccess cacheSuccess = applyMatchedCache(state, matchResult);
1622 NeedsApplyPass needsApplyPass;
1623 if (!cacheSuccess.isFullCacheHit()) {
1624 applyCustomProperties(state, matchResult, false, cacheSuccess,
1625 needsApplyPass);
1626 applyMatchedAnimationProperties(state, matchResult, cacheSuccess,
1627 needsApplyPass);
1628 }
1629 if (state.style()->animations() ||
1630 (state.element() && state.element()->hasAnimations())) {
1631 calculateAnimationUpdate(state, animatingElement);
1632 if (state.isAnimatingCustomProperties()) {
1633 cacheSuccess.setFailed();
1634 applyCustomProperties(state, matchResult, true, cacheSuccess,
1635 needsApplyPass);
1636 }
1637 }
1638 if (!cacheSuccess.isFullCacheHit()) {
1639 applyMatchedStandardProperties(state, matchResult, cacheSuccess,
1640 needsApplyPass);
1641 }
1642 }
1643
1644 StyleResolver::CacheSuccess StyleResolver::applyMatchedCache(
1645 StyleResolverState& state,
1646 const MatchResult& matchResult) {
1607 const Element* element = state.element(); 1647 const Element* element = state.element();
1608 DCHECK(element); 1648 DCHECK(element);
1609 1649
1610 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), matchedPropertyApply,
1611 1);
1612
1613 unsigned cacheHash = 1650 unsigned cacheHash =
1614 matchResult.isCacheable() 1651 matchResult.isCacheable()
1615 ? computeMatchedPropertiesHash(matchResult.matchedProperties().data(), 1652 ? computeMatchedPropertiesHash(matchResult.matchedProperties().data(),
1616 matchResult.matchedProperties().size()) 1653 matchResult.matchedProperties().size())
1617 : 0; 1654 : 0;
1618 bool applyInheritedOnly = false; 1655 bool isInheritedCacheHit = false;
1656 bool isNonInheritedCacheHit = false;
1619 const CachedMatchedProperties* cachedMatchedProperties = 1657 const CachedMatchedProperties* cachedMatchedProperties =
1620 cacheHash 1658 cacheHash
1621 ? m_matchedPropertiesCache.find(cacheHash, state, 1659 ? m_matchedPropertiesCache.find(cacheHash, state,
1622 matchResult.matchedProperties()) 1660 matchResult.matchedProperties())
1623 : nullptr; 1661 : nullptr;
1624 1662
1625 if (cachedMatchedProperties && MatchedPropertiesCache::isCacheable(state)) { 1663 if (cachedMatchedProperties && MatchedPropertiesCache::isCacheable(state)) {
1626 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), 1664 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(),
1627 matchedPropertyCacheHit, 1); 1665 matchedPropertyCacheHit, 1);
1628 // We can build up the style by copying non-inherited properties from an 1666 // We can build up the style by copying non-inherited properties from an
(...skipping 15 matching lines...) Expand all
1644 // If the cache item parent style has identical inherited properties to 1682 // If the cache item parent style has identical inherited properties to
1645 // the current parent style then the resulting style will be identical 1683 // the current parent style then the resulting style will be identical
1646 // too. We copy the inherited properties over from the cache and are done. 1684 // too. We copy the inherited properties over from the cache and are done.
1647 state.style()->inheritFrom(*cachedMatchedProperties->computedStyle); 1685 state.style()->inheritFrom(*cachedMatchedProperties->computedStyle);
1648 1686
1649 // Unfortunately the link status is treated like an inherited property. We 1687 // Unfortunately the link status is treated like an inherited property. We
1650 // need to explicitly restore it. 1688 // need to explicitly restore it.
1651 state.style()->setInsideLink(linkStatus); 1689 state.style()->setInsideLink(linkStatus);
1652 1690
1653 updateFont(state); 1691 updateFont(state);
1692 isInheritedCacheHit = true;
1693 }
1654 1694
1655 return; 1695 isNonInheritedCacheHit = true;
1656 }
1657 applyInheritedOnly = true;
1658 } 1696 }
1659 1697
1660 NeedsApplyPass needsApplyPass; 1698 return CacheSuccess(isInheritedCacheHit, isNonInheritedCacheHit, cacheHash,
1699 cachedMatchedProperties);
1700 }
1661 1701
1662 // TODO(leviw): We need the proper bit for tracking whether we need to do this 1702 void StyleResolver::applyCustomProperties(StyleResolverState& state,
1663 // work. 1703 const MatchResult& matchResult,
1704 bool applyAnimations,
1705 const CacheSuccess& cacheSuccess,
1706 NeedsApplyPass& needsApplyPass) {
1707 DCHECK(!cacheSuccess.isFullCacheHit());
1708 bool applyInheritedOnly = cacheSuccess.shouldApplyInheritedOnly();
1709
1710 // TODO(leviw): We need the proper bit for tracking whether we need to do
1711 // this work.
1664 applyMatchedProperties<ResolveVariables, UpdateNeedsApplyPass>( 1712 applyMatchedProperties<ResolveVariables, UpdateNeedsApplyPass>(
1665 state, matchResult.authorRules(), false, applyInheritedOnly, 1713 state, matchResult.authorRules(), false, applyInheritedOnly,
1666 needsApplyPass); 1714 needsApplyPass);
1667 applyMatchedProperties<ResolveVariables, CheckNeedsApplyPass>( 1715 applyMatchedProperties<ResolveVariables, CheckNeedsApplyPass>(
1668 state, matchResult.authorRules(), true, applyInheritedOnly, 1716 state, matchResult.authorRules(), true, applyInheritedOnly,
1669 needsApplyPass); 1717 needsApplyPass);
1718 if (applyAnimations) {
1719 applyAnimatedProperties<ResolveVariables>(
1720 state, state.animationUpdate().activeInterpolationsForAnimations());
1721 }
1670 // TODO(leviw): stop recalculating every time 1722 // TODO(leviw): stop recalculating every time
1671 CSSVariableResolver::resolveVariableDefinitions(state); 1723 CSSVariableResolver::resolveVariableDefinitions(state);
1672 1724
1673 if (RuntimeEnabledFeatures::cssApplyAtRulesEnabled()) { 1725 if (RuntimeEnabledFeatures::cssApplyAtRulesEnabled()) {
1674 if (cacheCustomPropertiesForApplyAtRules(state, 1726 if (cacheCustomPropertiesForApplyAtRules(state,
1675 matchResult.authorRules())) { 1727 matchResult.authorRules())) {
1676 applyMatchedProperties<ResolveVariables, UpdateNeedsApplyPass>( 1728 applyMatchedProperties<ResolveVariables, UpdateNeedsApplyPass>(
1677 state, matchResult.authorRules(), false, applyInheritedOnly, 1729 state, matchResult.authorRules(), false, applyInheritedOnly,
1678 needsApplyPass); 1730 needsApplyPass);
1679 applyMatchedProperties<ResolveVariables, CheckNeedsApplyPass>( 1731 applyMatchedProperties<ResolveVariables, CheckNeedsApplyPass>(
1680 state, matchResult.authorRules(), true, applyInheritedOnly, 1732 state, matchResult.authorRules(), true, applyInheritedOnly,
1681 needsApplyPass); 1733 needsApplyPass);
1734 if (applyAnimations) {
1735 applyAnimatedProperties<ResolveVariables>(
1736 state, state.animationUpdate().activeInterpolationsForAnimations());
1737 }
1682 CSSVariableResolver::resolveVariableDefinitions(state); 1738 CSSVariableResolver::resolveVariableDefinitions(state);
1683 } 1739 }
1684 } 1740 }
1741 }
1685 1742
1686 // Apply animation affecting properties. 1743 void StyleResolver::applyMatchedAnimationProperties(
1744 StyleResolverState& state,
1745 const MatchResult& matchResult,
1746 const CacheSuccess& cacheSuccess,
1747 NeedsApplyPass& needsApplyPass) {
1748 DCHECK(!cacheSuccess.isFullCacheHit());
1749 bool applyInheritedOnly = cacheSuccess.shouldApplyInheritedOnly();
1750
1687 applyMatchedProperties<AnimationPropertyPriority, UpdateNeedsApplyPass>( 1751 applyMatchedProperties<AnimationPropertyPriority, UpdateNeedsApplyPass>(
1688 state, matchResult.allRules(), false, applyInheritedOnly, needsApplyPass); 1752 state, matchResult.allRules(), false, applyInheritedOnly, needsApplyPass);
1689 applyMatchedProperties<AnimationPropertyPriority, CheckNeedsApplyPass>( 1753 applyMatchedProperties<AnimationPropertyPriority, CheckNeedsApplyPass>(
1690 state, matchResult.allRules(), true, applyInheritedOnly, needsApplyPass); 1754 state, matchResult.allRules(), true, applyInheritedOnly, needsApplyPass);
1755 }
1756
1757 void StyleResolver::calculateAnimationUpdate(StyleResolverState& state,
1758 const Element* animatingElement) {
1759 Element* element = state.element();
1760 DCHECK(state.style()->animations() || (element && element->hasAnimations()));
1761
1762 CSSAnimations::calculateAnimationUpdate(
1763 state.animationUpdate(), animatingElement, *element, *state.style(),
1764 state.parentStyle(), this);
1765
1766 if (state.isAnimatingCustomProperties())
1767 return;
1768 for (const auto& propertyHandle :
1769 state.animationUpdate().activeInterpolationsForAnimations().keys()) {
1770 if (CSSAnimations::isCustomPropertyHandle(propertyHandle)) {
1771 state.setIsAnimatingCustomProperties(true);
1772 return;
1773 }
1774 }
1775 }
1776
1777 void StyleResolver::applyMatchedStandardProperties(
1778 StyleResolverState& state,
1779 const MatchResult& matchResult,
1780 const CacheSuccess& cacheSuccess,
1781 NeedsApplyPass& needsApplyPass) {
1782 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), matchedPropertyApply,
1783 1);
1784
1785 DCHECK(!cacheSuccess.isFullCacheHit());
1786 bool applyInheritedOnly = cacheSuccess.shouldApplyInheritedOnly();
1691 1787
1692 // Now we have all of the matched rules in the appropriate order. Walk the 1788 // Now we have all of the matched rules in the appropriate order. Walk the
1693 // rules and apply high-priority properties first, i.e., those properties that 1789 // rules and apply high-priority properties first, i.e., those properties that
1694 // other properties depend on. The order is (1) high-priority not important, 1790 // other properties depend on. The order is (1) high-priority not important,
1695 // (2) high-priority important, (3) normal not important and (4) normal 1791 // (2) high-priority important, (3) normal not important and (4) normal
1696 // important. 1792 // important.
1697 applyMatchedProperties<HighPropertyPriority, CheckNeedsApplyPass>( 1793 applyMatchedProperties<HighPropertyPriority, CheckNeedsApplyPass>(
1698 state, matchResult.allRules(), false, applyInheritedOnly, needsApplyPass); 1794 state, matchResult.allRules(), false, applyInheritedOnly, needsApplyPass);
1699 for (auto range : ImportantAuthorRanges(matchResult)) { 1795 for (auto range : ImportantAuthorRanges(matchResult)) {
1700 applyMatchedProperties<HighPropertyPriority, CheckNeedsApplyPass>( 1796 applyMatchedProperties<HighPropertyPriority, CheckNeedsApplyPass>(
1701 state, range, true, applyInheritedOnly, needsApplyPass); 1797 state, range, true, applyInheritedOnly, needsApplyPass);
1702 } 1798 }
1703 applyMatchedProperties<HighPropertyPriority, CheckNeedsApplyPass>( 1799 applyMatchedProperties<HighPropertyPriority, CheckNeedsApplyPass>(
1704 state, matchResult.uaRules(), true, applyInheritedOnly, needsApplyPass); 1800 state, matchResult.uaRules(), true, applyInheritedOnly, needsApplyPass);
1705 1801
1706 if (UNLIKELY(isSVGForeignObjectElement(element))) { 1802 if (UNLIKELY(isSVGForeignObjectElement(state.element()))) {
1707 // LayoutSVGRoot handles zooming for the whole SVG subtree, so foreignObject 1803 // LayoutSVGRoot handles zooming for the whole SVG subtree, so foreignObject
1708 // content should not be scaled again. 1804 // content should not be scaled again.
1709 // 1805 //
1710 // FIXME: The following hijacks the zoom property for foreignObject so that 1806 // FIXME: The following hijacks the zoom property for foreignObject so that
1711 // children of foreignObject get the correct font-size in case of zooming. 1807 // children of foreignObject get the correct font-size in case of zooming.
1712 // 'zoom' has HighPropertyPriority, along with other font-related properties 1808 // 'zoom' has HighPropertyPriority, along with other font-related properties
1713 // used as input to the FontBuilder, so resetting it here may cause the 1809 // used as input to the FontBuilder, so resetting it here may cause the
1714 // FontBuilder to recompute the font used as inheritable font for 1810 // FontBuilder to recompute the font used as inheritable font for
1715 // foreignObject content. If we want to support zoom on foreignObject we'll 1811 // foreignObject content. If we want to support zoom on foreignObject we'll
1716 // need to find another way of handling the SVG zoom model. 1812 // need to find another way of handling the SVG zoom model.
1717 state.setEffectiveZoom(ComputedStyle::initialZoom()); 1813 state.setEffectiveZoom(ComputedStyle::initialZoom());
1718 } 1814 }
1719 1815
1720 if (cachedMatchedProperties && 1816 if (cacheSuccess.cachedMatchedProperties &&
1721 cachedMatchedProperties->computedStyle->effectiveZoom() != 1817 cacheSuccess.cachedMatchedProperties->computedStyle->effectiveZoom() !=
1722 state.style()->effectiveZoom()) { 1818 state.style()->effectiveZoom()) {
1723 state.fontBuilder().didChangeEffectiveZoom(); 1819 state.fontBuilder().didChangeEffectiveZoom();
1724 applyInheritedOnly = false; 1820 applyInheritedOnly = false;
1725 } 1821 }
1726 1822
1727 // If our font got dirtied, go ahead and update it now. 1823 // If our font got dirtied, go ahead and update it now.
1728 updateFont(state); 1824 updateFont(state);
1729 1825
1730 // Many properties depend on the font. If it changes we just apply all 1826 // Many properties depend on the font. If it changes we just apply all
1731 // properties. 1827 // properties.
1732 if (cachedMatchedProperties && 1828 if (cacheSuccess.cachedMatchedProperties &&
1733 cachedMatchedProperties->computedStyle->getFontDescription() != 1829 cacheSuccess.cachedMatchedProperties->computedStyle
1734 state.style()->getFontDescription()) 1830 ->getFontDescription() != state.style()->getFontDescription())
1735 applyInheritedOnly = false; 1831 applyInheritedOnly = false;
1736 1832
1737 // Registered custom properties are computed after high priority properties. 1833 // Registered custom properties are computed after high priority properties.
1738 CSSVariableResolver::computeRegisteredVariables(state); 1834 CSSVariableResolver::computeRegisteredVariables(state);
1739 1835
1740 // Now do the normal priority UA properties. 1836 // Now do the normal priority UA properties.
1741 applyMatchedProperties<LowPropertyPriority, CheckNeedsApplyPass>( 1837 applyMatchedProperties<LowPropertyPriority, CheckNeedsApplyPass>(
1742 state, matchResult.uaRules(), false, applyInheritedOnly, needsApplyPass); 1838 state, matchResult.uaRules(), false, applyInheritedOnly, needsApplyPass);
1743 1839
1744 // Cache the UA properties to pass them to LayoutTheme in adjustComputedStyle. 1840 // Cache the UA properties to pass them to LayoutTheme in adjustComputedStyle.
(...skipping 16 matching lines...) Expand all
1761 // ones. When there is a partial match in the MatchedPropertiesCache, these 1857 // ones. When there is a partial match in the MatchedPropertiesCache, these
1762 // flags will already be set correctly and the value stored in 1858 // flags will already be set correctly and the value stored in
1763 // cacheUserAgentBorderAndBackground is incorrect, so doing this check again 1859 // cacheUserAgentBorderAndBackground is incorrect, so doing this check again
1764 // would give the wrong answer. 1860 // would give the wrong answer.
1765 state.style()->setHasAuthorBackground(hasAuthorBackground(state)); 1861 state.style()->setHasAuthorBackground(hasAuthorBackground(state));
1766 state.style()->setHasAuthorBorder(hasAuthorBorder(state)); 1862 state.style()->setHasAuthorBorder(hasAuthorBorder(state));
1767 } 1863 }
1768 1864
1769 loadPendingResources(state); 1865 loadPendingResources(state);
1770 1866
1771 if (!cachedMatchedProperties && cacheHash && 1867 if (!state.isAnimatingCustomProperties() &&
1868 !cacheSuccess.cachedMatchedProperties && cacheSuccess.cacheHash &&
1772 MatchedPropertiesCache::isCacheable(state)) { 1869 MatchedPropertiesCache::isCacheable(state)) {
1773 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), 1870 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(),
1774 matchedPropertyCacheAdded, 1); 1871 matchedPropertyCacheAdded, 1);
1775 m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), 1872 m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(),
1776 cacheHash, matchResult.matchedProperties()); 1873 cacheSuccess.cacheHash,
1874 matchResult.matchedProperties());
1777 } 1875 }
1778 1876
1779 DCHECK(!state.fontBuilder().fontDirty()); 1877 DCHECK(!state.fontBuilder().fontDirty());
1780 } 1878 }
1781 1879
1782 bool StyleResolver::hasAuthorBackground(const StyleResolverState& state) { 1880 bool StyleResolver::hasAuthorBackground(const StyleResolverState& state) {
1783 const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); 1881 const CachedUAStyle* cachedUAStyle = state.cachedUAStyle();
1784 if (!cachedUAStyle) 1882 if (!cachedUAStyle)
1785 return false; 1883 return false;
1786 1884
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 visitor->trace(m_viewportDependentMediaQueryResults); 1981 visitor->trace(m_viewportDependentMediaQueryResults);
1884 visitor->trace(m_deviceDependentMediaQueryResults); 1982 visitor->trace(m_deviceDependentMediaQueryResults);
1885 visitor->trace(m_selectorFilter); 1983 visitor->trace(m_selectorFilter);
1886 visitor->trace(m_styleSharingLists); 1984 visitor->trace(m_styleSharingLists);
1887 visitor->trace(m_pendingStyleSheets); 1985 visitor->trace(m_pendingStyleSheets);
1888 visitor->trace(m_document); 1986 visitor->trace(m_document);
1889 visitor->trace(m_tracker); 1987 visitor->trace(m_tracker);
1890 } 1988 }
1891 1989
1892 } // namespace blink 1990 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698