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

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

Issue 1964523002: Fix clientX/Y properties of touch pointer events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix zoom problem Created 4 years, 7 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 "platform/geometry/FloatSize.h" 7 #include "platform/geometry/FloatSize.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 pointerEventInit.setView(view); 126 pointerEventInit.setView(view);
127 if (relatedTarget) 127 if (relatedTarget)
128 pointerEventInit.setRelatedTarget(relatedTarget); 128 pointerEventInit.setRelatedTarget(relatedTarget);
129 129
130 return PointerEvent::create(pointerEventName, pointerEventInit); 130 return PointerEvent::create(pointerEventName, pointerEventInit);
131 } 131 }
132 132
133 PointerEvent* PointerEventFactory::create(const AtomicString& type, 133 PointerEvent* PointerEventFactory::create(const AtomicString& type,
134 const PlatformTouchPoint& touchPoint, PlatformEvent::Modifiers modifiers, 134 const PlatformTouchPoint& touchPoint, PlatformEvent::Modifiers modifiers,
135 const FloatSize& pointRadius, 135 const FloatSize& pointRadius,
136 const FloatPoint& pagePoint) 136 const FloatPoint& clientPoint)
137 { 137 {
138 const PlatformTouchPoint::TouchState pointState = touchPoint.state(); 138 const PlatformTouchPoint::TouchState pointState = touchPoint.state();
139 139
140 bool pointerReleasedOrCancelled = 140 bool pointerReleasedOrCancelled =
141 pointState == PlatformTouchPoint::TouchReleased 141 pointState == PlatformTouchPoint::TouchReleased
142 || pointState == PlatformTouchPoint::TouchCancelled; 142 || pointState == PlatformTouchPoint::TouchCancelled;
143 bool pointerPressedOrReleased = 143 bool pointerPressedOrReleased =
144 pointState == PlatformTouchPoint::TouchPressed 144 pointState == PlatformTouchPoint::TouchPressed
145 || pointState == PlatformTouchPoint::TouchReleased; 145 || pointState == PlatformTouchPoint::TouchReleased;
146 146
147 bool isEnterOrLeave = false; 147 bool isEnterOrLeave = false;
148 148
149 PointerEventInit pointerEventInit; 149 PointerEventInit pointerEventInit;
150 150
151 setIdTypeButtons(pointerEventInit, touchPoint.pointerProperties(), 151 setIdTypeButtons(pointerEventInit, touchPoint.pointerProperties(),
152 pointerReleasedOrCancelled ? 0 : 1); 152 pointerReleasedOrCancelled ? 0 : 1);
153 153
154 pointerEventInit.setWidth(pointRadius.width()); 154 pointerEventInit.setWidth(pointRadius.width());
155 pointerEventInit.setHeight(pointRadius.height()); 155 pointerEventInit.setHeight(pointRadius.height());
156 pointerEventInit.setTiltX(touchPoint.pointerProperties().tiltX); 156 pointerEventInit.setTiltX(touchPoint.pointerProperties().tiltX);
157 pointerEventInit.setTiltY(touchPoint.pointerProperties().tiltY); 157 pointerEventInit.setTiltY(touchPoint.pointerProperties().tiltY);
158 pointerEventInit.setScreenX(touchPoint.screenPos().x()); 158 pointerEventInit.setScreenX(touchPoint.screenPos().x());
159 pointerEventInit.setScreenY(touchPoint.screenPos().y()); 159 pointerEventInit.setScreenY(touchPoint.screenPos().y());
160 pointerEventInit.setClientX(pagePoint.x()); 160 pointerEventInit.setClientX(clientPoint.x());
161 pointerEventInit.setClientY(pagePoint.y()); 161 pointerEventInit.setClientY(clientPoint.y());
162 pointerEventInit.setButton(pointerPressedOrReleased ? LeftButton: NoButton); 162 pointerEventInit.setButton(pointerPressedOrReleased ? LeftButton: NoButton);
163 pointerEventInit.setPressure(getPointerEventPressure( 163 pointerEventInit.setPressure(getPointerEventPressure(
164 touchPoint.force(), pointerEventInit.buttons())); 164 touchPoint.force(), pointerEventInit.buttons()));
165 165
166 UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit, modifiers); 166 UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit, modifiers);
167 167
168 pointerEventInit.setBubbles(!isEnterOrLeave); 168 pointerEventInit.setBubbles(!isEnterOrLeave);
169 pointerEventInit.setCancelable(!isEnterOrLeave && pointState != PlatformTouc hPoint::TouchCancelled); 169 pointerEventInit.setCancelable(!isEnterOrLeave && pointState != PlatformTouc hPoint::TouchCancelled);
170 170
171 return PointerEvent::create(type, pointerEventInit); 171 return PointerEvent::create(type, pointerEventInit);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 if (properties.pointerType 363 if (properties.pointerType
364 == WebPointerProperties::PointerType::Mouse) 364 == WebPointerProperties::PointerType::Mouse)
365 return PointerEventFactory::s_mouseId; 365 return PointerEventFactory::s_mouseId;
366 IncomingId id(properties.pointerType, properties.id); 366 IncomingId id(properties.pointerType, properties.id);
367 if (m_pointerIncomingIdMapping.contains(id)) 367 if (m_pointerIncomingIdMapping.contains(id))
368 return m_pointerIncomingIdMapping.get(id); 368 return m_pointerIncomingIdMapping.get(id);
369 return PointerEventFactory::s_invalidId; 369 return PointerEventFactory::s_invalidId;
370 } 370 }
371 371
372 } // namespace blink 372 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698