void RenderQuote::attachQuote() { ASSERT(view()); ASSERT(!m_attached); ASSERT(!m_next && !m_previous); ASSERT(isRooted()); if (!view()->renderQuoteHead()) { view()->setRenderQuoteHead(this); m_attached = true; return; } for (RenderObject* 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() || !toRenderQuote(predecessor)->isAttached()) continue; m_previous = toRenderQuote(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()->renderQuoteHead(); view()->setRenderQuoteHead(this); if (m_next) m_next->m_previous = this; } m_attached = true; for (RenderQuote* 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); }
void RenderQuote::detachQuote() { ASSERT(!m_next || m_next->m_isAttached); ASSERT(!m_previous || m_previous->m_isAttached); if (!m_isAttached) return; if (m_previous) m_previous->m_next = m_next; else view().setRenderQuoteHead(m_next); if (m_next) m_next->m_previous = m_previous; if (!documentBeingDestroyed()) { for (RenderQuote* quote = m_next; quote; quote = quote->m_next) quote->updateDepth(); } m_isAttached = false; m_next = 0; m_previous = 0; }
void RenderQuote::attachQuote() { ASSERT(!m_isAttached); ASSERT(!m_next); ASSERT(!m_previous); ASSERT(isRooted()); // Optimize case where this is the first quote in a RenderView by not searching for predecessors in that case. if (view().renderQuoteHead()) { for (RenderObject* 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 (!is<RenderQuote>(*predecessor) || !downcast<RenderQuote>(*predecessor).m_isAttached) continue; m_previous = downcast<RenderQuote>(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().renderQuoteHead(); view().setRenderQuoteHead(this); if (m_next) m_next->m_previous = this; } m_isAttached = true; for (RenderQuote* quote = this; quote; quote = quote->m_next) quote->updateDepth(); ASSERT(!m_next || m_next->m_isAttached); ASSERT(!m_next || m_next->m_previous == this); ASSERT(!m_previous || m_previous->m_isAttached); ASSERT(!m_previous || m_previous->m_next == this); }