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 "nsIDOMHTMLFrameElement.h"
41 : #include "nsGenericHTMLFrameElement.h"
42 : #include "nsGkAtoms.h"
43 : #include "nsIDocument.h"
44 : #include "nsIDOMDocument.h"
45 : #include "nsDOMError.h"
46 :
47 : using namespace mozilla;
48 : using namespace mozilla::dom;
49 :
50 : class nsHTMLFrameElement : public nsGenericHTMLFrameElement,
51 : public nsIDOMHTMLFrameElement
52 : {
53 : public:
54 : nsHTMLFrameElement(already_AddRefed<nsINodeInfo> aNodeInfo,
55 : mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
56 : virtual ~nsHTMLFrameElement();
57 :
58 : // nsISupports
59 : NS_DECL_ISUPPORTS_INHERITED
60 :
61 : // nsIDOMNode
62 0 : NS_FORWARD_NSIDOMNODE(nsGenericHTMLFrameElement::)
63 :
64 : // nsIDOMElement
65 0 : NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFrameElement::)
66 :
67 : // nsIDOMHTMLElement
68 0 : NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFrameElement::)
69 :
70 : // nsIDOMHTMLFrameElement
71 : NS_DECL_NSIDOMHTMLFRAMEELEMENT
72 :
73 : // nsIContent
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 : nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
80 : virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
81 : virtual nsXPCClassInfo* GetClassInfo();
82 : };
83 :
84 :
85 0 : NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Frame)
86 :
87 :
88 0 : nsHTMLFrameElement::nsHTMLFrameElement(already_AddRefed<nsINodeInfo> aNodeInfo,
89 : FromParser aFromParser)
90 0 : : nsGenericHTMLFrameElement(aNodeInfo, aFromParser)
91 : {
92 0 : }
93 :
94 0 : nsHTMLFrameElement::~nsHTMLFrameElement()
95 : {
96 0 : }
97 :
98 :
99 0 : NS_IMPL_ADDREF_INHERITED(nsHTMLFrameElement, nsGenericElement)
100 0 : NS_IMPL_RELEASE_INHERITED(nsHTMLFrameElement, nsGenericElement)
101 :
102 :
103 0 : DOMCI_NODE_DATA(HTMLFrameElement, nsHTMLFrameElement)
104 :
105 : // QueryInterface implementation for nsHTMLFrameElement
106 0 : NS_INTERFACE_TABLE_HEAD(nsHTMLFrameElement)
107 0 : NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLFrameElement, nsIDOMHTMLFrameElement)
108 0 : NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLFrameElement,
109 : nsGenericHTMLFrameElement)
110 0 : NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLFrameElement)
111 :
112 :
113 0 : NS_IMPL_ELEMENT_CLONE(nsHTMLFrameElement)
114 :
115 :
116 0 : NS_IMPL_STRING_ATTR(nsHTMLFrameElement, FrameBorder, frameborder)
117 0 : NS_IMPL_URI_ATTR(nsHTMLFrameElement, LongDesc, longdesc)
118 0 : NS_IMPL_STRING_ATTR(nsHTMLFrameElement, MarginHeight, marginheight)
119 0 : NS_IMPL_STRING_ATTR(nsHTMLFrameElement, MarginWidth, marginwidth)
120 0 : NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Name, name)
121 0 : NS_IMPL_BOOL_ATTR(nsHTMLFrameElement, NoResize, noresize)
122 0 : NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Scrolling, scrolling)
123 0 : NS_IMPL_URI_ATTR(nsHTMLFrameElement, Src, src)
124 :
125 :
126 : NS_IMETHODIMP
127 0 : nsHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
128 : {
129 0 : return nsGenericHTMLFrameElement::GetContentDocument(aContentDocument);
130 : }
131 :
132 : NS_IMETHODIMP
133 0 : nsHTMLFrameElement::GetContentWindow(nsIDOMWindow** aContentWindow)
134 : {
135 0 : return nsGenericHTMLFrameElement::GetContentWindow(aContentWindow);
136 : }
137 :
138 : bool
139 0 : nsHTMLFrameElement::ParseAttribute(PRInt32 aNamespaceID,
140 : nsIAtom* aAttribute,
141 : const nsAString& aValue,
142 : nsAttrValue& aResult)
143 : {
144 0 : if (aNamespaceID == kNameSpaceID_None) {
145 0 : if (aAttribute == nsGkAtoms::bordercolor) {
146 0 : return aResult.ParseColor(aValue);
147 : }
148 0 : if (aAttribute == nsGkAtoms::frameborder) {
149 0 : return ParseFrameborderValue(aValue, aResult);
150 : }
151 0 : if (aAttribute == nsGkAtoms::marginwidth) {
152 0 : return aResult.ParseSpecialIntValue(aValue);
153 : }
154 0 : if (aAttribute == nsGkAtoms::marginheight) {
155 0 : return aResult.ParseSpecialIntValue(aValue);
156 : }
157 0 : if (aAttribute == nsGkAtoms::scrolling) {
158 0 : return ParseScrollingValue(aValue, aResult);
159 : }
160 : }
161 :
162 : return nsGenericHTMLFrameElement::ParseAttribute(aNamespaceID, aAttribute,
163 0 : aValue, aResult);
164 : }
165 :
166 : static void
167 0 : MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
168 : nsRuleData* aData)
169 : {
170 0 : nsGenericHTMLElement::MapScrollingAttributeInto(aAttributes, aData);
171 0 : nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
172 0 : }
173 :
174 : NS_IMETHODIMP_(bool)
175 0 : nsHTMLFrameElement::IsAttributeMapped(const nsIAtom* aAttribute) const
176 : {
177 : static const MappedAttributeEntry* const map[] = {
178 : sScrollingAttributeMap,
179 : sCommonAttributeMap,
180 : };
181 :
182 0 : return FindAttributeDependence(aAttribute, map);
183 : }
184 :
185 : nsMapRuleToAttributesFunc
186 0 : nsHTMLFrameElement::GetAttributeMappingFunction() const
187 : {
188 0 : return &MapAttributesIntoRule;
189 : }
|