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/. */
|
2010-09-19 05:47:15 +04:00
|
|
|
|
2013-02-08 20:34:47 +04:00
|
|
|
#ifndef mozilla_dom_HTMLFieldSetElement_h
|
|
|
|
#define mozilla_dom_HTMLFieldSetElement_h
|
2010-09-19 05:47:15 +04:00
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2010-09-19 05:47:15 +04:00
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsIConstraintValidation.h"
|
2013-06-19 18:24:37 +04:00
|
|
|
#include "mozilla/dom/HTMLFormElement.h"
|
2013-02-08 20:34:48 +04:00
|
|
|
#include "mozilla/dom/ValidityState.h"
|
2010-09-19 05:47:15 +04:00
|
|
|
|
2013-02-08 20:34:47 +04:00
|
|
|
namespace mozilla {
|
2014-03-18 08:48:19 +04:00
|
|
|
class EventChainPreVisitor;
|
2013-02-08 20:34:47 +04:00
|
|
|
namespace dom {
|
2010-09-19 05:47:15 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class HTMLFieldSetElement final : public nsGenericHTMLFormElement,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIConstraintValidation
|
2010-09-19 05:47:15 +04:00
|
|
|
{
|
|
|
|
public:
|
2013-02-08 20:34:48 +04:00
|
|
|
using nsGenericHTMLFormElement::GetForm;
|
2010-09-19 05:47:15 +04:00
|
|
|
using nsIConstraintValidation::GetValidationMessage;
|
2017-07-14 06:46:28 +03:00
|
|
|
using nsIConstraintValidation::SetCustomValidity;
|
2010-09-19 05:47:15 +04:00
|
|
|
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit HTMLFieldSetElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2010-09-19 05:47:15 +04:00
|
|
|
|
2013-02-08 20:34:47 +04:00
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLFieldSetElement, fieldset)
|
2011-09-18 13:22:18 +04:00
|
|
|
|
2010-09-19 05:47:15 +04:00
|
|
|
// nsISupports
|
2010-11-24 03:09:48 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2010-09-19 05:47:15 +04:00
|
|
|
|
|
|
|
// nsIContent
|
2016-10-21 05:11:07 +03:00
|
|
|
virtual nsresult GetEventTargetParent(
|
|
|
|
EventChainPreVisitor& aVisitor) override;
|
2017-10-03 01:05:19 +03:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
2017-05-19 00:09:01 +03:00
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue,
|
2017-10-10 00:33:38 +03:00
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
2017-05-19 00:09:01 +03:00
|
|
|
bool aNotify) override;
|
2010-09-19 05:47:15 +04:00
|
|
|
|
2018-01-25 17:59:42 +03:00
|
|
|
virtual nsresult InsertChildBefore(nsIContent* aChild, nsIContent* aBeforeThis,
|
|
|
|
bool aNotify) override;
|
2018-01-23 16:30:18 +03:00
|
|
|
virtual nsresult InsertChildAt_Deprecated(nsIContent* aChild, uint32_t aIndex,
|
|
|
|
bool aNotify) override;
|
2018-01-03 16:01:03 +03:00
|
|
|
virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
|
2018-01-15 19:18:38 +03:00
|
|
|
virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
|
2010-09-19 05:47:15 +04:00
|
|
|
|
|
|
|
// nsIFormControl
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Reset() override;
|
2016-06-16 10:24:16 +03:00
|
|
|
NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override;
|
2015-08-26 15:56:59 +03:00
|
|
|
virtual bool IsDisabledForEvents(EventMessage aMessage) override;
|
2017-04-20 22:57:48 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
|
|
|
bool aPreallocateChildren) const override;
|
2010-09-19 05:47:15 +04:00
|
|
|
|
|
|
|
const nsIContent* GetFirstLegend() const { return mFirstLegend; }
|
|
|
|
|
2013-08-17 04:32:47 +04:00
|
|
|
void AddElement(nsGenericHTMLFormElement* aElement);
|
2010-11-05 20:15:05 +03:00
|
|
|
|
2013-08-17 04:32:47 +04:00
|
|
|
void RemoveElement(nsGenericHTMLFormElement* aElement);
|
2010-11-05 20:15:05 +03:00
|
|
|
|
2013-02-08 20:34:47 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLFieldSetElement,
|
2010-09-19 05:47:15 +04:00
|
|
|
nsGenericHTMLFormElement)
|
2013-02-08 20:34:48 +04:00
|
|
|
|
|
|
|
// WebIDL
|
|
|
|
bool Disabled() const
|
|
|
|
{
|
|
|
|
return GetBoolAttr(nsGkAtoms::disabled);
|
|
|
|
}
|
|
|
|
void SetDisabled(bool aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::disabled, aValue, aRv);
|
|
|
|
}
|
|
|
|
|
2017-08-14 19:31:47 +03:00
|
|
|
void GetName(nsAString& aValue)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::name, aValue);
|
|
|
|
}
|
2013-02-08 20:34:48 +04:00
|
|
|
|
|
|
|
void SetName(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::name, aValue, aRv);
|
|
|
|
}
|
|
|
|
|
2017-08-14 19:31:47 +03:00
|
|
|
NS_IMETHOD GetType(nsAString & aType);
|
2013-02-08 20:34:48 +04:00
|
|
|
|
|
|
|
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-03-21 19:28:04 +03:00
|
|
|
virtual EventStates IntrinsicState() const override;
|
2013-08-17 04:32:47 +04: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 20:34:48 +04:00
|
|
|
protected:
|
2014-07-09 01:23:16 +04:00
|
|
|
virtual ~HTMLFieldSetElement();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-02-08 20:34:48 +04:00
|
|
|
|
2010-09-19 05:47:15 +04:00
|
|
|
private:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify all elements (in mElements) that the first legend of the fieldset
|
|
|
|
* has now changed.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
void NotifyElementsForFirstLegendChange(bool aNotify);
|
2010-09-19 05:47:15 +04:00
|
|
|
|
|
|
|
// This function is used to generate the nsContentList (listed form elements).
|
2017-02-14 00:06:45 +03:00
|
|
|
static bool MatchListedElements(Element* aElement, int32_t aNamespaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAtom, void* aData);
|
2010-09-19 05:47:15 +04:00
|
|
|
|
|
|
|
// listed form controls elements.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsContentList> mElements;
|
2010-09-19 05:47:15 +04:00
|
|
|
|
2010-11-05 20:15:05 +03:00
|
|
|
// List of elements which have this fieldset as first fieldset ancestor.
|
2015-05-15 17:01:29 +03:00
|
|
|
nsTArray<nsGenericHTMLFormElement*> mDependentElements;
|
2010-11-05 20:15:05 +03:00
|
|
|
|
2015-05-15 17:01:29 +03:00
|
|
|
nsIContent* mFirstLegend;
|
2013-08-17 04:32:47 +04: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-19 05:47:15 +04:00
|
|
|
};
|
|
|
|
|
2013-02-08 20:34:47 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* mozilla_dom_HTMLFieldSetElement_h */
|