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

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

Issue 2782893002: WebMouseEvent coordinates are now fractional & private (Closed)
Patch Set: Rebased, fixed a comment in web_input_event_builders_mac.mm 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.setPositionInScreen(event.screenX(), event.screenY());
113 webEvent.globalY = event.screenY();
114 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt( 113 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt(
115 event.absoluteLocation(), layoutItem); 114 event.absoluteLocation(), layoutItem);
116 webEvent.x = localPoint.x(); 115 webEvent.setPositionInWidget(localPoint.x(), localPoint.y());
117 webEvent.y = localPoint.y();
118 } 116 }
119 117
120 unsigned toWebInputEventModifierFrom(WebMouseEvent::Button button) { 118 unsigned toWebInputEventModifierFrom(WebMouseEvent::Button button) {
121 if (button == WebMouseEvent::Button::NoButton) 119 if (button == WebMouseEvent::Button::NoButton)
122 return 0; 120 return 0;
123 121
124 unsigned webMouseButtonToPlatformModifier[] = { 122 unsigned webMouseButtonToPlatformModifier[] = {
125 WebInputEvent::LeftButtonDown, WebInputEvent::MiddleButtonDown, 123 WebInputEvent::LeftButtonDown, WebInputEvent::MiddleButtonDown,
126 WebInputEvent::RightButtonDown, WebInputEvent::BackButtonDown, 124 WebInputEvent::RightButtonDown, WebInputEvent::BackButtonDown,
127 WebInputEvent::ForwardButtonDown}; 125 WebInputEvent::ForwardButtonDown};
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 190
193 WebMouseEventBuilder::WebMouseEventBuilder(const FrameViewBase* frameViewBase, 191 WebMouseEventBuilder::WebMouseEventBuilder(const FrameViewBase* frameViewBase,
194 const LayoutItem layoutItem, 192 const LayoutItem layoutItem,
195 const MouseEvent& event) { 193 const MouseEvent& event) {
196 if (event.nativeEvent()) { 194 if (event.nativeEvent()) {
197 *static_cast<WebMouseEvent*>(this) = 195 *static_cast<WebMouseEvent*>(this) =
198 event.nativeEvent()->flattenTransform(); 196 event.nativeEvent()->flattenTransform();
199 WebFloatPoint absoluteRootFrameLocation = positionInRootFrame(); 197 WebFloatPoint absoluteRootFrameLocation = positionInRootFrame();
200 IntPoint localPoint = roundedIntPoint( 198 IntPoint localPoint = roundedIntPoint(
201 layoutItem.absoluteToLocal(absoluteRootFrameLocation, UseTransforms)); 199 layoutItem.absoluteToLocal(absoluteRootFrameLocation, UseTransforms));
202 x = localPoint.x(); 200 setPositionInWidget(localPoint.x(), localPoint.y());
203 y = localPoint.y();
204 return; 201 return;
205 } 202 }
206 203
207 // Code below here can be removed once OOPIF ships. 204 // Code below here can be removed once OOPIF ships.
208 // OOPIF will prevent synthetic events being dispatched into 205 // OOPIF will prevent synthetic events being dispatched into
209 // other frames; but for now we allow the fallback to generate 206 // other frames; but for now we allow the fallback to generate
210 // WebMouseEvents from synthetic events. 207 // WebMouseEvents from synthetic events.
211 if (event.type() == EventTypeNames::mousemove) 208 if (event.type() == EventTypeNames::mousemove)
212 m_type = WebInputEvent::MouseMove; 209 m_type = WebInputEvent::MouseMove;
213 else if (event.type() == EventTypeNames::mouseout) 210 else if (event.type() == EventTypeNames::mouseout)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 305
309 // The mouse event co-ordinates should be generated from the co-ordinates of 306 // The mouse event co-ordinates should be generated from the co-ordinates of
310 // the touch point. 307 // the touch point.
311 FrameView* view = toFrameView(frameViewBase->parent()); 308 FrameView* view = toFrameView(frameViewBase->parent());
312 // FIXME: if view == nullptr, pointInRootFrame will really be 309 // FIXME: if view == nullptr, pointInRootFrame will really be
313 // pointInRootContent. 310 // pointInRootContent.
314 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation()); 311 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation());
315 if (view) 312 if (view)
316 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); 313 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame);
317 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); 314 IntPoint screenPoint = roundedIntPoint(touch->screenLocation());
318 globalX = screenPoint.x(); 315 setPositionInScreen(screenPoint.x(), screenPoint.y());
319 globalY = screenPoint.y();
320 316
321 button = WebMouseEvent::Button::Left; 317 button = WebMouseEvent::Button::Left;
322 m_modifiers |= WebInputEvent::LeftButtonDown; 318 m_modifiers |= WebInputEvent::LeftButtonDown;
323 clickCount = (m_type == MouseDown || m_type == MouseUp); 319 clickCount = (m_type == MouseDown || m_type == MouseUp);
324 320
325 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt( 321 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt(
326 DoublePoint(touch->absoluteLocation()), layoutItem); 322 DoublePoint(touch->absoluteLocation()), layoutItem);
327 x = localPoint.x(); 323 setPositionInWidget(localPoint.x(), localPoint.y());
328 y = localPoint.y();
329 324
330 pointerType = WebPointerProperties::PointerType::Touch; 325 pointerType = WebPointerProperties::PointerType::Touch;
331 } 326 }
332 327
333 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) { 328 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) {
334 if (const WebKeyboardEvent* webEvent = event.keyEvent()) { 329 if (const WebKeyboardEvent* webEvent = event.keyEvent()) {
335 *static_cast<WebKeyboardEvent*>(this) = *webEvent; 330 *static_cast<WebKeyboardEvent*>(this) = *webEvent;
336 331
337 // TODO(dtapuska): DOM KeyboardEvents converted back to WebInputEvents 332 // TODO(dtapuska): DOM KeyboardEvents converted back to WebInputEvents
338 // drop the Raw behaviour. Figure out if this is actually really needed. 333 // drop the Raw behaviour. Figure out if this is actually really needed.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 Vector<WebTouchEvent> result; 370 Vector<WebTouchEvent> result;
376 for (const auto& event : coalescedEvents) { 371 for (const auto& event : coalescedEvents) {
377 DCHECK(WebInputEvent::isTouchEventType(event->type())); 372 DCHECK(WebInputEvent::isTouchEventType(event->type()));
378 result.push_back(TransformWebTouchEvent( 373 result.push_back(TransformWebTouchEvent(
379 scale, translation, static_cast<const WebTouchEvent&>(*event))); 374 scale, translation, static_cast<const WebTouchEvent&>(*event)));
380 } 375 }
381 return result; 376 return result;
382 } 377 }
383 378
384 } // namespace blink 379 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp ('k') | third_party/WebKit/Source/web/WebPagePopupImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698