void Text::reattachIfNeeded(const AttachContext& context) { bool layoutObjectIsNeeded = false; ContainerNode* layoutParent = LayoutTreeBuilderTraversal::parent(*this); if (layoutParent) { if (LayoutObject* parentLayoutObject = layoutParent->layoutObject()) { if (textLayoutObjectIsNeeded(*parentLayoutObject->style(), *parentLayoutObject)) layoutObjectIsNeeded = true; } } if (layoutObjectIsNeeded == !!layoutObject()) return; // The following is almost the same as Node::reattach() except that we create a layoutObject only if needed. // Not calling reattach() to avoid repeated calls to Text::textLayoutObjectIsNeeded(). AttachContext reattachContext(context); reattachContext.performingReattach = true; if (getStyleChangeType() < NeedsReattachStyleChange) detach(reattachContext); if (layoutObjectIsNeeded) LayoutTreeBuilderForText(*this, layoutParent->layoutObject()).createLayoutObject(); CharacterData::attach(reattachContext); }
void ShadowRoot::recalcStyle(StyleRecalcChange change) { // ShadowRoot doesn't support custom callbacks. DCHECK(!hasCustomStyleCallbacks()); StyleSharingDepthScope sharingScope(*this); if (getStyleChangeType() >= SubtreeStyleChange) change = Force; // There's no style to update so just calling recalcStyle means we're updated. clearNeedsStyleRecalc(); clearNeedsReattachLayoutTree(); recalcDescendantStyles(change); clearChildNeedsStyleRecalc(); clearChildNeedsReattachLayoutTree(); }