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

📄 html_tableimpl.cpp

📁 konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版本源码包.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        }        break;    case ATTR_COLS:    {        // ####if 0        int c;        c = attr->val()->toInt();        addColumns(c-totalCols);#endif        break;    }    case ATTR_ALIGN:        setChanged();        break;    case ATTR_VALIGN:        if (!attr->value().isEmpty())            addCSSProperty(CSS_PROP_VERTICAL_ALIGN, attr->value().lower());        else            removeCSSProperty(CSS_PROP_VERTICAL_ALIGN);        break;    case ATTR_NOSAVE:	break;    default:        HTMLElementImpl::parseAttribute(attr);    }}void HTMLTableElementImpl::attach(){    updateFrame();    HTMLElementImpl::attach();    if ( m_render && m_render->isTable() )        static_cast<RenderTable *>(m_render)->setCellPadding( padding );}void HTMLTableElementImpl::close(){    if (firstBody && !firstBody->closed())        firstBody->close();    HTMLElementImpl::close();}void HTMLTableElementImpl::updateFrame(){    int v = m_solid ? CSS_VAL_SOLID : CSS_VAL_OUTSET;    if ( frame & Above )         addCSSProperty(CSS_PROP_BORDER_TOP_STYLE, v);    else        addCSSProperty(CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_NONE);    if ( frame & Below )        addCSSProperty(CSS_PROP_BORDER_BOTTOM_STYLE, v);    else        addCSSProperty(CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_NONE);    if ( frame & Lhs )        addCSSProperty(CSS_PROP_BORDER_LEFT_STYLE, v);    else        addCSSProperty(CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_NONE);    if ( frame & Rhs )        addCSSProperty(CSS_PROP_BORDER_RIGHT_STYLE, v);    else        addCSSProperty(CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_NONE);}// --------------------------------------------------------------------------void HTMLTablePartElementImpl::parseAttribute(AttributeImpl *attr){    switch(attr->id())    {    case ATTR_BGCOLOR:        if (attr->val())            addHTMLColor(CSS_PROP_BACKGROUND_COLOR, attr->value() );        else            removeCSSProperty(CSS_PROP_BACKGROUND_COLOR);        break;    case ATTR_BACKGROUND:    {        if (attr->val()) {            QString url = khtml::parseURL( attr->value() ).string();            url = getDocument()->completeURL( url );            addCSSProperty(CSS_PROP_BACKGROUND_IMAGE,  "url('"+url+"')" );        }        else            removeCSSProperty(CSS_PROP_BACKGROUND_IMAGE);        break;    }    case ATTR_BORDERCOLOR:    {        if(!attr->value().isEmpty()) {            addHTMLColor(CSS_PROP_BORDER_COLOR, attr->value());            addCSSProperty(CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID);            addCSSProperty(CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID);            addCSSProperty(CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID);            addCSSProperty(CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID);        }        break;    }    case ATTR_ALIGN:    {        DOMString v = attr->value();        if ( strcasecmp( attr->value(), "middle" ) == 0 || strcasecmp( attr->value(), "center" ) == 0 )            addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_CENTER);        else if (strcasecmp(attr->value(), "absmiddle") == 0)            addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL_CENTER);        else if (strcasecmp(attr->value(), "left") == 0)            addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_LEFT);        else if (strcasecmp(attr->value(), "right") == 0)            addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_RIGHT);        else            addCSSProperty(CSS_PROP_TEXT_ALIGN, v);        break;    }    case ATTR_VALIGN:    {        if (!attr->value().isEmpty())            addCSSProperty(CSS_PROP_VERTICAL_ALIGN, attr->value().lower());        else            removeCSSProperty(CSS_PROP_VERTICAL_ALIGN);        break;    }    case ATTR_HEIGHT:        if (!attr->value().isEmpty())            addCSSLength(CSS_PROP_HEIGHT, attr->value());        else            removeCSSProperty(CSS_PROP_HEIGHT);        break;    case ATTR_NOSAVE:	break;    default:        HTMLElementImpl::parseAttribute(attr);    }}// -------------------------------------------------------------------------HTMLTableSectionElementImpl::HTMLTableSectionElementImpl(DocumentPtr *doc,                                                         ushort tagid, bool implicit)    : HTMLTablePartElementImpl(doc){    _id = tagid;    m_implicit = implicit;}HTMLTableSectionElementImpl::~HTMLTableSectionElementImpl(){}NodeImpl::Id HTMLTableSectionElementImpl::id() const{    return _id;}// these functions are rather slow, since we need to get the row at// the index... but they aren't used during usual HTML parsing anywayHTMLElementImpl *HTMLTableSectionElementImpl::insertRow( long index, int& exceptioncode ){    HTMLTableRowElementImpl *r = 0L;    NodeListImpl *children = childNodes();    int numRows = children ? (int)children->length() : 0;    //kdDebug(6030) << k_funcinfo << "index=" << index << " numRows=" << numRows << endl;    if ( index < -1 || index > numRows ) {        exceptioncode = DOMException::INDEX_SIZE_ERR; // per the DOM    }    else    {        r = new HTMLTableRowElementImpl(docPtr());        if ( numRows == index || index == -1 )            appendChild(r, exceptioncode);        else {            NodeImpl *n;            if(index < 1)                n = firstChild();            else                n = children->item(index);            insertBefore(r, n, exceptioncode );        }    }    delete children;    return r;}void HTMLTableSectionElementImpl::deleteRow( long index, int &exceptioncode ){    NodeListImpl *children = childNodes();    int numRows = children ? (int)children->length() : 0;    if ( index == -1 ) index = numRows - 1;    if( index >= 0 && index < numRows )        HTMLElementImpl::removeChild(children->item(index), exceptioncode);    else        exceptioncode = DOMException::INDEX_SIZE_ERR;    delete children;}int HTMLTableSectionElementImpl::numRows() const{    int rows = 0;    const NodeImpl *n = firstChild();    while (n) {        if (n->id() == ID_TR)            rows++;        n = n->nextSibling();    }    return rows;}// -------------------------------------------------------------------------NodeImpl::Id HTMLTableRowElementImpl::id() const{    return ID_TR;}long HTMLTableRowElementImpl::rowIndex() const{    int rIndex = 0;    NodeImpl *table = parentNode();    if ( !table )	return -1;    table = table->parentNode();    if ( !table || table->id() != ID_TABLE )	return -1;    HTMLTableSectionElementImpl *head = static_cast<HTMLTableElementImpl *>(table)->tHead();    HTMLTableSectionElementImpl *foot = static_cast<HTMLTableElementImpl *>(table)->tFoot();    if ( head ) {        const NodeImpl *row = head->firstChild();        while ( row ) {            if ( row == this )                return rIndex;            rIndex++;            row = row->nextSibling();        }    }    NodeImpl *node = table->firstChild();    while ( node ) {        if ( node != foot && node != head && (node->id() == ID_THEAD || node->id() == ID_TFOOT || node->id() == ID_TBODY) ) {	    HTMLTableSectionElementImpl* section = static_cast<HTMLTableSectionElementImpl *>(node);	    const NodeImpl *row = section->firstChild();	    while ( row ) {		if ( row == this )		    return rIndex;		rIndex++;		row = row->nextSibling();	    }	}	node = node->nextSibling();    }    const NodeImpl *row = foot->firstChild();    while ( row ) {	if ( row == this )	    return rIndex;	rIndex++;	row = row->nextSibling();    }    // should never happen    return -1;}long HTMLTableRowElementImpl::sectionRowIndex() const{    int rIndex = 0;    const NodeImpl *n = this;    do {        n = n->previousSibling();        if (n && n->id() == ID_TR)            rIndex++;    }    while (n);    return rIndex;}HTMLElementImpl *HTMLTableRowElementImpl::insertCell( long index, int &exceptioncode ){    HTMLTableCellElementImpl *c = 0L;    NodeListImpl *children = childNodes();    int numCells = children ? children->length() : 0;    if ( index < -1 || index > numCells )        exceptioncode = DOMException::INDEX_SIZE_ERR; // per the DOM    else    {        c = new HTMLTableCellElementImpl(docPtr(), ID_TD);        if(numCells == index || index == -1)            appendChild(c, exceptioncode);        else {            NodeImpl *n;            if(index < 1)                n = firstChild();            else                n = children->item(index);            insertBefore(c, n, exceptioncode);        }    }    delete children;    return c;}void HTMLTableRowElementImpl::deleteCell( long index, int &exceptioncode ){    NodeListImpl *children = childNodes();    int numCells = children ? children->length() : 0;    if ( index == -1 ) index = numCells-1;    if( index >= 0 && index < numCells )        HTMLElementImpl::removeChild(children->item(index), exceptioncode);    else        exceptioncode = DOMException::INDEX_SIZE_ERR;    delete children;}// -------------------------------------------------------------------------HTMLTableCellElementImpl::HTMLTableCellElementImpl(DocumentPtr *doc, int tag)  : HTMLTablePartElementImpl(doc){  _col = -1;  _row = -1;  cSpan = rSpan = 1;  _id = tag;  rowHeight = 0;  m_solid = false;}HTMLTableCellElementImpl::~HTMLTableCellElementImpl(){}long HTMLTableCellElementImpl::cellIndex() const{    int index = 0;    for (const NodeImpl * node = previousSibling(); node; node = node->previousSibling()) {        if (node->id() == ID_TD || node->id() == ID_TH)            index++;    }    return index;}void HTMLTableCellElementImpl::parseAttribute(AttributeImpl *attr){    switch(attr->id())    {    case ATTR_BORDER:        // euhm? not supported by other browsers as far as I can see (Dirk)        //addCSSLength(CSS_PROP_BORDER_WIDTH, attr->value());        break;    case ATTR_ROWSPAN:        // ###        rSpan = attr->val() ? attr->val()->toInt() : 1;        // limit this to something not causing an overflow with short int        if(rSpan < 1 || rSpan > 1024) rSpan = 1;        break;    case ATTR_COLSPAN:        // ###        cSpan = attr->val() ? attr->val()->toInt() : 1;        // limit this to something not causing an overflow with short int        if(cSpan < 1 || cSpan > 1024) cSpan = 1;        break;    case ATTR_NOWRAP:        if (attr->val() != 0)	    addCSSProperty(CSS_PROP_WHITE_SPACE, CSS_VAL__KHTML_NOWRAP);        else	    removeCSSProperty(CSS_PROP_WHITE_SPACE);        break;    case ATTR_WIDTH:        if (!attr->value().isEmpty())            addCSSLength( CSS_PROP_WIDTH, attr->value() );        else            removeCSSProperty(CSS_PROP_WIDTH);        break;    case ATTR_NOSAVE:	break;    default:        HTMLTablePartElementImpl::parseAttribute(attr);    }}void HTMLTableCellElementImpl::attach(){    HTMLElementImpl* p = static_cast<HTMLElementImpl*>(parentNode());    while(p && p->id() != ID_TABLE)        p = static_cast<HTMLElementImpl*>(p->parentNode());    if(p) {        HTMLTableElementImpl* table = static_cast<HTMLTableElementImpl*>(p);        if (table->rules == HTMLTableElementImpl::None) {            addCSSProperty(CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_NONE);            addCSSProperty(CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_NONE);            addCSSProperty(CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_NONE);            addCSSProperty(CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_NONE);        }        else {            addCSSProperty(CSS_PROP_BORDER_WIDTH, "1px");            int v = (table->m_solid || m_solid) ? CSS_VAL_SOLID : CSS_VAL_INSET;            addCSSProperty(CSS_PROP_BORDER_TOP_STYLE, v);            addCSSProperty(CSS_PROP_BORDER_BOTTOM_STYLE, v);            addCSSProperty(CSS_PROP_BORDER_LEFT_STYLE, v);            addCSSProperty(CSS_PROP_BORDER_RIGHT_STYLE, v);            if (!m_solid)                addCSSProperty(CSS_PROP_BORDER_COLOR, CSS_VAL_INHERIT);        }    }    HTMLTablePartElementImpl::attach();}// -------------------------------------------------------------------------HTMLTableColElementImpl::HTMLTableColElementImpl(DocumentPtr *doc, ushort i)    : HTMLTablePartElementImpl(doc){    _id = i;    _span = (_id == ID_COLGROUP ? 0 : 1);}NodeImpl::Id HTMLTableColElementImpl::id() const{    return _id;}void HTMLTableColElementImpl::parseAttribute(AttributeImpl *attr){    switch(attr->id())    {    case ATTR_SPAN:        _span = attr->val() ? attr->val()->toInt() : 1;        break;    case ATTR_WIDTH:        if (!attr->value().isEmpty())            addCSSLength(CSS_PROP_WIDTH, attr->value(), false, true );        else            removeCSSProperty(CSS_PROP_WIDTH);        break;    case ATTR_VALIGN:        if (!attr->value().isEmpty())            addCSSProperty(CSS_PROP_VERTICAL_ALIGN, attr->value().lower());        else            removeCSSProperty(CSS_PROP_VERTICAL_ALIGN);        break;    default:        HTMLTablePartElementImpl::parseAttribute(attr);    }}// -------------------------------------------------------------------------NodeImpl::Id HTMLTableCaptionElementImpl::id() const{    return ID_CAPTION;}void HTMLTableCaptionElementImpl::parseAttribute(AttributeImpl *attr){    switch(attr->id())    {    case ATTR_ALIGN:        if (!attr->value().isEmpty())            addCSSProperty(CSS_PROP_CAPTION_SIDE, attr->value().lower());        else            removeCSSProperty(CSS_PROP_CAPTION_SIDE);        break;    default:        HTMLElementImpl::parseAttribute(attr);    }}

⌨️ 快捷键说明

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