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

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

Issue 2350433002: Extract more of the mouse logic from EventHandler (Closed)
Patch Set: Yet another rebase because of a presubmit rule bug Created 4 years, 2 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/EventHandlingUtil.h" 5 #include "core/input/EventHandlingUtil.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/LocalFrame.h"
8 #include "core/layout/api/LayoutViewItem.h" 9 #include "core/layout/api/LayoutViewItem.h"
10 #include "core/paint/PaintLayer.h"
11 #include "platform/scroll/ScrollableArea.h"
9 12
10 namespace blink { 13 namespace blink {
11 namespace EventHandlingUtil { 14 namespace EventHandlingUtil {
12 15
13 HitTestResult hitTestResultInFrame(LocalFrame* frame, 16 HitTestResult hitTestResultInFrame(LocalFrame* frame,
14 const LayoutPoint& point, 17 const LayoutPoint& point,
15 HitTestRequest::HitTestRequestType hitType) { 18 HitTestRequest::HitTestRequestType hitType) {
16 HitTestResult result(HitTestRequest(hitType), point); 19 HitTestResult result(HitTestRequest(hitType), point);
17 20
18 if (!frame || frame->contentLayoutItem().isNull()) 21 if (!frame || frame->contentLayoutItem().isNull())
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 case DispatchEventResult::CanceledByDefaultEventHandler: 59 case DispatchEventResult::CanceledByDefaultEventHandler:
57 return WebInputEventResult::HandledSystem; 60 return WebInputEventResult::HandledSystem;
58 case DispatchEventResult::CanceledBeforeDispatch: 61 case DispatchEventResult::CanceledBeforeDispatch:
59 return WebInputEventResult::HandledSuppressed; 62 return WebInputEventResult::HandledSuppressed;
60 default: 63 default:
61 NOTREACHED(); 64 NOTREACHED();
62 return WebInputEventResult::HandledSystem; 65 return WebInputEventResult::HandledSystem;
63 } 66 }
64 } 67 }
65 68
69 PaintLayer* layerForNode(Node* node) {
70 if (!node)
71 return nullptr;
72
73 LayoutObject* layoutObject = node->layoutObject();
74 if (!layoutObject)
75 return nullptr;
76
77 PaintLayer* layer = layoutObject->enclosingLayer();
78 if (!layer)
79 return nullptr;
80
81 return layer;
82 }
83
84 ScrollableArea* associatedScrollableArea(const PaintLayer* layer) {
85 if (PaintLayerScrollableArea* scrollableArea = layer->getScrollableArea()) {
86 if (scrollableArea->scrollsOverflow())
87 return scrollableArea;
88 }
89
90 return nullptr;
91 }
92
93 ContainerNode* parentForClickEvent(const Node& node) {
94 // IE doesn't dispatch click events for mousedown/mouseup events across form
95 // controls.
96 if (node.isHTMLElement() && toHTMLElement(node).isInteractiveContent())
97 return nullptr;
98
99 return FlatTreeTraversal::parent(node);
100 }
101
102 LayoutPoint contentPointFromRootFrame(LocalFrame* frame,
103 const IntPoint& pointInRootFrame) {
104 FrameView* view = frame->view();
105 // FIXME: Is it really OK to use the wrong coordinates here when view is 0?
106 // Historically the code would just crash; this is clearly no worse than that.
107 return view ? view->rootFrameToContents(pointInRootFrame) : pointInRootFrame;
108 }
109
110 MouseEventWithHitTestResults performMouseEventHitTest(
111 LocalFrame* frame,
112 const HitTestRequest& request,
113 const PlatformMouseEvent& mev) {
114 DCHECK(frame);
115 DCHECK(frame->document());
116
117 return frame->document()->performMouseEventHitTest(
118 request, contentPointFromRootFrame(frame, mev.position()), mev);
119 }
120
66 } // namespace EventHandlingUtil 121 } // namespace EventHandlingUtil
67 } // namespace blink 122 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandlingUtil.h ('k') | third_party/WebKit/Source/core/input/GestureManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698