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

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

Issue 2782893002: WebMouseEvent coordinates are now fractional & private (Closed)
Patch Set: Fixed compile failures. Created 3 years, 8 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 webEvent.setTimeStampSeconds(event.platformTimeStamp().InSeconds()); 102 webEvent.setTimeStampSeconds(event.platformTimeStamp().InSeconds());
103 webEvent.setModifiers(event.modifiers()); 103 webEvent.setModifiers(event.modifiers());
104 104
105 FrameView* view = frameViewBase ? toFrameView(frameViewBase->parent()) : 0; 105 FrameView* view = frameViewBase ? toFrameView(frameViewBase->parent()) : 0;
106 // TODO(bokan): If view == nullptr, pointInRootFrame will really be 106 // TODO(bokan): If view == nullptr, pointInRootFrame will really be
107 // pointInRootContent. 107 // pointInRootContent.
108 IntPoint pointInRootFrame(event.absoluteLocation().x(), 108 IntPoint pointInRootFrame(event.absoluteLocation().x(),
109 event.absoluteLocation().y()); 109 event.absoluteLocation().y());
110 if (view) 110 if (view)
111 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); 111 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame);
112 webEvent.globalX = event.screenX(); 112 webEvent.screenPosition.x = event.screenX();
113 webEvent.globalY = event.screenY(); 113 webEvent.screenPosition.y = event.screenY();
114 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt( 114 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt(
115 event.absoluteLocation(), layoutItem); 115 event.absoluteLocation(), layoutItem);
116 webEvent.x = localPoint.x(); 116 webEvent.position.x = localPoint.x();
117 webEvent.y = localPoint.y(); 117 webEvent.position.y = localPoint.y();
118 } 118 }
119 119
120 unsigned toWebInputEventModifierFrom(WebMouseEvent::Button button) { 120 unsigned toWebInputEventModifierFrom(WebMouseEvent::Button button) {
121 if (button == WebMouseEvent::Button::NoButton) 121 if (button == WebMouseEvent::Button::NoButton)
122 return 0; 122 return 0;
123 123
124 unsigned webMouseButtonToPlatformModifier[] = { 124 unsigned webMouseButtonToPlatformModifier[] = {
125 WebInputEvent::LeftButtonDown, WebInputEvent::MiddleButtonDown, 125 WebInputEvent::LeftButtonDown, WebInputEvent::MiddleButtonDown,
126 WebInputEvent::RightButtonDown}; 126 WebInputEvent::RightButtonDown};
127 127
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 WebMouseEventBuilder::WebMouseEventBuilder(const FrameViewBase* frameViewBase, 192 WebMouseEventBuilder::WebMouseEventBuilder(const FrameViewBase* frameViewBase,
193 const LayoutItem layoutItem, 193 const LayoutItem layoutItem,
194 const MouseEvent& event) { 194 const MouseEvent& event) {
195 if (event.nativeEvent()) { 195 if (event.nativeEvent()) {
196 *static_cast<WebMouseEvent*>(this) = 196 *static_cast<WebMouseEvent*>(this) =
197 event.nativeEvent()->flattenTransform(); 197 event.nativeEvent()->flattenTransform();
198 WebFloatPoint absoluteRootFrameLocation = positionInRootFrame(); 198 WebFloatPoint absoluteRootFrameLocation = positionInRootFrame();
199 IntPoint localPoint = roundedIntPoint( 199 IntPoint localPoint = roundedIntPoint(
200 layoutItem.absoluteToLocal(absoluteRootFrameLocation, UseTransforms)); 200 layoutItem.absoluteToLocal(absoluteRootFrameLocation, UseTransforms));
201 x = localPoint.x(); 201 position.x = localPoint.x();
202 y = localPoint.y(); 202 position.y = localPoint.y();
203 return; 203 return;
204 } 204 }
205 205
206 // Code below here can be removed once OOPIF ships. 206 // Code below here can be removed once OOPIF ships.
207 // OOPIF will prevent synthetic events being dispatched into 207 // OOPIF will prevent synthetic events being dispatched into
208 // other frames; but for now we allow the fallback to generate 208 // other frames; but for now we allow the fallback to generate
209 // WebMouseEvents from synthetic events. 209 // WebMouseEvents from synthetic events.
210 if (event.type() == EventTypeNames::mousemove) 210 if (event.type() == EventTypeNames::mousemove)
211 m_type = WebInputEvent::MouseMove; 211 m_type = WebInputEvent::MouseMove;
212 else if (event.type() == EventTypeNames::mouseout) 212 else if (event.type() == EventTypeNames::mouseout)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 // The mouse event co-ordinates should be generated from the co-ordinates of 296 // The mouse event co-ordinates should be generated from the co-ordinates of
297 // the touch point. 297 // the touch point.
298 FrameView* view = toFrameView(frameViewBase->parent()); 298 FrameView* view = toFrameView(frameViewBase->parent());
299 // FIXME: if view == nullptr, pointInRootFrame will really be 299 // FIXME: if view == nullptr, pointInRootFrame will really be
300 // pointInRootContent. 300 // pointInRootContent.
301 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation()); 301 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation());
302 if (view) 302 if (view)
303 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); 303 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame);
304 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); 304 IntPoint screenPoint = roundedIntPoint(touch->screenLocation());
305 globalX = screenPoint.x(); 305 screenPosition.x = screenPoint.x();
306 globalY = screenPoint.y(); 306 screenPosition.y = screenPoint.y();
307 307
308 button = WebMouseEvent::Button::Left; 308 button = WebMouseEvent::Button::Left;
309 m_modifiers |= WebInputEvent::LeftButtonDown; 309 m_modifiers |= WebInputEvent::LeftButtonDown;
310 clickCount = (m_type == MouseDown || m_type == MouseUp); 310 clickCount = (m_type == MouseDown || m_type == MouseUp);
311 311
312 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt( 312 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt(
313 DoublePoint(touch->absoluteLocation()), layoutItem); 313 DoublePoint(touch->absoluteLocation()), layoutItem);
314 x = localPoint.x(); 314 position.x = localPoint.x();
315 y = localPoint.y(); 315 position.y = localPoint.y();
316 316
317 pointerType = WebPointerProperties::PointerType::Touch; 317 pointerType = WebPointerProperties::PointerType::Touch;
318 } 318 }
319 319
320 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) { 320 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) {
321 if (const WebKeyboardEvent* webEvent = event.keyEvent()) { 321 if (const WebKeyboardEvent* webEvent = event.keyEvent()) {
322 *static_cast<WebKeyboardEvent*>(this) = *webEvent; 322 *static_cast<WebKeyboardEvent*>(this) = *webEvent;
323 323
324 // TODO(dtapuska): DOM KeyboardEvents converted back to WebInputEvents 324 // TODO(dtapuska): DOM KeyboardEvents converted back to WebInputEvents
325 // drop the Raw behaviour. Figure out if this is actually really needed. 325 // drop the Raw behaviour. Figure out if this is actually really needed.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 Vector<WebTouchEvent> result; 362 Vector<WebTouchEvent> result;
363 for (const auto& event : coalescedEvents) { 363 for (const auto& event : coalescedEvents) {
364 DCHECK(WebInputEvent::isTouchEventType(event->type())); 364 DCHECK(WebInputEvent::isTouchEventType(event->type()));
365 result.push_back(TransformWebTouchEvent( 365 result.push_back(TransformWebTouchEvent(
366 scale, translation, static_cast<const WebTouchEvent&>(*event))); 366 scale, translation, static_cast<const WebTouchEvent&>(*event)));
367 } 367 }
368 return result; 368 return result;
369 } 369 }
370 370
371 } // namespace blink 371 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698