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

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

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

Powered by Google App Engine
This is Rietveld 408576698