Index: third_party/WebKit/Source/devtools/front_end/emulation/TouchModel.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/emulation/TouchModel.js b/third_party/WebKit/Source/devtools/front_end/emulation/TouchModel.js |
deleted file mode 100644 |
index 883ccf642fe3f473091f55078165b7925ed87486..0000000000000000000000000000000000000000 |
--- a/third_party/WebKit/Source/devtools/front_end/emulation/TouchModel.js |
+++ /dev/null |
@@ -1,141 +0,0 @@ |
-// Copyright 2016 The Chromium Authors. All rights reserved. |
-// Use of this source code is governed by a BSD-style license that can be |
-// found in the LICENSE file. |
-/** |
- * @implements {SDK.TargetManager.Observer} |
- * @unrestricted |
- */ |
-Emulation.MultitargetTouchModel = class { |
- constructor() { |
- this._touchEnabled = false; |
- this._touchMobile = false; |
- this._customTouchEnabled = false; |
- |
- SDK.targetManager.observeTargets(this, SDK.Target.Capability.TouchEmulation); |
- } |
- |
- /** |
- * @return {!Emulation.MultitargetTouchModel} |
- */ |
- static instance() { |
- if (!Emulation.MultitargetTouchModel._instance) |
- Emulation.MultitargetTouchModel._instance = new Emulation.MultitargetTouchModel(); |
- return /** @type {!Emulation.MultitargetTouchModel} */ (Emulation.MultitargetTouchModel._instance); |
- } |
- |
- /** |
- * @param {boolean} enabled |
- * @param {boolean} mobile |
- */ |
- setTouchEnabled(enabled, mobile) { |
- this._touchEnabled = enabled; |
- this._touchMobile = mobile; |
- this._updateAllTargets(); |
- } |
- |
- /** |
- * @param {boolean} enabled |
- */ |
- setCustomTouchEnabled(enabled) { |
- this._customTouchEnabled = enabled; |
- this._updateAllTargets(); |
- } |
- |
- _updateAllTargets() { |
- for (var target of SDK.targetManager.targets(SDK.Target.Capability.TouchEmulation)) |
- this._applyToTarget(target); |
- } |
- |
- /** |
- * @param {!SDK.Target} target |
- */ |
- _applyToTarget(target) { |
- var current = {enabled: this._touchEnabled, configuration: this._touchMobile ? 'mobile' : 'desktop'}; |
- if (this._customTouchEnabled) |
- current = {enabled: true, configuration: 'mobile'}; |
- |
- var overlayModel = target.model(SDK.OverlayModel); |
- var inspectModeEnabled = overlayModel ? overlayModel.inspectModeEnabled() : false; |
- if (inspectModeEnabled) |
- current = {enabled: false, configuration: 'mobile'}; |
- |
- /** |
- * @suppressGlobalPropertiesCheck |
- */ |
- const injectedFunction = function() { |
- const touchEvents = ['ontouchstart', 'ontouchend', 'ontouchmove', 'ontouchcancel']; |
- var recepients = [window.__proto__, document.__proto__]; |
- for (var i = 0; i < touchEvents.length; ++i) { |
- for (var j = 0; j < recepients.length; ++j) { |
- if (!(touchEvents[i] in recepients[j])) { |
- Object.defineProperty( |
- recepients[j], touchEvents[i], {value: null, writable: true, configurable: true, enumerable: true}); |
- } |
- } |
- } |
- }; |
- |
- var symbol = Emulation.MultitargetTouchModel._symbol; |
- var previous = target[symbol] || {enabled: false, configuration: 'mobile', scriptId: ''}; |
- |
- if (previous.enabled === current.enabled && (!current.enabled || previous.configuration === current.configuration)) |
- return; |
- |
- if (previous.scriptId) { |
- target.pageAgent().removeScriptToEvaluateOnLoad(previous.scriptId); |
- target[symbol].scriptId = ''; |
- } |
- |
- target[symbol] = current; |
- target[symbol].scriptId = ''; |
- |
- if (current.enabled) |
- target.pageAgent().addScriptToEvaluateOnLoad('(' + injectedFunction.toString() + ')()', scriptAddedCallback); |
- |
- /** |
- * @param {?Protocol.Error} error |
- * @param {string} scriptId |
- */ |
- function scriptAddedCallback(error, scriptId) { |
- (target[symbol] || {}).scriptId = error ? '' : scriptId; |
- } |
- |
- target.emulationAgent().setTouchEmulationEnabled(current.enabled, current.configuration); |
- } |
- |
- /** |
- * @param {!Common.Event} event |
- */ |
- _inspectModeToggled(event) { |
- var overlayModel = /** @type {!SDK.OverlayModel} */ (event.data); |
- this._applyToTarget(overlayModel.target()); |
- } |
- |
- /** |
- * @override |
- * @param {!SDK.Target} target |
- */ |
- targetAdded(target) { |
- var overlayModel = target.model(SDK.OverlayModel); |
- if (overlayModel) |
- overlayModel.addEventListener(SDK.OverlayModel.Events.InspectModeWillBeToggled, this._inspectModeToggled, this); |
- this._applyToTarget(target); |
- } |
- |
- /** |
- * @override |
- * @param {!SDK.Target} target |
- */ |
- targetRemoved(target) { |
- var overlayModel = target.model(SDK.OverlayModel); |
- if (overlayModel) { |
- overlayModel.removeEventListener( |
- SDK.OverlayModel.Events.InspectModeWillBeToggled, this._inspectModeToggled, this); |
- } |
- } |
-}; |
- |
-Emulation.MultitargetTouchModel._symbol = Symbol('MultitargetTouchModel.symbol'); |
- |
-/** @type {?Emulation.MultitargetTouchModel} */ |
-Emulation.MultitargetTouchModel._instance = null; |