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