mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 866304 DialogUI "modals" cleanup patch. Removes the "modals" portions of DialogUI. Converts the crash reporter prompt to use nsIPromptService.confirmEx instead of DialogUI.importModal. r=mbrubeck
The crash reporter prompt is the only consumer of DialogUI.importModal and related code. The "modals" concept that DialogUI implements should go away in favor of tab-modal dialogs and tab-agnostic notifications (e.g. flyouts). I don't think that the crash reporter prompt should be a tab modal dialog; I'd prefer to see it become an about: page or perhaps a flyout. Making it a tab-modal prompt was just the easiest thing to do in this set of patches.
This commit is contained in:
parent
f4e999f820
commit
d52c2fe1c5
@ -265,16 +265,40 @@ var BrowserUI = {
|
||||
let didPrompt = Services.prefs.getBoolPref("app.crashreporter.prompted");
|
||||
|
||||
if (!shouldReport && !didPrompt) {
|
||||
// We have a crash to submit, we haven't prompted for approval yet,
|
||||
// and the auto-submit pref is false, prompt. The dialog will call
|
||||
// startupCrashCheck again if the user approves.
|
||||
let crashBundle = Services.strings.createBundle("chrome://browser/locale/crashprompt.properties");
|
||||
let title = crashBundle.GetStringFromName("crashprompt.dialog.title");
|
||||
let acceptbutton = crashBundle.GetStringFromName("crashprompt.dialog.acceptbutton");
|
||||
let refusebutton = crashBundle.GetStringFromName("crashprompt.dialog.refusebutton");
|
||||
let bodyText = crashBundle.GetStringFromName("crashprompt.dialog.statement1");
|
||||
|
||||
let buttonPressed =
|
||||
Services.prompt.confirmEx(
|
||||
window,
|
||||
title,
|
||||
bodyText,
|
||||
Ci.nsIPrompt.BUTTON_POS_0 * Ci.nsIPrompt.BUTTON_TITLE_IS_STRING
|
||||
+ Ci.nsIPrompt.BUTTON_POS_1 * Ci.nsIPrompt.BUTTON_TITLE_IS_STRING
|
||||
+ Ci.nsIPrompt.BUTTON_POS_1_DEFAULT,
|
||||
acceptbutton,
|
||||
refusebutton,
|
||||
null,
|
||||
null,
|
||||
{ value: false });
|
||||
|
||||
Services.prefs.setBoolPref("app.crashreporter.prompted", true);
|
||||
DialogUI.importModal(document, "chrome://browser/content/prompt/crash.xul");
|
||||
return;
|
||||
|
||||
if (buttonPressed == 0) {
|
||||
Services.prefs.setBoolPref('app.crashreporter.autosubmit', true);
|
||||
BrowserUI.crashReportingPrefChanged(true);
|
||||
shouldReport = true;
|
||||
} else {
|
||||
Services.prefs.setBoolPref('app.crashreporter.autosubmit', false);
|
||||
BrowserUI.crashReportingPrefChanged(false);
|
||||
}
|
||||
}
|
||||
|
||||
// We've already prompted, return if the user doesn't want to report.
|
||||
if (!shouldReport && didPrompt) {
|
||||
if (!shouldReport) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -734,11 +758,6 @@ var BrowserUI = {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check open modal elements
|
||||
if (DialogUI.modals.length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check open panel
|
||||
if (PanelUI.isVisible) {
|
||||
PanelUI.hide();
|
||||
@ -1314,66 +1333,6 @@ var DialogUI = {
|
||||
window.addEventListener("mousedown", this, true);
|
||||
},
|
||||
|
||||
/*******************************************
|
||||
* Modal popups
|
||||
*/
|
||||
|
||||
get modals() {
|
||||
return document.getElementsByClassName("modal-block");
|
||||
},
|
||||
|
||||
importModal: function importModal(aParent, aSrc, aArguments) {
|
||||
// load the dialog with a synchronous XHR
|
||||
let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance();
|
||||
xhr.open("GET", aSrc, false);
|
||||
xhr.overrideMimeType("text/xml");
|
||||
xhr.send(null);
|
||||
if (!xhr.responseXML)
|
||||
return null;
|
||||
|
||||
let currentNode;
|
||||
let nodeIterator = xhr.responseXML.createNodeIterator(xhr.responseXML, NodeFilter.SHOW_TEXT, null, false);
|
||||
while (!!(currentNode = nodeIterator.nextNode())) {
|
||||
let trimmed = currentNode.nodeValue.replace(/^\s\s*/, "").replace(/\s\s*$/, "");
|
||||
if (!trimmed.length)
|
||||
currentNode.parentNode.removeChild(currentNode);
|
||||
}
|
||||
|
||||
let doc = xhr.responseXML.documentElement;
|
||||
|
||||
let dialog = null;
|
||||
|
||||
// we need to insert before context-container if we want allow pasting (using
|
||||
// the context menu) into dialogs
|
||||
let contentMenuContainer = document.getElementById("context-container");
|
||||
let parentNode = contentMenuContainer.parentNode;
|
||||
|
||||
// emit DOMWillOpenModalDialog event
|
||||
let event = document.createEvent("Events");
|
||||
event.initEvent("DOMWillOpenModalDialog", true, false);
|
||||
let dispatcher = aParent || getBrowser();
|
||||
dispatcher.dispatchEvent(event);
|
||||
|
||||
// create a full-screen semi-opaque box as a background or reuse
|
||||
// the existing one.
|
||||
let back = document.getElementById("dialog-modal-block");
|
||||
if (!back) {
|
||||
back = document.createElement("box");
|
||||
} else {
|
||||
while (back.hasChildNodes()) {
|
||||
back.removeChild(back.firstChild);
|
||||
}
|
||||
}
|
||||
back.setAttribute("class", "modal-block");
|
||||
back.setAttribute("id", "dialog-modal-block");
|
||||
dialog = back.appendChild(document.importNode(doc, true));
|
||||
parentNode.insertBefore(back, contentMenuContainer);
|
||||
|
||||
dialog.arguments = aArguments;
|
||||
dialog.parent = aParent;
|
||||
return dialog;
|
||||
},
|
||||
|
||||
/*******************************************
|
||||
* Popups
|
||||
*/
|
||||
|
@ -20,7 +20,6 @@
|
||||
locale/browser/sync.properties (%chrome/sync.properties)
|
||||
locale/browser/passwordmgr.properties (%chrome/passwordmgr.properties)
|
||||
locale/browser/phishing.dtd (%chrome/phishing.dtd)
|
||||
locale/browser/crashprompt.dtd (%chrome/crashprompt.dtd)
|
||||
locale/browser/aboutAddons.dtd (%chrome/aboutAddons.dtd)
|
||||
|
||||
@AB_CD@.jar:
|
||||
|
Loading…
Reference in New Issue
Block a user