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 Text::attach(const AttachContext& context) { if (ContainerNode* layoutParent = LayoutTreeBuilderTraversal::parent(*this)) { if (LayoutObject* parentLayoutObject = layoutParent->layoutObject()) { if (textLayoutObjectIsNeeded(*parentLayoutObject->style(), *parentLayoutObject)) LayoutTreeBuilderForText(*this, parentLayoutObject).createLayoutObject(); } } CharacterData::attach(context); }
void Text::updateTextLayoutObject(unsigned offsetOfReplacedData, unsigned lengthOfReplacedData, RecalcStyleBehavior recalcStyleBehavior) { if (!inActiveDocument()) return; LayoutText* textLayoutObject = layoutObject(); if (!textLayoutObject || !textLayoutObjectIsNeeded(*textLayoutObject->style(), *textLayoutObject->parent())) { lazyReattachIfAttached(); // FIXME: Editing should be updated so this is not neccesary. if (recalcStyleBehavior == DeprecatedRecalcStyleImmediatlelyForEditing) document().updateLayoutTreeIfNeeded(); return; } textLayoutObject->setTextWithOffset(dataImpl(), offsetOfReplacedData, lengthOfReplacedData); }