зеркало из https://github.com/mozilla/gecko-dev.git
Bug 925538 - Import fireDialogEvent method into FilePicker. r=mfinkle
This commit is contained in:
Родитель
a36a131eb3
Коммит
7ad015820c
|
@ -163,7 +163,7 @@ FilePicker.prototype = {
|
|||
|
||||
show: function() {
|
||||
if (this._domWin) {
|
||||
PromptUtils.fireDialogEvent(this._domWin, "DOMWillOpenModalDialog");
|
||||
this.fireDialogEvent(this._domWin, "DOMWillOpenModalDialog");
|
||||
let winUtils = this._domWin.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
|
||||
winUtils.enterModalState();
|
||||
}
|
||||
|
@ -176,6 +176,12 @@ FilePicker.prototype = {
|
|||
thread.processNextEvent(true);
|
||||
delete this._promptActive;
|
||||
|
||||
if (this._domWin) {
|
||||
let winUtils = this._domWin.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
|
||||
winUtils.leaveModalState();
|
||||
this.fireDialogEvent(this._domWin, "DOMModalDialogClosed");
|
||||
}
|
||||
|
||||
if (this._filePath)
|
||||
return Ci.nsIFilePicker.returnOK;
|
||||
|
||||
|
@ -245,6 +251,20 @@ FilePicker.prototype = {
|
|||
};
|
||||
},
|
||||
|
||||
fireDialogEvent: function(aDomWin, aEventName) {
|
||||
// accessing the document object can throw if this window no longer exists. See bug 789888.
|
||||
try {
|
||||
if (!aDomWin.document)
|
||||
return;
|
||||
let event = aDomWin.document.createEvent("Events");
|
||||
event.initEvent(aEventName, true, true);
|
||||
let winUtils = aDomWin.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
winUtils.dispatchEventToChromeOnly(aDomWin, event);
|
||||
} catch(ex) {
|
||||
}
|
||||
},
|
||||
|
||||
classID: Components.ID("{18a4e042-7c7c-424b-a583-354e68553a7f}"),
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFilePicker, Ci.nsIObserver])
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче