| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/input/EventHandlingUtil.h" |
| 6 |
| 7 #include "core/frame/FrameView.h" |
| 8 |
| 9 namespace blink { |
| 10 namespace EventHandlingUtil { |
| 11 |
| 12 HitTestResult hitTestResultInFrame(LocalFrame* frame, const LayoutPoint& point,
HitTestRequest::HitTestRequestType hitType) |
| 13 { |
| 14 HitTestResult result(HitTestRequest(hitType), point); |
| 15 |
| 16 if (!frame || frame->contentLayoutItem().isNull()) |
| 17 return result; |
| 18 if (frame->view()) { |
| 19 IntRect rect = frame->view()->visibleContentRect(IncludeScrollbars); |
| 20 if (!rect.contains(roundedIntPoint(point))) |
| 21 return result; |
| 22 } |
| 23 frame->contentLayoutItem().hitTest(result); |
| 24 return result; |
| 25 } |
| 26 |
| 27 WebInputEventResult mergeEventResult( |
| 28 WebInputEventResult resultA, WebInputEventResult resultB) |
| 29 { |
| 30 // The ordering of the enumeration is specific. There are times that |
| 31 // multiple events fire and we need to combine them into a single |
| 32 // result code. The enumeration is based on the level of consumption that |
| 33 // is most significant. The enumeration is ordered with smaller specified |
| 34 // numbers first. Examples of merged results are: |
| 35 // (HandledApplication, HandledSystem) -> HandledSystem |
| 36 // (NotHandled, HandledApplication) -> HandledApplication |
| 37 static_assert(static_cast<int>(WebInputEventResult::NotHandled) == 0, "WebIn
putEventResult not ordered"); |
| 38 static_assert(static_cast<int>(WebInputEventResult::HandledSuppressed) < sta
tic_cast<int>(WebInputEventResult::HandledApplication), "WebInputEventResult not
ordered"); |
| 39 static_assert(static_cast<int>(WebInputEventResult::HandledApplication) < st
atic_cast<int>(WebInputEventResult::HandledSystem), "WebInputEventResult not ord
ered"); |
| 40 return static_cast<WebInputEventResult>(max(static_cast<int>(resultA), stati
c_cast<int>(resultB))); |
| 41 } |
| 42 |
| 43 WebInputEventResult toWebInputEventResult( |
| 44 DispatchEventResult result) |
| 45 { |
| 46 switch (result) { |
| 47 case DispatchEventResult::NotCanceled: |
| 48 return WebInputEventResult::NotHandled; |
| 49 case DispatchEventResult::CanceledByEventHandler: |
| 50 return WebInputEventResult::HandledApplication; |
| 51 case DispatchEventResult::CanceledByDefaultEventHandler: |
| 52 return WebInputEventResult::HandledSystem; |
| 53 case DispatchEventResult::CanceledBeforeDispatch: |
| 54 return WebInputEventResult::HandledSuppressed; |
| 55 default: |
| 56 NOTREACHED(); |
| 57 return WebInputEventResult::HandledSystem; |
| 58 } |
| 59 } |
| 60 |
| 61 } // namespace EventHandlingUtil |
| 62 } // namespace blink |
| OLD | NEW |