Bug 1560374 - Set testharness and reftest web-platform-tests to Tier-1; r=jmaher...
[gecko.git] / dom / html / HTMLLabelElement.h
blob94bdc2795d2fee9ea92952f26286e78fc876ef3b
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 /**
8 * Declaration of HTML <label> elements.
9 */
10 #ifndef HTMLLabelElement_h
11 #define HTMLLabelElement_h
13 #include "mozilla/Attributes.h"
14 #include "nsGenericHTMLElement.h"
16 namespace mozilla {
17 class EventChainPostVisitor;
18 namespace dom {
20 class HTMLLabelElement final : public nsGenericHTMLElement {
21 public:
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)
28 // nsISupports
29 NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLLabelElement, nsGenericHTMLElement)
31 // Element
32 virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override {
33 return true;
36 HTMLFormElement* GetForm() const;
37 void GetHtmlFor(nsString& aHtmlFor) {
38 GetHTMLAttr(nsGkAtoms::_for, aHtmlFor);
40 void SetHtmlFor(const nsAString& aHtmlFor) {
41 SetHTMLAttr(nsGkAtoms::_for, aHtmlFor);
43 nsGenericHTMLElement* GetControl() const { return GetLabeledElement(); }
45 using nsGenericHTMLElement::Focus;
46 virtual void Focus(const FocusOptions& aOptions,
47 ErrorResult& aError) override;
49 // nsIContent
50 MOZ_CAN_RUN_SCRIPT_BOUNDARY
51 virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
52 virtual bool PerformAccesskey(bool aKeyCausesActivation,
53 bool aIsTrustedEvent) override;
54 virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
56 nsGenericHTMLElement* GetLabeledElement() const;
58 protected:
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.
67 bool mHandlingEvent;
70 } // namespace dom
71 } // namespace mozilla
73 #endif /* HTMLLabelElement_h */