зеркало из 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();
|
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);
|
ExtensionContent.init(this);
|
||||||
addEventListener("unload", () => {
|
addEventListener("unload", () => {
|
||||||
ExtensionContent.uninit(this);
|
ExtensionContent.uninit(this);
|
||||||
|
RefreshBlocker.uninit();
|
||||||
});
|
});
|
||||||
|
|
|
@ -4030,7 +4030,7 @@
|
||||||
<method name="receiveMessage">
|
<method name="receiveMessage">
|
||||||
<parameter name="aMessage"/>
|
<parameter name="aMessage"/>
|
||||||
<body><![CDATA[
|
<body><![CDATA[
|
||||||
let json = aMessage.json;
|
let data = aMessage.data;
|
||||||
let browser = aMessage.target;
|
let browser = aMessage.target;
|
||||||
|
|
||||||
switch (aMessage.name) {
|
switch (aMessage.name) {
|
||||||
|
@ -4062,32 +4062,32 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "contextmenu": {
|
case "contextmenu": {
|
||||||
let spellInfo = aMessage.data.spellInfo;
|
let spellInfo = data.spellInfo;
|
||||||
if (spellInfo)
|
if (spellInfo)
|
||||||
spellInfo.target = aMessage.target.messageManager;
|
spellInfo.target = aMessage.target.messageManager;
|
||||||
let documentURIObject = makeURI(aMessage.data.docLocation,
|
let documentURIObject = makeURI(data.docLocation,
|
||||||
aMessage.data.charSet,
|
data.charSet,
|
||||||
makeURI(aMessage.data.baseURI));
|
makeURI(data.baseURI));
|
||||||
gContextMenuContentData = { isRemote: true,
|
gContextMenuContentData = { isRemote: true,
|
||||||
event: aMessage.objects.event,
|
event: aMessage.objects.event,
|
||||||
popupNode: aMessage.objects.popupNode,
|
popupNode: aMessage.objects.popupNode,
|
||||||
browser: browser,
|
browser: browser,
|
||||||
editFlags: aMessage.data.editFlags,
|
editFlags: data.editFlags,
|
||||||
spellInfo: spellInfo,
|
spellInfo: spellInfo,
|
||||||
principal: aMessage.data.principal,
|
principal: data.principal,
|
||||||
customMenuItems: aMessage.data.customMenuItems,
|
customMenuItems: data.customMenuItems,
|
||||||
addonInfo: aMessage.data.addonInfo,
|
addonInfo: data.addonInfo,
|
||||||
documentURIObject: documentURIObject,
|
documentURIObject: documentURIObject,
|
||||||
docLocation: aMessage.data.docLocation,
|
docLocation: data.docLocation,
|
||||||
charSet: aMessage.data.charSet,
|
charSet: data.charSet,
|
||||||
referrer: aMessage.data.referrer,
|
referrer: data.referrer,
|
||||||
referrerPolicy: aMessage.data.referrerPolicy,
|
referrerPolicy: data.referrerPolicy,
|
||||||
contentType: aMessage.data.contentType,
|
contentType: data.contentType,
|
||||||
contentDisposition: aMessage.data.contentDisposition,
|
contentDisposition: data.contentDisposition,
|
||||||
frameOuterWindowID: aMessage.data.frameOuterWindowID,
|
frameOuterWindowID: data.frameOuterWindowID,
|
||||||
selectionInfo: aMessage.data.selectionInfo,
|
selectionInfo: data.selectionInfo,
|
||||||
disableSetDesktopBackground: aMessage.data.disableSetDesktopBg,
|
disableSetDesktopBackground: data.disableSetDesktopBg,
|
||||||
loginFillInfo: aMessage.data.loginFillInfo,
|
loginFillInfo: data.loginFillInfo,
|
||||||
};
|
};
|
||||||
let popup = browser.ownerDocument.getElementById("contentAreaContextMenu");
|
let popup = browser.ownerDocument.getElementById("contentAreaContextMenu");
|
||||||
let event = gContextMenuContentData.event;
|
let event = gContextMenuContentData.event;
|
||||||
|
@ -4118,13 +4118,13 @@
|
||||||
// it if there's a possibility FindAsYouType will be used.
|
// it if there's a possibility FindAsYouType will be used.
|
||||||
// There's no point in doing it for most random keypresses.
|
// There's no point in doing it for most random keypresses.
|
||||||
if (!this.isFindBarInitialized(tab) &&
|
if (!this.isFindBarInitialized(tab) &&
|
||||||
aMessage.data.shouldFastFind) {
|
data.shouldFastFind) {
|
||||||
let shouldFastFind = this._findAsYouType;
|
let shouldFastFind = this._findAsYouType;
|
||||||
if (!shouldFastFind) {
|
if (!shouldFastFind) {
|
||||||
// Please keep in sync with toolkit/content/widgets/findbar.xml
|
// Please keep in sync with toolkit/content/widgets/findbar.xml
|
||||||
const FAYT_LINKS_KEY = "'";
|
const FAYT_LINKS_KEY = "'";
|
||||||
const FAYT_TEXT_KEY = "/";
|
const FAYT_TEXT_KEY = "/";
|
||||||
let charCode = aMessage.data.fakeEvent.charCode;
|
let charCode = data.fakeEvent.charCode;
|
||||||
let key = charCode ? String.fromCharCode(charCode) : null;
|
let key = charCode ? String.fromCharCode(charCode) : null;
|
||||||
shouldFastFind = key == FAYT_LINKS_KEY || key == FAYT_TEXT_KEY;
|
shouldFastFind = key == FAYT_LINKS_KEY || key == FAYT_TEXT_KEY;
|
||||||
}
|
}
|
||||||
|
@ -4135,6 +4135,17 @@
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "RefreshBlocker:Blocked": {
|
||||||
|
let event = new CustomEvent("RefreshBlocked", {
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: false,
|
||||||
|
detail: data,
|
||||||
|
});
|
||||||
|
|
||||||
|
browser.dispatchEvent(event);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
]]></body>
|
]]></body>
|
||||||
|
@ -4244,6 +4255,7 @@
|
||||||
}
|
}
|
||||||
messageManager.addMessageListener("DOMWebNotificationClicked", this);
|
messageManager.addMessageListener("DOMWebNotificationClicked", this);
|
||||||
messageManager.addMessageListener("DOMServiceWorkerFocusClient", this);
|
messageManager.addMessageListener("DOMServiceWorkerFocusClient", this);
|
||||||
|
messageManager.addMessageListener("RefreshBlocker:Blocked", this);
|
||||||
|
|
||||||
// To correctly handle keypresses for potential FindAsYouType, while
|
// To correctly handle keypresses for potential FindAsYouType, while
|
||||||
// the tab's find bar is not yet initialized.
|
// the tab's find bar is not yet initialized.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче