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

Side by Side Diff: third_party/WebKit/Source/core/input/PointerEventManager.cpp

Issue 2916893003: Bookkeep the pointer event listeners added to page (Closed)
Patch Set: fix rebase error Created 3 years, 6 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 // 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 #include "core/input/PointerEventManager.h" 5 #include "core/input/PointerEventManager.h"
6 6
7 #include "core/dom/ElementTraversal.h" 7 #include "core/dom/ElementTraversal.h"
8 #include "core/dom/UserGestureIndicator.h" 8 #include "core/dom/UserGestureIndicator.h"
9 #include "core/dom/shadow/FlatTreeTraversal.h" 9 #include "core/dom/shadow/FlatTreeTraversal.h"
10 #include "core/events/MouseEvent.h" 10 #include "core/events/MouseEvent.h"
11 #include "core/frame/EventHandlerRegistry.h"
11 #include "core/frame/LocalFrameView.h" 12 #include "core/frame/LocalFrameView.h"
12 #include "core/frame/UseCounter.h" 13 #include "core/frame/UseCounter.h"
13 #include "core/html/HTMLCanvasElement.h" 14 #include "core/html/HTMLCanvasElement.h"
14 #include "core/input/EventHandler.h" 15 #include "core/input/EventHandler.h"
15 #include "core/input/EventHandlingUtil.h" 16 #include "core/input/EventHandlingUtil.h"
16 #include "core/input/MouseEventManager.h" 17 #include "core/input/MouseEventManager.h"
17 #include "core/input/TouchActionUtil.h" 18 #include "core/input/TouchActionUtil.h"
18 #include "core/layout/HitTestCanvasResult.h" 19 #include "core/layout/HitTestCanvasResult.h"
19 #include "core/page/ChromeClient.h" 20 #include "core/page/ChromeClient.h"
20 #include "core/page/Page.h" 21 #include "core/page/Page.h"
21 #include "platform/wtf/AutoReset.h" 22 #include "platform/wtf/AutoReset.h"
22 #include "public/platform/WebTouchEvent.h" 23 #include "public/platform/WebTouchEvent.h"
23 24
24 namespace blink { 25 namespace blink {
25 26
26 namespace { 27 namespace {
27 28
28 size_t ToPointerTypeIndex(WebPointerProperties::PointerType t) { 29 size_t ToPointerTypeIndex(WebPointerProperties::PointerType t) {
29 return static_cast<size_t>(t); 30 return static_cast<size_t>(t);
30 } 31 }
32 bool HasPointerEventListener(const EventHandlerRegistry& registry) {
33 return registry.HasEventHandlers(EventHandlerRegistry::kPointerEvent);
34 }
31 35
32 Vector<std::pair<WebTouchPoint, TimeTicks>> GetCoalescedPoints( 36 Vector<std::pair<WebTouchPoint, TimeTicks>> GetCoalescedPoints(
33 const Vector<WebTouchEvent>& coalesced_events, 37 const Vector<WebTouchEvent>& coalesced_events,
34 int id) { 38 int id) {
35 Vector<std::pair<WebTouchPoint, TimeTicks>> related_points; 39 Vector<std::pair<WebTouchPoint, TimeTicks>> related_points;
36 for (const auto& touch_event : coalesced_events) { 40 for (const auto& touch_event : coalesced_events) {
37 for (unsigned i = 0; i < touch_event.touches_length; ++i) { 41 for (unsigned i = 0; i < touch_event.touches_length; ++i) {
38 if (touch_event.touches[i].id == id && 42 if (touch_event.touches[i].id == id &&
39 touch_event.touches[i].state != WebTouchPoint::kStateStationary) { 43 touch_event.touches[i].state != WebTouchPoint::kStateStationary) {
40 related_points.push_back(std::pair<WebTouchPoint, TimeTicks>( 44 related_points.push_back(std::pair<WebTouchPoint, TimeTicks>(
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 EventTarget* target_under_pointer = 156 EventTarget* target_under_pointer =
153 node_under_pointer_.at(pointer_id).target; 157 node_under_pointer_.at(pointer_id).target;
154 if (target_under_pointer == target) { 158 if (target_under_pointer == target) {
155 node_under_pointer_.Set( 159 node_under_pointer_.Set(
156 pointer_id, 160 pointer_id,
157 EventTargetAttributes(target_under_pointer, 161 EventTargetAttributes(target_under_pointer,
158 event_type == EventTypeNames::pointerover)); 162 event_type == EventTypeNames::pointerover));
159 } 163 }
160 } 164 }
161 165
162 if (!RuntimeEnabledFeatures::PointerEventEnabled()) 166 if (!frame_ || !frame_->GetPage() ||
167 !HasPointerEventListener(frame_->GetPage()->GetEventHandlerRegistry()) ||
168 !RuntimeEnabledFeatures::PointerEventEnabled())
163 return WebInputEventResult::kNotHandled; 169 return WebInputEventResult::kNotHandled;
170
164 if (!check_for_listener || target->HasEventListeners(event_type)) { 171 if (!check_for_listener || target->HasEventListeners(event_type)) {
165 UseCounter::Count(frame_, UseCounter::kPointerEventDispatch); 172 UseCounter::Count(frame_, UseCounter::kPointerEventDispatch);
166 if (event_type == EventTypeNames::pointerdown) 173 if (event_type == EventTypeNames::pointerdown)
167 UseCounter::Count(frame_, UseCounter::kPointerEventDispatchPointerDown); 174 UseCounter::Count(frame_, UseCounter::kPointerEventDispatchPointerDown);
168 175
169 DCHECK(!dispatching_pointer_id_); 176 DCHECK(!dispatching_pointer_id_);
170 AutoReset<int> dispatch_holder(&dispatching_pointer_id_, pointer_id); 177 AutoReset<int> dispatch_holder(&dispatching_pointer_id_, pointer_id);
171 DispatchEventResult dispatch_result = target->DispatchEvent(pointer_event); 178 DispatchEventResult dispatch_result = target->DispatchEvent(pointer_event);
172 return EventHandlingUtil::ToWebInputEventResult(dispatch_result); 179 return EventHandlingUtil::ToWebInputEventResult(dispatch_result);
173 } 180 }
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 if (first_id > unique_touch_event_id) 752 if (first_id > unique_touch_event_id)
746 return false; 753 return false;
747 touch_ids_for_canceled_pointerdowns_.TakeFirst(); 754 touch_ids_for_canceled_pointerdowns_.TakeFirst();
748 if (first_id == unique_touch_event_id) 755 if (first_id == unique_touch_event_id)
749 return true; 756 return true;
750 } 757 }
751 return false; 758 return false;
752 } 759 }
753 760
754 } // namespace blink 761 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/forms/SliderThumbElement.cpp ('k') | third_party/WebKit/Source/core/testing/Internals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698