mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 12:45:27 +00:00
873d562bc3
Backed out changeset b92f856e15a8 (bug 1451169) Backed out changeset 348e825756fa (bug 1451169) Backed out changeset 624d82428726 (bug 1451169) Backed out changeset 4d51610ca08e (bug 1451169) Backed out changeset bb76a9589717 (bug 1451169) Backed out changeset c145fbd03947 (bug 1451169) Backed out changeset 6d36289e0f54 (bug 1451169) Backed out changeset 914fb7cd9fc3 (bug 1451169) --HG-- extra : histedit_source : 94de6631919f895dec422bc0e564f5baf885ba4a%2C18f52c6c11d3064d3137a6847575effb7d407894
118 lines
3.7 KiB
C++
118 lines
3.7 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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 "mozilla/dom/HTMLTableColElementBinding.h"
|
|
#include "nsMappedAttributes.h"
|
|
#include "nsAttrValueInlines.h"
|
|
#include "mozilla/GenericSpecifiedValuesInlines.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, JS::Handle<JSObject*> aGivenProto)
|
|
{
|
|
return HTMLTableColElementBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLTableColElement)
|
|
|
|
bool
|
|
HTMLTableColElement::ParseAttribute(int32_t aNamespaceID,
|
|
nsAtom* aAttribute,
|
|
const nsAString& aValue,
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
|
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 */
|
|
aResult.ParseClampedNonNegativeInt(aValue, 1, 1, MAX_COLSPAN);
|
|
return true;
|
|
}
|
|
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,
|
|
aMaybeScriptedPrincipal, aResult);
|
|
}
|
|
|
|
void
|
|
HTMLTableColElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|
GenericSpecifiedValues* aData)
|
|
{
|
|
if (!aData->PropertyIsSet(eCSSProperty__x_span)) {
|
|
// 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 <col
|
|
// span> and <colgroup span> it's just disallowed.
|
|
if (val > 0) {
|
|
aData->SetIntValue(eCSSProperty__x_span, value->GetIntegerValue());
|
|
}
|
|
}
|
|
}
|
|
|
|
nsGenericHTMLElement::MapWidthAttributeInto(aAttributes, aData);
|
|
nsGenericHTMLElement::MapDivAlignAttributeInto(aAttributes, aData);
|
|
nsGenericHTMLElement::MapVAlignAttributeInto(aAttributes, aData);
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
|
}
|
|
|
|
NS_IMETHODIMP_(bool)
|
|
HTMLTableColElement::IsAttributeMapped(const nsAtom* aAttribute) const
|
|
{
|
|
static const MappedAttributeEntry attributes[] = {
|
|
{ &nsGkAtoms::width },
|
|
{ &nsGkAtoms::align },
|
|
{ &nsGkAtoms::valign },
|
|
{ &nsGkAtoms::span },
|
|
{ nullptr }
|
|
};
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
attributes,
|
|
sCommonAttributeMap,
|
|
};
|
|
|
|
return FindAttributeDependence(aAttribute, map);
|
|
}
|
|
|
|
|
|
nsMapRuleToAttributesFunc
|
|
HTMLTableColElement::GetAttributeMappingFunction() const
|
|
{
|
|
return &MapAttributesIntoRule;
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|