Bug 1403795 - Remove nsIDOMHTMLButtonElement; r=bz

Removes the XPCOM interface for nsIDOMHTMLButtonElement, replacing it
with binding class usage.

MozReview-Commit-ID: CzqRb7lI28W
This commit is contained in:
Kyle Machulis 2017-09-27 21:03:58 -07:00
Родитель 587fb629ee
Коммит 2ac26c5527
9 изменённых файлов: 48 добавлений и 100 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<mozilla::dom::NodeInfo>& 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);

Просмотреть файл

@ -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<nsIDOMHTMLButtonElement> buttonElement = do_QueryInterface(aOriginatingElement);
auto buttonElement = HTMLButtonElement::FromContent(aOriginatingElement);
if (buttonElement) {
buttonElement->GetFormAction(action);
} else {

Просмотреть файл

@ -9,7 +9,6 @@ with Files("**"):
XPIDL_SOURCES += [
'nsIDOMHTMLBaseElement.idl',
'nsIDOMHTMLButtonElement.idl',
'nsIDOMHTMLCanvasElement.idl',
'nsIDOMHTMLCollection.idl',
'nsIDOMHTMLDocument.idl',

Просмотреть файл

@ -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;
};

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
},

Просмотреть файл

@ -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),