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

Unified Diff: Source/core/css/RuleFeature.cpp

Issue 185293011: Don't use RenderStyle::clone unless there is actually a RenderObject to attach the cloned style to. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Again. Created 6 years, 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/RuleFeature.cpp
diff --git a/Source/core/css/RuleFeature.cpp b/Source/core/css/RuleFeature.cpp
index a8df5fbbf23489e113dc80a03e65bd146958f110..fef21f20cfb46405eaab71ab95d40ab6ee9521c6 100644
--- a/Source/core/css/RuleFeature.cpp
+++ b/Source/core/css/RuleFeature.cpp
@@ -432,9 +432,16 @@ bool RuleFeatureSet::invalidateStyleForClassChange(Element* element, Vector<Atom
if (thisElementNeedsStyleRecalc) {
element->setNeedsStyleRecalc(LocalStyleChange);
} else if (foundInvalidationSet && someChildrenNeedStyleRecalc) {
- // Clone the RenderStyle in order to preserve correct style sharing.
- if (RenderStyle* renderStyle = element->renderStyle())
- element->renderer()->setStyle(RenderStyle::clone(renderStyle));
+ // Clone the RenderStyle in order to preserve correct style sharing, if possible. Otherwise recalc style.
+ bool clonedStyle = false;
+ if (RenderObject* renderer = element->renderer()) {
+ if (RenderStyle* renderStyle = renderer->style()) {
esprehn 2014/03/03 21:43:52 If you have a renderer you must have a style, this
chrishtr 2014/03/03 21:53:37 Done.
+ renderer->setStyleInternal(RenderStyle::clone(renderStyle));
+ clonedStyle = true;
+ }
+ }
+ if (!clonedStyle)
+ element->setNeedsStyleRecalc(LocalStyleChange);
}
invalidationClasses.remove(oldSize, invalidationClasses.size() - oldSize);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698