Index: third_party/WebKit/Source/core/input/TouchEventManager.h |
diff --git a/third_party/WebKit/Source/core/input/TouchEventManager.h b/third_party/WebKit/Source/core/input/TouchEventManager.h |
index d1a953024fa22033c7cc8618bb244ffbc3632342..a562fa55f3fff576624c73ac9d14a2440a3407f4 100644 |
--- a/third_party/WebKit/Source/core/input/TouchEventManager.h |
+++ b/third_party/WebKit/Source/core/input/TouchEventManager.h |
@@ -12,14 +12,15 @@ |
#include "platform/wtf/Allocator.h" |
#include "platform/wtf/HashMap.h" |
#include "platform/wtf/Vector.h" |
+#include "public/platform/WebCoalescedInputEvent.h" |
#include "public/platform/WebInputEventResult.h" |
-#include "public/platform/WebTouchPoint.h" |
+#include "public/platform/WebPointerEvent.h" |
+#include "public/platform/WebTouchEvent.h" |
namespace blink { |
class LocalFrame; |
class Document; |
-class WebTouchEvent; |
// This class takes care of dispatching all touch events and |
// maintaining related states. |
@@ -32,12 +33,11 @@ class CORE_EXPORT TouchEventManager |
explicit TouchEventManager(LocalFrame&); |
DECLARE_TRACE(); |
- // The entries in touch point array of WebTouchEvent (i.e. first parameter) |
- // correspond to the entries of the PointerEventTargets (i.e. last parameter). |
- WebInputEventResult HandleTouchEvent( |
- const WebTouchEvent&, |
- const Vector<WebTouchEvent>&, |
- const HeapVector<EventHandlingUtil::PointerEventTarget>&); |
+ void HandleTouchPoint(const WebPointerEvent&, |
+ const Vector<WebPointerEvent>&, |
+ const EventHandlingUtil::PointerEventTarget&); |
+ |
+ WebInputEventResult FlushEvents(); |
// Resets the internal state of this object. |
void Clear(); |
@@ -46,48 +46,68 @@ class CORE_EXPORT TouchEventManager |
bool IsAnyTouchActive() const; |
private: |
- Touch* CreateDomTouch(const WebTouchPoint&, bool* known_target); |
- |
- void UpdateTargetAndRegionMapsForTouchStart( |
- const WebTouchPoint&, |
+ // Class represending one touch point event with its coalesced events and |
+ // related attributes. |
+ class TouchPointAttributes |
+ : public GarbageCollectedFinalized<TouchPointAttributes> { |
+ public: |
+ DEFINE_INLINE_TRACE() { visitor->Trace(target_); } |
+ |
+ TouchPointAttributes() {} |
+ explicit TouchPointAttributes(WebPointerEvent event) |
+ : event_(event), stale_(false) {} |
+ |
+ // Last state of the touch point. |
+ WebPointerEvent event_; |
+ // The list of coalesced events of the touch point represented by this class |
+ // if there is any. Note that at the end of each frame this list gets |
+ // cleared and the touch point |stale_| flag will be true for the next frame |
+ // unless more new events arrives for this touch point. |
+ Vector<WebPointerEvent> coalesced_events_; |
+ Member<Node> target_; // The target of each active touch point. |
+ String region_; // // The region of each active touch point. |
+ bool stale_; |
+ }; |
+ |
+ WebCoalescedInputEvent GenerateWebCoalescedInputEvent(); |
+ Touch* CreateDomTouch(const TouchPointAttributes*, bool* known_target); |
+ void allTouchesReleasedCleanup(); |
+ |
+ // Keeps track of attributes of the touch point in the |
+ // |touch_points_attributes_| map and does the hit-testing if the original hit |
+ // test result was not inside capturing frame |touch_sequence_document_| for |
+ // touch events. |
+ void UpdateTouchAttributeMapsForPointerDown( |
+ const WebPointerEvent&, |
const EventHandlingUtil::PointerEventTarget&); |
- // Does the hit-testing if the original hit test result was not inside |
- // capturing frame for touch events. Returns true if touch events could be |
- // dispatched and otherwise returns false. |
- bool HitTestTouchPointsIfNeeded( |
- const WebTouchEvent&, |
- const HeapVector<EventHandlingUtil::PointerEventTarget>&); |
- |
- WebInputEventResult DispatchTouchEvents(const WebTouchEvent&, |
- const Vector<WebTouchEvent>&, |
- bool all_touches_released); |
+ // This is triggered either by VSync signal to send one touch event per frame |
+ // accumulating all move events or by discrete events pointerdown/up/cancel. |
+ WebInputEventResult DispatchTouchEventFromAccumulatdTouchPoints(); |
// NOTE: If adding a new field to this class please ensure that it is |
// cleared in |TouchEventManager::clear()|. |
const Member<LocalFrame> frame_; |
- // The target of each active touch point indexed by the touch ID. |
- using TouchTargetMap = |
- HeapHashMap<unsigned, |
- Member<Node>, |
- DefaultHash<unsigned>::Hash, |
- WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; |
- TouchTargetMap target_for_touch_id_; |
- using TouchRegionMap = HashMap<unsigned, |
- String, |
- DefaultHash<unsigned>::Hash, |
- WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; |
- TouchRegionMap region_for_touch_id_; |
+ // The attributes of each active touch point indexed by the touch ID. |
+ using TouchAttributeMap = |
+ HeapHashMap<int, |
+ Member<TouchPointAttributes>, |
+ WTF::IntHash<int>, |
+ WTF::UnsignedWithZeroKeyHashTraits<int>>; |
+ TouchAttributeMap touch_attribute_map_; |
// If set, the document of the active touch sequence. Unset if no touch |
// sequence active. |
Member<Document> touch_sequence_document_; |
- bool touch_pressed_; |
bool suppressing_touchmoves_within_slop_; |
+ // This is used to created a consistent sequence of coalesced events compared |
+ // to the last frame. |
+ WebTouchEvent last_coalesced_touch_event_; |
+ |
// The current touch action, computed on each touch start and is |
// a union of all touches. Reset when all touches are released. |
TouchAction current_touch_action_; |