1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is Mozilla Communicator client code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #include "mozilla/Util.h"
39 :
40 : #include "nsIDOMHTMLParagraphElement.h"
41 : #include "nsIDOMEventTarget.h"
42 : #include "nsGenericHTMLElement.h"
43 : #include "nsGkAtoms.h"
44 : #include "nsStyleConsts.h"
45 : #include "nsMappedAttributes.h"
46 : #include "nsRuleData.h"
47 :
48 : using namespace mozilla;
49 :
50 : // XXX missing nav attributes
51 :
52 : class nsHTMLParagraphElement : public nsGenericHTMLElement,
53 : public nsIDOMHTMLParagraphElement
54 : {
55 : public:
56 : nsHTMLParagraphElement(already_AddRefed<nsINodeInfo> aNodeInfo);
57 : virtual ~nsHTMLParagraphElement();
58 :
59 : // nsISupports
60 : NS_DECL_ISUPPORTS_INHERITED
61 :
62 : // nsIDOMNode
63 0 : NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
64 :
65 : // nsIDOMElement
66 0 : NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
67 :
68 : // nsIDOMHTMLElement
69 0 : NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
70 :
71 : // nsIDOMHTMLParagraphElement
72 : NS_DECL_NSIDOMHTMLPARAGRAPHELEMENT
73 :
74 : virtual bool ParseAttribute(PRInt32 aNamespaceID,
75 : nsIAtom* aAttribute,
76 : const nsAString& aValue,
77 : nsAttrValue& aResult);
78 : NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
79 : virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
80 :
81 : virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
82 :
83 : virtual nsXPCClassInfo* GetClassInfo();
84 : };
85 :
86 :
87 36 : NS_IMPL_NS_NEW_HTML_ELEMENT(Paragraph)
88 :
89 :
90 18 : nsHTMLParagraphElement::nsHTMLParagraphElement(already_AddRefed<nsINodeInfo> aNodeInfo)
91 18 : : nsGenericHTMLElement(aNodeInfo)
92 : {
93 18 : }
94 :
95 36 : nsHTMLParagraphElement::~nsHTMLParagraphElement()
96 : {
97 72 : }
98 :
99 :
100 180 : NS_IMPL_ADDREF_INHERITED(nsHTMLParagraphElement, nsGenericElement)
101 180 : NS_IMPL_RELEASE_INHERITED(nsHTMLParagraphElement, nsGenericElement)
102 :
103 0 : DOMCI_NODE_DATA(HTMLParagraphElement, nsHTMLParagraphElement)
104 :
105 : // QueryInterface implementation for nsHTMLParagraphElement
106 564 : NS_INTERFACE_TABLE_HEAD(nsHTMLParagraphElement)
107 564 : NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLParagraphElement,
108 : nsIDOMHTMLParagraphElement)
109 564 : NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLParagraphElement,
110 : nsGenericHTMLElement)
111 0 : NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLParagraphElement)
112 :
113 :
114 0 : NS_IMPL_ELEMENT_CLONE(nsHTMLParagraphElement)
115 :
116 :
117 0 : NS_IMPL_STRING_ATTR(nsHTMLParagraphElement, Align, align)
118 :
119 :
120 : bool
121 0 : nsHTMLParagraphElement::ParseAttribute(PRInt32 aNamespaceID,
122 : nsIAtom* aAttribute,
123 : const nsAString& aValue,
124 : nsAttrValue& aResult)
125 : {
126 0 : if (aAttribute == nsGkAtoms::align && aNamespaceID == kNameSpaceID_None) {
127 0 : return ParseDivAlignValue(aValue, aResult);
128 : }
129 :
130 : return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
131 0 : aResult);
132 : }
133 :
134 : static void
135 0 : MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
136 : {
137 0 : nsGenericHTMLElement::MapDivAlignAttributeInto(aAttributes, aData);
138 0 : nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
139 0 : }
140 :
141 : NS_IMETHODIMP_(bool)
142 0 : nsHTMLParagraphElement::IsAttributeMapped(const nsIAtom* aAttribute) const
143 : {
144 : static const MappedAttributeEntry* const map[] = {
145 : sDivAlignAttributeMap,
146 : sCommonAttributeMap,
147 : };
148 :
149 0 : return FindAttributeDependence(aAttribute, map);
150 : }
151 :
152 :
153 : nsMapRuleToAttributesFunc
154 0 : nsHTMLParagraphElement::GetAttributeMappingFunction() const
155 : {
156 0 : return &MapAttributesIntoRule;
157 : }
|