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

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

Issue 2389633002: reflow comments in web/ (Closed)
Patch Set: . Created 4 years, 2 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 scale = rootView->inputEventsScaleFactor(); 58 scale = rootView->inputEventsScaleFactor();
59 } 59 }
60 return delta / scale; 60 return delta / scale;
61 } 61 }
62 62
63 FloatSize scaleSizeToWindow(const Widget* widget, FloatSize size) { 63 FloatSize scaleSizeToWindow(const Widget* widget, FloatSize size) {
64 return FloatSize(scaleDeltaToWindow(widget, size.width()), 64 return FloatSize(scaleDeltaToWindow(widget, size.width()),
65 scaleDeltaToWindow(widget, size.height())); 65 scaleDeltaToWindow(widget, size.height()));
66 } 66 }
67 67
68 // This method converts from the renderer's coordinate space into Blink's root f rame coordinate space. 68 // This method converts from the renderer's coordinate space into Blink's root
69 // It's somewhat unique in that it takes into account DevTools emulation, which applies a scale and offset 69 // frame coordinate space. It's somewhat unique in that it takes into account
70 // in the root layer (see updateRootLayerTransform in WebViewImpl) as well as th e overscroll effect on OSX. 70 // DevTools emulation, which applies a scale and offset in the root layer (see
71 // This is in addition to the visual viewport "pinch-zoom" transformation and is one of the few cases where 71 // updateRootLayerTransform in WebViewImpl) as well as the overscroll effect on
72 // the visual viewport is not equal to the renderer's coordinate-space. 72 // OSX. This is in addition to the visual viewport "pinch-zoom" transformation
73 // and is one of the few cases where the visual viewport is not equal to the
74 // renderer's coordinate-space.
73 FloatPoint convertHitPointToRootFrame(const Widget* widget, 75 FloatPoint convertHitPointToRootFrame(const Widget* widget,
74 FloatPoint pointInRendererViewport) { 76 FloatPoint pointInRendererViewport) {
75 float scale = 1; 77 float scale = 1;
76 IntSize offset; 78 IntSize offset;
77 IntPoint visualViewport; 79 IntPoint visualViewport;
78 FloatSize overscrollOffset; 80 FloatSize overscrollOffset;
79 if (widget) { 81 if (widget) {
80 FrameView* rootView = toFrameView(widget->root()); 82 FrameView* rootView = toFrameView(widget->root());
81 if (rootView) { 83 if (rootView) {
82 scale = rootView->inputEventsScaleFactor(); 84 scale = rootView->inputEventsScaleFactor();
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 257
256 m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas; 258 m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas;
257 m_resendingPluginId = e.resendingPluginId; 259 m_resendingPluginId = e.resendingPluginId;
258 m_railsMode = static_cast<PlatformEvent::RailsMode>(e.railsMode); 260 m_railsMode = static_cast<PlatformEvent::RailsMode>(e.railsMode);
259 #if OS(MACOSX) 261 #if OS(MACOSX)
260 m_phase = static_cast<PlatformWheelEventPhase>(e.phase); 262 m_phase = static_cast<PlatformWheelEventPhase>(e.phase);
261 m_momentumPhase = static_cast<PlatformWheelEventPhase>(e.momentumPhase); 263 m_momentumPhase = static_cast<PlatformWheelEventPhase>(e.momentumPhase);
262 #endif 264 #endif
263 } 265 }
264 266
265 // PlatformGestureEventBuilder ------------------------------------------------- - 267 // PlatformGestureEventBuilder -----------------------------------------------
266 268
267 PlatformGestureEventBuilder::PlatformGestureEventBuilder( 269 PlatformGestureEventBuilder::PlatformGestureEventBuilder(
268 Widget* widget, 270 Widget* widget,
269 const WebGestureEvent& e) { 271 const WebGestureEvent& e) {
270 switch (e.type) { 272 switch (e.type) {
271 case WebInputEvent::GestureScrollBegin: 273 case WebInputEvent::GestureScrollBegin:
272 m_type = PlatformEvent::GestureScrollBegin; 274 m_type = PlatformEvent::GestureScrollBegin;
273 m_data.m_scroll.m_resendingPluginId = e.resendingPluginId; 275 m_data.m_scroll.m_resendingPluginId = e.resendingPluginId;
274 m_data.m_scroll.m_deltaX = e.data.scrollBegin.deltaXHint; 276 m_data.m_scroll.m_deltaX = e.data.scrollBegin.deltaXHint;
275 m_data.m_scroll.m_deltaY = e.data.scrollBegin.deltaYHint; 277 m_data.m_scroll.m_deltaY = e.data.scrollBegin.deltaYHint;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 break; 329 break;
328 case WebInputEvent::GestureShowPress: 330 case WebInputEvent::GestureShowPress:
329 m_type = PlatformEvent::GestureShowPress; 331 m_type = PlatformEvent::GestureShowPress;
330 m_area = expandedIntSize(scaleSizeToWindow( 332 m_area = expandedIntSize(scaleSizeToWindow(
331 widget, FloatSize(e.data.showPress.width, e.data.showPress.height))); 333 widget, FloatSize(e.data.showPress.width, e.data.showPress.height)));
332 break; 334 break;
333 case WebInputEvent::GestureTapCancel: 335 case WebInputEvent::GestureTapCancel:
334 m_type = PlatformEvent::GestureTapDownCancel; 336 m_type = PlatformEvent::GestureTapDownCancel;
335 break; 337 break;
336 case WebInputEvent::GestureDoubleTap: 338 case WebInputEvent::GestureDoubleTap:
337 // DoubleTap gesture is now handled as PlatformEvent::GestureTap with tap_ count = 2. So no 339 // DoubleTap gesture is now handled as PlatformEvent::GestureTap with
338 // need to convert to a Platfrom DoubleTap gesture. But in WebViewImpl::ha ndleGestureEvent 340 // tap_count = 2. So no need to convert to a Platfrom DoubleTap gesture.
339 // all WebGestureEvent are converted to PlatformGestureEvent, for complete ness and not reach 341 // But in WebViewImpl::handleGestureEvent all WebGestureEvent are
340 // the NOTREACHED() at the end, convert the DoubleTap to a NoType. 342 // converted to PlatformGestureEvent, for completeness and not reach the
343 // NOTREACHED() at the end, convert the DoubleTap to a NoType.
341 m_type = PlatformEvent::NoType; 344 m_type = PlatformEvent::NoType;
342 break; 345 break;
343 case WebInputEvent::GestureTwoFingerTap: 346 case WebInputEvent::GestureTwoFingerTap:
344 m_type = PlatformEvent::GestureTwoFingerTap; 347 m_type = PlatformEvent::GestureTwoFingerTap;
345 m_area = expandedIntSize(scaleSizeToWindow( 348 m_area = expandedIntSize(scaleSizeToWindow(
346 widget, FloatSize(e.data.twoFingerTap.firstFingerWidth, 349 widget, FloatSize(e.data.twoFingerTap.firstFingerWidth,
347 e.data.twoFingerTap.firstFingerHeight))); 350 e.data.twoFingerTap.firstFingerHeight)));
348 break; 351 break;
349 case WebInputEvent::GestureLongPress: 352 case WebInputEvent::GestureLongPress:
350 m_type = PlatformEvent::GestureLongPress; 353 m_type = PlatformEvent::GestureLongPress;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 // RemoteFrameViews. 492 // RemoteFrameViews.
490 static void updateWebMouseEventFromCoreMouseEvent( 493 static void updateWebMouseEventFromCoreMouseEvent(
491 const MouseRelatedEvent& event, 494 const MouseRelatedEvent& event,
492 const Widget* widget, 495 const Widget* widget,
493 const LayoutItem layoutItem, 496 const LayoutItem layoutItem,
494 WebMouseEvent& webEvent) { 497 WebMouseEvent& webEvent) {
495 webEvent.timeStampSeconds = event.platformTimeStamp(); 498 webEvent.timeStampSeconds = event.platformTimeStamp();
496 webEvent.modifiers = event.modifiers(); 499 webEvent.modifiers = event.modifiers();
497 500
498 FrameView* view = widget ? toFrameView(widget->parent()) : 0; 501 FrameView* view = widget ? toFrameView(widget->parent()) : 0;
499 // TODO(bokan): If view == nullptr, pointInRootFrame will really be pointInRoo tContent. 502 // TODO(bokan): If view == nullptr, pointInRootFrame will really be
503 // pointInRootContent.
500 IntPoint pointInRootFrame = IntPoint(event.absoluteLocation().x().toInt(), 504 IntPoint pointInRootFrame = IntPoint(event.absoluteLocation().x().toInt(),
501 event.absoluteLocation().y().toInt()); 505 event.absoluteLocation().y().toInt());
502 if (view) 506 if (view)
503 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); 507 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame);
504 webEvent.globalX = event.screenX(); 508 webEvent.globalX = event.screenX();
505 webEvent.globalY = event.screenY(); 509 webEvent.globalY = event.screenY();
506 webEvent.windowX = pointInRootFrame.x(); 510 webEvent.windowX = pointInRootFrame.x();
507 webEvent.windowY = pointInRootFrame.y(); 511 webEvent.windowY = pointInRootFrame.y();
508 IntPoint localPoint = convertAbsoluteLocationForLayoutObject( 512 IntPoint localPoint = convertAbsoluteLocationForLayoutObject(
509 event.absoluteLocation(), layoutItem); 513 event.absoluteLocation(), layoutItem);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 } 563 }
560 movementX = event.movementX(); 564 movementX = event.movementX();
561 movementY = event.movementY(); 565 movementY = event.movementY();
562 clickCount = event.detail(); 566 clickCount = event.detail();
563 567
564 pointerType = WebPointerProperties::PointerType::Mouse; 568 pointerType = WebPointerProperties::PointerType::Mouse;
565 if (event.mouseEvent()) 569 if (event.mouseEvent())
566 pointerType = event.mouseEvent()->pointerProperties().pointerType; 570 pointerType = event.mouseEvent()->pointerProperties().pointerType;
567 } 571 }
568 572
569 // Generate a synthetic WebMouseEvent given a TouchEvent (eg. for emulating a mo use 573 // Generate a synthetic WebMouseEvent given a TouchEvent (eg. for emulating a
570 // with touch input for plugins that don't support touch input). 574 // mouse with touch input for plugins that don't support touch input).
571 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, 575 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget,
572 const LayoutItem layoutItem, 576 const LayoutItem layoutItem,
573 const TouchEvent& event) { 577 const TouchEvent& event) {
574 if (!event.touches()) 578 if (!event.touches())
575 return; 579 return;
576 if (event.touches()->length() != 1) { 580 if (event.touches()->length() != 1) {
577 if (event.touches()->length() || event.type() != EventTypeNames::touchend || 581 if (event.touches()->length() || event.type() != EventTypeNames::touchend ||
578 !event.changedTouches() || event.changedTouches()->length() != 1) 582 !event.changedTouches() || event.changedTouches()->length() != 1)
579 return; 583 return;
580 } 584 }
581 585
582 const Touch* touch = event.touches()->length() == 1 586 const Touch* touch = event.touches()->length() == 1
583 ? event.touches()->item(0) 587 ? event.touches()->item(0)
584 : event.changedTouches()->item(0); 588 : event.changedTouches()->item(0);
585 if (touch->identifier()) 589 if (touch->identifier())
586 return; 590 return;
587 591
588 if (event.type() == EventTypeNames::touchstart) 592 if (event.type() == EventTypeNames::touchstart)
589 type = MouseDown; 593 type = MouseDown;
590 else if (event.type() == EventTypeNames::touchmove) 594 else if (event.type() == EventTypeNames::touchmove)
591 type = MouseMove; 595 type = MouseMove;
592 else if (event.type() == EventTypeNames::touchend) 596 else if (event.type() == EventTypeNames::touchend)
593 type = MouseUp; 597 type = MouseUp;
594 else 598 else
595 return; 599 return;
596 600
597 timeStampSeconds = event.platformTimeStamp(); 601 timeStampSeconds = event.platformTimeStamp();
598 modifiers = event.modifiers(); 602 modifiers = event.modifiers();
599 603
600 // The mouse event co-ordinates should be generated from the co-ordinates of t he touch point. 604 // The mouse event co-ordinates should be generated from the co-ordinates of
605 // the touch point.
601 FrameView* view = toFrameView(widget->parent()); 606 FrameView* view = toFrameView(widget->parent());
602 // FIXME: if view == nullptr, pointInRootFrame will really be pointInRootConte nt. 607 // FIXME: if view == nullptr, pointInRootFrame will really be
608 // pointInRootContent.
603 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation()); 609 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation());
604 if (view) 610 if (view)
605 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); 611 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame);
606 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); 612 IntPoint screenPoint = roundedIntPoint(touch->screenLocation());
607 globalX = screenPoint.x(); 613 globalX = screenPoint.x();
608 globalY = screenPoint.y(); 614 globalY = screenPoint.y();
609 windowX = pointInRootFrame.x(); 615 windowX = pointInRootFrame.x();
610 windowY = pointInRootFrame.y(); 616 windowY = pointInRootFrame.y();
611 617
612 button = WebMouseEvent::Button::Left; 618 button = WebMouseEvent::Button::Left;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 break; 823 break;
818 case GestureSourceTouchscreen: 824 case GestureSourceTouchscreen:
819 sourceDevice = WebGestureDeviceTouchscreen; 825 sourceDevice = WebGestureDeviceTouchscreen;
820 break; 826 break;
821 case GestureSourceUninitialized: 827 case GestureSourceUninitialized:
822 NOTREACHED(); 828 NOTREACHED();
823 } 829 }
824 } 830 }
825 831
826 } // namespace blink 832 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebHelperPluginImpl.cpp ('k') | third_party/WebKit/Source/web/WebKit.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698