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

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

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

Powered by Google App Engine
This is Rietveld 408576698