| 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();
|
|
|