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 the Mozilla XTF project.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Alex Fritze.
19 : * Portions created by the Initial Developer are Copyright (C) 2004
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Alex Fritze <alex@croczilla.com> (original author)
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either the GNU General Public License Version 2 or later (the "GPL"), or
27 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #ifndef __NS_XTFELEMENTWRAPPER_H__
40 : #define __NS_XTFELEMENTWRAPPER_H__
41 :
42 : #include "nsIXTFElementWrapper.h"
43 : #include "nsXMLElement.h"
44 : #include "nsIXTFAttributeHandler.h"
45 : #include "nsIXTFElement.h"
46 :
47 : typedef nsXMLElement nsXTFElementWrapperBase;
48 :
49 : // Pseudo IID for nsXTFElementWrapper
50 : // {599EB85F-ABC0-4B52-A1B0-EA103D48E3AE}
51 : #define NS_XTFELEMENTWRAPPER_IID \
52 : { 0x599eb85f, 0xabc0, 0x4b52, { 0xa1, 0xb0, 0xea, 0x10, 0x3d, 0x48, 0xe3, 0xae } }
53 :
54 :
55 : class nsXTFElementWrapper : public nsXTFElementWrapperBase,
56 : public nsIXTFElementWrapper,
57 : public nsXPCClassInfo
58 : {
59 : public:
60 : nsXTFElementWrapper(already_AddRefed<nsINodeInfo> aNodeInfo, nsIXTFElement* aXTFElement);
61 : virtual ~nsXTFElementWrapper();
62 : nsresult Init();
63 :
64 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_XTFELEMENTWRAPPER_IID)
65 :
66 : // nsISupports interface
67 : NS_DECL_ISUPPORTS_INHERITED
68 1468 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsXTFElementWrapper,
69 : nsXTFElementWrapperBase)
70 :
71 : // nsIXTFElementWrapper
72 : NS_DECL_NSIXTFELEMENTWRAPPER
73 :
74 : // nsIContent specializations:
75 : #ifdef HAVE_CPP_AMBIGUITY_RESOLVING_USING
76 : using nsINode::GetProperty;
77 : using nsINode::SetProperty;
78 : #endif
79 :
80 : virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
81 : nsIContent* aBindingParent,
82 : bool aCompileEventHandlers);
83 : virtual void UnbindFromTree(bool aDeep = true,
84 : bool aNullParent = true);
85 : nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
86 : bool aNotify);
87 : nsresult RemoveChildAt(PRUint32 aIndex, bool aNotify);
88 : nsIAtom *GetIDAttributeName() const;
89 : nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
90 : nsIAtom* aPrefix, const nsAString& aValue,
91 : bool aNotify);
92 : bool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
93 : nsAString& aResult) const;
94 : bool HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const;
95 : virtual bool AttrValueIs(PRInt32 aNameSpaceID, nsIAtom* aName,
96 : const nsAString& aValue,
97 : nsCaseTreatment aCaseSensitive) const;
98 : virtual bool AttrValueIs(PRInt32 aNameSpaceID, nsIAtom* aName,
99 : nsIAtom* aValue,
100 : nsCaseTreatment aCaseSensitive) const;
101 : virtual PRInt32 FindAttrValueIn(PRInt32 aNameSpaceID,
102 : nsIAtom* aName,
103 : AttrValuesArray* aValues,
104 : nsCaseTreatment aCaseSensitive) const;
105 : nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttr,
106 : bool aNotify);
107 : const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const;
108 : PRUint32 GetAttrCount() const;
109 : virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const;
110 :
111 : virtual nsEventStates IntrinsicState() const;
112 :
113 : virtual void BeginAddingChildren();
114 : virtual void DoneAddingChildren(bool aHaveNotified);
115 :
116 : virtual nsIAtom *GetClassAttributeName() const;
117 : virtual const nsAttrValue* DoGetClasses() const;
118 :
119 : virtual void PerformAccesskey(bool aKeyCausesActivation,
120 : bool aIsTrustedEvent);
121 :
122 : // nsIDOMElement specializations:
123 : NS_IMETHOD GetAttribute(const nsAString& aName,
124 : nsAString& aReturn);
125 : NS_IMETHOD RemoveAttribute(const nsAString& aName);
126 : NS_IMETHOD HasAttribute(const nsAString& aName, bool* aReturn);
127 :
128 : // nsIClassInfo interface
129 : NS_DECL_NSICLASSINFO
130 :
131 : // nsIXPCScriptable interface
132 18 : NS_FORWARD_SAFE_NSIXPCSCRIPTABLE(GetBaseXPCClassInfo())
133 :
134 : // nsXPCClassInfo
135 0 : virtual void PreserveWrapper(nsISupports *aNative)
136 : {
137 0 : nsXPCClassInfo *ci = GetBaseXPCClassInfo();
138 0 : if (ci) {
139 0 : ci->PreserveWrapper(aNative);
140 : }
141 0 : }
142 2 : virtual PRUint32 GetInterfacesBitmap()
143 : {
144 2 : nsXPCClassInfo *ci = GetBaseXPCClassInfo();
145 2 : return ci ? ci->GetInterfacesBitmap() : 0;
146 : }
147 :
148 : virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
149 :
150 0 : nsresult CloneState(nsIDOMElement *aElement)
151 : {
152 0 : return GetXTFElement()->CloneState(aElement);
153 : }
154 : nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
155 :
156 2 : virtual nsXPCClassInfo* GetClassInfo() { return this; }
157 :
158 0 : virtual void NodeInfoChanged(nsINodeInfo* aOldNodeInfo)
159 : {
160 0 : }
161 :
162 : protected:
163 8 : virtual nsIXTFElement* GetXTFElement() const
164 : {
165 8 : return mXTFElement;
166 : }
167 :
168 40 : static nsXPCClassInfo* GetBaseXPCClassInfo()
169 : {
170 : return static_cast<nsXPCClassInfo*>(
171 40 : NS_GetDOMClassInfoInstance(eDOMClassInfo_Element_id));
172 : }
173 :
174 : // implementation helpers:
175 : bool QueryInterfaceInner(REFNSIID aIID, void** result);
176 :
177 : bool HandledByInner(nsIAtom* attr) const;
178 :
179 : void RegUnregAccessKey(bool aDoReg);
180 :
181 : nsCOMPtr<nsIXTFElement> mXTFElement;
182 :
183 : PRUint32 mNotificationMask;
184 : nsCOMPtr<nsIXTFAttributeHandler> mAttributeHandler;
185 :
186 : /*
187 : * The intrinsic state of the element.
188 : * @see nsIContent::IntrinsicState()
189 : */
190 : nsEventStates mIntrinsicState;
191 :
192 : // Temporary owner used by GetAttrNameAt
193 : nsAttrName mTmpAttrName;
194 :
195 : nsCOMPtr<nsIAtom> mClassAttributeName;
196 : };
197 :
198 : NS_DEFINE_STATIC_IID_ACCESSOR(nsXTFElementWrapper, NS_XTFELEMENTWRAPPER_IID)
199 :
200 : nsresult
201 : NS_NewXTFElementWrapper(nsIXTFElement* aXTFElement, already_AddRefed<nsINodeInfo> aNodeInfo,
202 : nsIContent** aResult);
203 :
204 : #endif // __NS_XTFELEMENTWRAPPER_H__
|