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 75a480c3d6d890defa7fb5bd4d0483c22440185c..5684d6e9762706eed2528a6c3177256cb12639bd 100644 |
| --- a/Source/core/css/resolver/StyleResolver.cpp |
| +++ b/Source/core/css/resolver/StyleResolver.cpp |
| @@ -530,32 +530,10 @@ PassRefPtr<ComputedStyle> StyleResolver::styleForDocument(Document& document) |
| return documentStyle.release(); |
| } |
| -AuthorStyleInfo StyleResolver::authorStyleInfo(StyleResolverState& state) |
| -{ |
| - const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); |
| - |
| - if (!cachedUAStyle) |
| - return AuthorStyleInfo(); |
| - |
| - // Exclude background-repeat from comparison by resetting it. |
| - FillLayer backgroundCopy = cachedUAStyle->backgroundLayers; |
| - FillLayer backgroundLayersCopy = state.style()->backgroundLayers(); |
| - backgroundCopy.setRepeatX(NoRepeatFill); |
| - backgroundCopy.setRepeatY(NoRepeatFill); |
| - backgroundLayersCopy.setRepeatX(NoRepeatFill); |
| - backgroundLayersCopy.setRepeatY(NoRepeatFill); |
| - |
| - bool backgroundChanged = backgroundLayersCopy != backgroundCopy |
| - || state.style()->backgroundColor() != cachedUAStyle->backgroundColor; |
| - bool borderChanged = state.style()->border() != cachedUAStyle->border; |
| - |
| - return AuthorStyleInfo(backgroundChanged, borderChanged); |
| -} |
| - |
| void StyleResolver::adjustComputedStyle(StyleResolverState& state, Element* element) |
| { |
| StyleAdjuster adjuster(document().inQuirksMode()); |
| - adjuster.adjustComputedStyle(state.mutableStyleRef(), *state.parentStyle(), element, authorStyleInfo(state)); |
| + adjuster.adjustComputedStyle(state.mutableStyleRef(), *state.parentStyle(), element); |
| } |
| // Start loading resources referenced by this style. |
| @@ -1415,6 +1393,17 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc |
| applyMatchedProperties<LowPropertyPriority>(state, range, true, applyInheritedOnly); |
| applyMatchedProperties<LowPropertyPriority>(state, matchResult.uaRules(), true, applyInheritedOnly); |
| + if (state.style()->hasAppearance() && !applyInheritedOnly) { |
| + // Check whether the final border and background differs from the cached UA ones. |
| + // When there is a partial match in the MatchedPropertiesCache, the non-inherited values are copied from |
|
Timothy Loh
2015/08/25 08:08:20
This comment took me a couple of reads to get, may
meade_UTC10
2015/08/25 08:22:51
The comment about what happens in cacheUserAgentBo
|
| + // the cache, and cacheUserAgentBorderAndBackground caches those. In that case, hasAuthorBackground/Border |
| + // compares the final style with itself and returns the wrong result, but |
| + // state.style().hasAuthorBackground has already been calculated and cached, so it's ok not to do this |
| + // check again. |
| + state.style()->setHasAuthorBackground(hasAuthorBackground(state)); |
| + state.style()->setHasAuthorBorder(hasAuthorBorder(state)); |
| + } |
| + |
| loadPendingResources(state); |
| if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCacheable(element, *state.style(), *state.parentStyle())) { |
| @@ -1425,6 +1414,29 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc |
| ASSERT(!state.fontBuilder().fontDirty()); |
| } |
| +bool StyleResolver::hasAuthorBackground(const StyleResolverState& state) |
| +{ |
| + const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); |
| + if (!cachedUAStyle) |
| + return false; |
| + |
| + FillLayer oldFill = cachedUAStyle->backgroundLayers; |
| + FillLayer newFill = state.style()->backgroundLayers(); |
| + // Exclude background-repeat from comparison by resetting it. |
| + oldFill.setRepeatX(NoRepeatFill); |
| + oldFill.setRepeatY(NoRepeatFill); |
| + newFill.setRepeatX(NoRepeatFill); |
| + newFill.setRepeatY(NoRepeatFill); |
| + |
| + return (oldFill != newFill || cachedUAStyle->backgroundColor != state.style()->backgroundColor()); |
| +} |
| + |
| +bool StyleResolver::hasAuthorBorder(const StyleResolverState& state) |
| +{ |
| + const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); |
| + return cachedUAStyle && (cachedUAStyle->border != state.style()->border()); |
| +} |
| + |
| void StyleResolver::applyCallbackSelectors(StyleResolverState& state) |
| { |
| if (!m_watchedSelectorsRules) |