OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WebCoalescedInputEvent_h | 5 #ifndef WebCoalescedInputEvent_h |
6 #define WebCoalescedInputEvent_h | 6 #define WebCoalescedInputEvent_h |
7 | 7 |
8 #include "WebCommon.h" | 8 #include "WebCommon.h" |
9 #include "WebInputEvent.h" | 9 #include "WebInputEvent.h" |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 // This class is representing a polymorphic WebInputEvent structure with its | 16 // This class is representing a polymorphic WebInputEvent structure with its |
17 // coalesced events. The event could be any events defined in WebInputEvent.h. | 17 // coalesced events. The event could be any events defined in WebInputEvent.h. |
18 class BLINK_PLATFORM_EXPORT WebCoalescedInputEvent { | 18 class BLINK_PLATFORM_EXPORT WebCoalescedInputEvent { |
19 public: | 19 public: |
20 explicit WebCoalescedInputEvent(const WebInputEvent&); | 20 explicit WebCoalescedInputEvent(const WebInputEvent&); |
21 WebCoalescedInputEvent(const WebInputEvent&, | 21 WebCoalescedInputEvent(const WebInputEvent&, |
22 const std::vector<const WebInputEvent*>&); | 22 const std::vector<const WebInputEvent*>&); |
| 23 // Copy constructor to deep copy the event. |
| 24 WebCoalescedInputEvent(const WebCoalescedInputEvent&); |
23 | 25 |
24 WebInputEvent* EventPointer(); | 26 WebInputEvent* EventPointer(); |
25 void AddCoalescedEvent(const blink::WebInputEvent&); | 27 void AddCoalescedEvent(const blink::WebInputEvent&); |
26 const WebInputEvent& Event() const; | 28 const WebInputEvent& Event() const; |
27 size_t CoalescedEventSize() const; | 29 size_t CoalescedEventSize() const; |
28 const WebInputEvent& CoalescedEvent(size_t index) const; | 30 const WebInputEvent& CoalescedEvent(size_t index) const; |
29 std::vector<const WebInputEvent*> GetCoalescedEventsPointers() const; | 31 std::vector<const WebInputEvent*> GetCoalescedEventsPointers() const; |
30 | 32 |
31 private: | 33 private: |
32 // TODO(hans): Remove this once clang-cl knows to not inline dtors that | 34 // TODO(hans): Remove this once clang-cl knows to not inline dtors that |
33 // call operator(), https://crbug.com/691714 | 35 // call operator(), https://crbug.com/691714 |
34 struct BLINK_PLATFORM_EXPORT WebInputEventDeleter { | 36 struct BLINK_PLATFORM_EXPORT WebInputEventDeleter { |
35 void operator()(blink::WebInputEvent*) const; | 37 void operator()(blink::WebInputEvent*) const; |
36 }; | 38 }; |
37 | 39 |
38 using WebScopedInputEvent = | 40 using WebScopedInputEvent = |
39 std::unique_ptr<WebInputEvent, WebInputEventDeleter>; | 41 std::unique_ptr<WebInputEvent, WebInputEventDeleter>; |
40 | 42 |
41 WebScopedInputEvent MakeWebScopedInputEvent(const blink::WebInputEvent&); | 43 WebScopedInputEvent MakeWebScopedInputEvent(const blink::WebInputEvent&); |
42 | 44 |
43 WebScopedInputEvent event_; | 45 WebScopedInputEvent event_; |
44 std::vector<WebScopedInputEvent> coalesced_events_; | 46 std::vector<WebScopedInputEvent> coalesced_events_; |
45 }; | 47 }; |
46 | 48 |
47 using WebScopedCoalescedInputEvent = std::unique_ptr<WebCoalescedInputEvent>; | 49 using WebScopedCoalescedInputEvent = std::unique_ptr<WebCoalescedInputEvent>; |
48 | 50 |
49 } // namespace blink | 51 } // namespace blink |
50 | 52 |
51 #endif | 53 #endif |
OLD | NEW |