Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/emulation/TouchModel.js

Issue 2819183002: [DevTools] Consolidate overlay-related functionality in Overlay domain (Closed)
Patch Set: rebased bad merge Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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'};
56 56
57 var domModel = target.model(SDK.DOMModel); 57 var overlayModel = target.model(SDK.OverlayModel);
58 var inspectModeEnabled = domModel ? domModel.inspectModeEnabled() : false; 58 var inspectModeEnabled = overlayModel ? overlayModel.inspectModeEnabled() : false;
59 if (inspectModeEnabled) 59 if (inspectModeEnabled)
60 current = {enabled: false, configuration: 'mobile'}; 60 current = {enabled: false, configuration: 'mobile'};
61 61
62 /** 62 /**
63 * @suppressGlobalPropertiesCheck 63 * @suppressGlobalPropertiesCheck
64 */ 64 */
65 const injectedFunction = function() { 65 const injectedFunction = function() {
66 const touchEvents = ['ontouchstart', 'ontouchend', 'ontouchmove', 'ontouch cancel']; 66 const touchEvents = ['ontouchstart', 'ontouchend', 'ontouchmove', 'ontouch cancel'];
67 var recepients = [window.__proto__, document.__proto__]; 67 var recepients = [window.__proto__, document.__proto__];
68 for (var i = 0; i < touchEvents.length; ++i) { 68 for (var i = 0; i < touchEvents.length; ++i) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 (target[symbol] || {}).scriptId = error ? '' : scriptId; 100 (target[symbol] || {}).scriptId = error ? '' : scriptId;
101 } 101 }
102 102
103 target.emulationAgent().setTouchEmulationEnabled(current.enabled, current.co nfiguration); 103 target.emulationAgent().setTouchEmulationEnabled(current.enabled, current.co nfiguration);
104 } 104 }
105 105
106 /** 106 /**
107 * @param {!Common.Event} event 107 * @param {!Common.Event} event
108 */ 108 */
109 _inspectModeToggled(event) { 109 _inspectModeToggled(event) {
110 var domModel = /** @type {!SDK.DOMModel} */ (event.data); 110 var overlayModel = /** @type {!SDK.OverlayModel} */ (event.data);
111 this._applyToTarget(domModel.target()); 111 this._applyToTarget(overlayModel.target());
112 } 112 }
113 113
114 /** 114 /**
115 * @override 115 * @override
116 * @param {!SDK.Target} target 116 * @param {!SDK.Target} target
117 */ 117 */
118 targetAdded(target) { 118 targetAdded(target) {
119 var domModel = target.model(SDK.DOMModel); 119 var overlayModel = target.model(SDK.OverlayModel);
120 if (domModel) 120 if (overlayModel)
121 domModel.addEventListener(SDK.DOMModel.Events.InspectModeWillBeToggled, th is._inspectModeToggled, this); 121 overlayModel.addEventListener(SDK.OverlayModel.Events.InspectModeWillBeTog gled, this._inspectModeToggled, this);
122 this._applyToTarget(target); 122 this._applyToTarget(target);
123 } 123 }
124 124
125 /** 125 /**
126 * @override 126 * @override
127 * @param {!SDK.Target} target 127 * @param {!SDK.Target} target
128 */ 128 */
129 targetRemoved(target) { 129 targetRemoved(target) {
130 var domModel = target.model(SDK.DOMModel); 130 var overlayModel = target.model(SDK.OverlayModel);
131 if (domModel) 131 if (overlayModel) {
132 domModel.removeEventListener(SDK.DOMModel.Events.InspectModeWillBeToggled, this._inspectModeToggled, this); 132 overlayModel.removeEventListener(
133 SDK.OverlayModel.Events.InspectModeWillBeToggled, this._inspectModeTog gled, this);
134 }
133 } 135 }
134 }; 136 };
135 137
136 Emulation.MultitargetTouchModel._symbol = Symbol('MultitargetTouchModel.symbol') ; 138 Emulation.MultitargetTouchModel._symbol = Symbol('MultitargetTouchModel.symbol') ;
137 139
138 /** @type {?Emulation.MultitargetTouchModel} */ 140 /** @type {?Emulation.MultitargetTouchModel} */
139 Emulation.MultitargetTouchModel._instance = null; 141 Emulation.MultitargetTouchModel._instance = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698