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

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

Issue 1888163003: Articulate the cancel behavior in the WebTouchEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and non-const ref passed back Created 4 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 offset = rootView->inputEventsOffsetForEmulation(); 84 offset = rootView->inputEventsOffsetForEmulation();
85 visualViewport = flooredIntPoint(rootView->page()->frameHost().visua lViewport().visibleRect().location()); 85 visualViewport = flooredIntPoint(rootView->page()->frameHost().visua lViewport().visibleRect().location());
86 overscrollOffset = rootView->page()->frameHost().chromeClient().elas ticOverscroll(); 86 overscrollOffset = rootView->page()->frameHost().chromeClient().elas ticOverscroll();
87 } 87 }
88 } 88 }
89 return FloatPoint( 89 return FloatPoint(
90 (pointInRendererViewport.x() - offset.width()) / scale + visualViewport. x() + overscrollOffset.width(), 90 (pointInRendererViewport.x() - offset.width()) / scale + visualViewport. x() + overscrollOffset.width(),
91 (pointInRendererViewport.y() - offset.height()) / scale + visualViewport .y() + overscrollOffset.height()); 91 (pointInRendererViewport.y() - offset.height()) / scale + visualViewport .y() + overscrollOffset.height());
92 } 92 }
93 93
94 PlatformEvent::DispatchType toPlatformDispatchType(WebInputEvent::DispatchType t ype)
95 {
96 static_assert(PlatformEvent::DispatchType::Blocking == static_cast<PlatformE vent::DispatchType>(WebInputEvent::DispatchType::Blocking),
97 "Dispatch Types not equal");
98 static_assert(PlatformEvent::DispatchType::EventNonBlocking == static_cast<P latformEvent::DispatchType>(WebInputEvent::DispatchType::EventNonBlocking),
99 "Dispatch Types not equal");
100 static_assert(PlatformEvent::DispatchType::ListenersNonBlockingPassive == st atic_cast<PlatformEvent::DispatchType>(WebInputEvent::DispatchType::ListenersNon BlockingPassive),
101 "Dispatch Types not equal");
102 static_assert(PlatformEvent::DispatchType::ListenersForcedNonBlockingPassive == static_cast<PlatformEvent::DispatchType>(WebInputEvent::DispatchType::Listen ersForcedNonBlockingPassive),
103 "Dispatch Types not equal");
104
105 return static_cast<PlatformEvent::DispatchType>(type);
106 }
107
94 unsigned toPlatformModifierFrom(WebMouseEvent::Button button) 108 unsigned toPlatformModifierFrom(WebMouseEvent::Button button)
95 { 109 {
96 if (button == WebMouseEvent::ButtonNone) 110 if (button == WebMouseEvent::ButtonNone)
97 return 0; 111 return 0;
98 112
99 unsigned webMouseButtonToPlatformModifier[] = { 113 unsigned webMouseButtonToPlatformModifier[] = {
100 PlatformEvent::LeftButtonDown, 114 PlatformEvent::LeftButtonDown,
101 PlatformEvent::MiddleButtonDown, 115 PlatformEvent::MiddleButtonDown,
102 PlatformEvent::RightButtonDown 116 PlatformEvent::RightButtonDown
103 }; 117 };
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 PlatformTouchEventBuilder::PlatformTouchEventBuilder(Widget* widget, const WebTo uchEvent& event) 466 PlatformTouchEventBuilder::PlatformTouchEventBuilder(Widget* widget, const WebTo uchEvent& event)
453 { 467 {
454 m_type = toPlatformTouchEventType(event.type); 468 m_type = toPlatformTouchEventType(event.type);
455 m_modifiers = event.modifiers; 469 m_modifiers = event.modifiers;
456 m_timestamp = event.timeStampSeconds; 470 m_timestamp = event.timeStampSeconds;
457 m_causesScrollingIfUncanceled = event.movedBeyondSlopRegion; 471 m_causesScrollingIfUncanceled = event.movedBeyondSlopRegion;
458 472
459 for (unsigned i = 0; i < event.touchesLength; ++i) 473 for (unsigned i = 0; i < event.touchesLength; ++i)
460 m_touchPoints.append(PlatformTouchPointBuilder(widget, event.touches[i]) ); 474 m_touchPoints.append(PlatformTouchPointBuilder(widget, event.touches[i]) );
461 475
462 m_cancelable = event.cancelable; 476 m_dispatchType = toPlatformDispatchType(event.dispatchType);
463 } 477 }
464 478
465 static FloatPoint convertAbsoluteLocationForLayoutObjectFloat(const LayoutPoint& location, const LayoutObject& layoutObject) 479 static FloatPoint convertAbsoluteLocationForLayoutObjectFloat(const LayoutPoint& location, const LayoutObject& layoutObject)
466 { 480 {
467 return layoutObject.absoluteToLocal(FloatPoint(location), UseTransforms); 481 return layoutObject.absoluteToLocal(FloatPoint(location), UseTransforms);
468 } 482 }
469 483
470 static IntPoint convertAbsoluteLocationForLayoutObject(const LayoutPoint& locati on, const LayoutObject& layoutObject) 484 static IntPoint convertAbsoluteLocationForLayoutObject(const LayoutPoint& locati on, const LayoutObject& layoutObject)
471 { 485 {
472 return roundedIntPoint(convertAbsoluteLocationForLayoutObjectFloat(location, layoutObject)); 486 return roundedIntPoint(convertAbsoluteLocationForLayoutObjectFloat(location, layoutObject));
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 else if (event.type() == EventTypeNames::touchcancel) 726 else if (event.type() == EventTypeNames::touchcancel)
713 type = TouchCancel; 727 type = TouchCancel;
714 else { 728 else {
715 NOTREACHED(); 729 NOTREACHED();
716 type = Undefined; 730 type = Undefined;
717 return; 731 return;
718 } 732 }
719 733
720 timeStampSeconds = event.platformTimeStamp(); 734 timeStampSeconds = event.platformTimeStamp();
721 modifiers = event.modifiers(); 735 modifiers = event.modifiers();
722 cancelable = event.cancelable(); 736 dispatchType = event.cancelable() ? WebInputEvent::Blocking : WebInputEvent: :EventNonBlocking;
723 movedBeyondSlopRegion = event.causesScrollingIfUncanceled(); 737 movedBeyondSlopRegion = event.causesScrollingIfUncanceled();
724 738
725 // Currently touches[] is empty, add stationary points as-is. 739 // Currently touches[] is empty, add stationary points as-is.
726 for (unsigned i = 0; i < event.touches()->length() && i < static_cast<unsign ed>(WebTouchEvent::touchesLengthCap); ++i) { 740 for (unsigned i = 0; i < event.touches()->length() && i < static_cast<unsign ed>(WebTouchEvent::touchesLengthCap); ++i) {
727 touches[i] = toWebTouchPoint(event.touches()->item(i), layoutObject, Web TouchPoint::StateStationary); 741 touches[i] = toWebTouchPoint(event.touches()->item(i), layoutObject, Web TouchPoint::StateStationary);
728 ++touchesLength; 742 ++touchesLength;
729 } 743 }
730 // If any existing points are also in the change list, we should update 744 // If any existing points are also in the change list, we should update
731 // their state, otherwise just add the new points. 745 // their state, otherwise just add the new points.
732 addTouchPointsUpdateStateIfNecessary(toWebTouchPointState(event.type()), eve nt.changedTouches(), touches, &touchesLength, layoutObject); 746 addTouchPointsUpdateStateIfNecessary(toWebTouchPointState(event.type()), eve nt.changedTouches(), touches, &touchesLength, layoutObject);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 break; 799 break;
786 case GestureSourceTouchscreen: 800 case GestureSourceTouchscreen:
787 sourceDevice = WebGestureDeviceTouchscreen; 801 sourceDevice = WebGestureDeviceTouchscreen;
788 break; 802 break;
789 case GestureSourceUninitialized: 803 case GestureSourceUninitialized:
790 NOTREACHED(); 804 NOTREACHED();
791 } 805 }
792 } 806 }
793 807
794 } // namespace blink 808 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebInputEvent.cpp ('k') | third_party/WebKit/Source/web/tests/TouchActionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698