/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* vim: set ts=2 sw=2 sts=2 et: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; dump("############################### browserElementPanningAPZDisabled.js loaded\n"); var { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Geometry.jsm"); var global = this; const ContentPanningAPZDisabled = { // Are we listening to touch or mouse events? watchedEventsType: '', // Are mouse events being delivered to this content along with touch // events, in violation of spec? hybridEvents: false, init: function cp_init() { this._setupListenersForPanning(); }, _setupListenersForPanning: function cp_setupListenersForPanning() { let events; if (content.TouchEvent) { events = ['touchstart', 'touchend', 'touchmove']; this.watchedEventsType = 'touch'; #ifdef MOZ_WIDGET_GONK // The gonk widget backend does not deliver mouse events per // spec. Third-party content isn't exposed to this behavior, // but that behavior creates some extra work for us here. let appInfo = Cc["@mozilla.org/xre/app-info;1"]; let isParentProcess = !appInfo || appInfo.getService(Ci.nsIXULRuntime) .processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT; this.hybridEvents = isParentProcess; #endif } else { // Touch events aren't supported, so fall back on mouse. events = ['mousedown', 'mouseup', 'mousemove']; this.watchedEventsType = 'mouse'; } let els = Cc["@mozilla.org/eventlistenerservice;1"] .getService(Ci.nsIEventListenerService); events.forEach(function(type) { // Using the system group for mouse/touch events to avoid // missing events if .stopPropagation() has been called. els.addSystemEventListener(global, type, this.handleEvent.bind(this), /* useCapture = */ false); }.bind(this)); }, handleEvent: function cp_handleEvent(evt) { // Ignore events targeting an oop