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

Side by Side Diff: third_party/WebKit/Source/core/events/MouseRelatedEvent.cpp

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: 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 /* 1 /*
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 cancelable, 67 cancelable,
68 abstractView, 68 abstractView,
69 detail, 69 detail,
70 modifiers, 70 modifiers,
71 platformTimeStamp, 71 platformTimeStamp,
72 sourceCapabilities), 72 sourceCapabilities),
73 m_screenLocation(screenLocation), 73 m_screenLocation(screenLocation),
74 m_movementDelta(movementDelta), 74 m_movementDelta(movementDelta),
75 m_positionType(positionType) { 75 m_positionType(positionType) {
76 LayoutPoint adjustedPageLocation; 76 LayoutPoint adjustedPageLocation;
77 LayoutPoint scrollPosition; 77 LayoutPoint scrollOffset;
bokan 2016/10/02 19:47:50 Make this LayoutSize to avoid casts below.
szager1 2016/10/05 07:43:36 Done.
78 78
79 LocalFrame* frame = view() && view()->isLocalDOMWindow() 79 LocalFrame* frame = view() && view()->isLocalDOMWindow()
80 ? toLocalDOMWindow(view())->frame() 80 ? toLocalDOMWindow(view())->frame()
81 : nullptr; 81 : nullptr;
82 if (frame && hasPosition()) { 82 if (frame && hasPosition()) {
83 if (FrameView* frameView = frame->view()) { 83 if (FrameView* frameView = frame->view()) {
84 scrollPosition = frameView->scrollPosition(); 84 scrollOffset = LayoutPoint(LayoutSize(frameView->scrollOffsetInt()));
85 adjustedPageLocation = frameView->rootFrameToContents(rootFrameLocation); 85 adjustedPageLocation = frameView->rootFrameToContents(rootFrameLocation);
86 float scaleFactor = 1 / frame->pageZoomFactor(); 86 float scaleFactor = 1 / frame->pageZoomFactor();
87 if (scaleFactor != 1.0f) { 87 if (scaleFactor != 1.0f) {
88 adjustedPageLocation.scale(scaleFactor, scaleFactor); 88 adjustedPageLocation.scale(scaleFactor, scaleFactor);
89 scrollPosition.scale(scaleFactor, scaleFactor); 89 scrollOffset.scale(scaleFactor, scaleFactor);
90 } 90 }
91 } 91 }
92 } 92 }
93 93
94 m_clientLocation = adjustedPageLocation - toLayoutSize(scrollPosition); 94 m_clientLocation = adjustedPageLocation - toLayoutSize(scrollOffset);
95 m_pageLocation = adjustedPageLocation; 95 m_pageLocation = adjustedPageLocation;
96 96
97 // Set up initial values for coordinates. 97 // Set up initial values for coordinates.
98 // Correct values are computed lazily, see computeRelativePosition. 98 // Correct values are computed lazily, see computeRelativePosition.
99 m_layerLocation = m_pageLocation; 99 m_layerLocation = m_pageLocation;
100 m_offsetLocation = m_pageLocation; 100 m_offsetLocation = m_pageLocation;
101 101
102 computePageLocation(); 102 computePageLocation();
103 m_hasCachedRelativePosition = false; 103 m_hasCachedRelativePosition = false;
104 } 104 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // FIXME: This is not correct. 255 // FIXME: This is not correct.
256 // See Microsoft documentation and <http://www.quirksmode.org/dom/w3c_events.h tml>. 256 // See Microsoft documentation and <http://www.quirksmode.org/dom/w3c_events.h tml>.
257 return m_clientLocation.y().toInt(); 257 return m_clientLocation.y().toInt();
258 } 258 }
259 259
260 DEFINE_TRACE(MouseRelatedEvent) { 260 DEFINE_TRACE(MouseRelatedEvent) {
261 UIEventWithKeyState::trace(visitor); 261 UIEventWithKeyState::trace(visitor);
262 } 262 }
263 263
264 } // namespace blink 264 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698