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
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/
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
15 * The Original Code is the Mozilla XTF project.
17 * The Initial Developer of the Original Code is
19 * Portions created by the Initial Developer are Copyright (C) 2004
20 * the Initial Developer. All Rights Reserved.
23 * Alex Fritze <alex@croczilla.com> (original author)
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.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef __NS_XTFELEMENTWRAPPER_H__
40 #define __NS_XTFELEMENTWRAPPER_H__
42 #include "nsIXTFElementWrapper.h"
43 #include "nsXMLElement.h"
44 #include "nsIXTFAttributeHandler.h"
45 #include "nsIXTFElement.h"
47 typedef nsXMLElement nsXTFElementWrapperBase
;
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 } }
55 class nsXTFElementWrapper
: public nsXTFElementWrapperBase
,
56 public nsIXTFElementWrapper
,
60 nsXTFElementWrapper(nsINodeInfo
* aNodeInfo
, nsIXTFElement
* aXTFElement
);
61 virtual ~nsXTFElementWrapper();
64 NS_DECLARE_STATIC_IID_ACCESSOR(NS_XTFELEMENTWRAPPER_IID
)
66 // nsISupports interface
67 NS_DECL_ISUPPORTS_INHERITED
68 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsXTFElementWrapper
,
69 nsXTFElementWrapperBase
)
71 // nsIXTFElementWrapper
72 NS_DECL_NSIXTFELEMENTWRAPPER
74 // nsIContent specializations:
75 virtual nsresult
BindToTree(nsIDocument
* aDocument
, nsIContent
* aParent
,
76 nsIContent
* aBindingParent
,
77 PRBool aCompileEventHandlers
);
78 virtual void UnbindFromTree(PRBool aDeep
= PR_TRUE
,
79 PRBool aNullParent
= PR_TRUE
);
80 nsresult
InsertChildAt(nsIContent
* aKid
, PRUint32 aIndex
,
82 nsresult
RemoveChildAt(PRUint32 aIndex
, PRBool aNotify
);
83 nsIAtom
*GetIDAttributeName() const;
84 nsresult
SetAttr(PRInt32 aNameSpaceID
, nsIAtom
* aName
,
85 nsIAtom
* aPrefix
, const nsAString
& aValue
,
87 PRBool
GetAttr(PRInt32 aNameSpaceID
, nsIAtom
* aName
,
88 nsAString
& aResult
) const;
89 PRBool
HasAttr(PRInt32 aNameSpaceID
, nsIAtom
* aName
) const;
90 virtual PRBool
AttrValueIs(PRInt32 aNameSpaceID
, nsIAtom
* aName
,
91 const nsAString
& aValue
,
92 nsCaseTreatment aCaseSensitive
) const;
93 virtual PRBool
AttrValueIs(PRInt32 aNameSpaceID
, nsIAtom
* aName
,
95 nsCaseTreatment aCaseSensitive
) const;
96 virtual PRInt32
FindAttrValueIn(PRInt32 aNameSpaceID
,
98 AttrValuesArray
* aValues
,
99 nsCaseTreatment aCaseSensitive
) const;
100 nsresult
UnsetAttr(PRInt32 aNameSpaceID
, nsIAtom
* aAttr
,
102 const nsAttrName
* GetAttrNameAt(PRUint32 aIndex
) const;
103 PRUint32
GetAttrCount() const;
104 virtual already_AddRefed
<nsINodeInfo
> GetExistingAttrNameFromQName(const nsAString
& aStr
) const;
106 virtual PRInt32
IntrinsicState() const;
108 virtual void BeginAddingChildren();
109 virtual nsresult
DoneAddingChildren(PRBool aHaveNotified
);
111 virtual nsIAtom
*GetClassAttributeName() const;
112 virtual const nsAttrValue
* DoGetClasses() const;
114 virtual void PerformAccesskey(PRBool aKeyCausesActivation
,
115 PRBool aIsTrustedEvent
);
117 // nsIDOMElement specializations:
118 NS_IMETHOD
GetAttribute(const nsAString
& aName
,
120 NS_IMETHOD
RemoveAttribute(const nsAString
& aName
);
121 NS_IMETHOD
HasAttribute(const nsAString
& aName
, PRBool
* aReturn
);
123 // nsIClassInfo interface
126 virtual nsresult
PostHandleEvent(nsEventChainPostVisitor
& aVisitor
);
128 nsresult
CloneState(nsIDOMElement
*aElement
)
130 return GetXTFElement()->CloneState(aElement
);
132 nsresult
Clone(nsINodeInfo
*aNodeInfo
, nsINode
**aResult
) const;
135 virtual nsIXTFElement
* GetXTFElement() const
140 // implementation helpers:
141 PRBool
QueryInterfaceInner(REFNSIID aIID
, void** result
);
143 PRBool
HandledByInner(nsIAtom
* attr
) const;
145 void RegUnregAccessKey(PRBool aDoReg
);
147 nsCOMPtr
<nsIXTFElement
> mXTFElement
;
149 PRUint32 mNotificationMask
;
150 nsCOMPtr
<nsIXTFAttributeHandler
> mAttributeHandler
;
153 * The intrinsic state of the element.
154 * @see nsIContent::IntrinsicState()
156 PRInt32 mIntrinsicState
;
158 // Temporary owner used by GetAttrNameAt
159 nsAttrName mTmpAttrName
;
161 nsCOMPtr
<nsIAtom
> mClassAttributeName
;
164 NS_DEFINE_STATIC_IID_ACCESSOR(nsXTFElementWrapper
, NS_XTFELEMENTWRAPPER_IID
)
167 NS_NewXTFElementWrapper(nsIXTFElement
* aXTFElement
, nsINodeInfo
* aNodeInfo
,
168 nsIContent
** aResult
);
170 #endif // __NS_XTFELEMENTWRAPPER_H__