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"
|
2013-07-31 07:32:35 +04:00
|
|
|
#include "nsIDOMHTMLLabelElement.h"
|
2011-05-25 04:18:23 +04:00
|
|
|
|
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 {
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class HTMLLabelElement final : public nsGenericHTMLFormElement,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIDOMHTMLLabelElement
|
2011-05-25 04:18:23 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit HTMLLabelElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2012-12-21 18:06:50 +04:00
|
|
|
: nsGenericHTMLFormElement(aNodeInfo),
|
|
|
|
mHandlingEvent(false)
|
|
|
|
{
|
|
|
|
}
|
2011-05-25 04:18:23 +04:00
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLLabelElement, label)
|
2011-05-25 04:18:23 +04:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2015-01-20 23:39:28 +03:00
|
|
|
// Element
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override
|
2015-01-20 23:39:28 +03:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-31 07:32:35 +04:00
|
|
|
// nsIDOMHTMLLabelElement
|
|
|
|
NS_DECL_NSIDOMHTMLLABELELEMENT
|
|
|
|
|
2012-12-21 18:07:28 +04: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-08 00:23:08 +04:00
|
|
|
using nsGenericHTMLElement::Focus;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Focus(mozilla::ErrorResult& aError) override;
|
2011-05-25 04:18:23 +04:00
|
|
|
|
|
|
|
// nsIFormControl
|
2015-03-21 19:28:04 +03: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 04:18:23 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsDisabled() const override { return false; }
|
2011-05-25 04:18:23 +04:00
|
|
|
|
|
|
|
// nsIContent
|
2014-03-18 08:48:20 +04:00
|
|
|
virtual nsresult PostHandleEvent(
|
2015-03-21 19:28:04 +03:00
|
|
|
EventChainPostVisitor& aVisitor) override;
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual void PerformAccesskey(bool aKeyCausesActivation,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aIsTrustedEvent) override;
|
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
|
2011-05-25 04:18:23 +04:00
|
|
|
|
2012-12-21 18:07:28 +04:00
|
|
|
nsGenericHTMLElement* GetLabeledElement() const;
|
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 */
|