1 /* vim: set ts=2 sw=2 sts=2 et tw=80: */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 export class AutoScrollParent extends JSWindowActorParent {
8 let browser = this.manager.browsingContext.top.embedderElement;
13 // If another tab is activated, we shouldn't start autoscroll requested
14 // for the previous active window if and only if the browser is a remote
15 // browser. This is required for web apps which don't prevent default of
16 // middle click after opening a new window. If the active tab is our
17 // documents like about:*, we don't need this check since our documents
18 // should do it correctly.
19 const requestedInForegroundTab = browser.isRemoteBrowser
20 ? Services.focus.focusedElement == browser
25 case "Autoscroll:Start":
26 // Don't start autoscroll if the tab has already been a background tab.
27 if (!requestedInForegroundTab) {
28 return Promise.resolve({ autoscrollEnabled: false, usingAPZ: false });
30 return Promise.resolve(browser.startScroll(data));
31 case "Autoscroll:MaybeStartInParent":
32 // Don't start autoscroll if the tab has already been a background tab.
33 if (!requestedInForegroundTab) {
34 return Promise.resolve({ autoscrollEnabled: false, usingAPZ: false });
36 let parent = this.browsingContext.parent;
38 let actor = parent.currentWindowGlobal.getActor("AutoScroll");
39 actor.sendAsyncMessage("Autoscroll:MaybeStart", data);
42 case "Autoscroll:Cancel":
43 browser.cancelScroll();