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

Side by Side Diff: third_party/WebKit/Source/web/DevToolsEmulator.cpp

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Fix nits Created 3 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "web/DevToolsEmulator.h" 5 #include "web/DevToolsEmulator.h"
6 6
7 #include "core/fetch/MemoryCache.h" 7 #include "core/fetch/MemoryCache.h"
8 #include "core/frame/FrameHost.h" 8 #include "core/frame/FrameHost.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 m_scriptExecutionDisabled ? false : m_embedderScriptEnabled); 495 m_scriptExecutionDisabled ? false : m_embedderScriptEnabled);
496 } 496 }
497 497
498 bool DevToolsEmulator::handleInputEvent(const WebInputEvent& inputEvent) { 498 bool DevToolsEmulator::handleInputEvent(const WebInputEvent& inputEvent) {
499 Page* page = m_webViewImpl->page(); 499 Page* page = m_webViewImpl->page();
500 if (!page) 500 if (!page)
501 return false; 501 return false;
502 502
503 // FIXME: This workaround is required for touch emulation on Mac, where 503 // FIXME: This workaround is required for touch emulation on Mac, where
504 // compositor-side pinch handling is not enabled. See http://crbug.com/138003. 504 // compositor-side pinch handling is not enabled. See http://crbug.com/138003.
505 bool isPinch = inputEvent.type == WebInputEvent::GesturePinchBegin || 505 bool isPinch = inputEvent.type() == WebInputEvent::GesturePinchBegin ||
506 inputEvent.type == WebInputEvent::GesturePinchUpdate || 506 inputEvent.type() == WebInputEvent::GesturePinchUpdate ||
507 inputEvent.type == WebInputEvent::GesturePinchEnd; 507 inputEvent.type() == WebInputEvent::GesturePinchEnd;
508 if (isPinch && m_touchEventEmulationEnabled) { 508 if (isPinch && m_touchEventEmulationEnabled) {
509 FrameView* frameView = page->deprecatedLocalMainFrame()->view(); 509 FrameView* frameView = page->deprecatedLocalMainFrame()->view();
510 WebGestureEvent scaledEvent = TransformWebGestureEvent( 510 WebGestureEvent scaledEvent = TransformWebGestureEvent(
511 frameView, static_cast<const WebGestureEvent&>(inputEvent)); 511 frameView, static_cast<const WebGestureEvent&>(inputEvent));
512 float pageScaleFactor = page->pageScaleFactor(); 512 float pageScaleFactor = page->pageScaleFactor();
513 if (scaledEvent.type == WebInputEvent::GesturePinchBegin) { 513 if (scaledEvent.type() == WebInputEvent::GesturePinchBegin) {
514 WebFloatPoint gesturePosition = scaledEvent.positionInRootFrame(); 514 WebFloatPoint gesturePosition = scaledEvent.positionInRootFrame();
515 m_lastPinchAnchorCss = WTF::wrapUnique(new IntPoint( 515 m_lastPinchAnchorCss = WTF::wrapUnique(new IntPoint(
516 roundedIntPoint(gesturePosition + frameView->getScrollOffset()))); 516 roundedIntPoint(gesturePosition + frameView->getScrollOffset())));
517 m_lastPinchAnchorDip = 517 m_lastPinchAnchorDip =
518 WTF::wrapUnique(new IntPoint(flooredIntPoint(gesturePosition))); 518 WTF::wrapUnique(new IntPoint(flooredIntPoint(gesturePosition)));
519 m_lastPinchAnchorDip->scale(pageScaleFactor, pageScaleFactor); 519 m_lastPinchAnchorDip->scale(pageScaleFactor, pageScaleFactor);
520 } 520 }
521 if (scaledEvent.type == WebInputEvent::GesturePinchUpdate && 521 if (scaledEvent.type() == WebInputEvent::GesturePinchUpdate &&
522 m_lastPinchAnchorCss) { 522 m_lastPinchAnchorCss) {
523 float newPageScaleFactor = pageScaleFactor * scaledEvent.pinchScale(); 523 float newPageScaleFactor = pageScaleFactor * scaledEvent.pinchScale();
524 IntPoint anchorCss(*m_lastPinchAnchorDip.get()); 524 IntPoint anchorCss(*m_lastPinchAnchorDip.get());
525 anchorCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor); 525 anchorCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor);
526 m_webViewImpl->setPageScaleFactor(newPageScaleFactor); 526 m_webViewImpl->setPageScaleFactor(newPageScaleFactor);
527 m_webViewImpl->mainFrame()->setScrollOffset( 527 m_webViewImpl->mainFrame()->setScrollOffset(
528 toIntSize(*m_lastPinchAnchorCss.get() - toIntSize(anchorCss))); 528 toIntSize(*m_lastPinchAnchorCss.get() - toIntSize(anchorCss)));
529 } 529 }
530 if (scaledEvent.type == WebInputEvent::GesturePinchEnd) { 530 if (scaledEvent.type() == WebInputEvent::GesturePinchEnd) {
531 m_lastPinchAnchorCss.reset(); 531 m_lastPinchAnchorCss.reset();
532 m_lastPinchAnchorDip.reset(); 532 m_lastPinchAnchorDip.reset();
533 } 533 }
534 return true; 534 return true;
535 } 535 }
536 536
537 return false; 537 return false;
538 } 538 }
539 539
540 } // namespace blink 540 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ChromeClientImpl.cpp ('k') | third_party/WebKit/Source/web/ExternalPopupMenu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698