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

Unified Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 5216392399814656: Clear StyleResolverState after each resolve. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/css/resolver/StyleResolverState.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/StyleResolver.cpp
diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp
index 74409ec01cca1d9e8d8e58d4e13f5fa4704dd5e1..48eb2c104c505b53690a2502f3ad32edd1aad715 100644
--- a/Source/core/css/resolver/StyleResolver.cpp
+++ b/Source/core/css/resolver/StyleResolver.cpp
@@ -1015,10 +1015,10 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
StyleResolverState& state = m_state;
state.initForStyleResolve(document(), element, defaultParent, regionForStyling);
if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoint()) {
- RenderStyle* sharedStyle = locateSharedStyle();
+ RefPtr<RenderStyle> sharedStyle = locateSharedStyle();
if (sharedStyle) {
state.clear();
- return sharedStyle;
+ return sharedStyle.release();
}
}
@@ -1069,15 +1069,13 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
// Clean up our style object's display and text decorations (among other fixups).
adjustRenderStyle(state.style(), state.parentStyle(), element);
- state.clear(); // Clear out for the next resolve.
-
document()->didAccessStyleResolver();
if (element->hasTagName(bodyTag))
document()->textLinkColors().setTextColor(state.style()->visitedDependentColor(CSSPropertyColor));
- // Now return the style.
- return state.takeStyle();
+ // Now return the style and clear out for the next resolve.
+ return state.takeStyleAndClear();
}
PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(const RenderStyle* elementStyle, const StyleKeyframe* keyframe, KeyframeValue& keyframeValue)
@@ -1194,6 +1192,7 @@ void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle* el
keyframeValue.setStyle(styleForKeyframe(elementStyle, hundredPercentKeyframe, keyframeValue));
list.insert(keyframeValue);
}
+ m_state.clear();
}
PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* e, const PseudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle)
@@ -1227,8 +1226,10 @@ PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* e, const P
matchAuthorRules(collector, false);
}
- if (collector.matchedResult().matchedProperties.isEmpty())
+ if (collector.matchedResult().matchedProperties.isEmpty()) {
+ state.clear();
Jeffrey Yasskin 2013/07/11 21:24:05 This .clear() on an early return is a good sign th
return 0;
+ }
state.style()->setStyleType(pseudoStyleRequest.pseudoId);
@@ -1243,7 +1244,7 @@ PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* e, const P
document()->didAccessStyleResolver();
// Now return the style.
- return state.takeStyle();
+ return state.takeStyleAndClear();
}
PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
@@ -1283,7 +1284,7 @@ PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
document()->didAccessStyleResolver();
// Now return the style.
- return m_state.takeStyle();
+ return m_state.takeStyleAndClear();
}
PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement()
@@ -1726,6 +1727,7 @@ PassRefPtr<CSSRuleList> StyleResolver::pseudoStyleRulesForElement(Element* e, Ps
matchAuthorRules(collector, rulesToInclude & EmptyCSSRules);
}
+ m_state.clear();
return collector.matchedRuleList();
}
@@ -2054,6 +2056,7 @@ void StyleResolver::applyPropertyToStyle(CSSPropertyID id, CSSValue* value, Rend
m_state.initForStyleResolve(document(), 0, style);
m_state.setStyle(style);
applyPropertyToCurrentStyle(id, value);
+ m_state.clear();
}
void StyleResolver::applyPropertyToCurrentStyle(CSSPropertyID id, CSSValue* value)
« no previous file with comments | « no previous file | Source/core/css/resolver/StyleResolverState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698