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 #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/layout/api/LayoutViewItem.h" | 8 #include "core/layout/api/LayoutViewItem.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 case DispatchEventResult::CanceledByDefaultEventHandler: | 52 case DispatchEventResult::CanceledByDefaultEventHandler: |
53 return WebInputEventResult::HandledSystem; | 53 return WebInputEventResult::HandledSystem; |
54 case DispatchEventResult::CanceledBeforeDispatch: | 54 case DispatchEventResult::CanceledBeforeDispatch: |
55 return WebInputEventResult::HandledSuppressed; | 55 return WebInputEventResult::HandledSuppressed; |
56 default: | 56 default: |
57 NOTREACHED(); | 57 NOTREACHED(); |
58 return WebInputEventResult::HandledSystem; | 58 return WebInputEventResult::HandledSystem; |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
| 62 PaintLayer* layerForNode(Node* node) |
| 63 { |
| 64 if (!node) |
| 65 return nullptr; |
| 66 |
| 67 LayoutObject* layoutObject = node->layoutObject(); |
| 68 if (!layoutObject) |
| 69 return nullptr; |
| 70 |
| 71 PaintLayer* layer = layoutObject->enclosingLayer(); |
| 72 if (!layer) |
| 73 return nullptr; |
| 74 |
| 75 return layer; |
| 76 } |
| 77 |
| 78 ScrollableArea* associatedScrollableArea(const PaintLayer* layer) |
| 79 { |
| 80 if (PaintLayerScrollableArea* scrollableArea = layer->getScrollableArea()) { |
| 81 if (scrollableArea->scrollsOverflow()) |
| 82 return scrollableArea; |
| 83 } |
| 84 |
| 85 return nullptr; |
| 86 } |
| 87 |
| 88 ContainerNode* parentForClickEvent(const Node& node) |
| 89 { |
| 90 // IE doesn't dispatch click events for mousedown/mouseup events across form |
| 91 // controls. |
| 92 if (node.isHTMLElement() && toHTMLElement(node).isInteractiveContent()) |
| 93 return nullptr; |
| 94 |
| 95 return FlatTreeTraversal::parent(node); |
| 96 } |
| 97 |
| 98 LayoutPoint contentPointFromRootFrame(LocalFrame* frame, const IntPoint& pointIn
RootFrame) |
| 99 { |
| 100 FrameView* view = frame->view(); |
| 101 // FIXME: Is it really OK to use the wrong coordinates here when view is 0? |
| 102 // Historically the code would just crash; this is clearly no worse than tha
t. |
| 103 return view ? view->rootFrameToContents(pointInRootFrame) : pointInRootFrame
; |
| 104 } |
| 105 |
| 106 MouseEventWithHitTestResults performMouseEventHitTest(LocalFrame* frame, |
| 107 const HitTestRequest& request, const PlatformMouseEvent& mev) |
| 108 { |
| 109 DCHECK(frame); |
| 110 DCHECK(frame->document()); |
| 111 |
| 112 return frame->document()->performMouseEventHitTest(request, contentPointFrom
RootFrame(frame, mev.position()), mev); |
| 113 } |
| 114 |
62 } // namespace EventHandlingUtil | 115 } // namespace EventHandlingUtil |
63 } // namespace blink | 116 } // namespace blink |
OLD | NEW |