2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-05-25 04:18:23 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Declaration of HTML <label> elements.
|
|
|
|
*/
|
2012-12-21 18:06:50 +04:00
|
|
|
#ifndef HTMLLabelElement_h
|
|
|
|
#define HTMLLabelElement_h
|
2011-05-25 04:18:23 +04:00
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-05-25 04:18:23 +04:00
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
namespace mozilla {
|
2014-03-18 08:48:20 +04:00
|
|
|
class EventChainPostVisitor;
|
2012-12-21 18:06:50 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2017-08-14 19:31:47 +03:00
|
|
|
class HTMLLabelElement final : public nsGenericHTMLElement {
|
2011-05-25 04:18:23 +04:00
|
|
|
public:
|
2018-09-21 23:45:49 +03:00
|
|
|
explicit HTMLLabelElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
|
|
|
: nsGenericHTMLElement(std::move(aNodeInfo)), mHandlingEvent(false) {}
|
2011-05-25 04:18:23 +04:00
|
|
|
|
2018-03-22 00:39:04 +03:00
|
|
|
NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLLabelElement, label)
|
2011-05-25 04:18:23 +04:00
|
|
|
|
|
|
|
// nsISupports
|
2018-02-12 23:44:40 +03:00
|
|
|
NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLLabelElement, nsGenericHTMLElement)
|
2011-05-25 04:18:23 +04:00
|
|
|
|
2015-01-20 23:39:28 +03:00
|
|
|
// Element
|
2020-04-28 14:22:32 +03:00
|
|
|
virtual bool IsInteractiveHTMLContent() const override { return true; }
|
2015-01-20 23:39:28 +03:00
|
|
|
|
2016-05-27 02:39:03 +03:00
|
|
|
HTMLFormElement* GetForm() const;
|
2012-12-21 18:07:28 +04:00
|
|
|
void GetHtmlFor(nsString& aHtmlFor) {
|
|
|
|
GetHTMLAttr(nsGkAtoms::_for, aHtmlFor);
|
|
|
|
}
|
2017-08-14 19:31:47 +03:00
|
|
|
void SetHtmlFor(const nsAString& aHtmlFor) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::_for, aHtmlFor);
|
2012-12-21 18:07:28 +04:00
|
|
|
}
|
|
|
|
nsGenericHTMLElement* GetControl() const { return GetLabeledElement(); }
|
|
|
|
|
2013-08-08 00:23:08 +04:00
|
|
|
using nsGenericHTMLElement::Focus;
|
2019-04-12 11:16:47 +03:00
|
|
|
virtual void Focus(const FocusOptions& aOptions,
|
2020-01-16 17:38:40 +03:00
|
|
|
const mozilla::dom::CallerType aCallerType,
|
2019-04-12 11:16:47 +03:00
|
|
|
ErrorResult& aError) override;
|
2011-05-25 04:18:23 +04:00
|
|
|
|
|
|
|
// nsIContent
|
2019-05-06 16:15:05 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
|
2015-09-18 15:18:42 +03:00
|
|
|
virtual bool PerformAccesskey(bool aKeyCausesActivation,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aIsTrustedEvent) override;
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
2011-05-25 04:18:23 +04:00
|
|
|
|
2012-12-21 18:07:28 +04:00
|
|
|
nsGenericHTMLElement* GetLabeledElement() const;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-05-25 04:18:23 +04:00
|
|
|
protected:
|
2014-07-09 01:23:16 +04:00
|
|
|
virtual ~HTMLLabelElement();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2012-12-21 18:07:28 +04:00
|
|
|
|
|
|
|
nsGenericHTMLElement* GetFirstLabelableDescendant() const;
|
2011-05-25 04:18:23 +04:00
|
|
|
|
|
|
|
// XXX It would be nice if we could use an event flag instead.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mHandlingEvent;
|
2011-05-25 04:18:23 +04:00
|
|
|
};
|
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* HTMLLabelElement_h */
|