Bug 839179 - Part b: Move HTMLButtonElement to Paris bindings; r=bz
authorMs2ger <ms2ger@gmail.com>
Fri, 08 Feb 2013 13:50:30 +0100
changeset 121291 cd295f459224cca4b8b85c1e9930c597e17ab74b
parent 121290 1416061b8e7b96ef5046ac9f97a0efcc5d65edac
child 121292 7357eb529db251ca3dd09b8b70e849396a6f3170
push id22678
push userMs2ger@gmail.com
push dateFri, 08 Feb 2013 12:55:43 +0000
treeherdermozilla-inbound@7357eb529db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs839179
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 839179 - Part b: Move HTMLButtonElement to Paris bindings; r=bz
content/html/content/public/nsIConstraintValidation.h
content/html/content/src/HTMLButtonElement.cpp
content/html/content/src/HTMLButtonElement.h
dom/bindings/Bindings.conf
dom/webidl/HTMLButtonElement.webidl
dom/webidl/WebIDL.mk
--- a/content/html/content/public/nsIConstraintValidation.h
+++ b/content/html/content/public/nsIConstraintValidation.h
@@ -1,9 +1,9 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- 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/. */
 
 #ifndef nsIConstraintValidition_h___
 #define nsIConstraintValidition_h___
 
 #include "nsISupports.h"
--- a/content/html/content/src/HTMLButtonElement.cpp
+++ b/content/html/content/src/HTMLButtonElement.cpp
@@ -1,15 +1,16 @@
 /* -*- 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/HTMLButtonElement.h"
 
+#include "mozilla/dom/HTMLButtonElementBinding.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIDOMEventTarget.h"
 #include "nsAttrValueInlines.h"
 #include "nsGkAtoms.h"
 #include "nsIPresShell.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsIFormControl.h"
@@ -61,16 +62,18 @@ HTMLButtonElement::HTMLButtonElement(alr
     mInInternalActivate(false),
     mInhibitStateRestoration(!!(aFromParser & FROM_PARSER_FRAGMENT))
 {
   // <button> is always barred from constraint validation.
   SetBarredFromConstraintValidation(true);
 
   // Set up our default state: enabled
   AddStatesSilently(NS_EVENT_STATE_ENABLED);
+
+  SetIsDOMBinding();
 }
 
 HTMLButtonElement::~HTMLButtonElement()
 {
 }
 
 // nsISupports
 
@@ -540,10 +543,17 @@ HTMLButtonElement::IntrinsicState() cons
 
   if (mForm && !mForm->GetValidity() && IsSubmitControl()) {
     state |= NS_EVENT_STATE_MOZ_SUBMITINVALID;
   }
 
   return state;
 }
 
+JSObject*
+HTMLButtonElement::WrapNode(JSContext* aCx, JSObject* aScope,
+                            bool* aTriedToWrap)
+{
+  return HTMLButtonElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/content/html/content/src/HTMLButtonElement.h
+++ b/content/html/content/src/HTMLButtonElement.h
@@ -55,16 +55,18 @@ public:
   // nsIDOMEventTarget
   virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
 
   // nsINode
   virtual nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const;
   virtual nsXPCClassInfo* GetClassInfo();
   virtual nsIDOMNode* AsDOMNode() { return this; }
+  virtual JSObject*
+  WrapNode(JSContext* aCx, JSObject* aScope, bool* aTriedToWrap) MOZ_OVERRIDE;
 
   // nsIContent
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers);
   virtual void UnbindFromTree(bool aDeep = true,
                               bool aNullParent = true);
   virtual void DoneCreatingElement();
@@ -87,16 +89,86 @@ public:
                               const nsAString& aValue,
                               nsAttrValue& aResult);
 
   // nsGenericHTMLElement
   virtual bool IsHTMLFocusable(bool aWithMouse,
                                bool* aIsFocusable,
                                int32_t* aTabIndex);
 
+  // WebIDL
+  bool Autofocus() const
+  {
+    return GetBoolAttr(nsGkAtoms::autofocus);
+  }
+  void SetAutofocus(bool aAutofocus, ErrorResult& aError)
+  {
+    SetHTMLBoolAttr(nsGkAtoms::autofocus, aAutofocus, aError);
+  }
+  bool Disabled() const
+  {
+    return GetBoolAttr(nsGkAtoms::disabled);
+  }
+  void SetDisabled(bool aDisabled, ErrorResult& aError)
+  {
+    SetHTMLBoolAttr(nsGkAtoms::disabled, aDisabled, aError);
+  }
+  // nsGenericHTMLFormElement::GetForm is fine.
+  using nsGenericHTMLFormElement::GetForm;
+  // XPCOM GetFormAction is fine.
+  void SetFormAction(const nsAString& aFormAction, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::formaction, aFormAction, aRv);
+  }
+  // XPCOM GetFormEnctype is fine.
+  void SetFormEnctype(const nsAString& aFormEnctype, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::formenctype, aFormEnctype, aRv);
+  }
+  // XPCOM GetFormMethod is fine.
+  void SetFormMethod(const nsAString& aFormMethod, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::formmethod, aFormMethod, aRv);
+  }
+  bool FormNoValidate() const
+  {
+    return GetBoolAttr(nsGkAtoms::formnovalidate);
+  }
+  void SetFormNoValidate(bool aFormNoValidate, ErrorResult& aError)
+  {
+    SetHTMLBoolAttr(nsGkAtoms::formnovalidate, aFormNoValidate, aError);
+  }
+  // XPCOM GetFormTarget is fine.
+  void SetFormTarget(const nsAString& aFormTarget, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::formtarget, aFormTarget, aRv);
+  }
+  // XPCOM GetName is fine.
+  void SetName(const nsAString& aName, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::name, aName, aRv);
+  }
+  // XPCOM GetType is fine.
+  void SetType(const nsAString& aType, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::type, aType, aRv);
+  }
+  // XPCOM GetValue is fine.
+  void SetValue(const nsAString& aValue, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::value, aValue, aRv);
+  }
+
+  // nsIConstraintValidation::WillValidate is fine.
+  // nsIConstraintValidation::Validity() is fine.
+  // nsIConstraintValidation::GetValidationMessage() is fine.
+  // nsIConstraintValidation::CheckValidity() is fine.
+  using nsIConstraintValidation::CheckValidity;
+  // nsIConstraintValidation::SetCustomValidity() is fine.
+
 protected:
   uint8_t mType;
   bool mDisabledChanged;
   bool mInInternalActivate;
   bool mInhibitStateRestoration;
 };
 
 } // namespace dom
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -356,16 +356,20 @@ DOMInterfaces = {
 'HTMLBodyElement': {
     'hasInstanceInterface': 'nsIDOMHTMLBodyElement',
 },
 
 'HTMLBRElement': {
     'hasInstanceInterface': 'nsIDOMHTMLBRElement',
 },
 
+'HTMLButtonElement': {
+    'hasInstanceInterface': 'nsIDOMHTMLButtonElement',
+},
+
 'HTMLCollection': {
     'nativeType': 'nsIHTMLCollection',
     'resultNotAddRefed': [ 'item' ]
 },
 
 'HTMLDataListElement': {
     'resultNotAddRefed': [
         'options'
new file mode 100644
--- /dev/null
+++ b/dom/webidl/HTMLButtonElement.webidl
@@ -0,0 +1,37 @@
+/* -*- 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-button-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.
+ */
+
+// http://www.whatwg.org/specs/web-apps/current-work/#the-button-element
+interface HTMLButtonElement : HTMLElement {
+           attribute boolean autofocus;
+           attribute boolean disabled;
+  readonly attribute HTMLFormElement? form;
+           attribute DOMString formAction;
+           attribute DOMString formEnctype;
+           attribute DOMString formMethod;
+           attribute boolean formNoValidate;
+           attribute DOMString formTarget;
+           attribute DOMString name;
+           attribute DOMString type;
+           attribute DOMString value;
+// Not yet implemented:
+//           attribute HTMLMenuElement? menu;
+
+  readonly attribute boolean willValidate;
+  readonly attribute ValidityState validity;
+  readonly attribute DOMString validationMessage;
+  boolean checkValidity();
+  void setCustomValidity(DOMString error);
+
+// Not yet implemented:
+//  readonly attribute NodeList labels;
+};
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -55,16 +55,17 @@ webidl_files = \
   FileReaderSync.webidl \
   FormData.webidl \
   Function.webidl \
   GainNode.webidl \
   HTMLAnchorElement.webidl \
   HTMLBaseElement.webidl \
   HTMLBodyElement.webidl \
   HTMLBRElement.webidl \
+  HTMLButtonElement.webidl \
   HTMLCollection.webidl \
   HTMLDataListElement.webidl \
   HTMLDirectoryElement.webidl \
   HTMLDivElement.webidl \
   HTMLDListElement.webidl \
   HTMLDocument.webidl \
   HTMLElement.webidl \
   HTMLFontElement.webidl \