| Index: Source/core/dom/Element.cpp
|
| diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
|
| index ff152e2f58e6c21293336eb34a94c2193d6759e3..9b2182f2e561dd2aeaac7b5d9fc340d4eb9439c5 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)
|
| + explicit StyleResolverParentPusher(Element& parent, StyleRecalcChange change = NoChange)
|
| : 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);
|
| }
|
|
|
| @@ -1366,8 +1356,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) {
|
| @@ -1383,14 +1371,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);
|
|
|
| @@ -1599,13 +1586,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))
|
| @@ -1624,12 +1609,10 @@ void Element::recalcChildStyle(StyleRecalcChange change)
|
| toText(child)->recalcTextStyle(change);
|
| } else if (child->isElementNode()) {
|
| Element* element = toElement(child);
|
| - if (shouldRecalcStyle(change, element)) {
|
| - parentPusher.push();
|
| + if (shouldRecalcStyle(change, element))
|
| element->recalcStyle(change);
|
| - } else if (element->supportsStyleSharing()) {
|
| + else if (element->supportsStyleSharing())
|
| styleResolver.addToStyleSharingList(*element);
|
| - }
|
| }
|
| }
|
|
|
|
|