mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 561636 (4/4) - When an invalid form is submitted, an error messages should be displayed. r=dolske a2.0=blocking
This commit is contained in:
parent
aae7d7f917
commit
89797e20ed
@ -372,6 +372,10 @@ window[chromehidden~="toolbar"] toolbar:not(.toolbar-primary):not(.chromeclass-m
|
||||
display: -moz-box;
|
||||
}
|
||||
|
||||
#invalid-form-popup {
|
||||
max-width: 280px;
|
||||
}
|
||||
|
||||
#geolocation-notification {
|
||||
-moz-binding: url("chrome://browser/content/urlbarBindings.xml#geolocation-notification");
|
||||
}
|
||||
|
@ -789,6 +789,72 @@ const gXPInstallObserver = {
|
||||
}
|
||||
};
|
||||
|
||||
const gFormSubmitObserver = {
|
||||
QueryInterface : XPCOMUtils.generateQI([Ci.nsIFormSubmitObserver]),
|
||||
|
||||
panel: null,
|
||||
|
||||
init: function()
|
||||
{
|
||||
this.panel = document.getElementById('invalid-form-popup');
|
||||
this.panel.appendChild(document.createTextNode(""));
|
||||
},
|
||||
|
||||
panelIsOpen: function()
|
||||
{
|
||||
return this.panel && this.panel.state != "hiding" &&
|
||||
this.panel.state != "closed";
|
||||
},
|
||||
|
||||
notifyInvalidSubmit : function (aFormElement, aInvalidElements)
|
||||
{
|
||||
// We are going to handle invalid form submission attempt by focusing the
|
||||
// first invalid element and show the corresponding validation message in a
|
||||
// panel attached to the element.
|
||||
if (!aInvalidElements.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't show the popup if the current tab doesn't contain the invalid form.
|
||||
if (gBrowser.selectedTab.linkedBrowser.contentDocument !=
|
||||
aFormElement.ownerDocument) {
|
||||
return;
|
||||
}
|
||||
|
||||
let element = aInvalidElements.queryElementAt(0, Ci.nsISupports);
|
||||
|
||||
if (!(element instanceof HTMLInputElement ||
|
||||
element instanceof HTMLTextAreaElement ||
|
||||
element instanceof HTMLSelectElement ||
|
||||
element instanceof HTMLButtonElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Limit the message to 256 characters.
|
||||
this.panel.firstChild.nodeValue = element.validationMessage.substring(0, 256);
|
||||
|
||||
element.focus();
|
||||
|
||||
// If the user type something or blur the element, we want to remove the popup.
|
||||
// We could check for clicks but a click is already removing the popup.
|
||||
let eventHandler = function(e) {
|
||||
gFormSubmitObserver.panel.hidePopup();
|
||||
};
|
||||
element.addEventListener("input", eventHandler, false);
|
||||
element.addEventListener("blur", eventHandler, false);
|
||||
|
||||
// One event to bring them all and in the darkness bind them all.
|
||||
this.panel.addEventListener("popuphiding", function(aEvent) {
|
||||
aEvent.target.removeEventListener("popuphiding", arguments.callee, false);
|
||||
element.removeEventListener("input", eventHandler, false);
|
||||
element.removeEventListener("blur", eventHandler, false);
|
||||
}, false);
|
||||
|
||||
this.panel.hidden = false;
|
||||
this.panel.openPopup(element, "after_start", 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
// Simple gestures support
|
||||
//
|
||||
// As per bug #412486, web content must not be allowed to receive any
|
||||
@ -1318,10 +1384,12 @@ function delayedStartup(isLoadingBlank, mustLoadSidebar) {
|
||||
Services.obs.addObserver(gXPInstallObserver, "addon-install-blocked", false);
|
||||
Services.obs.addObserver(gXPInstallObserver, "addon-install-failed", false);
|
||||
Services.obs.addObserver(gXPInstallObserver, "addon-install-complete", false);
|
||||
Services.obs.addObserver(gFormSubmitObserver, "invalidformsubmit", false);
|
||||
|
||||
BrowserOffline.init();
|
||||
OfflineApps.init();
|
||||
IndexedDBPromptHelper.init();
|
||||
gFormSubmitObserver.init();
|
||||
|
||||
gBrowser.addEventListener("pageshow", function(evt) { setTimeout(pageShowEventHandlers, 0, evt); }, true);
|
||||
|
||||
@ -1562,6 +1630,7 @@ function BrowserShutdown()
|
||||
Services.obs.removeObserver(gXPInstallObserver, "addon-install-failed");
|
||||
Services.obs.removeObserver(gXPInstallObserver, "addon-install-complete");
|
||||
Services.obs.removeObserver(gPluginHandler.pluginCrashed, "plugin-crashed");
|
||||
Services.obs.removeObserver(gFormSubmitObserver, "invalidformsubmit");
|
||||
|
||||
try {
|
||||
gBrowser.removeProgressListener(window.XULBrowserWindow);
|
||||
@ -4191,6 +4260,11 @@ var XULBrowserWindow = {
|
||||
var location = aLocationURI ? aLocationURI.spec : "";
|
||||
this._hostChanged = true;
|
||||
|
||||
// Hide the form invalid popup.
|
||||
if (gFormSubmitObserver.panelIsOpen()) {
|
||||
gFormSubmitObserver.panel.hidePopup();
|
||||
}
|
||||
|
||||
if (document.tooltipNode) {
|
||||
// Optimise for the common case
|
||||
if (aWebProgress.DOMWindow == content) {
|
||||
|
@ -163,6 +163,9 @@
|
||||
<!-- for url bar autocomplete -->
|
||||
<panel type="autocomplete-richlistbox" id="PopupAutoCompleteRichResult" noautofocus="true" hidden="true"/>
|
||||
|
||||
<!-- for invalid form error message -->
|
||||
<panel id="invalid-form-popup" noautofocus="true" hidden="true" level="parent"/>
|
||||
|
||||
<panel id="editBookmarkPanel"
|
||||
orient="vertical"
|
||||
ignorekeys="true"
|
||||
|
@ -1008,6 +1008,15 @@ toolbar[iconsize="small"] #fullscreen-button {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
/* Invalid form popup */
|
||||
#invalid-form-popup {
|
||||
-moz-appearance: none;
|
||||
background-color: #fffcd6;
|
||||
border: 1px solid #dad8b6;
|
||||
padding: 5px 5px 5px 5px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Notification popup */
|
||||
#notification-popup {
|
||||
margin: 4px 0;
|
||||
|
@ -1910,6 +1910,15 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker {
|
||||
-moz-border-image: url(chrome://browser/skin/hud-panel.png) 26 18 22 50 / 26px 18px 22px 50px repeat;
|
||||
}
|
||||
|
||||
/* Invalid form popup */
|
||||
#invalid-form-popup {
|
||||
-moz-appearance: none;
|
||||
background-color: #fffcd6;
|
||||
border: 1px solid #dad8b6;
|
||||
padding: 5px 5px 5px 5px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#notification-popup {
|
||||
color: #fff;
|
||||
margin-top: -1px;
|
||||
|
@ -1857,6 +1857,15 @@ toolbarbutton.bookmark-item[dragover="true"][open="true"] {
|
||||
color: MenuText;
|
||||
}
|
||||
|
||||
/* Invalid form popup */
|
||||
#invalid-form-popup {
|
||||
-moz-appearance: none;
|
||||
background-color: #fffcd6;
|
||||
border: 1px solid #dad8b6;
|
||||
padding: 5px 5px 5px 5px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Notification popup */
|
||||
#notification-popup {
|
||||
padding: 10px;
|
||||
|
Loading…
Reference in New Issue
Block a user