2010-09-18 18:47:15 -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/. */
|
2010-09-18 18:47:15 -07:00
|
|
|
|
2013-02-08 08:34:47 -08:00
|
|
|
#ifndef mozilla_dom_HTMLFieldSetElement_h
|
|
|
|
#define mozilla_dom_HTMLFieldSetElement_h
|
2010-09-18 18:47:15 -07:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2010-09-18 18:47:15 -07:00
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsIDOMHTMLFieldSetElement.h"
|
|
|
|
#include "nsIConstraintValidation.h"
|
2013-06-19 07:24:37 -07:00
|
|
|
#include "mozilla/dom/HTMLFormElement.h"
|
2013-02-08 08:34:48 -08:00
|
|
|
#include "mozilla/dom/ValidityState.h"
|
2010-09-18 18:47:15 -07:00
|
|
|
|
2013-02-08 08:34:47 -08:00
|
|
|
namespace mozilla {
|
2014-03-17 21:48:19 -07:00
|
|
|
class EventChainPreVisitor;
|
2013-02-08 08:34:47 -08:00
|
|
|
namespace dom {
|
2010-09-18 18:47:15 -07:00
|
|
|
|
2013-07-11 14:26:54 -07:00
|
|
|
class HTMLFieldSetElement MOZ_FINAL : public nsGenericHTMLFormElement,
|
|
|
|
public nsIDOMHTMLFieldSetElement,
|
|
|
|
public nsIConstraintValidation
|
2010-09-18 18:47:15 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-02-08 08:34:48 -08:00
|
|
|
using nsGenericHTMLFormElement::GetForm;
|
|
|
|
using nsIConstraintValidation::Validity;
|
|
|
|
using nsIConstraintValidation::CheckValidity;
|
2010-09-18 18:47:15 -07:00
|
|
|
using nsIConstraintValidation::GetValidationMessage;
|
|
|
|
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit HTMLFieldSetElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2010-09-18 18:47:15 -07:00
|
|
|
|
2013-02-08 08:34:47 -08:00
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLFieldSetElement, fieldset)
|
2011-09-18 02:22:18 -07:00
|
|
|
|
2010-09-18 18:47:15 -07:00
|
|
|
// nsISupports
|
2010-11-23 16:09:48 -08:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2010-09-18 18:47:15 -07:00
|
|
|
|
|
|
|
// nsIDOMHTMLFieldSetElement
|
|
|
|
NS_DECL_NSIDOMHTMLFIELDSETELEMENT
|
|
|
|
|
|
|
|
// nsIContent
|
2014-03-17 21:48:19 -07:00
|
|
|
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
2013-05-29 13:43:41 -07:00
|
|
|
const nsAttrValue* aValue, bool aNotify) MOZ_OVERRIDE;
|
2010-09-18 18:47:15 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult InsertChildAt(nsIContent* aChild, uint32_t aIndex,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aNotify) MOZ_OVERRIDE;
|
|
|
|
virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) MOZ_OVERRIDE;
|
2010-09-18 18:47:15 -07:00
|
|
|
|
|
|
|
// nsIFormControl
|
2013-05-29 13:43:41 -07:00
|
|
|
NS_IMETHOD_(uint32_t) GetType() const MOZ_OVERRIDE { return NS_FORM_FIELDSET; }
|
|
|
|
NS_IMETHOD Reset() MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) MOZ_OVERRIDE;
|
|
|
|
virtual bool IsDisabledForEvents(uint32_t aMessage) MOZ_OVERRIDE;
|
2014-06-19 19:01:40 -07:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
|
2010-09-18 18:47:15 -07:00
|
|
|
|
|
|
|
const nsIContent* GetFirstLegend() const { return mFirstLegend; }
|
|
|
|
|
2013-08-16 17:32:47 -07:00
|
|
|
void AddElement(nsGenericHTMLFormElement* aElement);
|
2010-11-05 10:15:05 -07:00
|
|
|
|
2013-08-16 17:32:47 -07:00
|
|
|
void RemoveElement(nsGenericHTMLFormElement* aElement);
|
2010-11-05 10:15:05 -07:00
|
|
|
|
2013-02-08 08:34:47 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLFieldSetElement,
|
2010-09-18 18:47:15 -07:00
|
|
|
nsGenericHTMLFormElement)
|
2013-02-08 08:34:48 -08:00
|
|
|
|
|
|
|
// WebIDL
|
|
|
|
bool Disabled() const
|
|
|
|
{
|
|
|
|
return GetBoolAttr(nsGkAtoms::disabled);
|
|
|
|
}
|
|
|
|
void SetDisabled(bool aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::disabled, aValue, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
// XPCOM GetName is OK for us
|
|
|
|
|
|
|
|
void SetName(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::name, aValue, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
// XPCOM GetType is OK for us
|
|
|
|
|
|
|
|
nsIHTMLCollection* Elements();
|
|
|
|
|
|
|
|
// XPCOM WillValidate is OK for us
|
|
|
|
|
|
|
|
// XPCOM Validity is OK for us
|
|
|
|
|
|
|
|
// XPCOM GetValidationMessage is OK for us
|
|
|
|
|
|
|
|
// XPCOM CheckValidity is OK for us
|
|
|
|
|
|
|
|
// XPCOM SetCustomValidity is OK for us
|
|
|
|
|
2015-01-06 12:13:36 -08:00
|
|
|
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
2013-08-16 17:32:47 -07:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This method will update the fieldset's validity. This method has to be
|
|
|
|
* called by fieldset elements whenever their validity state or status regarding
|
|
|
|
* constraint validation changes.
|
|
|
|
*
|
|
|
|
* @note If an element becomes barred from constraint validation, it has to
|
|
|
|
* be considered as valid.
|
|
|
|
*
|
|
|
|
* @param aElementValidityState the new validity state of the element
|
|
|
|
*/
|
|
|
|
void UpdateValidity(bool aElementValidityState);
|
|
|
|
|
2013-02-08 08:34:48 -08:00
|
|
|
protected:
|
2014-07-08 14:23:16 -07:00
|
|
|
virtual ~HTMLFieldSetElement();
|
|
|
|
|
2014-04-08 15:27:17 -07:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx) MOZ_OVERRIDE;
|
2013-02-08 08:34:48 -08:00
|
|
|
|
2010-09-18 18:47:15 -07:00
|
|
|
private:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify all elements (in mElements) that the first legend of the fieldset
|
|
|
|
* has now changed.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
void NotifyElementsForFirstLegendChange(bool aNotify);
|
2010-09-18 18:47:15 -07:00
|
|
|
|
|
|
|
// This function is used to generate the nsContentList (listed form elements).
|
2012-08-22 08:56:38 -07:00
|
|
|
static bool MatchListedElements(nsIContent* aContent, int32_t aNamespaceID,
|
2010-09-18 18:47:15 -07:00
|
|
|
nsIAtom* aAtom, void* aData);
|
|
|
|
|
|
|
|
// listed form controls elements.
|
|
|
|
nsRefPtr<nsContentList> mElements;
|
|
|
|
|
2010-11-05 10:15:05 -07:00
|
|
|
// List of elements which have this fieldset as first fieldset ancestor.
|
2011-08-09 22:36:00 -07:00
|
|
|
nsTArray<nsGenericHTMLFormElement*> mDependentElements;
|
2010-11-05 10:15:05 -07:00
|
|
|
|
2010-09-18 18:47:15 -07:00
|
|
|
nsIContent* mFirstLegend;
|
2013-08-16 17:32:47 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of invalid and candidate for constraint validation
|
|
|
|
* elements in the fieldSet the last time UpdateValidity has been called.
|
|
|
|
*
|
|
|
|
* @note Should only be used by UpdateValidity() and IntrinsicState()!
|
|
|
|
*/
|
|
|
|
int32_t mInvalidElementsCount;
|
2010-09-18 18:47:15 -07:00
|
|
|
};
|
|
|
|
|
2013-02-08 08:34:47 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* mozilla_dom_HTMLFieldSetElement_h */
|