Bug 839105 - Convert HTMLFieldSetElement to WebIDL. r=Ms2ger
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 08 Feb 2013 11:34:48 -0500
changeset 121339 f2ece1151f003665ade62a255f05c50223ef0f28
parent 121338 afeaf8f42c099a9a747d0133bbf27b997c2072b9
child 121340 3b7d82d4dbd235a851a72a6d1b29fbe28763f6ea
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-esr52@cc37417e2c28 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
bugs839105
milestone21.0a1
Bug 839105 - Convert HTMLFieldSetElement to WebIDL. r=Ms2ger
content/html/content/src/HTMLFieldSetElement.cpp
content/html/content/src/HTMLFieldSetElement.h
dom/bindings/Bindings.conf
dom/webidl/HTMLFieldSetElement.webidl
dom/webidl/WebIDL.mk
--- a/content/html/content/src/HTMLFieldSetElement.cpp
+++ b/content/html/content/src/HTMLFieldSetElement.cpp
@@ -1,28 +1,31 @@
 /* -*- Mode: C++; 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/. */
 
 #include "mozilla/dom/HTMLFieldSetElement.h"
+#include "mozilla/dom/HTMLFieldSetElementBinding.h"
 #include "nsEventDispatcher.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(FieldSet)
 DOMCI_NODE_DATA(HTMLFieldSetElement, mozilla::dom::HTMLFieldSetElement)
 
 
 namespace mozilla {
 namespace dom {
 
 HTMLFieldSetElement::HTMLFieldSetElement(already_AddRefed<nsINodeInfo> aNodeInfo)
   : nsGenericHTMLFormElement(aNodeInfo)
   , mElements(nullptr)
   , mFirstLegend(nullptr)
 {
+  SetIsDOMBinding();
+
   // <fieldset> is always barred from constraint validation.
   SetBarredFromConstraintValidation(true);
 
   // We start out enabled
   AddStatesSilently(NS_EVENT_STATE_ENABLED);
 }
 
 HTMLFieldSetElement::~HTMLFieldSetElement()
@@ -131,23 +134,29 @@ HTMLFieldSetElement::MatchListedElements
 {
   nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(aContent);
   return formControl && formControl->GetType() != NS_FORM_LABEL;
 }
 
 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
 
 nsresult
 HTMLFieldSetElement::Reset()
 {
   return NS_OK;
@@ -231,10 +240,17 @@ HTMLFieldSetElement::NotifyElementsForFi
 
   uint32_t length = mElements->Length(true);
   for (uint32_t i = 0; i < length; ++i) {
     static_cast<nsGenericHTMLFormElement*>(mElements->Item(i))
       ->FieldSetFirstLegendChanged(aNotify);
   }
 }
 
+JSObject*
+HTMLFieldSetElement::WrapNode(JSContext* aCx, JSObject* aScope,
+                              bool* aTriedToWrap)
+{
+  return HTMLFieldSetElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/content/html/content/src/HTMLFieldSetElement.h
+++ b/content/html/content/src/HTMLFieldSetElement.h
@@ -4,25 +4,30 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_HTMLFieldSetElement_h
 #define mozilla_dom_HTMLFieldSetElement_h
 
 #include "nsGenericHTMLElement.h"
 #include "nsIDOMHTMLFieldSetElement.h"
 #include "nsIConstraintValidation.h"
+#include "nsHTMLFormElement.h"
+#include "mozilla/dom/ValidityState.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLFieldSetElement : public nsGenericHTMLFormElement,
                             public nsIDOMHTMLFieldSetElement,
                             public nsIConstraintValidation
 {
 public:
+  using nsGenericHTMLFormElement::GetForm;
+  using nsIConstraintValidation::Validity;
+  using nsIConstraintValidation::CheckValidity;
   using nsIConstraintValidation::GetValidationMessage;
 
   HTMLFieldSetElement(already_AddRefed<nsINodeInfo> aNodeInfo);
   virtual ~HTMLFieldSetElement();
 
   NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLFieldSetElement, fieldset)
 
   // nsISupports
@@ -65,16 +70,52 @@ public:
   }
 
   void RemoveElement(nsGenericHTMLFormElement* aElement) {
     mDependentElements.RemoveElement(aElement);
   }
 
   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:
 
   /**
    * Notify all elements (in mElements) that the first legend of the fieldset
    * has now changed.
    */
   void NotifyElementsForFirstLegendChange(bool aNotify);
 
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -408,16 +408,20 @@ DOMInterfaces = {
     'hasXPConnectImpls': True,
     'hasInstanceInterface': 'nsIDOMHTMLElement',
     'resultNotAddRefed': [
         'itemType', 'itemRef', 'itemProp', 'properties', 'contextMenu', 'style',
         'offsetParent'
     ]
 },
 
+'HTMLFieldSetElement': {
+    'hasInstanceInterface': 'nsIDOMHTMLFieldSetElement',
+},
+
 'HTMLFrameSetElement': {
     'hasInstanceInterface': 'nsIDOMHTMLFrameSetElement',
 },
 
 'HTMLHeadElement': {
     'nativeType': 'mozilla::dom::HTMLSharedElement'
 },
 
new file mode 100644
--- /dev/null
+++ b/dom/webidl/HTMLFieldSetElement.webidl
@@ -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);
+};
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -63,16 +63,17 @@ webidl_files = \
   HTMLButtonElement.webidl \
   HTMLCollection.webidl \
   HTMLDataListElement.webidl \
   HTMLDirectoryElement.webidl \
   HTMLDivElement.webidl \
   HTMLDListElement.webidl \
   HTMLDocument.webidl \
   HTMLElement.webidl \
+  HTMLFieldSetElement.webidl \
   HTMLFontElement.webidl \
   HTMLFrameSetElement.webidl \
   HTMLHeadElement.webidl \
   HTMLHeadingElement.webidl \
   HTMLHRElement.webidl \
   HTMLHtmlElement.webidl \
   HTMLImageElement.webidl \
   HTMLLabelElement.webidl \