Bug 839105 - Convert HTMLFieldSetElement to WebIDL. r=Ms2ger

This commit is contained in:
Andrea Marchesini 2013-02-08 11:34:48 -05:00
parent 6c9e07070e
commit 2961b400e1
5 changed files with 96 additions and 2 deletions

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/HTMLFieldSetElement.h"
#include "mozilla/dom/HTMLFieldSetElementBinding.h"
#include "nsEventDispatcher.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(FieldSet)
@ -18,6 +19,8 @@ HTMLFieldSetElement::HTMLFieldSetElement(already_AddRefed<nsINodeInfo> aNodeInfo
, mElements(nullptr)
, mFirstLegend(nullptr)
{
SetIsDOMBinding();
// <fieldset> is always barred from constraint validation.
SetBarredFromConstraintValidation(true);
@ -135,14 +138,20 @@ HTMLFieldSetElement::MatchListedElements(nsIContent* aContent, int32_t aNamespac
NS_IMETHODIMP
HTMLFieldSetElement::GetElements(nsIDOMHTMLCollection** aElements)
{
NS_ADDREF(*aElements = Elements());
return NS_OK;
}
nsIHTMLCollection*
HTMLFieldSetElement::Elements()
{
if (!mElements) {
mElements = new nsContentList(this, MatchListedElements, nullptr, nullptr,
true);
}
NS_ADDREF(*aElements = mElements);
return NS_OK;
return mElements;
}
// nsIFormControl
@ -236,5 +245,12 @@ HTMLFieldSetElement::NotifyElementsForFirstLegendChange(bool aNotify)
}
}
JSObject*
HTMLFieldSetElement::WrapNode(JSContext* aCx, JSObject* aScope,
bool* aTriedToWrap)
{
return HTMLFieldSetElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
} // namespace dom
} // namespace mozilla

View File

@ -9,6 +9,8 @@
#include "nsGenericHTMLElement.h"
#include "nsIDOMHTMLFieldSetElement.h"
#include "nsIConstraintValidation.h"
#include "nsHTMLFormElement.h"
#include "mozilla/dom/ValidityState.h"
namespace mozilla {
namespace dom {
@ -18,6 +20,9 @@ class HTMLFieldSetElement : public nsGenericHTMLFormElement,
public nsIConstraintValidation
{
public:
using nsGenericHTMLFormElement::GetForm;
using nsIConstraintValidation::Validity;
using nsIConstraintValidation::CheckValidity;
using nsIConstraintValidation::GetValidationMessage;
HTMLFieldSetElement(already_AddRefed<nsINodeInfo> aNodeInfo);
@ -70,6 +75,42 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLFieldSetElement,
nsGenericHTMLFormElement)
// 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
protected:
virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope,
bool* aTriedToWrap) MOZ_OVERRIDE;
private:
/**

View File

@ -413,6 +413,10 @@ DOMInterfaces = {
]
},
'HTMLFieldSetElement': {
'hasInstanceInterface': 'nsIDOMHTMLFieldSetElement',
},
'HTMLFrameSetElement': {
'hasInstanceInterface': 'nsIDOMHTMLFrameSetElement',
},

View File

@ -0,0 +1,32 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.whatwg.org/specs/web-apps/current-work/#the-fieldset-element
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
interface HTMLFieldSetElement : HTMLElement {
[SetterThrows]
attribute boolean disabled;
readonly attribute HTMLFormElement? form;
[SetterThrows]
attribute DOMString name;
readonly attribute DOMString type;
readonly attribute HTMLCollection elements;
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(DOMString error);
};

View File

@ -68,6 +68,7 @@ webidl_files = \
HTMLDListElement.webidl \
HTMLDocument.webidl \
HTMLElement.webidl \
HTMLFieldSetElement.webidl \
HTMLFontElement.webidl \
HTMLFrameSetElement.webidl \
HTMLHeadElement.webidl \