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
|
|
|
|
2018-09-21 23:45:49 +03:00
|
|
|
explicit HTMLFieldSetElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2010-09-19 05:47:15 +04:00
|
|
|
|
2018-03-22 00:39:04 +03:00
|
|
|
NS_IMPL_FROMNODE_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
|
2018-04-05 20:42:41 +03:00
|
|
|
void 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-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;
|
2018-10-31 11:55:33 +03:00
|
|
|
virtual bool IsDisabledForEvents(WidgetEvent* aEvent) override;
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) 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);
|
|
|
|
}
|
|
|
|
|
2018-06-02 05:35:26 +03:00
|
|
|
void GetType(nsAString& aType) const;
|
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;
|
2010-09-19 05:47:15 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
private:
|
2010-09-19 05:47:15 +04:00
|
|
|
/**
|
|
|
|
* 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 */
|