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

Side by Side Diff: Source/core/inspector/InspectorPageAgent.cpp

Issue 376873004: [DevTools] Allow touch emulation on devices with native touch. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 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 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 } 1330 }
1331 1331
1332 void InspectorPageAgent::updateTouchEventEmulationInPage(bool enabled) 1332 void InspectorPageAgent::updateTouchEventEmulationInPage(bool enabled)
1333 { 1333 {
1334 if (!m_touchEmulationEnabled) { 1334 if (!m_touchEmulationEnabled) {
1335 m_originalTouchEnabled = RuntimeEnabledFeatures::touchEnabled(); 1335 m_originalTouchEnabled = RuntimeEnabledFeatures::touchEnabled();
1336 m_originalDeviceSupportsMouse = m_page->settings().deviceSupportsMouse() ; 1336 m_originalDeviceSupportsMouse = m_page->settings().deviceSupportsMouse() ;
1337 m_originalDeviceSupportsTouch = m_page->settings().deviceSupportsTouch() ; 1337 m_originalDeviceSupportsTouch = m_page->settings().deviceSupportsTouch() ;
1338 } 1338 }
1339 RuntimeEnabledFeatures::setTouchEnabled(enabled ? true : m_originalTouchEnab led); 1339 RuntimeEnabledFeatures::setTouchEnabled(enabled ? true : m_originalTouchEnab led);
1340 m_page->settings().setDeviceSupportsMouse(enabled ? false : m_originalDevice SupportsMouse); 1340 if (!m_originalDeviceSupportsTouch) {
1341 m_page->settings().setDeviceSupportsTouch(enabled ? true : m_originalDeviceS upportsTouch); 1341 m_page->settings().setDeviceSupportsMouse(enabled ? false : m_originalDe viceSupportsMouse);
1342 m_page->settings().setDeviceSupportsTouch(enabled ? true : m_originalDev iceSupportsTouch);
1343 }
1342 m_touchEmulationEnabled = enabled; 1344 m_touchEmulationEnabled = enabled;
1343 m_client->setTouchEventEmulationEnabled(enabled); 1345 m_client->setTouchEventEmulationEnabled(enabled);
1344 m_page->deprecatedLocalMainFrame()->view()->layout(); 1346 m_page->deprecatedLocalMainFrame()->view()->layout();
1345 } 1347 }
1346 1348
1347 void InspectorPageAgent::hasTouchInputs(ErrorString*, bool* result) 1349 void InspectorPageAgent::setTouchEmulationEnabled(ErrorString*, bool enabled)
1348 {
1349 *result = m_touchEmulationEnabled ? m_originalDeviceSupportsTouch : m_page-> settings().deviceSupportsTouch();
1350 }
1351
1352 void InspectorPageAgent::setTouchEmulationEnabled(ErrorString* error, bool enabl ed)
1353 { 1350 {
1354 if (m_state->getBoolean(PageAgentState::touchEventEmulationEnabled) == enabl ed) 1351 if (m_state->getBoolean(PageAgentState::touchEventEmulationEnabled) == enabl ed)
1355 return; 1352 return;
1356 1353
1357 bool hasTouch = false;
1358 hasTouchInputs(error, &hasTouch);
1359 if (enabled && hasTouch) {
1360 if (error)
1361 *error = "Device already supports touch input";
1362 return;
1363 }
1364
1365 m_state->setBoolean(PageAgentState::touchEventEmulationEnabled, enabled); 1354 m_state->setBoolean(PageAgentState::touchEventEmulationEnabled, enabled);
1366 updateTouchEventEmulationInPage(enabled); 1355 updateTouchEventEmulationInPage(enabled);
1367 } 1356 }
1368 1357
1369 void InspectorPageAgent::setEmulatedMedia(ErrorString*, const String& media) 1358 void InspectorPageAgent::setEmulatedMedia(ErrorString*, const String& media)
1370 { 1359 {
1371 String currentMedia = m_state->getString(PageAgentState::pageAgentEmulatedMe dia); 1360 String currentMedia = m_state->getString(PageAgentState::pageAgentEmulatedMe dia);
1372 if (media == currentMedia) 1361 if (media == currentMedia)
1373 return; 1362 return;
1374 1363
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 } 1427 }
1439 1428
1440 void InspectorPageAgent::trace(Visitor* visitor) 1429 void InspectorPageAgent::trace(Visitor* visitor)
1441 { 1430 {
1442 visitor->trace(m_page); 1431 visitor->trace(m_page);
1443 InspectorBaseAgent::trace(visitor); 1432 InspectorBaseAgent::trace(visitor);
1444 } 1433 }
1445 1434
1446 } // namespace blink 1435 } // namespace blink
1447 1436
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorPageAgent.h ('k') | Source/devtools/front_end/main/OverridesView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698