diff --git a/content/html/content/src/HTMLParagraphElement.cpp b/content/html/content/src/HTMLParagraphElement.cpp new file mode 100644 index 00000000000..eebf90bc09f --- /dev/null +++ b/content/html/content/src/HTMLParagraphElement.cpp @@ -0,0 +1,78 @@ +/* -*- 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/HTMLParagraphElement.h" + +#include "nsStyleConsts.h" +#include "nsMappedAttributes.h" +#include "nsRuleData.h" + + +NS_IMPL_NS_NEW_HTML_ELEMENT(Paragraph) +DOMCI_NODE_DATA(HTMLParagraphElement, mozilla::dom::HTMLParagraphElement) + +namespace mozilla { +namespace dom { + +HTMLParagraphElement::~HTMLParagraphElement() +{ +} + +NS_IMPL_ADDREF_INHERITED(HTMLParagraphElement, Element) +NS_IMPL_RELEASE_INHERITED(HTMLParagraphElement, Element) + +// QueryInterface implementation for nsHTMLParagraphElement +NS_INTERFACE_TABLE_HEAD(HTMLParagraphElement) + NS_HTML_CONTENT_INTERFACE_TABLE1(HTMLParagraphElement, + nsIDOMHTMLParagraphElement) + NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLParagraphElement, + nsGenericHTMLElement) +NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLParagraphElement) + +NS_IMPL_ELEMENT_CLONE(HTMLParagraphElement) + +NS_IMPL_STRING_ATTR(HTMLParagraphElement, Align, align) + +bool +HTMLParagraphElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) +{ + if (aAttribute == nsGkAtoms::align && aNamespaceID == kNameSpaceID_None) { + return ParseDivAlignValue(aValue, aResult); + } + + return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue, + aResult); +} + +static void +MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) +{ + nsGenericHTMLElement::MapDivAlignAttributeInto(aAttributes, aData); + nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData); +} + +NS_IMETHODIMP_(bool) +HTMLParagraphElement::IsAttributeMapped(const nsIAtom* aAttribute) const +{ + static const MappedAttributeEntry* const map[] = { + sDivAlignAttributeMap, + sCommonAttributeMap, + }; + + return FindAttributeDependence(aAttribute, map); +} + + +nsMapRuleToAttributesFunc +HTMLParagraphElement::GetAttributeMappingFunction() const +{ + return &MapAttributesIntoRule; +} + +} // namespace dom +} // namespace mozilla diff --git a/content/html/content/src/HTMLParagraphElement.h b/content/html/content/src/HTMLParagraphElement.h new file mode 100644 index 00000000000..b067f82a1e3 --- /dev/null +++ b/content/html/content/src/HTMLParagraphElement.h @@ -0,0 +1,59 @@ +/* -*- 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/. */ + +#ifndef mozilla_dom_HTMLParagraphElement_h +#define mozilla_dom_HTMLParagraphElement_h + +#include "mozilla/Util.h" + +#include "nsIDOMHTMLParagraphElement.h" +#include "nsGenericHTMLElement.h" + +namespace mozilla { +namespace dom { + +class HTMLParagraphElement : public nsGenericHTMLElement, + public nsIDOMHTMLParagraphElement +{ +public: + HTMLParagraphElement(already_AddRefed aNodeInfo) + : nsGenericHTMLElement(aNodeInfo) + { + } + virtual ~HTMLParagraphElement(); + + // nsISupports + NS_DECL_ISUPPORTS_INHERITED + + // nsIDOMNode + NS_FORWARD_NSIDOMNODE_TO_NSINODE + + // nsIDOMElement + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + + // nsIDOMHTMLElement + NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC + + // nsIDOMHTMLParagraphElement + NS_DECL_NSIDOMHTMLPARAGRAPHELEMENT + + virtual bool ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult); + NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; + virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_HTMLParagraphElement_h diff --git a/content/html/content/src/Makefile.in b/content/html/content/src/Makefile.in index 9465a36727f..bdf1256f529 100644 --- a/content/html/content/src/Makefile.in +++ b/content/html/content/src/Makefile.in @@ -40,6 +40,7 @@ EXPORTS_mozilla/dom = \ HTMLImageElement.h \ HTMLLabelElement.h \ HTMLLIElement.h \ + HTMLParagraphElement.h \ HTMLSharedListElement.h \ HTMLTitleElement.h \ HTMLUnknownElement.h @@ -86,7 +87,7 @@ CPPSRCS = \ nsHTMLOptionElement.cpp \ nsHTMLOptGroupElement.cpp \ nsHTMLOutputElement.cpp \ - nsHTMLParagraphElement.cpp \ + HTMLParagraphElement.cpp \ nsHTMLPreElement.cpp \ nsHTMLProgressElement.cpp \ nsHTMLScriptElement.cpp \ diff --git a/content/html/content/src/nsHTMLParagraphElement.cpp b/content/html/content/src/nsHTMLParagraphElement.cpp deleted file mode 100644 index c2a267b138f..00000000000 --- a/content/html/content/src/nsHTMLParagraphElement.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- 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/Util.h" - -#include "nsIDOMHTMLParagraphElement.h" -#include "nsIDOMEventTarget.h" -#include "nsGenericHTMLElement.h" -#include "nsGkAtoms.h" -#include "nsStyleConsts.h" -#include "nsMappedAttributes.h" -#include "nsRuleData.h" - -using namespace mozilla; -using namespace mozilla::dom; - -// XXX missing nav attributes - -class nsHTMLParagraphElement : public nsGenericHTMLElement, - public nsIDOMHTMLParagraphElement -{ -public: - nsHTMLParagraphElement(already_AddRefed aNodeInfo); - virtual ~nsHTMLParagraphElement(); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsIDOMNode - NS_FORWARD_NSIDOMNODE_TO_NSINODE - - // nsIDOMElement - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - - // nsIDOMHTMLElement - NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC - - // nsIDOMHTMLParagraphElement - NS_DECL_NSIDOMHTMLPARAGRAPHELEMENT - - virtual bool ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult); - NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; - virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -}; - - -NS_IMPL_NS_NEW_HTML_ELEMENT(Paragraph) - - -nsHTMLParagraphElement::nsHTMLParagraphElement(already_AddRefed aNodeInfo) - : nsGenericHTMLElement(aNodeInfo) -{ -} - -nsHTMLParagraphElement::~nsHTMLParagraphElement() -{ -} - - -NS_IMPL_ADDREF_INHERITED(nsHTMLParagraphElement, Element) -NS_IMPL_RELEASE_INHERITED(nsHTMLParagraphElement, Element) - -DOMCI_NODE_DATA(HTMLParagraphElement, nsHTMLParagraphElement) - -// QueryInterface implementation for nsHTMLParagraphElement -NS_INTERFACE_TABLE_HEAD(nsHTMLParagraphElement) - NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLParagraphElement, - nsIDOMHTMLParagraphElement) - NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLParagraphElement, - nsGenericHTMLElement) -NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLParagraphElement) - - -NS_IMPL_ELEMENT_CLONE(nsHTMLParagraphElement) - - -NS_IMPL_STRING_ATTR(nsHTMLParagraphElement, Align, align) - - -bool -nsHTMLParagraphElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) -{ - if (aAttribute == nsGkAtoms::align && aNamespaceID == kNameSpaceID_None) { - return ParseDivAlignValue(aValue, aResult); - } - - return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue, - aResult); -} - -static void -MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) -{ - nsGenericHTMLElement::MapDivAlignAttributeInto(aAttributes, aData); - nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData); -} - -NS_IMETHODIMP_(bool) -nsHTMLParagraphElement::IsAttributeMapped(const nsIAtom* aAttribute) const -{ - static const MappedAttributeEntry* const map[] = { - sDivAlignAttributeMap, - sCommonAttributeMap, - }; - - return FindAttributeDependence(aAttribute, map); -} - - -nsMapRuleToAttributesFunc -nsHTMLParagraphElement::GetAttributeMappingFunction() const -{ - return &MapAttributesIntoRule; -}