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/. */
8 * Declaration of HTML <label> elements.
10 #ifndef HTMLLabelElement_h
11 #define HTMLLabelElement_h
13 #include "mozilla/Attributes.h"
14 #include "nsGenericHTMLElement.h"
17 class EventChainPostVisitor
;
20 class HTMLLabelElement final
: public nsGenericHTMLElement
{
22 explicit HTMLLabelElement(
23 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
)
24 : nsGenericHTMLElement(std::move(aNodeInfo
)), mHandlingEvent(false) {}
26 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLLabelElement
, label
)
29 NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLLabelElement
, nsGenericHTMLElement
)
32 virtual bool IsInteractiveHTMLContent() const override
{ return true; }
34 HTMLFormElement
* GetForm() const;
35 void GetHtmlFor(nsString
& aHtmlFor
) {
36 GetHTMLAttr(nsGkAtoms::_for
, aHtmlFor
);
38 void SetHtmlFor(const nsAString
& aHtmlFor
) {
39 SetHTMLAttr(nsGkAtoms::_for
, aHtmlFor
);
41 nsGenericHTMLElement
* GetControl() const { return GetLabeledElement(); }
43 using nsGenericHTMLElement::Focus
;
44 virtual void Focus(const FocusOptions
& aOptions
,
45 const mozilla::dom::CallerType aCallerType
,
46 ErrorResult
& aError
) override
;
49 MOZ_CAN_RUN_SCRIPT_BOUNDARY
50 virtual nsresult
PostHandleEvent(EventChainPostVisitor
& aVisitor
) override
;
52 virtual Result
<bool, nsresult
> PerformAccesskey(
53 bool aKeyCausesActivation
, bool aIsTrustedEvent
) override
;
54 virtual nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
56 nsGenericHTMLElement
* GetLabeledElement() const;
59 virtual ~HTMLLabelElement();
61 virtual JSObject
* WrapNode(JSContext
* aCx
,
62 JS::Handle
<JSObject
*> aGivenProto
) override
;
64 nsGenericHTMLElement
* GetFirstLabelableDescendant() const;
66 // XXX It would be nice if we could use an event flag instead.
71 } // namespace mozilla
73 #endif /* HTMLLabelElement_h */