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

Unified Diff: Source/core/dom/Element.cpp

Issue 68253003: StyleResolverParentPusher can decide if it needs to push at creation time (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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/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();
« 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