diff options
Diffstat (limited to 'Source/WebCore/html/HTMLTableElement.cpp')
-rw-r--r-- | Source/WebCore/html/HTMLTableElement.cpp | 166 |
1 files changed, 77 insertions, 89 deletions
diff --git a/Source/WebCore/html/HTMLTableElement.cpp b/Source/WebCore/html/HTMLTableElement.cpp index cac8b4d61..be3aaa2ce 100644 --- a/Source/WebCore/html/HTMLTableElement.cpp +++ b/Source/WebCore/html/HTMLTableElement.cpp @@ -241,42 +241,6 @@ void HTMLTableElement::deleteRow(int index, ExceptionCode& ec) row->remove(ec); } -bool HTMLTableElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const -{ - if (attrName == backgroundAttr) { - result = (MappedAttributeEntry)(eLastEntry + document()->docID()); - return false; - } - - if (attrName == widthAttr || - attrName == heightAttr || - attrName == bgcolorAttr || - attrName == cellspacingAttr || - attrName == vspaceAttr || - attrName == hspaceAttr || - attrName == valignAttr) { - result = eUniversal; - return false; - } - - if (attrName == bordercolorAttr || attrName == frameAttr || attrName == rulesAttr) { - result = eUniversal; - return true; - } - - if (attrName == borderAttr) { - result = eTable; - return true; - } - - if (attrName == alignAttr) { - result = eTable; - return false; - } - - return HTMLElement::mapToEntry(attrName, result); -} - static inline bool isTableCellAncestor(Node* n) { return n->hasTagName(theadTag) || n->hasTagName(tbodyTag) || @@ -302,44 +266,52 @@ static bool setTableCellsChanged(Node* n) return cellChanged; } -void HTMLTableElement::parseMappedAttribute(Attribute* attr) +void HTMLTableElement::parseAttribute(Attribute* attr) { CellBorders bordersBefore = cellBorders(); unsigned short oldPadding = m_padding; if (attr->name() == widthAttr) - addCSSLength(attr, CSSPropertyWidth, attr->value()); + if (attr->isNull()) + removeCSSProperty(CSSPropertyWidth); + else + addCSSLength(CSSPropertyWidth, attr->value()); else if (attr->name() == heightAttr) - addCSSLength(attr, CSSPropertyHeight, attr->value()); + if (attr->isNull()) + removeCSSProperty(CSSPropertyHeight); + else + addCSSLength(CSSPropertyHeight, attr->value()); else if (attr->name() == borderAttr) { m_borderAttr = true; - if (attr->decl()) { - RefPtr<CSSValue> val = attr->decl()->getPropertyCSSValue(CSSPropertyBorderLeftWidth); - if (val && val->isPrimitiveValue()) { - CSSPrimitiveValue* primVal = static_cast<CSSPrimitiveValue*>(val.get()); - m_borderAttr = primVal->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER); - } - } else if (!attr->isNull()) { + + if (attr->isNull()) + removeCSSProperty(CSSPropertyBorderWidth); + else { int border = 0; if (attr->isEmpty()) border = 1; else border = attr->value().toInt(); m_borderAttr = border; - addCSSLength(attr, CSSPropertyBorderWidth, String::number(border)); + addCSSLength(CSSPropertyBorderWidth, String::number(border)); } } else if (attr->name() == bgcolorAttr) - addCSSColor(attr, CSSPropertyBackgroundColor, attr->value()); + if (attr->isNull()) + removeCSSProperty(CSSPropertyBackgroundColor); + else + addCSSColor(CSSPropertyBackgroundColor, attr->value()); else if (attr->name() == bordercolorAttr) { - m_borderColorAttr = attr->decl(); - if (!attr->decl() && !attr->isEmpty()) { - addCSSColor(attr, CSSPropertyBorderColor, attr->value()); - m_borderColorAttr = true; - } + m_borderColorAttr = !attr->isEmpty(); + if (!attr->isEmpty()) + addCSSColor(CSSPropertyBorderColor, attr->value()); + else + removeCSSProperty(CSSPropertyBorderColor); } else if (attr->name() == backgroundAttr) { String url = stripLeadingAndTrailingHTMLSpaces(attr->value()); if (!url.isEmpty()) - addCSSImageProperty(attr, CSSPropertyBackgroundImage, document()->completeURL(url).string()); + addCSSImageProperty(CSSPropertyBackgroundImage, document()->completeURL(url).string()); + else + removeCSSProperty(CSSPropertyBackgroundImage); } else if (attr->name() == frameAttr) { // Cache the value of "frame" so that the table can examine it later. m_frameAttr = false; @@ -380,15 +352,16 @@ void HTMLTableElement::parseMappedAttribute(Attribute* attr) // Now map in the border styles of solid and hidden respectively. if (m_frameAttr) { - addCSSProperty(attr, CSSPropertyBorderTopWidth, CSSValueThin); - addCSSProperty(attr, CSSPropertyBorderBottomWidth, CSSValueThin); - addCSSProperty(attr, CSSPropertyBorderLeftWidth, CSSValueThin); - addCSSProperty(attr, CSSPropertyBorderRightWidth, CSSValueThin); - addCSSProperty(attr, CSSPropertyBorderTopStyle, borders[cTop] ? CSSValueSolid : CSSValueHidden); - addCSSProperty(attr, CSSPropertyBorderBottomStyle, borders[cBottom] ? CSSValueSolid : CSSValueHidden); - addCSSProperty(attr, CSSPropertyBorderLeftStyle, borders[cLeft] ? CSSValueSolid : CSSValueHidden); - addCSSProperty(attr, CSSPropertyBorderRightStyle, borders[cRight] ? CSSValueSolid : CSSValueHidden); - } + addCSSProperty(CSSPropertyBorderTopWidth, CSSValueThin); + addCSSProperty(CSSPropertyBorderBottomWidth, CSSValueThin); + addCSSProperty(CSSPropertyBorderLeftWidth, CSSValueThin); + addCSSProperty(CSSPropertyBorderRightWidth, CSSValueThin); + addCSSProperty(CSSPropertyBorderTopStyle, borders[cTop] ? CSSValueSolid : CSSValueHidden); + addCSSProperty(CSSPropertyBorderBottomStyle, borders[cBottom] ? CSSValueSolid : CSSValueHidden); + addCSSProperty(CSSPropertyBorderLeftStyle, borders[cLeft] ? CSSValueSolid : CSSValueHidden); + addCSSProperty(CSSPropertyBorderRightStyle, borders[cRight] ? CSSValueSolid : CSSValueHidden); + } else + removeCSSProperties(CSSPropertyBorderTopWidth, CSSPropertyBorderBottomWidth, CSSPropertyBorderLeftWidth, CSSPropertyBorderRightWidth, CSSPropertyBorderTopStyle, CSSPropertyBorderBottomStyle, CSSPropertyBorderLeftStyle, CSSPropertyBorderRightStyle); } else if (attr->name() == rulesAttr) { m_rulesAttr = UnsetRules; if (equalIgnoringCase(attr->value(), "none")) @@ -404,10 +377,14 @@ void HTMLTableElement::parseMappedAttribute(Attribute* attr) // The presence of a valid rules attribute causes border collapsing to be enabled. if (m_rulesAttr != UnsetRules) - addCSSProperty(attr, CSSPropertyBorderCollapse, CSSValueCollapse); + addCSSProperty(CSSPropertyBorderCollapse, CSSValueCollapse); + else + removeCSSProperty(CSSPropertyBorderCollapse); } else if (attr->name() == cellspacingAttr) { if (!attr->value().isEmpty()) - addCSSLength(attr, CSSPropertyBorderSpacing, attr->value()); + addCSSLength(CSSPropertyBorderSpacing, attr->value()); + else + removeCSSProperty(CSSPropertyBorderSpacing); } else if (attr->name() == cellpaddingAttr) { if (!attr->value().isEmpty()) m_padding = max(0, attr->value().toInt()); @@ -416,24 +393,35 @@ void HTMLTableElement::parseMappedAttribute(Attribute* attr) } else if (attr->name() == colsAttr) { // ### } else if (attr->name() == vspaceAttr) { - addCSSLength(attr, CSSPropertyMarginTop, attr->value()); - addCSSLength(attr, CSSPropertyMarginBottom, attr->value()); + if (attr->isNull()) + removeCSSProperties(CSSPropertyMarginTop, CSSPropertyMarginBottom); + else { + addCSSLength(CSSPropertyMarginTop, attr->value()); + addCSSLength(CSSPropertyMarginBottom, attr->value()); + } } else if (attr->name() == hspaceAttr) { - addCSSLength(attr, CSSPropertyMarginLeft, attr->value()); - addCSSLength(attr, CSSPropertyMarginRight, attr->value()); + if (attr->isNull()) + removeCSSProperties(CSSPropertyMarginLeft, CSSPropertyMarginRight); + else { + addCSSLength(CSSPropertyMarginLeft, attr->value()); + addCSSLength(CSSPropertyMarginRight, attr->value()); + } } else if (attr->name() == alignAttr) { if (!attr->value().isEmpty()) { if (equalIgnoringCase(attr->value(), "center")) { - addCSSProperty(attr, CSSPropertyWebkitMarginStart, CSSValueAuto); - addCSSProperty(attr, CSSPropertyWebkitMarginEnd, CSSValueAuto); + addCSSProperty(CSSPropertyWebkitMarginStart, CSSValueAuto); + addCSSProperty(CSSPropertyWebkitMarginEnd, CSSValueAuto); } else - addCSSProperty(attr, CSSPropertyFloat, attr->value()); - } + addCSSProperty(CSSPropertyFloat, attr->value()); + } else + removeCSSProperties(CSSPropertyWebkitMarginStart, CSSPropertyWebkitMarginEnd, CSSPropertyFloat); } else if (attr->name() == valignAttr) { if (!attr->value().isEmpty()) - addCSSProperty(attr, CSSPropertyVerticalAlign, attr->value()); + addCSSProperty(CSSPropertyVerticalAlign, attr->value()); + else + removeCSSProperty(CSSPropertyVerticalAlign); } else - HTMLElement::parseMappedAttribute(attr); + HTMLElement::parseAttribute(attr); if (bordersBefore != cellBorders() || oldPadding != m_padding) { m_sharedCellStyle = 0; @@ -445,9 +433,9 @@ void HTMLTableElement::parseMappedAttribute(Attribute* attr) } } -static CSSMutableStyleDeclaration* leakBorderStyle(int value) +static StylePropertySet* leakBorderStyle(int value) { - RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create(); + RefPtr<StylePropertySet> style = StylePropertySet::create(); style->setProperty(CSSPropertyBorderTopStyle, value); style->setProperty(CSSPropertyBorderBottomStyle, value); style->setProperty(CSSPropertyBorderLeftStyle, value); @@ -455,16 +443,16 @@ static CSSMutableStyleDeclaration* leakBorderStyle(int value) return style.release().leakRef(); } -PassRefPtr<CSSMutableStyleDeclaration> HTMLTableElement::additionalAttributeStyle() +StylePropertySet* HTMLTableElement::additionalAttributeStyle() { if ((!m_borderAttr && !m_borderColorAttr) || m_frameAttr) return 0; if (m_borderColorAttr) { - static CSSMutableStyleDeclaration* solidBorderStyle = leakBorderStyle(CSSValueSolid); + static StylePropertySet* solidBorderStyle = leakBorderStyle(CSSValueSolid); return solidBorderStyle; } - static CSSMutableStyleDeclaration* outsetBorderStyle = leakBorderStyle(CSSValueOutset); + static StylePropertySet* outsetBorderStyle = leakBorderStyle(CSSValueOutset); return outsetBorderStyle; } @@ -491,9 +479,9 @@ HTMLTableElement::CellBorders HTMLTableElement::cellBorders() const return NoBorders; } -PassRefPtr<CSSMutableStyleDeclaration> HTMLTableElement::createSharedCellStyle() +PassRefPtr<StylePropertySet> HTMLTableElement::createSharedCellStyle() { - RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create(); + RefPtr<StylePropertySet> style = StylePropertySet::create(); switch (cellBorders()) { case SolidBordersColsOnly: @@ -542,16 +530,16 @@ PassRefPtr<CSSMutableStyleDeclaration> HTMLTableElement::createSharedCellStyle() return style.release(); } -PassRefPtr<CSSMutableStyleDeclaration> HTMLTableElement::additionalCellStyle() +StylePropertySet* HTMLTableElement::additionalCellStyle() { if (!m_sharedCellStyle) m_sharedCellStyle = createSharedCellStyle(); - return m_sharedCellStyle; + return m_sharedCellStyle.get(); } -static CSSMutableStyleDeclaration* leakGroupBorderStyle(int rows) +static StylePropertySet* leakGroupBorderStyle(int rows) { - RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create(); + RefPtr<StylePropertySet> style = StylePropertySet::create(); if (rows) { style->setProperty(CSSPropertyBorderTopWidth, CSSValueThin); style->setProperty(CSSPropertyBorderBottomWidth, CSSValueThin); @@ -566,16 +554,16 @@ static CSSMutableStyleDeclaration* leakGroupBorderStyle(int rows) return style.release().leakRef(); } -PassRefPtr<CSSMutableStyleDeclaration> HTMLTableElement::additionalGroupStyle(bool rows) +StylePropertySet* HTMLTableElement::additionalGroupStyle(bool rows) { if (m_rulesAttr != GroupsRules) return 0; if (rows) { - static CSSMutableStyleDeclaration* rowBorderStyle = leakGroupBorderStyle(true); + static StylePropertySet* rowBorderStyle = leakGroupBorderStyle(true); return rowBorderStyle; } - static CSSMutableStyleDeclaration* columnBorderStyle = leakGroupBorderStyle(false); + static StylePropertySet* columnBorderStyle = leakGroupBorderStyle(false); return columnBorderStyle; } |