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

Unified Diff: third_party/WebKit/Source/core/input/EventHandlingUtil.cpp

Issue 2255323004: Create MouseEventManager and EventHandlingUtil (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/input/EventHandlingUtil.cpp
diff --git a/third_party/WebKit/Source/core/input/EventHandlingUtil.cpp b/third_party/WebKit/Source/core/input/EventHandlingUtil.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fcc2707690d6535de8476b756c65c94ef6b9686e
--- /dev/null
+++ b/third_party/WebKit/Source/core/input/EventHandlingUtil.cpp
@@ -0,0 +1,62 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/input/EventHandlingUtil.h"
+
+#include "core/frame/FrameView.h"
+
+namespace blink {
+namespace EventHandlingUtil {
+
+HitTestResult hitTestResultInFrame(LocalFrame* frame, const LayoutPoint& point, HitTestRequest::HitTestRequestType hitType)
+{
+ HitTestResult result(HitTestRequest(hitType), point);
+
+ if (!frame || frame->contentLayoutItem().isNull())
+ return result;
+ if (frame->view()) {
+ IntRect rect = frame->view()->visibleContentRect(IncludeScrollbars);
+ if (!rect.contains(roundedIntPoint(point)))
+ return result;
+ }
+ frame->contentLayoutItem().hitTest(result);
+ return result;
+}
+
+WebInputEventResult mergeEventResult(
+ WebInputEventResult resultA, WebInputEventResult resultB)
+{
+ // The ordering of the enumeration is specific. There are times that
+ // multiple events fire and we need to combine them into a single
+ // result code. The enumeration is based on the level of consumption that
+ // is most significant. The enumeration is ordered with smaller specified
+ // numbers first. Examples of merged results are:
+ // (HandledApplication, HandledSystem) -> HandledSystem
+ // (NotHandled, HandledApplication) -> HandledApplication
+ static_assert(static_cast<int>(WebInputEventResult::NotHandled) == 0, "WebInputEventResult not ordered");
+ static_assert(static_cast<int>(WebInputEventResult::HandledSuppressed) < static_cast<int>(WebInputEventResult::HandledApplication), "WebInputEventResult not ordered");
+ static_assert(static_cast<int>(WebInputEventResult::HandledApplication) < static_cast<int>(WebInputEventResult::HandledSystem), "WebInputEventResult not ordered");
+ return static_cast<WebInputEventResult>(max(static_cast<int>(resultA), static_cast<int>(resultB)));
+}
+
+WebInputEventResult toWebInputEventResult(
+ DispatchEventResult result)
+{
+ switch (result) {
+ case DispatchEventResult::NotCanceled:
+ return WebInputEventResult::NotHandled;
+ case DispatchEventResult::CanceledByEventHandler:
+ return WebInputEventResult::HandledApplication;
+ case DispatchEventResult::CanceledByDefaultEventHandler:
+ return WebInputEventResult::HandledSystem;
+ case DispatchEventResult::CanceledBeforeDispatch:
+ return WebInputEventResult::HandledSuppressed;
+ default:
+ NOTREACHED();
+ return WebInputEventResult::HandledSystem;
+ }
+}
+
+} // namespace EventHandlingUtil
+} // namespace blink
« 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