📄 html_tableimpl.cpp
字号:
DOMString url(KURL::completeURL(attr->value(), doc->baseURL()).url());#endif addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, url, false ); } else removeCSSProperty(CSS_PROP_BACKGROUND_IMAGE); break; } default: HTMLElementImpl::parseAttribute(attr); }}void HTMLTablePartElementImpl::attach(MGHTMLView *w){ HTMLElementImpl::attach(w);}// -------------------------------------------------------------------------HTMLTableSectionElementImpl::HTMLTableSectionElementImpl(DocumentImpl *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(document); if(index < 1) { insertBefore(r, firstChild()); return r; } NodeListImpl *children = childNodes(); if(!children || (int)children->length() <= index) appendChild(r); else insertBefore(r, children->item(index)); 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--; HTMLElementImpl::removeChild(children->item(index)); } if(children) delete children;}// -------------------------------------------------------------------------HTMLTableRowElementImpl::HTMLTableRowElementImpl(DocumentImpl *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(document, ID_TD); if(index < 1) { insertBefore(c, firstChild()); return c; } NodeListImpl *children = childNodes(); if(!children || (int)children->length() <= index) appendChild(c); else insertBefore(c, children->item(index)); if(children) delete children; return c;}void HTMLTableRowElementImpl::deleteCell( long index ){ if(index < 0) return; NodeListImpl *children = childNodes(); if(children && (int)children->length() > index) HTMLElementImpl::removeChild(children->item(index)); if(children) delete children;}NodeImpl *HTMLTableRowElementImpl::addChild(NodeImpl *child){#ifdef DEBUG_LAYOUT kdDebug( 6030 ) << nodeName().string() << "(TableRow)::addChild( " << child->nodeName().string() << " )" << endl;#endif NodeImpl *ret = HTMLElementImpl::addChild(child); return ret;}void HTMLTableRowElementImpl::parseAttribute(AttrImpl *attr){ switch(attr->attrId) { case ATTR_ALIGN: if (attr->val()) addCSSProperty(CSS_PROP_TEXT_ALIGN, attr->value(), false); else removeCSSProperty(CSS_PROP_TEXT_ALIGN); break; case ATTR_VALIGN: if (attr->val()) addCSSProperty(CSS_PROP_VERTICAL_ALIGN, attr->value(), false); else removeCSSProperty(CSS_PROP_VERTICAL_ALIGN); default: HTMLTablePartElementImpl::parseAttribute(attr); }}// -------------------------------------------------------------------------HTMLTableCellElementImpl::HTMLTableCellElementImpl(DocumentImpl *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: { int border; border = attr->val() ? attr->val()->toInt() : 0; QString str; str.sprintf("%dpx solid black", border); addCSSProperty(CSS_PROP_BORDER, str, false); break; } case ATTR_ROWSPAN: // ### rSpan = attr->val() ? attr->val()->toInt() : 1; if(rSpan < 1) rSpan = 1; // fix for GNOME websites... ;-) break; case ATTR_COLSPAN: // ### cSpan = attr->val() ? attr->val()->toInt() : 1; if(cSpan < 1) cSpan = 1; // fix for GNOME websites... ;-) break; case ATTR_NOWRAP: nWrap = (attr->val() != 0); break; case ATTR_WIDTH: if (attr->val()) addCSSLength(CSS_PROP_WIDTH, attr->value(), false); else removeCSSProperty(CSS_PROP_WIDTH); break; case ATTR_HEIGHT: if (attr->val()) addCSSLength(CSS_PROP_HEIGHT, attr->value(), false); else removeCSSProperty(CSS_PROP_HEIGHT); break; case ATTR_ALIGN: if (attr->val()) addCSSProperty(CSS_PROP_TEXT_ALIGN, attr->value(), false); else removeCSSProperty(CSS_PROP_TEXT_ALIGN); break; case ATTR_VALIGN: if (attr->val()) addCSSProperty(CSS_PROP_VERTICAL_ALIGN, attr->value(), false); else removeCSSProperty(CSS_PROP_VERTICAL_ALIGN); break; default: HTMLTablePartElementImpl::parseAttribute(attr); }}void HTMLTableCellElementImpl::attach(MGHTMLView *_view){ m_style = document->styleSelector()->styleForElement(this, _view->part()); 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, _next ? _next->renderer() : 0); } NodeBaseImpl::attach(_view);}// -------------------------------------------------------------------------HTMLTableColElementImpl::HTMLTableColElementImpl(DocumentImpl *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); HTMLTableColElementImpl* colel = static_cast<HTMLTableColElementImpl *>(child); colel->setStartCol(_currentCol);// kdDebug( 6030 ) << "_currentCol=" << _currentCol << endl; _currentCol++; return child; } default: throw DOMException(DOMException::HIERARCHY_REQUEST_ERR); 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->val()) addCSSLength(CSS_PROP_WIDTH, attr->value(), false); else removeCSSProperty(CSS_PROP_WIDTH); break; case ATTR_ALIGN: if (attr->val()) addCSSProperty(CSS_PROP_TEXT_ALIGN, attr->value(), false); else removeCSSProperty(CSS_PROP_TEXT_ALIGN); break; case ATTR_VALIGN: if (attr->val()) addCSSProperty(CSS_PROP_VERTICAL_ALIGN, attr->value(), false); else removeCSSProperty(CSS_PROP_VERTICAL_ALIGN); break; default: HTMLElementImpl::parseAttribute(attr); }}// -------------------------------------------------------------------------HTMLTableCaptionElementImpl::HTMLTableCaptionElementImpl(DocumentImpl *doc) : HTMLTablePartElementImpl(doc){}HTMLTableCaptionElementImpl::~HTMLTableCaptionElementImpl(){}const DOMString HTMLTableCaptionElementImpl::nodeName() const{ return "CAPTION";}ushort HTMLTableCaptionElementImpl::id() const{ return ID_CAPTION;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -