зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1055464 - Add RefreshBlocker to tab-content, and a listener in tabbrowser.xml. r=Mossop
--HG-- extra : commitid : A2DWArd8dy6 extra : rebase_source : 209045482dab1455821892a7b5301487ccbbc963 extra : amend_source : 6c5fa1da07f7690a030db6d15033435a7b7e375d
This commit is contained in:
Родитель
3c97745a55
Коммит
5cb4464af6
|
@ -688,7 +688,76 @@ var DOMFullscreenHandler = {
|
|||
};
|
||||
DOMFullscreenHandler.init();
|
||||
|
||||
var RefreshBlocker = {
|
||||
init() {
|
||||
this._filter = Cc["@mozilla.org/appshell/component/browser-status-filter;1"]
|
||||
.createInstance(Ci.nsIWebProgress);
|
||||
this._filter.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_REFRESH);
|
||||
|
||||
let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebProgress);
|
||||
webProgress.addProgressListener(this._filter, Ci.nsIWebProgress.NOTIFY_REFRESH);
|
||||
|
||||
addMessageListener("RefreshBlocker:Refresh", this);
|
||||
},
|
||||
|
||||
uninit() {
|
||||
let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebProgress);
|
||||
webProgress.removeProgressListener(this._filter);
|
||||
|
||||
this._filter.removeProgressListener(this);
|
||||
this._filter = null;
|
||||
|
||||
removeMessageListener("RefreshBlocker:Refresh", this);
|
||||
},
|
||||
|
||||
onRefreshAttempted(aWebProgress, aURI, aDelay, aSameURI) {
|
||||
if (Services.prefs.getBoolPref("accessibility.blockautorefresh")) {
|
||||
let win = aWebProgress.DOMWindow;
|
||||
let outerWindowID = win.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils)
|
||||
.outerWindowID;
|
||||
|
||||
sendAsyncMessage("RefreshBlocker:Blocked", {
|
||||
URI: aURI.spec,
|
||||
originCharset: aURI.originCharset,
|
||||
delay: aDelay,
|
||||
sameURI: aSameURI,
|
||||
outerWindowID,
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
receiveMessage(message) {
|
||||
let data = message.data;
|
||||
|
||||
if (message.name == "RefreshBlocker:Refresh") {
|
||||
let win = Services.wm.getOuterWindowWithId(data.outerWindowID);
|
||||
let refreshURI = win.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDocShell)
|
||||
.QueryInterface(Ci.nsIRefreshURI);
|
||||
|
||||
let URI = BrowserUtils.makeURI(data.URI, data.originCharset, null);
|
||||
|
||||
refreshURI.forceRefreshURI(URI, data.delay, true);
|
||||
}
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener2,
|
||||
Ci.nsIWebProgressListener,
|
||||
Ci.nsISupportsWeakReference,
|
||||
Ci.nsISupports]),
|
||||
};
|
||||
|
||||
RefreshBlocker.init();
|
||||
|
||||
ExtensionContent.init(this);
|
||||
addEventListener("unload", () => {
|
||||
ExtensionContent.uninit(this);
|
||||
RefreshBlocker.uninit();
|
||||
});
|
||||
|
|
|
@ -4030,7 +4030,7 @@
|
|||
<method name="receiveMessage">
|
||||
<parameter name="aMessage"/>
|
||||
<body><![CDATA[
|
||||
let json = aMessage.json;
|
||||
let data = aMessage.data;
|
||||
let browser = aMessage.target;
|
||||
|
||||
switch (aMessage.name) {
|
||||
|
@ -4062,32 +4062,32 @@
|
|||
break;
|
||||
}
|
||||
case "contextmenu": {
|
||||
let spellInfo = aMessage.data.spellInfo;
|
||||
let spellInfo = data.spellInfo;
|
||||
if (spellInfo)
|
||||
spellInfo.target = aMessage.target.messageManager;
|
||||
let documentURIObject = makeURI(aMessage.data.docLocation,
|
||||
aMessage.data.charSet,
|
||||
makeURI(aMessage.data.baseURI));
|
||||
let documentURIObject = makeURI(data.docLocation,
|
||||
data.charSet,
|
||||
makeURI(data.baseURI));
|
||||
gContextMenuContentData = { isRemote: true,
|
||||
event: aMessage.objects.event,
|
||||
popupNode: aMessage.objects.popupNode,
|
||||
browser: browser,
|
||||
editFlags: aMessage.data.editFlags,
|
||||
editFlags: data.editFlags,
|
||||
spellInfo: spellInfo,
|
||||
principal: aMessage.data.principal,
|
||||
customMenuItems: aMessage.data.customMenuItems,
|
||||
addonInfo: aMessage.data.addonInfo,
|
||||
principal: data.principal,
|
||||
customMenuItems: data.customMenuItems,
|
||||
addonInfo: data.addonInfo,
|
||||
documentURIObject: documentURIObject,
|
||||
docLocation: aMessage.data.docLocation,
|
||||
charSet: aMessage.data.charSet,
|
||||
referrer: aMessage.data.referrer,
|
||||
referrerPolicy: aMessage.data.referrerPolicy,
|
||||
contentType: aMessage.data.contentType,
|
||||
contentDisposition: aMessage.data.contentDisposition,
|
||||
frameOuterWindowID: aMessage.data.frameOuterWindowID,
|
||||
selectionInfo: aMessage.data.selectionInfo,
|
||||
disableSetDesktopBackground: aMessage.data.disableSetDesktopBg,
|
||||
loginFillInfo: aMessage.data.loginFillInfo,
|
||||
docLocation: data.docLocation,
|
||||
charSet: data.charSet,
|
||||
referrer: data.referrer,
|
||||
referrerPolicy: data.referrerPolicy,
|
||||
contentType: data.contentType,
|
||||
contentDisposition: data.contentDisposition,
|
||||
frameOuterWindowID: data.frameOuterWindowID,
|
||||
selectionInfo: data.selectionInfo,
|
||||
disableSetDesktopBackground: data.disableSetDesktopBg,
|
||||
loginFillInfo: data.loginFillInfo,
|
||||
};
|
||||
let popup = browser.ownerDocument.getElementById("contentAreaContextMenu");
|
||||
let event = gContextMenuContentData.event;
|
||||
|
@ -4118,13 +4118,13 @@
|
|||
// it if there's a possibility FindAsYouType will be used.
|
||||
// There's no point in doing it for most random keypresses.
|
||||
if (!this.isFindBarInitialized(tab) &&
|
||||
aMessage.data.shouldFastFind) {
|
||||
data.shouldFastFind) {
|
||||
let shouldFastFind = this._findAsYouType;
|
||||
if (!shouldFastFind) {
|
||||
// Please keep in sync with toolkit/content/widgets/findbar.xml
|
||||
const FAYT_LINKS_KEY = "'";
|
||||
const FAYT_TEXT_KEY = "/";
|
||||
let charCode = aMessage.data.fakeEvent.charCode;
|
||||
let charCode = data.fakeEvent.charCode;
|
||||
let key = charCode ? String.fromCharCode(charCode) : null;
|
||||
shouldFastFind = key == FAYT_LINKS_KEY || key == FAYT_TEXT_KEY;
|
||||
}
|
||||
|
@ -4135,6 +4135,17 @@
|
|||
}
|
||||
break;
|
||||
}
|
||||
case "RefreshBlocker:Blocked": {
|
||||
let event = new CustomEvent("RefreshBlocked", {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
detail: data,
|
||||
});
|
||||
|
||||
browser.dispatchEvent(event);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
]]></body>
|
||||
|
@ -4244,6 +4255,7 @@
|
|||
}
|
||||
messageManager.addMessageListener("DOMWebNotificationClicked", this);
|
||||
messageManager.addMessageListener("DOMServiceWorkerFocusClient", this);
|
||||
messageManager.addMessageListener("RefreshBlocker:Blocked", this);
|
||||
|
||||
// To correctly handle keypresses for potential FindAsYouType, while
|
||||
// the tab's find bar is not yet initialized.
|
||||
|
|
Загрузка…
Ссылка в новой задаче