diff --git a/browser/modules/FormSubmitObserver.jsm b/browser/modules/FormSubmitObserver.jsm index df7182679150..a70cbb175136 100644 --- a/browser/modules/FormSubmitObserver.jsm +++ b/browser/modules/FormSubmitObserver.jsm @@ -13,11 +13,6 @@ var Cc = Components.classes; var Ci = Components.interfaces; var Cu = Components.utils; -var HTMLInputElement = Ci.nsIDOMHTMLInputElement; -var HTMLTextAreaElement = Ci.nsIDOMHTMLTextAreaElement; -var HTMLSelectElement = Ci.nsIDOMHTMLSelectElement; -var HTMLButtonElement = Ci.nsIDOMHTMLButtonElement; - this.EXPORTED_SYMBOLS = [ "FormSubmitObserver" ]; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); @@ -110,10 +105,10 @@ FormSubmitObserver.prototype = return; } - if (!(element instanceof HTMLInputElement || - element instanceof HTMLTextAreaElement || - element instanceof HTMLSelectElement || - element instanceof HTMLButtonElement)) { + if (!(ChromeUtils.getClassName(element) === "HTMLInputElement" || + ChromeUtils.getClassName(element) === "HTMLTextAreaElement" || + ChromeUtils.getClassName(element) === "HTMLSelectElement" || + ChromeUtils.getClassName(element) === "HTMLButtonElement")) { continue; } diff --git a/dom/html/HTMLButtonElement.cpp b/dom/html/HTMLButtonElement.cpp index d80efae2a6e3..948b4b57fed9 100644 --- a/dom/html/HTMLButtonElement.cpp +++ b/dom/html/HTMLButtonElement.cpp @@ -78,7 +78,6 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLButtonElement, NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLButtonElement, nsGenericHTMLFormElementWithState, - nsIDOMHTMLButtonElement, nsIConstraintValidation) void @@ -110,32 +109,25 @@ HTMLButtonElement::FieldSetDisabledChanged(bool aNotify) UpdateState(aNotify); } -// nsIDOMHTMLButtonElement - NS_IMPL_ELEMENT_CLONE(HTMLButtonElement) - -// nsIDOMHTMLButtonElement - -NS_IMETHODIMP -HTMLButtonElement::GetForm(nsIDOMHTMLFormElement** aForm) +void +HTMLButtonElement::GetFormEnctype(nsAString& aFormEncType) { - return nsGenericHTMLFormElementWithState::GetForm(aForm); + GetEnumAttr(nsGkAtoms::formenctype, "", kFormDefaultEnctype->tag, aFormEncType); } -NS_IMPL_BOOL_ATTR(HTMLButtonElement, Autofocus, autofocus) -NS_IMPL_BOOL_ATTR(HTMLButtonElement, Disabled, disabled) -NS_IMPL_ACTION_ATTR(HTMLButtonElement, FormAction, formaction) -NS_IMPL_ENUM_ATTR_DEFAULT_MISSING_INVALID_VALUES(HTMLButtonElement, FormEnctype, formenctype, - "", kFormDefaultEnctype->tag) -NS_IMPL_ENUM_ATTR_DEFAULT_MISSING_INVALID_VALUES(HTMLButtonElement, FormMethod, formmethod, - "", kFormDefaultMethod->tag) -NS_IMPL_BOOL_ATTR(HTMLButtonElement, FormNoValidate, formnovalidate) -NS_IMPL_STRING_ATTR(HTMLButtonElement, FormTarget, formtarget) -NS_IMPL_STRING_ATTR(HTMLButtonElement, Name, name) -NS_IMPL_STRING_ATTR(HTMLButtonElement, Value, value) -NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(HTMLButtonElement, Type, type, - kButtonDefaultType->tag) +void +HTMLButtonElement::GetFormMethod(nsAString& aFormMethod) +{ + GetEnumAttr(nsGkAtoms::formmethod, "", kFormDefaultMethod->tag, aFormMethod); +} + +void +HTMLButtonElement::GetType(nsAString& aType) +{ + GetEnumAttr(nsGkAtoms::type, kButtonDefaultType->tag, aType); +} int32_t HTMLButtonElement::TabIndexDefault() @@ -375,7 +367,7 @@ HTMLButtonElement::SubmitNamesValues(HTMLFormSubmission* aFormSubmission) // Get the name (if no name, no submit) // nsAutoString name; - GetAttr(kNameSpaceID_None, nsGkAtoms::name, name); + GetHTMLAttr(nsGkAtoms::name, name); if (name.IsEmpty()) { return NS_OK; } @@ -384,10 +376,7 @@ HTMLButtonElement::SubmitNamesValues(HTMLFormSubmission* aFormSubmission) // Get the value // nsAutoString value; - nsresult rv = GetValue(value); - if (NS_FAILED(rv)) { - return rv; - } + GetHTMLAttr(nsGkAtoms::value, value); // // Submit @@ -471,7 +460,8 @@ bool HTMLButtonElement::RestoreState(nsPresState* aState) { if (aState && aState->IsDisabledSet() && !aState->GetDisabled()) { - SetDisabled(false); + IgnoredErrorResult rv; + SetDisabled(false, rv); } return false; diff --git a/dom/html/HTMLButtonElement.h b/dom/html/HTMLButtonElement.h index 9a3c8f18b7fe..02f470349129 100644 --- a/dom/html/HTMLButtonElement.h +++ b/dom/html/HTMLButtonElement.h @@ -9,7 +9,6 @@ #include "mozilla/Attributes.h" #include "nsGenericHTMLElement.h" -#include "nsIDOMHTMLButtonElement.h" #include "nsIConstraintValidation.h" namespace mozilla { @@ -18,12 +17,10 @@ class EventChainPreVisitor; namespace dom { class HTMLButtonElement final : public nsGenericHTMLFormElementWithState, - public nsIDOMHTMLButtonElement, public nsIConstraintValidation { public: using nsIConstraintValidation::GetValidationMessage; - using nsGenericHTMLFormElementWithState::GetFormAction; explicit HTMLButtonElement(already_AddRefed& aNodeInfo, FromParser aFromParser = NOT_FROM_PARSER); @@ -44,9 +41,6 @@ public: return true; } - // nsIDOMHTMLButtonElement - NS_DECL_NSIDOMHTMLBUTTONELEMENT - // overriden nsIFormControl methods NS_IMETHOD Reset() override; NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override; @@ -120,17 +114,17 @@ public: } // nsGenericHTMLFormElement::GetForm is fine. using nsGenericHTMLFormElement::GetForm; - // XPCOM GetFormAction is fine. + // GetFormAction implemented in superclass void SetFormAction(const nsAString& aFormAction, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::formaction, aFormAction, aRv); } - // XPCOM GetFormEnctype is fine. + void GetFormEnctype(nsAString& aFormEncType); void SetFormEnctype(const nsAString& aFormEnctype, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::formenctype, aFormEnctype, aRv); } - // XPCOM GetFormMethod is fine. + void GetFormMethod(nsAString& aFormMethod); void SetFormMethod(const nsAString& aFormMethod, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::formmethod, aFormMethod, aRv); @@ -143,22 +137,31 @@ public: { SetHTMLBoolAttr(nsGkAtoms::formnovalidate, aFormNoValidate, aError); } - // XPCOM GetFormTarget is fine. + void GetFormTarget(DOMString& aFormTarget) + { + GetHTMLAttr(nsGkAtoms::formtarget, aFormTarget); + } void SetFormTarget(const nsAString& aFormTarget, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::formtarget, aFormTarget, aRv); } - // XPCOM GetName is fine. + void GetName(DOMString& aName) + { + GetHTMLAttr(nsGkAtoms::name, aName); + } void SetName(const nsAString& aName, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::name, aName, aRv); } - // XPCOM GetType is fine. + void GetType(nsAString& aType); void SetType(const nsAString& aType, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::type, aType, aRv); } - // XPCOM GetValue is fine. + void GetValue(DOMString& aValue) + { + GetHTMLAttr(nsGkAtoms::value, aValue); + } void SetValue(const nsAString& aValue, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::value, aValue, aRv); diff --git a/dom/html/HTMLFormElement.cpp b/dom/html/HTMLFormElement.cpp index 936dada73d76..b84b902dd77a 100644 --- a/dom/html/HTMLFormElement.cpp +++ b/dom/html/HTMLFormElement.cpp @@ -66,13 +66,13 @@ #include "nsIConstraintValidation.h" -#include "nsIDOMHTMLButtonElement.h" #include "nsSandboxFlags.h" #include "nsIContentSecurityPolicy.h" // images #include "mozilla/dom/HTMLImageElement.h" +#include "mozilla/dom/HTMLButtonElement.h" // construction, destruction NS_IMPL_NS_NEW_HTML_ELEMENT(Form) @@ -1649,7 +1649,7 @@ HTMLFormElement::GetActionURL(nsIURI** aActionURL, if (inputElement) { inputElement->GetFormAction(action); } else { - nsCOMPtr buttonElement = do_QueryInterface(aOriginatingElement); + auto buttonElement = HTMLButtonElement::FromContent(aOriginatingElement); if (buttonElement) { buttonElement->GetFormAction(action); } else { diff --git a/dom/interfaces/html/moz.build b/dom/interfaces/html/moz.build index b0f4f6c35a03..ec6eb387d54b 100644 --- a/dom/interfaces/html/moz.build +++ b/dom/interfaces/html/moz.build @@ -9,7 +9,6 @@ with Files("**"): XPIDL_SOURCES += [ 'nsIDOMHTMLBaseElement.idl', - 'nsIDOMHTMLButtonElement.idl', 'nsIDOMHTMLCanvasElement.idl', 'nsIDOMHTMLCollection.idl', 'nsIDOMHTMLDocument.idl', diff --git a/dom/interfaces/html/nsIDOMHTMLButtonElement.idl b/dom/interfaces/html/nsIDOMHTMLButtonElement.idl deleted file mode 100644 index 3c2e31fde5f4..000000000000 --- a/dom/interfaces/html/nsIDOMHTMLButtonElement.idl +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- 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/. */ - -#include "nsIDOMHTMLElement.idl" - -/** - * The nsIDOMHTMLButtonElement interface is the interface to a [X]HTML - * button element. - * - * This interface is trying to follow the DOM Level 2 HTML specification: - * http://www.w3.org/TR/DOM-Level-2-HTML/ - * - * with changes from the work-in-progress WHATWG HTML specification: - * http://www.whatwg.org/specs/web-apps/current-work/ - */ - -interface nsIDOMValidityState; - -[uuid(44b7a468-7dba-4f0c-9b4e-ee46dc0f26c7)] -interface nsIDOMHTMLButtonElement : nsISupports -{ - attribute boolean autofocus; - attribute boolean disabled; - readonly attribute nsIDOMHTMLFormElement 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; -}; - diff --git a/mobile/android/components/BrowserCLH.js b/mobile/android/components/BrowserCLH.js index 321f9cda2a3a..1de91f16108c 100644 --- a/mobile/android/components/BrowserCLH.js +++ b/mobile/android/components/BrowserCLH.js @@ -138,10 +138,10 @@ BrowserCLH.prototype = { "focus", "blur", "click", "input", ], { handler: event => { - if (event.target instanceof Ci.nsIDOMHTMLInputElement || - event.target instanceof Ci.nsIDOMHTMLTextAreaElement || - event.target instanceof Ci.nsIDOMHTMLSelectElement || - event.target instanceof Ci.nsIDOMHTMLButtonElement) { + if (ChromeUtils.getClassName(event.target) === "HTMLInputElement" || + ChromeUtils.getClassName(event.target) === "HTMLTextAreaElement" || + ChromeUtils.getClassName(event.target) === "HTMLSelectElement" || + ChromeUtils.getClassName(event.target) === "HTMLButtonElement") { // Only load FormAssistant when the event target is what we care about. return this.FormAssistant; } diff --git a/mobile/android/modules/FormAssistant.jsm b/mobile/android/modules/FormAssistant.jsm index f230f26a6ffc..8350f3a39a89 100644 --- a/mobile/android/modules/FormAssistant.jsm +++ b/mobile/android/modules/FormAssistant.jsm @@ -296,10 +296,10 @@ var FormAssistant = { // Only show a validation message if the user submitted an invalid form, // there's a non-empty message string, and the element is the correct type _isValidateable: function(aElement) { - return (aElement instanceof Ci.nsIDOMHTMLInputElement || - aElement instanceof Ci.nsIDOMHTMLTextAreaElement || - aElement instanceof Ci.nsIDOMHTMLSelectElement || - aElement instanceof Ci.nsIDOMHTMLButtonElement) && + return (ChromeUtils.getClassName(aElement) === "HTMLInputElement" || + ChromeUtils.getClassName(aElement) === "HTMLTextAreaElement" || + ChromeUtils.getClassName(aElement) === "HTMLSelectElement" || + ChromeUtils.getClassName(aElement) === "HTMLButtonElement") && aElement.matches(":-moz-ui-invalid") && aElement.validationMessage; }, diff --git a/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp b/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp index 0768695d81ff..2dbff9088a0c 100644 --- a/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp +++ b/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp @@ -46,7 +46,6 @@ #include "nsIDOMGeoPositionError.h" #include "nsIDOMHistory.h" #include "nsIDOMHTMLBaseElement.h" -#include "nsIDOMHTMLButtonElement.h" #include "nsIDOMHTMLCanvasElement.h" #include "nsIDOMHTMLCollection.h" #include "nsIDOMHTMLDocument.h" @@ -320,7 +319,6 @@ const ComponentsInterfaceShimEntry kComponentsInterfaceShimMap[] = DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMGeoPositionError, PositionError), DEFINE_SHIM(History), DEFINE_SHIM(HTMLBaseElement), - DEFINE_SHIM(HTMLButtonElement), DEFINE_SHIM(HTMLCanvasElement), DEFINE_SHIM(HTMLCollection), DEFINE_SHIM(HTMLDocument),