2011-05-25 00:18:23 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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 00:18:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Declaration of HTML <label> elements.
|
|
|
|
*/
|
2012-12-21 14:06:50 +00:00
|
|
|
#ifndef HTMLLabelElement_h
|
|
|
|
#define HTMLLabelElement_h
|
2011-05-25 00:18:23 +00:00
|
|
|
|
2013-05-29 20:43:41 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-05-25 00:18:23 +00:00
|
|
|
#include "nsGenericHTMLElement.h"
|
2013-07-31 03:32:35 +00:00
|
|
|
#include "nsIDOMHTMLLabelElement.h"
|
2011-05-25 00:18:23 +00:00
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
namespace mozilla {
|
2014-03-18 04:48:20 +00:00
|
|
|
class EventChainPostVisitor;
|
2012-12-21 14:06:50 +00:00
|
|
|
namespace dom {
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class HTMLLabelElement final : public nsGenericHTMLFormElement,
|
2015-03-27 18:52:19 +00:00
|
|
|
public nsIDOMHTMLLabelElement
|
2011-05-25 00:18:23 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-09-02 00:49:25 +00:00
|
|
|
explicit HTMLLabelElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2012-12-21 14:06:50 +00:00
|
|
|
: nsGenericHTMLFormElement(aNodeInfo),
|
|
|
|
mHandlingEvent(false)
|
|
|
|
{
|
|
|
|
}
|
2011-05-25 00:18:23 +00:00
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLLabelElement, label)
|
2011-05-25 00:18:23 +00:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2015-01-20 20:39:28 +00:00
|
|
|
// Element
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override
|
2015-01-20 20:39:28 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-31 03:32:35 +00:00
|
|
|
// nsIDOMHTMLLabelElement
|
|
|
|
NS_DECL_NSIDOMHTMLLABELELEMENT
|
|
|
|
|
2012-12-21 14:07:28 +00:00
|
|
|
using nsGenericHTMLFormElement::GetForm;
|
|
|
|
void GetHtmlFor(nsString& aHtmlFor)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::_for, aHtmlFor);
|
|
|
|
}
|
|
|
|
void SetHtmlFor(const nsAString& aHtmlFor, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::_for, aHtmlFor, aError);
|
|
|
|
}
|
|
|
|
nsGenericHTMLElement* GetControl() const
|
|
|
|
{
|
|
|
|
return GetLabeledElement();
|
|
|
|
}
|
|
|
|
|
2013-08-07 20:23:08 +00:00
|
|
|
using nsGenericHTMLElement::Focus;
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void Focus(mozilla::ErrorResult& aError) override;
|
2011-05-25 00:18:23 +00:00
|
|
|
|
|
|
|
// nsIFormControl
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD_(uint32_t) GetType() const override { return NS_FORM_LABEL; }
|
|
|
|
NS_IMETHOD Reset() override;
|
|
|
|
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) override;
|
2011-05-25 00:18:23 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool IsDisabled() const override { return false; }
|
2011-05-25 00:18:23 +00:00
|
|
|
|
|
|
|
// nsIContent
|
2014-03-18 04:48:20 +00:00
|
|
|
virtual nsresult PostHandleEvent(
|
2015-03-21 16:28:04 +00:00
|
|
|
EventChainPostVisitor& aVisitor) override;
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual void PerformAccesskey(bool aKeyCausesActivation,
|
2015-03-21 16:28:04 +00:00
|
|
|
bool aIsTrustedEvent) override;
|
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
|
2011-05-25 00:18:23 +00:00
|
|
|
|
2012-12-21 14:07:28 +00:00
|
|
|
nsGenericHTMLElement* GetLabeledElement() const;
|
2011-05-25 00:18:23 +00:00
|
|
|
protected:
|
2014-07-08 21:23:16 +00:00
|
|
|
virtual ~HTMLLabelElement();
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2012-12-21 14:07:28 +00:00
|
|
|
|
|
|
|
nsGenericHTMLElement* GetFirstLabelableDescendant() const;
|
2011-05-25 00:18:23 +00:00
|
|
|
|
|
|
|
// XXX It would be nice if we could use an event flag instead.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mHandlingEvent;
|
2011-05-25 00:18:23 +00:00
|
|
|
};
|
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* HTMLLabelElement_h */
|