1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 // vim:set et sw=2 sts=2 cin:
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_HTMLObjectElement_h
8 #define mozilla_dom_HTMLObjectElement_h
10 #include "mozilla/Attributes.h"
11 #include "nsGenericHTMLElement.h"
12 #include "nsObjectLoadingContent.h"
13 #include "nsIDOMHTMLObjectElement.h"
14 #include "nsIConstraintValidation.h"
19 class HTMLObjectElement MOZ_FINAL
: public nsGenericHTMLFormElement
20 , public nsObjectLoadingContent
21 , public nsIDOMHTMLObjectElement
22 , public nsIConstraintValidation
25 explicit HTMLObjectElement(already_AddRefed
<mozilla::dom::NodeInfo
>& aNodeInfo
,
26 FromParser aFromParser
= NOT_FROM_PARSER
);
29 NS_DECL_ISUPPORTS_INHERITED
31 virtual int32_t TabIndexDefault() MOZ_OVERRIDE
;
35 NS_IMETHOD
PostHandleEvent(EventChainPostVisitor
& aVisitor
) MOZ_OVERRIDE
;
37 static void OnFocusBlurPlugin(Element
* aElement
, bool aFocus
);
38 static void HandleFocusBlurPlugin(Element
* aElement
, WidgetEvent
* aEvent
);
39 // Weak pointer. Null if last action was blur.
40 static Element
* sLastFocused
;
43 // nsIDOMHTMLObjectElement
44 NS_DECL_NSIDOMHTMLOBJECTELEMENT
46 virtual nsresult
BindToTree(nsIDocument
*aDocument
, nsIContent
*aParent
,
47 nsIContent
*aBindingParent
,
48 bool aCompileEventHandlers
) MOZ_OVERRIDE
;
49 virtual void UnbindFromTree(bool aDeep
= true,
50 bool aNullParent
= true) MOZ_OVERRIDE
;
51 virtual nsresult
SetAttr(int32_t aNameSpaceID
, nsIAtom
*aName
,
52 nsIAtom
*aPrefix
, const nsAString
&aValue
,
53 bool aNotify
) MOZ_OVERRIDE
;
54 virtual nsresult
UnsetAttr(int32_t aNameSpaceID
, nsIAtom
* aAttribute
,
55 bool aNotify
) MOZ_OVERRIDE
;
57 virtual bool IsHTMLFocusable(bool aWithMouse
, bool *aIsFocusable
, int32_t *aTabIndex
) MOZ_OVERRIDE
;
58 virtual IMEState
GetDesiredIMEState() MOZ_OVERRIDE
;
60 // Overriden nsIFormControl methods
61 NS_IMETHOD_(uint32_t) GetType() const MOZ_OVERRIDE
63 return NS_FORM_OBJECT
;
66 NS_IMETHOD
Reset() MOZ_OVERRIDE
;
67 NS_IMETHOD
SubmitNamesValues(nsFormSubmission
*aFormSubmission
) MOZ_OVERRIDE
;
69 virtual bool IsDisabled() const MOZ_OVERRIDE
{ return false; }
71 virtual void DoneAddingChildren(bool aHaveNotified
) MOZ_OVERRIDE
;
72 virtual bool IsDoneAddingChildren() MOZ_OVERRIDE
;
74 virtual bool ParseAttribute(int32_t aNamespaceID
,
76 const nsAString
&aValue
,
77 nsAttrValue
&aResult
) MOZ_OVERRIDE
;
78 virtual nsMapRuleToAttributesFunc
GetAttributeMappingFunction() const MOZ_OVERRIDE
;
79 NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom
*aAttribute
) const MOZ_OVERRIDE
;
80 virtual EventStates
IntrinsicState() const MOZ_OVERRIDE
;
81 virtual void DestroyContent() MOZ_OVERRIDE
;
83 // nsObjectLoadingContent
84 virtual uint32_t GetCapabilities() const MOZ_OVERRIDE
;
86 virtual nsresult
Clone(mozilla::dom::NodeInfo
*aNodeInfo
, nsINode
**aResult
) const MOZ_OVERRIDE
;
88 nsresult
CopyInnerTo(Element
* aDest
);
90 void StartObjectLoad() { StartObjectLoad(true); }
92 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLObjectElement
,
93 nsGenericHTMLFormElement
)
95 // Web IDL binding methods
96 // XPCOM GetData is ok; note that it's a URI attribute with a weird base URI
97 void SetData(const nsAString
& aValue
, ErrorResult
& aRv
)
99 SetHTMLAttr(nsGkAtoms::data
, aValue
, aRv
);
101 void GetType(DOMString
& aValue
)
103 GetHTMLAttr(nsGkAtoms::type
, aValue
);
105 void SetType(const nsAString
& aValue
, ErrorResult
& aRv
)
107 SetHTMLAttr(nsGkAtoms::type
, aValue
, aRv
);
111 return GetBoolAttr(nsGkAtoms::typemustmatch
);
113 void SetTypeMustMatch(bool aValue
, ErrorResult
& aRv
)
115 SetHTMLBoolAttr(nsGkAtoms::typemustmatch
, aValue
, aRv
);
117 void GetName(DOMString
& aValue
)
119 GetHTMLAttr(nsGkAtoms::name
, aValue
);
121 void SetName(const nsAString
& aValue
, ErrorResult
& aRv
)
123 SetHTMLAttr(nsGkAtoms::name
, aValue
, aRv
);
125 void GetUseMap(DOMString
& aValue
)
127 GetHTMLAttr(nsGkAtoms::usemap
, aValue
);
129 void SetUseMap(const nsAString
& aValue
, ErrorResult
& aRv
)
131 SetHTMLAttr(nsGkAtoms::usemap
, aValue
, aRv
);
133 using nsGenericHTMLFormElement::GetForm
;
134 void GetWidth(DOMString
& aValue
)
136 GetHTMLAttr(nsGkAtoms::width
, aValue
);
138 void SetWidth(const nsAString
& aValue
, ErrorResult
& aRv
)
140 SetHTMLAttr(nsGkAtoms::width
, aValue
, aRv
);
142 void GetHeight(DOMString
& aValue
)
144 GetHTMLAttr(nsGkAtoms::height
, aValue
);
146 void SetHeight(const nsAString
& aValue
, ErrorResult
& aRv
)
148 SetHTMLAttr(nsGkAtoms::height
, aValue
, aRv
);
150 using nsObjectLoadingContent::GetContentDocument
;
151 nsIDOMWindow
* GetContentWindow();
152 using nsIConstraintValidation::CheckValidity
;
153 using nsIConstraintValidation::GetValidationMessage
;
154 void GetAlign(DOMString
& aValue
)
156 GetHTMLAttr(nsGkAtoms::align
, aValue
);
158 void SetAlign(const nsAString
& aValue
, ErrorResult
& aRv
)
160 SetHTMLAttr(nsGkAtoms::align
, aValue
, aRv
);
162 void GetArchive(DOMString
& aValue
)
164 GetHTMLAttr(nsGkAtoms::archive
, aValue
);
166 void SetArchive(const nsAString
& aValue
, ErrorResult
& aRv
)
168 SetHTMLAttr(nsGkAtoms::archive
, aValue
, aRv
);
170 // XPCOM GetCode is ok; note that it's a URI attribute with a weird base URI
171 void SetCode(const nsAString
& aValue
, ErrorResult
& aRv
)
173 SetHTMLAttr(nsGkAtoms::code
, aValue
, aRv
);
177 return GetBoolAttr(nsGkAtoms::declare
);
179 void SetDeclare(bool aValue
, ErrorResult
& aRv
)
181 SetHTMLBoolAttr(nsGkAtoms::declare
, aValue
, aRv
);
185 return GetUnsignedIntAttr(nsGkAtoms::hspace
, 0);
187 void SetHspace(uint32_t aValue
, ErrorResult
& aRv
)
189 SetUnsignedIntAttr(nsGkAtoms::hspace
, aValue
, aRv
);
191 void GetStandby(DOMString
& aValue
)
193 GetHTMLAttr(nsGkAtoms::standby
, aValue
);
195 void SetStandby(const nsAString
& aValue
, ErrorResult
& aRv
)
197 SetHTMLAttr(nsGkAtoms::standby
, aValue
, aRv
);
201 return GetUnsignedIntAttr(nsGkAtoms::vspace
, 0);
203 void SetVspace(uint32_t aValue
, ErrorResult
& aRv
)
205 SetUnsignedIntAttr(nsGkAtoms::vspace
, aValue
, aRv
);
207 // XPCOM GetCodebase is ok; note that it's a URI attribute
208 void SetCodeBase(const nsAString
& aValue
, ErrorResult
& aRv
)
210 SetHTMLAttr(nsGkAtoms::codebase
, aValue
, aRv
);
212 void GetCodeType(DOMString
& aValue
)
214 GetHTMLAttr(nsGkAtoms::codetype
, aValue
);
216 void SetCodeType(const nsAString
& aValue
, ErrorResult
& aRv
)
218 SetHTMLAttr(nsGkAtoms::codetype
, aValue
, aRv
);
220 void GetBorder(DOMString
& aValue
)
222 GetHTMLAttr(nsGkAtoms::border
, aValue
);
224 void SetBorder(const nsAString
& aValue
, ErrorResult
& aRv
)
226 SetHTMLAttr(nsGkAtoms::border
, aValue
, aRv
);
228 nsIDocument
* GetSVGDocument()
230 return GetContentDocument();
235 * Calls LoadObject with the correct arguments to start the plugin load.
237 void StartObjectLoad(bool aNotify
);
240 * Returns if the element is currently focusable regardless of it's tabindex
241 * value. This is used to know the default tabindex value.
243 bool IsFocusableForTabIndex();
245 virtual void GetItemValueText(nsAString
& text
) MOZ_OVERRIDE
;
246 virtual void SetItemValueText(const nsAString
& text
) MOZ_OVERRIDE
;
248 virtual ~HTMLObjectElement();
250 virtual JSObject
* WrapNode(JSContext
*aCx
) MOZ_OVERRIDE
;
252 static void MapAttributesIntoRule(const nsMappedAttributes
* aAttributes
,
255 bool mIsDoneAddingChildren
;
259 } // namespace mozilla
261 #endif // mozilla_dom_HTMLObjectElement_h