зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1474143 - Replace form submission observer notifications with events. r=Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D16651 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0ad4c17e2f
Коммит
2913059e69
|
@ -860,44 +860,16 @@ nsresult HTMLFormElement::NotifySubmitObservers(nsIURI* aActionURL,
|
|||
}
|
||||
}
|
||||
|
||||
// Notify observers that the form is being submitted.
|
||||
nsCOMPtr<nsIObserverService> service =
|
||||
mozilla::services::GetObserverService();
|
||||
if (!service) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> theEnum;
|
||||
nsresult rv = service->EnumerateObservers(
|
||||
aEarlyNotify ? NS_EARLYFORMSUBMIT_SUBJECT : NS_FORMSUBMIT_SUBJECT,
|
||||
getter_AddRefs(theEnum));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (theEnum) {
|
||||
nsCOMPtr<nsISupports> inst;
|
||||
*aCancelSubmit = false;
|
||||
|
||||
// XXXbz what do the submit observers actually want? The window
|
||||
// of the document this is shown in? Or something else?
|
||||
// sXBL/XBL2 issue
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = OwnerDoc()->GetWindow();
|
||||
|
||||
bool loop = true;
|
||||
while (NS_SUCCEEDED(theEnum->HasMoreElements(&loop)) && loop) {
|
||||
theEnum->GetNext(getter_AddRefs(inst));
|
||||
|
||||
nsCOMPtr<nsIFormSubmitObserver> formSubmitObserver(
|
||||
do_QueryInterface(inst));
|
||||
if (formSubmitObserver) {
|
||||
rv = formSubmitObserver->Notify(
|
||||
this, window ? window->GetCurrentInnerWindow() : nullptr,
|
||||
aActionURL, aCancelSubmit);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
if (*aCancelSubmit) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
bool defaultAction = true;
|
||||
nsresult rv = nsContentUtils::DispatchEventOnlyToChrome(
|
||||
OwnerDoc(), static_cast<nsINode*>(this),
|
||||
aEarlyNotify ? NS_LITERAL_STRING("DOMFormBeforeSubmit")
|
||||
: NS_LITERAL_STRING("DOMFormSubmit"),
|
||||
CanBubble::eYes, Cancelable::eYes, &defaultAction);
|
||||
*aCancelSubmit = !defaultAction;
|
||||
if (*aCancelSubmit) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,14 +16,10 @@ webidl Element;
|
|||
[scriptable, uuid(867cb7e7-835d-408b-9788-d2834d284e03)]
|
||||
interface nsIFormSubmitObserver: nsISupports
|
||||
{
|
||||
void notify(in HTMLFormElement formNode, in mozIDOMWindow window, in nsIURI actionURL, out boolean cancelSubmit);
|
||||
|
||||
void notifyInvalidSubmit(in HTMLFormElement formNode,
|
||||
in Array<Element> invalidElements);
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_FORMSUBMIT_SUBJECT "formsubmit"
|
||||
#define NS_EARLYFORMSUBMIT_SUBJECT "earlyformsubmit"
|
||||
#define NS_INVALIDFORMSUBMIT_SUBJECT "invalidformsubmit"
|
||||
%}
|
||||
|
|
Загрузка…
Ссылка в новой задаче