Index: third_party/WebKit/Source/core/dom/Element.cpp |
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp |
index 1e9ac996a103133d46428a7536e41ccbf27841a7..f700da982f18721c604bc5e07461e27f4384b8fc 100644 |
--- a/third_party/WebKit/Source/core/dom/Element.cpp |
+++ b/third_party/WebKit/Source/core/dom/Element.cpp |
@@ -1556,7 +1556,8 @@ void Element::attachLayoutTree(const AttachContext& context) |
// need to clear any state that's been added since then. |
if (hasRareData() && getStyleChangeType() == NeedsReattachStyleChange) { |
ElementRareData* data = elementRareData(); |
- data->clearComputedStyle(); |
+ if (!data->layoutObject()) |
+ data->clearComputedStyle(); |
} |
if (!isSlotOrActiveInsertionPoint()) |
@@ -1601,7 +1602,7 @@ void Element::detachLayoutTree(const AttachContext& context) |
data->clearPseudoElements(); |
// attachLayoutTree() will clear the computed style for us when inside recalcStyle. |
- if (!document().inStyleRecalc()) |
+ if (!document().inStyleRecalc() && !data->layoutObject()) |
data->clearComputedStyle(); |
if (ElementAnimations* elementAnimations = data->elementAnimations()) { |