⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 render_table.cpp

📁 将konqueror浏览器移植到ARM9 2410中
💻 CPP
📖 第 1 页 / 共 4 页
字号:
    calcColMinMax();}void RenderTable::close(){//    kdDebug( 6040 ) << "RenderTable::close()" << endl;    setParsing(false);    setLayouted(false);    updateSize();}void RenderTable::updateSize(){//    kdDebug( 6040 ) << "RenderTable::updateSize()" << endl;//    setMinMaxKnown(false);//    setLayouted(false);//    parent()->updateSize();     RenderFlow::updateSize();}int RenderTable::borderTopExtra(){    if (tCaption && tCaption->style()->captionSide()!=CAPBOTTOM)        return -(tCaption->height() + tCaption->marginBottom() +  tCaption->marginTop());    else        return 0;}int RenderTable::borderBottomExtra(){    if (tCaption && tCaption->style()->captionSide()==CAPBOTTOM)        return -(tCaption->height() + tCaption->marginBottom() +  tCaption->marginTop());    else        return 0;}void RenderTable::setNeedsCellsRecalc(){    needsCellsRecalc = true;    setMinMaxKnown(false);    setLayouted(false);}void RenderTable::recalcCells(){    if (!needsCellsRecalc)	return;    needsCellsRecalc = false;    _oldColElem = 0;    m_maxWidth = 0;    row = 0;    col = 0;    maxColSpan = 0;    totalColInfos = 0;    _currentCol=0;    _lastParentWidth = 0;    columnPos.resize( 0 );    columnPos.resize( 1 );    colMaxWidth.resize( 0 );    colMaxWidth.resize( 1 );    colMinWidth.resize( 0 );    colMinWidth.resize( 1 );    colValue.resize(0);    colValue.resize(1);    colType.resize(0);    colType.resize(1);    actColWidth.resize(0);    actColWidth.resize(1);    columnPos.fill( 0 );    colMaxWidth.fill( 0 );    colMinWidth.fill( 0 );    colValue.fill(0);    colType.fill(Variable);    actColWidth.fill(0);    columnPos[0] = spacing;    for (unsigned int r = 0; r < allocRows; r++)    {	delete[] cells[r];    }    delete[] cells;    totalCols = 0;   // this should be expanded to the maximum number of cols                     // by the first row parsed    totalRows = 1;    allocRows = 5;   // allocate five rows initially    cells = new RenderTableCell ** [allocRows];    for ( unsigned int r = 0; r < allocRows; r++ )    {        cells[r] = new RenderTableCell * [totalCols];        memset( cells[r], 0, totalCols * sizeof( RenderTableCell * ));    }    for (RenderObject *s = m_first; s; s = s->nextSibling()) {	if (s->isTableSection()) {	    for (RenderObject *r = static_cast<RenderTableSection*>(s)->firstChild(); r; r = r->nextSibling()) {		if (r->isTableRow()) {		    startRow();		    for (RenderObject *c = static_cast<RenderTableRow*>(r)->firstChild(); c; c = c->nextSibling()) {			if (c->isTableCell())			    addCell(static_cast<RenderTableCell*>(c));		    }		    closeRow();		}	    }	}    }    recalcColInfos();}// --------------------------------------------------------------------------RenderTableSection::RenderTableSection()    : RenderContainer(){    // init RenderObject attributes    setInline(false);   // our object is not Inline}RenderTableSection::~RenderTableSection(){    nrows = 0;    // recalc cell info because RenderTable has unguarded pointers    // stored that point to this RenderTableSection.    if (table)        table->setNeedsCellsRecalc();}void RenderTableSection::addChild(RenderObject *child, RenderObject *beforeChild){#ifdef DEBUG_LAYOUT    kdDebug( 6040 ) << renderName() << "(TableSection)::addChild( " << child->renderName()  << ", beforeChild=" <<                       (beforeChild ? beforeChild->renderName() : 0) << " )" << endl;#endif    RenderObject *row = child;    if ( !child->isTableRow() ) {        if( !beforeChild )            beforeChild = lastChild();        if( beforeChild && beforeChild->isAnonymousBox() )            row = beforeChild;        else {            kdDebug( 6040 ) << "creating anonymous table row" << endl;            row = new RenderTableRow();            RenderStyle *newStyle = new RenderStyle();            newStyle->inheritFrom(style());            newStyle->setDisplay(TABLE_ROW);            row->setStyle(newStyle);            row->setIsAnonymousBox(true);            addChild(row, beforeChild);        }        row->addChild(child);        return;    }    if (beforeChild)	table->setNeedsCellsRecalc();    table->startRow();    child->setTable(table);    RenderContainer::addChild(child,beforeChild);}// -------------------------------------------------------------------------RenderTableRow::RenderTableRow()    : RenderContainer(){    // init RenderObject attributes    setInline(false);   // our object is not Inline    rIndex = -1;}RenderTableRow::~RenderTableRow(){    if (table)        table->setNeedsCellsRecalc();}long RenderTableRow::rowIndex() const{    // ###    return 0;}void RenderTableRow::setRowIndex( long  ){    // ###}void RenderTableRow::close(){    table->closeRow();    RenderContainer::close();}void RenderTableRow::addChild(RenderObject *child, RenderObject *beforeChild){#ifdef DEBUG_LAYOUT    kdDebug( 6040 ) << renderName() << "(TableRow)::addChild( " << child->renderName() << " )"  << ", " <<                       (beforeChild ? beforeChild->renderName() : 0) << " )" << endl;#endif    RenderTableCell *cell;    if ( !child->isTableCell() ) {        if ( !beforeChild )            beforeChild = lastChild();        RenderTableCell *cell;        if( beforeChild && beforeChild->isAnonymousBox() && beforeChild->isTableCell() )            cell = static_cast<RenderTableCell *>(beforeChild);        else {//          kdDebug( 6040 ) << "creating anonymous table cell" << endl;            cell = new RenderTableCell();            RenderStyle *newStyle = new RenderStyle();            newStyle->inheritFrom(style());            newStyle->setDisplay(TABLE_CELL);            cell->setStyle(newStyle);            cell->setIsAnonymousBox(true);            addChild(cell, beforeChild);        }        cell->addChild(child);        return;    } else        cell = static_cast<RenderTableCell *>(child);    cell->setTable(table);    cell->setRowImpl(this);    table->addCell(cell);  // ### may not work for beforeChild != 0    RenderContainer::addChild(cell,beforeChild);    if (beforeChild || nextSibling())	table->setNeedsCellsRecalc();}void RenderTableRow::repaint(){    if ( table ) table->repaint();}// -------------------------------------------------------------------------RenderTableCell::RenderTableCell()  : RenderFlow(){  _col = -1;  _row = -1;  cSpan = rSpan = 1;  nWrap = false;  rowHeight = 0;  m_table = 0;  rowimpl = 0;  setSpecialObjects(true);  _topExtra = 0;  _bottomExtra = 0;}RenderTableCell::~RenderTableCell(){    if (m_table)        m_table->setNeedsCellsRecalc();}void RenderTableCell::calcMinMaxWidth(){#ifdef DEBUG_LAYOUT    kdDebug( 6040 ) << renderName() << "(TableCell)::calcMinMaxWidth() known=" << minMaxKnown() << endl;#endif    //if(minMaxKnown()) return;    int oldMin = m_minWidth;    int oldMax = m_maxWidth;    RenderFlow::calcMinMaxWidth();    if(nWrap && style()->width().type!=Fixed)        m_minWidth = m_maxWidth;    if (m_minWidth!=oldMin || m_maxWidth!=oldMax)        m_table->addColInfo(this);}void RenderTableCell::calcWidth(){}void RenderTableCell::close(){    //kdDebug( 6040 ) << "renderFlow::close()" << endl;    setParsing(false);    if(haveAnonymousBox())    {        lastChild()->close();        //kdDebug( 6040 ) << "RenderFlow::close(): closing anonymous box" << endl;        setHaveAnonymousBox(false);    }    //if(lastChild())    //    m_height += lastChild()->height() + lastChild()->marginBottom();    if(style()->hasBorder())        m_height += borderBottom();    if(style()->hasPadding())        m_height += paddingBottom();    setMinMaxKnown(false);    calcMinMaxWidth();    setLayouted(false);    m_table->updateSize();#ifdef DEBUG_LAYOUT    kdDebug( 6040 ) << renderName() << "(RenderTableCell)::close() total height =" << m_height << endl;#endif}void RenderTableCell::updateSize(){//    kdDebug( 6040 ) << renderName() << "(RenderTableCell)::updateSize()" << endl;    RenderFlow::updateSize();}void RenderTableCell::repaintRectangle(int x, int y, int w, int h, bool f){    y += _topExtra;    RenderFlow::repaintRectangle(x, y, w, h, f);}bool RenderTableCell::absolutePosition(int &xPos, int &yPos, bool f){    bool ret = RenderFlow::absolutePosition(xPos, yPos, f);    if (ret)      yPos += _topExtra;    return ret;}short RenderTableCell::baselinePosition( bool ) const{    RenderObject *o = firstChild();    int offset = paddingTop();    if ( !o ) return offset;    while ( o->firstChild() ) {	offset += paddingTop() + borderTop();	o = o->firstChild();    }    offset += o->baselinePosition( true );    return offset;}void RenderTableCell::setStyle( RenderStyle *style ){    RenderFlow::setStyle( style );    setSpecialObjects(true);}#ifdef BOX_DEBUGstatic void outlineBox(QPainter *p, int _tx, int _ty, int w, int h){    p->setPen(QPen(QColor("yellow"), 3, Qt::DotLine));    p->setBrush( Qt::NoBrush );    p->drawRect(_tx, _ty, w, h );}#endifvoid RenderTableCell::print(QPainter *p, int _x, int _y,                                       int _w, int _h, int _tx, int _ty){#ifdef TABLE_PRINT    kdDebug( 6040 ) << renderName() << "(RenderTableCell)::print() w/h = (" << width() << "/" << height() << ")" << endl;#endif//    if (!layouted())//      return;    _tx += m_x;    _ty += m_y + _topExtra;    // check if we need to do anything at all...    if(!containsPositioned() && ((_ty-_topExtra > _y + _h)        || (_ty + m_height+_topExtra+_bottomExtra < _y))) return;    printObject(p, _x, _y, _w, _h, _tx, _ty);#ifdef BOX_DEBUG    ::outlineBox( p, _tx, _ty - _topExtra, width(), height() + borderTopExtra() + borderBottomExtra());#endif}void RenderTableCell::printBoxDecorations(QPainter *p,int, int _y,                                       int, int _h, int _tx, int _ty){    //kdDebug( 6040 ) << renderName() << "::printDecorations()" << endl;    int w = width();    int h = height() + borderTopExtra() + borderBottomExtra();    _ty -= borderTopExtra();    int my = KMAX(_ty,_y);    int mh;    if (_ty<_y)        mh= KMAX(0,h-(_y-_ty));    else        mh = KMIN(_h,h);    QColor c = style()->backgroundColor();    if ( !c.isValid() && parent() ) // take from row        c = parent()->style()->backgroundColor();    if ( !c.isValid() && parent() && parent()->parent() ) // take from rowgroup        c = parent()->parent()->style()->backgroundColor();        // ### col is missing...    // ### get offsets right in case the bgimage is inherited.    CachedImage *bg = style()->backgroundImage();    if ( !bg && parent() )        bg = parent()->style()->backgroundImage();    if ( !bg && parent() && parent()->parent() )        bg = parent()->parent()->style()->backgroundImage();    if ( bg || c.isValid() )	printBackground(p, c, bg, my, mh, _tx, _ty, w, h);    if(style()->hasBorder())        printBorder(p, _tx, _ty, w, h, style());}void RenderTableCell::repaint(){    if ( m_table ) m_table->repaint();}// -------------------------------------------------------------------------RenderTableCol::RenderTableCol()    : RenderContainer(){    // init RenderObject attributes    setInline(true);   // our object is not Inline    _span = 1;}RenderTableCol::~RenderTableCol(){}void RenderTableCol::addChild(RenderObject *child, RenderObject *beforeChild){#ifdef DEBUG_LAYOUT    //kdDebug( 6040 ) << renderName() << "(Table)::addChild( " << child->renderName() << " )"  << ", " <<    //                   (beforeChild ? beforeChild->renderName() : 0) << " )" << endl;#endif    if (child->style()->display() == TABLE_COLUMN)    {        // these have to come before the table definition!        RenderContainer::addChild(child,beforeChild);        RenderTableCol* colel = static_cast<RenderTableCol *>(child);        colel->setStartCol(_currentCol);//      kdDebug( 6040 ) << "_currentCol=" << _currentCol << endl;        table->addColInfo(colel);        _currentCol++;    }}Length RenderTableCol::width(){    if (style()->width().type == Undefined        && parent() &&            parent()->style()->display()==TABLE_COLUMN_GROUP)        return static_cast<RenderTableCol*>(parent())->width();    else        return style()->width();}// -------------------------------------------------------------------------RenderTableCaption::RenderTableCaption()  : RenderFlow(){}RenderTableCaption::~RenderTableCaption(){}#undef TABLE_DEBUG#undef DEBUG_LAYOUT#undef BOX_DEBUG

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -