📄 html_tableimpl.cpp
字号:
{ case ATTR_BGCOLOR: if (attr->val()) addCSSProperty(CSS_PROP_BACKGROUND_COLOR, attr->value() ); else removeCSSProperty(CSS_PROP_BACKGROUND_COLOR); break; case ATTR_BACKGROUND: { if (attr->val()) { HTMLDocumentImpl *doc = static_cast<HTMLDocumentImpl *>(ownerDocument()); QString url = khtml::parseURL( attr->value() ).string(); if ( doc->view() ) url = doc->view()->part()->completeURL( url ).url(); addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, "url('"+url+"')" ); } else removeCSSProperty(CSS_PROP_BACKGROUND_IMAGE); break; } case ATTR_BORDERCOLOR: { if(!attr->value().isEmpty()) { addCSSProperty(CSS_PROP_BORDER_COLOR, attr->value()); addCSSProperty(CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID); addCSSProperty(CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID); addCSSProperty(CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID); addCSSProperty(CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID); } break; } case ATTR_VALIGN: { if (!attr->value().isEmpty()) addCSSProperty(CSS_PROP_VERTICAL_ALIGN, attr->value()); else removeCSSProperty(CSS_PROP_VERTICAL_ALIGN); break; } case ATTR_NOSAVE: break; default: HTMLElementImpl::parseAttribute(attr); }}void HTMLTablePartElementImpl::attach(){ HTMLElementImpl::attach();}// -------------------------------------------------------------------------HTMLTableSectionElementImpl::HTMLTableSectionElementImpl(DocumentPtr *doc, ushort tagid) : HTMLTablePartElementImpl(doc){ _id = tagid;}HTMLTableSectionElementImpl::~HTMLTableSectionElementImpl(){ nrows = 0;}const DOMString HTMLTableSectionElementImpl::nodeName() const{ return getTagName(_id);}ushort 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 ){ nrows++; HTMLTableRowElementImpl *r = new HTMLTableRowElementImpl(docPtr()); NodeListImpl *children = childNodes(); int exceptioncode; if(!children || (int)children->length() <= index) appendChild(r, exceptioncode); else { NodeImpl *n; if(index < 1) n = firstChild(); else n = children->item(index); insertBefore(r, n, exceptioncode ); } if(children) delete children; return r;}void HTMLTableSectionElementImpl::deleteRow( long index ){ if(index < 0) return; NodeListImpl *children = childNodes(); if(children && (int)children->length() > index) { nrows--; int exceptioncode; HTMLElementImpl::removeChild(children->item(index), exceptioncode); } if(children) delete children;}// -------------------------------------------------------------------------HTMLTableRowElementImpl::HTMLTableRowElementImpl(DocumentPtr *doc) : HTMLTablePartElementImpl(doc){}HTMLTableRowElementImpl::~HTMLTableRowElementImpl(){}const DOMString HTMLTableRowElementImpl::nodeName() const{ return "TR";}ushort HTMLTableRowElementImpl::id() const{ return ID_TR;}long HTMLTableRowElementImpl::rowIndex() const{ // some complex traversal stuff here to take into account that some rows may be in different sections int rIndex = 0; const NodeImpl *n = this; do { while (!n->previousSibling() && !(n->isElementNode() && n->id() == ID_TABLE)) n = n->parentNode(); if (n->isElementNode() && n->id() == ID_TABLE) n = 0; if (n) { n = n->previousSibling(); while (!(n->isElementNode() && n->id() == ID_TR) && n->lastChild()) n = n->lastChild(); } if (n && n->isElementNode() && n->id() == ID_TR) rIndex++; } while (n && n->isElementNode() && n->id() == ID_TR); return rIndex;}long HTMLTableRowElementImpl::sectionRowIndex() const{ int rIndex = 0; const NodeImpl *n = this; do { n = n->previousSibling(); if (n && n->isElementNode() && n->id() == ID_TR) rIndex++; } while (n); return rIndex;}HTMLElementImpl *HTMLTableRowElementImpl::insertCell( long index ){ HTMLTableCellElementImpl *c = new HTMLTableCellElementImpl(docPtr(), ID_TD); NodeListImpl *children = childNodes(); int exceptioncode; if(!children || (int)children->length() <= index) appendChild(c, exceptioncode); else { NodeImpl *n; if(index < 1) n = firstChild(); else n = children->item(index); insertBefore(c, n, exceptioncode); } if(children) delete children; return c;}void HTMLTableRowElementImpl::deleteCell( long index ){ if(index < 0) return; NodeListImpl *children = childNodes(); if(children && (int)children->length() > index) { int exceptioncode; HTMLElementImpl::removeChild(children->item(index), exceptioncode); } if(children) delete children;}// -------------------------------------------------------------------------HTMLTableCellElementImpl::HTMLTableCellElementImpl(DocumentPtr *doc, int tag) : HTMLTablePartElementImpl(doc){ _col = -1; _row = -1; cSpan = rSpan = 1; nWrap = false; _id = tag; rowHeight = 0;}HTMLTableCellElementImpl::~HTMLTableCellElementImpl(){}const DOMString HTMLTableCellElementImpl::nodeName() const{ return getTagName(_id);}void HTMLTableCellElementImpl::parseAttribute(AttrImpl *attr){ switch(attr->attrId) { case ATTR_BORDER: addCSSLength(CSS_PROP_BORDER_TOP_WIDTH, attr->value()); addCSSLength(CSS_PROP_BORDER_RIGHT_WIDTH, attr->value()); addCSSLength(CSS_PROP_BORDER_BOTTOM_WIDTH, attr->value()); addCSSLength(CSS_PROP_BORDER_LEFT_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: nWrap = (attr->val() != 0); break; case ATTR_WIDTH: if (!attr->value().isEmpty()) addCSSLength(CSS_PROP_WIDTH, attr->value()); else removeCSSProperty(CSS_PROP_WIDTH); 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: HTMLTablePartElementImpl::parseAttribute(attr); }}void HTMLTableCellElementImpl::attach(){ HTMLElementImpl* p = static_cast<HTMLElementImpl*>(_parent); while(p && p->id() != ID_TABLE) p = static_cast<HTMLElementImpl*>(p->parentNode()); if(p) { HTMLTableElementImpl* table = static_cast<HTMLTableElementImpl*>(p); // if(table->m_noBorder && getAttribute(ATTR_BORDER).isNull()) { addCSSProperty(CSS_PROP_BORDER_WIDTH, "0"); } if(!table->getAttribute(ATTR_BORDERCOLOR).isNull()) { addCSSProperty(CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID); addCSSProperty(CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID); addCSSProperty(CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID); addCSSProperty(CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID); } } setStyle(ownerDocument()->styleSelector()->styleForElement(this)); khtml::RenderObject *r = _parent->renderer(); if(r) { m_render = khtml::RenderObject::createObject(this); if(m_render && m_render->style()->display() == TABLE_CELL) { RenderTableCell *cell = static_cast<RenderTableCell *>(m_render); cell->setRowSpan(rSpan); cell->setColSpan(cSpan); cell->setNoWrap(nWrap); } if(m_render) r->addChild(m_render, nextRenderer()); } HTMLElementImpl::attach();}// -------------------------------------------------------------------------HTMLTableColElementImpl::HTMLTableColElementImpl(DocumentPtr *doc, ushort i) : HTMLElementImpl(doc){ _id = i; _span = 1;}HTMLTableColElementImpl::~HTMLTableColElementImpl(){}const DOMString HTMLTableColElementImpl::nodeName() const{ return getTagName(_id);}ushort HTMLTableColElementImpl::id() const{ return _id;}NodeImpl *HTMLTableColElementImpl::addChild(NodeImpl *child){#ifdef DEBUG_LAYOUT kdDebug( 6030 ) << nodeName().string() << "(Table)::addChild( " << child->nodeName().string() << " )" << endl;#endif switch(child->id()) { case ID_COL: { // these have to come before the table definition! HTMLElementImpl::addChild(child); return child; } default: return 0; break; // #### } return child;}void HTMLTableColElementImpl::parseAttribute(AttrImpl *attr){ switch(attr->attrId) { case ATTR_SPAN: _span = attr->val() ? attr->val()->toInt() : 1; break; case ATTR_WIDTH: if (!attr->value().isEmpty()) addCSSLength(CSS_PROP_WIDTH, attr->value()); else removeCSSProperty(CSS_PROP_WIDTH); break; case ATTR_VALIGN: if (!attr->value().isEmpty()) addCSSProperty(CSS_PROP_VERTICAL_ALIGN, attr->value()); else removeCSSProperty(CSS_PROP_VERTICAL_ALIGN); break; default: HTMLElementImpl::parseAttribute(attr); }}// -------------------------------------------------------------------------HTMLTableCaptionElementImpl::HTMLTableCaptionElementImpl(DocumentPtr *doc) : HTMLTablePartElementImpl(doc){}HTMLTableCaptionElementImpl::~HTMLTableCaptionElementImpl(){}const DOMString HTMLTableCaptionElementImpl::nodeName() const{ return "CAPTION";}ushort HTMLTableCaptionElementImpl::id() const{ return ID_CAPTION;}void HTMLTableCaptionElementImpl::parseAttribute(AttrImpl *attr){ switch(attr->attrId) { case ATTR_ALIGN: if (!attr->value().isEmpty()) addCSSProperty(CSS_PROP_CAPTION_SIDE, attr->value()); else removeCSSProperty(CSS_PROP_CAPTION_SIDE); break; default: HTMLElementImpl::parseAttribute(attr); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -