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

Unified Diff: Source/core/dom/ContainerNode.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/ContainerNode.h ('k') | Source/core/dom/Element.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ContainerNode.cpp
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
index 114e63d4ece6650a7c8627650a51f1a87a5104b0..6cc52d45f84fa1b825740b49c5985d0839db6397 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -1205,6 +1205,37 @@ void ContainerNode::setRestyleFlag(DynamicRestyleFlags mask)
ensureRareData().setRestyleFlag(mask);
}
+void ContainerNode::recalcChildStyle(StyleRecalcChange change)
+{
+ ASSERT(document().inStyleRecalc());
+ ASSERT(change >= UpdatePseudoElements || childNeedsStyleRecalc());
+ ASSERT(!needsStyleRecalc());
+
+ if (change < Force && hasRareData() && childNeedsStyleRecalc())
+ checkForChildrenAdjacentRuleChanges();
+
+ // 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;
+ }
+ }
+}
+
void ContainerNode::checkForChildrenAdjacentRuleChanges()
{
bool hasDirectAdjacentRules = childrenAffectedByDirectAdjacentRules();
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | Source/core/dom/Element.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698