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

Side by Side Diff: Source/web/WebDevToolsAgentImpl.cpp

Issue 243233002: [DevTools] Disable touch emulation on devices with touch input. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 /* 1 /*
2 * Copyright (C) 2010-2011 Google Inc. All rights reserved. 2 * Copyright (C) 2010-2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 , m_webViewImpl(webViewImpl) 202 , m_webViewImpl(webViewImpl)
203 , m_attached(false) 203 , m_attached(false)
204 , m_generatingEvent(false) 204 , m_generatingEvent(false)
205 , m_deviceMetricsEnabled(false) 205 , m_deviceMetricsEnabled(false)
206 , m_emulateViewportEnabled(false) 206 , m_emulateViewportEnabled(false)
207 , m_originalViewportEnabled(false) 207 , m_originalViewportEnabled(false)
208 , m_isOverlayScrollbarsEnabled(false) 208 , m_isOverlayScrollbarsEnabled(false)
209 , m_touchEventEmulationEnabled(false) 209 , m_touchEventEmulationEnabled(false)
210 , m_originalTouchEnabled(false) 210 , m_originalTouchEnabled(false)
211 , m_originalDeviceSupportsMouse(false) 211 , m_originalDeviceSupportsMouse(false)
212 , m_originalDeviceSupportsTouch(false)
212 { 213 {
213 ASSERT(m_hostId > 0); 214 ASSERT(m_hostId > 0);
214 ClientMessageLoopAdapter::ensureClientMessageLoopCreated(m_client); 215 ClientMessageLoopAdapter::ensureClientMessageLoopCreated(m_client);
215 } 216 }
216 217
217 WebDevToolsAgentImpl::~WebDevToolsAgentImpl() 218 WebDevToolsAgentImpl::~WebDevToolsAgentImpl()
218 { 219 {
219 ClientMessageLoopAdapter::inspectedViewClosed(m_webViewImpl); 220 ClientMessageLoopAdapter::inspectedViewClosed(m_webViewImpl);
220 if (m_attached) 221 if (m_attached)
221 blink::Platform::current()->currentThread()->removeTaskObserver(this); 222 blink::Platform::current()->currentThread()->removeTaskObserver(this);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 } 383 }
383 } 384 }
384 385
385 void WebDevToolsAgentImpl::setTouchEventEmulationEnabled(bool enabled) 386 void WebDevToolsAgentImpl::setTouchEventEmulationEnabled(bool enabled)
386 { 387 {
387 if (m_touchEventEmulationEnabled == enabled) 388 if (m_touchEventEmulationEnabled == enabled)
388 return; 389 return;
389 390
390 if (!m_touchEventEmulationEnabled) { 391 if (!m_touchEventEmulationEnabled) {
391 m_originalTouchEnabled = RuntimeEnabledFeatures::touchEnabled(); 392 m_originalTouchEnabled = RuntimeEnabledFeatures::touchEnabled();
392 if (m_webViewImpl->page()) 393 if (m_webViewImpl->page()) {
393 m_originalDeviceSupportsMouse = m_webViewImpl->page()->settings().de viceSupportsMouse(); 394 m_originalDeviceSupportsMouse = m_webViewImpl->page()->settings().de viceSupportsMouse();
395 m_originalDeviceSupportsTouch = m_webViewImpl->page()->settings().de viceSupportsTouch();
396 }
394 } 397 }
395 RuntimeEnabledFeatures::setTouchEnabled(enabled ? true : m_originalTouchEnab led); 398 RuntimeEnabledFeatures::setTouchEnabled(enabled ? true : m_originalTouchEnab led);
396 if (m_webViewImpl->page()) 399 if (m_webViewImpl->page()) {
397 m_webViewImpl->page()->settings().setDeviceSupportsMouse(enabled ? false : m_originalDeviceSupportsMouse); 400 m_webViewImpl->page()->settings().setDeviceSupportsMouse(enabled ? false : m_originalDeviceSupportsMouse);
401 m_webViewImpl->page()->settings().setDeviceSupportsTouch(enabled ? true : m_originalDeviceSupportsTouch);
402 }
398 m_client->setTouchEventEmulationEnabled(enabled, m_emulateViewportEnabled); 403 m_client->setTouchEventEmulationEnabled(enabled, m_emulateViewportEnabled);
399 m_touchEventEmulationEnabled = enabled; 404 m_touchEventEmulationEnabled = enabled;
400 m_webViewImpl->mainFrameImpl()->frame()->view()->layout(); 405 m_webViewImpl->mainFrameImpl()->frame()->view()->layout();
401 } 406 }
402 407
408 bool WebDevToolsAgentImpl::hasTouchInputs()
409 {
410 return m_touchEventEmulationEnabled ? m_originalDeviceSupportsTouch :
411 (m_webViewImpl->page() ? m_webViewImpl->page()->settings().deviceSupport sTouch() : false);
412 }
413
403 void WebDevToolsAgentImpl::enableViewportEmulation() 414 void WebDevToolsAgentImpl::enableViewportEmulation()
404 { 415 {
405 if (m_emulateViewportEnabled) 416 if (m_emulateViewportEnabled)
406 return; 417 return;
407 m_emulateViewportEnabled = true; 418 m_emulateViewportEnabled = true;
408 m_isOverlayScrollbarsEnabled = RuntimeEnabledFeatures::overlayScrollbarsEnab led(); 419 m_isOverlayScrollbarsEnabled = RuntimeEnabledFeatures::overlayScrollbarsEnab led();
409 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); 420 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true);
410 m_originalViewportEnabled = RuntimeEnabledFeatures::cssViewportEnabled(); 421 m_originalViewportEnabled = RuntimeEnabledFeatures::cssViewportEnabled();
411 RuntimeEnabledFeatures::setCSSViewportEnabled(true); 422 RuntimeEnabledFeatures::setCSSViewportEnabled(true);
412 m_webViewImpl->settings()->setViewportEnabled(true); 423 m_webViewImpl->settings()->setViewportEnabled(true);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke ndDispatcher::kDebugger_removeBreakpointCmd) 730 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke ndDispatcher::kDebugger_removeBreakpointCmd)
720 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke ndDispatcher::kDebugger_setBreakpointsActiveCmd); 731 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke ndDispatcher::kDebugger_setBreakpointsActiveCmd);
721 } 732 }
722 733
723 void WebDevToolsAgent::processPendingMessages() 734 void WebDevToolsAgent::processPendingMessages()
724 { 735 {
725 PageScriptDebugServer::shared().runPendingTasks(); 736 PageScriptDebugServer::shared().runPendingTasks();
726 } 737 }
727 738
728 } // namespace blink 739 } // namespace blink
OLDNEW
« Source/devtools/front_end/Target.js ('K') | « Source/web/WebDevToolsAgentImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698