gecko/dom/html/HTMLDivElement.cpp

116 lines
3.4 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2012-05-21 04:12:37 -07:00
/* 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/. */
Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings) - move some HTML element classes to mozilla::dom. r=bz. --HG-- rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp rename : content/html/content/src/nsHTMLDivElement.cpp => content/html/content/src/HTMLDivElement.cpp rename : content/html/content/src/nsHTMLDivElement.h => content/html/content/src/HTMLDivElement.h rename : content/html/content/src/nsHTMLElement.cpp => content/html/content/src/HTMLElement.cpp rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h rename : content/html/content/src/nsHTMLUnknownElement.cpp => content/html/content/src/HTMLUnknownElement.cpp rename : content/html/content/src/nsHTMLUnknownElement.h => content/html/content/src/HTMLUnknownElement.h extra : rebase_source : 99a2b1764bfd34db1375939b967f816dc2a42a91
2012-12-21 06:06:50 -08:00
#include "HTMLDivElement.h"
#include "nsGenericHTMLElement.h"
#include "nsStyleConsts.h"
#include "nsMappedAttributes.h"
#include "mozilla/dom/HTMLDivElementBinding.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Div)
Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings) - move some HTML element classes to mozilla::dom. r=bz. --HG-- rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp rename : content/html/content/src/nsHTMLDivElement.cpp => content/html/content/src/HTMLDivElement.cpp rename : content/html/content/src/nsHTMLDivElement.h => content/html/content/src/HTMLDivElement.h rename : content/html/content/src/nsHTMLElement.cpp => content/html/content/src/HTMLElement.cpp rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h rename : content/html/content/src/nsHTMLUnknownElement.cpp => content/html/content/src/HTMLUnknownElement.cpp rename : content/html/content/src/nsHTMLUnknownElement.h => content/html/content/src/HTMLUnknownElement.h extra : rebase_source : 99a2b1764bfd34db1375939b967f816dc2a42a91
2012-12-21 06:06:50 -08:00
namespace mozilla {
namespace dom {
Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings) - move some HTML element classes to mozilla::dom. r=bz. --HG-- rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp rename : content/html/content/src/nsHTMLDivElement.cpp => content/html/content/src/HTMLDivElement.cpp rename : content/html/content/src/nsHTMLDivElement.h => content/html/content/src/HTMLDivElement.h rename : content/html/content/src/nsHTMLElement.cpp => content/html/content/src/HTMLElement.cpp rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h rename : content/html/content/src/nsHTMLUnknownElement.cpp => content/html/content/src/HTMLUnknownElement.cpp rename : content/html/content/src/nsHTMLUnknownElement.h => content/html/content/src/HTMLUnknownElement.h extra : rebase_source : 99a2b1764bfd34db1375939b967f816dc2a42a91
2012-12-21 06:06:50 -08:00
HTMLDivElement::~HTMLDivElement()
{
}
NS_IMPL_ISUPPORTS_INHERITED(HTMLDivElement, nsGenericHTMLElement,
nsIDOMHTMLDivElement)
Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings) - move some HTML element classes to mozilla::dom. r=bz. --HG-- rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp rename : content/html/content/src/nsHTMLDivElement.cpp => content/html/content/src/HTMLDivElement.cpp rename : content/html/content/src/nsHTMLDivElement.h => content/html/content/src/HTMLDivElement.h rename : content/html/content/src/nsHTMLElement.cpp => content/html/content/src/HTMLElement.cpp rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h rename : content/html/content/src/nsHTMLUnknownElement.cpp => content/html/content/src/HTMLUnknownElement.cpp rename : content/html/content/src/nsHTMLUnknownElement.h => content/html/content/src/HTMLUnknownElement.h extra : rebase_source : 99a2b1764bfd34db1375939b967f816dc2a42a91
2012-12-21 06:06:50 -08:00
NS_IMPL_ELEMENT_CLONE(HTMLDivElement)
JSObject*
HTMLDivElement::WrapNode(JSContext *aCx)
{
return dom::HTMLDivElementBinding::Wrap(aCx, this);
}
bool
Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings) - move some HTML element classes to mozilla::dom. r=bz. --HG-- rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp rename : content/html/content/src/nsHTMLDivElement.cpp => content/html/content/src/HTMLDivElement.cpp rename : content/html/content/src/nsHTMLDivElement.h => content/html/content/src/HTMLDivElement.h rename : content/html/content/src/nsHTMLElement.cpp => content/html/content/src/HTMLElement.cpp rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h rename : content/html/content/src/nsHTMLUnknownElement.cpp => content/html/content/src/HTMLUnknownElement.cpp rename : content/html/content/src/nsHTMLUnknownElement.h => content/html/content/src/HTMLUnknownElement.h extra : rebase_source : 99a2b1764bfd34db1375939b967f816dc2a42a91
2012-12-21 06:06:50 -08:00
HTMLDivElement::ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aNamespaceID == kNameSpaceID_None) {
if (mNodeInfo->Equals(nsGkAtoms::marquee)) {
if ((aAttribute == nsGkAtoms::width) ||
(aAttribute == nsGkAtoms::height)) {
return aResult.ParseSpecialIntValue(aValue);
}
if (aAttribute == nsGkAtoms::bgcolor) {
return aResult.ParseColor(aValue);
}
if ((aAttribute == nsGkAtoms::hspace) ||
(aAttribute == nsGkAtoms::vspace)) {
return aResult.ParseIntWithBounds(aValue, 0);
}
}
if (mNodeInfo->Equals(nsGkAtoms::div) &&
aAttribute == nsGkAtoms::align) {
return ParseDivAlignValue(aValue, aResult);
}
}
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
void
HTMLDivElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsRuleData* aData)
{
nsGenericHTMLElement::MapDivAlignAttributeInto(aAttributes, aData);
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
}
static void
MapMarqueeAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
{
nsGenericHTMLElement::MapImageMarginAttributeInto(aAttributes, aData);
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
nsGenericHTMLElement::MapBGColorInto(aAttributes, aData);
}
NS_IMETHODIMP_(bool)
Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings) - move some HTML element classes to mozilla::dom. r=bz. --HG-- rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp rename : content/html/content/src/nsHTMLDivElement.cpp => content/html/content/src/HTMLDivElement.cpp rename : content/html/content/src/nsHTMLDivElement.h => content/html/content/src/HTMLDivElement.h rename : content/html/content/src/nsHTMLElement.cpp => content/html/content/src/HTMLElement.cpp rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h rename : content/html/content/src/nsHTMLUnknownElement.cpp => content/html/content/src/HTMLUnknownElement.cpp rename : content/html/content/src/nsHTMLUnknownElement.h => content/html/content/src/HTMLUnknownElement.h extra : rebase_source : 99a2b1764bfd34db1375939b967f816dc2a42a91
2012-12-21 06:06:50 -08:00
HTMLDivElement::IsAttributeMapped(const nsIAtom* aAttribute) const
{
if (mNodeInfo->Equals(nsGkAtoms::div)) {
static const MappedAttributeEntry* const map[] = {
sDivAlignAttributeMap,
sCommonAttributeMap
};
return FindAttributeDependence(aAttribute, map);
}
if (mNodeInfo->Equals(nsGkAtoms::marquee)) {
static const MappedAttributeEntry* const map[] = {
sImageMarginSizeAttributeMap,
sBackgroundColorAttributeMap,
sCommonAttributeMap
};
return FindAttributeDependence(aAttribute, map);
}
return nsGenericHTMLElement::IsAttributeMapped(aAttribute);
}
nsMapRuleToAttributesFunc
Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings) - move some HTML element classes to mozilla::dom. r=bz. --HG-- rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp rename : content/html/content/src/nsHTMLDivElement.cpp => content/html/content/src/HTMLDivElement.cpp rename : content/html/content/src/nsHTMLDivElement.h => content/html/content/src/HTMLDivElement.h rename : content/html/content/src/nsHTMLElement.cpp => content/html/content/src/HTMLElement.cpp rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h rename : content/html/content/src/nsHTMLUnknownElement.cpp => content/html/content/src/HTMLUnknownElement.cpp rename : content/html/content/src/nsHTMLUnknownElement.h => content/html/content/src/HTMLUnknownElement.h extra : rebase_source : 99a2b1764bfd34db1375939b967f816dc2a42a91
2012-12-21 06:06:50 -08:00
HTMLDivElement::GetAttributeMappingFunction() const
{
if (mNodeInfo->Equals(nsGkAtoms::div)) {
return &MapAttributesIntoRule;
}
if (mNodeInfo->Equals(nsGkAtoms::marquee)) {
return &MapMarqueeAttributesIntoRule;
}
return nsGenericHTMLElement::GetAttributeMappingFunction();
}
Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings) - move some HTML element classes to mozilla::dom. r=bz. --HG-- rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp rename : content/html/content/src/nsHTMLDivElement.cpp => content/html/content/src/HTMLDivElement.cpp rename : content/html/content/src/nsHTMLDivElement.h => content/html/content/src/HTMLDivElement.h rename : content/html/content/src/nsHTMLElement.cpp => content/html/content/src/HTMLElement.cpp rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h rename : content/html/content/src/nsHTMLUnknownElement.cpp => content/html/content/src/HTMLUnknownElement.cpp rename : content/html/content/src/nsHTMLUnknownElement.h => content/html/content/src/HTMLUnknownElement.h extra : rebase_source : 99a2b1764bfd34db1375939b967f816dc2a42a91
2012-12-21 06:06:50 -08:00
} // namespace dom
} // namespace mozilla