diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp index da5e6752a16732..16c6f1902d77b9 100644 --- a/third_party/WebKit/Source/core/dom/Document.cpp +++ b/third_party/WebKit/Source/core/dom/Document.cpp @@ -3542,7 +3542,7 @@ ReferrerPolicy Document::getReferrerPolicy() const { MouseEventWithHitTestResults Document::performMouseEventHitTest( const HitTestRequest& request, const LayoutPoint& documentPoint, - const PlatformMouseEvent& event) { + const WebMouseEvent& event) { DCHECK(layoutViewItem().isNull() || layoutViewItem().isLayoutView()); // LayoutView::hitTest causes a layout, and we don't want to hit that until @@ -3562,15 +3562,13 @@ MouseEventWithHitTestResults Document::performMouseEventHitTest( updateHoverActiveState(request, result.innerElement(), result.scrollbar()); if (isHTMLCanvasElement(result.innerNode())) { - PlatformMouseEvent eventWithRegion = event; HitTestCanvasResult* hitTestCanvasResult = toHTMLCanvasElement(result.innerNode()) ->getControlAndIdIfHitRegionExists(result.pointInInnerNodeFrame()); if (hitTestCanvasResult->getControl()) { result.setInnerNode(hitTestCanvasResult->getControl()); } - eventWithRegion.setRegion(hitTestCanvasResult->getId()); - return MouseEventWithHitTestResults(eventWithRegion, result); + result.setCanvasRegionId(hitTestCanvasResult->getId()); } return MouseEventWithHitTestResults(event, result); diff --git a/third_party/WebKit/Source/core/dom/Document.h b/third_party/WebKit/Source/core/dom/Document.h index a46b828b0d4250..746f7f59f8d1f3 100644 --- a/third_party/WebKit/Source/core/dom/Document.h +++ b/third_party/WebKit/Source/core/dom/Document.h @@ -141,7 +141,6 @@ class NodeIterator; class NthIndexCache; class OriginAccessEntry; class Page; -class PlatformMouseEvent; class ProcessingInstruction; class PropertyRegistry; class QualifiedName; @@ -172,12 +171,12 @@ class TouchList; class TransformSource; class TreeWalker; class VisitedLinkState; +class WebMouseEvent; struct AnnotatedRegionValue; struct FocusParams; struct IconURL; -using MouseEventWithHitTestResults = - EventWithHitTestResults; +using MouseEventWithHitTestResults = EventWithHitTestResults; using ExceptionCode = int; enum NodeListInvalidationType { @@ -687,10 +686,9 @@ class CORE_EXPORT Document : public ContainerNode, TextLinkColors& textLinkColors() { return m_textLinkColors; } VisitedLinkState& visitedLinkState() const { return *m_visitedLinkState; } - MouseEventWithHitTestResults performMouseEventHitTest( - const HitTestRequest&, - const LayoutPoint&, - const PlatformMouseEvent&); + MouseEventWithHitTestResults performMouseEventHitTest(const HitTestRequest&, + const LayoutPoint&, + const WebMouseEvent&); /* Newly proposed CSS3 mechanism for selecting alternate stylesheets using the DOM. May be subject to change as diff --git a/third_party/WebKit/Source/core/dom/Node.cpp b/third_party/WebKit/Source/core/dom/Node.cpp index 66fb351cd033a4..0c491557b80f31 100644 --- a/third_party/WebKit/Source/core/dom/Node.cpp +++ b/third_party/WebKit/Source/core/dom/Node.cpp @@ -2119,7 +2119,7 @@ DispatchEventResult Node::dispatchDOMActivateEvent(int detail, } void Node::createAndDispatchPointerEvent(const AtomicString& mouseEventName, - const PlatformMouseEvent& mouseEvent, + const WebMouseEvent& mouseEvent, LocalDOMWindow* view) { AtomicString pointerEventName; if (mouseEventName == EventTypeNames::mousemove) @@ -2137,22 +2137,22 @@ void Node::createAndDispatchPointerEvent(const AtomicString& mouseEventName, pointerEventInit.setPointerType("mouse"); pointerEventInit.setIsPrimary(true); pointerEventInit.setButtons( - MouseEvent::platformModifiersToButtons(mouseEvent.getModifiers())); + MouseEvent::platformModifiersToButtons(mouseEvent.modifiers())); pointerEventInit.setBubbles(true); pointerEventInit.setCancelable(true); pointerEventInit.setComposed(true); pointerEventInit.setDetail(0); - pointerEventInit.setScreenX(mouseEvent.globalPosition().x()); - pointerEventInit.setScreenY(mouseEvent.globalPosition().y()); + pointerEventInit.setScreenX(mouseEvent.globalX); + pointerEventInit.setScreenY(mouseEvent.globalY); IntPoint locationInFrameZoomed; if (view && view->frame() && view->frame()->view()) { LocalFrame* frame = view->frame(); FrameView* frameView = frame->view(); - IntPoint locationInContents = - frameView->rootFrameToContents(mouseEvent.position()); + IntPoint locationInContents = frameView->rootFrameToContents( + flooredIntPoint(mouseEvent.positionInRootFrame())); locationInFrameZoomed = frameView->contentsToFrame(locationInContents); float scaleFactor = 1 / frame->pageZoomFactor(); locationInFrameZoomed.scale(scaleFactor, scaleFactor); @@ -2164,28 +2164,30 @@ void Node::createAndDispatchPointerEvent(const AtomicString& mouseEventName, if (pointerEventName == EventTypeNames::pointerdown || pointerEventName == EventTypeNames::pointerup) { - pointerEventInit.setButton( - static_cast(mouseEvent.pointerProperties().button)); + pointerEventInit.setButton(static_cast(mouseEvent.button)); } else { pointerEventInit.setButton( static_cast(WebPointerProperties::Button::NoButton)); } - UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit, - mouseEvent.getModifiers()); + UIEventWithKeyState::setFromWebInputEventModifiers( + pointerEventInit, + static_cast(mouseEvent.modifiers())); pointerEventInit.setView(view); dispatchEvent(PointerEvent::create(pointerEventName, pointerEventInit)); } -void Node::dispatchMouseEvent(const PlatformMouseEvent& nativeEvent, +void Node::dispatchMouseEvent(const WebMouseEvent& nativeEvent, const AtomicString& mouseEventType, int detail, + const String& canvasRegionId, Node* relatedTarget) { createAndDispatchPointerEvent(mouseEventType, nativeEvent, document().domWindow()); dispatchEvent(MouseEvent::create(mouseEventType, document().domWindow(), - nativeEvent, detail, relatedTarget)); + nativeEvent, detail, canvasRegionId, + relatedTarget)); } void Node::dispatchSimulatedClick(Event* underlyingEvent, diff --git a/third_party/WebKit/Source/core/dom/Node.h b/third_party/WebKit/Source/core/dom/Node.h index c02e8527d0a984..48f16d982ecc79 100644 --- a/third_party/WebKit/Source/core/dom/Node.h +++ b/third_party/WebKit/Source/core/dom/Node.h @@ -60,7 +60,6 @@ class EventDispatchHandlingState; class NodeList; class NodeListsNodeData; class NodeRareData; -class PlatformMouseEvent; class QualifiedName; class RegisteredEventListener; class LayoutBox; @@ -74,6 +73,7 @@ class StaticNodeTypeList; using StaticNodeList = StaticNodeTypeList; class StyleChangeReasonForTracing; class Text; +class WebMouseEvent; const int nodeStyleChangeShift = 18; const int nodeCustomElementShift = 20; @@ -717,9 +717,10 @@ class CORE_EXPORT Node : public EventTarget { DispatchEventResult dispatchDOMActivateEvent(int detail, Event& underlyingEvent); - void dispatchMouseEvent(const PlatformMouseEvent&, + void dispatchMouseEvent(const WebMouseEvent&, const AtomicString& eventType, int clickCount = 0, + const String& canvasNodeId = String(), Node* relatedTarget = nullptr); void dispatchSimulatedClick( @@ -842,10 +843,10 @@ class CORE_EXPORT Node : public EventTarget { void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; } // TODO(mustaq): This is a hack to fix sites with flash objects. We should - // instead route all PlatformMouseEvents through EventHandler. See + // instead route all WebMouseEvents through EventHandler. See // crbug.com/665924. void createAndDispatchPointerEvent(const AtomicString& mouseEventName, - const PlatformMouseEvent&, + const WebMouseEvent&, LocalDOMWindow* view); protected: diff --git a/third_party/WebKit/Source/core/editing/SelectionController.cpp b/third_party/WebKit/Source/core/editing/SelectionController.cpp index 390e6def00fd5f..b798e6497b6c6e 100644 --- a/third_party/WebKit/Source/core/editing/SelectionController.cpp +++ b/third_party/WebKit/Source/core/editing/SelectionController.cpp @@ -180,8 +180,8 @@ bool SelectionController::handleMousePressEventSingleClick( // Don't restart the selection when the mouse is pressed on an // existing selection so we can allow for text dragging. if (FrameView* view = m_frame->view()) { - const LayoutPoint vPoint = - view->rootFrameToContents(event.event().position()); + const LayoutPoint vPoint = view->rootFrameToContents( + flooredIntPoint(event.event().positionInRootFrame())); if (!extendSelection && this->selection().contains(vPoint)) { m_mouseDownWasSingleClickInSelection = true; if (!event.event().fromTouch()) @@ -245,8 +245,8 @@ bool SelectionController::handleMousePressEventSingleClick( .selectAllChildren(*innerNode) .build()) .isCaret(); - const bool notLeftClick = event.event().pointerProperties().button != - WebPointerProperties::Button::Left; + const bool notLeftClick = + event.event().button != WebPointerProperties::Button::Left; if (!isTextBoxEmpty || notLeftClick) isHandleVisible = event.event().fromTouch(); } @@ -538,7 +538,7 @@ void SelectionController::selectClosestWordFromMouseEvent( return; AppendTrailingWhitespace appendTrailingWhitespace = - (result.event().clickCount() == 2 && + (result.event().clickCount == 2 && m_frame->editor().isSelectTrailingWhitespaceEnabled()) ? AppendTrailingWhitespace::ShouldAppend : AppendTrailingWhitespace::DontAppend; @@ -558,7 +558,7 @@ void SelectionController::selectClosestMisspellingFromMouseEvent( selectClosestMisspellingFromHitTestResult( result.hitTestResult(), - (result.event().clickCount() == 2 && + (result.event().clickCount == 2 && m_frame->editor().isSelectTrailingWhitespaceEnabled()) ? AppendTrailingWhitespace::ShouldAppend : AppendTrailingWhitespace::DontAppend); @@ -733,8 +733,7 @@ bool SelectionController::handleMousePressEventDoubleClick( if (!m_mouseDownAllowsMultiClick) return handleMousePressEventSingleClick(event); - if (event.event().pointerProperties().button != - WebPointerProperties::Button::Left) + if (event.event().button != WebPointerProperties::Button::Left) return false; if (selection().isRange()) { @@ -763,8 +762,7 @@ bool SelectionController::handleMousePressEventTripleClick( if (!m_mouseDownAllowsMultiClick) return handleMousePressEventSingleClick(event); - if (event.event().pointerProperties().button != - WebPointerProperties::Button::Left) + if (event.event().button != WebPointerProperties::Button::Left) return false; Node* innerNode = event.innerNode(); @@ -865,9 +863,9 @@ bool SelectionController::handleMouseReleaseEvent( // editing, place the caret. if (m_mouseDownWasSingleClickInSelection && m_selectionState != SelectionState::ExtendedSelection && - dragStartPos == event.event().position() && selection().isRange() && - event.event().pointerProperties().button != - WebPointerProperties::Button::Right) { + dragStartPos == flooredIntPoint(event.event().positionInRootFrame()) && + selection().isRange() && + event.event().button != WebPointerProperties::Button::Right) { // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets // needs to be audited. See http://crbug.com/590369 for more details. m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); @@ -893,8 +891,7 @@ bool SelectionController::handleMouseReleaseEvent( selection().selectFrameElementInParentIfFullySelected(); - if (event.event().pointerProperties().button == - WebPointerProperties::Button::Middle && + if (event.event().button == WebPointerProperties::Button::Middle && !event.isOverLink()) { // Ignore handled, since we want to paste to where the caret was placed // anyway. @@ -905,7 +902,7 @@ bool SelectionController::handleMouseReleaseEvent( } bool SelectionController::handlePasteGlobalSelection( - const PlatformMouseEvent& mouseEvent) { + const WebMouseEvent& mouseEvent) { // If the event was a middle click, attempt to copy global selection in after // the newly set caret position. // @@ -922,7 +919,7 @@ bool SelectionController::handlePasteGlobalSelection( // down then the text is pasted just before the onclick handler runs and // clears the text box. So it's important this happens after the event // handlers have been fired. - if (mouseEvent.type() != PlatformEvent::MouseReleased) + if (mouseEvent.type() != WebInputEvent::MouseUp) return false; if (!m_frame->page()) @@ -1022,7 +1019,8 @@ void SelectionController::passMousePressEventToSubframe( // greyed out even though we're clicking on the selection. This looks // really strange (having the whole frame be greyed out), so we deselect the // selection. - IntPoint p = m_frame->view()->rootFrameToContents(mev.event().position()); + IntPoint p = m_frame->view()->rootFrameToContents( + flooredIntPoint(mev.event().positionInRootFrame())); if (!selection().contains(p)) return; @@ -1071,13 +1069,16 @@ FrameSelection& SelectionController::selection() const { } bool isLinkSelection(const MouseEventWithHitTestResults& event) { - return event.event().altKey() && event.isOverLink(); + return (event.event().modifiers() & WebInputEvent::Modifiers::AltKey) != 0 && + event.isOverLink(); } bool isExtendingSelection(const MouseEventWithHitTestResults& event) { bool isMouseDownOnLinkOrImage = event.isOverLink() || event.hitTestResult().image(); - return event.event().shiftKey() && !isMouseDownOnLinkOrImage; + return (event.event().modifiers() & WebInputEvent::Modifiers::ShiftKey) != + 0 && + !isMouseDownOnLinkOrImage; } } // namespace blink diff --git a/third_party/WebKit/Source/core/editing/SelectionController.h b/third_party/WebKit/Source/core/editing/SelectionController.h index 8d847cca22f637..69abbddcbbe724 100644 --- a/third_party/WebKit/Source/core/editing/SelectionController.h +++ b/third_party/WebKit/Source/core/editing/SelectionController.h @@ -62,7 +62,7 @@ class CORE_EXPORT SelectionController final const IntPoint&); bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&, const LayoutPoint&); - bool handlePasteGlobalSelection(const PlatformMouseEvent&); + bool handlePasteGlobalSelection(const WebMouseEvent&); bool handleGestureLongPress(const WebGestureEvent&, const HitTestResult&); void handleGestureTwoFingerTap(const GestureEventWithHitTestResults&); void handleGestureLongTap(const GestureEventWithHitTestResults&); diff --git a/third_party/WebKit/Source/core/events/DragEvent.cpp b/third_party/WebKit/Source/core/events/DragEvent.cpp index 61e44d418bf851..9512e6cd8dceab 100644 --- a/third_party/WebKit/Source/core/events/DragEvent.cpp +++ b/third_party/WebKit/Source/core/events/DragEvent.cpp @@ -10,25 +10,24 @@ namespace blink { -DragEvent* DragEvent::create( - const AtomicString& type, - bool canBubble, - bool cancelable, - AbstractView* view, - int detail, - int screenX, - int screenY, - int windowX, - int windowY, - int movementX, - int movementY, - PlatformEvent::Modifiers modifiers, - short button, - unsigned short buttons, - EventTarget* relatedTarget, - TimeTicks platformTimeStamp, - DataTransfer* dataTransfer, - PlatformMouseEvent::SyntheticEventType syntheticEventType) { +DragEvent* DragEvent::create(const AtomicString& type, + bool canBubble, + bool cancelable, + AbstractView* view, + int detail, + int screenX, + int screenY, + int windowX, + int windowY, + int movementX, + int movementY, + PlatformEvent::Modifiers modifiers, + short button, + unsigned short buttons, + EventTarget* relatedTarget, + TimeTicks platformTimeStamp, + DataTransfer* dataTransfer, + SyntheticEventType syntheticEventType) { return new DragEvent(type, canBubble, cancelable, view, detail, screenX, screenY, windowX, windowY, movementX, movementY, modifiers, button, buttons, relatedTarget, @@ -57,7 +56,7 @@ DragEvent::DragEvent(const AtomicString& eventType, EventTarget* relatedTarget, TimeTicks platformTimeStamp, DataTransfer* dataTransfer, - PlatformMouseEvent::SyntheticEventType syntheticEventType) + SyntheticEventType syntheticEventType) : MouseEvent( eventType, canBubble, @@ -78,8 +77,7 @@ DragEvent::DragEvent(const AtomicString& eventType, syntheticEventType, // TODO(zino): Should support canvas hit region because the drag event // is a kind of mouse event. Please see http://crbug.com/594073 - String(), - nullptr), + String()), m_dataTransfer(dataTransfer) {} diff --git a/third_party/WebKit/Source/core/events/DragEvent.h b/third_party/WebKit/Source/core/events/DragEvent.h index e1d6fcb85864b3..2bdef6ef886856 100644 --- a/third_party/WebKit/Source/core/events/DragEvent.h +++ b/third_party/WebKit/Source/core/events/DragEvent.h @@ -40,8 +40,7 @@ class CORE_EXPORT DragEvent final : public MouseEvent { EventTarget* relatedTarget, TimeTicks platformTimeStamp, DataTransfer*, - PlatformMouseEvent::SyntheticEventType = - PlatformMouseEvent::RealOrIndistinguishable); + SyntheticEventType = RealOrIndistinguishable); static DragEvent* create(const AtomicString& type, const DragEventInit& initializer) { @@ -79,7 +78,7 @@ class CORE_EXPORT DragEvent final : public MouseEvent { EventTarget* relatedTarget, TimeTicks platformTimeStamp, DataTransfer*, - PlatformMouseEvent::SyntheticEventType); + SyntheticEventType); DragEvent(const AtomicString& type, const DragEventInit&); diff --git a/third_party/WebKit/Source/core/events/MouseEvent.cpp b/third_party/WebKit/Source/core/events/MouseEvent.cpp index da7a86940579ba..5e68f976bc08bc 100644 --- a/third_party/WebKit/Source/core/events/MouseEvent.cpp +++ b/third_party/WebKit/Source/core/events/MouseEvent.cpp @@ -32,7 +32,6 @@ #include "core/layout/LayoutObject.h" #include "core/paint/PaintLayer.h" #include "core/svg/SVGElement.h" -#include "platform/PlatformMouseEvent.h" #include "public/platform/WebPointerProperties.h" namespace blink { @@ -91,48 +90,16 @@ MouseEvent* MouseEvent::create(ScriptState* scriptState, MouseEvent* MouseEvent::create(const AtomicString& eventType, AbstractView* view, - const PlatformMouseEvent& event, + const WebMouseEvent& event, int detail, + const String& canvasRegionId, Node* relatedTarget) { bool isMouseEnterOrLeave = eventType == EventTypeNames::mouseenter || eventType == EventTypeNames::mouseleave; bool isCancelable = !isMouseEnterOrLeave; bool isBubbling = !isMouseEnterOrLeave; - - return MouseEvent::create( - eventType, isBubbling, isCancelable, view, detail, - event.globalPosition().x(), event.globalPosition().y(), - event.position().x(), event.position().y(), event.movementDelta().x(), - event.movementDelta().y(), event.getModifiers(), - static_cast(event.pointerProperties().button), - platformModifiersToButtons(event.getModifiers()), relatedTarget, - event.timestamp(), event.getSyntheticEventType(), event.region(), &event); -} - -MouseEvent* MouseEvent::create( - const AtomicString& type, - bool canBubble, - bool cancelable, - AbstractView* view, - int detail, - int screenX, - int screenY, - int windowX, - int windowY, - int movementX, - int movementY, - PlatformEvent::Modifiers modifiers, - short button, - unsigned short buttons, - EventTarget* relatedTarget, - TimeTicks platformTimeStamp, - PlatformMouseEvent::SyntheticEventType syntheticEventType, - const String& region, - const PlatformMouseEvent* mouseEvent) { - return new MouseEvent( - type, canBubble, cancelable, view, detail, screenX, screenY, windowX, - windowY, movementX, movementY, modifiers, button, buttons, relatedTarget, - platformTimeStamp, syntheticEventType, region, mouseEvent); + return new MouseEvent(eventType, isBubbling, isCancelable, view, event, + detail, canvasRegionId, relatedTarget); } MouseEvent* MouseEvent::create(const AtomicString& eventType, @@ -145,12 +112,11 @@ MouseEvent* MouseEvent::create(const AtomicString& eventType, modifiers = keyStateEvent->modifiers(); } - PlatformMouseEvent::SyntheticEventType syntheticType = - PlatformMouseEvent::Positionless; + SyntheticEventType syntheticType = Positionless; int screenX = 0; int screenY = 0; if (underlyingEvent && underlyingEvent->isMouseEvent()) { - syntheticType = PlatformMouseEvent::RealOrIndistinguishable; + syntheticType = RealOrIndistinguishable; MouseEvent* mouseEvent = toMouseEvent(underlyingEvent); screenX = mouseEvent->screenX(); screenY = mouseEvent->screenY(); @@ -158,14 +124,14 @@ MouseEvent* MouseEvent::create(const AtomicString& eventType, TimeTicks timestamp = underlyingEvent ? underlyingEvent->platformTimeStamp() : TimeTicks::Now(); - MouseEvent* createdEvent = MouseEvent::create( + MouseEvent* createdEvent = new MouseEvent( eventType, true, true, view, 0, screenX, screenY, 0, 0, 0, 0, modifiers, - 0, 0, nullptr, timestamp, syntheticType, String(), nullptr); + 0, 0, nullptr, timestamp, syntheticType, String()); createdEvent->setTrusted(creationScope == SimulatedClickCreationScope::FromUserAgent); createdEvent->setUnderlyingEvent(underlyingEvent); - if (syntheticType == PlatformMouseEvent::RealOrIndistinguishable) { + if (syntheticType == RealOrIndistinguishable) { MouseEvent* mouseEvent = toMouseEvent(createdEvent->underlyingEvent()); createdEvent->initCoordinates(mouseEvent->clientX(), mouseEvent->clientY()); } @@ -179,62 +145,60 @@ MouseEvent::MouseEvent() m_button(0), m_buttons(0), m_relatedTarget(nullptr), - m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable) {} + m_syntheticEventType(RealOrIndistinguishable) {} -MouseEvent::MouseEvent( - const AtomicString& eventType, - bool canBubble, - bool cancelable, - AbstractView* abstractView, - PlatformMouseEvent::SyntheticEventType syntheticEventType, - const String& region, - const WebMouseEvent& event) +MouseEvent::MouseEvent(const AtomicString& eventType, + bool canBubble, + bool cancelable, + AbstractView* abstractView, + const WebMouseEvent& event, + int detail, + const String& region, + EventTarget* relatedTarget) : UIEventWithKeyState( eventType, canBubble, cancelable, abstractView, - 0, + detail, static_cast(event.modifiers()), TimeTicks::FromSeconds(event.timeStampSeconds()), - syntheticEventType == PlatformMouseEvent::FromTouch + event.fromTouch() ? InputDeviceCapabilities::firesTouchEventsSourceCapabilities() : InputDeviceCapabilities:: doesntFireTouchEventsSourceCapabilities()), m_screenLocation(event.globalX, event.globalY), m_movementDelta(flooredIntPoint(event.movementInRootFrame())), - m_positionType(syntheticEventType == PlatformMouseEvent::Positionless - ? PositionType::Positionless - : PositionType::Position), - m_button(0), + m_positionType(PositionType::Position), + m_button(static_cast(event.button)), m_buttons(platformModifiersToButtons(event.modifiers())), - m_syntheticEventType(syntheticEventType), + m_relatedTarget(relatedTarget), + m_syntheticEventType(event.fromTouch() ? FromTouch + : RealOrIndistinguishable), m_region(region) { IntPoint rootFrameCoordinates = flooredIntPoint(event.positionInRootFrame()); initCoordinatesFromRootFrame(rootFrameCoordinates.x(), rootFrameCoordinates.y()); } -MouseEvent::MouseEvent( - const AtomicString& eventType, - bool canBubble, - bool cancelable, - AbstractView* abstractView, - int detail, - int screenX, - int screenY, - int windowX, - int windowY, - int movementX, - int movementY, - PlatformEvent::Modifiers modifiers, - short button, - unsigned short buttons, - EventTarget* relatedTarget, - TimeTicks platformTimeStamp, - PlatformMouseEvent::SyntheticEventType syntheticEventType, - const String& region, - const PlatformMouseEvent* mouseEvent) +MouseEvent::MouseEvent(const AtomicString& eventType, + bool canBubble, + bool cancelable, + AbstractView* abstractView, + int detail, + int screenX, + int screenY, + int windowX, + int windowY, + int movementX, + int movementY, + PlatformEvent::Modifiers modifiers, + short button, + unsigned short buttons, + EventTarget* relatedTarget, + TimeTicks platformTimeStamp, + SyntheticEventType syntheticEventType, + const String& region) : UIEventWithKeyState( eventType, canBubble, @@ -243,13 +207,13 @@ MouseEvent::MouseEvent( detail, modifiers, platformTimeStamp, - syntheticEventType == PlatformMouseEvent::FromTouch + syntheticEventType == FromTouch ? InputDeviceCapabilities::firesTouchEventsSourceCapabilities() : InputDeviceCapabilities:: doesntFireTouchEventsSourceCapabilities()), m_screenLocation(screenX, screenY), m_movementDelta(movementX, movementY), - m_positionType(syntheticEventType == PlatformMouseEvent::Positionless + m_positionType(syntheticEventType == Positionless ? PositionType::Positionless : PositionType::Position), m_button(button), @@ -257,8 +221,6 @@ MouseEvent::MouseEvent( m_relatedTarget(relatedTarget), m_syntheticEventType(syntheticEventType), m_region(region) { - if (mouseEvent) - m_mouseEvent.reset(new PlatformMouseEvent(*mouseEvent)); initCoordinatesFromRootFrame(windowX, windowY); } @@ -273,7 +235,7 @@ MouseEvent::MouseEvent(const AtomicString& eventType, m_button(initializer.button()), m_buttons(initializer.buttons()), m_relatedTarget(initializer.relatedTarget()), - m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable), + m_syntheticEventType(RealOrIndistinguishable), m_region(initializer.region()) { initCoordinates(initializer.clientX(), initializer.clientY()); } diff --git a/third_party/WebKit/Source/core/events/MouseEvent.h b/third_party/WebKit/Source/core/events/MouseEvent.h index 767a3409f788b7..831be6c723f3fa 100644 --- a/third_party/WebKit/Source/core/events/MouseEvent.h +++ b/third_party/WebKit/Source/core/events/MouseEvent.h @@ -28,7 +28,6 @@ #include "core/events/EventDispatchMediator.h" #include "core/events/MouseEventInit.h" #include "core/events/UIEventWithKeyState.h" -#include "platform/PlatformMouseEvent.h" #include "public/platform/WebMouseEvent.h" namespace blink { @@ -39,34 +38,24 @@ class CORE_EXPORT MouseEvent : public UIEventWithKeyState { DEFINE_WRAPPERTYPEINFO(); public: - static MouseEvent* create() { return new MouseEvent; } + enum SyntheticEventType { + // Real mouse input events or synthetic events that behave just like real + // events + RealOrIndistinguishable, + // Synthetic mouse events derived from touch input + FromTouch, + // Synthetic mouse events generated without a position, for example those + // generated from keyboard input. + Positionless, + }; - // TODO(mustaq): Should replace most/all of these params with a - // MouseEventInit. - static MouseEvent* create(const AtomicString& type, - bool canBubble, - bool cancelable, - AbstractView*, - int detail, - int screenX, - int screenY, - int windowX, - int windowY, - int movementX, - int movementY, - PlatformEvent::Modifiers, - short button, - unsigned short buttons, - EventTarget* relatedTarget, - TimeTicks platformTimeStamp, - PlatformMouseEvent::SyntheticEventType, - const String& region, - const PlatformMouseEvent*); + static MouseEvent* create() { return new MouseEvent; } static MouseEvent* create(const AtomicString& eventType, AbstractView*, - const PlatformMouseEvent&, + const WebMouseEvent&, int detail, + const String& canvasRegionId, Node* relatedTarget); static MouseEvent* create(ScriptState*, @@ -109,20 +98,17 @@ class CORE_EXPORT MouseEvent : public UIEventWithKeyState { void setRelatedTarget(EventTarget* relatedTarget) { m_relatedTarget = relatedTarget; } - PlatformMouseEvent::SyntheticEventType getSyntheticEventType() const { + SyntheticEventType getSyntheticEventType() const { return m_syntheticEventType; } const String& region() const { return m_region; } - void setRegion(const String& region) { m_region = region; } Node* toElement() const; Node* fromElement() const; virtual DataTransfer* getDataTransfer() const { return nullptr; } - bool fromTouch() const { - return m_syntheticEventType == PlatformMouseEvent::FromTouch; - } + bool fromTouch() const { return m_syntheticEventType == FromTouch; } const AtomicString& interfaceName() const override; @@ -133,7 +119,7 @@ class CORE_EXPORT MouseEvent : public UIEventWithKeyState { int clickCount() { return detail(); } - const PlatformMouseEvent* mouseEvent() const { return m_mouseEvent.get(); } + const WebMouseEvent* nativeEvent() const { return m_nativeEvent.get(); } enum class PositionType { Position, @@ -200,9 +186,10 @@ class CORE_EXPORT MouseEvent : public UIEventWithKeyState { bool canBubble, bool cancelable, AbstractView*, - PlatformMouseEvent::SyntheticEventType, + const WebMouseEvent&, + int detail, const String& region, - const WebMouseEvent&); + EventTarget* relatedTarget); MouseEvent(const AtomicString& type, bool canBubble, @@ -220,9 +207,8 @@ class CORE_EXPORT MouseEvent : public UIEventWithKeyState { unsigned short buttons, EventTarget* relatedTarget, TimeTicks platformTimeStamp, - PlatformMouseEvent::SyntheticEventType, - const String& region, - const PlatformMouseEvent*); + SyntheticEventType, + const String& region); MouseEvent(const AtomicString& type, const MouseEventInit&); @@ -267,9 +253,9 @@ class CORE_EXPORT MouseEvent : public UIEventWithKeyState { short m_button; unsigned short m_buttons; Member m_relatedTarget; - PlatformMouseEvent::SyntheticEventType m_syntheticEventType; + SyntheticEventType m_syntheticEventType; String m_region; - std::unique_ptr m_mouseEvent; + std::unique_ptr m_nativeEvent; }; class MouseEventDispatchMediator final : public EventDispatchMediator { diff --git a/third_party/WebKit/Source/core/events/PointerEventFactory.cpp b/third_party/WebKit/Source/core/events/PointerEventFactory.cpp index 13eed8ba6437e2..75586e7bb0eb91 100644 --- a/third_party/WebKit/Source/core/events/PointerEventFactory.cpp +++ b/third_party/WebKit/Source/core/events/PointerEventFactory.cpp @@ -134,22 +134,22 @@ void updateTouchPointerEventInit(const WebTouchPoint& touchPoint, pointerEventInit->setTwist(touchPoint.twist); } -void updateMousePointerEventInit(const PlatformMouseEvent& mouseEvent, +void updateMousePointerEventInit(const WebMouseEvent& mouseEvent, LocalDOMWindow* view, PointerEventInit* pointerEventInit) { // This function should not update attributes like pointerId, isPrimary, // and pointerType which is the same among the coalesced events and the // dispatched event. - pointerEventInit->setScreenX(mouseEvent.globalPosition().x()); - pointerEventInit->setScreenY(mouseEvent.globalPosition().y()); + pointerEventInit->setScreenX(mouseEvent.globalX); + pointerEventInit->setScreenY(mouseEvent.globalY); IntPoint locationInFrameZoomed; if (view && view->frame() && view->frame()->view()) { LocalFrame* frame = view->frame(); FrameView* frameView = frame->view(); - IntPoint locationInContents = - frameView->rootFrameToContents(mouseEvent.position()); + IntPoint locationInContents = frameView->rootFrameToContents( + flooredIntPoint(mouseEvent.positionInRootFrame())); locationInFrameZoomed = frameView->contentsToFrame(locationInContents); float scaleFactor = 1 / frame->pageZoomFactor(); locationInFrameZoomed.scale(scaleFactor, scaleFactor); @@ -158,13 +158,12 @@ void updateMousePointerEventInit(const PlatformMouseEvent& mouseEvent, pointerEventInit->setClientX(locationInFrameZoomed.x()); pointerEventInit->setClientY(locationInFrameZoomed.y()); - pointerEventInit->setPressure(getPointerEventPressure( - mouseEvent.pointerProperties().force, pointerEventInit->buttons())); - pointerEventInit->setTiltX(mouseEvent.pointerProperties().tiltX); - pointerEventInit->setTiltY(mouseEvent.pointerProperties().tiltY); - pointerEventInit->setTangentialPressure( - mouseEvent.pointerProperties().tangentialPressure); - pointerEventInit->setTwist(mouseEvent.pointerProperties().twist); + pointerEventInit->setPressure( + getPointerEventPressure(mouseEvent.force, pointerEventInit->buttons())); + pointerEventInit->setTiltX(mouseEvent.tiltX); + pointerEventInit->setTiltY(mouseEvent.tiltY); + pointerEventInit->setTangentialPressure(mouseEvent.tangentialPressure); + pointerEventInit->setTwist(mouseEvent.twist); } } // namespace @@ -216,8 +215,8 @@ void PointerEventFactory::setEventSpecificFields( PointerEvent* PointerEventFactory::create( const AtomicString& mouseEventName, - const PlatformMouseEvent& mouseEvent, - const Vector& coalescedMouseEvents, + const WebMouseEvent& mouseEvent, + const Vector& coalescedMouseEvents, LocalDOMWindow* view) { DCHECK(mouseEventName == EventTypeNames::mousemove || mouseEventName == EventTypeNames::mousedown || @@ -226,19 +225,18 @@ PointerEvent* PointerEventFactory::create( AtomicString pointerEventName = pointerEventNameForMouseEventName(mouseEventName); - unsigned buttons = - MouseEvent::platformModifiersToButtons(mouseEvent.getModifiers()); + unsigned buttons = MouseEvent::platformModifiersToButtons( + static_cast(mouseEvent.modifiers())); PointerEventInit pointerEventInit; - setIdTypeButtons(pointerEventInit, mouseEvent.pointerProperties(), buttons); + setIdTypeButtons(pointerEventInit, mouseEvent, buttons); setEventSpecificFields(pointerEventInit, pointerEventName); if (pointerEventName == EventTypeNames::pointerdown || pointerEventName == EventTypeNames::pointerup) { - WebPointerProperties::Button button = mouseEvent.pointerProperties().button; + WebPointerProperties::Button button = mouseEvent.button; // TODO(mustaq): Fix when the spec starts supporting hovering erasers. - if (mouseEvent.pointerProperties().pointerType == - WebPointerProperties::PointerType::Eraser && + if (mouseEvent.pointerType == WebPointerProperties::PointerType::Eraser && button == WebPointerProperties::Button::Left) button = WebPointerProperties::Button::Eraser; pointerEventInit.setButton(static_cast(button)); @@ -248,14 +246,13 @@ PointerEvent* PointerEventFactory::create( static_cast(WebPointerProperties::Button::NoButton)); } - UIEventWithKeyState::setFromPlatformModifiers(pointerEventInit, - mouseEvent.getModifiers()); + UIEventWithKeyState::setFromWebInputEventModifiers( + pointerEventInit, + static_cast(mouseEvent.modifiers())); // Make sure chorded buttons fire pointermove instead of pointerup/down. if ((pointerEventName == EventTypeNames::pointerdown && - (buttons & - ~buttonToButtonsBitfield(mouseEvent.pointerProperties().button)) != - 0) || + (buttons & ~buttonToButtonsBitfield(mouseEvent.button)) != 0) || (pointerEventName == EventTypeNames::pointerup && buttons != 0)) pointerEventName = EventTypeNames::pointermove; @@ -267,12 +264,10 @@ PointerEvent* PointerEventFactory::create( if (pointerEventName == EventTypeNames::pointermove) { HeapVector> coalescedPointerEvents; for (const auto& coalescedMouseEvent : coalescedMouseEvents) { - DCHECK_EQ(mouseEvent.pointerProperties().id, - coalescedMouseEvent.pointerProperties().id); + DCHECK_EQ(mouseEvent.id, coalescedMouseEvent.id); // TODO(crbug.com/684292): We need further investigation of why the // following DCHECK fails. - // DCHECK_EQ(mouseEvent.pointerProperties().pointerType, - // coalescedMouseEvent.pointerProperties().pointerType); + // DCHECK_EQ(mouseEvent.pointerType, coalescedMouseEvent.pointerType); PointerEventInit coalescedEventInit = pointerEventInit; updateMousePointerEventInit(coalescedMouseEvent, view, &coalescedEventInit); diff --git a/third_party/WebKit/Source/core/events/PointerEventFactory.h b/third_party/WebKit/Source/core/events/PointerEventFactory.h index 2f1275ec4ac597..7c9d0d726bf4c3 100644 --- a/third_party/WebKit/Source/core/events/PointerEventFactory.h +++ b/third_party/WebKit/Source/core/events/PointerEventFactory.h @@ -30,8 +30,8 @@ class CORE_EXPORT PointerEventFactory { ~PointerEventFactory(); PointerEvent* create(const AtomicString& mouseEventName, - const PlatformMouseEvent&, - const Vector&, + const WebMouseEvent&, + const Vector&, LocalDOMWindow*); PointerEvent* create(const WebTouchPoint&, diff --git a/third_party/WebKit/Source/core/events/PointerEventFactoryTest.cpp b/third_party/WebKit/Source/core/events/PointerEventFactoryTest.cpp index 9050098f02ea05..9ff83624f6c311 100644 --- a/third_party/WebKit/Source/core/events/PointerEventFactoryTest.cpp +++ b/third_party/WebKit/Source/core/events/PointerEventFactoryTest.cpp @@ -66,11 +66,11 @@ class PointerEventFactoryTest : public ::testing::Test { WebTouchPoint::State); }; - class PlatformMouseEventBuilder : public PlatformMouseEvent { + class WebMouseEventBuilder : public WebMouseEvent { public: - PlatformMouseEventBuilder(WebPointerProperties::PointerType, - int, - PlatformEvent::Modifiers); + WebMouseEventBuilder(WebPointerProperties::PointerType, + int, + PlatformEvent::Modifiers); }; }; @@ -89,13 +89,13 @@ PointerEventFactoryTest::WebTouchPointBuilder::WebTouchPointBuilder( state = stateParam; } -PointerEventFactoryTest::PlatformMouseEventBuilder::PlatformMouseEventBuilder( - WebPointerProperties::PointerType pointerType, - int id, - PlatformEvent::Modifiers modifiers) { - m_pointerProperties.pointerType = pointerType; - m_pointerProperties.id = id; - m_modifiers = modifiers; +PointerEventFactoryTest::WebMouseEventBuilder::WebMouseEventBuilder( + WebPointerProperties::PointerType pointerTypeParam, + int idParam, + PlatformEvent::Modifiers modifiersParam) { + pointerType = pointerTypeParam; + id = idParam; + m_modifiers = modifiersParam; } PointerEvent* PointerEventFactoryTest::createAndCheckTouchCancel( @@ -160,17 +160,16 @@ PointerEvent* PointerEventFactoryTest::createAndCheckMouseEvent( bool isPrimary, PlatformEvent::Modifiers modifiers, size_t coalescedEventCount) { - Vector coalescedEvents; + Vector coalescedEvents; for (size_t i = 0; i < coalescedEventCount; i++) { - coalescedEvents.push_back( - PointerEventFactoryTest::PlatformMouseEventBuilder(pointerType, rawId, - modifiers)); + coalescedEvents.push_back(PointerEventFactoryTest::WebMouseEventBuilder( + pointerType, rawId, modifiers)); } PointerEvent* pointerEvent = m_pointerEventFactory.create( coalescedEventCount ? EventTypeNames::mousemove : EventTypeNames::mousedown, - PointerEventFactoryTest::PlatformMouseEventBuilder(pointerType, rawId, - modifiers), + PointerEventFactoryTest::WebMouseEventBuilder(pointerType, rawId, + modifiers), coalescedEvents, nullptr); EXPECT_EQ(uniqueId, pointerEvent->pointerId()); EXPECT_EQ(isPrimary, pointerEvent->isPrimary()); diff --git a/third_party/WebKit/Source/core/events/WheelEvent.cpp b/third_party/WebKit/Source/core/events/WheelEvent.cpp index 5f39f8bfb960bd..3597836380a3f2 100644 --- a/third_party/WebKit/Source/core/events/WheelEvent.cpp +++ b/third_party/WebKit/Source/core/events/WheelEvent.cpp @@ -24,7 +24,6 @@ #include "core/events/WheelEvent.h" #include "core/clipboard/DataTransfer.h" -#include "platform/PlatformMouseEvent.h" namespace blink { @@ -73,12 +72,13 @@ WheelEvent::WheelEvent(const WebMouseWheelEvent& event, AbstractView* view) true, event.isCancelable(), view, - PlatformMouseEvent::RealOrIndistinguishable, + event, + event.clickCount, // TODO(zino): Should support canvas hit region because the // wheel event is a kind of mouse event. Please see // http://crbug.com/594075 String(), - event), + nullptr), m_wheelDelta(event.wheelTicksX * TickMultiplier, event.wheelTicksY * TickMultiplier), m_deltaX(-event.deltaXInRootFrame()), diff --git a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp index 07ee1a2913f461..af78e1d7cecd1c 100644 --- a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp @@ -72,7 +72,6 @@ #include "core/layout/LayoutTheme.h" #include "core/page/ChromeClient.h" #include "platform/Language.h" -#include "platform/PlatformMouseEvent.h" #include "platform/RuntimeEnabledFeatures.h" #include "platform/text/PlatformLocale.h" #include "wtf/MathExtras.h" diff --git a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp index db8af6744e0bbc..6489494298abf1 100644 --- a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp @@ -70,7 +70,6 @@ #include "core/page/ChromeClient.h" #include "core/page/Page.h" #include "core/page/SpatialNavigation.h" -#include "platform/PlatformMouseEvent.h" #include "platform/PopupMenu.h" #include "platform/instrumentation/tracing/TraceEvent.h" #include "platform/text/PlatformLocale.h" @@ -1288,7 +1287,7 @@ void HTMLSelectElement::menuListDefaultEventHandler(Event* event) { return; int ignoreModifiers = PlatformEvent::ShiftKey | PlatformEvent::CtrlKey | - PlatformEvent::AltKey | PlatformMouseEvent::MetaKey; + PlatformEvent::AltKey | PlatformEvent::MetaKey; if (keyEvent->modifiers() & ignoreModifiers) return; diff --git a/third_party/WebKit/Source/core/html/forms/RangeInputType.cpp b/third_party/WebKit/Source/core/html/forms/RangeInputType.cpp index 0ca1bd5e0073fb..e2a50b29a0844a 100644 --- a/third_party/WebKit/Source/core/html/forms/RangeInputType.cpp +++ b/third_party/WebKit/Source/core/html/forms/RangeInputType.cpp @@ -50,7 +50,6 @@ #include "core/html/shadow/ShadowElementNames.h" #include "core/html/shadow/SliderThumbElement.h" #include "core/layout/LayoutSlider.h" -#include "platform/PlatformMouseEvent.h" #include "wtf/MathExtras.h" #include "wtf/NonCopyingSort.h" #include diff --git a/third_party/WebKit/Source/core/input/EventHandler.cpp b/third_party/WebKit/Source/core/input/EventHandler.cpp index 35cea31c489be6..1d310088b319f7 100644 --- a/third_party/WebKit/Source/core/input/EventHandler.cpp +++ b/third_party/WebKit/Source/core/input/EventHandler.cpp @@ -568,14 +568,13 @@ OptionalCursor EventHandler::selectAutoCursor(const HitTestResult& result, } WebInputEventResult EventHandler::handleMousePressEvent( - const PlatformMouseEvent& mouseEvent) { + const WebMouseEvent& mouseEvent) { TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); // For 4th/5th button in the mouse since Chrome does not yet send // button value to Blink but in some cases it does send the event. // This check is needed to suppress such an event (crbug.com/574959) - if (mouseEvent.pointerProperties().button == - WebPointerProperties::Button::NoButton) + if (mouseEvent.button == WebPointerProperties::Button::NoButton) return WebInputEventResult::HandledSuppressed; if (m_eventHandlerWillResetCapturingMouseEventsNode) @@ -588,8 +587,8 @@ WebInputEventResult EventHandler::handleMousePressEvent( HitTestRequest request(HitTestRequest::Active); // Save the document point we generate in case the window coordinate is // invalidated by what happens when we dispatch the event. - LayoutPoint documentPoint = - m_frame->view()->rootFrameToContents(mouseEvent.position()); + LayoutPoint documentPoint = m_frame->view()->rootFrameToContents( + flooredIntPoint(mouseEvent.positionInRootFrame())); MouseEventWithHitTestResults mev = m_frame->document()->performMouseEventHitTest(request, documentPoint, mouseEvent); @@ -642,7 +641,7 @@ WebInputEventResult EventHandler::handleMousePressEvent( } } - m_mouseEventManager->setClickCount(mouseEvent.clickCount()); + m_mouseEventManager->setClickCount(mouseEvent.clickCount); m_mouseEventManager->setClickNode( mev.innerNode()->isTextNode() ? FlatTreeTraversal::parent(*mev.innerNode()) @@ -652,15 +651,16 @@ WebInputEventResult EventHandler::handleMousePressEvent( m_frame->selection().setCaretBlinkingSuspended(true); WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents( - EventTypeNames::mousedown, mev.innerNode(), mev.event(), - Vector()); + EventTypeNames::mousedown, mev.innerNode(), mev.canvasRegionId(), + mev.event(), Vector()); if (eventResult == WebInputEventResult::NotHandled && m_frame->view()) { FrameView* view = m_frame->view(); PaintLayer* layer = mev.innerNode()->layoutObject() ? mev.innerNode()->layoutObject()->enclosingLayer() : nullptr; - IntPoint p = view->rootFrameToContents(mouseEvent.position()); + IntPoint p = view->rootFrameToContents( + flooredIntPoint(mouseEvent.positionInRootFrame())); if (layer && layer->getScrollableArea() && layer->getScrollableArea()->isPointInResizeControl(p, ResizerForPointer)) { @@ -678,7 +678,7 @@ WebInputEventResult EventHandler::handleMousePressEvent( HitTestResult hitTestResult = EventHandlingUtil::hitTestResultInFrame( m_frame, documentPoint, HitTestRequest::ReadOnly); InputDeviceCapabilities* sourceCapabilities = - mouseEvent.getSyntheticEventType() == PlatformMouseEvent::FromTouch + mouseEvent.fromTouch() ? InputDeviceCapabilities::firesTouchEventsSourceCapabilities() : InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); if (eventResult == WebInputEventResult::NotHandled) { @@ -719,9 +719,8 @@ WebInputEventResult EventHandler::handleMousePressEvent( } if (mev.hitTestResult().innerNode() && - mouseEvent.pointerProperties().button == - WebPointerProperties::Button::Left) { - ASSERT(mouseEvent.type() == PlatformEvent::MousePressed); + mouseEvent.button == WebPointerProperties::Button::Left) { + DCHECK_EQ(WebInputEvent::MouseDown, mouseEvent.type()); HitTestResult result = mev.hitTestResult(); result.setToShadowHostIfInUserAgentShadowRoot(); m_frame->chromeClient().onMouseDown(result.innerNode()); @@ -731,8 +730,8 @@ WebInputEventResult EventHandler::handleMousePressEvent( } WebInputEventResult EventHandler::handleMouseMoveEvent( - const PlatformMouseEvent& event, - const Vector& coalescedEvents) { + const WebMouseEvent& event, + const Vector& coalescedEvents) { TRACE_EVENT0("blink", "EventHandler::handleMouseMoveEvent"); HitTestResult hoveredNode = HitTestResult(); @@ -759,16 +758,15 @@ WebInputEventResult EventHandler::handleMouseMoveEvent( return result; } -void EventHandler::handleMouseLeaveEvent(const PlatformMouseEvent& event) { +void EventHandler::handleMouseLeaveEvent(const WebMouseEvent& event) { TRACE_EVENT0("blink", "EventHandler::handleMouseLeaveEvent"); - handleMouseMoveOrLeaveEvent(event, Vector(), 0, false, - true); + handleMouseMoveOrLeaveEvent(event, Vector(), 0, false, true); } WebInputEventResult EventHandler::handleMouseMoveOrLeaveEvent( - const PlatformMouseEvent& mouseEvent, - const Vector& coalescedEvents, + const WebMouseEvent& mouseEvent, + const Vector& coalescedEvents, HitTestResult* hoveredNode, bool onlyUpdateScrollbars, bool forceLeave) { @@ -784,9 +782,9 @@ WebInputEventResult EventHandler::handleMouseMoveOrLeaveEvent( m_mouseEventManager->handleSvgPanIfNeeded(false); if (m_frameSetBeingResized) { - return updatePointerTargetAndDispatchEvents(EventTypeNames::mousemove, - m_frameSetBeingResized.get(), - mouseEvent, coalescedEvents); + return updatePointerTargetAndDispatchEvents( + EventTypeNames::mousemove, m_frameSetBeingResized.get(), String(), + mouseEvent, coalescedEvents); } // Send events right to a scrollbar if the mouse is pressed. @@ -862,7 +860,8 @@ WebInputEventResult EventHandler::handleMouseMoveOrLeaveEvent( if (newSubframe) { // Update over/out state before passing the event to the subframe. m_pointerEventManager->sendMouseAndPointerBoundaryEvents( - updateMouseEventTargetNode(mev.innerNode()), mev.event()); + updateMouseEventTargetNode(mev.innerNode()), mev.canvasRegionId(), + mev.event()); // Event dispatch in sendMouseAndPointerBoundaryEvents may have caused the // subframe of the target node to be detached from its FrameView, in which @@ -891,7 +890,8 @@ WebInputEventResult EventHandler::handleMouseMoveOrLeaveEvent( return eventResult; eventResult = updatePointerTargetAndDispatchEvents( - EventTypeNames::mousemove, mev.innerNode(), mev.event(), coalescedEvents); + EventTypeNames::mousemove, mev.innerNode(), mev.canvasRegionId(), + mev.event(), coalescedEvents); if (eventResult != WebInputEventResult::NotHandled) return eventResult; @@ -899,14 +899,13 @@ WebInputEventResult EventHandler::handleMouseMoveOrLeaveEvent( } WebInputEventResult EventHandler::handleMouseReleaseEvent( - const PlatformMouseEvent& mouseEvent) { + const WebMouseEvent& mouseEvent) { TRACE_EVENT0("blink", "EventHandler::handleMouseReleaseEvent"); // For 4th/5th button in the mouse since Chrome does not yet send // button value to Blink but in some cases it does send the event. // This check is needed to suppress such an event (crbug.com/574959) - if (mouseEvent.pointerProperties().button == - WebPointerProperties::Button::NoButton) + if (mouseEvent.button == WebPointerProperties::Button::NoButton) return WebInputEventResult::HandledSuppressed; if (!mouseEvent.fromTouch()) @@ -924,7 +923,7 @@ WebInputEventResult EventHandler::handleMouseReleaseEvent( if (m_frameSetBeingResized) { return m_mouseEventManager->setMousePositionAndDispatchMouseEvent( - updateMouseEventTargetNode(m_frameSetBeingResized.get()), + updateMouseEventTargetNode(m_frameSetBeingResized.get()), String(), EventTypeNames::mouseup, mouseEvent); } @@ -933,7 +932,7 @@ WebInputEventResult EventHandler::handleMouseReleaseEvent( m_lastScrollbarUnderMouse->mouseUp(mouseEvent); return updatePointerTargetAndDispatchEvents( EventTypeNames::mouseup, m_mouseEventManager->getNodeUnderMouse(), - mouseEvent, Vector()); + String(), mouseEvent, Vector()); } // Mouse events simulated from touch should not hit-test again. @@ -971,8 +970,8 @@ WebInputEventResult EventHandler::handleMouseReleaseEvent( } WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents( - EventTypeNames::mouseup, mev.innerNode(), mev.event(), - Vector()); + EventTypeNames::mouseup, mev.innerNode(), mev.canvasRegionId(), + mev.event(), Vector()); WebInputEventResult clickEventResult = m_mouseEventManager->dispatchMouseClickIfNeeded(mev); @@ -1044,7 +1043,7 @@ static bool findDropZone(Node* target, DataTransfer* dataTransfer) { } WebInputEventResult EventHandler::updateDragAndDrop( - const PlatformMouseEvent& event, + const WebMouseEvent& event, DataTransfer* dataTransfer) { WebInputEventResult eventResult = WebInputEventResult::NotHandled; @@ -1062,9 +1061,11 @@ WebInputEventResult EventHandler::updateDragAndDrop( newTarget = FlatTreeTraversal::parent(*newTarget); if (AutoscrollController* controller = - m_scrollManager->autoscrollController()) - controller->updateDragAndDrop(newTarget, event.position(), - event.timestamp()); + m_scrollManager->autoscrollController()) { + controller->updateDragAndDrop( + newTarget, flooredIntPoint(event.positionInRootFrame()), + TimeTicks::FromSeconds(event.timeStampSeconds())); + } if (m_dragTarget != newTarget) { // FIXME: this ordering was explicitly chosen to match WinIE. However, @@ -1137,7 +1138,7 @@ WebInputEventResult EventHandler::updateDragAndDrop( return eventResult; } -void EventHandler::cancelDragAndDrop(const PlatformMouseEvent& event, +void EventHandler::cancelDragAndDrop(const WebMouseEvent& event, DataTransfer* dataTransfer) { LocalFrame* targetFrame; if (targetIsFrame(m_dragTarget.get(), targetFrame)) { @@ -1153,7 +1154,7 @@ void EventHandler::cancelDragAndDrop(const PlatformMouseEvent& event, } WebInputEventResult EventHandler::performDragAndDrop( - const PlatformMouseEvent& event, + const WebMouseEvent& event, DataTransfer* dataTransfer) { LocalFrame* targetFrame; WebInputEventResult result = WebInputEventResult::NotHandled; @@ -1256,15 +1257,16 @@ void EventHandler::elementRemoved(EventTarget* target) { WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents( const AtomicString& mouseEventType, Node* targetNode, - const PlatformMouseEvent& mouseEvent, - const Vector& coalescedEvents) { + const String& canvasRegionId, + const WebMouseEvent& mouseEvent, + const Vector& coalescedEvents) { ASSERT(mouseEventType == EventTypeNames::mousedown || mouseEventType == EventTypeNames::mousemove || mouseEventType == EventTypeNames::mouseup); const auto& eventResult = m_pointerEventManager->sendMousePointerEvent( - updateMouseEventTargetNode(targetNode), mouseEventType, mouseEvent, - coalescedEvents); + updateMouseEventTargetNode(targetNode), canvasRegionId, mouseEventType, + mouseEvent, coalescedEvents); return eventResult; } @@ -1617,33 +1619,33 @@ void EventHandler::updateGestureTargetNodeForMouseEvent( const WebGestureEvent& gestureEvent = targetedEvent.event(); unsigned modifiers = gestureEvent.modifiers(); - PlatformMouseEvent fakeMouseMove( - gestureEvent, WebPointerProperties::Button::NoButton, - PlatformEvent::MouseMoved, - /* clickCount */ 0, static_cast(modifiers), - PlatformMouseEvent::FromTouch, - TimeTicks::FromSeconds(gestureEvent.timeStampSeconds()), - WebPointerProperties::PointerType::Mouse); + WebMouseEvent fakeMouseMove( + WebInputEvent::MouseMove, gestureEvent, + WebPointerProperties::Button::NoButton, + /* clickCount */ 0, + modifiers | WebInputEvent::Modifiers::IsCompatibilityEventForTouch, + gestureEvent.timeStampSeconds()); // Update the mouseout/mouseleave event size_t indexExitedFrameChain = exitedFrameChain.size(); while (indexExitedFrameChain) { LocalFrame* leaveFrame = exitedFrameChain[--indexExitedFrameChain]; leaveFrame->eventHandler().m_mouseEventManager->setNodeUnderMouse( - updateMouseEventTargetNode(nullptr), fakeMouseMove); + updateMouseEventTargetNode(nullptr), String(), fakeMouseMove); } // update the mouseover/mouseenter event while (indexEnteredFrameChain) { Frame* parentFrame = enteredFrameChain[--indexEnteredFrameChain]->tree().parent(); - if (parentFrame && parentFrame->isLocalFrame()) + if (parentFrame && parentFrame->isLocalFrame()) { toLocalFrame(parentFrame) ->eventHandler() .m_mouseEventManager->setNodeUnderMouse( updateMouseEventTargetNode(toHTMLFrameOwnerElement( enteredFrameChain[indexEnteredFrameChain]->owner())), - fakeMouseMove); + String(), fakeMouseMove); + } } } @@ -1782,7 +1784,7 @@ void EventHandler::applyTouchAdjustment(WebGestureEvent* gestureEvent, } WebInputEventResult EventHandler::sendContextMenuEvent( - const PlatformMouseEvent& event, + const WebMouseEvent& event, Node* overrideTargetNode) { FrameView* v = m_frame->view(); if (!v) @@ -1791,7 +1793,8 @@ WebInputEventResult EventHandler::sendContextMenuEvent( // Clear mouse press state to avoid initiating a drag while context menu is // up. m_mouseEventManager->setMousePressed(false); - LayoutPoint positionInContents = v->rootFrameToContents(event.position()); + LayoutPoint positionInContents = + v->rootFrameToContents(flooredIntPoint(event.positionInRootFrame())); HitTestRequest request(HitTestRequest::Active); MouseEventWithHitTestResults mev = m_frame->document()->performMouseEventHitTest(request, positionInContents, @@ -1806,7 +1809,7 @@ WebInputEventResult EventHandler::sendContextMenuEvent( Node* targetNode = overrideTargetNode ? overrideTargetNode : mev.innerNode(); return m_mouseEventManager->dispatchMouseEvent( updateMouseEventTargetNode(targetNode), EventTypeNames::contextmenu, - event, 0); + event, mev.hitTestResult().canvasRegionId(), 0); } WebInputEventResult EventHandler::sendContextMenuEventForKey( @@ -1883,15 +1886,20 @@ WebInputEventResult EventHandler::sendContextMenuEventForKey( // The contextmenu event is a mouse event even when invoked using the // keyboard. This is required for web compatibility. - PlatformEvent::EventType eventType = PlatformEvent::MousePressed; + WebInputEvent::Type eventType = WebInputEvent::MouseDown; if (m_frame->settings() && m_frame->settings()->getShowContextMenuOnMouseUp()) - eventType = PlatformEvent::MouseReleased; + eventType = WebInputEvent::MouseUp; + + WebMouseEvent mouseEvent( + eventType, + WebFloatPoint(locationInRootFrame.x(), locationInRootFrame.y()), + WebFloatPoint(globalPosition.x(), globalPosition.y()), + WebPointerProperties::Button::NoButton, /* clickCount */ 0, + PlatformEvent::NoModifiers, TimeTicks::Now().InSeconds()); - PlatformMouseEvent mouseEvent( - locationInRootFrame, globalPosition, - WebPointerProperties::Button::NoButton, eventType, /* clickCount */ 0, - PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, - TimeTicks::Now(), WebPointerProperties::PointerType::Mouse); + // TODO(dtapuska): Transition the mouseEvent to be created really in viewport + // coordinates instead of root frame coordinates. + mouseEvent.setFrameScale(1); return sendContextMenuEvent(mouseEvent, overrideTargetElement); } @@ -1987,7 +1995,7 @@ void EventHandler::defaultKeyboardEventHandler(KeyboardEvent* event) { event, m_mouseEventManager->mousePressNode()); } -void EventHandler::dragSourceEndedAt(const PlatformMouseEvent& event, +void EventHandler::dragSourceEndedAt(const WebMouseEvent& event, DragOperation operation) { // Asides from routing the event to the correct frame, the hit test is also an // opportunity for Layer to update the :hover and :active pseudoclasses. @@ -2100,7 +2108,7 @@ WebInputEventResult EventHandler::passMousePressEventToSubframe( WebInputEventResult EventHandler::passMouseMoveEventToSubframe( MouseEventWithHitTestResults& mev, - const Vector& coalescedEvents, + const Vector& coalescedEvents, LocalFrame* subframe, HitTestResult* hoveredNode) { if (m_mouseEventManager->mouseDownMayStartDrag()) diff --git a/third_party/WebKit/Source/core/input/EventHandler.h b/third_party/WebKit/Source/core/input/EventHandler.h index 152219ddecb379..6b52de472203e7 100644 --- a/third_party/WebKit/Source/core/input/EventHandler.h +++ b/third_party/WebKit/Source/core/input/EventHandler.h @@ -38,7 +38,6 @@ #include "core/page/EventWithHitTestResults.h" #include "core/style/ComputedStyleConstants.h" #include "platform/Cursor.h" -#include "platform/PlatformMouseEvent.h" #include "platform/UserGestureIndicator.h" #include "platform/geometry/LayoutPoint.h" #include "platform/heap/Handle.h" @@ -73,6 +72,7 @@ class Scrollbar; class SelectionController; class TextEvent; class WebGestureEvent; +class WebMouseEvent; class WebMouseWheelEvent; class WebTouchEvent; @@ -113,11 +113,9 @@ class CORE_EXPORT EventHandler final void setCapturingMouseEventsNode( Node*); // A caller is responsible for resetting capturing node to 0. - WebInputEventResult updateDragAndDrop(const PlatformMouseEvent&, - DataTransfer*); - void cancelDragAndDrop(const PlatformMouseEvent&, DataTransfer*); - WebInputEventResult performDragAndDrop(const PlatformMouseEvent&, - DataTransfer*); + WebInputEventResult updateDragAndDrop(const WebMouseEvent&, DataTransfer*); + void cancelDragAndDrop(const WebMouseEvent&, DataTransfer*); + WebInputEventResult performDragAndDrop(const WebMouseEvent&, DataTransfer*); void updateDragStateAfterEditDragIfNeeded(Element* rootEditableElement); void scheduleHoverStateUpdate(); @@ -142,12 +140,12 @@ class CORE_EXPORT EventHandler final Node* startingNode = nullptr); WebInputEventResult handleMouseMoveEvent( - const PlatformMouseEvent&, - const Vector& coalescedEvents); - void handleMouseLeaveEvent(const PlatformMouseEvent&); + const WebMouseEvent&, + const Vector& coalescedEvents); + void handleMouseLeaveEvent(const WebMouseEvent&); - WebInputEventResult handleMousePressEvent(const PlatformMouseEvent&); - WebInputEventResult handleMouseReleaseEvent(const PlatformMouseEvent&); + WebInputEventResult handleMousePressEvent(const WebMouseEvent&); + WebInputEventResult handleMouseReleaseEvent(const WebMouseEvent&); WebInputEventResult handleWheelEvent(const WebMouseWheelEvent&); // Called on the local root frame exactly once per gesture event. @@ -193,7 +191,7 @@ class CORE_EXPORT EventHandler final IntRect& targetArea, Node*& targetNode); - WebInputEventResult sendContextMenuEvent(const PlatformMouseEvent&, + WebInputEventResult sendContextMenuEvent(const WebMouseEvent&, Node* overrideTargetNode = nullptr); WebInputEventResult sendContextMenuEventForKey( Element* overrideTargetElement = nullptr); @@ -219,7 +217,7 @@ class CORE_EXPORT EventHandler final TextEventInputType = TextEventInputKeyboard); void defaultTextInputEventHandler(TextEvent*); - void dragSourceEndedAt(const PlatformMouseEvent&, DragOperation); + void dragSourceEndedAt(const WebMouseEvent&, DragOperation); void capsLockStateMayHaveChanged(); // Only called by FrameSelection @@ -260,8 +258,8 @@ class CORE_EXPORT EventHandler final private: WebInputEventResult handleMouseMoveOrLeaveEvent( - const PlatformMouseEvent&, - const Vector&, + const WebMouseEvent&, + const Vector&, HitTestResult* hoveredNode = nullptr, bool onlyUpdateScrollbars = false, bool forceLeave = false); @@ -302,13 +300,14 @@ class CORE_EXPORT EventHandler final // preventDefaulted pointerdown (i.e., one of // {mousedown, mousemove, mouseup}). // TODO(mustaq): Can we avoid the clickCount param, instead use - // PlatformMouseEvent's count? + // WebmMouseEvent's count? // Same applied to dispatchMouseEvent() above. WebInputEventResult updatePointerTargetAndDispatchEvents( const AtomicString& mouseEventType, Node* target, - const PlatformMouseEvent&, - const Vector& coalescedEvents); + const String& canvasRegionId, + const WebMouseEvent&, + const Vector& coalescedEvents); // Clears drag target and related states. It is called when drag is done or // canceled. @@ -319,7 +318,7 @@ class CORE_EXPORT EventHandler final LocalFrame* subframe); WebInputEventResult passMouseMoveEventToSubframe( MouseEventWithHitTestResults&, - const Vector&, + const Vector&, LocalFrame* subframe, HitTestResult* hoveredNode = nullptr); WebInputEventResult passMouseReleaseEventToSubframe( diff --git a/third_party/WebKit/Source/core/input/EventHandlerTest.cpp b/third_party/WebKit/Source/core/input/EventHandlerTest.cpp index 8ff61f1149f03e..e92bcffb1bba1b 100644 --- a/third_party/WebKit/Source/core/input/EventHandlerTest.cpp +++ b/third_party/WebKit/Source/core/input/EventHandlerTest.cpp @@ -14,7 +14,6 @@ #include "core/page/AutoscrollController.h" #include "core/page/Page.h" #include "core/testing/DummyPageHolder.h" -#include "platform/PlatformMouseEvent.h" #include "testing/gtest/include/gtest/gtest.h" #include @@ -63,18 +62,20 @@ class LongPressEventBuilder : public WebGestureEvent { } }; -class MousePressEventBuilder : public PlatformMouseEvent { +class MousePressEventBuilder : public WebMouseEvent { public: MousePressEventBuilder(IntPoint position, - int clickCount, - WebMouseEvent::Button button) - : PlatformMouseEvent(position, - position, - button, - PlatformEvent::MousePressed, - clickCount, - static_cast(0), - TimeTicks::Now()) {} + int clickCountParam, + WebMouseEvent::Button buttonParam) + : WebMouseEvent(WebInputEvent::MouseDown, + WebInputEvent::NoModifiers, + TimeTicks::Now().InSeconds()) { + clickCount = clickCountParam; + button = buttonParam; + x = globalX = position.x(); + y = globalY = position.y(); + m_frameScale = 1; + } }; void EventHandlerTest::SetUp() { @@ -105,27 +106,32 @@ TEST_F(EventHandlerTest, dragSelectionAfterScroll) { frameView->layoutViewportScrollableArea()->setScrollOffset( ScrollOffset(0, 400), ProgrammaticScroll); - PlatformMouseEvent mouseDownEvent( - IntPoint(0, 0), IntPoint(100, 200), WebPointerProperties::Button::Left, - PlatformEvent::MousePressed, 1, PlatformEvent::Modifiers::LeftButtonDown, - TimeTicks::Now()); + WebMouseEvent mouseDownEvent(WebInputEvent::MouseDown, WebFloatPoint(0, 0), + WebFloatPoint(100, 200), + WebPointerProperties::Button::Left, 1, + WebInputEvent::Modifiers::LeftButtonDown, + WebInputEvent::TimeStampForTesting); + mouseDownEvent.setFrameScale(1); document().frame()->eventHandler().handleMousePressEvent(mouseDownEvent); - PlatformMouseEvent mouseMoveEvent( - IntPoint(100, 50), IntPoint(200, 250), WebPointerProperties::Button::Left, - PlatformEvent::MouseMoved, 1, PlatformEvent::Modifiers::LeftButtonDown, - TimeTicks::Now()); + WebMouseEvent mouseMoveEvent(WebInputEvent::MouseMove, WebFloatPoint(100, 50), + WebFloatPoint(200, 250), + WebPointerProperties::Button::Left, 1, + WebInputEvent::Modifiers::LeftButtonDown, + WebInputEvent::TimeStampForTesting); + mouseMoveEvent.setFrameScale(1); document().frame()->eventHandler().handleMouseMoveEvent( - mouseMoveEvent, Vector()); + mouseMoveEvent, Vector()); page().autoscrollController().animate(WTF::monotonicallyIncreasingTime()); page().animator().serviceScriptedAnimations( WTF::monotonicallyIncreasingTime()); - PlatformMouseEvent mouseUpEvent( - IntPoint(100, 50), IntPoint(200, 250), WebPointerProperties::Button::Left, - PlatformEvent::MouseReleased, 1, static_cast(0), - TimeTicks::Now()); + WebMouseEvent mouseUpEvent( + WebMouseEvent::MouseUp, WebFloatPoint(100, 50), WebFloatPoint(200, 250), + WebPointerProperties::Button::Left, 1, WebInputEvent::NoModifiers, + WebInputEvent::TimeStampForTesting); + mouseUpEvent.setFrameScale(1); document().frame()->eventHandler().handleMouseReleaseEvent(mouseUpEvent); ASSERT_TRUE(selection().isRange()); @@ -206,18 +212,22 @@ TEST_F(EventHandlerTest, draggedInlinePositionTest) { "
" "abcd" "
"); - PlatformMouseEvent mouseDownEvent( - IntPoint(262, 29), IntPoint(329, 67), WebPointerProperties::Button::Left, - PlatformEvent::MousePressed, 1, PlatformEvent::Modifiers::LeftButtonDown, - TimeTicks::Now()); + WebMouseEvent mouseDownEvent(WebMouseEvent::MouseDown, WebFloatPoint(262, 29), + WebFloatPoint(329, 67), + WebPointerProperties::Button::Left, 1, + WebInputEvent::Modifiers::LeftButtonDown, + WebInputEvent::TimeStampForTesting); + mouseDownEvent.setFrameScale(1); document().frame()->eventHandler().handleMousePressEvent(mouseDownEvent); - PlatformMouseEvent mouseMoveEvent( - IntPoint(618, 298), IntPoint(685, 436), - WebPointerProperties::Button::Left, PlatformEvent::MouseMoved, 1, - PlatformEvent::Modifiers::LeftButtonDown, TimeTicks::Now()); + WebMouseEvent mouseMoveEvent(WebMouseEvent::MouseMove, + WebFloatPoint(618, 298), WebFloatPoint(685, 436), + WebPointerProperties::Button::Left, 1, + WebInputEvent::Modifiers::LeftButtonDown, + WebInputEvent::TimeStampForTesting); + mouseMoveEvent.setFrameScale(1); document().frame()->eventHandler().handleMouseMoveEvent( - mouseMoveEvent, Vector()); + mouseMoveEvent, Vector()); EXPECT_EQ( IntPoint(12, 29), @@ -238,18 +248,22 @@ TEST_F(EventHandlerTest, draggedSVGImagePositionTest) { "draggable='true'/>" "" ""); - PlatformMouseEvent mouseDownEvent( - IntPoint(145, 144), IntPoint(212, 282), - WebPointerProperties::Button::Left, PlatformEvent::MousePressed, 1, - PlatformEvent::Modifiers::LeftButtonDown, TimeTicks::Now()); + WebMouseEvent mouseDownEvent(WebMouseEvent::MouseDown, + WebFloatPoint(145, 144), WebFloatPoint(212, 282), + WebPointerProperties::Button::Left, 1, + WebInputEvent::Modifiers::LeftButtonDown, + WebInputEvent::TimeStampForTesting); + mouseDownEvent.setFrameScale(1); document().frame()->eventHandler().handleMousePressEvent(mouseDownEvent); - PlatformMouseEvent mouseMoveEvent( - IntPoint(618, 298), IntPoint(685, 436), - WebPointerProperties::Button::Left, PlatformEvent::MouseMoved, 1, - PlatformEvent::Modifiers::LeftButtonDown, TimeTicks::Now()); + WebMouseEvent mouseMoveEvent(WebMouseEvent::MouseMove, + WebFloatPoint(618, 298), WebFloatPoint(685, 436), + WebPointerProperties::Button::Left, 1, + WebInputEvent::Modifiers::LeftButtonDown, + WebInputEvent::TimeStampForTesting); + mouseMoveEvent.setFrameScale(1); document().frame()->eventHandler().handleMouseMoveEvent( - mouseMoveEvent, Vector()); + mouseMoveEvent, Vector()); EXPECT_EQ( IntPoint(45, 44), @@ -273,10 +287,11 @@ TEST_F(EventHandlerTest, sendContextMenuEventWithHover) { SelectionInDOMTree::Builder() .collapse(Position(document().body(), 0)) .build()); - PlatformMouseEvent mouseDownEvent( - IntPoint(0, 0), IntPoint(100, 200), WebPointerProperties::Button::Right, - PlatformEvent::MousePressed, 1, PlatformEvent::Modifiers::RightButtonDown, - TimeTicks::Now()); + WebMouseEvent mouseDownEvent( + WebMouseEvent::MouseDown, WebFloatPoint(0, 0), WebFloatPoint(100, 200), + WebPointerProperties::Button::Right, 1, + PlatformEvent::Modifiers::RightButtonDown, TimeTicks::Now().InSeconds()); + mouseDownEvent.setFrameScale(1); EXPECT_EQ( WebInputEventResult::HandledApplication, document().frame()->eventHandler().sendContextMenuEvent(mouseDownEvent)); @@ -387,18 +402,20 @@ TEST_F(EventHandlerTest, dragEndInNewDrag) { "" "Drag me"); - PlatformMouseEvent mouseDownEvent( - IntPoint(50, 50), IntPoint(50, 50), WebPointerProperties::Button::Left, - PlatformEvent::MousePressed, 1, PlatformEvent::Modifiers::LeftButtonDown, - TimeTicks::Now()); + WebMouseEvent mouseDownEvent( + WebInputEvent::MouseDown, WebFloatPoint(50, 50), WebFloatPoint(50, 50), + WebPointerProperties::Button::Left, 1, + PlatformEvent::Modifiers::LeftButtonDown, TimeTicks::Now().InSeconds()); + mouseDownEvent.setFrameScale(1); document().frame()->eventHandler().handleMousePressEvent(mouseDownEvent); - PlatformMouseEvent mouseMoveEvent( - IntPoint(51, 50), IntPoint(51, 50), WebPointerProperties::Button::Left, - PlatformEvent::MouseMoved, 1, PlatformEvent::Modifiers::LeftButtonDown, - TimeTicks::Now()); + WebMouseEvent mouseMoveEvent( + WebInputEvent::MouseMove, WebFloatPoint(51, 50), WebFloatPoint(51, 50), + WebPointerProperties::Button::Left, 1, + PlatformEvent::Modifiers::LeftButtonDown, TimeTicks::Now().InSeconds()); + mouseMoveEvent.setFrameScale(1); document().frame()->eventHandler().handleMouseMoveEvent( - mouseMoveEvent, Vector()); + mouseMoveEvent, Vector()); // This reproduces what might be the conditions of http://crbug.com/677916 // @@ -406,10 +423,11 @@ TEST_F(EventHandlerTest, dragEndInNewDrag) { // this contrived test. Given the current code, it is unclear how the // dragSourceEndedAt() call could occur before a drag operation is started. - PlatformMouseEvent mouseUpEvent( - IntPoint(100, 50), IntPoint(200, 250), WebPointerProperties::Button::Left, - PlatformEvent::MouseReleased, 1, static_cast(0), - TimeTicks::Now()); + WebMouseEvent mouseUpEvent( + WebInputEvent::MouseUp, WebFloatPoint(100, 50), WebFloatPoint(200, 250), + WebPointerProperties::Button::Left, 1, + static_cast(0), TimeTicks::Now().InSeconds()); + mouseUpEvent.setFrameScale(1); document().frame()->eventHandler().dragSourceEndedAt(mouseUpEvent, DragOperationNone); diff --git a/third_party/WebKit/Source/core/input/EventHandlingUtil.cpp b/third_party/WebKit/Source/core/input/EventHandlingUtil.cpp index 908de11084e01b..4c8e0fb2ba5c5f 100644 --- a/third_party/WebKit/Source/core/input/EventHandlingUtil.cpp +++ b/third_party/WebKit/Source/core/input/EventHandlingUtil.cpp @@ -9,6 +9,7 @@ #include "core/layout/api/LayoutViewItem.h" #include "core/paint/PaintLayer.h" #include "platform/scroll/ScrollableArea.h" +#include "public/platform/WebMouseEvent.h" namespace blink { namespace EventHandlingUtil { @@ -110,12 +111,14 @@ LayoutPoint contentPointFromRootFrame(LocalFrame* frame, MouseEventWithHitTestResults performMouseEventHitTest( LocalFrame* frame, const HitTestRequest& request, - const PlatformMouseEvent& mev) { + const WebMouseEvent& mev) { DCHECK(frame); DCHECK(frame->document()); return frame->document()->performMouseEventHitTest( - request, contentPointFromRootFrame(frame, mev.position()), mev); + request, contentPointFromRootFrame( + frame, flooredIntPoint(mev.positionInRootFrame())), + mev); } } // namespace EventHandlingUtil diff --git a/third_party/WebKit/Source/core/input/EventHandlingUtil.h b/third_party/WebKit/Source/core/input/EventHandlingUtil.h index 558ae12dc89884..8e45b6bf6b6110 100644 --- a/third_party/WebKit/Source/core/input/EventHandlingUtil.h +++ b/third_party/WebKit/Source/core/input/EventHandlingUtil.h @@ -36,10 +36,9 @@ ContainerNode* parentForClickEvent(const Node&); LayoutPoint contentPointFromRootFrame(LocalFrame*, const IntPoint& pointInRootFrame); -MouseEventWithHitTestResults performMouseEventHitTest( - LocalFrame*, - const HitTestRequest&, - const PlatformMouseEvent&); +MouseEventWithHitTestResults performMouseEventHitTest(LocalFrame*, + const HitTestRequest&, + const WebMouseEvent&); } // namespace EventHandlingUtil diff --git a/third_party/WebKit/Source/core/input/GestureManager.cpp b/third_party/WebKit/Source/core/input/GestureManager.cpp index 780be37131a5aa..5646057fc0f7b8 100644 --- a/third_party/WebKit/Source/core/input/GestureManager.cpp +++ b/third_party/WebKit/Source/core/input/GestureManager.cpp @@ -150,15 +150,16 @@ WebInputEventResult GestureManager::handleGestureTap( const unsigned modifiers = gestureEvent.modifiers(); if (!m_suppressMouseEventsFromGestures) { - PlatformMouseEvent fakeMouseMove( - gestureEvent, WebPointerProperties::Button::NoButton, - PlatformEvent::MouseMoved, - /* clickCount */ 0, static_cast(modifiers), - PlatformMouseEvent::FromTouch, - TimeTicks::FromSeconds(gestureEvent.timeStampSeconds()), - WebPointerProperties::PointerType::Mouse); + WebMouseEvent fakeMouseMove( + WebInputEvent::MouseMove, gestureEvent, + WebPointerProperties::Button::NoButton, + /* clickCount */ 0, + static_cast( + modifiers | WebInputEvent::Modifiers::IsCompatibilityEventForTouch), + gestureEvent.timeStampSeconds()); m_mouseEventManager->setMousePositionAndDispatchMouseEvent( - currentHitTest.innerNode(), EventTypeNames::mousemove, fakeMouseMove); + currentHitTest.innerNode(), currentHitTest.canvasRegionId(), + EventTypeNames::mousemove, fakeMouseMove); } // Do a new hit-test in case the mousemove event changed the DOM. @@ -192,14 +193,13 @@ WebInputEventResult GestureManager::handleGestureTap( m_mouseEventManager->setClickNode(tappedNonTextNode); - PlatformMouseEvent fakeMouseDown( - gestureEvent, WebPointerProperties::Button::Left, - PlatformEvent::MousePressed, gestureEvent.tapCount(), - static_cast(modifiers | - PlatformEvent::LeftButtonDown), - PlatformMouseEvent::FromTouch, - TimeTicks::FromSeconds(gestureEvent.timeStampSeconds()), - WebPointerProperties::PointerType::Mouse); + WebMouseEvent fakeMouseDown( + WebInputEvent::MouseDown, gestureEvent, + WebPointerProperties::Button::Left, gestureEvent.tapCount(), + static_cast( + modifiers | WebInputEvent::Modifiers::LeftButtonDown | + WebInputEvent::Modifiers::IsCompatibilityEventForTouch), + gestureEvent.timeStampSeconds()); // TODO(mustaq): We suppress MEs plus all it's side effects. What would that // mean for for TEs? What's the right balance here? crbug.com/617255 @@ -210,8 +210,8 @@ WebInputEventResult GestureManager::handleGestureTap( mouseDownEventResult = m_mouseEventManager->setMousePositionAndDispatchMouseEvent( - currentHitTest.innerNode(), EventTypeNames::mousedown, - fakeMouseDown); + currentHitTest.innerNode(), currentHitTest.canvasRegionId(), + EventTypeNames::mousedown, fakeMouseDown); m_selectionController->initializeSelectionState(); if (mouseDownEventResult == WebInputEventResult::NotHandled) mouseDownEventResult = m_mouseEventManager->handleMouseFocus( @@ -240,19 +240,18 @@ WebInputEventResult GestureManager::handleGestureTap( m_frame, adjustedPoint, hitType); } - PlatformMouseEvent fakeMouseUp( - gestureEvent, WebPointerProperties::Button::Left, - PlatformEvent::MouseReleased, gestureEvent.tapCount(), - static_cast(modifiers), - PlatformMouseEvent::FromTouch, - TimeTicks::FromSeconds(gestureEvent.timeStampSeconds()), - WebPointerProperties::PointerType::Mouse); + WebMouseEvent fakeMouseUp( + WebInputEvent::MouseUp, gestureEvent, WebPointerProperties::Button::Left, + gestureEvent.tapCount(), + static_cast( + modifiers | WebInputEvent::Modifiers::IsCompatibilityEventForTouch), + gestureEvent.timeStampSeconds()); WebInputEventResult mouseUpEventResult = m_suppressMouseEventsFromGestures ? WebInputEventResult::HandledSuppressed : m_mouseEventManager->setMousePositionAndDispatchMouseEvent( - currentHitTest.innerNode(), EventTypeNames::mouseup, - fakeMouseUp); + currentHitTest.innerNode(), currentHitTest.canvasRegionId(), + EventTypeNames::mouseup, fakeMouseUp); WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; if (tappedNonTextNode) { @@ -268,7 +267,7 @@ WebInputEventResult GestureManager::handleGestureTap( *tappedNonTextNode, EventHandlingUtil::parentForClickEvent); clickEventResult = m_mouseEventManager->setMousePositionAndDispatchMouseEvent( - clickTargetNode, EventTypeNames::click, fakeMouseUp); + clickTargetNode, String(), EventTypeNames::click, fakeMouseUp); } m_mouseEventManager->setClickNode(nullptr); } @@ -361,30 +360,31 @@ WebInputEventResult GestureManager::sendContextMenuEventForGesture( unsigned modifiers = gestureEvent.modifiers(); if (!m_suppressMouseEventsFromGestures) { - // Send MouseMoved event prior to handling (https://crbug.com/485290). - PlatformMouseEvent fakeMouseMove( - gestureEvent, WebPointerProperties::Button::NoButton, - PlatformEvent::MouseMoved, - /* clickCount */ 0, static_cast(modifiers), - PlatformMouseEvent::FromTouch, - TimeTicks::FromSeconds(gestureEvent.timeStampSeconds()), - WebPointerProperties::PointerType::Mouse); + // Send MouseMove event prior to handling (https://crbug.com/485290). + WebMouseEvent fakeMouseMove( + WebInputEvent::MouseMove, gestureEvent, + WebPointerProperties::Button::NoButton, + /* clickCount */ 0, + static_cast( + modifiers | WebInputEvent::IsCompatibilityEventForTouch), + gestureEvent.timeStampSeconds()); m_mouseEventManager->setMousePositionAndDispatchMouseEvent( - targetedEvent.hitTestResult().innerNode(), EventTypeNames::mousemove, + targetedEvent.hitTestResult().innerNode(), + targetedEvent.canvasRegionId(), EventTypeNames::mousemove, fakeMouseMove); } - PlatformEvent::EventType eventType = PlatformEvent::MousePressed; + WebInputEvent::Type eventType = WebInputEvent::MouseDown; if (m_frame->settings() && m_frame->settings()->getShowContextMenuOnMouseUp()) - eventType = PlatformEvent::MouseReleased; + eventType = WebInputEvent::MouseUp; - PlatformMouseEvent mouseEvent( - gestureEvent, WebPointerProperties::Button::Right, eventType, + WebMouseEvent mouseEvent( + eventType, gestureEvent, WebPointerProperties::Button::Right, /* clickCount */ 1, static_cast( - modifiers | PlatformEvent::Modifiers::RightButtonDown), - PlatformMouseEvent::FromTouch, TimeTicks::Now(), - WebPointerProperties::PointerType::Mouse); + modifiers | PlatformEvent::Modifiers::RightButtonDown | + WebInputEvent::IsCompatibilityEventForTouch), + gestureEvent.timeStampSeconds()); if (!m_suppressMouseEventsFromGestures && m_frame->view()) { HitTestRequest request(HitTestRequest::Active); diff --git a/third_party/WebKit/Source/core/input/MouseEventManager.cpp b/third_party/WebKit/Source/core/input/MouseEventManager.cpp index bb2943116f4784..aaca3de4a6922a 100644 --- a/third_party/WebKit/Source/core/input/MouseEventManager.cpp +++ b/third_party/WebKit/Source/core/input/MouseEventManager.cpp @@ -35,25 +35,21 @@ namespace blink { namespace { -PlatformMouseEvent mouseEventWithRegion(Node* node, - const PlatformMouseEvent& mouseEvent) { +String canvasRegionId(Node* node, const WebMouseEvent& mouseEvent) { if (!node->isElementNode()) - return mouseEvent; + return String(); Element* element = toElement(node); if (!element->isInCanvasSubtree()) - return mouseEvent; + return String(); HTMLCanvasElement* canvas = Traversal::firstAncestorOrSelf(*element); // In this case, the event target is canvas and mouse rerouting doesn't // happen. if (canvas == element) - return mouseEvent; - String region = canvas->getIdFromControl(element); - PlatformMouseEvent newMouseEvent = mouseEvent; - newMouseEvent.setRegion(region); - return newMouseEvent; + return String(); + return canvas->getIdFromControl(element); } // The amount of time to wait before sending a fake mouse event triggered @@ -100,7 +96,7 @@ void MouseEventManager::clear() { m_clickNode = nullptr; m_mouseDownPos = IntPoint(); m_mouseDownTimestamp = TimeTicks(); - m_mouseDown = PlatformMouseEvent(); + m_mouseDown = WebMouseEvent(); m_svgPan = false; m_dragStartPos = LayoutPoint(); m_fakeMouseMoveEventTimer.stop(); @@ -118,46 +114,45 @@ DEFINE_TRACE(MouseEventManager) { } MouseEventManager::MouseEventBoundaryEventDispatcher:: - MouseEventBoundaryEventDispatcher( - MouseEventManager* mouseEventManager, - const PlatformMouseEvent* platformMouseEvent, - EventTarget* exitedTarget) + MouseEventBoundaryEventDispatcher(MouseEventManager* mouseEventManager, + const WebMouseEvent* webMouseEvent, + EventTarget* exitedTarget, + const String& canvasRegionId) : m_mouseEventManager(mouseEventManager), - m_platformMouseEvent(platformMouseEvent), - m_exitedTarget(exitedTarget) {} + m_webMouseEvent(webMouseEvent), + m_exitedTarget(exitedTarget), + m_canvasRegionId(canvasRegionId) {} void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatchOut( EventTarget* target, EventTarget* relatedTarget) { - dispatch( - target, relatedTarget, EventTypeNames::mouseout, - mouseEventWithRegion(m_exitedTarget->toNode(), *m_platformMouseEvent), - false); + dispatch(target, relatedTarget, EventTypeNames::mouseout, + canvasRegionId(m_exitedTarget->toNode(), *m_webMouseEvent), + *m_webMouseEvent, false); } void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatchOver( EventTarget* target, EventTarget* relatedTarget) { - dispatch(target, relatedTarget, EventTypeNames::mouseover, - *m_platformMouseEvent, false); + dispatch(target, relatedTarget, EventTypeNames::mouseover, m_canvasRegionId, + *m_webMouseEvent, false); } void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatchLeave( EventTarget* target, EventTarget* relatedTarget, bool checkForListener) { - dispatch( - target, relatedTarget, EventTypeNames::mouseleave, - mouseEventWithRegion(m_exitedTarget->toNode(), *m_platformMouseEvent), - checkForListener); + dispatch(target, relatedTarget, EventTypeNames::mouseleave, + canvasRegionId(m_exitedTarget->toNode(), *m_webMouseEvent), + *m_webMouseEvent, checkForListener); } void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatchEnter( EventTarget* target, EventTarget* relatedTarget, bool checkForListener) { - dispatch(target, relatedTarget, EventTypeNames::mouseenter, - *m_platformMouseEvent, checkForListener); + dispatch(target, relatedTarget, EventTypeNames::mouseenter, m_canvasRegionId, + *m_webMouseEvent, checkForListener); } AtomicString @@ -174,25 +169,28 @@ void MouseEventManager::MouseEventBoundaryEventDispatcher::dispatch( EventTarget* target, EventTarget* relatedTarget, const AtomicString& type, - const PlatformMouseEvent& platformMouseEvent, + const String& canvasRegionId, + const WebMouseEvent& webMouseEvent, bool checkForListener) { - m_mouseEventManager->dispatchMouseEvent(target, type, platformMouseEvent, - relatedTarget, checkForListener); + m_mouseEventManager->dispatchMouseEvent(target, type, webMouseEvent, + canvasRegionId, relatedTarget, + checkForListener); } -void MouseEventManager::sendBoundaryEvents( - EventTarget* exitedTarget, - EventTarget* enteredTarget, - const PlatformMouseEvent& mousePlatformEvent) { +void MouseEventManager::sendBoundaryEvents(EventTarget* exitedTarget, + EventTarget* enteredTarget, + const String& canvasRegionId, + const WebMouseEvent& mouseEvent) { MouseEventBoundaryEventDispatcher boundaryEventDispatcher( - this, &mousePlatformEvent, exitedTarget); + this, &mouseEvent, exitedTarget, canvasRegionId); boundaryEventDispatcher.sendBoundaryEvents(exitedTarget, enteredTarget); } WebInputEventResult MouseEventManager::dispatchMouseEvent( EventTarget* target, const AtomicString& mouseEventType, - const PlatformMouseEvent& mouseEvent, + const WebMouseEvent& mouseEvent, + const String& canvasRegionId, EventTarget* relatedTarget, bool checkForListener) { if (target && target->toNode() && @@ -206,9 +204,10 @@ WebInputEventResult MouseEventManager::dispatchMouseEvent( mouseEventType == EventTypeNames::dblclick) { clickCount = m_clickCount; } - MouseEvent* event = MouseEvent::create( - mouseEventType, targetNode->document().domWindow(), mouseEvent, - clickCount, relatedTarget ? relatedTarget->toNode() : nullptr); + MouseEvent* event = + MouseEvent::create(mouseEventType, targetNode->document().domWindow(), + mouseEvent, clickCount, canvasRegionId, + relatedTarget ? relatedTarget->toNode() : nullptr); DispatchEventResult dispatchResult = target->dispatchEvent(event); return EventHandlingUtil::toWebInputEventResult(dispatchResult); } @@ -217,32 +216,32 @@ WebInputEventResult MouseEventManager::dispatchMouseEvent( WebInputEventResult MouseEventManager::setMousePositionAndDispatchMouseEvent( Node* targetNode, + const String& canvasRegionId, const AtomicString& eventType, - const PlatformMouseEvent& platformMouseEvent) { + const WebMouseEvent& webMouseEvent) { // If the target node is a text node, dispatch on the parent node. if (targetNode && targetNode->isTextNode()) targetNode = FlatTreeTraversal::parent(*targetNode); - setNodeUnderMouse(targetNode, platformMouseEvent); + setNodeUnderMouse(targetNode, canvasRegionId, webMouseEvent); - return dispatchMouseEvent(m_nodeUnderMouse, eventType, platformMouseEvent, - nullptr); + return dispatchMouseEvent(m_nodeUnderMouse, eventType, webMouseEvent, + canvasRegionId, nullptr); } WebInputEventResult MouseEventManager::dispatchMouseClickIfNeeded( const MouseEventWithHitTestResults& mev) { // We only prevent click event when the click may cause contextmenu to popup. // However, we always send auxclick. - bool contextMenuEvent = !RuntimeEnabledFeatures::auxclickEnabled() && - mev.event().pointerProperties().button == - WebPointerProperties::Button::Right; + bool contextMenuEvent = + !RuntimeEnabledFeatures::auxclickEnabled() && + mev.event().button == WebPointerProperties::Button::Right; #if OS(MACOSX) // FIXME: The Mac port achieves the same behavior by checking whether the // context menu is currently open in WebPage::mouseEvent(). Consider merging // the implementations. - if (mev.event().pointerProperties().button == - WebPointerProperties::Button::Left && - mev.event().getModifiers() & PlatformEvent::CtrlKey) + if (mev.event().button == WebPointerProperties::Button::Left && + mev.event().modifiers() & WebInputEvent::Modifiers::ControlKey) contextMenuEvent = true; #endif @@ -269,12 +268,12 @@ WebInputEventResult MouseEventManager::dispatchMouseClickIfNeeded( } if (clickTargetNode) { clickEventResult = dispatchMouseEvent( - clickTargetNode, !RuntimeEnabledFeatures::auxclickEnabled() || - (mev.event().pointerProperties().button == - WebPointerProperties::Button::Left) - ? EventTypeNames::click - : EventTypeNames::auxclick, - mev.event(), nullptr); + clickTargetNode, + !RuntimeEnabledFeatures::auxclickEnabled() || + (mev.event().button == WebPointerProperties::Button::Left) + ? EventTypeNames::click + : EventTypeNames::auxclick, + mev.event(), mev.canvasRegionId(), nullptr); } } return clickEventResult; @@ -300,14 +299,17 @@ void MouseEventManager::fakeMouseMoveEventTimerFired(TimerBase* timer) { if (!m_frame->page()->isCursorVisible()) return; - PlatformMouseEvent fakeMouseMoveEvent( - m_lastKnownMousePosition, m_lastKnownMouseGlobalPosition, - WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 0, - static_cast( - KeyboardEventManager::getCurrentModifierState()), - PlatformMouseEvent::RealOrIndistinguishable, TimeTicks::Now(), - WebPointerProperties::PointerType::Mouse); - Vector coalescedEvents; + WebMouseEvent fakeMouseMoveEvent( + WebInputEvent::MouseMove, + WebFloatPoint(m_lastKnownMousePosition.x(), m_lastKnownMousePosition.y()), + WebFloatPoint(m_lastKnownMouseGlobalPosition.x(), + m_lastKnownMouseGlobalPosition.y()), + WebPointerProperties::Button::NoButton, 0, + KeyboardEventManager::getCurrentModifierState(), + TimeTicks::Now().InSeconds()); + // TODO(dtapuska): Update m_lastKnowMousePosition to be viewport coordinates. + fakeMouseMoveEvent.setFrameScale(1); + Vector coalescedEvents; m_frame->eventHandler().handleMouseMoveEvent(fakeMouseMoveEvent, coalescedEvents); } @@ -316,9 +318,9 @@ void MouseEventManager::cancelFakeMouseMoveEvent() { m_fakeMouseMoveEventTimer.stop(); } -void MouseEventManager::setNodeUnderMouse( - Node* target, - const PlatformMouseEvent& platformMouseEvent) { +void MouseEventManager::setNodeUnderMouse(Node* target, + const String& canvasRegionId, + const WebMouseEvent& webMouseEvent) { Node* lastNodeUnderMouse = m_nodeUnderMouse; m_nodeUnderMouse = target; @@ -367,7 +369,8 @@ void MouseEventManager::setNodeUnderMouse( lastNodeUnderMouse = nullptr; } - sendBoundaryEvents(lastNodeUnderMouse, m_nodeUnderMouse, platformMouseEvent); + sendBoundaryEvents(lastNodeUnderMouse, m_nodeUnderMouse, canvasRegionId, + webMouseEvent); } void MouseEventManager::nodeChildrenWillBeRemoved(ContainerNode& container) { @@ -493,17 +496,18 @@ bool MouseEventManager::slideFocusOnShadowHostIfNecessary( } void MouseEventManager::handleMousePressEventUpdateStates( - const PlatformMouseEvent& mouseEvent) { + const WebMouseEvent& mouseEvent) { cancelFakeMouseMoveEvent(); m_mousePressed = true; m_capturesDragging = true; setLastKnownMousePosition(mouseEvent); m_mouseDownMayStartDrag = false; m_mouseDownMayStartAutoscroll = false; - m_mouseDownTimestamp = mouseEvent.timestamp(); + m_mouseDownTimestamp = TimeTicks::FromSeconds(mouseEvent.timeStampSeconds()); if (FrameView* view = m_frame->view()) { - m_mouseDownPos = view->rootFrameToContents(mouseEvent.position()); + m_mouseDownPos = view->rootFrameToContents( + flooredIntPoint(mouseEvent.positionInRootFrame())); } else { invalidateClick(); } @@ -517,11 +521,10 @@ IntPoint MouseEventManager::lastKnownMousePosition() { return m_lastKnownMousePosition; } -void MouseEventManager::setLastKnownMousePosition( - const PlatformMouseEvent& event) { +void MouseEventManager::setLastKnownMousePosition(const WebMouseEvent& event) { m_isMousePositionUnknown = false; - m_lastKnownMousePosition = event.position(); - m_lastKnownMouseGlobalPosition = event.globalPosition(); + m_lastKnownMousePosition = flooredIntPoint(event.positionInRootFrame()); + m_lastKnownMouseGlobalPosition = IntPoint(event.globalX, event.globalY); } void MouseEventManager::dispatchFakeMouseMoveEventSoon() { @@ -561,11 +564,12 @@ WebInputEventResult MouseEventManager::handleMousePressEvent( m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); if (FrameView* frameView = m_frame->view()) { - if (frameView->isPointInScrollbarCorner(event.event().position())) + if (frameView->isPointInScrollbarCorner( + flooredIntPoint(event.event().positionInRootFrame()))) return WebInputEventResult::NotHandled; } - bool singleClick = event.event().clickCount() <= 1; + bool singleClick = event.event().clickCount <= 1; m_mouseDownMayStartDrag = singleClick && !isLinkSelection(event) && !isExtendingSelection(event); @@ -576,10 +580,12 @@ WebInputEventResult MouseEventManager::handleMousePressEvent( if (m_frame->document()->isSVGDocument() && m_frame->document()->accessSVGExtensions().zoomAndPanEnabled()) { - if (event.event().shiftKey() && singleClick) { + if ((event.event().modifiers() & WebInputEvent::Modifiers::ShiftKey) && + singleClick) { m_svgPan = true; m_frame->document()->accessSVGExtensions().startPan( - m_frame->view()->rootFrameToContents(event.event().position())); + m_frame->view()->rootFrameToContents( + flooredIntPoint(event.event().positionInRootFrame()))); return WebInputEventResult::HandledSystem; } } @@ -593,16 +599,16 @@ WebInputEventResult MouseEventManager::handleMousePressEvent( m_mousePressNode = innerNode; m_frame->document()->setSequentialFocusNavigationStartingPoint(innerNode); - m_dragStartPos = event.event().position(); + m_dragStartPos = flooredIntPoint(event.event().positionInRootFrame()); bool swallowEvent = false; m_mousePressed = true; - if (event.event().clickCount() == 2) { + if (event.event().clickCount == 2) { swallowEvent = m_frame->eventHandler() .selectionController() .handleMousePressEventDoubleClick(event); - } else if (event.event().clickCount() >= 3) { + } else if (event.event().clickCount >= 3) { swallowEvent = m_frame->eventHandler() .selectionController() .handleMousePressEventTripleClick(event); @@ -647,30 +653,28 @@ bool MouseEventManager::handleDragDropIfPossible( // TODO(mustaq): Suppressing long-tap MouseEvents could break // drag-drop. Will do separately because of the risk. crbug.com/606938. - PlatformMouseEvent mouseDownEvent( - gestureEvent, WebPointerProperties::Button::Left, - PlatformEvent::MousePressed, 1, - static_cast(modifiers | - PlatformEvent::LeftButtonDown), - PlatformMouseEvent::FromTouch, TimeTicks::Now(), - WebPointerProperties::PointerType::Mouse); + WebMouseEvent mouseDownEvent( + WebInputEvent::MouseDown, gestureEvent, + WebPointerProperties::Button::Left, 1, + modifiers | WebInputEvent::Modifiers::LeftButtonDown | + WebInputEvent::Modifiers::IsCompatibilityEventForTouch, + TimeTicks::Now().InSeconds()); m_mouseDown = mouseDownEvent; - PlatformMouseEvent mouseDragEvent( - gestureEvent, WebPointerProperties::Button::Left, - PlatformEvent::MouseMoved, 1, - static_cast(modifiers | - PlatformEvent::LeftButtonDown), - PlatformMouseEvent::FromTouch, TimeTicks::Now(), - WebPointerProperties::PointerType::Mouse); + WebMouseEvent mouseDragEvent( + WebInputEvent::MouseMove, gestureEvent, + WebPointerProperties::Button::Left, 1, + modifiers | WebInputEvent::Modifiers::LeftButtonDown | + WebInputEvent::Modifiers::IsCompatibilityEventForTouch, + TimeTicks::Now().InSeconds()); HitTestRequest request(HitTestRequest::ReadOnly); MouseEventWithHitTestResults mev = EventHandlingUtil::performMouseEventHitTest(m_frame, request, mouseDragEvent); m_mouseDownMayStartDrag = true; dragState().m_dragSrc = nullptr; - m_mouseDownPos = - m_frame->view()->rootFrameToContents(mouseDragEvent.position()); + m_mouseDownPos = m_frame->view()->rootFrameToContents( + flooredIntPoint(mouseDragEvent.positionInRootFrame())); return handleDrag(mev, DragInitiator::Touch); } return false; @@ -701,8 +705,7 @@ WebInputEventResult MouseEventManager::handleMouseDraggedEvent( // that ends as a result of a mouse release does not send a mouse release // event. As a result, m_mousePressed also ends up remaining true until // the next mouse release event seen by the EventHandler. - if (event.event().pointerProperties().button != - WebPointerProperties::Button::Left) + if (event.event().button != WebPointerProperties::Button::Left) m_mousePressed = false; if (!m_mousePressed) @@ -751,7 +754,7 @@ WebInputEventResult MouseEventManager::handleMouseDraggedEvent( bool MouseEventManager::handleDrag(const MouseEventWithHitTestResults& event, DragInitiator initiator) { - DCHECK(event.event().type() == PlatformEvent::MouseMoved); + DCHECK(event.event().type() == WebInputEvent::MouseMove); // Callers must protect the reference to FrameView, since this function may // dispatch DOM events, causing page/FrameView to go away. DCHECK(m_frame); @@ -766,7 +769,9 @@ bool MouseEventManager::handleDrag(const MouseEventWithHitTestResults& event, Node* node = result.innerNode(); if (node) { DragController::SelectionDragPolicy selectionDragPolicy = - event.event().timestamp() - m_mouseDownTimestamp < kTextDragDelay + TimeTicks::FromSeconds(event.event().timeStampSeconds()) - + m_mouseDownTimestamp < + kTextDragDelay ? DragController::DelayedSelectionDragResolution : DragController::ImmediateSelectionDragResolution; dragState().m_dragSrc = m_frame->page()->dragController().draggableNode( @@ -794,7 +799,8 @@ bool MouseEventManager::handleDrag(const MouseEventWithHitTestResults& event, m_frame->view()->setCursor(pointerCursor()); if (initiator == DragInitiator::Mouse && - !dragThresholdExceeded(event.event().position())) { + !dragThresholdExceeded( + flooredIntPoint(event.event().positionInRootFrame()))) { dragState().m_dragSrc = nullptr; return true; } @@ -867,7 +873,7 @@ bool MouseEventManager::tryStartDrag( // eventhandler canceled. WebInputEventResult MouseEventManager::dispatchDragSrcEvent( const AtomicString& eventType, - const PlatformMouseEvent& event) { + const WebMouseEvent& event) { return dispatchDragEvent(eventType, dragState().m_dragSrc.get(), event, dragState().m_dragDataTransfer.get()); } @@ -875,7 +881,7 @@ WebInputEventResult MouseEventManager::dispatchDragSrcEvent( WebInputEventResult MouseEventManager::dispatchDragEvent( const AtomicString& eventType, Node* dragTarget, - const PlatformMouseEvent& event, + const WebMouseEvent& event, DataTransfer* dataTransfer) { FrameView* view = m_frame->view(); @@ -886,13 +892,16 @@ WebInputEventResult MouseEventManager::dispatchDragEvent( const bool cancelable = eventType != EventTypeNames::dragleave && eventType != EventTypeNames::dragend; + IntPoint position = flooredIntPoint(event.positionInRootFrame()); + IntPoint movement = flooredIntPoint(event.movementInRootFrame()); DragEvent* me = DragEvent::create( eventType, true, cancelable, m_frame->document()->domWindow(), 0, - event.globalPosition().x(), event.globalPosition().y(), - event.position().x(), event.position().y(), event.movementDelta().x(), - event.movementDelta().y(), event.getModifiers(), 0, - MouseEvent::platformModifiersToButtons(event.getModifiers()), nullptr, - event.timestamp(), dataTransfer, event.getSyntheticEventType()); + event.globalX, event.globalY, position.x(), position.y(), movement.x(), + movement.y(), static_cast(event.modifiers()), 0, + MouseEvent::platformModifiersToButtons(event.modifiers()), nullptr, + TimeTicks::FromSeconds(event.timeStampSeconds()), dataTransfer, + event.fromTouch() ? MouseEvent::FromTouch + : MouseEvent::RealOrIndistinguishable); return EventHandlingUtil::toWebInputEventResult( dragTarget->dispatchEvent(me)); @@ -905,7 +914,7 @@ void MouseEventManager::clearDragDataTransfer() { } } -void MouseEventManager::dragSourceEndedAt(const PlatformMouseEvent& event, +void MouseEventManager::dragSourceEndedAt(const WebMouseEvent& event, DragOperation operation) { if (dragState().m_dragSrc) { dragState().m_dragDataTransfer->setDestinationOperation(operation); diff --git a/third_party/WebKit/Source/core/input/MouseEventManager.h b/third_party/WebKit/Source/core/input/MouseEventManager.h index aa8640a042e6c2..0628dfb560b3d6 100644 --- a/third_party/WebKit/Source/core/input/MouseEventManager.h +++ b/third_party/WebKit/Source/core/input/MouseEventManager.h @@ -10,9 +10,9 @@ #include "core/input/BoundaryEventDispatcher.h" #include "core/page/DragActions.h" #include "core/page/EventWithHitTestResults.h" -#include "platform/PlatformMouseEvent.h" #include "platform/Timer.h" #include "public/platform/WebInputEventResult.h" +#include "public/platform/WebMouseEvent.h" #include "wtf/Allocator.h" #include "wtf/Time.h" @@ -45,23 +45,25 @@ class CORE_EXPORT MouseEventManager final WebInputEventResult dispatchMouseEvent(EventTarget*, const AtomicString&, - const PlatformMouseEvent&, + const WebMouseEvent&, + const String& canvasRegionId, EventTarget* relatedTarget, bool checkForListener = false); WebInputEventResult setMousePositionAndDispatchMouseEvent( Node* targetNode, + const String& canvasRegionId, const AtomicString& eventType, - const PlatformMouseEvent&); + const WebMouseEvent&); WebInputEventResult dispatchMouseClickIfNeeded( const MouseEventWithHitTestResults&); WebInputEventResult dispatchDragSrcEvent(const AtomicString& eventType, - const PlatformMouseEvent&); + const WebMouseEvent&); WebInputEventResult dispatchDragEvent(const AtomicString& eventType, Node* target, - const PlatformMouseEvent&, + const WebMouseEvent&, DataTransfer*); // Resets the internal state of this object. @@ -69,9 +71,12 @@ class CORE_EXPORT MouseEventManager final void sendBoundaryEvents(EventTarget* exitedTarget, EventTarget* enteredTarget, - const PlatformMouseEvent& mousePlatformEvent); + const String& canvasRegionId, + const WebMouseEvent&); - void setNodeUnderMouse(Node*, const PlatformMouseEvent&); + void setNodeUnderMouse(Node*, + const String& canvasRegionId, + const WebMouseEvent&); WebInputEventResult handleMouseFocus( const HitTestResult&, @@ -83,7 +88,7 @@ class CORE_EXPORT MouseEventManager final void dispatchFakeMouseMoveEventSoon(); void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&); - void setLastKnownMousePosition(const PlatformMouseEvent&); + void setLastKnownMousePosition(const WebMouseEvent&); bool handleDragDropIfPossible(const GestureEventWithHitTestResults&); @@ -103,11 +108,11 @@ class CORE_EXPORT MouseEventManager final // drag heuristics. void clearDragHeuristicState(); - void dragSourceEndedAt(const PlatformMouseEvent&, DragOperation); + void dragSourceEndedAt(const WebMouseEvent&, DragOperation); void updateSelectionForMouseDrag(); - void handleMousePressEventUpdateStates(const PlatformMouseEvent&); + void handleMousePressEventUpdateStates(const WebMouseEvent&); // Returns whether pan is handled and resets the state on release. bool handleSvgPanIfNeeded(bool isReleaseEvent); @@ -144,8 +149,9 @@ class CORE_EXPORT MouseEventManager final public: MouseEventBoundaryEventDispatcher(MouseEventManager*, - const PlatformMouseEvent*, - EventTarget* exitedTarget); + const WebMouseEvent*, + EventTarget* exitedTarget, + const String& canvasRegionId); protected: void dispatchOut(EventTarget*, EventTarget* relatedTarget) override; @@ -163,11 +169,13 @@ class CORE_EXPORT MouseEventManager final void dispatch(EventTarget*, EventTarget* relatedTarget, const AtomicString&, - const PlatformMouseEvent&, + const String& canvasRegionId, + const WebMouseEvent&, bool checkForListener); Member m_mouseEventManager; - const PlatformMouseEvent* m_platformMouseEvent; + const WebMouseEvent* m_webMouseEvent; Member m_exitedTarget; + String m_canvasRegionId; }; // If the given element is a shadow host and its root has delegatesFocus=false @@ -218,7 +226,7 @@ class CORE_EXPORT MouseEventManager final IntPoint m_mouseDownPos; // In our view's coords. TimeTicks m_mouseDownTimestamp; - PlatformMouseEvent m_mouseDown; + WebMouseEvent m_mouseDown; LayoutPoint m_dragStartPos; diff --git a/third_party/WebKit/Source/core/input/PointerEventManager.cpp b/third_party/WebKit/Source/core/input/PointerEventManager.cpp index 3d22ce286adfef..ae2d1960c00134 100644 --- a/third_party/WebKit/Source/core/input/PointerEventManager.cpp +++ b/third_party/WebKit/Source/core/input/PointerEventManager.cpp @@ -180,12 +180,13 @@ EventTarget* PointerEventManager::getEffectiveTargetForPointerEvent( void PointerEventManager::sendMouseAndPointerBoundaryEvents( Node* enteredNode, - const PlatformMouseEvent& mouseEvent) { + const String& canvasRegionId, + const WebMouseEvent& mouseEvent) { // Mouse event type does not matter as this pointerevent will only be used // to create boundary pointer events and its type will be overridden in // |sendBoundaryEvents| function. PointerEvent* dummyPointerEvent = m_pointerEventFactory.create( - EventTypeNames::mousedown, mouseEvent, Vector(), + EventTypeNames::mousedown, mouseEvent, Vector(), m_frame->document()->domWindow()); // TODO(crbug/545647): This state should reset with pointercancel too. @@ -195,11 +196,11 @@ void PointerEventManager::sendMouseAndPointerBoundaryEvents( // behavior regarding preventMouseEvent state in that case. if (dummyPointerEvent->buttons() == 0 && dummyPointerEvent->isPrimary()) { m_preventMouseEventForPointerType[toPointerTypeIndex( - mouseEvent.pointerProperties().pointerType)] = false; + mouseEvent.pointerType)] = false; } processCaptureAndPositionOfPointerEvent(dummyPointerEvent, enteredNode, - mouseEvent, true); + canvasRegionId, mouseEvent, true); } void PointerEventManager::sendBoundaryEvents(EventTarget* exitedTarget, @@ -439,9 +440,10 @@ WebInputEventResult PointerEventManager::sendTouchPointerEvent( WebInputEventResult PointerEventManager::sendMousePointerEvent( Node* target, + const String& canvasRegionId, const AtomicString& mouseEventType, - const PlatformMouseEvent& mouseEvent, - const Vector& coalescedEvents) { + const WebMouseEvent& mouseEvent, + const Vector& coalescedEvents) { PointerEvent* pointerEvent = m_pointerEventFactory.create(mouseEventType, mouseEvent, coalescedEvents, m_frame->document()->domWindow()); @@ -455,12 +457,12 @@ WebInputEventResult PointerEventManager::sendMousePointerEvent( if (pointerEvent->isPrimary()) { m_preventMouseEventForPointerType[toPointerTypeIndex( - mouseEvent.pointerProperties().pointerType)] = false; + mouseEvent.pointerType)] = false; } } EventTarget* pointerEventTarget = processCaptureAndPositionOfPointerEvent( - pointerEvent, target, mouseEvent, true); + pointerEvent, target, canvasRegionId, mouseEvent, true); EventTarget* effectiveTarget = getEffectiveTargetForPointerEvent( pointerEventTarget, pointerEvent->pointerId()); @@ -472,12 +474,12 @@ WebInputEventResult PointerEventManager::sendMousePointerEvent( pointerEvent->type() == EventTypeNames::pointerdown && pointerEvent->isPrimary()) { m_preventMouseEventForPointerType[toPointerTypeIndex( - mouseEvent.pointerProperties().pointerType)] = true; + mouseEvent.pointerType)] = true; } if (pointerEvent->isPrimary() && !m_preventMouseEventForPointerType[toPointerTypeIndex( - mouseEvent.pointerProperties().pointerType)]) { + mouseEvent.pointerType)]) { EventTarget* mouseTarget = effectiveTarget; // Event path could be null if pointer event is not dispatched and // that happens for example when pointer event feature is not enabled. @@ -491,8 +493,9 @@ WebInputEventResult PointerEventManager::sendMousePointerEvent( } } result = EventHandlingUtil::mergeEventResult( - result, m_mouseEventManager->dispatchMouseEvent( - mouseTarget, mouseEventType, mouseEvent, nullptr)); + result, + m_mouseEventManager->dispatchMouseEvent( + mouseTarget, mouseEventType, mouseEvent, canvasRegionId, nullptr)); } if (pointerEvent->type() == EventTypeNames::pointerup || @@ -503,7 +506,7 @@ WebInputEventResult PointerEventManager::sendMousePointerEvent( if (pointerEvent->isPrimary()) { m_preventMouseEventForPointerType[toPointerTypeIndex( - mouseEvent.pointerProperties().pointerType)] = false; + mouseEvent.pointerType)] = false; } } @@ -534,7 +537,8 @@ bool PointerEventManager::getPointerCaptureState( EventTarget* PointerEventManager::processCaptureAndPositionOfPointerEvent( PointerEvent* pointerEvent, EventTarget* hitTestTarget, - const PlatformMouseEvent& mouseEvent, + const String& canvasRegionId, + const WebMouseEvent& mouseEvent, bool sendMouseEvent) { processPendingPointerCapture(pointerEvent); @@ -547,7 +551,8 @@ EventTarget* PointerEventManager::processCaptureAndPositionOfPointerEvent( setNodeUnderPointer(pointerEvent, hitTestTarget); if (sendMouseEvent) { m_mouseEventManager->setNodeUnderMouse( - hitTestTarget ? hitTestTarget->toNode() : nullptr, mouseEvent); + hitTestTarget ? hitTestTarget->toNode() : nullptr, canvasRegionId, + mouseEvent); } return hitTestTarget; } diff --git a/third_party/WebKit/Source/core/input/PointerEventManager.h b/third_party/WebKit/Source/core/input/PointerEventManager.h index 8504f5c47b478e..0ba65f669b0e89 100644 --- a/third_party/WebKit/Source/core/input/PointerEventManager.h +++ b/third_party/WebKit/Source/core/input/PointerEventManager.h @@ -36,9 +36,10 @@ class CORE_EXPORT PointerEventManager // in this function. WebInputEventResult sendMousePointerEvent( Node* target, + const String& canvasRegionId, const AtomicString& type, - const PlatformMouseEvent&, - const Vector& coalescedEvents); + const WebMouseEvent&, + const Vector& coalescedEvents); WebInputEventResult handleTouchEvents( const WebTouchEvent&, @@ -51,7 +52,8 @@ class CORE_EXPORT PointerEventManager // and their corresponding boundary events will be handled altogether by // sendMousePointerEvent function. void sendMouseAndPointerBoundaryEvents(Node* enteredNode, - const PlatformMouseEvent&); + const String& canvasRegionId, + const WebMouseEvent&); // Resets the internal state of this object. void clear(); @@ -168,7 +170,8 @@ class CORE_EXPORT PointerEventManager EventTarget* processCaptureAndPositionOfPointerEvent( PointerEvent*, EventTarget* hitTestTarget, - const PlatformMouseEvent& = PlatformMouseEvent(), + const String& canvasRegionId = String(), + const WebMouseEvent& = WebMouseEvent(), bool sendMouseEvent = false); void removeTargetFromPointerCapturingMapping(PointerCapturingMap&, diff --git a/third_party/WebKit/Source/core/input/ScrollManager.cpp b/third_party/WebKit/Source/core/input/ScrollManager.cpp index 0a5c306b0383dd..12de4c6bf407d4 100644 --- a/third_party/WebKit/Source/core/input/ScrollManager.cpp +++ b/third_party/WebKit/Source/core/input/ScrollManager.cpp @@ -506,11 +506,12 @@ bool ScrollManager::inResizeMode() const { return m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode(); } -void ScrollManager::resize(const PlatformMouseEvent& evt) { - if (evt.type() == PlatformEvent::MouseMoved) { +void ScrollManager::resize(const WebMouseEvent& evt) { + if (evt.type() == WebInputEvent::MouseMove) { if (!m_frame->eventHandler().mousePressed()) return; - m_resizeScrollableArea->resize(evt.position(), m_offsetFromResizeCorner); + m_resizeScrollableArea->resize(flooredIntPoint(evt.positionInRootFrame()), + m_offsetFromResizeCorner); } } diff --git a/third_party/WebKit/Source/core/input/ScrollManager.h b/third_party/WebKit/Source/core/input/ScrollManager.h index a5f69d79d4ac6d..b87e24419aa247 100644 --- a/third_party/WebKit/Source/core/input/ScrollManager.h +++ b/third_party/WebKit/Source/core/input/ScrollManager.h @@ -86,7 +86,7 @@ class CORE_EXPORT ScrollManager // These functions are related to |m_resizeScrollableArea|. bool inResizeMode() const; - void resize(const PlatformMouseEvent&); + void resize(const WebMouseEvent&); // Clears |m_resizeScrollableArea|. if |shouldNotBeNull| is true this // function DCHECKs to make sure that variable is indeed not null. void clearResizeScrollableArea(bool shouldNotBeNull); diff --git a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp index bbb87a7d505512..8cfe3a1afa7d2b 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp @@ -75,7 +75,6 @@ #include "core/page/Page.h" #include "core/xml/DocumentXPathEvaluator.h" #include "core/xml/XPathResult.h" -#include "platform/PlatformMouseEvent.h" #include "wtf/ListHashSet.h" #include "wtf/PtrUtil.h" #include "wtf/text/CString.h" diff --git a/third_party/WebKit/Source/core/layout/HitTestResult.cpp b/third_party/WebKit/Source/core/layout/HitTestResult.cpp index 76f4cd952ed4d7..b1b70ee934d3e4 100644 --- a/third_party/WebKit/Source/core/layout/HitTestResult.cpp +++ b/third_party/WebKit/Source/core/layout/HitTestResult.cpp @@ -92,7 +92,8 @@ HitTestResult::HitTestResult(const HitTestResult& other) m_localPoint(other.localPoint()), m_innerURLElement(other.URLElement()), m_scrollbar(other.scrollbar()), - m_isOverWidget(other.isOverWidget()) { + m_isOverWidget(other.isOverWidget()), + m_canvasRegionId(other.canvasRegionId()) { // Only copy the NodeSet in case of list hit test. m_listBasedTestResult = other.m_listBasedTestResult ? new NodeSet(*other.m_listBasedTestResult) @@ -135,6 +136,7 @@ void HitTestResult::populateFromCachedResult(const HitTestResult& other) { m_scrollbar = other.scrollbar(); m_isOverWidget = other.isOverWidget(); m_cacheable = other.m_cacheable; + m_canvasRegionId = other.canvasRegionId(); // Only copy the NodeSet in case of list hit test. m_listBasedTestResult = other.m_listBasedTestResult @@ -438,6 +440,7 @@ void HitTestResult::append(const HitTestResult& other) { m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame; m_innerURLElement = other.URLElement(); m_isOverWidget = other.isOverWidget(); + m_canvasRegionId = other.canvasRegionId(); } if (other.m_listBasedTestResult) { diff --git a/third_party/WebKit/Source/core/layout/HitTestResult.h b/third_party/WebKit/Source/core/layout/HitTestResult.h index 18225cff8b1ee1..ff5c464228f02e 100644 --- a/third_party/WebKit/Source/core/layout/HitTestResult.h +++ b/third_party/WebKit/Source/core/layout/HitTestResult.h @@ -154,6 +154,9 @@ class CORE_EXPORT HitTestResult { bool isLiveLink() const; bool isContentEditable() const; + const String& canvasRegionId() const { return m_canvasRegionId; } + void setCanvasRegionId(const String& id) { m_canvasRegionId = id; } + bool isOverLink() const; bool isCacheable() const { return m_cacheable; } @@ -208,6 +211,7 @@ class CORE_EXPORT HitTestResult { // border/padding area of a LayoutPart for example). mutable Member m_listBasedTestResult; + String m_canvasRegionId; }; } // namespace blink diff --git a/third_party/WebKit/Source/core/layout/LayoutScrollbarTheme.h b/third_party/WebKit/Source/core/layout/LayoutScrollbarTheme.h index c9b96ebebe0203..de89c064fee666 100644 --- a/third_party/WebKit/Source/core/layout/LayoutScrollbarTheme.h +++ b/third_party/WebKit/Source/core/layout/LayoutScrollbarTheme.h @@ -30,7 +30,7 @@ namespace blink { -class PlatformMouseEvent; +class WebMouseEvent; class LayoutScrollbarTheme final : public ScrollbarTheme { public: @@ -49,11 +49,11 @@ class LayoutScrollbarTheme final : public ScrollbarTheme { const IntRect& cornerRect) override; bool shouldCenterOnThumb(const ScrollbarThemeClient& scrollbar, - const PlatformMouseEvent& event) override { + const WebMouseEvent& event) override { return ScrollbarTheme::theme().shouldCenterOnThumb(scrollbar, event); } bool shouldSnapBackToDragOrigin(const ScrollbarThemeClient& scrollbar, - const PlatformMouseEvent& event) override { + const WebMouseEvent& event) override { return ScrollbarTheme::theme().shouldSnapBackToDragOrigin(scrollbar, event); } diff --git a/third_party/WebKit/Source/core/page/AutoscrollController.cpp b/third_party/WebKit/Source/core/page/AutoscrollController.cpp index 748b48dae496bd..86c673226055e7 100644 --- a/third_party/WebKit/Source/core/page/AutoscrollController.cpp +++ b/third_party/WebKit/Source/core/page/AutoscrollController.cpp @@ -203,14 +203,13 @@ void AutoscrollController::updateDragAndDrop(Node* dropTargetNode, void AutoscrollController::handleMouseReleaseForMiddleClickAutoscroll( LocalFrame* frame, - const PlatformMouseEvent& mouseEvent) { + const WebMouseEvent& mouseEvent) { DCHECK(RuntimeEnabledFeatures::middleClickAutoscrollEnabled()); if (!frame->isMainFrame()) return; switch (m_autoscrollType) { case AutoscrollForMiddleClick: - if (mouseEvent.pointerProperties().button == - WebPointerProperties::Button::Middle) + if (mouseEvent.button == WebPointerProperties::Button::Middle) m_autoscrollType = AutoscrollForMiddleClickCanStop; break; case AutoscrollForMiddleClickCanStop: diff --git a/third_party/WebKit/Source/core/page/AutoscrollController.h b/third_party/WebKit/Source/core/page/AutoscrollController.h index aab9602b556b8e..5ab08a0267b859 100644 --- a/third_party/WebKit/Source/core/page/AutoscrollController.h +++ b/third_party/WebKit/Source/core/page/AutoscrollController.h @@ -38,9 +38,9 @@ class LocalFrame; class FrameView; class Node; class Page; -class PlatformMouseEvent; class LayoutBox; class LayoutObject; +class WebMouseEvent; enum AutoscrollType { NoAutoscroll, @@ -72,7 +72,7 @@ class CORE_EXPORT AutoscrollController final const IntPoint& eventPosition, TimeTicks eventTime); void handleMouseReleaseForMiddleClickAutoscroll(LocalFrame*, - const PlatformMouseEvent&); + const WebMouseEvent&); void startMiddleClickAutoscroll(LayoutBox*, const IntPoint&); private: diff --git a/third_party/WebKit/Source/core/page/ContextMenuControllerTest.cpp b/third_party/WebKit/Source/core/page/ContextMenuControllerTest.cpp index 94435af81d3443..ae1100cbf14db0 100644 --- a/third_party/WebKit/Source/core/page/ContextMenuControllerTest.cpp +++ b/third_party/WebKit/Source/core/page/ContextMenuControllerTest.cpp @@ -76,11 +76,15 @@ TEST_F(ContextMenuControllerTest, TestCustomMenu) { "" ""); + MouseEventInit mouseInitializer; + mouseInitializer.setView(document().domWindow()); + mouseInitializer.setScreenX(50); + mouseInitializer.setScreenY(50); + mouseInitializer.setButton(1); + // Create right button click event and pass it to context menu controller. - Event* event = MouseEvent::create( - EventTypeNames::click, false, false, document().domWindow(), 50, 50, 0, 0, - 0, 0, 0, PlatformEvent::NoModifiers, 1, 0, nullptr, TimeTicks(), - PlatformMouseEvent::RealOrIndistinguishable, String(), nullptr); + Event* event = + MouseEvent::create(nullptr, EventTypeNames::click, mouseInitializer); document().getElementById("button_id")->focus(); event->setTarget(document().getElementById("button_id")); document().page()->contextMenuController().handleContextMenuEvent(event); diff --git a/third_party/WebKit/Source/core/page/DragController.cpp b/third_party/WebKit/Source/core/page/DragController.cpp index c9eef0f9997b00..07385275214487 100644 --- a/third_party/WebKit/Source/core/page/DragController.cpp +++ b/third_party/WebKit/Source/core/page/DragController.cpp @@ -118,12 +118,19 @@ static bool dragTypeIsValid(DragSourceAction action) { } #endif // DCHECK_IS_ON() -static PlatformMouseEvent createMouseEvent(DragData* dragData) { - return PlatformMouseEvent( - dragData->clientPosition(), dragData->globalPosition(), - WebPointerProperties::Button::Left, PlatformEvent::MouseMoved, 0, +static WebMouseEvent createMouseEvent(DragData* dragData) { + WebMouseEvent result( + WebInputEvent::MouseMove, WebFloatPoint(dragData->clientPosition().x(), + dragData->clientPosition().y()), + WebFloatPoint(dragData->globalPosition().x(), + dragData->globalPosition().y()), + WebPointerProperties::Button::Left, 0, static_cast(dragData->modifiers()), - PlatformMouseEvent::RealOrIndistinguishable, TimeTicks::Now()); + TimeTicks::Now().InSeconds()); + // TODO(dtapuska): Really we should chnage DragData to store the viewport + // coordinates and scale. + result.setFrameScale(1); + return result; } static DataTransfer* createDraggingDataTransfer(DataTransferAccessPolicy policy, @@ -719,7 +726,7 @@ bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation srcOpMask = dragData->draggingSourceOperationMask(); dataTransfer->setSourceOperation(srcOpMask); - PlatformMouseEvent event = createMouseEvent(dragData); + WebMouseEvent event = createMouseEvent(dragData); if (localRoot.eventHandler().updateDragAndDrop(event, dataTransfer) == WebInputEventResult::NotHandled) { dataTransfer->setAccessPolicy( @@ -1050,7 +1057,7 @@ static std::unique_ptr dragImageForLink( bool DragController::startDrag(LocalFrame* src, const DragState& state, - const PlatformMouseEvent& dragEvent, + const WebMouseEvent& dragEvent, const IntPoint& dragOrigin) { #if DCHECK_IS_ON() DCHECK(dragTypeIsValid(state.m_dragType)); @@ -1072,8 +1079,8 @@ bool DragController::startDrag(LocalFrame* src, const KURL& linkURL = hitTestResult.absoluteLinkURL(); const KURL& imageURL = hitTestResult.absoluteImageURL(); - IntPoint mouseDraggedPoint = - src->view()->rootFrameToContents(dragEvent.position()); + IntPoint mouseDraggedPoint = src->view()->rootFrameToContents( + flooredIntPoint(dragEvent.positionInRootFrame())); IntPoint dragLocation; IntPoint dragOffset; diff --git a/third_party/WebKit/Source/core/page/DragController.h b/third_party/WebKit/Source/core/page/DragController.h index 3d28be6cf3b6d2..763f6576dcffc8 100644 --- a/third_party/WebKit/Source/core/page/DragController.h +++ b/third_party/WebKit/Source/core/page/DragController.h @@ -47,7 +47,7 @@ class FrameSelection; class HTMLInputElement; class Node; class Page; -class PlatformMouseEvent; +class WebMouseEvent; class CORE_EXPORT DragController final : public GarbageCollected { @@ -76,7 +76,7 @@ class CORE_EXPORT DragController final const IntPoint& dragOrigin); bool startDrag(LocalFrame* src, const DragState&, - const PlatformMouseEvent& dragEvent, + const WebMouseEvent& dragEvent, const IntPoint& dragOrigin); DECLARE_TRACE(); diff --git a/third_party/WebKit/Source/core/page/EventWithHitTestResults.h b/third_party/WebKit/Source/core/page/EventWithHitTestResults.h index 9d0bdb7b5c4513..b8292558340782 100644 --- a/third_party/WebKit/Source/core/page/EventWithHitTestResults.h +++ b/third_party/WebKit/Source/core/page/EventWithHitTestResults.h @@ -23,8 +23,8 @@ #include "core/layout/HitTestResult.h" #include "platform/PlatformEvent.h" -#include "platform/PlatformMouseEvent.h" #include "public/platform/WebGestureEvent.h" +#include "public/platform/WebMouseEvent.h" namespace blink { @@ -46,14 +46,16 @@ class EventWithHitTestResults { bool isOverLink() const { return m_hitTestResult.isOverLink(); } bool isOverWidget() const { return m_hitTestResult.isOverWidget(); } Node* innerNode() const { return m_hitTestResult.innerNode(); } + const String& canvasRegionId() const { + return m_hitTestResult.canvasRegionId(); + } private: EventType m_event; HitTestResult m_hitTestResult; }; -using MouseEventWithHitTestResults = - EventWithHitTestResults; +using MouseEventWithHitTestResults = EventWithHitTestResults; using GestureEventWithHitTestResults = EventWithHitTestResults; diff --git a/third_party/WebKit/Source/core/page/PointerLockController.cpp b/third_party/WebKit/Source/core/page/PointerLockController.cpp index 720e004db740ab..97b298bd9d5cd7 100644 --- a/third_party/WebKit/Source/core/page/PointerLockController.cpp +++ b/third_party/WebKit/Source/core/page/PointerLockController.cpp @@ -31,7 +31,7 @@ #include "core/inspector/ConsoleMessage.h" #include "core/page/ChromeClient.h" #include "core/page/Page.h" -#include "platform/PlatformMouseEvent.h" +#include "public/platform/WebMouseEvent.h" namespace blink { @@ -132,17 +132,18 @@ void PointerLockController::didLosePointerLock() { } void PointerLockController::dispatchLockedMouseEvent( - const PlatformMouseEvent& event, + const WebMouseEvent& event, const AtomicString& eventType) { if (!m_element || !m_element->document().frame()) return; - m_element->dispatchMouseEvent(event, eventType, event.clickCount()); + m_element->dispatchMouseEvent(event, eventType, event.clickCount); // Create click events - if (eventType == EventTypeNames::mouseup) + if (eventType == EventTypeNames::mouseup) { m_element->dispatchMouseEvent(event, EventTypeNames::click, - event.clickCount()); + event.clickCount); + } } void PointerLockController::clearElement() { diff --git a/third_party/WebKit/Source/core/page/PointerLockController.h b/third_party/WebKit/Source/core/page/PointerLockController.h index cea1abb727ba42..d4caa2fa4d8c6c 100644 --- a/third_party/WebKit/Source/core/page/PointerLockController.h +++ b/third_party/WebKit/Source/core/page/PointerLockController.h @@ -36,7 +36,7 @@ namespace blink { class Element; class Document; class Page; -class PlatformMouseEvent; +class WebMouseEvent; class CORE_EXPORT PointerLockController final : public GarbageCollected { @@ -55,7 +55,7 @@ class CORE_EXPORT PointerLockController final void didAcquirePointerLock(); void didNotAcquirePointerLock(); void didLosePointerLock(); - void dispatchLockedMouseEvent(const PlatformMouseEvent&, + void dispatchLockedMouseEvent(const WebMouseEvent&, const AtomicString& eventType); DECLARE_TRACE(); diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp index 894d81f85ace40..4b9c6d9c2fd6f9 100644 --- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp +++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp @@ -78,7 +78,6 @@ #include "core/page/scrolling/ScrollingCoordinator.h" #include "core/page/scrolling/TopDocumentRootScrollerController.h" #include "core/paint/PaintLayerFragment.h" -#include "platform/PlatformMouseEvent.h" #include "platform/graphics/CompositorMutableProperties.h" #include "platform/graphics/GraphicsLayer.h" #include "platform/graphics/paint/DrawingRecorder.h" diff --git a/third_party/WebKit/Source/core/svg/SVGAElement.cpp b/third_party/WebKit/Source/core/svg/SVGAElement.cpp index 6dec847d065afa..a3283c6c2cd069 100644 --- a/third_party/WebKit/Source/core/svg/SVGAElement.cpp +++ b/third_party/WebKit/Source/core/svg/SVGAElement.cpp @@ -44,7 +44,6 @@ #include "core/page/ChromeClient.h" #include "core/page/Page.h" #include "core/svg/animation/SVGSMILElement.h" -#include "platform/PlatformMouseEvent.h" #include "platform/network/ResourceRequest.h" namespace blink { diff --git a/third_party/WebKit/Source/platform/BUILD.gn b/third_party/WebKit/Source/platform/BUILD.gn index c100adca21895c..0c685232ad70ed 100644 --- a/third_party/WebKit/Source/platform/BUILD.gn +++ b/third_party/WebKit/Source/platform/BUILD.gn @@ -304,7 +304,6 @@ component("platform") { "PlatformEvent.h", "PlatformInstrumentation.cpp", "PlatformInstrumentation.h", - "PlatformMouseEvent.h", "PlatformResourceLoader.cpp", "PlatformResourceLoader.h", "PluginScriptForbiddenScope.cpp", diff --git a/third_party/WebKit/Source/platform/PlatformEvent.h b/third_party/WebKit/Source/platform/PlatformEvent.h index d8c09cb4a7e98f..21ab74ce7f883f 100644 --- a/third_party/WebKit/Source/platform/PlatformEvent.h +++ b/third_party/WebKit/Source/platform/PlatformEvent.h @@ -36,12 +36,6 @@ class PlatformEvent { public: enum EventType { NoType = 0, - - // PlatformMouseEvent - MouseMoved, - MousePressed, - MouseReleased, - MouseScroll, }; // These values are direct mappings of the values in WebInputEvent so the diff --git a/third_party/WebKit/Source/platform/PlatformMouseEvent.h b/third_party/WebKit/Source/platform/PlatformMouseEvent.h deleted file mode 100644 index f8234d74549a32..00000000000000 --- a/third_party/WebKit/Source/platform/PlatformMouseEvent.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef PlatformMouseEvent_h -#define PlatformMouseEvent_h - -#include "platform/PlatformEvent.h" -#include "platform/geometry/FloatPoint.h" -#include "platform/geometry/IntPoint.h" -#include "public/platform/WebGestureEvent.h" -#include "public/platform/WebPointerProperties.h" -#include "wtf/text/WTFString.h" - -namespace blink { - -class PlatformMouseEvent : public PlatformEvent { - public: - enum SyntheticEventType { - // Real mouse input events or synthetic events that behave just like real - // events - RealOrIndistinguishable, - // Synthetic mouse events derived from touch input - FromTouch, - // Synthetic mouse events generated without a position, for example those - // generated from keyboard input. - Positionless, - }; - - PlatformMouseEvent() : PlatformMouseEvent(PlatformEvent::MouseMoved) {} - - explicit PlatformMouseEvent(EventType type) - : PlatformEvent(type), - m_clickCount(0), - m_synthesized(RealOrIndistinguishable) {} - - PlatformMouseEvent(const IntPoint& position, - const IntPoint& globalPosition, - WebPointerProperties::Button button, - EventType type, - int clickCount, - Modifiers modifiers, - TimeTicks timestamp) - : PlatformEvent(type, modifiers, timestamp), - m_position(position), - m_globalPosition(globalPosition), - m_clickCount(clickCount), - m_synthesized(RealOrIndistinguishable) { - m_pointerProperties.button = button; - } - - PlatformMouseEvent(const IntPoint& position, - const IntPoint& globalPosition, - WebPointerProperties::Button button, - EventType type, - int clickCount, - Modifiers modifiers, - SyntheticEventType synthesized, - TimeTicks timestamp, - WebPointerProperties::PointerType pointerType = - WebPointerProperties::PointerType::Unknown) - : PlatformEvent(type, modifiers, timestamp), - m_position(position), - m_globalPosition(globalPosition), - m_clickCount(clickCount), - m_synthesized(synthesized) { - m_pointerProperties.pointerType = pointerType; - m_pointerProperties.button = button; - } - -#if INSIDE_BLINK - PlatformMouseEvent(const WebGestureEvent& gestureEvent, - WebPointerProperties::Button button, - EventType type, - int clickCount, - Modifiers modifiers, - SyntheticEventType synthesized, - TimeTicks timestamp, - WebPointerProperties::PointerType pointerType = - WebPointerProperties::PointerType::Unknown) - : PlatformMouseEvent(flooredIntPoint(gestureEvent.positionInRootFrame()), - IntPoint(gestureEvent.globalX, gestureEvent.globalY), - button, - type, - clickCount, - modifiers, - synthesized, - timestamp, - pointerType) {} -#endif - - const WebPointerProperties& pointerProperties() const { - return m_pointerProperties; - } - const IntPoint& position() const { return m_position; } - const IntPoint& globalPosition() const { return m_globalPosition; } - const IntPoint& movementDelta() const { return m_movementDelta; } - - int clickCount() const { return m_clickCount; } - bool fromTouch() const { return m_synthesized == FromTouch; } - SyntheticEventType getSyntheticEventType() const { return m_synthesized; } - - const String& region() const { return m_region; } - void setRegion(const String& region) { m_region = region; } - - protected: - WebPointerProperties m_pointerProperties; - - // In local root frame coordinates. (Except possibly if the Widget under - // the mouse is a popup, see FIXME in PlatformMouseEventBuilder). - IntPoint m_position; - - // In screen coordinates. - IntPoint m_globalPosition; - - IntPoint m_movementDelta; - int m_clickCount; - SyntheticEventType m_synthesized; - - // For canvas hit region. - // TODO(zino): This might make more sense to put in HitTestResults or - // some other part of MouseEventWithHitTestResults, but for now it's - // most convenient to stash it here. Please see: http://crbug.com/592947. - String m_region; -}; - -} // namespace blink - -#endif // PlatformMouseEvent_h diff --git a/third_party/WebKit/Source/platform/WebMouseEvent.cpp b/third_party/WebKit/Source/platform/WebMouseEvent.cpp index 4e6e9575f02fe7..8e297fa165b3b6 100644 --- a/third_party/WebKit/Source/platform/WebMouseEvent.cpp +++ b/third_party/WebKit/Source/platform/WebMouseEvent.cpp @@ -4,8 +4,28 @@ #include "public/platform/WebMouseEvent.h" +#include "public/platform/WebGestureEvent.h" + namespace blink { +WebMouseEvent::WebMouseEvent(WebInputEvent::Type type, + const WebGestureEvent& gestureEvent, + Button buttonParam, + int clickCountParam, + int modifiers, + double timeStampSeconds) + : WebInputEvent(sizeof(WebMouseEvent), type, modifiers, timeStampSeconds), + WebPointerProperties(buttonParam, + WebPointerProperties::PointerType::Mouse), + x(gestureEvent.x), + y(gestureEvent.y), + globalX(gestureEvent.globalX), + globalY(gestureEvent.globalY), + clickCount(clickCountParam) { + setFrameScale(gestureEvent.frameScale()); + setFrameTranslate(gestureEvent.frameTranslate()); +} + WebFloatPoint WebMouseEvent::movementInRootFrame() const { return WebFloatPoint((movementX / m_frameScale), (movementY / m_frameScale)); } @@ -15,6 +35,12 @@ WebFloatPoint WebMouseEvent::positionInRootFrame() const { (y / m_frameScale) + m_frameTranslate.y); } +WebMouseEvent WebMouseEvent::flattenTransform() const { + WebMouseEvent result = *this; + result.flattenTransformSelf(); + return result; +} + void WebMouseEvent::flattenTransformSelf() { x = (x / m_frameScale) + m_frameTranslate.x; y = (y / m_frameScale) + m_frameTranslate.y; diff --git a/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp b/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp index 442518dddee697..cd3b8accdf87d8 100644 --- a/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp +++ b/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp @@ -27,13 +27,13 @@ #include #include "platform/HostWindow.h" -#include "platform/PlatformMouseEvent.h" #include "platform/geometry/FloatRect.h" #include "platform/graphics/paint/CullRect.h" #include "platform/scroll/ScrollAnimatorBase.h" #include "platform/scroll/ScrollableArea.h" #include "platform/scroll/ScrollbarTheme.h" #include "public/platform/WebGestureEvent.h" +#include "public/platform/WebMouseEvent.h" namespace blink { @@ -418,7 +418,8 @@ bool Scrollbar::gestureEvent(const WebGestureEvent& evt, } } -void Scrollbar::mouseMoved(const PlatformMouseEvent& evt) { +void Scrollbar::mouseMoved(const WebMouseEvent& evt) { + IntPoint position = flooredIntPoint(evt.positionInRootFrame()); if (m_pressedPart == ThumbPart) { if (theme().shouldSnapBackToDragOrigin(*this, evt)) { if (m_scrollableArea) { @@ -429,19 +430,20 @@ void Scrollbar::mouseMoved(const PlatformMouseEvent& evt) { } } else { moveThumb(m_orientation == HorizontalScrollbar - ? convertFromRootFrame(evt.position()).x() - : convertFromRootFrame(evt.position()).y(), + ? convertFromRootFrame(position).x() + : convertFromRootFrame(position).y(), theme().shouldDragDocumentInsteadOfThumb(*this, evt)); } return; } - if (m_pressedPart != NoPart) + if (m_pressedPart != NoPart) { m_pressedPos = orientation() == HorizontalScrollbar - ? convertFromRootFrame(evt.position()).x() - : convertFromRootFrame(evt.position()).y(); + ? convertFromRootFrame(position).x() + : convertFromRootFrame(position).y(); + } - ScrollbarPart part = theme().hitTest(*this, evt.position()); + ScrollbarPart part = theme().hitTest(*this, position); if (part != m_hoveredPart) { if (m_pressedPart != NoPart) { if (part == m_pressedPart) { @@ -472,7 +474,7 @@ void Scrollbar::mouseExited() { setHoveredPart(NoPart); } -void Scrollbar::mouseUp(const PlatformMouseEvent& mouseEvent) { +void Scrollbar::mouseUp(const WebMouseEvent& mouseEvent) { bool isCaptured = m_pressedPart == ThumbPart; setPressedPart(NoPart); m_pressedPos = 0; @@ -483,7 +485,8 @@ void Scrollbar::mouseUp(const PlatformMouseEvent& mouseEvent) { if (isCaptured) m_scrollableArea->mouseReleasedScrollbar(); - ScrollbarPart part = theme().hitTest(*this, mouseEvent.position()); + ScrollbarPart part = theme().hitTest( + *this, flooredIntPoint(mouseEvent.positionInRootFrame())); if (part == NoPart) { setHoveredPart(NoPart); m_scrollableArea->mouseExitedScrollbar(*this); @@ -491,15 +494,16 @@ void Scrollbar::mouseUp(const PlatformMouseEvent& mouseEvent) { } } -void Scrollbar::mouseDown(const PlatformMouseEvent& evt) { +void Scrollbar::mouseDown(const WebMouseEvent& evt) { // Early exit for right click - if (evt.pointerProperties().button == WebPointerProperties::Button::Right) + if (evt.button == WebPointerProperties::Button::Right) return; - setPressedPart(theme().hitTest(*this, evt.position())); + IntPoint position = flooredIntPoint(evt.positionInRootFrame()); + setPressedPart(theme().hitTest(*this, position)); int pressedPos = orientation() == HorizontalScrollbar - ? convertFromRootFrame(evt.position()).x() - : convertFromRootFrame(evt.position()).y(); + ? convertFromRootFrame(position).x() + : convertFromRootFrame(position).y(); if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && theme().shouldCenterOnThumb(*this, evt)) { diff --git a/third_party/WebKit/Source/platform/scroll/Scrollbar.h b/third_party/WebKit/Source/platform/scroll/Scrollbar.h index 6af3ef15384849..914c9aa3f535b4 100644 --- a/third_party/WebKit/Source/platform/scroll/Scrollbar.h +++ b/third_party/WebKit/Source/platform/scroll/Scrollbar.h @@ -39,10 +39,10 @@ namespace blink { class GraphicsContext; class HostWindow; class IntRect; -class PlatformMouseEvent; class ScrollableArea; class ScrollbarTheme; class WebGestureEvent; +class WebMouseEvent; class PLATFORM_EXPORT Scrollbar : public Widget, public ScrollbarThemeClient, @@ -145,14 +145,14 @@ class PLATFORM_EXPORT Scrollbar : public Widget, // They will not get called when the mouse went down in a scrollbar, since it // is assumed the scrollbar will start // grabbing all events in that case anyway. - void mouseMoved(const PlatformMouseEvent&); + void mouseMoved(const WebMouseEvent&); void mouseEntered(); void mouseExited(); // Used by some platform scrollbars to know when they've been released from // capture. - void mouseUp(const PlatformMouseEvent&); - void mouseDown(const PlatformMouseEvent&); + void mouseUp(const WebMouseEvent&); + void mouseDown(const WebMouseEvent&); ScrollbarTheme& theme() const { return m_theme; } diff --git a/third_party/WebKit/Source/platform/scroll/ScrollbarTheme.cpp b/third_party/WebKit/Source/platform/scroll/ScrollbarTheme.cpp index 00b2e022398ea7..91c715962d6a17 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollbarTheme.cpp +++ b/third_party/WebKit/Source/platform/scroll/ScrollbarTheme.cpp @@ -25,7 +25,6 @@ #include "platform/scroll/ScrollbarTheme.h" -#include "platform/PlatformMouseEvent.h" #include "platform/RuntimeEnabledFeatures.h" #include "platform/graphics/Color.h" #include "platform/graphics/GraphicsContext.h" @@ -39,6 +38,7 @@ #include "platform/scroll/ScrollbarThemeMock.h" #include "platform/scroll/ScrollbarThemeOverlayMock.h" #include "public/platform/Platform.h" +#include "public/platform/WebMouseEvent.h" #include "public/platform/WebPoint.h" #include "public/platform/WebRect.h" #include "public/platform/WebScrollbarBehavior.h" @@ -219,9 +219,10 @@ void ScrollbarTheme::paintScrollCorner( } bool ScrollbarTheme::shouldCenterOnThumb(const ScrollbarThemeClient& scrollbar, - const PlatformMouseEvent& evt) { + const WebMouseEvent& evt) { return Platform::current()->scrollbarBehavior()->shouldCenterOnThumb( - evt.pointerProperties().button, evt.shiftKey(), evt.altKey()); + evt.button, evt.modifiers() & WebInputEvent::ShiftKey, + evt.modifiers() & WebInputEvent::AltKey); } void ScrollbarTheme::paintTickmarks(GraphicsContext& context, @@ -270,8 +271,9 @@ void ScrollbarTheme::paintTickmarks(GraphicsContext& context, bool ScrollbarTheme::shouldSnapBackToDragOrigin( const ScrollbarThemeClient& scrollbar, - const PlatformMouseEvent& evt) { - IntPoint mousePosition = scrollbar.convertFromRootFrame(evt.position()); + const WebMouseEvent& evt) { + IntPoint mousePosition = scrollbar.convertFromRootFrame( + flooredIntPoint(evt.positionInRootFrame())); mousePosition.move(scrollbar.x(), scrollbar.y()); return Platform::current()->scrollbarBehavior()->shouldSnapBackToDragOrigin( mousePosition, trackRect(scrollbar), diff --git a/third_party/WebKit/Source/platform/scroll/ScrollbarTheme.h b/third_party/WebKit/Source/platform/scroll/ScrollbarTheme.h index 948af5645e1bb5..a7a5f702f1c91f 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollbarTheme.h +++ b/third_party/WebKit/Source/platform/scroll/ScrollbarTheme.h @@ -37,7 +37,7 @@ namespace blink { class CullRect; class GraphicsContext; -class PlatformMouseEvent; +class WebMouseEvent; class PLATFORM_EXPORT ScrollbarTheme { WTF_MAKE_NONCOPYABLE(ScrollbarTheme); @@ -106,11 +106,11 @@ class PLATFORM_EXPORT ScrollbarTheme { const IntRect&); virtual bool shouldCenterOnThumb(const ScrollbarThemeClient&, - const PlatformMouseEvent&); + const WebMouseEvent&); virtual bool shouldSnapBackToDragOrigin(const ScrollbarThemeClient&, - const PlatformMouseEvent&); + const WebMouseEvent&); virtual bool shouldDragDocumentInsteadOfThumb(const ScrollbarThemeClient&, - const PlatformMouseEvent&) { + const WebMouseEvent&) { return false; } diff --git a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp index ce7f749a4d7607..45c1d47b252270 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp +++ b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp @@ -31,7 +31,6 @@ #include "platform/scroll/ScrollbarThemeAura.h" #include "platform/LayoutTestSupport.h" -#include "platform/PlatformMouseEvent.h" #include "platform/RuntimeEnabledFeatures.h" #include "platform/graphics/GraphicsContext.h" #include "platform/graphics/paint/DrawingRecorder.h" diff --git a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeMac.h b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeMac.h index 2dd3765738cd0d..558b170d04b573 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeMac.h +++ b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeMac.h @@ -89,7 +89,7 @@ class PLATFORM_EXPORT ScrollbarThemeMac : public ScrollbarTheme { int maxOverlapBetweenPages() override { return 40; } bool shouldDragDocumentInsteadOfThumb(const ScrollbarThemeClient&, - const PlatformMouseEvent&) override; + const WebMouseEvent&) override; int scrollbarPartToHIPressedState(ScrollbarPart); virtual void updateButtonPlacement(WebScrollbarButtonsPlacement) {} diff --git a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeMac.mm b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeMac.mm index 88c92c377cb7d6..5fd9bd0d3af4ae 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeMac.mm +++ b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeMac.mm @@ -27,7 +27,6 @@ #include "platform/scroll/ScrollbarThemeMac.h" #include -#include "platform/PlatformMouseEvent.h" #include "platform/graphics/GraphicsContext.h" #include "platform/graphics/GraphicsContextStateSaver.h" #include "platform/graphics/paint/DrawingRecorder.h" @@ -36,6 +35,7 @@ #include "platform/mac/NSScrollerImpDetails.h" #include "platform/mac/ScrollAnimatorMac.h" #include "platform/scroll/ScrollbarThemeClient.h" +#include "public/platform/WebMouseEvent.h" #include "public/platform/WebThemeEngine.h" #include "public/platform/Platform.h" #include "public/platform/WebRect.h" @@ -172,8 +172,8 @@ static bool supportsExpandedScrollbars() { bool ScrollbarThemeMac::shouldDragDocumentInsteadOfThumb( const ScrollbarThemeClient&, - const PlatformMouseEvent& event) { - return event.altKey(); + const WebMouseEvent& event) { + return (event.modifiers() & WebInputEvent::Modifiers::AltKey) != 0; } int ScrollbarThemeMac::scrollbarPartToHIPressedState(ScrollbarPart part) { diff --git a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeOverlay.cpp b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeOverlay.cpp index 14878b965bced5..9753dcc192827a 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeOverlay.cpp +++ b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeOverlay.cpp @@ -25,7 +25,6 @@ #include "platform/scroll/ScrollbarThemeOverlay.h" -#include "platform/PlatformMouseEvent.h" #include "platform/graphics/GraphicsContext.h" #include "platform/graphics/paint/DrawingRecorder.h" #include "platform/scroll/Scrollbar.h" diff --git a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeOverlayMock.h b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeOverlayMock.h index 1022c2b2b1c47c..8f657e4b28dfdb 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeOverlayMock.h +++ b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeOverlayMock.h @@ -59,7 +59,7 @@ class PLATFORM_EXPORT ScrollbarThemeOverlayMock : public ScrollbarThemeOverlay { } bool shouldSnapBackToDragOrigin(const ScrollbarThemeClient& scrollbar, - const PlatformMouseEvent& evt) override { + const WebMouseEvent& evt) override { return false; } diff --git a/third_party/WebKit/Source/web/AssertMatchingEnums.cpp b/third_party/WebKit/Source/web/AssertMatchingEnums.cpp index dbfbb05a1ea7c8..3518f80b0f5045 100644 --- a/third_party/WebKit/Source/web/AssertMatchingEnums.cpp +++ b/third_party/WebKit/Source/web/AssertMatchingEnums.cpp @@ -66,7 +66,7 @@ #include "platform/Cursor.h" #include "platform/FileMetadata.h" #include "platform/FileSystemType.h" -#include "platform/PlatformMouseEvent.h" +#include "platform/PlatformEvent.h" #include "platform/fonts/FontDescription.h" #include "platform/fonts/FontSmoothingMode.h" #include "platform/mediastream/MediaStreamSource.h" diff --git a/third_party/WebKit/Source/web/InspectorOverlay.cpp b/third_party/WebKit/Source/web/InspectorOverlay.cpp index 210ddea33e7fcf..4c14f4770d4d79 100644 --- a/third_party/WebKit/Source/web/InspectorOverlay.cpp +++ b/third_party/WebKit/Source/web/InspectorOverlay.cpp @@ -89,9 +89,11 @@ Node* hoveredNodeForEvent(LocalFrame* frame, } Node* hoveredNodeForEvent(LocalFrame* frame, - const PlatformMouseEvent& event, + const WebMouseEvent& event, bool ignorePointerEventsNone) { - return hoveredNodeForPoint(frame, event.position(), ignorePointerEventsNone); + return hoveredNodeForPoint(frame, + roundedIntPoint(event.positionInRootFrame()), + ignorePointerEventsNone); } Node* hoveredNodeForEvent(LocalFrame* frame, @@ -245,33 +247,30 @@ bool InspectorOverlay::handleInputEvent(const WebInputEvent& inputEvent) { overlayMainFrame()->eventHandler().handleGestureEvent(transformedEvent); } - if (WebInputEvent::isMouseEventType(inputEvent.type()) && - inputEvent.type() != WebInputEvent::MouseEnter) { - // PlatformMouseEventBuilder does not work with MouseEnter type, so we - // filter it out manually. - PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder( - m_frameImpl->frameView(), - static_cast(inputEvent)); + if (WebInputEvent::isMouseEventType(inputEvent.type())) { + WebMouseEvent mouseEvent = + TransformWebMouseEvent(m_frameImpl->frameView(), + static_cast(inputEvent)); - if (mouseEvent.type() == PlatformEvent::MouseMoved) + if (mouseEvent.type() == WebInputEvent::MouseMove) handled = handleMouseMove(mouseEvent); - else if (mouseEvent.type() == PlatformEvent::MousePressed) + else if (mouseEvent.type() == WebInputEvent::MouseDown) handled = handleMousePress(); if (handled) return true; - if (mouseEvent.type() == PlatformEvent::MouseMoved) { + if (mouseEvent.type() == WebInputEvent::MouseMove) { handled = overlayMainFrame()->eventHandler().handleMouseMoveEvent( - mouseEvent, createPlatformMouseEventVector( + mouseEvent, TransformWebMouseEventVector( m_frameImpl->frameView(), std::vector())) != WebInputEventResult::NotHandled; } - if (mouseEvent.type() == PlatformEvent::MousePressed) + if (mouseEvent.type() == WebInputEvent::MouseDown) handled = overlayMainFrame()->eventHandler().handleMousePressEvent( mouseEvent) != WebInputEventResult::NotHandled; - if (mouseEvent.type() == PlatformEvent::MouseReleased) + if (mouseEvent.type() == WebInputEvent::MouseUp) handled = overlayMainFrame()->eventHandler().handleMouseReleaseEvent( mouseEvent) != WebInputEventResult::NotHandled; } @@ -706,14 +705,15 @@ void InspectorOverlay::setShowViewportSizeOnResize(bool show) { m_drawViewSize = show; } -bool InspectorOverlay::handleMouseMove(const PlatformMouseEvent& event) { +bool InspectorOverlay::handleMouseMove(const WebMouseEvent& event) { if (!shouldSearchForNode()) return false; LocalFrame* frame = m_frameImpl->frame(); if (!frame || !frame->view() || frame->contentLayoutItem().isNull()) return false; - Node* node = hoveredNodeForEvent(frame, event, event.shiftKey()); + Node* node = hoveredNodeForEvent(frame, event, + event.modifiers() & WebInputEvent::ShiftKey); // Do not highlight within user agent shadow root unless requested. if (m_inspectMode != InspectorDOMAgent::SearchingForUAShadow) { @@ -729,8 +729,9 @@ bool InspectorOverlay::handleMouseMove(const PlatformMouseEvent& event) { if (!node) return true; - Node* eventTarget = - event.shiftKey() ? hoveredNodeForEvent(frame, event, false) : nullptr; + Node* eventTarget = (event.modifiers() & WebInputEvent::ShiftKey) + ? hoveredNodeForEvent(frame, event, false) + : nullptr; if (eventTarget == node) eventTarget = nullptr; @@ -739,7 +740,8 @@ bool InspectorOverlay::handleMouseMove(const PlatformMouseEvent& event) { if (m_domAgent) m_domAgent->nodeHighlightedInOverlay(node); highlightNode(node, eventTarget, *m_inspectModeHighlightConfig, - event.ctrlKey() || event.metaKey()); + (event.modifiers() & + (WebInputEvent::ControlKey | WebInputEvent::MetaKey))); } return true; } diff --git a/third_party/WebKit/Source/web/InspectorOverlay.h b/third_party/WebKit/Source/web/InspectorOverlay.h index a03cb44e0b2a10..7276894cfc848a 100644 --- a/third_party/WebKit/Source/web/InspectorOverlay.h +++ b/third_party/WebKit/Source/web/InspectorOverlay.h @@ -50,8 +50,8 @@ class LocalFrame; class Node; class Page; class PageOverlay; -class PlatformMouseEvent; class WebGestureEvent; +class WebMouseEvent; class WebLocalFrameImpl; class WebTouchEvent; @@ -133,7 +133,7 @@ class InspectorOverlay final bool handleMousePress(); bool handleGestureEvent(const WebGestureEvent&); bool handleTouchEvent(const WebTouchEvent&); - bool handleMouseMove(const PlatformMouseEvent&); + bool handleMouseMove(const WebMouseEvent&); bool shouldSearchForNode(); void inspect(Node*); diff --git a/third_party/WebKit/Source/web/PageWidgetDelegate.cpp b/third_party/WebKit/Source/web/PageWidgetDelegate.cpp index bdc5f91a415ba4..a0fbb32574f133 100644 --- a/third_party/WebKit/Source/web/PageWidgetDelegate.cpp +++ b/third_party/WebKit/Source/web/PageWidgetDelegate.cpp @@ -119,10 +119,11 @@ WebInputEventResult PageWidgetDelegate::handleInputEvent( const WebInputEvent& event = coalescedEvent.event(); if (event.modifiers() & WebInputEvent::IsTouchAccessibility && WebInputEvent::isMouseEventType(event.type())) { - PlatformMouseEventBuilder pme(root->view(), - static_cast(event)); + WebMouseEvent mouseEvent = TransformWebMouseEvent( + root->view(), static_cast(event)); - IntPoint docPoint(root->view()->rootFrameToContents(pme.position())); + IntPoint docPoint(root->view()->rootFrameToContents( + flooredIntPoint(mouseEvent.positionInRootFrame()))); HitTestResult result = root->eventHandler().hitTestResultAtPoint( docPoint, HitTestRequest::ReadOnly | HitTestRequest::Active); result.setToShadowHostIfInUserAgentShadowRoot(); @@ -225,27 +226,32 @@ void PageWidgetEventHandler::handleMouseMove( LocalFrame& mainFrame, const WebMouseEvent& event, const std::vector& coalescedEvents) { + WebMouseEvent transformedEvent = + TransformWebMouseEvent(mainFrame.view(), event); mainFrame.eventHandler().handleMouseMoveEvent( - PlatformMouseEventBuilder(mainFrame.view(), event), - createPlatformMouseEventVector(mainFrame.view(), coalescedEvents)); + transformedEvent, + TransformWebMouseEventVector(mainFrame.view(), coalescedEvents)); } void PageWidgetEventHandler::handleMouseLeave(LocalFrame& mainFrame, const WebMouseEvent& event) { - mainFrame.eventHandler().handleMouseLeaveEvent( - PlatformMouseEventBuilder(mainFrame.view(), event)); + WebMouseEvent transformedEvent = + TransformWebMouseEvent(mainFrame.view(), event); + mainFrame.eventHandler().handleMouseLeaveEvent(transformedEvent); } void PageWidgetEventHandler::handleMouseDown(LocalFrame& mainFrame, const WebMouseEvent& event) { - mainFrame.eventHandler().handleMousePressEvent( - PlatformMouseEventBuilder(mainFrame.view(), event)); + WebMouseEvent transformedEvent = + TransformWebMouseEvent(mainFrame.view(), event); + mainFrame.eventHandler().handleMousePressEvent(transformedEvent); } void PageWidgetEventHandler::handleMouseUp(LocalFrame& mainFrame, const WebMouseEvent& event) { - mainFrame.eventHandler().handleMouseReleaseEvent( - PlatformMouseEventBuilder(mainFrame.view(), event)); + WebMouseEvent transformedEvent = + TransformWebMouseEvent(mainFrame.view(), event); + mainFrame.eventHandler().handleMouseReleaseEvent(transformedEvent); } WebInputEventResult PageWidgetEventHandler::handleMouseWheel( diff --git a/third_party/WebKit/Source/web/PopupMenuImpl.cpp b/third_party/WebKit/Source/web/PopupMenuImpl.cpp index 7b2b88f4b059ea..97bf482a6c9ff1 100644 --- a/third_party/WebKit/Source/web/PopupMenuImpl.cpp +++ b/third_party/WebKit/Source/web/PopupMenuImpl.cpp @@ -446,7 +446,9 @@ void PopupMenuImpl::setValueAndClosePopup(int numValue, // We dispatch events on the owner element to match the legacy behavior. // Other browsers dispatch click events before and after showing the popup. if (m_ownerElement) { - PlatformMouseEvent event; + // TODO(dtapuska): Why is this event positionless? + WebMouseEvent event; + event.setFrameScale(1); Element* owner = &ownerElement(); owner->dispatchMouseEvent(event, EventTypeNames::mouseup); owner->dispatchMouseEvent(event, EventTypeNames::click); diff --git a/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp b/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp index 8ff5670b996beb..2f1df5b1efa90b 100644 --- a/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp +++ b/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp @@ -540,9 +540,9 @@ void WebDevToolsAgentImpl::inspectElementAt(int sessionId, WTF::monotonicallyIncreasingTimeMS()); dummyEvent.x = pointInRootFrame.x; dummyEvent.y = pointInRootFrame.y; - IntPoint transformedPoint = - PlatformMouseEventBuilder(m_webLocalFrameImpl->frameView(), dummyEvent) - .position(); + IntPoint transformedPoint = flooredIntPoint( + TransformWebMouseEvent(m_webLocalFrameImpl->frameView(), dummyEvent) + .positionInRootFrame()); HitTestResult result( request, m_webLocalFrameImpl->frameView()->rootFrameToContents(transformedPoint)); diff --git a/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp b/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp index 00a0c73407b793..5a34a0e3281039 100644 --- a/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp +++ b/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp @@ -131,16 +131,19 @@ void WebFrameWidgetBase::dragSourceEndedAt(const WebPoint& pointInViewport, cancelDrag(); return; } - WebPoint pointInRootFrame( + WebFloatPoint pointInRootFrame( page()->frameHost().visualViewport().viewportToRootFrame( pointInViewport)); - PlatformMouseEvent pme( - pointInRootFrame, screenPoint, WebPointerProperties::Button::Left, - PlatformEvent::MouseMoved, 0, PlatformEvent::NoModifiers, - PlatformMouseEvent::RealOrIndistinguishable, TimeTicks::Now()); + + WebMouseEvent fakeMouseMove(WebInputEvent::MouseMove, pointInRootFrame, + WebFloatPoint(screenPoint.x, screenPoint.y), + WebPointerProperties::Button::Left, 0, + PlatformEvent::NoModifiers, + TimeTicks::Now().InSeconds()); + fakeMouseMove.setFrameScale(1); toCoreFrame(localRoot()) ->eventHandler() - .dragSourceEndedAt(pme, static_cast(operation)); + .dragSourceEndedAt(fakeMouseMove, static_cast(operation)); } void WebFrameWidgetBase::dragSourceSystemDragEnded() { diff --git a/third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp b/third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp index 563b887b646c93..b015b9b24c3c74 100644 --- a/third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp +++ b/third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp @@ -372,11 +372,11 @@ WebInputEventResult WebFrameWidgetImpl::handleInputEvent( NOTREACHED(); } - node->dispatchMouseEvent( - PlatformMouseEventBuilder( - m_localRoot->frameView(), - static_cast(inputEvent)), - eventType, static_cast(inputEvent).clickCount); + WebMouseEvent transformedEvent = + TransformWebMouseEvent(m_localRoot->frameView(), + static_cast(inputEvent)); + node->dispatchMouseEvent(transformedEvent, eventType, + transformedEvent.clickCount); return WebInputEventResult::HandledSystem; } @@ -776,10 +776,13 @@ void WebFrameWidgetImpl::handleMouseDown(LocalFrame& mainFrame, void WebFrameWidgetImpl::mouseContextMenu(const WebMouseEvent& event) { page()->contextMenuController().clearContextMenu(); - PlatformMouseEventBuilder pme(m_localRoot->frameView(), event); + WebMouseEvent transformedEvent = + TransformWebMouseEvent(m_localRoot->frameView(), event); + IntPoint positionInRootFrame = + flooredIntPoint(transformedEvent.positionInRootFrame()); // Find the right target frame. See issue 1186900. - HitTestResult result = hitTestResultForRootFramePos(pme.position()); + HitTestResult result = hitTestResultForRootFramePos(positionInRootFrame); Frame* targetFrame; if (result.innerNodeOrImageMapImage()) targetFrame = result.innerNodeOrImageMapImage()->document().frame(); @@ -801,7 +804,8 @@ void WebFrameWidgetImpl::mouseContextMenu(const WebMouseEvent& event) { { ContextMenuAllowedScope scope; - targetLocalFrame->eventHandler().sendContextMenuEvent(pme, nullptr); + targetLocalFrame->eventHandler().sendContextMenuEvent(transformedEvent, + nullptr); } // Actually showing the context menu is handled by the ContextMenuClient // implementation... diff --git a/third_party/WebKit/Source/web/WebInputEventConversion.cpp b/third_party/WebKit/Source/web/WebInputEventConversion.cpp index aed825ce918ec8..4c585682ed8dd3 100644 --- a/third_party/WebKit/Source/web/WebInputEventConversion.cpp +++ b/third_party/WebKit/Source/web/WebInputEventConversion.cpp @@ -85,54 +85,6 @@ FloatPoint frameTranslation(const Widget* widget) { overscrollOffset.height()); } -float scaleDeltaToWindow(const Widget* widget, float delta) { - return delta / frameScale(widget); -} - -// This method converts from the renderer's coordinate space into Blink's root -// frame coordinate space. It's somewhat unique in that it takes into account -// DevTools emulation, which applies a scale and offset in the root layer (see -// updateRootLayerTransform in WebViewImpl) as well as the overscroll effect on -// OSX. This is in addition to the visual viewport "pinch-zoom" transformation -// and is one of the few cases where the visual viewport is not equal to the -// renderer's coordinate-space. -FloatPoint convertHitPointToRootFrame(const Widget* widget, - FloatPoint pointInRendererViewport) { - float scale = 1; - IntSize offset; - IntPoint visualViewport; - FloatSize overscrollOffset; - if (widget) { - FrameView* rootView = toFrameView(widget->root()); - if (rootView) { - scale = rootView->inputEventsScaleFactor(); - offset = rootView->inputEventsOffsetForEmulation(); - visualViewport = flooredIntPoint(rootView->page() - ->frameHost() - .visualViewport() - .visibleRect() - .location()); - overscrollOffset = - rootView->page()->frameHost().chromeClient().elasticOverscroll(); - } - } - return FloatPoint((pointInRendererViewport.x() - offset.width()) / scale + - visualViewport.x() + overscrollOffset.width(), - (pointInRendererViewport.y() - offset.height()) / scale + - visualViewport.y() + overscrollOffset.height()); -} - -unsigned toPlatformModifierFrom(WebMouseEvent::Button button) { - if (button == WebMouseEvent::Button::NoButton) - return 0; - - unsigned webMouseButtonToPlatformModifier[] = { - PlatformEvent::LeftButtonDown, PlatformEvent::MiddleButtonDown, - PlatformEvent::RightButtonDown}; - - return webMouseButtonToPlatformModifier[static_cast(button)]; -} - FloatPoint convertAbsoluteLocationForLayoutObjectFloat( const DoublePoint& location, const LayoutItem layoutItem) { @@ -172,51 +124,40 @@ void updateWebMouseEventFromCoreMouseEvent(const MouseEvent& event, webEvent.y = localPoint.y(); } -} // namespace +unsigned toWebInputEventModifierFrom(WebMouseEvent::Button button) { + if (button == WebMouseEvent::Button::NoButton) + return 0; -// MakePlatformMouseEvent ----------------------------------------------------- - -// TODO(mustaq): Add tests for this. -PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, - const WebMouseEvent& e) { - // FIXME: Widget is always toplevel, unless it's a popup. We may be able - // to get rid of this once we abstract popups into a WebKit API. - m_position = widget->convertFromRootFrame( - flooredIntPoint(convertHitPointToRootFrame(widget, IntPoint(e.x, e.y)))); - m_globalPosition = IntPoint(e.globalX, e.globalY); - m_movementDelta = IntPoint(scaleDeltaToWindow(widget, e.movementX), - scaleDeltaToWindow(widget, e.movementY)); - m_modifiers = e.modifiers(); - - m_timestamp = TimeTicks::FromSeconds(e.timeStampSeconds()); - m_clickCount = e.clickCount; - - m_pointerProperties = static_cast(e); - - switch (e.type()) { - case WebInputEvent::MouseMove: - case WebInputEvent::MouseEnter: // synthesize a move event - case WebInputEvent::MouseLeave: // synthesize a move event - m_type = PlatformEvent::MouseMoved; - break; + unsigned webMouseButtonToPlatformModifier[] = { + WebInputEvent::LeftButtonDown, WebInputEvent::MiddleButtonDown, + WebInputEvent::RightButtonDown}; - case WebInputEvent::MouseDown: - m_type = PlatformEvent::MousePressed; - break; + return webMouseButtonToPlatformModifier[static_cast(button)]; +} - case WebInputEvent::MouseUp: - m_type = PlatformEvent::MouseReleased; +} // namespace - // The MouseEvent spec requires that buttons indicates the state - // immediately after the event takes place. To ensure consistency - // between platforms here, we explicitly clear the button that is - // in the process of being released. - m_modifiers &= ~toPlatformModifierFrom(e.button); - break; +WebMouseEvent TransformWebMouseEvent(Widget* widget, + const WebMouseEvent& event) { + WebMouseEvent result = event; - default: - NOTREACHED(); + // TODO(dtapuska): Remove this translation. In the past blink has + // converted leaves into moves and not known about leaves. It should + // be educated about them. crbug.com/686196 + if (event.type() == WebInputEvent::MouseEnter || + event.type() == WebInputEvent::MouseLeave) { + result.setType(WebInputEvent::MouseMove); } + + // TODO(dtapuska): Perhaps the event should be constructed correctly? + // crbug.com/686200 + if (event.type() == WebInputEvent::MouseUp) { + result.setModifiers(event.modifiers() & + ~toWebInputEventModifierFrom(event.button)); + } + result.setFrameScale(frameScale(widget)); + result.setFrameTranslate(frameTranslation(widget)); + return result; } WebMouseWheelEvent TransformWebMouseWheelEvent( @@ -258,6 +199,21 @@ WebTouchEvent TransformWebTouchEvent(Widget* widget, WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const LayoutItem layoutItem, const MouseEvent& event) { + if (event.nativeEvent()) { + *static_cast(this) = + event.nativeEvent()->flattenTransform(); + WebFloatPoint absoluteRootFrameLocation = positionInRootFrame(); + IntPoint localPoint = roundedIntPoint( + layoutItem.absoluteToLocal(absoluteRootFrameLocation, UseTransforms)); + x = localPoint.x(); + y = localPoint.y(); + return; + } + + // Code below here can be removed once OOPIF ships. + // OOPIF will prevent synthetic events being dispatched into + // other frames; but for now we allow the fallback to generate + // WebMouseEvents from synthetic events. if (event.type() == EventTypeNames::mousemove) m_type = WebInputEvent::MouseMove; else if (event.type() == EventTypeNames::mouseout) @@ -308,8 +264,6 @@ WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, clickCount = event.detail(); pointerType = WebPointerProperties::PointerType::Mouse; - if (event.mouseEvent()) - pointerType = event.mouseEvent()->pointerProperties().pointerType; } // Generate a synthetic WebMouseEvent given a TouchEvent (eg. for emulating a @@ -396,13 +350,13 @@ WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) { windowsKeyCode = event.keyCode(); } -Vector createPlatformMouseEventVector( +Vector TransformWebMouseEventVector( Widget* widget, const std::vector& coalescedEvents) { - Vector result; + Vector result; for (const auto& event : coalescedEvents) { DCHECK(WebInputEvent::isMouseEventType(event->type())); - result.push_back(PlatformMouseEventBuilder( + result.push_back(TransformWebMouseEvent( widget, static_cast(*event))); } return result; diff --git a/third_party/WebKit/Source/web/WebInputEventConversion.h b/third_party/WebKit/Source/web/WebInputEventConversion.h index f2972ec3c692c6..0d4878361ab98a 100644 --- a/third_party/WebKit/Source/web/WebInputEventConversion.h +++ b/third_party/WebKit/Source/web/WebInputEventConversion.h @@ -31,7 +31,6 @@ #ifndef WebInputEventConversion_h #define WebInputEventConversion_h -#include "platform/PlatformMouseEvent.h" #include "platform/scroll/ScrollTypes.h" #include "public/platform/WebInputEvent.h" #include "public/platform/WebKeyboardEvent.h" @@ -48,19 +47,12 @@ class MouseEvent; class LayoutItem; class TouchEvent; class WebGestureEvent; -class WebMouseEvent; class WebKeyboardEvent; -class WebTouchEvent; class Widget; // These classes are used to convert from WebInputEvent subclasses to // corresponding WebCore events. -class WEB_EXPORT PlatformMouseEventBuilder - : NON_EXPORTED_BASE(public PlatformMouseEvent) { - public: - PlatformMouseEventBuilder(Widget*, const WebMouseEvent&); -}; class WEB_EXPORT WebMouseEventBuilder : NON_EXPORTED_BASE(public WebMouseEvent) { @@ -96,14 +88,15 @@ class WEB_EXPORT WebTouchEventBuilder // and translation. WEB_EXPORT WebGestureEvent TransformWebGestureEvent(Widget*, const WebGestureEvent&); +WEB_EXPORT WebMouseEvent TransformWebMouseEvent(Widget*, const WebMouseEvent&); + WEB_EXPORT WebMouseWheelEvent TransformWebMouseWheelEvent(Widget*, const WebMouseWheelEvent&); WEB_EXPORT WebTouchEvent TransformWebTouchEvent(Widget*, const WebTouchEvent&); -Vector WEB_EXPORT -createPlatformMouseEventVector(Widget*, - const std::vector&); +Vector WEB_EXPORT +TransformWebMouseEventVector(Widget*, const std::vector&); Vector WEB_EXPORT TransformWebTouchEventVector(Widget*, const std::vector&); diff --git a/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp b/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp index 865ab971dcd5c3..00617d0b41d1c4 100644 --- a/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp +++ b/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp @@ -706,16 +706,16 @@ void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) { // in the call to HandleEvent. See http://b/issue?id=1362948 FrameView* parentView = toFrameView(parent()); - WebMouseEventBuilder webEvent(this, LayoutItem(m_element->layoutObject()), - *event); - if (webEvent.type() == WebInputEvent::Undefined) + WebMouseEventBuilder transformedEvent( + this, LayoutItem(m_element->layoutObject()), *event); + if (transformedEvent.type() == WebInputEvent::Undefined) return; if (event->type() == EventTypeNames::mousedown) focusPlugin(); WebCursorInfo cursorInfo; - if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != + if (m_webPlugin->handleInputEvent(transformedEvent, cursorInfo) != WebInputEventResult::NotHandled) event->setDefaultHandled(); diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp index fe119164d3f4f1..ddc23b9cacb0e3 100644 --- a/third_party/WebKit/Source/web/WebViewImpl.cpp +++ b/third_party/WebKit/Source/web/WebViewImpl.cpp @@ -97,7 +97,6 @@ #include "platform/Cursor.h" #include "platform/Histogram.h" #include "platform/KeyboardCodes.h" -#include "platform/PlatformMouseEvent.h" #include "platform/RuntimeEnabledFeatures.h" #include "platform/UserGestureIndicator.h" #include "platform/animation/CompositorAnimationHost.h" @@ -556,10 +555,13 @@ void WebViewImpl::mouseContextMenu(const WebMouseEvent& event) { m_page->contextMenuController().clearContextMenu(); - PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), event); + WebMouseEvent transformedEvent = + TransformWebMouseEvent(mainFrameImpl()->frameView(), event); + IntPoint positionInRootFrame = + flooredIntPoint(transformedEvent.positionInRootFrame()); // Find the right target frame. See issue 1186900. - HitTestResult result = hitTestResultForRootFramePos(pme.position()); + HitTestResult result = hitTestResultForRootFramePos(positionInRootFrame); Frame* targetFrame; if (result.innerNodeOrImageMapImage()) targetFrame = result.innerNodeOrImageMapImage()->document().frame(); @@ -577,7 +579,8 @@ void WebViewImpl::mouseContextMenu(const WebMouseEvent& event) { { ContextMenuAllowedScope scope; - targetLocalFrame->eventHandler().sendContextMenuEvent(pme, nullptr); + targetLocalFrame->eventHandler().sendContextMenuEvent(transformedEvent, + nullptr); } // Actually showing the context menu is handled by the ContextMenuClient // implementation... @@ -2189,11 +2192,11 @@ WebInputEventResult WebViewImpl::handleInputEvent( NOTREACHED(); } - node->dispatchMouseEvent( - PlatformMouseEventBuilder( - mainFrameImpl()->frameView(), - static_cast(inputEvent)), - eventType, static_cast(inputEvent).clickCount); + WebMouseEvent transformedEvent = + TransformWebMouseEvent(mainFrameImpl()->frameView(), + static_cast(inputEvent)); + node->dispatchMouseEvent(transformedEvent, eventType, + transformedEvent.clickCount); return WebInputEventResult::HandledSystem; } @@ -4125,10 +4128,12 @@ void WebViewImpl::pointerLockMouseEvent(const WebInputEvent& event) { const WebMouseEvent& mouseEvent = static_cast(event); - if (page()) - page()->pointerLockController().dispatchLockedMouseEvent( - PlatformMouseEventBuilder(mainFrameImpl()->frameView(), mouseEvent), - eventType); + if (page()) { + WebMouseEvent transformedEvent = + TransformWebMouseEvent(mainFrameImpl()->frameView(), mouseEvent); + page()->pointerLockController().dispatchLockedMouseEvent(transformedEvent, + eventType); + } } void WebViewImpl::forceNextWebGLContextCreationToFail() { diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp index f07cc25b0229d6..d123a03ceffb17 100644 --- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp +++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp @@ -79,7 +79,6 @@ #include "modules/mediastream/MediaStreamRegistry.h" #include "platform/Cursor.h" #include "platform/DragImage.h" -#include "platform/PlatformMouseEvent.h" #include "platform/PlatformResourceLoader.h" #include "platform/RuntimeEnabledFeatures.h" #include "platform/UserGestureIndicator.h" @@ -6873,10 +6872,12 @@ TEST_P(ParameterizedWebFrameTest, SimulateFragmentAnchorMiddleClick) { KURL destination = document->url(); destination.setFragmentIdentifier("test"); - Event* event = MouseEvent::create( - EventTypeNames::click, false, false, document->domWindow(), 0, 0, 0, 0, 0, - 0, 0, PlatformEvent::NoModifiers, 1, 0, nullptr, TimeTicks(), - PlatformMouseEvent::RealOrIndistinguishable, String(), nullptr); + MouseEventInit mouseInitializer; + mouseInitializer.setView(document->domWindow()); + mouseInitializer.setButton(1); + + Event* event = + MouseEvent::create(nullptr, EventTypeNames::click, mouseInitializer); FrameLoadRequest frameRequest(document, ResourceRequest(destination)); frameRequest.setTriggeringEvent(event); toLocalFrame(webViewHelper.webView()->page()->mainFrame()) @@ -6928,10 +6929,13 @@ TEST_P(ParameterizedWebFrameTest, ModifiedClickNewWindow) { KURL destination = toKURL(m_baseURL + "hello_world.html"); // ctrl+click event - Event* event = MouseEvent::create( - EventTypeNames::click, false, false, document->domWindow(), 0, 0, 0, 0, 0, - 0, 0, PlatformEvent::CtrlKey, 0, 0, nullptr, TimeTicks(), - PlatformMouseEvent::RealOrIndistinguishable, String(), nullptr); + MouseEventInit mouseInitializer; + mouseInitializer.setView(document->domWindow()); + mouseInitializer.setButton(1); + mouseInitializer.setCtrlKey(true); + + Event* event = + MouseEvent::create(nullptr, EventTypeNames::click, mouseInitializer); FrameLoadRequest frameRequest(document, ResourceRequest(destination)); frameRequest.setTriggeringEvent(event); UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); @@ -10795,13 +10799,15 @@ TEST_F(WebFrameTest, MouseOverDifferntNodeClearsTooltip) { EXPECT_TRUE(hitTestResult.innerElement()); // Mouse over link. Mouse cursor should be hand. - PlatformMouseEvent mouseMoveOverLinkEvent( - IntPoint(div1Tag->offsetLeft() + 5, div1Tag->offsetTop() + 5), - IntPoint(div1Tag->offsetLeft() + 5, div1Tag->offsetTop() + 5), - WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 0, - PlatformEvent::NoModifiers, TimeTicks::Now()); + WebMouseEvent mouseMoveOverLinkEvent( + WebInputEvent::MouseMove, + WebFloatPoint(div1Tag->offsetLeft() + 5, div1Tag->offsetTop() + 5), + WebFloatPoint(div1Tag->offsetLeft() + 5, div1Tag->offsetTop() + 5), + WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers, + TimeTicks::Now().InSeconds()); + mouseMoveOverLinkEvent.setFrameScale(1); document->frame()->eventHandler().handleMouseMoveEvent( - mouseMoveOverLinkEvent, Vector()); + mouseMoveOverLinkEvent, Vector()); EXPECT_EQ(document->hoverNode(), document->frame()->chromeClient().lastSetTooltipNodeForTesting()); @@ -10810,13 +10816,15 @@ TEST_F(WebFrameTest, MouseOverDifferntNodeClearsTooltip) { Element* div2Tag = document->getElementById("div2"); - PlatformMouseEvent mouseMoveEvent( - IntPoint(div2Tag->offsetLeft() + 5, div2Tag->offsetTop() + 5), - IntPoint(div2Tag->offsetLeft() + 5, div2Tag->offsetTop() + 5), - WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 0, - PlatformEvent::NoModifiers, TimeTicks::Now()); + WebMouseEvent mouseMoveEvent( + WebInputEvent::MouseMove, + WebFloatPoint(div2Tag->offsetLeft() + 5, div2Tag->offsetTop() + 5), + WebFloatPoint(div2Tag->offsetLeft() + 5, div2Tag->offsetTop() + 5), + WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers, + TimeTicks::Now().InSeconds()); + mouseMoveEvent.setFrameScale(1); document->frame()->eventHandler().handleMouseMoveEvent( - mouseMoveEvent, Vector()); + mouseMoveEvent, Vector()); EXPECT_EQ(document->hoverNode(), document->frame()->chromeClient().lastSetTooltipNodeForTesting()); @@ -10857,13 +10865,15 @@ TEST_F(WebFrameTest, MouseOverLinkAndOverlayScrollbar) { EXPECT_FALSE(hitTestResult.scrollbar()->isCustomScrollbar()); // Mouse over link. Mouse cursor should be hand. - PlatformMouseEvent mouseMoveOverLinkEvent( - IntPoint(aTag->offsetLeft(), aTag->offsetTop()), - IntPoint(aTag->offsetLeft(), aTag->offsetTop()), - WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 0, - PlatformEvent::NoModifiers, TimeTicks::Now()); + WebMouseEvent mouseMoveOverLinkEvent( + WebInputEvent::MouseMove, + WebFloatPoint(aTag->offsetLeft(), aTag->offsetTop()), + WebFloatPoint(aTag->offsetLeft(), aTag->offsetTop()), + WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers, + TimeTicks::Now().InSeconds()); + mouseMoveOverLinkEvent.setFrameScale(1); document->frame()->eventHandler().handleMouseMoveEvent( - mouseMoveOverLinkEvent, Vector()); + mouseMoveOverLinkEvent, Vector()); EXPECT_EQ( Cursor::Type::Hand, @@ -10871,31 +10881,37 @@ TEST_F(WebFrameTest, MouseOverLinkAndOverlayScrollbar) { // Mouse over enabled overlay scrollbar. Mouse cursor should be pointer and no // active hover element. - PlatformMouseEvent mouseMoveEvent( - IntPoint(18, aTag->offsetTop()), IntPoint(18, aTag->offsetTop()), - WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 0, - PlatformEvent::NoModifiers, TimeTicks::Now()); + WebMouseEvent mouseMoveEvent( + WebInputEvent::MouseMove, WebFloatPoint(18, aTag->offsetTop()), + WebFloatPoint(18, aTag->offsetTop()), + WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers, + TimeTicks::Now().InSeconds()); + mouseMoveEvent.setFrameScale(1); document->frame()->eventHandler().handleMouseMoveEvent( - mouseMoveEvent, Vector()); + mouseMoveEvent, Vector()); EXPECT_EQ( Cursor::Type::Pointer, document->frame()->chromeClient().lastSetCursorForTesting().getType()); - PlatformMouseEvent mousePressEvent( - IntPoint(18, aTag->offsetTop()), IntPoint(18, aTag->offsetTop()), - WebPointerProperties::Button::Left, PlatformEvent::MousePressed, 0, - PlatformEvent::Modifiers::LeftButtonDown, TimeTicks::Now()); + WebMouseEvent mousePressEvent( + WebInputEvent::MouseDown, WebFloatPoint(18, aTag->offsetTop()), + WebFloatPoint(18, aTag->offsetTop()), WebPointerProperties::Button::Left, + 0, WebInputEvent::Modifiers::LeftButtonDown, + TimeTicks::Now().InSeconds()); + mousePressEvent.setFrameScale(1); document->frame()->eventHandler().handleMousePressEvent(mousePressEvent); EXPECT_FALSE(document->activeHoverElement()); EXPECT_FALSE(document->hoverNode()); - PlatformMouseEvent MouseReleaseEvent( - IntPoint(18, aTag->offsetTop()), IntPoint(18, aTag->offsetTop()), - WebPointerProperties::Button::Left, PlatformEvent::MouseReleased, 0, - PlatformEvent::Modifiers::LeftButtonDown, TimeTicks::Now()); - document->frame()->eventHandler().handleMouseReleaseEvent(MouseReleaseEvent); + WebMouseEvent mouseReleaseEvent( + WebInputEvent::MouseUp, WebFloatPoint(18, aTag->offsetTop()), + WebFloatPoint(18, aTag->offsetTop()), WebPointerProperties::Button::Left, + 0, WebInputEvent::Modifiers::LeftButtonDown, + TimeTicks::Now().InSeconds()); + mouseReleaseEvent.setFrameScale(1); + document->frame()->eventHandler().handleMouseReleaseEvent(mouseReleaseEvent); // Mouse over disabled overlay scrollbar. Mouse cursor should be hand and has // active hover element. @@ -10909,7 +10925,7 @@ TEST_F(WebFrameTest, MouseOverLinkAndOverlayScrollbar) { EXPECT_FALSE(hitTestResult.scrollbar()); document->frame()->eventHandler().handleMouseMoveEvent( - mouseMoveEvent, Vector()); + mouseMoveEvent, Vector()); EXPECT_EQ( Cursor::Type::Hand, @@ -10920,7 +10936,7 @@ TEST_F(WebFrameTest, MouseOverLinkAndOverlayScrollbar) { EXPECT_TRUE(document->activeHoverElement()); EXPECT_TRUE(document->hoverNode()); - document->frame()->eventHandler().handleMouseReleaseEvent(MouseReleaseEvent); + document->frame()->eventHandler().handleMouseReleaseEvent(mouseReleaseEvent); } // Makes sure that mouse hover over an custom scrollbar doesn't change the @@ -10947,12 +10963,13 @@ TEST_F(WebFrameTest, MouseOverCustomScrollbar) { EXPECT_FALSE(hitTestResult.scrollbar()); // Mouse over DIV - PlatformMouseEvent mouseMoveOverDiv( - IntPoint(1, 1), IntPoint(1, 1), WebPointerProperties::Button::NoButton, - PlatformEvent::MouseMoved, 0, PlatformEvent::NoModifiers, - TimeTicks::Now()); + WebMouseEvent mouseMoveOverDiv( + WebInputEvent::MouseMove, WebFloatPoint(1, 1), WebFloatPoint(1, 1), + WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers, + TimeTicks::Now().InSeconds()); + mouseMoveOverDiv.setFrameScale(1); document->frame()->eventHandler().handleMouseMoveEvent( - mouseMoveOverDiv, Vector()); + mouseMoveOverDiv, Vector()); // DIV :hover EXPECT_EQ(document->hoverNode(), scrollbarDiv); @@ -10965,12 +10982,13 @@ TEST_F(WebFrameTest, MouseOverCustomScrollbar) { EXPECT_TRUE(hitTestResult.scrollbar()->isCustomScrollbar()); // Mouse over scrollbar - PlatformMouseEvent mouseMoveOverDivAndScrollbar( - IntPoint(175, 1), IntPoint(175, 1), - WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 0, - PlatformEvent::NoModifiers, TimeTicks::Now()); + WebMouseEvent mouseMoveOverDivAndScrollbar( + WebInputEvent::MouseMove, WebFloatPoint(175, 1), WebFloatPoint(175, 1), + WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers, + TimeTicks::Now().InSeconds()); + mouseMoveOverDivAndScrollbar.setFrameScale(1); document->frame()->eventHandler().handleMouseMoveEvent( - mouseMoveOverDivAndScrollbar, Vector()); + mouseMoveOverDivAndScrollbar, Vector()); // Custom not change the DIV :hover EXPECT_EQ(document->hoverNode(), scrollbarDiv); @@ -11001,41 +11019,45 @@ TEST_F(WebFrameTest, MouseReleaseUpdatesScrollbarHoveredPart) { EXPECT_EQ(scrollbar->hoveredPart(), ScrollbarPart::NoPart); // Mouse moved over the scrollbar. - PlatformMouseEvent mouseMoveOverScrollbar( - IntPoint(175, 1), IntPoint(175, 1), - WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 0, - PlatformEvent::NoModifiers, TimeTicks::Now()); + WebMouseEvent mouseMoveOverScrollbar( + WebInputEvent::MouseMove, WebFloatPoint(175, 1), WebFloatPoint(175, 1), + WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers, + TimeTicks::Now().InSeconds()); + mouseMoveOverScrollbar.setFrameScale(1); document->frame()->eventHandler().handleMouseMoveEvent( - mouseMoveOverScrollbar, Vector()); + mouseMoveOverScrollbar, Vector()); HitTestResult hitTestResult = webView->coreHitTestResultAt(WebPoint(175, 1)); EXPECT_EQ(scrollbar->pressedPart(), ScrollbarPart::NoPart); EXPECT_EQ(scrollbar->hoveredPart(), ScrollbarPart::ThumbPart); // Mouse pressed. - PlatformMouseEvent mousePressEvent( - IntPoint(175, 1), IntPoint(175, 1), WebPointerProperties::Button::Left, - PlatformEvent::MousePressed, 0, PlatformEvent::Modifiers::LeftButtonDown, - TimeTicks::Now()); + WebMouseEvent mousePressEvent( + WebInputEvent::MouseDown, WebFloatPoint(175, 1), WebFloatPoint(175, 1), + WebPointerProperties::Button::Left, 0, + WebInputEvent::Modifiers::LeftButtonDown, TimeTicks::Now().InSeconds()); + mousePressEvent.setFrameScale(1); document->frame()->eventHandler().handleMousePressEvent(mousePressEvent); EXPECT_EQ(scrollbar->pressedPart(), ScrollbarPart::ThumbPart); EXPECT_EQ(scrollbar->hoveredPart(), ScrollbarPart::ThumbPart); // Mouse moved off the scrollbar while still pressed. - PlatformMouseEvent mouseMoveOffScrollbar( - IntPoint(1, 1), IntPoint(1, 1), WebPointerProperties::Button::Left, - PlatformEvent::MouseMoved, 0, PlatformEvent::Modifiers::LeftButtonDown, - TimeTicks::Now()); + WebMouseEvent mouseMoveOffScrollbar( + WebInputEvent::MouseMove, WebFloatPoint(1, 1), WebFloatPoint(1, 1), + WebPointerProperties::Button::Left, 0, + WebInputEvent::Modifiers::LeftButtonDown, TimeTicks::Now().InSeconds()); + mouseMoveOffScrollbar.setFrameScale(1); document->frame()->eventHandler().handleMouseLeaveEvent( mouseMoveOffScrollbar); EXPECT_EQ(scrollbar->pressedPart(), ScrollbarPart::ThumbPart); EXPECT_EQ(scrollbar->hoveredPart(), ScrollbarPart::ThumbPart); // Mouse released. - PlatformMouseEvent MouseReleaseEvent( - IntPoint(1, 1), IntPoint(1, 1), WebPointerProperties::Button::Left, - PlatformEvent::MouseReleased, 0, PlatformEvent::Modifiers::LeftButtonDown, - TimeTicks::Now()); - document->frame()->eventHandler().handleMouseReleaseEvent(MouseReleaseEvent); + WebMouseEvent mouseReleaseEvent( + WebInputEvent::MouseUp, WebFloatPoint(1, 1), WebFloatPoint(1, 1), + WebPointerProperties::Button::Left, 0, + WebInputEvent::Modifiers::LeftButtonDown, TimeTicks::Now().InSeconds()); + mouseReleaseEvent.setFrameScale(1); + document->frame()->eventHandler().handleMouseReleaseEvent(mouseReleaseEvent); EXPECT_EQ(scrollbar->pressedPart(), ScrollbarPart::NoPart); EXPECT_EQ(scrollbar->hoveredPart(), ScrollbarPart::NoPart); } diff --git a/third_party/WebKit/Source/web/tests/WebInputEventConversionTest.cpp b/third_party/WebKit/Source/web/tests/WebInputEventConversionTest.cpp index 4de6fd5a38f6f9..6189e7b0e2709c 100644 --- a/third_party/WebKit/Source/web/tests/WebInputEventConversionTest.cpp +++ b/third_party/WebKit/Source/web/tests/WebInputEventConversionTest.cpp @@ -121,10 +121,6 @@ TEST(WebInputEventConversionTest, InputEventsScaling) { webViewImpl->setPageScaleFactor(2); FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); - Document* document = - toLocalFrame(webViewImpl->page()->mainFrame())->document(); - LocalDOMWindow* domWindow = document->domWindow(); - LayoutViewItem documentLayoutView = document->layoutViewItem(); { WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, @@ -139,13 +135,17 @@ TEST(WebInputEventConversionTest, InputEventsScaling) { webMouseEvent.movementX = 10; webMouseEvent.movementY = 10; - PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); - EXPECT_EQ(5, platformMouseBuilder.position().x()); - EXPECT_EQ(5, platformMouseBuilder.position().y()); - EXPECT_EQ(10, platformMouseBuilder.globalPosition().x()); - EXPECT_EQ(10, platformMouseBuilder.globalPosition().y()); - EXPECT_EQ(5, platformMouseBuilder.movementDelta().x()); - EXPECT_EQ(5, platformMouseBuilder.movementDelta().y()); + WebMouseEvent transformedEvent = + TransformWebMouseEvent(view, webMouseEvent); + IntPoint position = flooredIntPoint(transformedEvent.positionInRootFrame()); + EXPECT_EQ(5, position.x()); + EXPECT_EQ(5, position.y()); + EXPECT_EQ(10, transformedEvent.globalX); + EXPECT_EQ(10, transformedEvent.globalY); + + IntPoint movement = flooredIntPoint(transformedEvent.movementInRootFrame()); + EXPECT_EQ(5, movement.x()); + EXPECT_EQ(5, movement.y()); } { @@ -326,37 +326,6 @@ TEST(WebInputEventConversionTest, InputEventsScaling) { EXPECT_FLOAT_EQ(5.3f, transformedPoint.radiusX); EXPECT_FLOAT_EQ(5.2f, transformedPoint.radiusY); } - - // Reverse builders should *not* go back to physical pixels, as they are used - // for plugins which expect CSS pixel coordinates. - { - PlatformMouseEvent platformMouseEvent( - IntPoint(10, 10), IntPoint(10, 10), WebPointerProperties::Button::Left, - PlatformEvent::MouseMoved, 1, PlatformEvent::NoModifiers, - PlatformMouseEvent::RealOrIndistinguishable, TimeTicks()); - MouseEvent* mouseEvent = MouseEvent::create( - EventTypeNames::mousemove, domWindow, platformMouseEvent, 0, document); - WebMouseEventBuilder webMouseBuilder(view, documentLayoutView, *mouseEvent); - - EXPECT_EQ(10, webMouseBuilder.x); - EXPECT_EQ(10, webMouseBuilder.y); - EXPECT_EQ(10, webMouseBuilder.globalX); - EXPECT_EQ(10, webMouseBuilder.globalY); - EXPECT_EQ(10, webMouseBuilder.windowX); - EXPECT_EQ(10, webMouseBuilder.windowY); - } - - { - PlatformMouseEvent platformMouseEvent( - IntPoint(10, 10), IntPoint(10, 10), - WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 1, - PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, - TimeTicks()); - MouseEvent* mouseEvent = MouseEvent::create( - EventTypeNames::mousemove, domWindow, platformMouseEvent, 0, document); - WebMouseEventBuilder webMouseBuilder(view, documentLayoutView, *mouseEvent); - EXPECT_EQ(WebMouseEvent::Button::NoButton, webMouseBuilder.button); - } } TEST(WebInputEventConversionTest, InputEventsTransform) { @@ -394,13 +363,18 @@ TEST(WebInputEventConversionTest, InputEventsTransform) { webMouseEvent.movementX = 60; webMouseEvent.movementY = 60; - PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); - EXPECT_EQ(30, platformMouseBuilder.position().x()); - EXPECT_EQ(30, platformMouseBuilder.position().y()); - EXPECT_EQ(100, platformMouseBuilder.globalPosition().x()); - EXPECT_EQ(110, platformMouseBuilder.globalPosition().y()); - EXPECT_EQ(20, platformMouseBuilder.movementDelta().x()); - EXPECT_EQ(20, platformMouseBuilder.movementDelta().y()); + WebMouseEvent transformedEvent = + TransformWebMouseEvent(view, webMouseEvent); + FloatPoint position = transformedEvent.positionInRootFrame(); + + EXPECT_FLOAT_EQ(30, position.x()); + EXPECT_FLOAT_EQ(30, position.y()); + EXPECT_EQ(100, transformedEvent.globalX); + EXPECT_EQ(110, transformedEvent.globalY); + + IntPoint movement = flooredIntPoint(transformedEvent.movementInRootFrame()); + EXPECT_EQ(20, movement.x()); + EXPECT_EQ(20, movement.y()); } { @@ -426,23 +400,30 @@ TEST(WebInputEventConversionTest, InputEventsTransform) { events.push_back(&webMouseEvent1); events.push_back(&webMouseEvent2); - Vector coalescedevents = - createPlatformMouseEventVector(view, events); + Vector coalescedevents = + TransformWebMouseEventVector(view, events); EXPECT_EQ(events.size(), coalescedevents.size()); - EXPECT_EQ(30, coalescedevents[0].position().x()); - EXPECT_EQ(30, coalescedevents[0].position().y()); - EXPECT_EQ(100, coalescedevents[0].globalPosition().x()); - EXPECT_EQ(110, coalescedevents[0].globalPosition().y()); - EXPECT_EQ(20, coalescedevents[0].movementDelta().x()); - EXPECT_EQ(20, coalescedevents[0].movementDelta().y()); - - EXPECT_EQ(30, coalescedevents[1].position().x()); - EXPECT_EQ(40, coalescedevents[1].position().y()); - EXPECT_EQ(100, coalescedevents[1].globalPosition().x()); - EXPECT_EQ(140, coalescedevents[1].globalPosition().y()); - EXPECT_EQ(20, coalescedevents[1].movementDelta().x()); - EXPECT_EQ(10, coalescedevents[1].movementDelta().y()); + FloatPoint position = coalescedevents[0].positionInRootFrame(); + EXPECT_FLOAT_EQ(30, position.x()); + EXPECT_FLOAT_EQ(30, position.y()); + EXPECT_EQ(100, coalescedevents[0].globalX); + EXPECT_EQ(110, coalescedevents[0].globalY); + + IntPoint movement = + flooredIntPoint(coalescedevents[0].movementInRootFrame()); + EXPECT_EQ(20, movement.x()); + EXPECT_EQ(20, movement.y()); + + position = coalescedevents[1].positionInRootFrame(); + EXPECT_FLOAT_EQ(30, position.x()); + EXPECT_FLOAT_EQ(40, position.y()); + EXPECT_EQ(100, coalescedevents[1].globalX); + EXPECT_EQ(140, coalescedevents[1].globalY); + + movement = flooredIntPoint(coalescedevents[1].movementInRootFrame()); + EXPECT_EQ(20, movement.x()); + EXPECT_EQ(10, movement.y()); } { @@ -703,11 +684,14 @@ TEST(WebInputEventConversionTest, VisualViewportOffset) { webMouseEvent.globalX = 10; webMouseEvent.globalY = 10; - PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); - EXPECT_EQ(5 + visualOffset.x(), platformMouseBuilder.position().x()); - EXPECT_EQ(5 + visualOffset.y(), platformMouseBuilder.position().y()); - EXPECT_EQ(10, platformMouseBuilder.globalPosition().x()); - EXPECT_EQ(10, platformMouseBuilder.globalPosition().y()); + WebMouseEvent transformedMouseEvent = + TransformWebMouseEvent(view, webMouseEvent); + IntPoint position = + flooredIntPoint(transformedMouseEvent.positionInRootFrame()); + EXPECT_EQ(5 + visualOffset.x(), position.x()); + EXPECT_EQ(5 + visualOffset.y(), position.y()); + EXPECT_EQ(10, transformedMouseEvent.globalX); + EXPECT_EQ(10, transformedMouseEvent.globalY); } { @@ -811,13 +795,15 @@ TEST(WebInputEventConversionTest, ElasticOverscroll) { webMouseEvent.globalX = 10; webMouseEvent.globalY = 50; - PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); - EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), - platformMouseBuilder.position().x()); - EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), - platformMouseBuilder.position().y()); - EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x()); - EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y()); + WebMouseEvent transformedMouseEvent = + TransformWebMouseEvent(view, webMouseEvent); + IntPoint position = + flooredIntPoint(transformedMouseEvent.positionInRootFrame()); + + EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), position.x()); + EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), position.y()); + EXPECT_EQ(webMouseEvent.globalX, transformedMouseEvent.globalX); + EXPECT_EQ(webMouseEvent.globalY, transformedMouseEvent.globalY); } // Elastic overscroll and pinch-zoom (this doesn't actually ever happen, @@ -838,15 +824,19 @@ TEST(WebInputEventConversionTest, ElasticOverscroll) { webMouseEvent.globalX = 10; webMouseEvent.globalY = 10; - PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); + WebMouseEvent transformedMouseEvent = + TransformWebMouseEvent(view, webMouseEvent); + IntPoint position = + flooredIntPoint(transformedMouseEvent.positionInRootFrame()); + EXPECT_EQ(webMouseEvent.x / pageScale + visualOffset.x() + elasticOverscroll.width(), - platformMouseBuilder.position().x()); + position.x()); EXPECT_EQ(webMouseEvent.y / pageScale + visualOffset.y() + elasticOverscroll.height(), - platformMouseBuilder.position().y()); - EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x()); - EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y()); + position.y()); + EXPECT_EQ(webMouseEvent.globalX, transformedMouseEvent.globalX); + EXPECT_EQ(webMouseEvent.globalY, transformedMouseEvent.globalY); } } @@ -884,13 +874,15 @@ TEST(WebInputEventConversionTest, ElasticOverscrollWithPageReload) { webMouseEvent.globalX = 10; webMouseEvent.globalY = 50; - PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); - EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), - platformMouseBuilder.position().x()); - EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), - platformMouseBuilder.position().y()); - EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x()); - EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y()); + WebMouseEvent transformedMouseEvent = + TransformWebMouseEvent(view, webMouseEvent); + IntPoint position = + flooredIntPoint(transformedMouseEvent.positionInRootFrame()); + + EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), position.x()); + EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), position.y()); + EXPECT_EQ(webMouseEvent.globalX, transformedMouseEvent.globalX); + EXPECT_EQ(webMouseEvent.globalY, transformedMouseEvent.globalY); } } diff --git a/third_party/WebKit/public/platform/WebInputEvent.h b/third_party/WebKit/public/platform/WebInputEvent.h index 99e27f0810b4b9..9efd6a8781a376 100644 --- a/third_party/WebKit/public/platform/WebInputEvent.h +++ b/third_party/WebKit/public/platform/WebInputEvent.h @@ -187,6 +187,11 @@ class WebInputEvent { ScrollLockOn = 1 << 18, + // Whether this is a compatibility event generated due to a + // native touch event. Mouse events generated from touch + // events will set this. + IsCompatibilityEventForTouch = 1 << 19, + // The set of non-stateful modifiers that specifically change the // interpretation of the key being pressed. For example; IsLeft, // IsRight, IsComposing don't change the meaning of the key diff --git a/third_party/WebKit/public/platform/WebMouseEvent.h b/third_party/WebKit/public/platform/WebMouseEvent.h index ec23a72f442ff2..c9e5a419d1edf8 100644 --- a/third_party/WebKit/public/platform/WebMouseEvent.h +++ b/third_party/WebKit/public/platform/WebMouseEvent.h @@ -9,6 +9,8 @@ namespace blink { +class WebGestureEvent; + // See WebInputEvent.h for details why this pack is here. #pragma pack(push, 4) @@ -34,16 +36,69 @@ class WebMouseEvent : public WebInputEvent, public WebPointerProperties { int movementY; int clickCount; - WebMouseEvent(Type type, int modifiers, double timeStampSeconds) - : WebInputEvent(sizeof(WebMouseEvent), type, modifiers, timeStampSeconds), - WebPointerProperties() {} - - WebMouseEvent() - : WebInputEvent(sizeof(WebMouseEvent)), WebPointerProperties() {} + WebMouseEvent(Type typeParam, + int xParam, + int yParam, + int globalXParam, + int globalYParam, + int modifiersParam, + double timeStampSecondsParam) + : WebInputEvent(sizeof(WebMouseEvent), + typeParam, + modifiersParam, + timeStampSecondsParam), + WebPointerProperties(), + x(xParam), + y(yParam), + globalX(globalXParam), + globalY(globalYParam) {} + + WebMouseEvent(Type typeParam, + WebFloatPoint position, + WebFloatPoint globalPosition, + Button buttonParam, + int clickCountParam, + int modifiersParam, + double timeStampSecondsParam) + : WebInputEvent(sizeof(WebMouseEvent), + typeParam, + modifiersParam, + timeStampSecondsParam), + WebPointerProperties(buttonParam, PointerType::Mouse), + x(position.x), + y(position.y), + globalX(globalPosition.x), + globalY(globalPosition.y), + clickCount(clickCountParam) {} + + WebMouseEvent(Type typeParam, + int modifiersParam, + double timeStampSecondsParam) + : WebMouseEvent(sizeof(WebMouseEvent), + typeParam, + modifiersParam, + timeStampSecondsParam) {} + + WebMouseEvent() : WebMouseEvent(sizeof(WebMouseEvent)) {} + + bool fromTouch() const { + return (modifiers() & IsCompatibilityEventForTouch) != 0; + } #if INSIDE_BLINK + BLINK_PLATFORM_EXPORT WebMouseEvent(Type typeParam, + const WebGestureEvent&, + Button buttonParam, + int clickCountParam, + int modifiersParam, + double timeStampSecondsParam); + BLINK_PLATFORM_EXPORT WebFloatPoint movementInRootFrame() const; BLINK_PLATFORM_EXPORT WebFloatPoint positionInRootFrame() const; + + // Sets any scaled values to be their computed values and sets |frameScale| + // back to 1 and |translateX|, |translateY| back to 0. + BLINK_PLATFORM_EXPORT WebMouseEvent flattenTransform() const; #endif protected: diff --git a/third_party/WebKit/public/platform/WebPointerProperties.h b/third_party/WebKit/public/platform/WebPointerProperties.h index 86f2960081b822..27e59c44268912 100644 --- a/third_party/WebKit/public/platform/WebPointerProperties.h +++ b/third_party/WebKit/public/platform/WebPointerProperties.h @@ -17,16 +17,6 @@ namespace blink { // WebTouchEvent and WebTouchPoint and merge this into WebPointerEvent. class WebPointerProperties { public: - WebPointerProperties() - : id(0), - force(std::numeric_limits::quiet_NaN()), - tiltX(0), - tiltY(0), - tangentialPressure(0.0f), - twist(0), - button(Button::NoButton), - pointerType(PointerType::Unknown) {} - enum class Button { NoButton = -1, Left, Middle, Right, X1, X2, Eraser }; enum class Buttons : unsigned { @@ -48,6 +38,26 @@ class WebPointerProperties { LastEntry = Touch // Must be the last entry in the list }; + WebPointerProperties() + : id(0), + force(std::numeric_limits::quiet_NaN()), + tiltX(0), + tiltY(0), + tangentialPressure(0.0f), + twist(0), + button(Button::NoButton), + pointerType(PointerType::Unknown) {} + + WebPointerProperties(Button buttonParam, PointerType pointerTypeParam) + : id(0), + force(std::numeric_limits::quiet_NaN()), + tiltX(0), + tiltY(0), + tangentialPressure(0.0f), + twist(0), + button(buttonParam), + pointerType(pointerTypeParam) {} + int id; // The valid range is [0,1], with NaN meaning pressure is not supported by