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

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

Issue 2255323004: Create MouseEventManager and EventHandlingUtil (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing Created 4 years, 4 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/EventHandler.cpp
diff --git a/third_party/WebKit/Source/core/input/EventHandler.cpp b/third_party/WebKit/Source/core/input/EventHandler.cpp
index b3d05d79c33807ff153a024ffc3580ff1cc56a87..8cb9a412562667d2e9d4c31f3bd5a6c2d30f8812 100644
--- a/third_party/WebKit/Source/core/input/EventHandler.cpp
+++ b/third_party/WebKit/Source/core/input/EventHandler.cpp
@@ -63,6 +63,7 @@
#include "core/html/HTMLFrameElementBase.h"
#include "core/html/HTMLFrameSetElement.h"
#include "core/html/HTMLInputElement.h"
+#include "core/input/EventHandlingUtil.h"
#include "core/input/InputDeviceCapabilities.h"
#include "core/input/TouchActionUtil.h"
#include "core/layout/HitTestRequest.h"
@@ -191,9 +192,10 @@ EventHandler::EventHandler(LocalFrame* frame)
, m_shouldOnlyFireDragOverEvent(false)
, m_mousePositionIsUnknown(true)
, m_mouseDownTimestamp(0)
- , m_pointerEventManager(frame)
, m_scrollManager(frame)
+ , m_mouseEventManager(frame)
, m_keyboardEventManager(frame, &m_scrollManager)
+ , m_pointerEventManager(frame, &m_mouseEventManager)
, m_gestureManager(frame, &m_scrollManager, &m_pointerEventManager, m_selectionController)
, m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired)
{
@@ -221,6 +223,7 @@ DEFINE_TRACE(EventHandler)
visitor->trace(m_scrollManager);
visitor->trace(m_keyboardEventManager);
visitor->trace(m_gestureManager);
+ visitor->trace(m_mouseEventManager);
dtapuska 2016/09/02 03:26:27 The trace should probably happen the order of the
Navid Zolghadr 2016/09/02 16:36:45 Done.
}
DragState& EventHandler::dragState()
@@ -254,6 +257,7 @@ void EventHandler::clear()
m_pointerEventManager.clear();
m_scrollManager.clear();
m_gestureManager.clear();
+ m_mouseEventManager.clear();
m_mouseDownMayStartDrag = false;
m_lastDeferredTapElement = nullptr;
m_eventHandlerWillResetCapturingMouseEventsNode = false;
@@ -265,40 +269,6 @@ void EventHandler::clear()
m_mouseDown = PlatformMouseEvent();
}
-WebInputEventResult EventHandler::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 EventHandler::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:
- ASSERT_NOT_REACHED();
- return WebInputEventResult::HandledSystem;
- }
-}
-
void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved)
{
if (nodeToBeRemoved.isShadowIncludingInclusiveAncestorOf(m_clickNode.get())) {
@@ -868,7 +838,7 @@ WebInputEventResult EventHandler::handleMousePressEvent(const PlatformMouseEvent
// dragging if we keep the selection in case of mousedown. FireFox also has
// the same behavior and it's more compatible with other browsers.
selectionController().initializeSelectionState();
- HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, HitTestRequest::ReadOnly);
+ HitTestResult hitTestResult = EventHandlingUtil::hitTestResultInFrame(m_frame, documentPoint, HitTestRequest::ReadOnly);
InputDeviceCapabilities* sourceCapabilities = mouseEvent.getSyntheticEventType() == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEventsSourceCapabilities() :
InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities();
if (eventResult == WebInputEventResult::NotHandled)
@@ -1186,7 +1156,8 @@ WebInputEventResult EventHandler::handleMouseReleaseEvent(const PlatformMouseEve
// because the mouseup dispatch above has already updated it
// correctly. Moreover, clickTargetNode is different from
// mev.innerNode at drag-release.
- clickEventResult = toWebInputEventResult(clickTargetNode->dispatchMouseEvent(mev.event(),
+ clickEventResult = EventHandlingUtil::toWebInputEventResult(
+ clickTargetNode->dispatchMouseEvent(mev.event(),
!RuntimeEnabledFeatures::auxclickEnabled()
|| (mev.event().pointerProperties().button == WebPointerProperties::Button::Left)
? EventTypeNames::click
@@ -1203,7 +1174,7 @@ WebInputEventResult EventHandler::handleMouseReleaseEvent(const PlatformMouseEve
invalidateClick();
- return mergeEventResult(clickEventResult, eventResult);
+ return EventHandlingUtil::mergeEventResult(clickEventResult, eventResult);
}
WebInputEventResult EventHandler::dispatchDragEvent(const AtomicString& eventType, Node* dragTarget, const PlatformMouseEvent& event, DataTransfer* dataTransfer)
@@ -1221,7 +1192,7 @@ WebInputEventResult EventHandler::dispatchDragEvent(const AtomicString& eventTyp
event.getModifiers(),
0, MouseEvent::platformModifiersToButtons(event.getModifiers()), nullptr, event.timestamp(), dataTransfer, event.getSyntheticEventType());
- return toWebInputEventResult(dragTarget->dispatchEvent(me));
+ return EventHandlingUtil::toWebInputEventResult(dragTarget->dispatchEvent(me));
}
static bool targetIsFrame(Node* target, LocalFrame*& frame)
@@ -1476,11 +1447,9 @@ void EventHandler::updateMouseEventTargetNodeAndSendEvents(Node* targetNode,
WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent)
mustaq 2016/08/30 21:49:23 The only EventHandler state this function uses is
Navid Zolghadr 2016/08/31 14:23:48 I planned to do these in the next CL if you are ok
{
updateMouseEventTargetNodeAndSendEvents(targetNode, mouseEvent);
- if (!m_nodeUnderMouse)
- return WebInputEventResult::NotHandled;
- MouseEvent* event = MouseEvent::create(eventType, m_nodeUnderMouse->document().domWindow(), mouseEvent, clickCount, nullptr);
- return toWebInputEventResult(m_nodeUnderMouse->dispatchEvent(event));
+ return m_mouseEventManager.dispatchMouseEvent(m_nodeUnderMouse, eventType,
+ mouseEvent, nullptr, clickCount);
}
bool EventHandler::isPointerEventActive(int pointerId)
@@ -1667,7 +1636,7 @@ WebInputEventResult EventHandler::handleWheelEvent(const PlatformWheelEvent& eve
WheelEvent* domEvent = WheelEvent::create(event, node->document().domWindow());
DispatchEventResult domEventResult = node->dispatchEvent(domEvent);
if (domEventResult != DispatchEventResult::NotCanceled)
- return toWebInputEventResult(domEventResult);
+ return EventHandlingUtil::toWebInputEventResult(domEventResult);
}
return WebInputEventResult::NotHandled;
@@ -1988,7 +1957,7 @@ GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(const
LocalFrame* hitFrame = hitTestResult.innerNodeFrame();
if (!hitFrame)
hitFrame = m_frame;
- hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->rootFrameToContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~HitTestRequest::ListBased);
+ hitTestResult = EventHandlingUtil::hitTestResultInFrame(hitFrame, hitFrame->view()->rootFrameToContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~HitTestRequest::ListBased);
}
// If we did a rect-based hit test it must be resolved to the best single node by now to
@@ -2536,21 +2505,6 @@ void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, bool setL
}
}
-HitTestResult EventHandler::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 EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
{
TRACE_EVENT0("blink", "EventHandler::handleTouchEvent");

Powered by Google App Engine
This is Rietveld 408576698