OLD | NEW |
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/frame/FrameHost.h" | 7 #include "core/frame/FrameHost.h" |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
10 #include "core/frame/VisualViewport.h" | 10 #include "core/frame/VisualViewport.h" |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 // compositor-side pinch handling is not enabled. See http://crbug.com/138003. | 489 // compositor-side pinch handling is not enabled. See http://crbug.com/138003. |
490 bool isPinch = inputEvent.type == WebInputEvent::GesturePinchBegin || | 490 bool isPinch = inputEvent.type == WebInputEvent::GesturePinchBegin || |
491 inputEvent.type == WebInputEvent::GesturePinchUpdate || | 491 inputEvent.type == WebInputEvent::GesturePinchUpdate || |
492 inputEvent.type == WebInputEvent::GesturePinchEnd; | 492 inputEvent.type == WebInputEvent::GesturePinchEnd; |
493 if (isPinch && m_touchEventEmulationEnabled) { | 493 if (isPinch && m_touchEventEmulationEnabled) { |
494 FrameView* frameView = page->deprecatedLocalMainFrame()->view(); | 494 FrameView* frameView = page->deprecatedLocalMainFrame()->view(); |
495 PlatformGestureEventBuilder gestureEvent( | 495 PlatformGestureEventBuilder gestureEvent( |
496 frameView, static_cast<const WebGestureEvent&>(inputEvent)); | 496 frameView, static_cast<const WebGestureEvent&>(inputEvent)); |
497 float pageScaleFactor = page->pageScaleFactor(); | 497 float pageScaleFactor = page->pageScaleFactor(); |
498 if (gestureEvent.type() == PlatformEvent::GesturePinchBegin) { | 498 if (gestureEvent.type() == PlatformEvent::GesturePinchBegin) { |
499 m_lastPinchAnchorCss = wrapUnique( | 499 m_lastPinchAnchorCss = wrapUnique(new IntPoint(roundedIntPoint( |
500 new IntPoint(frameView->scrollPosition() + gestureEvent.position())); | 500 gestureEvent.position() + frameView->scrollOffset()))); |
501 m_lastPinchAnchorDip = wrapUnique(new IntPoint(gestureEvent.position())); | 501 m_lastPinchAnchorDip = wrapUnique(new IntPoint(gestureEvent.position())); |
502 m_lastPinchAnchorDip->scale(pageScaleFactor, pageScaleFactor); | 502 m_lastPinchAnchorDip->scale(pageScaleFactor, pageScaleFactor); |
503 } | 503 } |
504 if (gestureEvent.type() == PlatformEvent::GesturePinchUpdate && | 504 if (gestureEvent.type() == PlatformEvent::GesturePinchUpdate && |
505 m_lastPinchAnchorCss) { | 505 m_lastPinchAnchorCss) { |
506 float newPageScaleFactor = pageScaleFactor * gestureEvent.scale(); | 506 float newPageScaleFactor = pageScaleFactor * gestureEvent.scale(); |
507 IntPoint anchorCss(*m_lastPinchAnchorDip.get()); | 507 IntPoint anchorCss(*m_lastPinchAnchorDip.get()); |
508 anchorCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor); | 508 anchorCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor); |
509 m_webViewImpl->setPageScaleFactor(newPageScaleFactor); | 509 m_webViewImpl->setPageScaleFactor(newPageScaleFactor); |
510 m_webViewImpl->mainFrame()->setScrollOffset( | 510 m_webViewImpl->mainFrame()->setScrollOffset( |
511 toIntSize(*m_lastPinchAnchorCss.get() - toIntSize(anchorCss))); | 511 toIntSize(*m_lastPinchAnchorCss.get() - toIntSize(anchorCss))); |
512 } | 512 } |
513 if (gestureEvent.type() == PlatformEvent::GesturePinchEnd) { | 513 if (gestureEvent.type() == PlatformEvent::GesturePinchEnd) { |
514 m_lastPinchAnchorCss.reset(); | 514 m_lastPinchAnchorCss.reset(); |
515 m_lastPinchAnchorDip.reset(); | 515 m_lastPinchAnchorDip.reset(); |
516 } | 516 } |
517 return true; | 517 return true; |
518 } | 518 } |
519 | 519 |
520 return false; | 520 return false; |
521 } | 521 } |
522 | 522 |
523 } // namespace blink | 523 } // namespace blink |
OLD | NEW |