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

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

Issue 548693002: Share recalcChildStyle between Element and ShadowRoot. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add back parent scope for ShadowRoot. Created 6 years, 3 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 | « Source/core/dom/Element.h ('k') | Source/core/dom/shadow/ShadowRoot.cpp » ('j') | 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 7f7a9a06ab6a6cc3ac920dbf1a2572a23eb3d8a8..b572730ebf46aefbc7cd2d9279dfb29698da9c5b 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -1492,7 +1492,21 @@ void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling)
// If we reattached we don't need to recalc the style of our descendants anymore.
if ((change >= UpdatePseudoElements && change < Reattach) || childNeedsStyleRecalc()) {
- recalcChildStyle(change);
+ StyleResolverParentScope parentScope(*this);
+
+ updatePseudoElement(BEFORE, change);
+
+ if (change > UpdatePseudoElements || childNeedsStyleRecalc()) {
+ for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) {
+ if (root->shouldCallRecalcStyle(change))
+ root->recalcStyle(change);
+ }
+ recalcChildStyle(change);
+ }
+
+ updatePseudoElement(AFTER, change);
+ updatePseudoElement(BACKDROP, change);
+
clearChildNeedsStyleRecalc();
}
@@ -1555,53 +1569,6 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change)
return localChange;
}
-void Element::recalcChildStyle(StyleRecalcChange change)
-{
- ASSERT(document().inStyleRecalc());
- ASSERT(change >= UpdatePseudoElements || childNeedsStyleRecalc());
- ASSERT(!needsStyleRecalc());
-
- StyleResolverParentScope parentScope(*this);
-
- updatePseudoElement(BEFORE, change);
-
- if (change > UpdatePseudoElements || childNeedsStyleRecalc()) {
- for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) {
- if (root->shouldCallRecalcStyle(change))
- root->recalcStyle(change);
- }
- }
-
- if (change < Force && hasRareData() && childNeedsStyleRecalc())
- checkForChildrenAdjacentRuleChanges();
-
- if (change > UpdatePseudoElements || childNeedsStyleRecalc()) {
- // This loop is deliberately backwards because we use insertBefore in the rendering tree, and want to avoid
- // a potentially n^2 loop to find the insertion point while resolving style. Having us start from the last
- // child and work our way back means in the common case, we'll find the insertion point in O(1) time.
- // See crbug.com/288225
- StyleResolver& styleResolver = document().ensureStyleResolver();
- Text* lastTextNode = 0;
- for (Node* child = lastChild(); child; child = child->previousSibling()) {
- if (child->isTextNode()) {
- toText(child)->recalcTextStyle(change, lastTextNode);
- lastTextNode = toText(child);
- } else if (child->isElementNode()) {
- Element* element = toElement(child);
- if (element->shouldCallRecalcStyle(change))
- element->recalcStyle(change, lastTextNode);
- else if (element->supportsStyleSharing())
- styleResolver.addToStyleSharingList(*element);
- if (element->renderer())
- lastTextNode = 0;
- }
- }
- }
-
- updatePseudoElement(AFTER, change);
- updatePseudoElement(BACKDROP, change);
-}
-
void Element::updateCallbackSelectors(RenderStyle* oldStyle, RenderStyle* newStyle)
{
Vector<String> emptyVector;
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/shadow/ShadowRoot.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698