void PseudoElement::attach(const AttachContext& context) { ASSERT(!layoutObject()); Element::attach(context); LayoutObject* renderer = this->layoutObject(); if (!renderer) return; ComputedStyle& style = renderer->mutableStyleRef(); if (style.styleType() != BEFORE && style.styleType() != AFTER) return; ASSERT(style.contentData()); for (const ContentData* content = style.contentData(); content; content = content->next()) { LayoutObject* child = content->createLayoutObject(document(), style); if (renderer->isChildAllowed(child, style)) { renderer->addChild(child); if (child->isQuote()) toLayoutQuote(child)->attachQuote(); } else child->destroy(); } }
void PseudoElement::attachLayoutTree(const AttachContext& context) { DCHECK(!layoutObject()); Element::attachLayoutTree(context); LayoutObject* layoutObject = this->layoutObject(); if (!layoutObject) return; ComputedStyle& style = layoutObject->mutableStyleRef(); if (style.styleType() != PseudoIdBefore && style.styleType() != PseudoIdAfter) return; DCHECK(style.contentData()); for (const ContentData* content = style.contentData(); content; content = content->next()) { LayoutObject* child = content->createLayoutObject(document(), style); if (layoutObject->isChildAllowed(child, style)) { layoutObject->addChild(child); if (child->isQuote()) toLayoutQuote(child)->attachQuote(); } else { child->destroy(); } } }
void LayoutQuote::attachQuote() { ASSERT(view()); ASSERT(!m_attached); ASSERT(!m_next && !m_previous); ASSERT(isRooted()); if (!view()->layoutQuoteHead()) { view()->setLayoutQuoteHead(this); m_attached = true; return; } for (LayoutObject* predecessor = previousInPreOrder(); predecessor; predecessor = predecessor->previousInPreOrder()) { // Skip unattached predecessors to avoid having stale m_previous pointers // if the previous node is never attached and is then destroyed. if (!predecessor->isQuote() || !toLayoutQuote(predecessor)->isAttached()) continue; m_previous = toLayoutQuote(predecessor); m_next = m_previous->m_next; m_previous->m_next = this; if (m_next) m_next->m_previous = this; break; } if (!m_previous) { m_next = view()->layoutQuoteHead(); view()->setLayoutQuoteHead(this); if (m_next) m_next->m_previous = this; } m_attached = true; for (LayoutQuote* quote = this; quote; quote = quote->m_next) quote->updateDepth(); ASSERT(!m_next || m_next->m_attached); ASSERT(!m_next || m_next->m_previous == this); ASSERT(!m_previous || m_previous->m_attached); ASSERT(!m_previous || m_previous->m_next == this); }