| 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 f1be4b37d03a6d0ad54fa087c08573ef3f917a14..7dc1242870bcb025d19f4d5d5cf9faaa04309955 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,10 +192,11 @@ EventHandler::EventHandler(LocalFrame* frame)
|
| , m_shouldOnlyFireDragOverEvent(false)
|
| , m_mousePositionIsUnknown(true)
|
| , m_mouseDownTimestamp(0)
|
| - , m_pointerEventManager(frame)
|
| + , m_gestureManager(frame, &m_scrollManager, &m_pointerEventManager, m_selectionController)
|
| + , m_mouseEventManager(frame)
|
| + , m_pointerEventManager(frame, &m_mouseEventManager)
|
| , m_scrollManager(frame)
|
| , m_keyboardEventManager(frame, &m_scrollManager)
|
| - , 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);
|
| }
|
|
|
| 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)
|
| @@ -1184,7 +1154,7 @@ 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().button() == MouseButton::LeftButton)
|
| ? EventTypeNames::click
|
| : EventTypeNames::auxclick,
|
| @@ -1200,7 +1170,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)
|
| @@ -1218,7 +1188,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)
|
| @@ -1477,7 +1447,7 @@ WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy
|
| return WebInputEventResult::NotHandled;
|
|
|
| MouseEvent* event = MouseEvent::create(eventType, m_nodeUnderMouse->document().domWindow(), mouseEvent, clickCount, nullptr);
|
| - return toWebInputEventResult(m_nodeUnderMouse->dispatchEvent(event));
|
| + return EventHandlingUtil::toWebInputEventResult(m_nodeUnderMouse->dispatchEvent(event));
|
| }
|
|
|
| bool EventHandler::isPointerEventActive(int pointerId)
|
| @@ -1662,7 +1632,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;
|
| @@ -1983,7 +1953,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
|
| @@ -2527,21 +2497,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");
|
|
|