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