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

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

Issue 2782893002: WebMouseEvent coordinates are now fractional & private (Closed)
Patch Set: Fixed a compile failure 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}; 124 WebInputEvent::RightButtonDown};
127 125
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 189
192 WebMouseEventBuilder::WebMouseEventBuilder(const FrameViewBase* frameViewBase, 190 WebMouseEventBuilder::WebMouseEventBuilder(const FrameViewBase* frameViewBase,
193 const LayoutItem layoutItem, 191 const LayoutItem layoutItem,
194 const MouseEvent& event) { 192 const MouseEvent& event) {
195 if (event.nativeEvent()) { 193 if (event.nativeEvent()) {
196 *static_cast<WebMouseEvent*>(this) = 194 *static_cast<WebMouseEvent*>(this) =
197 event.nativeEvent()->flattenTransform(); 195 event.nativeEvent()->flattenTransform();
198 WebFloatPoint absoluteRootFrameLocation = positionInRootFrame(); 196 WebFloatPoint absoluteRootFrameLocation = positionInRootFrame();
199 IntPoint localPoint = roundedIntPoint( 197 IntPoint localPoint = roundedIntPoint(
200 layoutItem.absoluteToLocal(absoluteRootFrameLocation, UseTransforms)); 198 layoutItem.absoluteToLocal(absoluteRootFrameLocation, UseTransforms));
201 x = localPoint.x(); 199 setPositionInWidget(localPoint.x(), localPoint.y());
202 y = localPoint.y();
203 return; 200 return;
204 } 201 }
205 202
206 // Code below here can be removed once OOPIF ships. 203 // Code below here can be removed once OOPIF ships.
207 // OOPIF will prevent synthetic events being dispatched into 204 // OOPIF will prevent synthetic events being dispatched into
208 // other frames; but for now we allow the fallback to generate 205 // other frames; but for now we allow the fallback to generate
209 // WebMouseEvents from synthetic events. 206 // WebMouseEvents from synthetic events.
210 if (event.type() == EventTypeNames::mousemove) 207 if (event.type() == EventTypeNames::mousemove)
211 m_type = WebInputEvent::MouseMove; 208 m_type = WebInputEvent::MouseMove;
212 else if (event.type() == EventTypeNames::mouseout) 209 else if (event.type() == EventTypeNames::mouseout)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 292
296 // The mouse event co-ordinates should be generated from the co-ordinates of 293 // The mouse event co-ordinates should be generated from the co-ordinates of
297 // the touch point. 294 // the touch point.
298 FrameView* view = toFrameView(frameViewBase->parent()); 295 FrameView* view = toFrameView(frameViewBase->parent());
299 // FIXME: if view == nullptr, pointInRootFrame will really be 296 // FIXME: if view == nullptr, pointInRootFrame will really be
300 // pointInRootContent. 297 // pointInRootContent.
301 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation()); 298 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation());
302 if (view) 299 if (view)
303 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); 300 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame);
304 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); 301 IntPoint screenPoint = roundedIntPoint(touch->screenLocation());
305 globalX = screenPoint.x(); 302 setPositionInScreen(screenPoint.x(), screenPoint.y());
306 globalY = screenPoint.y();
307 303
308 button = WebMouseEvent::Button::Left; 304 button = WebMouseEvent::Button::Left;
309 m_modifiers |= WebInputEvent::LeftButtonDown; 305 m_modifiers |= WebInputEvent::LeftButtonDown;
310 clickCount = (m_type == MouseDown || m_type == MouseUp); 306 clickCount = (m_type == MouseDown || m_type == MouseUp);
311 307
312 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt( 308 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt(
313 DoublePoint(touch->absoluteLocation()), layoutItem); 309 DoublePoint(touch->absoluteLocation()), layoutItem);
314 x = localPoint.x(); 310 setPositionInWidget(localPoint.x(), localPoint.y());
315 y = localPoint.y();
316 311
317 pointerType = WebPointerProperties::PointerType::Touch; 312 pointerType = WebPointerProperties::PointerType::Touch;
318 } 313 }
319 314
320 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) { 315 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) {
321 if (const WebKeyboardEvent* webEvent = event.keyEvent()) { 316 if (const WebKeyboardEvent* webEvent = event.keyEvent()) {
322 *static_cast<WebKeyboardEvent*>(this) = *webEvent; 317 *static_cast<WebKeyboardEvent*>(this) = *webEvent;
323 318
324 // TODO(dtapuska): DOM KeyboardEvents converted back to WebInputEvents 319 // TODO(dtapuska): DOM KeyboardEvents converted back to WebInputEvents
325 // drop the Raw behaviour. Figure out if this is actually really needed. 320 // 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; 357 Vector<WebTouchEvent> result;
363 for (const auto& event : coalescedEvents) { 358 for (const auto& event : coalescedEvents) {
364 DCHECK(WebInputEvent::isTouchEventType(event->type())); 359 DCHECK(WebInputEvent::isTouchEventType(event->type()));
365 result.push_back(TransformWebTouchEvent( 360 result.push_back(TransformWebTouchEvent(
366 scale, translation, static_cast<const WebTouchEvent&>(*event))); 361 scale, translation, static_cast<const WebTouchEvent&>(*event)));
367 } 362 }
368 return result; 363 return result;
369 } 364 }
370 365
371 } // namespace blink 366 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698