1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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_HTMLLegendElement_h
8 #define mozilla_dom_HTMLLegendElement_h
10 #include "mozilla/Attributes.h"
11 #include "nsGenericHTMLElement.h"
12 #include "mozilla/dom/HTMLFormElement.h"
17 class HTMLLegendElement final
: public nsGenericHTMLElement
20 explicit HTMLLegendElement(already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
)
21 : nsGenericHTMLElement(std::move(aNodeInfo
))
25 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLLegendElement
, legend
)
27 using nsGenericHTMLElement::Focus
;
28 virtual void Focus(ErrorResult
& aError
) override
;
30 virtual bool PerformAccesskey(bool aKeyCausesActivation
,
31 bool aIsTrustedEvent
) override
;
34 virtual nsresult
BindToTree(nsIDocument
* aDocument
,
36 nsIContent
* aBindingParent
) override
;
37 virtual void UnbindFromTree(bool aDeep
= true,
38 bool aNullParent
= true) override
;
39 virtual bool ParseAttribute(int32_t aNamespaceID
,
41 const nsAString
& aValue
,
42 nsIPrincipal
* aMaybeScriptedPrincipal
,
43 nsAttrValue
& aResult
) override
;
44 virtual nsChangeHint
GetAttributeChangeHint(const nsAtom
* aAttribute
,
45 int32_t aModType
) const override
;
47 virtual nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
49 Element
* GetFormElement() const
51 nsCOMPtr
<nsIFormControl
> fieldsetControl
= do_QueryInterface(GetFieldSet());
53 return fieldsetControl
? fieldsetControl
->GetFormElement() : nullptr;
60 already_AddRefed
<HTMLFormElement
> GetForm();
62 void GetAlign(DOMString
& aAlign
)
64 GetHTMLAttr(nsGkAtoms::align
, aAlign
);
67 void SetAlign(const nsAString
& aAlign
, ErrorResult
& aError
)
69 SetHTMLAttr(nsGkAtoms::align
, aAlign
, aError
);
72 nsINode
* GetScopeChainParent() const override
74 Element
* form
= GetFormElement();
75 return form
? form
: nsGenericHTMLElement::GetScopeChainParent();
79 virtual ~HTMLLegendElement();
81 virtual JSObject
* WrapNode(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) override
;
84 * Get the fieldset content element that contains this legend.
85 * Returns null if there is no fieldset containing this legend.
87 nsIContent
* GetFieldSet() const;
91 } // namespace mozilla
93 #endif /* mozilla_dom_HTMLLegendElement_h */