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

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

Issue 1654653002: Canvas2d: Implement rerouting event by hit region's control. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass existing tests. Created 4 years, 10 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) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "core/events/TextEvent.h" 49 #include "core/events/TextEvent.h"
50 #include "core/events/TouchEvent.h" 50 #include "core/events/TouchEvent.h"
51 #include "core/events/WheelEvent.h" 51 #include "core/events/WheelEvent.h"
52 #include "core/fetch/ImageResource.h" 52 #include "core/fetch/ImageResource.h"
53 #include "core/frame/EventHandlerRegistry.h" 53 #include "core/frame/EventHandlerRegistry.h"
54 #include "core/frame/FrameHost.h" 54 #include "core/frame/FrameHost.h"
55 #include "core/frame/FrameView.h" 55 #include "core/frame/FrameView.h"
56 #include "core/frame/LocalFrame.h" 56 #include "core/frame/LocalFrame.h"
57 #include "core/frame/Settings.h" 57 #include "core/frame/Settings.h"
58 #include "core/frame/VisualViewport.h" 58 #include "core/frame/VisualViewport.h"
59 #include "core/html/HTMLCanvasElement.h"
59 #include "core/html/HTMLDialogElement.h" 60 #include "core/html/HTMLDialogElement.h"
60 #include "core/html/HTMLFrameElementBase.h" 61 #include "core/html/HTMLFrameElementBase.h"
61 #include "core/html/HTMLFrameSetElement.h" 62 #include "core/html/HTMLFrameSetElement.h"
62 #include "core/html/HTMLInputElement.h" 63 #include "core/html/HTMLInputElement.h"
63 #include "core/input/InputDeviceCapabilities.h" 64 #include "core/input/InputDeviceCapabilities.h"
64 #include "core/input/TouchActionUtil.h" 65 #include "core/input/TouchActionUtil.h"
65 #include "core/layout/HitTestRequest.h" 66 #include "core/layout/HitTestRequest.h"
66 #include "core/layout/HitTestResult.h" 67 #include "core/layout/HitTestResult.h"
67 #include "core/layout/LayoutPart.h" 68 #include "core/layout/LayoutPart.h"
68 #include "core/layout/LayoutTextControlSingleLine.h" 69 #include "core/layout/LayoutTextControlSingleLine.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 visitor->trace(m_capturingMouseEventsNode); 353 visitor->trace(m_capturingMouseEventsNode);
353 visitor->trace(m_nodeUnderMouse); 354 visitor->trace(m_nodeUnderMouse);
354 visitor->trace(m_lastMouseMoveEventSubframe); 355 visitor->trace(m_lastMouseMoveEventSubframe);
355 visitor->trace(m_lastScrollbarUnderMouse); 356 visitor->trace(m_lastScrollbarUnderMouse);
356 visitor->trace(m_clickNode); 357 visitor->trace(m_clickNode);
357 visitor->trace(m_dragTarget); 358 visitor->trace(m_dragTarget);
358 visitor->trace(m_frameSetBeingResized); 359 visitor->trace(m_frameSetBeingResized);
359 visitor->trace(m_previousWheelScrolledNode); 360 visitor->trace(m_previousWheelScrolledNode);
360 visitor->trace(m_scrollbarHandlingScrollGesture); 361 visitor->trace(m_scrollbarHandlingScrollGesture);
361 visitor->trace(m_targetForTouchID); 362 visitor->trace(m_targetForTouchID);
363 visitor->trace(m_regionForTouchID);
362 visitor->trace(m_touchSequenceDocument); 364 visitor->trace(m_touchSequenceDocument);
363 visitor->trace(m_scrollGestureHandlingNode); 365 visitor->trace(m_scrollGestureHandlingNode);
364 visitor->trace(m_previousGestureScrolledNode); 366 visitor->trace(m_previousGestureScrolledNode);
365 visitor->trace(m_lastDeferredTapElement); 367 visitor->trace(m_lastDeferredTapElement);
366 visitor->trace(m_selectionController); 368 visitor->trace(m_selectionController);
367 #endif 369 #endif
368 } 370 }
369 371
370 DragState& EventHandler::dragState() 372 DragState& EventHandler::dragState()
371 { 373 {
(...skipping 3465 matching lines...) Expand 10 before | Expand all | Expand 10 after
3837 continue; 3839 continue;
3838 3840
3839 RefPtrWillBeRawPtr<Touch> touch = Touch::create( 3841 RefPtrWillBeRawPtr<Touch> touch = Touch::create(
3840 touchInfo.targetFrame.get(), 3842 touchInfo.targetFrame.get(),
3841 touchInfo.touchTarget.get(), 3843 touchInfo.touchTarget.get(),
3842 point.id(), 3844 point.id(),
3843 point.screenPos(), 3845 point.screenPos(),
3844 touchInfo.adjustedPagePoint, 3846 touchInfo.adjustedPagePoint,
3845 touchInfo.adjustedRadius, 3847 touchInfo.adjustedRadius,
3846 point.rotationAngle(), 3848 point.rotationAngle(),
3847 point.force()); 3849 point.force(),
3850 touchInfo.region);
3848 3851
3849 // Ensure this target's touch list exists, even if it ends up empty, so 3852 // Ensure this target's touch list exists, even if it ends up empty, so
3850 // it can always be passed to TouchEvent::Create below. 3853 // it can always be passed to TouchEvent::Create below.
3851 TargetTouchesHeapMap::iterator targetTouchesIterator = touchesByTarget.f ind(touchInfo.touchTarget.get()); 3854 TargetTouchesHeapMap::iterator targetTouchesIterator = touchesByTarget.f ind(touchInfo.touchTarget.get());
3852 if (targetTouchesIterator == touchesByTarget.end()) { 3855 if (targetTouchesIterator == touchesByTarget.end()) {
3853 touchesByTarget.set(touchInfo.touchTarget.get(), TouchList::create() ); 3856 touchesByTarget.set(touchInfo.touchTarget.get(), TouchList::create() );
3854 targetTouchesIterator = touchesByTarget.find(touchInfo.touchTarget.g et()); 3857 targetTouchesIterator = touchesByTarget.find(touchInfo.touchTarget.g et());
3855 } 3858 }
3856 3859
3857 // touches and targetTouches should only contain information about 3860 // touches and targetTouches should only contain information about
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
3964 LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocum ent->frame()->view()->rootFrameToContents(point.pos())); 3967 LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocum ent->frame()->view()->rootFrameToContents(point.pos()));
3965 result = hitTestResultInFrame(m_touchSequenceDocument->frame(), framePoint, hitType); 3968 result = hitTestResultInFrame(m_touchSequenceDocument->frame(), framePoint, hitType);
3966 } else { 3969 } else {
3967 continue; 3970 continue;
3968 } 3971 }
3969 3972
3970 Node* node = result.innerNode(); 3973 Node* node = result.innerNode();
3971 if (!node) 3974 if (!node)
3972 continue; 3975 continue;
3973 3976
3977 if (isHTMLCanvasElement(node)) {
3978 std::pair<Element*, String> regionInfo = toHTMLCanvasElement(nod e)->getControlAndIDIfHitRegionExists(result.pointInInnerNodeFrame());
3979 if (regionInfo.first)
3980 node = regionInfo.first;
3981 m_regionForTouchID.set(point.id(), regionInfo.second);
3982 }
3983
3974 // Touch events should not go to text nodes 3984 // Touch events should not go to text nodes
3975 if (node->isTextNode()) 3985 if (node->isTextNode())
3976 node = ComposedTreeTraversal::parent(*node); 3986 node = ComposedTreeTraversal::parent(*node);
3977 3987
3978 if (!m_touchSequenceDocument) { 3988 if (!m_touchSequenceDocument) {
3979 // Keep track of which document should receive all touch events 3989 // Keep track of which document should receive all touch events
3980 // in the active sequence. This must be a single document to 3990 // in the active sequence. This must be a single document to
3981 // ensure we don't leak Nodes between documents. 3991 // ensure we don't leak Nodes between documents.
3982 m_touchSequenceDocument = &(result.innerNode()->document()); 3992 m_touchSequenceDocument = &(result.innerNode()->document());
3983 ASSERT(m_touchSequenceDocument->frame()->view()); 3993 ASSERT(m_touchSequenceDocument->frame()->view());
(...skipping 26 matching lines...) Expand all
4010 return WebInputEventResult::NotHandled; 4020 return WebInputEventResult::NotHandled;
4011 } 4021 }
4012 4022
4013 // Compute and store the common info used by both PointerEvent and TouchEven t. 4023 // Compute and store the common info used by both PointerEvent and TouchEven t.
4014 WillBeHeapVector<TouchInfo> touchInfos(points.size()); 4024 WillBeHeapVector<TouchInfo> touchInfos(points.size());
4015 4025
4016 for (unsigned i = 0; i < points.size(); ++i) { 4026 for (unsigned i = 0; i < points.size(); ++i) {
4017 const PlatformTouchPoint& point = points[i]; 4027 const PlatformTouchPoint& point = points[i];
4018 PlatformTouchPoint::State pointState = point.state(); 4028 PlatformTouchPoint::State pointState = point.state();
4019 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr; 4029 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr;
4030 String regionID;
4020 4031
4021 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla tformTouchPoint::TouchCancelled) { 4032 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla tformTouchPoint::TouchCancelled) {
4022 // The target should be the original target for this touch, so get 4033 // The target should be the original target for this touch, so get
4023 // it from the hashmap. As it's a release or cancel we also remove 4034 // it from the hashmap. As it's a release or cancel we also remove
4024 // it from the map. 4035 // it from the map.
4025 touchTarget = m_targetForTouchID.take(point.id()); 4036 touchTarget = m_targetForTouchID.take(point.id());
4037 regionID = m_regionForTouchID.take(point.id());
4026 } else { 4038 } else {
4027 // No hittest is performed on move or stationary, since the target 4039 // No hittest is performed on move or stationary, since the target
4028 // is not allowed to change anyway. 4040 // is not allowed to change anyway.
4029 touchTarget = m_targetForTouchID.get(point.id()); 4041 touchTarget = m_targetForTouchID.get(point.id());
4042 regionID = m_regionForTouchID.get(point.id());
4030 } 4043 }
4031 4044
4032 LocalFrame* targetFrame = nullptr; 4045 LocalFrame* targetFrame = nullptr;
4033 bool knownTarget = false; 4046 bool knownTarget = false;
4034 if (touchTarget) { 4047 if (touchTarget) {
4035 Document& doc = touchTarget->toNode()->document(); 4048 Document& doc = touchTarget->toNode()->document();
4036 // If the target node has moved to a new document while it was being touched, 4049 // If the target node has moved to a new document while it was being touched,
4037 // we can't send events to the new document because that could leak nodes 4050 // we can't send events to the new document because that could leak nodes
4038 // from one document to another. See http://crbug.com/394339. 4051 // from one document to another. See http://crbug.com/394339.
4039 if (&doc == m_touchSequenceDocument.get()) { 4052 if (&doc == m_touchSequenceDocument.get()) {
(...skipping 25 matching lines...) Expand all
4065 float scaleFactor = 1.0f / targetFrame->pageZoomFactor(); 4078 float scaleFactor = 1.0f / targetFrame->pageZoomFactor();
4066 4079
4067 TouchInfo& touchInfo = touchInfos[i]; 4080 TouchInfo& touchInfo = touchInfos[i];
4068 touchInfo.point = point; 4081 touchInfo.point = point;
4069 touchInfo.touchTarget = touchTarget; 4082 touchInfo.touchTarget = touchTarget;
4070 touchInfo.targetFrame = targetFrame; 4083 touchInfo.targetFrame = targetFrame;
4071 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor); 4084 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor);
4072 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor); 4085 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor);
4073 touchInfo.knownTarget = knownTarget; 4086 touchInfo.knownTarget = knownTarget;
4074 touchInfo.consumed = false; 4087 touchInfo.consumed = false;
4088 touchInfo.region = regionID;
4075 } 4089 }
4076 4090
4077 if (!m_inPointerCanceledState) { 4091 if (!m_inPointerCanceledState) {
4078 dispatchPointerEvents(event, touchInfos); 4092 dispatchPointerEvents(event, touchInfos);
4079 // Note that the disposition of any pointer events affects only the gene ration of touch 4093 // Note that the disposition of any pointer events affects only the gene ration of touch
4080 // events. If all pointer events were handled (and hence no touch events were fired), that 4094 // events. If all pointer events were handled (and hence no touch events were fired), that
4081 // is still equivalent to the touch events going unhandled because point er event handler 4095 // is still equivalent to the touch events going unhandled because point er event handler
4082 // don't block scroll gesture generation. 4096 // don't block scroll gesture generation.
4083 } 4097 }
4084 4098
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
4169 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 4183 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
4170 { 4184 {
4171 #if OS(MACOSX) 4185 #if OS(MACOSX)
4172 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 4186 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
4173 #else 4187 #else
4174 return PlatformEvent::AltKey; 4188 return PlatformEvent::AltKey;
4175 #endif 4189 #endif
4176 } 4190 }
4177 4191
4178 } // namespace blink 4192 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698