From d0fe7fc7ff736f3d9bb2a33fa4dd56de1502e188 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 8 Feb 2013 13:50:30 +0100 Subject: [PATCH] Bug 839179 - Part b: Move HTMLButtonElement to Paris bindings; r=bz --- .../content/public/nsIConstraintValidation.h | 2 +- .../html/content/src/HTMLButtonElement.cpp | 10 +++ content/html/content/src/HTMLButtonElement.h | 72 +++++++++++++++++++ dom/bindings/Bindings.conf | 4 ++ dom/webidl/HTMLButtonElement.webidl | 37 ++++++++++ dom/webidl/WebIDL.mk | 1 + 6 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 dom/webidl/HTMLButtonElement.webidl diff --git a/content/html/content/public/nsIConstraintValidation.h b/content/html/content/public/nsIConstraintValidation.h index 5c23984a5ad5..580f798155a1 100644 --- a/content/html/content/public/nsIConstraintValidation.h +++ b/content/html/content/public/nsIConstraintValidation.h @@ -1,4 +1,4 @@ -/* -*- 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/. */ diff --git a/content/html/content/src/HTMLButtonElement.cpp b/content/html/content/src/HTMLButtonElement.cpp index 9cb2085989d1..05f3f4edc51b 100644 --- a/content/html/content/src/HTMLButtonElement.cpp +++ b/content/html/content/src/HTMLButtonElement.cpp @@ -5,6 +5,7 @@ #include "mozilla/dom/HTMLButtonElement.h" +#include "mozilla/dom/HTMLButtonElementBinding.h" #include "nsIDOMHTMLFormElement.h" #include "nsIDOMEventTarget.h" #include "nsAttrValueInlines.h" @@ -66,6 +67,8 @@ HTMLButtonElement::HTMLButtonElement(already_AddRefed aNodeInfo, // Set up our default state: enabled AddStatesSilently(NS_EVENT_STATE_ENABLED); + + SetIsDOMBinding(); } HTMLButtonElement::~HTMLButtonElement() @@ -545,5 +548,12 @@ HTMLButtonElement::IntrinsicState() const return state; } +JSObject* +HTMLButtonElement::WrapNode(JSContext* aCx, JSObject* aScope, + bool* aTriedToWrap) +{ + return HTMLButtonElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + } // namespace dom } // namespace mozilla diff --git a/content/html/content/src/HTMLButtonElement.h b/content/html/content/src/HTMLButtonElement.h index 85f37c5b19cd..e905959e4970 100644 --- a/content/html/content/src/HTMLButtonElement.h +++ b/content/html/content/src/HTMLButtonElement.h @@ -60,6 +60,8 @@ public: 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, @@ -92,6 +94,76 @@ public: 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; diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 7e5de2fd02f1..4f6667f6b6e4 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -361,6 +361,10 @@ DOMInterfaces = { 'hasInstanceInterface': 'nsIDOMHTMLBRElement', }, +'HTMLButtonElement': { + 'hasInstanceInterface': 'nsIDOMHTMLButtonElement', +}, + 'HTMLCollection': { 'nativeType': 'nsIHTMLCollection', 'resultNotAddRefed': [ 'item' ] diff --git a/dom/webidl/HTMLButtonElement.webidl b/dom/webidl/HTMLButtonElement.webidl new file mode 100644 index 000000000000..7a0e19d931b1 --- /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; +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 20ef40e86530..e580f53cf227 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -60,6 +60,7 @@ webidl_files = \ HTMLBaseElement.webidl \ HTMLBodyElement.webidl \ HTMLBRElement.webidl \ + HTMLButtonElement.webidl \ HTMLCollection.webidl \ HTMLDataListElement.webidl \ HTMLDirectoryElement.webidl \