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. | 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 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 unsigned linkMatchType = matchedProperties.m_types.linkMatchType; | 1543 unsigned linkMatchType = matchedProperties.m_types.linkMatchType; |
1544 // FIXME: It would be nicer to pass these as arguments but that requires | 1544 // FIXME: It would be nicer to pass these as arguments but that requires |
1545 // changes in many places. | 1545 // changes in many places. |
1546 state.setApplyPropertyToRegularStyle(linkMatchType & | 1546 state.setApplyPropertyToRegularStyle(linkMatchType & |
1547 CSSSelector::MatchLink); | 1547 CSSSelector::MatchLink); |
1548 state.setApplyPropertyToVisitedLinkStyle(linkMatchType & | 1548 state.setApplyPropertyToVisitedLinkStyle(linkMatchType & |
1549 CSSSelector::MatchVisited); | 1549 CSSSelector::MatchVisited); |
1550 | 1550 |
1551 applyProperties<priority, shouldUpdateNeedsApplyPass>( | 1551 applyProperties<priority, shouldUpdateNeedsApplyPass>( |
1552 state, matchedProperties.properties.get(), isImportant, inheritedOnly, | 1552 state, matchedProperties.properties.get(), isImportant, inheritedOnly, |
1553 needsApplyPass, static_cast<PropertyWhitelistType>( | 1553 needsApplyPass, |
1554 matchedProperties.m_types.whitelistType)); | 1554 static_cast<PropertyWhitelistType>( |
| 1555 matchedProperties.m_types.whitelistType)); |
1555 } | 1556 } |
1556 state.setApplyPropertyToRegularStyle(true); | 1557 state.setApplyPropertyToRegularStyle(true); |
1557 state.setApplyPropertyToVisitedLinkStyle(false); | 1558 state.setApplyPropertyToVisitedLinkStyle(false); |
1558 return; | 1559 return; |
1559 } | 1560 } |
1560 for (const auto& matchedProperties : range) { | 1561 for (const auto& matchedProperties : range) { |
1561 applyProperties<priority, shouldUpdateNeedsApplyPass>( | 1562 applyProperties<priority, shouldUpdateNeedsApplyPass>( |
1562 state, matchedProperties.properties.get(), isImportant, inheritedOnly, | 1563 state, matchedProperties.properties.get(), isImportant, inheritedOnly, |
1563 needsApplyPass, static_cast<PropertyWhitelistType>( | 1564 needsApplyPass, |
1564 matchedProperties.m_types.whitelistType)); | 1565 static_cast<PropertyWhitelistType>( |
| 1566 matchedProperties.m_types.whitelistType)); |
1565 } | 1567 } |
1566 } | 1568 } |
1567 | 1569 |
1568 static unsigned computeMatchedPropertiesHash( | 1570 static unsigned computeMatchedPropertiesHash( |
1569 const MatchedProperties* properties, | 1571 const MatchedProperties* properties, |
1570 unsigned size) { | 1572 unsigned size) { |
1571 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size); | 1573 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size); |
1572 } | 1574 } |
1573 | 1575 |
1574 void StyleResolver::invalidateMatchedPropertiesCache() { | 1576 void StyleResolver::invalidateMatchedPropertiesCache() { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1620 DCHECK(element); | 1622 DCHECK(element); |
1621 | 1623 |
1622 unsigned cacheHash = | 1624 unsigned cacheHash = |
1623 matchResult.isCacheable() | 1625 matchResult.isCacheable() |
1624 ? computeMatchedPropertiesHash(matchResult.matchedProperties().data(), | 1626 ? computeMatchedPropertiesHash(matchResult.matchedProperties().data(), |
1625 matchResult.matchedProperties().size()) | 1627 matchResult.matchedProperties().size()) |
1626 : 0; | 1628 : 0; |
1627 bool isInheritedCacheHit = false; | 1629 bool isInheritedCacheHit = false; |
1628 bool isNonInheritedCacheHit = false; | 1630 bool isNonInheritedCacheHit = false; |
1629 const CachedMatchedProperties* cachedMatchedProperties = | 1631 const CachedMatchedProperties* cachedMatchedProperties = |
1630 cacheHash | 1632 cacheHash ? m_matchedPropertiesCache.find(cacheHash, state, |
1631 ? m_matchedPropertiesCache.find(cacheHash, state, | 1633 matchResult.matchedProperties()) |
1632 matchResult.matchedProperties()) | 1634 : nullptr; |
1633 : nullptr; | |
1634 | 1635 |
1635 if (cachedMatchedProperties && MatchedPropertiesCache::isCacheable(state)) { | 1636 if (cachedMatchedProperties && MatchedPropertiesCache::isCacheable(state)) { |
1636 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), | 1637 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), |
1637 matchedPropertyCacheHit, 1); | 1638 matchedPropertyCacheHit, 1); |
1638 // We can build up the style by copying non-inherited properties from an | 1639 // We can build up the style by copying non-inherited properties from an |
1639 // earlier style object built using the same exact style declarations. We | 1640 // earlier style object built using the same exact style declarations. We |
1640 // then only need to apply the inherited properties, if any, as their values | 1641 // then only need to apply the inherited properties, if any, as their values |
1641 // can depend on the element context. This is fast and saves memory by | 1642 // can depend on the element context. This is fast and saves memory by |
1642 // reusing the style data structures. | 1643 // reusing the style data structures. |
1643 state.style()->copyNonInheritedFromCached( | 1644 state.style()->copyNonInheritedFromCached( |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 | 1933 |
1933 DEFINE_TRACE(StyleResolver) { | 1934 DEFINE_TRACE(StyleResolver) { |
1934 visitor->trace(m_matchedPropertiesCache); | 1935 visitor->trace(m_matchedPropertiesCache); |
1935 visitor->trace(m_selectorFilter); | 1936 visitor->trace(m_selectorFilter); |
1936 visitor->trace(m_styleSharingLists); | 1937 visitor->trace(m_styleSharingLists); |
1937 visitor->trace(m_document); | 1938 visitor->trace(m_document); |
1938 visitor->trace(m_tracker); | 1939 visitor->trace(m_tracker); |
1939 } | 1940 } |
1940 | 1941 |
1941 } // namespace blink | 1942 } // namespace blink |
OLD | NEW |