Chromium Code Reviews| Index: Source/core/css/resolver/StyleResolver.cpp |
| diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp |
| index 57f33842d5b36cd49c3ec1a293008548b1376e85..10f0688ec2ffff2911d6cf9de39920a575e08e52 100644 |
| --- a/Source/core/css/resolver/StyleResolver.cpp |
| +++ b/Source/core/css/resolver/StyleResolver.cpp |
| @@ -408,6 +408,7 @@ void StyleResolver::matchUARules(ElementRuleCollector& collector) |
| if (document().isViewSource()) |
| matchRuleSet(collector, defaultStyleSheets.defaultViewSourceStyle()); |
| + collector.uaRulesFinished(); |
| collector.setMatchingUARules(false); |
| } |
| @@ -454,6 +455,8 @@ void StyleResolver::matchAllRules(StyleResolverState& state, ElementRuleCollecto |
| if (includeSMILProperties && state.element()->isSVGElement()) |
| collector.addElementStyleProperties(toSVGElement(state.element())->animatedSMILStyleProperties(), false /* isCacheable */); |
| } |
| + |
| + collector.authorScopeFinished(); |
| } |
| PassRefPtr<ComputedStyle> StyleResolver::styleForDocument(Document& document) |
| @@ -749,7 +752,7 @@ bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo |
| matchUARules(collector); |
| matchAuthorRules(state.element(), collector, false); |
| - if (collector.matchedResult().matchedProperties.isEmpty()) |
| + if (!collector.matchedResult().hasMatchedProperties()) |
| return false; |
| applyMatchedProperties(state, collector.matchedResult()); |
| @@ -822,12 +825,12 @@ PassRefPtr<ComputedStyle> StyleResolver::styleForPage(int pageIndex) |
| bool inheritedOnly = false; |
| const MatchResult& result = collector.matchedResult(); |
| - applyMatchedProperties<HighPropertyPriority>(state, result, false, result.begin(), result.end(), inheritedOnly); |
| + applyMatchedProperties<HighPropertyPriority>(state, result.allRules(), false, inheritedOnly); |
| // If our font got dirtied, go ahead and update it now. |
| updateFont(state); |
| - applyMatchedProperties<LowPropertyPriority>(state, result, false, result.begin(), result.end(), inheritedOnly); |
| + applyMatchedProperties<LowPropertyPriority>(state, result.allRules(), false, inheritedOnly); |
| loadPendingResources(state); |
| @@ -1225,16 +1228,13 @@ void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper |
| } |
| template <CSSPropertyPriority priority> |
| -void StyleResolver::applyMatchedProperties(StyleResolverState& state, const MatchResult& matchResult, bool isImportant, unsigned startIndex, unsigned endIndex, bool inheritedOnly) |
| +void StyleResolver::applyMatchedProperties(StyleResolverState& state, const MatchedPropertiesRange& range, bool isImportant, bool inheritedOnly) |
| { |
| - if (startIndex == endIndex) |
| + if (range.begin() == range.end()) |
|
kochi
2015/08/11 11:07:35
Maybe we can have isEmpty() for MatchedPropertiesR
rune
2015/08/12 01:13:26
Done.
|
| return; |
| - ASSERT_WITH_SECURITY_IMPLICATION(endIndex <= matchResult.matchedProperties.size()); |
| - |
| if (state.style()->insideLink() != NotInsideLink) { |
| - for (unsigned i = startIndex; i < endIndex; ++i) { |
| - const MatchedProperties& matchedProperties = matchResult.matchedProperties[i]; |
| + for (const auto& matchedProperties : range) { |
| unsigned linkMatchType = matchedProperties.m_types.linkMatchType; |
| // FIXME: It would be nicer to pass these as arguments but that requires changes in many places. |
| state.setApplyPropertyToRegularStyle(linkMatchType & CSSSelector::MatchLink); |
| @@ -1246,10 +1246,8 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc |
| state.setApplyPropertyToVisitedLinkStyle(false); |
| return; |
| } |
| - for (unsigned i = startIndex; i < endIndex; ++i) { |
| - const MatchedProperties& matchedProperties = matchResult.matchedProperties[i]; |
| + for (const auto& matchedProperties : range) |
| applyProperties<priority>(state, matchedProperties.properties.get(), isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.m_types.whitelistType)); |
| - } |
| } |
| static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties, unsigned size) |
| @@ -1275,9 +1273,9 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc |
| INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyApply, 1); |
| - unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash(matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0; |
| + unsigned cacheHash = matchResult.isCacheable() ? computeMatchedPropertiesHash(matchResult.matchedProperties().data(), matchResult.matchedProperties().size()) : 0; |
| bool applyInheritedOnly = false; |
| - const CachedMatchedProperties* cachedMatchedProperties = cacheHash ? m_matchedPropertiesCache.find(cacheHash, state, matchResult) : 0; |
| + const CachedMatchedProperties* cachedMatchedProperties = cacheHash ? m_matchedPropertiesCache.find(cacheHash, state, matchResult.matchedProperties()) : 0; |
| if (cachedMatchedProperties && MatchedPropertiesCache::isCacheable(element, *state.style(), *state.parentStyle())) { |
| INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheHit, 1); |
| @@ -1308,9 +1306,10 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc |
| // high-priority properties first, i.e., those properties that other properties depend on. |
| // The order is (1) high-priority not important, (2) high-priority important, (3) normal not important |
| // and (4) normal important. |
| - applyMatchedProperties<HighPropertyPriority>(state, matchResult, false, matchResult.begin(), matchResult.end(), applyInheritedOnly); |
| - applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, matchResult.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly); |
| - applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, matchResult.beginUA(), matchResult.endUA(), applyInheritedOnly); |
| + applyMatchedProperties<HighPropertyPriority>(state, matchResult.allRules(), false, applyInheritedOnly); |
| + for (auto range : ImportantAuthorRanges(matchResult)) |
| + applyMatchedProperties<HighPropertyPriority>(state, range, true, applyInheritedOnly); |
| + applyMatchedProperties<HighPropertyPriority>(state, matchResult.uaRules(), true, applyInheritedOnly); |
| if (UNLIKELY(isSVGForeignObjectElement(element))) { |
| // LayoutSVGRoot handles zooming for the whole SVG subtree, so foreignObject content should not be scaled again. |
| @@ -1336,21 +1335,22 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc |
| applyInheritedOnly = false; |
| // Now do the normal priority UA properties. |
| - applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, matchResult.beginUA(), matchResult.endUA(), applyInheritedOnly); |
| + applyMatchedProperties<LowPropertyPriority>(state, matchResult.uaRules(), false, applyInheritedOnly); |
| // Cache the UA properties to pass them to LayoutTheme in adjustComputedStyle. |
| state.cacheUserAgentBorderAndBackground(); |
| // Now do the author and user normal priority properties and all the !important properties. |
| - applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, matchResult.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly); |
| - applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchResult.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly); |
| - applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchResult.beginUA(), matchResult.endUA(), applyInheritedOnly); |
| + applyMatchedProperties<LowPropertyPriority>(state, matchResult.authorRules(), false, applyInheritedOnly); |
| + for (auto range : ImportantAuthorRanges(matchResult)) |
| + applyMatchedProperties<LowPropertyPriority>(state, range, true, applyInheritedOnly); |
| + applyMatchedProperties<LowPropertyPriority>(state, matchResult.uaRules(), true, applyInheritedOnly); |
| loadPendingResources(state); |
| if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCacheable(element, *state.style(), *state.parentStyle())) { |
| INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded, 1); |
| - m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), cacheHash, matchResult); |
| + m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), cacheHash, matchResult.matchedProperties()); |
| } |
| ASSERT(!state.fontBuilder().fontDirty()); |