gecko/dom/html/HTMLLabelElement.h

85 lines
2.4 KiB
C
Raw Normal View History

/* -*- 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/. */
/**
* Declaration of HTML <label> elements.
*/
Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings) - move some HTML element classes to mozilla::dom. r=bz. --HG-- rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp rename : content/html/content/src/nsHTMLDivElement.cpp => content/html/content/src/HTMLDivElement.cpp rename : content/html/content/src/nsHTMLDivElement.h => content/html/content/src/HTMLDivElement.h rename : content/html/content/src/nsHTMLElement.cpp => content/html/content/src/HTMLElement.cpp rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h rename : content/html/content/src/nsHTMLUnknownElement.cpp => content/html/content/src/HTMLUnknownElement.cpp rename : content/html/content/src/nsHTMLUnknownElement.h => content/html/content/src/HTMLUnknownElement.h extra : rebase_source : 99a2b1764bfd34db1375939b967f816dc2a42a91
2012-12-21 06:06:50 -08:00
#ifndef HTMLLabelElement_h
#define HTMLLabelElement_h
#include "mozilla/Attributes.h"
#include "nsGenericHTMLElement.h"
#include "nsIDOMHTMLLabelElement.h"
Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings) - move some HTML element classes to mozilla::dom. r=bz. --HG-- rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp rename : content/html/content/src/nsHTMLDivElement.cpp => content/html/content/src/HTMLDivElement.cpp rename : content/html/content/src/nsHTMLDivElement.h => content/html/content/src/HTMLDivElement.h rename : content/html/content/src/nsHTMLElement.cpp => content/html/content/src/HTMLElement.cpp rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h rename : content/html/content/src/nsHTMLUnknownElement.cpp => content/html/content/src/HTMLUnknownElement.cpp rename : content/html/content/src/nsHTMLUnknownElement.h => content/html/content/src/HTMLUnknownElement.h extra : rebase_source : 99a2b1764bfd34db1375939b967f816dc2a42a91
2012-12-21 06:06:50 -08:00
namespace mozilla {
class EventChainPostVisitor;
Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings) - move some HTML element classes to mozilla::dom. r=bz. --HG-- rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp rename : content/html/content/src/nsHTMLDivElement.cpp => content/html/content/src/HTMLDivElement.cpp rename : content/html/content/src/nsHTMLDivElement.h => content/html/content/src/HTMLDivElement.h rename : content/html/content/src/nsHTMLElement.cpp => content/html/content/src/HTMLElement.cpp rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h rename : content/html/content/src/nsHTMLUnknownElement.cpp => content/html/content/src/HTMLUnknownElement.cpp rename : content/html/content/src/nsHTMLUnknownElement.h => content/html/content/src/HTMLUnknownElement.h extra : rebase_source : 99a2b1764bfd34db1375939b967f816dc2a42a91
2012-12-21 06:06:50 -08:00
namespace dom {
class HTMLLabelElement MOZ_FINAL : public nsGenericHTMLFormElement,
public nsIDOMHTMLLabelElement
{
public:
explicit HTMLLabelElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings) - move some HTML element classes to mozilla::dom. r=bz. --HG-- rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp rename : content/html/content/src/nsHTMLDivElement.cpp => content/html/content/src/HTMLDivElement.cpp rename : content/html/content/src/nsHTMLDivElement.h => content/html/content/src/HTMLDivElement.h rename : content/html/content/src/nsHTMLElement.cpp => content/html/content/src/HTMLElement.cpp rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h rename : content/html/content/src/nsHTMLUnknownElement.cpp => content/html/content/src/HTMLUnknownElement.cpp rename : content/html/content/src/nsHTMLUnknownElement.h => content/html/content/src/HTMLUnknownElement.h extra : rebase_source : 99a2b1764bfd34db1375939b967f816dc2a42a91
2012-12-21 06:06:50 -08:00
: nsGenericHTMLFormElement(aNodeInfo),
mHandlingEvent(false)
{
}
Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings) - move some HTML element classes to mozilla::dom. r=bz. --HG-- rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp rename : content/html/content/src/nsHTMLDivElement.cpp => content/html/content/src/HTMLDivElement.cpp rename : content/html/content/src/nsHTMLDivElement.h => content/html/content/src/HTMLDivElement.h rename : content/html/content/src/nsHTMLElement.cpp => content/html/content/src/HTMLElement.cpp rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h rename : content/html/content/src/nsHTMLUnknownElement.cpp => content/html/content/src/HTMLUnknownElement.cpp rename : content/html/content/src/nsHTMLUnknownElement.h => content/html/content/src/HTMLUnknownElement.h extra : rebase_source : 99a2b1764bfd34db1375939b967f816dc2a42a91
2012-12-21 06:06:50 -08:00
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLLabelElement, label)
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMHTMLLabelElement
NS_DECL_NSIDOMHTMLLABELELEMENT
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();
}
using nsGenericHTMLElement::Focus;
virtual void Focus(mozilla::ErrorResult& aError) MOZ_OVERRIDE;
// nsIFormControl
NS_IMETHOD_(uint32_t) GetType() const MOZ_OVERRIDE { return NS_FORM_LABEL; }
NS_IMETHOD Reset() MOZ_OVERRIDE;
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) MOZ_OVERRIDE;
virtual bool IsDisabled() const MOZ_OVERRIDE { return false; }
// nsIContent
virtual nsresult PostHandleEvent(
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual void PerformAccesskey(bool aKeyCausesActivation,
bool aIsTrustedEvent) MOZ_OVERRIDE;
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
nsGenericHTMLElement* GetLabeledElement() const;
protected:
virtual ~HTMLLabelElement();
virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE;
nsGenericHTMLElement* GetFirstLabelableDescendant() const;
// XXX It would be nice if we could use an event flag instead.
bool mHandlingEvent;
};
Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings) - move some HTML element classes to mozilla::dom. r=bz. --HG-- rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp rename : content/html/content/src/nsHTMLDivElement.cpp => content/html/content/src/HTMLDivElement.cpp rename : content/html/content/src/nsHTMLDivElement.h => content/html/content/src/HTMLDivElement.h rename : content/html/content/src/nsHTMLElement.cpp => content/html/content/src/HTMLElement.cpp rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h rename : content/html/content/src/nsHTMLUnknownElement.cpp => content/html/content/src/HTMLUnknownElement.cpp rename : content/html/content/src/nsHTMLUnknownElement.h => content/html/content/src/HTMLUnknownElement.h extra : rebase_source : 99a2b1764bfd34db1375939b967f816dc2a42a91
2012-12-21 06:06:50 -08:00
} // namespace dom
} // namespace mozilla
#endif /* HTMLLabelElement_h */