/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/HTMLTableColElement.h" #include "nsMappedAttributes.h" #include "nsAttrValueInlines.h" #include "nsRuleData.h" #include "mozilla/dom/HTMLTableColElementBinding.h" NS_IMPL_NS_NEW_HTML_ELEMENT(TableCol) namespace mozilla { namespace dom { // use the same protection as ancient code did // http://lxr.mozilla.org/classic/source/lib/layout/laytable.c#46 #define MAX_COLSPAN 1000 HTMLTableColElement::~HTMLTableColElement() { } JSObject* HTMLTableColElement::WrapNode(JSContext *aCx) { return HTMLTableColElementBinding::Wrap(aCx, this); } NS_IMPL_ELEMENT_CLONE(HTMLTableColElement) bool HTMLTableColElement::ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult) { if (aNamespaceID == kNameSpaceID_None) { /* ignore these attributes, stored simply as strings ch */ if (aAttribute == nsGkAtoms::charoff) { return aResult.ParseSpecialIntValue(aValue); } if (aAttribute == nsGkAtoms::span) { /* protection from unrealistic large colspan values */ return aResult.ParseIntWithBounds(aValue, 1, MAX_COLSPAN); } if (aAttribute == nsGkAtoms::width) { return aResult.ParseSpecialIntValue(aValue); } if (aAttribute == nsGkAtoms::align) { return ParseTableCellHAlignValue(aValue, aResult); } if (aAttribute == nsGkAtoms::valign) { return ParseTableVAlignValue(aValue, aResult); } } return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue, aResult); } void HTMLTableColElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) { if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Table)) { nsCSSValue *span = aData->ValueForSpan(); if (span->GetUnit() == eCSSUnit_Null) { // span: int const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::span); if (value && value->Type() == nsAttrValue::eInteger) { int32_t val = value->GetIntegerValue(); // Note: Do NOT use this code for table cells! The value "0" // means something special for colspan and rowspan, but for