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

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: Created 4 years, 9 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 visitor->trace(m_resizeScrollableArea); 282 visitor->trace(m_resizeScrollableArea);
282 visitor->trace(m_capturingMouseEventsNode); 283 visitor->trace(m_capturingMouseEventsNode);
283 visitor->trace(m_nodeUnderMouse); 284 visitor->trace(m_nodeUnderMouse);
284 visitor->trace(m_lastMouseMoveEventSubframe); 285 visitor->trace(m_lastMouseMoveEventSubframe);
285 visitor->trace(m_lastScrollbarUnderMouse); 286 visitor->trace(m_lastScrollbarUnderMouse);
286 visitor->trace(m_clickNode); 287 visitor->trace(m_clickNode);
287 visitor->trace(m_dragTarget); 288 visitor->trace(m_dragTarget);
288 visitor->trace(m_frameSetBeingResized); 289 visitor->trace(m_frameSetBeingResized);
289 visitor->trace(m_scrollbarHandlingScrollGesture); 290 visitor->trace(m_scrollbarHandlingScrollGesture);
290 visitor->trace(m_targetForTouchID); 291 visitor->trace(m_targetForTouchID);
292 visitor->trace(m_regionForTouchID);
291 visitor->trace(m_touchSequenceDocument); 293 visitor->trace(m_touchSequenceDocument);
292 visitor->trace(m_scrollGestureHandlingNode); 294 visitor->trace(m_scrollGestureHandlingNode);
293 visitor->trace(m_previousGestureScrolledNode); 295 visitor->trace(m_previousGestureScrolledNode);
294 visitor->trace(m_lastDeferredTapElement); 296 visitor->trace(m_lastDeferredTapElement);
295 visitor->trace(m_selectionController); 297 visitor->trace(m_selectionController);
296 visitor->trace(m_pointerEventManager); 298 visitor->trace(m_pointerEventManager);
297 #endif 299 #endif
298 } 300 }
299 301
300 DragState& EventHandler::dragState() 302 DragState& EventHandler::dragState()
(...skipping 3378 matching lines...) Expand 10 before | Expand all | Expand 10 after
3679 continue; 3681 continue;
3680 3682
3681 RefPtrWillBeRawPtr<Touch> touch = Touch::create( 3683 RefPtrWillBeRawPtr<Touch> touch = Touch::create(
3682 touchInfo.targetFrame.get(), 3684 touchInfo.targetFrame.get(),
3683 touchInfo.touchTarget.get(), 3685 touchInfo.touchTarget.get(),
3684 point.id(), 3686 point.id(),
3685 point.screenPos(), 3687 point.screenPos(),
3686 touchInfo.adjustedPagePoint, 3688 touchInfo.adjustedPagePoint,
3687 touchInfo.adjustedRadius, 3689 touchInfo.adjustedRadius,
3688 point.rotationAngle(), 3690 point.rotationAngle(),
3689 point.force()); 3691 point.force(),
3692 touchInfo.region);
3690 3693
3691 // Ensure this target's touch list exists, even if it ends up empty, so 3694 // Ensure this target's touch list exists, even if it ends up empty, so
3692 // it can always be passed to TouchEvent::Create below. 3695 // it can always be passed to TouchEvent::Create below.
3693 TargetTouchesHeapMap::iterator targetTouchesIterator = touchesByTarget.f ind(touchInfo.touchTarget.get()); 3696 TargetTouchesHeapMap::iterator targetTouchesIterator = touchesByTarget.f ind(touchInfo.touchTarget.get());
3694 if (targetTouchesIterator == touchesByTarget.end()) { 3697 if (targetTouchesIterator == touchesByTarget.end()) {
3695 touchesByTarget.set(touchInfo.touchTarget.get(), TouchList::create() ); 3698 touchesByTarget.set(touchInfo.touchTarget.get(), TouchList::create() );
3696 targetTouchesIterator = touchesByTarget.find(touchInfo.touchTarget.g et()); 3699 targetTouchesIterator = touchesByTarget.find(touchInfo.touchTarget.g et());
3697 } 3700 }
3698 3701
3699 // touches and targetTouches should only contain information about 3702 // touches and targetTouches should only contain information about
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3805 LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocum ent->frame()->view()->rootFrameToContents(point.pos())); 3808 LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocum ent->frame()->view()->rootFrameToContents(point.pos()));
3806 result = hitTestResultInFrame(m_touchSequenceDocument->frame(), framePoint, hitType); 3809 result = hitTestResultInFrame(m_touchSequenceDocument->frame(), framePoint, hitType);
3807 } else { 3810 } else {
3808 continue; 3811 continue;
3809 } 3812 }
3810 3813
3811 Node* node = result.innerNode(); 3814 Node* node = result.innerNode();
3812 if (!node) 3815 if (!node)
3813 continue; 3816 continue;
3814 3817
3818 if (isHTMLCanvasElement(node)) {
3819 std::pair<Element*, String> regionInfo = toHTMLCanvasElement(nod e)->getControlAndIdIfHitRegionExists(result.pointInInnerNodeFrame());
3820 if (regionInfo.first)
3821 node = regionInfo.first;
3822 m_regionForTouchID.set(point.id(), regionInfo.second);
3823 }
3824
3815 // Touch events should not go to text nodes 3825 // Touch events should not go to text nodes
3816 if (node->isTextNode()) 3826 if (node->isTextNode())
3817 node = FlatTreeTraversal::parent(*node); 3827 node = FlatTreeTraversal::parent(*node);
3818 3828
3819 if (!m_touchSequenceDocument) { 3829 if (!m_touchSequenceDocument) {
3820 // Keep track of which document should receive all touch events 3830 // Keep track of which document should receive all touch events
3821 // in the active sequence. This must be a single document to 3831 // in the active sequence. This must be a single document to
3822 // ensure we don't leak Nodes between documents. 3832 // ensure we don't leak Nodes between documents.
3823 m_touchSequenceDocument = &(result.innerNode()->document()); 3833 m_touchSequenceDocument = &(result.innerNode()->document());
3824 ASSERT(m_touchSequenceDocument->frame()->view()); 3834 ASSERT(m_touchSequenceDocument->frame()->view());
(...skipping 26 matching lines...) Expand all
3851 return WebInputEventResult::NotHandled; 3861 return WebInputEventResult::NotHandled;
3852 } 3862 }
3853 3863
3854 // Compute and store the common info used by both PointerEvent and TouchEven t. 3864 // Compute and store the common info used by both PointerEvent and TouchEven t.
3855 WillBeHeapVector<TouchInfo> touchInfos(points.size()); 3865 WillBeHeapVector<TouchInfo> touchInfos(points.size());
3856 3866
3857 for (unsigned i = 0; i < points.size(); ++i) { 3867 for (unsigned i = 0; i < points.size(); ++i) {
3858 const PlatformTouchPoint& point = points[i]; 3868 const PlatformTouchPoint& point = points[i];
3859 PlatformTouchPoint::TouchState pointState = point.state(); 3869 PlatformTouchPoint::TouchState pointState = point.state();
3860 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr; 3870 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr;
3871 String regionID;
3861 3872
3862 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla tformTouchPoint::TouchCancelled) { 3873 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla tformTouchPoint::TouchCancelled) {
3863 // The target should be the original target for this touch, so get 3874 // The target should be the original target for this touch, so get
3864 // it from the hashmap. As it's a release or cancel we also remove 3875 // it from the hashmap. As it's a release or cancel we also remove
3865 // it from the map. 3876 // it from the map.
3866 touchTarget = m_targetForTouchID.take(point.id()); 3877 touchTarget = m_targetForTouchID.take(point.id());
3878 regionID = m_regionForTouchID.take(point.id());
3867 } else { 3879 } else {
3868 // No hittest is performed on move or stationary, since the target 3880 // No hittest is performed on move or stationary, since the target
3869 // is not allowed to change anyway. 3881 // is not allowed to change anyway.
3870 touchTarget = m_targetForTouchID.get(point.id()); 3882 touchTarget = m_targetForTouchID.get(point.id());
3883 regionID = m_regionForTouchID.get(point.id());
3871 } 3884 }
3872 3885
3873 LocalFrame* targetFrame = nullptr; 3886 LocalFrame* targetFrame = nullptr;
3874 bool knownTarget = false; 3887 bool knownTarget = false;
3875 if (touchTarget) { 3888 if (touchTarget) {
3876 Document& doc = touchTarget->toNode()->document(); 3889 Document& doc = touchTarget->toNode()->document();
3877 // If the target node has moved to a new document while it was being touched, 3890 // If the target node has moved to a new document while it was being touched,
3878 // we can't send events to the new document because that could leak nodes 3891 // we can't send events to the new document because that could leak nodes
3879 // from one document to another. See http://crbug.com/394339. 3892 // from one document to another. See http://crbug.com/394339.
3880 if (&doc == m_touchSequenceDocument.get()) { 3893 if (&doc == m_touchSequenceDocument.get()) {
(...skipping 25 matching lines...) Expand all
3906 float scaleFactor = 1.0f / targetFrame->pageZoomFactor(); 3919 float scaleFactor = 1.0f / targetFrame->pageZoomFactor();
3907 3920
3908 TouchInfo& touchInfo = touchInfos[i]; 3921 TouchInfo& touchInfo = touchInfos[i];
3909 touchInfo.point = point; 3922 touchInfo.point = point;
3910 touchInfo.touchTarget = touchTarget; 3923 touchInfo.touchTarget = touchTarget;
3911 touchInfo.targetFrame = targetFrame; 3924 touchInfo.targetFrame = targetFrame;
3912 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor); 3925 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor);
3913 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor); 3926 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor);
3914 touchInfo.knownTarget = knownTarget; 3927 touchInfo.knownTarget = knownTarget;
3915 touchInfo.consumed = false; 3928 touchInfo.consumed = false;
3929 touchInfo.region = regionID;
3916 } 3930 }
3917 3931
3918 if (!m_inPointerCanceledState) { 3932 if (!m_inPointerCanceledState) {
3919 dispatchPointerEvents(event, touchInfos); 3933 dispatchPointerEvents(event, touchInfos);
3920 // Note that the disposition of any pointer events affects only the gene ration of touch 3934 // Note that the disposition of any pointer events affects only the gene ration of touch
3921 // events. If all pointer events were handled (and hence no touch events were fired), that 3935 // events. If all pointer events were handled (and hence no touch events were fired), that
3922 // is still equivalent to the touch events going unhandled because point er event handler 3936 // is still equivalent to the touch events going unhandled because point er event handler
3923 // don't block scroll gesture generation. 3937 // don't block scroll gesture generation.
3924 } 3938 }
3925 3939
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3994 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 4008 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
3995 { 4009 {
3996 #if OS(MACOSX) 4010 #if OS(MACOSX)
3997 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 4011 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
3998 #else 4012 #else
3999 return PlatformEvent::AltKey; 4013 return PlatformEvent::AltKey;
4000 #endif 4014 #endif
4001 } 4015 }
4002 4016
4003 } // namespace blink 4017 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698