Index: Source/core/dom/Element.cpp |
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp |
index 99f551cac537fec26ae004c9aca77f719996b589..31e3497a5e398a207bba526cb48df8d9df3634e9 100644 |
--- a/Source/core/dom/Element.cpp |
+++ b/Source/core/dom/Element.cpp |
@@ -109,30 +109,20 @@ using namespace XMLNames; |
class StyleResolverParentPusher { |
public: |
- explicit StyleResolverParentPusher(Element& parent) |
+ StyleResolverParentPusher(Element& parent, StyleRecalcChange change = NoChange) |
leviw_travelin_and_unemployed
2013/11/11 18:56:15
Since the 2nd argument isn't required, are you sur
|
: m_parent(parent) |
, m_pushedStyleResolver(0) |
{ |
+ if ((change >= Inherit || parent.childNeedsStyleRecalc()) && (parent.hasChildNodes() || parent.youngestShadowRoot())) { |
+ m_pushedStyleResolver = m_parent.document().styleResolver(); |
+ m_pushedStyleResolver->pushParentElement(m_parent); |
+ } |
} |
- void push() |
- { |
- if (m_pushedStyleResolver) |
- return; |
- m_pushedStyleResolver = m_parent.document().styleResolver(); |
- m_pushedStyleResolver->pushParentElement(m_parent); |
- } |
+ |
~StyleResolverParentPusher() |
{ |
- |
if (!m_pushedStyleResolver) |
return; |
- |
- // This tells us that our pushed style selector is in a bad state, |
- // so we should just bail out in that scenario. |
- ASSERT(m_pushedStyleResolver == m_parent.document().styleResolver()); |
- if (m_pushedStyleResolver != m_parent.document().styleResolver()) |
- return; |
- |
m_pushedStyleResolver->popParentElement(m_parent); |
} |
@@ -1359,8 +1349,6 @@ void Element::attach(const AttachContext& context) |
{ |
ASSERT(document().inStyleRecalc()); |
- StyleResolverParentPusher parentPusher(*this); |
- |
// We've already been through detach when doing a lazyAttach, but we might |
// need to clear any state that's been added since then. |
if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) { |
@@ -1376,14 +1364,13 @@ void Element::attach(const AttachContext& context) |
if (RenderStyle* style = renderStyle()) |
updateCallbackSelectors(0, style); |
+ StyleResolverParentPusher pushParent(*this); |
+ |
createPseudoElementIfNeeded(BEFORE); |
// When a shadow root exists, it does the work of attaching the children. |
- if (ElementShadow* shadow = this->shadow()) { |
- parentPusher.push(); |
+ if (ElementShadow* shadow = this->shadow()) |
shadow->attach(context); |
- } else if (firstChild()) |
- parentPusher.push(); |
ContainerNode::attach(context); |
@@ -1591,13 +1578,11 @@ void Element::recalcChildStyle(StyleRecalcChange change) |
ASSERT(change >= Inherit || childNeedsStyleRecalc()); |
ASSERT(!needsStyleRecalc()); |
- StyleResolverParentPusher parentPusher(*this); |
+ StyleResolverParentPusher pushParent(*this, change); |
for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) { |
- if (shouldRecalcStyle(change, root)) { |
- parentPusher.push(); |
+ if (shouldRecalcStyle(change, root)) |
root->recalcStyle(change); |
- } |
} |
if (shouldRecalcStyle(change, this)) |
@@ -1618,12 +1603,10 @@ void Element::recalcChildStyle(StyleRecalcChange change) |
didReattach = toText(child)->recalcTextStyle(change); |
} else if (child->isElementNode()) { |
Element* element = toElement(child); |
- if (shouldRecalcStyle(change, element)) { |
- parentPusher.push(); |
+ if (shouldRecalcStyle(change, element)) |
didReattach = element->recalcStyle(change); |
- } else if (element->supportsStyleSharing()) { |
+ else if (element->supportsStyleSharing()) |
document().styleResolver()->addToStyleSharingList(*element); |
- } |
} |
if (didReattach) |
child->reattachWhitespaceSiblings(); |