void RenderContainer::addChild(RenderObject* newChild, RenderObject* beforeChild) { bool needsTable = false; if (newChild->isListItem()) updateListMarkerNumbers(beforeChild ? beforeChild : m_lastChild); else if (newChild->isTableCol() && newChild->style()->display() == TABLE_COLUMN_GROUP) needsTable = !isTable(); else if (newChild->isRenderBlock() && newChild->style()->display() == TABLE_CAPTION) needsTable = !isTable(); else if (newChild->isTableSection()) needsTable = !isTable(); else if (newChild->isTableRow()) needsTable = !isTableSection(); else if (newChild->isTableCell()) { needsTable = !isTableRow(); // I'm not 100% sure this is the best way to fix this, but without this // change we recurse infinitely when trying to render the CSS2 test page: // http://www.bath.ac.uk/%7Epy8ieh/internet/eviltests/htmlbodyheadrendering2.html. // See Radar 2925291. if (needsTable && isTableCell() && !m_firstChild && !newChild->isTableCell()) needsTable = false; } if (needsTable) { RenderTable* table; RenderObject* afterChild = beforeChild ? beforeChild->previousSibling() : m_lastChild; if (afterChild && afterChild->isAnonymous() && afterChild->isTable()) table = static_cast<RenderTable*>(afterChild); else { table = new (renderArena()) RenderTable(document() /* is anonymous */); RefPtr<RenderStyle> newStyle = RenderStyle::create(); newStyle->inheritFrom(style()); newStyle->setDisplay(TABLE); table->setStyle(newStyle.release()); addChild(table, beforeChild); } table->addChild(newChild); } else { // just add it... insertChildNode(newChild, beforeChild); } if (newChild->isText() && newChild->style()->textTransform() == CAPITALIZE) { RefPtr<StringImpl> textToTransform = static_cast<RenderText*>(newChild)->originalText(); if (textToTransform) static_cast<RenderText*>(newChild)->setText(textToTransform.release(), true); } }
void RenderObject::addChild(RenderObject *newChild, RenderObject *beforeChild) { #ifdef DEBUG_LAYOUT kdDebug( 6040 ) << renderName() << "(RenderObject)::addChild( " << newChild->renderName() << ", " (beforeChild ? beforeChild->renderName() : "0") << " )" << endl; #endif newChild->m_root = m_root; if(parsing()) newChild->setParsing(); bool needsTable = false; if(!newChild->isText()) { switch(newChild->style()->display()) { case INLINE: case BLOCK: case LIST_ITEM: case RUN_IN: case COMPACT: case MARKER: case TABLE: case INLINE_TABLE: break; case TABLE_COLUMN_GROUP: case TABLE_COLUMN: case TABLE_CAPTION: case TABLE_ROW_GROUP: case TABLE_HEADER_GROUP: case TABLE_FOOTER_GROUP: //kdDebug( 6040 ) << "adding section" << endl; if ( !isTable() ) needsTable = true; break; case TABLE_ROW: //kdDebug( 6040 ) << "adding row" << endl; if ( !isTableSection() ) needsTable = true; break; case TABLE_CELL: //kdDebug( 6040 ) << "adding cell" << endl; if ( !isTableRow() ) needsTable = true; break; case NONE: kdDebug( 6000 ) << "error in RenderObject::addChild()!!!!" << endl; break; } } if ( needsTable ) { RenderTable *table; if( !beforeChild ) beforeChild = lastChild(); if( beforeChild && beforeChild->isAnonymousBox() && beforeChild->isTable() ) table = static_cast<RenderTable *>(beforeChild); else { // kdDebug( 6040 ) << "creating anonymous table" << endl; table = new RenderTable; RenderStyle *newStyle = new RenderStyle(m_style); newStyle->setDisplay(TABLE); table->setStyle(newStyle); table->setIsAnonymousBox(true); addChild(table, beforeChild); } table->addChild(newChild); return; } // just add it... insertChildNode(newChild, beforeChild); }
void RenderContainer::addChild(RenderObject *newChild, RenderObject *beforeChild) { #ifdef DEBUG_LAYOUT kdDebug( 6040 ) << this << ": " << renderName() << "(RenderObject)::addChild( " << newChild << ": " << newChild->renderName() << ", " << (beforeChild ? beforeChild->renderName() : "0") << " )" << endl; #endif bool needsTable = false; if(!newChild->isText() && !newChild->isReplaced()) { switch(newChild->style()->display()) { case INLINE: case BLOCK: case INLINE_BLOCK: case LIST_ITEM: case RUN_IN: case COMPACT: case BOX: case INLINE_BOX: case TABLE: case INLINE_TABLE: case TABLE_COLUMN: break; case TABLE_COLUMN_GROUP: case TABLE_CAPTION: case TABLE_ROW_GROUP: case TABLE_HEADER_GROUP: case TABLE_FOOTER_GROUP: //kdDebug( 6040 ) << "adding section" << endl; if ( !isTable() ) needsTable = true; break; case TABLE_ROW: //kdDebug( 6040 ) << "adding row" << endl; if ( !isTableSection() ) needsTable = true; break; case TABLE_CELL: //kdDebug( 6040 ) << "adding cell" << endl; if ( !isTableRow() ) needsTable = true; #if APPLE_CHANGES // I'm not 100% sure this is the best way to fix this, but without this // change we recurse infinitely when trying to render the CSS2 test page: // http://www.bath.ac.uk/%7Epy8ieh/internet/eviltests/htmlbodyheadrendering2.html. // See Radar 2925291. if ( isTableCell() && !firstChild() && !newChild->isTableCell() ) needsTable = false; #endif break; case NONE: kdDebug( 6000 ) << "error in RenderObject::addChild()!!!!" << endl; break; } } if ( needsTable ) { RenderTable *table; if( !beforeChild ) beforeChild = lastChild(); if( beforeChild && beforeChild->isAnonymous() && beforeChild->isTable() ) table = static_cast<RenderTable *>(beforeChild); else { //kdDebug( 6040 ) << "creating anonymous table" << endl; table = new (renderArena()) RenderTable(document() /* is anonymous */); RenderStyle *newStyle = new (renderArena()) RenderStyle(); newStyle->inheritFrom(style()); newStyle->setDisplay(TABLE); table->setStyle(newStyle); addChild(table, beforeChild); } table->addChild(newChild); } else { // just add it... insertChildNode(newChild, beforeChild); } }