📄 html_tableimpl.cpp
字号:
case ATTR_BGCOLOR: case ATTR_BACKGROUND: case ATTR_CELLSPACING: case ATTR_VSPACE: case ATTR_HSPACE: case ATTR_VALIGN: result = eUniversal; return false; case ATTR_BORDERCOLOR: result = eUniversal; return true; case ATTR_BORDER: result = eTable; return true; case ATTR_ALIGN: result = eTable; return false; default: break; } return HTMLElementImpl::mapToEntry(attr, result);}void HTMLTableElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr){ switch(attr->id()) { case ATTR_WIDTH: addCSSLength(attr, CSS_PROP_WIDTH, attr->value()); break; case ATTR_HEIGHT: addCSSLength(attr, CSS_PROP_HEIGHT, attr->value()); break; case ATTR_BORDER: { m_noBorder = true; if (attr->isNull()) break; if (attr->decl()) { CSSValueImpl* val = attr->decl()->getPropertyCSSValue(CSS_PROP_BORDER_LEFT_WIDTH); if (val && val->isPrimitiveValue()) { CSSPrimitiveValueImpl* primVal = static_cast<CSSPrimitiveValueImpl*>(val); m_noBorder = !primVal->getFloatValue(CSSPrimitiveValue::CSS_NUMBER); } } else { // ### this needs more work, as the border value is not only // the border of the box, but also between the cells int border = 0; if (attr->isEmpty()) border = 1; else border = attr->value().toInt();#ifdef DEBUG_DRAW_BORDER border=1;#endif m_noBorder = !border; DOMString v = QString::number( border ); addCSSLength(attr, CSS_PROP_BORDER_WIDTH, v ); }#if 0 // wanted by HTML4 specs if (m_noBorder) frame = Void, rules = None; else frame = Box, rules = All;#endif break; } case ATTR_BGCOLOR: addHTMLColor(attr, CSS_PROP_BACKGROUND_COLOR, attr->value()); break; case ATTR_BORDERCOLOR: m_solid = attr->decl(); if (!attr->decl() && !attr->isEmpty()) { addHTMLColor(attr, CSS_PROP_BORDER_COLOR, attr->value()); addCSSProperty(attr, CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID); addCSSProperty(attr, CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID); addCSSProperty(attr, CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID); addCSSProperty(attr, CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID); m_solid = true; } break; case ATTR_BACKGROUND: { QString url = khtml::parseURL( attr->value() ).string(); if (!url.isEmpty()) addCSSImageProperty(attr, CSS_PROP_BACKGROUND_IMAGE, getDocument()->completeURL(url)); break; } case ATTR_FRAME:#if 0 if ( strcasecmp( attr->value(), "void" ) == 0 ) frame = Void; else if ( strcasecmp( attr->value(), "border" ) == 0 ) frame = Box; else if ( strcasecmp( attr->value(), "box" ) == 0 ) frame = Box; else if ( strcasecmp( attr->value(), "hsides" ) == 0 ) frame = Hsides; else if ( strcasecmp( attr->value(), "vsides" ) == 0 ) frame = Vsides; else if ( strcasecmp( attr->value(), "above" ) == 0 ) frame = Above; else if ( strcasecmp( attr->value(), "below" ) == 0 ) frame = Below; else if ( strcasecmp( attr->value(), "lhs" ) == 0 ) frame = Lhs; else if ( strcasecmp( attr->value(), "rhs" ) == 0 ) frame = Rhs;#endif break; case ATTR_RULES:#if 0 if ( strcasecmp( attr->value(), "none" ) == 0 ) rules = None; else if ( strcasecmp( attr->value(), "groups" ) == 0 ) rules = Groups; else if ( strcasecmp( attr->value(), "rows" ) == 0 ) rules = Rows; else if ( strcasecmp( attr->value(), "cols" ) == 0 ) rules = Cols; else if ( strcasecmp( attr->value(), "all" ) == 0 ) rules = All;#endif break; case ATTR_CELLSPACING: if (!attr->value().isEmpty()) addCSSLength(attr, CSS_PROP_BORDER_SPACING, attr->value()); break; case ATTR_CELLPADDING: if (!attr->value().isEmpty()) padding = kMax( 0, attr->value().toInt() ); else padding = 1; if (m_render && m_render->isTable()) { static_cast<RenderTable *>(m_render)->setCellPadding(padding); if (!m_render->needsLayout()) m_render->setNeedsLayout(true); } break; case ATTR_COLS: { // ####if 0 int c; c = attr->val()->toInt(); addColumns(c-totalCols); break;#endif } case ATTR_VSPACE: addCSSLength(attr, CSS_PROP_MARGIN_TOP, attr->value()); addCSSLength(attr, CSS_PROP_MARGIN_BOTTOM, attr->value()); break; case ATTR_HSPACE: addCSSLength(attr, CSS_PROP_MARGIN_LEFT, attr->value()); addCSSLength(attr, CSS_PROP_MARGIN_RIGHT, attr->value()); break; case ATTR_ALIGN: if (!attr->value().isEmpty()) addCSSProperty(attr, CSS_PROP_FLOAT, attr->value()); break; case ATTR_VALIGN: if (!attr->value().isEmpty()) addCSSProperty(attr, CSS_PROP_VERTICAL_ALIGN, attr->value()); break; case ATTR_NOSAVE: break; default: HTMLElementImpl::parseHTMLAttribute(attr); }}CSSStyleDeclarationImpl* HTMLTableElementImpl::additionalAttributeStyleDecl(){ if (m_noBorder) return 0; HTMLAttributeImpl attr(ATTR_TABLEBORDER, m_solid ? "solid" : "outset"); CSSMappedAttributeDeclarationImpl* decl = getMappedAttributeDecl(ePersistent, &attr); if (!decl) { decl = new CSSMappedAttributeDeclarationImpl(0); decl->setParent(getDocument()->elementSheet()); decl->setNode(this); decl->setStrictParsing(false); // Mapped attributes are just always quirky. decl->ref(); // This single ref pins us in the table until the document dies. int v = m_solid ? CSS_VAL_SOLID : CSS_VAL_OUTSET; decl->setProperty(CSS_PROP_BORDER_TOP_STYLE, v, false); decl->setProperty(CSS_PROP_BORDER_BOTTOM_STYLE, v, false); decl->setProperty(CSS_PROP_BORDER_LEFT_STYLE, v, false); decl->setProperty(CSS_PROP_BORDER_RIGHT_STYLE, v, false); setMappedAttributeDecl(ePersistent, &attr, decl); decl->setParent(0); decl->setNode(0); decl->setMappedState(ePersistent, attr.id(), attr.value()); } return decl;}CSSStyleDeclarationImpl* HTMLTableElementImpl::getSharedCellDecl(){ HTMLAttributeImpl attr(ATTR_CELLBORDER, m_noBorder ? "none" : (m_solid ? "solid" : "inset")); CSSMappedAttributeDeclarationImpl* decl = getMappedAttributeDecl(ePersistent, &attr); if (!decl) { decl = new CSSMappedAttributeDeclarationImpl(0); decl->setParent(getDocument()->elementSheet()); decl->setNode(this); decl->setStrictParsing(false); // Mapped attributes are just always quirky. decl->ref(); // This single ref pins us in the table until the table dies. if (m_noBorder) decl->setProperty(CSS_PROP_BORDER_WIDTH, "0", false); else { decl->setProperty(CSS_PROP_BORDER_WIDTH, "1px", false); int v = m_solid ? CSS_VAL_SOLID : CSS_VAL_INSET; decl->setProperty(CSS_PROP_BORDER_TOP_STYLE, v, false); decl->setProperty(CSS_PROP_BORDER_BOTTOM_STYLE, v, false); decl->setProperty(CSS_PROP_BORDER_LEFT_STYLE, v, false); decl->setProperty(CSS_PROP_BORDER_RIGHT_STYLE, v, false); decl->setProperty(CSS_PROP_BORDER_COLOR, "inherit", false); } setMappedAttributeDecl(ePersistent, &attr, decl); decl->setParent(0); decl->setNode(0); decl->setMappedState(ePersistent, attr.id(), attr.value()); } return decl;}void HTMLTableElementImpl::attach(){ assert(!m_attached); HTMLElementImpl::attach(); if ( m_render && m_render->isTable() ) static_cast<RenderTable *>(m_render)->setCellPadding( padding );}bool HTMLTableElementImpl::isURLAttribute(AttributeImpl *attr) const{ return attr->id() == ATTR_BACKGROUND;}// --------------------------------------------------------------------------bool HTMLTablePartElementImpl::mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const{ switch(attr) { case ATTR_BGCOLOR: case ATTR_BACKGROUND: case ATTR_BORDERCOLOR: case ATTR_VALIGN: case ATTR_HEIGHT: result = eUniversal; return false; case ATTR_ALIGN: result = eCell; // All table parts will just share in the TD space. return false; default: break; } return HTMLElementImpl::mapToEntry(attr, result);}void HTMLTablePartElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr){ switch(attr->id()) { case ATTR_BGCOLOR: addHTMLColor(attr, CSS_PROP_BACKGROUND_COLOR, attr->value() ); break; case ATTR_BACKGROUND: { QString url = khtml::parseURL( attr->value() ).string(); if (!url.isEmpty()) addCSSImageProperty(attr, CSS_PROP_BACKGROUND_IMAGE, getDocument()->completeURL(url)); break; } case ATTR_BORDERCOLOR: { if (!attr->value().isEmpty()) { addHTMLColor(attr, CSS_PROP_BORDER_COLOR, attr->value()); addCSSProperty(attr, CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID); addCSSProperty(attr, CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID); addCSSProperty(attr, CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID); addCSSProperty(attr, CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID); } break; } case ATTR_VALIGN: { if (!attr->value().isEmpty()) addCSSProperty(attr, CSS_PROP_VERTICAL_ALIGN, attr->value()); break; } case ATTR_ALIGN: { DOMString v = attr->value(); if ( strcasecmp( attr->value(), "middle" ) == 0 || strcasecmp( attr->value(), "center" ) == 0 ) addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_CENTER); else if (strcasecmp(attr->value(), "absmiddle") == 0) addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, CSS_VAL_CENTER); else if (strcasecmp(attr->value(), "left") == 0) addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_LEFT); else if (strcasecmp(attr->value(), "right") == 0) addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_RIGHT); else addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, v); break; } case ATTR_HEIGHT: if (!attr->value().isEmpty()) addCSSLength(attr, CSS_PROP_HEIGHT, attr->value()); break; case ATTR_NOSAVE: break; default: HTMLElementImpl::parseHTMLAttribute(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;}NodeImpl *HTMLTableSectionElementImpl::addChild(NodeImpl *child){#ifdef DEBUG_LAYOUT kdDebug( 6030 ) << nodeName().string() << "(Tbody)::addChild( " << child->nodeName().string() << " )" << endl;#endif if (child->id() == ID_FORM) { // First add the child.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -