| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @implements {SDK.TargetManager.Observer} | 5 * @implements {SDK.TargetManager.Observer} |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 Emulation.MultitargetTouchModel = class { | 8 Emulation.MultitargetTouchModel = class { |
| 9 constructor() { | 9 constructor() { |
| 10 this._touchEnabled = false; | 10 this._touchEnabled = false; |
| 11 this._touchMobile = false; | 11 this._touchMobile = false; |
| 12 this._customTouchEnabled = false; | 12 this._customTouchEnabled = false; |
| 13 | 13 |
| 14 SDK.targetManager.observeTargets(this, SDK.Target.Capability.Browser); | 14 SDK.targetManager.observeTargets(this, SDK.Target.Capability.TouchEmulation)
; |
| 15 } | 15 } |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * @return {!Emulation.MultitargetTouchModel} | 18 * @return {!Emulation.MultitargetTouchModel} |
| 19 */ | 19 */ |
| 20 static instance() { | 20 static instance() { |
| 21 if (!Emulation.MultitargetTouchModel._instance) | 21 if (!Emulation.MultitargetTouchModel._instance) |
| 22 Emulation.MultitargetTouchModel._instance = new Emulation.MultitargetTouch
Model(); | 22 Emulation.MultitargetTouchModel._instance = new Emulation.MultitargetTouch
Model(); |
| 23 return /** @type {!Emulation.MultitargetTouchModel} */ (Emulation.Multitarge
tTouchModel._instance); | 23 return /** @type {!Emulation.MultitargetTouchModel} */ (Emulation.Multitarge
tTouchModel._instance); |
| 24 } | 24 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * @param {boolean} enabled | 37 * @param {boolean} enabled |
| 38 */ | 38 */ |
| 39 setCustomTouchEnabled(enabled) { | 39 setCustomTouchEnabled(enabled) { |
| 40 this._customTouchEnabled = enabled; | 40 this._customTouchEnabled = enabled; |
| 41 this._updateAllTargets(); | 41 this._updateAllTargets(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 _updateAllTargets() { | 44 _updateAllTargets() { |
| 45 for (var target of SDK.targetManager.targets(SDK.Target.Capability.Browser)) | 45 for (var target of SDK.targetManager.targets(SDK.Target.Capability.TouchEmul
ation)) |
| 46 this._applyToTarget(target); | 46 this._applyToTarget(target); |
| 47 } | 47 } |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * @param {!SDK.Target} target | 50 * @param {!SDK.Target} target |
| 51 */ | 51 */ |
| 52 _applyToTarget(target) { | 52 _applyToTarget(target) { |
| 53 var current = {enabled: this._touchEnabled, configuration: this._touchMobile
? 'mobile' : 'desktop'}; | 53 var current = {enabled: this._touchEnabled, configuration: this._touchMobile
? 'mobile' : 'desktop'}; |
| 54 if (this._customTouchEnabled) | 54 if (this._customTouchEnabled) |
| 55 current = {enabled: true, configuration: 'mobile'}; | 55 current = {enabled: true, configuration: 'mobile'}; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 var domModel = SDK.DOMModel.fromTarget(target); | 130 var domModel = SDK.DOMModel.fromTarget(target); |
| 131 if (domModel) | 131 if (domModel) |
| 132 domModel.removeEventListener(SDK.DOMModel.Events.InspectModeWillBeToggled,
this._inspectModeToggled, this); | 132 domModel.removeEventListener(SDK.DOMModel.Events.InspectModeWillBeToggled,
this._inspectModeToggled, this); |
| 133 } | 133 } |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 Emulation.MultitargetTouchModel._symbol = Symbol('MultitargetTouchModel.symbol')
; | 136 Emulation.MultitargetTouchModel._symbol = Symbol('MultitargetTouchModel.symbol')
; |
| 137 | 137 |
| 138 /** @type {?Emulation.MultitargetTouchModel} */ | 138 /** @type {?Emulation.MultitargetTouchModel} */ |
| 139 Emulation.MultitargetTouchModel._instance = null; | 139 Emulation.MultitargetTouchModel._instance = null; |
| OLD | NEW |