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

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

Issue 2624783002: Fix movementX/Y attributes for touch pointer events (Closed)
Patch Set: Wrap ForwardTouchEventWithLatencyInfo to always reset points Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "core/events/PointerEventFactory.h" 5 #include "core/events/PointerEventFactory.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "platform/geometry/FloatSize.h" 8 #include "platform/geometry/FloatSize.h"
9 9
10 namespace blink { 10 namespace blink {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 FloatPoint pagePoint = 111 FloatPoint pagePoint =
112 targetFrame->view()->rootFrameToContents(touchPoint.position); 112 targetFrame->view()->rootFrameToContents(touchPoint.position);
113 float scaleFactor = 1.0f / targetFrame->pageZoomFactor(); 113 float scaleFactor = 1.0f / targetFrame->pageZoomFactor();
114 FloatPoint scrollPosition(targetFrame->view()->getScrollOffset()); 114 FloatPoint scrollPosition(targetFrame->view()->getScrollOffset());
115 FloatPoint clientPoint = pagePoint.scaledBy(scaleFactor); 115 FloatPoint clientPoint = pagePoint.scaledBy(scaleFactor);
116 clientPoint.moveBy(scrollPosition.scaledBy(-scaleFactor)); 116 clientPoint.moveBy(scrollPosition.scaledBy(-scaleFactor));
117 117
118 pointerEventInit->setClientX(clientPoint.x()); 118 pointerEventInit->setClientX(clientPoint.x());
119 pointerEventInit->setClientY(clientPoint.y()); 119 pointerEventInit->setClientY(clientPoint.y());
120 120
121 if (touchPoint.state == WebTouchPoint::StateMoved) {
122 pointerEventInit->setMovementX(touchPoint.movementX);
123 pointerEventInit->setMovementY(touchPoint.movementY);
124 }
125
121 FloatSize pointRadius = 126 FloatSize pointRadius =
122 FloatSize(touchPoint.radiusX, touchPoint.radiusY).scaledBy(scaleFactor); 127 FloatSize(touchPoint.radiusX, touchPoint.radiusY).scaledBy(scaleFactor);
123 pointerEventInit->setWidth(pointRadius.width()); 128 pointerEventInit->setWidth(pointRadius.width());
124 pointerEventInit->setHeight(pointRadius.height()); 129 pointerEventInit->setHeight(pointRadius.height());
125 } 130 }
126 131
127 pointerEventInit->setScreenX(touchPoint.screenPosition.x); 132 pointerEventInit->setScreenX(touchPoint.screenPosition.x);
128 pointerEventInit->setScreenY(touchPoint.screenPosition.y); 133 pointerEventInit->setScreenY(touchPoint.screenPosition.y);
129 pointerEventInit->setPressure( 134 pointerEventInit->setPressure(
130 getPointerEventPressure(touchPoint.force, pointerEventInit->buttons())); 135 getPointerEventPressure(touchPoint.force, pointerEventInit->buttons()));
(...skipping 26 matching lines...) Expand all
157 162
158 pointerEventInit->setClientX(locationInFrameZoomed.x()); 163 pointerEventInit->setClientX(locationInFrameZoomed.x());
159 pointerEventInit->setClientY(locationInFrameZoomed.y()); 164 pointerEventInit->setClientY(locationInFrameZoomed.y());
160 165
161 pointerEventInit->setPressure( 166 pointerEventInit->setPressure(
162 getPointerEventPressure(mouseEvent.force, pointerEventInit->buttons())); 167 getPointerEventPressure(mouseEvent.force, pointerEventInit->buttons()));
163 pointerEventInit->setTiltX(mouseEvent.tiltX); 168 pointerEventInit->setTiltX(mouseEvent.tiltX);
164 pointerEventInit->setTiltY(mouseEvent.tiltY); 169 pointerEventInit->setTiltY(mouseEvent.tiltY);
165 pointerEventInit->setTangentialPressure(mouseEvent.tangentialPressure); 170 pointerEventInit->setTangentialPressure(mouseEvent.tangentialPressure);
166 pointerEventInit->setTwist(mouseEvent.twist); 171 pointerEventInit->setTwist(mouseEvent.twist);
172
173 IntPoint movement = flooredIntPoint(mouseEvent.movementInRootFrame());
174 pointerEventInit->setMovementX(movement.x());
175 pointerEventInit->setMovementY(movement.y());
167 } 176 }
168 177
169 } // namespace 178 } // namespace
170 179
171 const int PointerEventFactory::s_invalidId = 0; 180 const int PointerEventFactory::s_invalidId = 0;
172 181
173 // Mouse id is 1 to behave the same as MS Edge for compatibility reasons. 182 // Mouse id is 1 to behave the same as MS Edge for compatibility reasons.
174 const int PointerEventFactory::s_mouseId = 1; 183 const int PointerEventFactory::s_mouseId = 1;
175 184
176 void PointerEventFactory::setIdTypeButtons( 185 void PointerEventFactory::setIdTypeButtons(
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 const WebPointerProperties& properties) const { 526 const WebPointerProperties& properties) const {
518 if (properties.pointerType == WebPointerProperties::PointerType::Mouse) 527 if (properties.pointerType == WebPointerProperties::PointerType::Mouse)
519 return PointerEventFactory::s_mouseId; 528 return PointerEventFactory::s_mouseId;
520 IncomingId id(properties.pointerType, properties.id); 529 IncomingId id(properties.pointerType, properties.id);
521 if (m_pointerIncomingIdMapping.contains(id)) 530 if (m_pointerIncomingIdMapping.contains(id))
522 return m_pointerIncomingIdMapping.get(id); 531 return m_pointerIncomingIdMapping.get(id);
523 return PointerEventFactory::s_invalidId; 532 return PointerEventFactory::s_invalidId;
524 } 533 }
525 534
526 } // namespace blink 535 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698