OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. |
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 24 matching lines...) Expand all Loading... | |
35 #include "core/clipboard/DataTransfer.h" | 35 #include "core/clipboard/DataTransfer.h" |
36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
37 #include "core/dom/TouchList.h" | 37 #include "core/dom/TouchList.h" |
38 #include "core/dom/shadow/ComposedTreeTraversal.h" | 38 #include "core/dom/shadow/ComposedTreeTraversal.h" |
39 #include "core/dom/shadow/ShadowRoot.h" | 39 #include "core/dom/shadow/ShadowRoot.h" |
40 #include "core/editing/Editor.h" | 40 #include "core/editing/Editor.h" |
41 #include "core/editing/FrameSelection.h" | 41 #include "core/editing/FrameSelection.h" |
42 #include "core/editing/SelectionController.h" | 42 #include "core/editing/SelectionController.h" |
43 #include "core/events/DragEvent.h" | 43 #include "core/events/DragEvent.h" |
44 #include "core/events/EventPath.h" | 44 #include "core/events/EventPath.h" |
45 #include "core/events/GestureEvent.h" | |
45 #include "core/events/KeyboardEvent.h" | 46 #include "core/events/KeyboardEvent.h" |
46 #include "core/events/MouseEvent.h" | 47 #include "core/events/MouseEvent.h" |
47 #include "core/events/PointerEvent.h" | 48 #include "core/events/PointerEvent.h" |
48 #include "core/events/TextEvent.h" | 49 #include "core/events/TextEvent.h" |
49 #include "core/events/TouchEvent.h" | 50 #include "core/events/TouchEvent.h" |
50 #include "core/events/WheelEvent.h" | 51 #include "core/events/WheelEvent.h" |
51 #include "core/fetch/ImageResource.h" | 52 #include "core/fetch/ImageResource.h" |
52 #include "core/frame/EventHandlerRegistry.h" | 53 #include "core/frame/EventHandlerRegistry.h" |
53 #include "core/frame/FrameHost.h" | 54 #include "core/frame/FrameHost.h" |
54 #include "core/frame/FrameView.h" | 55 #include "core/frame/FrameView.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 #include "platform/scroll/Scrollbar.h" | 97 #include "platform/scroll/Scrollbar.h" |
97 #include "wtf/Assertions.h" | 98 #include "wtf/Assertions.h" |
98 #include "wtf/CurrentTime.h" | 99 #include "wtf/CurrentTime.h" |
99 #include "wtf/StdLibExtras.h" | 100 #include "wtf/StdLibExtras.h" |
100 #include "wtf/TemporaryChange.h" | 101 #include "wtf/TemporaryChange.h" |
101 | 102 |
102 namespace blink { | 103 namespace blink { |
103 | 104 |
104 namespace { | 105 namespace { |
105 | 106 |
107 WebInputEventResult mergeEventResult(WebInputEventResult responseA, WebInputEven tResult responseB) | |
108 { | |
109 // The ordering of the enumeration is specific. There are times that | |
110 // multiple events fire and we need to combine them into a single | |
111 // result code. The enumeration is based on the level of consumption that | |
112 // is most significant. The enumeration is ordered with smaller specified | |
113 // numbers first. Examples of merged results are: | |
114 // (HandledApplication, HandledSystem) -> HandledSystem | |
115 // (NotHandled, HandledApplication) -> HandledApplication | |
116 static_assert(static_cast<int>(WebInputEventResult::NotHandled) == 0, "WebIn putEventResult not ordered"); | |
117 static_assert(static_cast<int>(WebInputEventResult::HandledSuppressed) < sta tic_cast<int>(WebInputEventResult::HandledApplication), "WebInputEventResult not ordered"); | |
118 static_assert(static_cast<int>(WebInputEventResult::HandledApplication) < st atic_cast<int>(WebInputEventResult::HandledSystem), "WebInputEventResult not ord ered"); | |
119 return static_cast<WebInputEventResult>(max(static_cast<int>(responseA), sta tic_cast<int>(responseB))); | |
120 } | |
121 | |
122 WebInputEventResult eventToEventResult(PassRefPtrWillBeRawPtr<Event> event, bool res) | |
123 { | |
124 if (event->defaultPrevented()) | |
125 return WebInputEventResult::HandledApplication; | |
126 if (event->defaultHandled()) | |
127 return WebInputEventResult::HandledSystem; | |
128 | |
129 // TODO(dtapuska): There are cases in the code where dispatchEvent | |
130 // returns false (indicated handled) but event is not marked | |
131 // as default handled or default prevented. crbug.com/560355 | |
132 if (!res) | |
133 return WebInputEventResult::HandledSuppressed; | |
134 return WebInputEventResult::NotHandled; | |
135 } | |
136 | |
106 bool isNodeInDocument(Node* n) | 137 bool isNodeInDocument(Node* n) |
107 { | 138 { |
108 return n && n->inDocument(); | 139 return n && n->inDocument(); |
109 } | 140 } |
110 | 141 |
111 const AtomicString& touchEventNameForTouchPointState(PlatformTouchPoint::State s tate) | 142 const AtomicString& touchEventNameForTouchPointState(PlatformTouchPoint::State s tate) |
112 { | 143 { |
113 switch (state) { | 144 switch (state) { |
114 case PlatformTouchPoint::TouchReleased: | 145 case PlatformTouchPoint::TouchReleased: |
115 return EventTypeNames::touchend; | 146 return EventTypeNames::touchend; |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 | 424 |
394 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved) | 425 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved) |
395 { | 426 { |
396 if (nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get())) { | 427 if (nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get())) { |
397 // We don't dispatch click events if the mousedown node is removed | 428 // We don't dispatch click events if the mousedown node is removed |
398 // before a mouseup event. It is compatible with IE and Firefox. | 429 // before a mouseup event. It is compatible with IE and Firefox. |
399 m_clickNode = nullptr; | 430 m_clickNode = nullptr; |
400 } | 431 } |
401 } | 432 } |
402 | 433 |
403 bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve nt) | 434 WebInputEventResult EventHandler::handleMousePressEvent(const MouseEventWithHitT estResults& event) |
404 { | 435 { |
405 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); | 436 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); |
406 | 437 |
407 // Reset drag state. | 438 // Reset drag state. |
408 dragState().m_dragSrc = nullptr; | 439 dragState().m_dragSrc = nullptr; |
409 | 440 |
410 cancelFakeMouseMoveEvent(); | 441 cancelFakeMouseMoveEvent(); |
411 | 442 |
412 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 443 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
413 | 444 |
414 if (FrameView* frameView = m_frame->view()) { | 445 if (FrameView* frameView = m_frame->view()) { |
415 if (frameView->isPointInScrollbarCorner(event.event().position())) | 446 if (frameView->isPointInScrollbarCorner(event.event().position())) |
416 return false; | 447 return WebInputEventResult::NotHandled; |
417 } | 448 } |
418 | 449 |
419 bool singleClick = event.event().clickCount() <= 1; | 450 bool singleClick = event.event().clickCount() <= 1; |
420 | 451 |
421 m_mouseDownMayStartDrag = singleClick; | 452 m_mouseDownMayStartDrag = singleClick; |
422 | 453 |
423 selectionController().handleMousePressEvent(event); | 454 selectionController().handleMousePressEvent(event); |
424 | 455 |
425 m_mouseDown = event.event(); | 456 m_mouseDown = event.event(); |
426 | 457 |
427 if (m_frame->document()->isSVGDocument() && m_frame->document()->accessSVGEx tensions().zoomAndPanEnabled()) { | 458 if (m_frame->document()->isSVGDocument() && m_frame->document()->accessSVGEx tensions().zoomAndPanEnabled()) { |
428 if (event.event().shiftKey() && singleClick) { | 459 if (event.event().shiftKey() && singleClick) { |
429 m_svgPan = true; | 460 m_svgPan = true; |
430 m_frame->document()->accessSVGExtensions().startPan(m_frame->view()- >rootFrameToContents(event.event().position())); | 461 m_frame->document()->accessSVGExtensions().startPan(m_frame->view()- >rootFrameToContents(event.event().position())); |
431 return true; | 462 return WebInputEventResult::HandledSystem; |
432 } | 463 } |
433 } | 464 } |
434 | 465 |
435 // We don't do this at the start of mouse down handling, | 466 // We don't do this at the start of mouse down handling, |
436 // because we don't want to do it until we know we didn't hit a widget. | 467 // because we don't want to do it until we know we didn't hit a widget. |
437 if (singleClick) | 468 if (singleClick) |
438 focusDocumentView(); | 469 focusDocumentView(); |
439 | 470 |
440 Node* innerNode = event.innerNode(); | 471 Node* innerNode = event.innerNode(); |
441 | 472 |
442 m_mousePressNode = innerNode; | 473 m_mousePressNode = innerNode; |
443 m_dragStartPos = event.event().position(); | 474 m_dragStartPos = event.event().position(); |
444 | 475 |
445 bool swallowEvent = false; | 476 bool swallowEvent = false; |
446 m_mousePressed = true; | 477 m_mousePressed = true; |
447 | 478 |
448 if (event.event().clickCount() == 2) | 479 if (event.event().clickCount() == 2) |
449 swallowEvent = selectionController().handleMousePressEventDoubleClick(ev ent); | 480 swallowEvent = selectionController().handleMousePressEventDoubleClick(ev ent); |
450 else if (event.event().clickCount() >= 3) | 481 else if (event.event().clickCount() >= 3) |
451 swallowEvent = selectionController().handleMousePressEventTripleClick(ev ent); | 482 swallowEvent = selectionController().handleMousePressEventTripleClick(ev ent); |
452 else | 483 else |
453 swallowEvent = selectionController().handleMousePressEventSingleClick(ev ent); | 484 swallowEvent = selectionController().handleMousePressEventSingleClick(ev ent); |
454 | 485 |
455 m_mouseDownMayStartAutoscroll = selectionController().mouseDownMayStartSelec t() | 486 m_mouseDownMayStartAutoscroll = selectionController().mouseDownMayStartSelec t() |
456 || (m_mousePressNode && m_mousePressNode->layoutBox() && m_mousePressNod e->layoutBox()->canBeProgramaticallyScrolled()); | 487 || (m_mousePressNode && m_mousePressNode->layoutBox() && m_mousePressNod e->layoutBox()->canBeProgramaticallyScrolled()); |
457 | 488 |
458 return swallowEvent; | 489 return swallowEvent ? WebInputEventResult::HandledSystem : WebInputEventResu lt::NotHandled; |
459 } | 490 } |
460 | 491 |
461 bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e vent) | 492 WebInputEventResult EventHandler::handleMouseDraggedEvent(const MouseEventWithHi tTestResults& event) |
462 { | 493 { |
463 TRACE_EVENT0("blink", "EventHandler::handleMouseDraggedEvent"); | 494 TRACE_EVENT0("blink", "EventHandler::handleMouseDraggedEvent"); |
464 | 495 |
465 // While resetting m_mousePressed here may seem out of place, it turns out | 496 // While resetting m_mousePressed here may seem out of place, it turns out |
466 // to be needed to handle some bugs^Wfeatures in Blink mouse event handling: | 497 // to be needed to handle some bugs^Wfeatures in Blink mouse event handling: |
467 // 1. Certain elements, such as <embed>, capture mouse events. They do not | 498 // 1. Certain elements, such as <embed>, capture mouse events. They do not |
468 // bubble back up. One way for a <embed> to start capturing mouse events | 499 // bubble back up. One way for a <embed> to start capturing mouse events |
469 // is on a mouse press. The problem is the <embed> node only starts | 500 // is on a mouse press. The problem is the <embed> node only starts |
470 // capturing mouse events *after* m_mousePressed for the containing frame | 501 // capturing mouse events *after* m_mousePressed for the containing frame |
471 // has already been set to true. As a result, the frame's EventHandler | 502 // has already been set to true. As a result, the frame's EventHandler |
472 // never sees the mouse release event, which is supposed to reset | 503 // never sees the mouse release event, which is supposed to reset |
473 // m_mousePressed... so m_mousePressed ends up remaining true until the | 504 // m_mousePressed... so m_mousePressed ends up remaining true until the |
474 // event handler finally gets another mouse released event. Oops. | 505 // event handler finally gets another mouse released event. Oops. |
475 // 2. Dragging doesn't start until after a mouse press event, but a drag | 506 // 2. Dragging doesn't start until after a mouse press event, but a drag |
476 // that ends as a result of a mouse release does not send a mouse release | 507 // that ends as a result of a mouse release does not send a mouse release |
477 // event. As a result, m_mousePressed also ends up remaining true until | 508 // event. As a result, m_mousePressed also ends up remaining true until |
478 // the next mouse release event seen by the EventHandler. | 509 // the next mouse release event seen by the EventHandler. |
479 if (event.event().button() != LeftButton) | 510 if (event.event().button() != LeftButton) |
480 m_mousePressed = false; | 511 m_mousePressed = false; |
481 | 512 |
482 if (!m_mousePressed) | 513 if (!m_mousePressed) |
483 return false; | 514 return WebInputEventResult::NotHandled; |
484 | 515 |
485 if (handleDrag(event, DragInitiator::Mouse)) | 516 if (handleDrag(event, DragInitiator::Mouse)) |
486 return true; | 517 return WebInputEventResult::HandledSystem; |
487 | 518 |
488 Node* targetNode = event.innerNode(); | 519 Node* targetNode = event.innerNode(); |
489 if (!targetNode) | 520 if (!targetNode) |
490 return false; | 521 return WebInputEventResult::NotHandled; |
491 | 522 |
492 LayoutObject* layoutObject = targetNode->layoutObject(); | 523 LayoutObject* layoutObject = targetNode->layoutObject(); |
493 if (!layoutObject) { | 524 if (!layoutObject) { |
494 Node* parent = ComposedTreeTraversal::parent(*targetNode); | 525 Node* parent = ComposedTreeTraversal::parent(*targetNode); |
495 if (!parent) | 526 if (!parent) |
496 return false; | 527 return WebInputEventResult::NotHandled; |
497 | 528 |
498 layoutObject = parent->layoutObject(); | 529 layoutObject = parent->layoutObject(); |
499 if (!layoutObject || !layoutObject->isListBox()) | 530 if (!layoutObject || !layoutObject->isListBox()) |
500 return false; | 531 return WebInputEventResult::NotHandled; |
501 } | 532 } |
502 | 533 |
503 m_mouseDownMayStartDrag = false; | 534 m_mouseDownMayStartDrag = false; |
504 | 535 |
505 if (m_mouseDownMayStartAutoscroll && !panScrollInProgress()) { | 536 if (m_mouseDownMayStartAutoscroll && !panScrollInProgress()) { |
506 if (AutoscrollController* controller = autoscrollController()) { | 537 if (AutoscrollController* controller = autoscrollController()) { |
507 controller->startAutoscrollForSelection(layoutObject); | 538 controller->startAutoscrollForSelection(layoutObject); |
508 m_mouseDownMayStartAutoscroll = false; | 539 m_mouseDownMayStartAutoscroll = false; |
509 } | 540 } |
510 } | 541 } |
511 | 542 |
512 selectionController().handleMouseDraggedEvent(event, m_mouseDownPos, m_dragS tartPos, m_mousePressNode.get(), m_lastKnownMousePosition); | 543 selectionController().handleMouseDraggedEvent(event, m_mouseDownPos, m_dragS tartPos, m_mousePressNode.get(), m_lastKnownMousePosition); |
513 return true; | 544 return WebInputEventResult::HandledSystem; |
514 } | 545 } |
515 | 546 |
516 void EventHandler::updateSelectionForMouseDrag() | 547 void EventHandler::updateSelectionForMouseDrag() |
517 { | 548 { |
518 selectionController().updateSelectionForMouseDrag(m_mousePressNode.get(), m_ dragStartPos, m_lastKnownMousePosition); | 549 selectionController().updateSelectionForMouseDrag(m_mousePressNode.get(), m_ dragStartPos, m_lastKnownMousePosition); |
519 } | 550 } |
520 | 551 |
521 bool EventHandler::handleMouseReleaseEvent(const MouseEventWithHitTestResults& e vent) | 552 WebInputEventResult EventHandler::handleMouseReleaseEvent(const MouseEventWithHi tTestResults& event) |
522 { | 553 { |
523 AutoscrollController* controller = autoscrollController(); | 554 AutoscrollController* controller = autoscrollController(); |
524 if (controller && controller->autoscrollInProgress()) | 555 if (controller && controller->autoscrollInProgress()) |
525 stopAutoscroll(); | 556 stopAutoscroll(); |
526 | 557 |
527 // Used to prevent mouseMoveEvent from initiating a drag before | 558 // Used to prevent mouseMoveEvent from initiating a drag before |
528 // the mouse is pressed again. | 559 // the mouse is pressed again. |
529 m_mousePressed = false; | 560 m_mousePressed = false; |
530 m_capturesDragging = false; | 561 m_capturesDragging = false; |
531 m_mouseDownMayStartDrag = false; | 562 m_mouseDownMayStartDrag = false; |
532 m_mouseDownMayStartAutoscroll = false; | 563 m_mouseDownMayStartAutoscroll = false; |
533 | 564 |
534 return selectionController().handleMouseReleaseEvent(event, m_dragStartPos); | 565 return selectionController().handleMouseReleaseEvent(event, m_dragStartPos) ? WebInputEventResult::HandledSystem : WebInputEventResult::NotHandled; |
535 } | 566 } |
536 | 567 |
537 #if OS(WIN) | 568 #if OS(WIN) |
538 | 569 |
539 void EventHandler::startPanScrolling(LayoutObject* layoutObject) | 570 void EventHandler::startPanScrolling(LayoutObject* layoutObject) |
540 { | 571 { |
541 if (!layoutObject->isBox()) | 572 if (!layoutObject->isBox()) |
542 return; | 573 return; |
543 AutoscrollController* controller = autoscrollController(); | 574 AutoscrollController* controller = autoscrollController(); |
544 if (!controller) | 575 if (!controller) |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
941 } | 972 } |
942 | 973 |
943 static LayoutPoint contentPointFromRootFrame(LocalFrame* frame, const IntPoint& pointInRootFrame) | 974 static LayoutPoint contentPointFromRootFrame(LocalFrame* frame, const IntPoint& pointInRootFrame) |
944 { | 975 { |
945 FrameView* view = frame->view(); | 976 FrameView* view = frame->view(); |
946 // FIXME: Is it really OK to use the wrong coordinates here when view is 0? | 977 // FIXME: Is it really OK to use the wrong coordinates here when view is 0? |
947 // Historically the code would just crash; this is clearly no worse than tha t. | 978 // Historically the code would just crash; this is clearly no worse than tha t. |
948 return view ? view->rootFrameToContents(pointInRootFrame) : pointInRootFrame ; | 979 return view ? view->rootFrameToContents(pointInRootFrame) : pointInRootFrame ; |
949 } | 980 } |
950 | 981 |
951 bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) | 982 WebInputEventResult EventHandler::handleMousePressEvent(const PlatformMouseEvent & mouseEvent) |
952 { | 983 { |
953 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); | 984 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); |
954 | 985 |
955 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 986 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
956 | 987 |
957 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | 988 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); |
958 m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToken = gestureIndicator.currentToken(); | 989 m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToken = gestureIndicator.currentToken(); |
959 | 990 |
960 cancelFakeMouseMoveEvent(); | 991 cancelFakeMouseMoveEvent(); |
961 if (m_eventHandlerWillResetCapturingMouseEventsNode) | 992 if (m_eventHandlerWillResetCapturingMouseEventsNode) |
962 m_capturingMouseEventsNode = nullptr; | 993 m_capturingMouseEventsNode = nullptr; |
963 m_mousePressed = true; | 994 m_mousePressed = true; |
964 m_capturesDragging = true; | 995 m_capturesDragging = true; |
965 setLastKnownMousePosition(mouseEvent); | 996 setLastKnownMousePosition(mouseEvent); |
966 m_mouseDownTimestamp = mouseEvent.timestamp(); | 997 m_mouseDownTimestamp = mouseEvent.timestamp(); |
967 m_mouseDownMayStartDrag = false; | 998 m_mouseDownMayStartDrag = false; |
968 selectionController().setMouseDownMayStartSelect(false); | 999 selectionController().setMouseDownMayStartSelect(false); |
969 m_mouseDownMayStartAutoscroll = false; | 1000 m_mouseDownMayStartAutoscroll = false; |
970 if (FrameView* view = m_frame->view()) { | 1001 if (FrameView* view = m_frame->view()) { |
971 m_mouseDownPos = view->rootFrameToContents(mouseEvent.position()); | 1002 m_mouseDownPos = view->rootFrameToContents(mouseEvent.position()); |
972 } else { | 1003 } else { |
973 invalidateClick(); | 1004 invalidateClick(); |
974 return false; | 1005 return WebInputEventResult::NotHandled; |
975 } | 1006 } |
976 | 1007 |
977 HitTestRequest request(HitTestRequest::Active); | 1008 HitTestRequest request(HitTestRequest::Active); |
978 // Save the document point we generate in case the window coordinate is inva lidated by what happens | 1009 // Save the document point we generate in case the window coordinate is inva lidated by what happens |
979 // when we dispatch the event. | 1010 // when we dispatch the event. |
980 LayoutPoint documentPoint = contentPointFromRootFrame(m_frame, mouseEvent.po sition()); | 1011 LayoutPoint documentPoint = contentPointFromRootFrame(m_frame, mouseEvent.po sition()); |
981 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re quest, documentPoint, mouseEvent); | 1012 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re quest, documentPoint, mouseEvent); |
982 | 1013 |
983 if (!mev.innerNode()) { | 1014 if (!mev.innerNode()) { |
984 invalidateClick(); | 1015 invalidateClick(); |
985 return false; | 1016 return WebInputEventResult::NotHandled; |
986 } | 1017 } |
987 | 1018 |
988 m_mousePressNode = mev.innerNode(); | 1019 m_mousePressNode = mev.innerNode(); |
989 | 1020 |
990 RefPtrWillBeRawPtr<LocalFrame> subframe = subframeForHitTestResult(mev); | 1021 RefPtrWillBeRawPtr<LocalFrame> subframe = subframeForHitTestResult(mev); |
991 if (subframe && passMousePressEventToSubframe(mev, subframe.get())) { | 1022 if (subframe) { |
1023 WebInputEventResult result = passMousePressEventToSubframe(mev, subframe .get()); | |
992 // Start capturing future events for this frame. We only do this if we didn't clear | 1024 // Start capturing future events for this frame. We only do this if we didn't clear |
993 // the m_mousePressed flag, which may happen if an AppKit widget entered a modal event loop. | 1025 // the m_mousePressed flag, which may happen if an AppKit widget entered a modal event loop. |
1026 // The capturing should be done only when the result indicates it | |
1027 // has been handled. See crbug.com/269917 | |
994 m_capturesDragging = subframe->eventHandler().capturesDragging(); | 1028 m_capturesDragging = subframe->eventHandler().capturesDragging(); |
995 if (m_mousePressed && m_capturesDragging) { | 1029 if (m_mousePressed && m_capturesDragging) { |
996 m_capturingMouseEventsNode = mev.innerNode(); | 1030 m_capturingMouseEventsNode = mev.innerNode(); |
997 m_eventHandlerWillResetCapturingMouseEventsNode = true; | 1031 m_eventHandlerWillResetCapturingMouseEventsNode = true; |
998 } | 1032 } |
999 invalidateClick(); | 1033 invalidateClick(); |
1000 return true; | 1034 return result; |
1001 } | 1035 } |
1002 | 1036 |
1003 #if OS(WIN) | 1037 #if OS(WIN) |
1004 // We store whether pan scrolling is in progress before calling stopAutoscro ll() | 1038 // We store whether pan scrolling is in progress before calling stopAutoscro ll() |
1005 // because it will set m_autoscrollType to NoAutoscroll on return. | 1039 // because it will set m_autoscrollType to NoAutoscroll on return. |
1006 bool isPanScrollInProgress = panScrollInProgress(); | 1040 bool isPanScrollInProgress = panScrollInProgress(); |
1007 stopAutoscroll(); | 1041 stopAutoscroll(); |
1008 if (isPanScrollInProgress) { | 1042 if (isPanScrollInProgress) { |
1009 // We invalidate the click when exiting pan scrolling so that we don't i nadvertently navigate | 1043 // We invalidate the click when exiting pan scrolling so that we don't i nadvertently navigate |
1010 // away from the current page (e.g. the click was on a hyperlink). See < rdar://problem/6095023>. | 1044 // away from the current page (e.g. the click was on a hyperlink). See < rdar://problem/6095023>. |
1011 invalidateClick(); | 1045 invalidateClick(); |
1012 return true; | 1046 return WebInputEventResult::HandledSuppressed; |
1013 } | 1047 } |
1014 #endif | 1048 #endif |
1015 | 1049 |
1016 m_clickCount = mouseEvent.clickCount(); | 1050 m_clickCount = mouseEvent.clickCount(); |
1017 m_clickNode = mev.innerNode()->isTextNode() ? ComposedTreeTraversal::parent (*mev.innerNode()) : mev.innerNode(); | 1051 m_clickNode = mev.innerNode()->isTextNode() ? ComposedTreeTraversal::parent (*mev.innerNode()) : mev.innerNode(); |
1018 | 1052 |
1019 if (FrameView* view = m_frame->view()) { | 1053 if (FrameView* view = m_frame->view()) { |
1020 PaintLayer* layer = mev.innerNode()->layoutObject() ? mev.innerNode()->l ayoutObject()->enclosingLayer() : nullptr; | 1054 PaintLayer* layer = mev.innerNode()->layoutObject() ? mev.innerNode()->l ayoutObject()->enclosingLayer() : nullptr; |
1021 IntPoint p = view->rootFrameToContents(mouseEvent.position()); | 1055 IntPoint p = view->rootFrameToContents(mouseEvent.position()); |
1022 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint InResizeControl(p, ResizerForPointer)) { | 1056 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint InResizeControl(p, ResizerForPointer)) { |
1023 m_resizeScrollableArea = layer->scrollableArea(); | 1057 m_resizeScrollableArea = layer->scrollableArea(); |
1024 m_resizeScrollableArea->setInResizeMode(true); | 1058 m_resizeScrollableArea->setInResizeMode(true); |
1025 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p)); | 1059 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p)); |
1026 invalidateClick(); | 1060 invalidateClick(); |
1027 return true; | 1061 return WebInputEventResult::HandledSuppressed; |
1028 } | 1062 } |
1029 } | 1063 } |
1030 | 1064 |
1031 m_frame->selection().setCaretBlinkingSuspended(true); | 1065 m_frame->selection().setCaretBlinkingSuspended(true); |
1032 | 1066 |
1033 bool swallowEvent = updatePointerTargetAndDispatchEvents(EventTypeNames::mou sedown, mev.innerNode(), m_clickCount, mouseEvent); | 1067 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mousedown, mev.innerNode(), m_clickCount, mouseEvent); |
1034 | 1068 |
1035 // m_selectionInitiationState is initialized after dispatching mousedown | 1069 // m_selectionInitiationState is initialized after dispatching mousedown |
1036 // event in order not to keep the selection by DOM APIs Because we can't | 1070 // event in order not to keep the selection by DOM APIs Because we can't |
1037 // give the user the chance to handle the selection by user action like | 1071 // give the user the chance to handle the selection by user action like |
1038 // dragging if we keep the selection in case of mousedown. FireFox also has | 1072 // dragging if we keep the selection in case of mousedown. FireFox also has |
1039 // the same behavior and it's more compatible with other browsers. | 1073 // the same behavior and it's more compatible with other browsers. |
1040 selectionController().initializeSelectionState(); | 1074 selectionController().initializeSelectionState(); |
1041 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H itTestRequest::ReadOnly); | 1075 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H itTestRequest::ReadOnly); |
1042 InputDeviceCapabilities* sourceCapabilities = mouseEvent.syntheticEventType( ) == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEventsSo urceCapabilities() : | 1076 InputDeviceCapabilities* sourceCapabilities = mouseEvent.syntheticEventType( ) == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEventsSo urceCapabilities() : |
1043 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); | 1077 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); |
1044 swallowEvent = swallowEvent || handleMouseFocus(MouseEventWithHitTestResults (mouseEvent, hitTestResult), sourceCapabilities); | 1078 if (eventResult == WebInputEventResult::NotHandled) |
1045 m_capturesDragging = !swallowEvent || mev.scrollbar(); | 1079 eventResult = handleMouseFocus(MouseEventWithHitTestResults(mouseEvent, hitTestResult), sourceCapabilities); |
1080 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s crollbar(); | |
1046 | 1081 |
1047 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults | 1082 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults |
1048 // in case the scrollbar widget was destroyed when the mouse event was handl ed. | 1083 // in case the scrollbar widget was destroyed when the mouse event was handl ed. |
1049 if (mev.scrollbar()) { | 1084 if (mev.scrollbar()) { |
1050 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); | 1085 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); |
1051 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); | 1086 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); |
1052 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent); | 1087 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent); |
1053 if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get ()) | 1088 if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get ()) |
1054 m_lastScrollbarUnderMouse = nullptr; | 1089 m_lastScrollbarUnderMouse = nullptr; |
1055 } | 1090 } |
1056 | 1091 |
1057 if (swallowEvent) { | 1092 if (eventResult != WebInputEventResult::NotHandled) { |
1058 // scrollbars should get events anyway, even disabled controls might be scrollable | 1093 // scrollbars should get events anyway, even disabled controls might be scrollable |
1059 passMousePressEventToScrollbar(mev); | 1094 passMousePressEventToScrollbar(mev); |
1060 } else { | 1095 } else { |
1061 if (shouldRefetchEventTarget(mev)) { | 1096 if (shouldRefetchEventTarget(mev)) { |
1062 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Ac tive); | 1097 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Ac tive); |
1063 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent); | 1098 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent); |
1064 } | 1099 } |
1065 | 1100 |
1066 if (passMousePressEventToScrollbar(mev)) | 1101 if (passMousePressEventToScrollbar(mev)) |
1067 swallowEvent = true; | 1102 eventResult = WebInputEventResult::HandledSystem; |
1068 else | 1103 else |
1069 swallowEvent = handleMousePressEvent(mev); | 1104 eventResult = handleMousePressEvent(mev); |
1070 } | 1105 } |
1071 | 1106 |
1072 if (mev.hitTestResult().innerNode() && mouseEvent.button() == LeftButton) { | 1107 if (mev.hitTestResult().innerNode() && mouseEvent.button() == LeftButton) { |
1073 ASSERT(mouseEvent.type() == PlatformEvent::MousePressed); | 1108 ASSERT(mouseEvent.type() == PlatformEvent::MousePressed); |
1074 HitTestResult result = mev.hitTestResult(); | 1109 HitTestResult result = mev.hitTestResult(); |
1075 result.setToShadowHostIfInUserAgentShadowRoot(); | 1110 result.setToShadowHostIfInUserAgentShadowRoot(); |
1076 m_frame->chromeClient().onMouseDown(result.innerNode()); | 1111 m_frame->chromeClient().onMouseDown(result.innerNode()); |
1077 } | 1112 } |
1078 | 1113 |
1079 return swallowEvent; | 1114 return eventResult; |
1080 } | 1115 } |
1081 | 1116 |
1082 static PaintLayer* layerForNode(Node* node) | 1117 static PaintLayer* layerForNode(Node* node) |
1083 { | 1118 { |
1084 if (!node) | 1119 if (!node) |
1085 return nullptr; | 1120 return nullptr; |
1086 | 1121 |
1087 LayoutObject* layoutObject = node->layoutObject(); | 1122 LayoutObject* layoutObject = node->layoutObject(); |
1088 if (!layoutObject) | 1123 if (!layoutObject) |
1089 return nullptr; | 1124 return nullptr; |
1090 | 1125 |
1091 PaintLayer* layer = layoutObject->enclosingLayer(); | 1126 PaintLayer* layer = layoutObject->enclosingLayer(); |
1092 if (!layer) | 1127 if (!layer) |
1093 return nullptr; | 1128 return nullptr; |
1094 | 1129 |
1095 return layer; | 1130 return layer; |
1096 } | 1131 } |
1097 | 1132 |
1098 ScrollableArea* EventHandler::associatedScrollableArea(const PaintLayer* layer) const | 1133 ScrollableArea* EventHandler::associatedScrollableArea(const PaintLayer* layer) const |
1099 { | 1134 { |
1100 if (PaintLayerScrollableArea* scrollableArea = layer->scrollableArea()) { | 1135 if (PaintLayerScrollableArea* scrollableArea = layer->scrollableArea()) { |
1101 if (scrollableArea->scrollsOverflow()) | 1136 if (scrollableArea->scrollsOverflow()) |
1102 return scrollableArea; | 1137 return scrollableArea; |
1103 } | 1138 } |
1104 | 1139 |
1105 return nullptr; | 1140 return nullptr; |
1106 } | 1141 } |
1107 | 1142 |
1108 bool EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& event) | 1143 WebInputEventResult EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& event) |
1109 { | 1144 { |
1110 TRACE_EVENT0("blink", "EventHandler::handleMouseMoveEvent"); | 1145 TRACE_EVENT0("blink", "EventHandler::handleMouseMoveEvent"); |
1111 | 1146 |
1112 conditionallyEnableMouseEventForPointerTypeMouse(event); | 1147 conditionallyEnableMouseEventForPointerTypeMouse(event); |
1113 | 1148 |
1114 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 1149 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
1115 | 1150 |
1116 HitTestResult hoveredNode = HitTestResult(); | 1151 HitTestResult hoveredNode = HitTestResult(); |
1117 bool result = handleMouseMoveOrLeaveEvent(event, &hoveredNode); | 1152 WebInputEventResult result = handleMouseMoveOrLeaveEvent(event, &hoveredNode ); |
1118 | 1153 |
1119 Page* page = m_frame->page(); | 1154 Page* page = m_frame->page(); |
1120 if (!page) | 1155 if (!page) |
1121 return result; | 1156 return result; |
1122 | 1157 |
1123 if (PaintLayer* layer = layerForNode(hoveredNode.innerNode())) { | 1158 if (PaintLayer* layer = layerForNode(hoveredNode.innerNode())) { |
1124 if (ScrollableArea* layerScrollableArea = associatedScrollableArea(layer )) | 1159 if (ScrollableArea* layerScrollableArea = associatedScrollableArea(layer )) |
1125 layerScrollableArea->mouseMovedInContentArea(); | 1160 layerScrollableArea->mouseMovedInContentArea(); |
1126 } | 1161 } |
1127 | 1162 |
1128 if (FrameView* frameView = m_frame->view()) | 1163 if (FrameView* frameView = m_frame->view()) |
1129 frameView->mouseMovedInContentArea(); | 1164 frameView->mouseMovedInContentArea(); |
1130 | 1165 |
1131 hoveredNode.setToShadowHostIfInUserAgentShadowRoot(); | 1166 hoveredNode.setToShadowHostIfInUserAgentShadowRoot(); |
1132 page->chromeClient().mouseDidMoveOverElement(hoveredNode); | 1167 page->chromeClient().mouseDidMoveOverElement(hoveredNode); |
1133 | 1168 |
1134 return result; | 1169 return result; |
1135 } | 1170 } |
1136 | 1171 |
1137 void EventHandler::handleMouseLeaveEvent(const PlatformMouseEvent& event) | 1172 void EventHandler::handleMouseLeaveEvent(const PlatformMouseEvent& event) |
1138 { | 1173 { |
1139 TRACE_EVENT0("blink", "EventHandler::handleMouseLeaveEvent"); | 1174 TRACE_EVENT0("blink", "EventHandler::handleMouseLeaveEvent"); |
1140 | 1175 |
1141 conditionallyEnableMouseEventForPointerTypeMouse(event); | 1176 conditionallyEnableMouseEventForPointerTypeMouse(event); |
1142 | 1177 |
1143 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 1178 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
1144 handleMouseMoveOrLeaveEvent(event, 0, false, true); | 1179 handleMouseMoveOrLeaveEvent(event, 0, false, true); |
1145 } | 1180 } |
1146 | 1181 |
1147 bool EventHandler::handleMouseMoveOrLeaveEvent(const PlatformMouseEvent& mouseEv ent, HitTestResult* hoveredNode, bool onlyUpdateScrollbars, bool forceLeave) | 1182 WebInputEventResult EventHandler::handleMouseMoveOrLeaveEvent(const PlatformMous eEvent& mouseEvent, HitTestResult* hoveredNode, bool onlyUpdateScrollbars, bool forceLeave) |
1148 { | 1183 { |
1149 ASSERT(m_frame); | 1184 ASSERT(m_frame); |
1150 ASSERT(m_frame->view()); | 1185 ASSERT(m_frame->view()); |
1151 | 1186 |
1152 setLastKnownMousePosition(mouseEvent); | 1187 setLastKnownMousePosition(mouseEvent); |
1153 | 1188 |
1154 if (m_hoverTimer.isActive()) | 1189 if (m_hoverTimer.isActive()) |
1155 m_hoverTimer.stop(); | 1190 m_hoverTimer.stop(); |
1156 | 1191 |
1157 m_cursorUpdateTimer.stop(); | 1192 m_cursorUpdateTimer.stop(); |
1158 | 1193 |
1159 cancelFakeMouseMoveEvent(); | 1194 cancelFakeMouseMoveEvent(); |
1160 | 1195 |
1161 if (m_svgPan) { | 1196 if (m_svgPan) { |
1162 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->ro otFrameToContents(m_lastKnownMousePosition)); | 1197 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->ro otFrameToContents(m_lastKnownMousePosition)); |
1163 return true; | 1198 return WebInputEventResult::HandledSuppressed; |
1164 } | 1199 } |
1165 | 1200 |
1166 if (m_frameSetBeingResized) | 1201 if (m_frameSetBeingResized) |
1167 return updatePointerTargetAndDispatchEvents(EventTypeNames::mousemove, m _frameSetBeingResized.get(), 0, mouseEvent); | 1202 return updatePointerTargetAndDispatchEvents(EventTypeNames::mousemove, m _frameSetBeingResized.get(), 0, mouseEvent); |
1168 | 1203 |
1169 // Send events right to a scrollbar if the mouse is pressed. | 1204 // Send events right to a scrollbar if the mouse is pressed. |
1170 if (m_lastScrollbarUnderMouse && m_mousePressed) { | 1205 if (m_lastScrollbarUnderMouse && m_mousePressed) { |
1171 m_lastScrollbarUnderMouse->mouseMoved(mouseEvent); | 1206 m_lastScrollbarUnderMouse->mouseMoved(mouseEvent); |
1172 return true; | 1207 return WebInputEventResult::HandledSystem; |
1173 } | 1208 } |
1174 | 1209 |
1175 // Mouse events simulated from touch should not hit-test again. | 1210 // Mouse events simulated from touch should not hit-test again. |
1176 ASSERT(!mouseEvent.fromTouch()); | 1211 ASSERT(!mouseEvent.fromTouch()); |
1177 | 1212 |
1178 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Move; | 1213 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Move; |
1179 if (m_mousePressed) { | 1214 if (m_mousePressed) { |
1180 hitType |= HitTestRequest::Active; | 1215 hitType |= HitTestRequest::Active; |
1181 } else if (onlyUpdateScrollbars) { | 1216 } else if (onlyUpdateScrollbars) { |
1182 // Mouse events should be treated as "read-only" if we're updating only scrollbars. This | 1217 // Mouse events should be treated as "read-only" if we're updating only scrollbars. This |
(...skipping 22 matching lines...) Expand all Loading... | |
1205 Scrollbar* scrollbar = nullptr; | 1240 Scrollbar* scrollbar = nullptr; |
1206 | 1241 |
1207 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { | 1242 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { |
1208 m_resizeScrollableArea->resize(mouseEvent, m_offsetFromResizeCorner); | 1243 m_resizeScrollableArea->resize(mouseEvent, m_offsetFromResizeCorner); |
1209 } else { | 1244 } else { |
1210 if (!scrollbar) | 1245 if (!scrollbar) |
1211 scrollbar = mev.scrollbar(); | 1246 scrollbar = mev.scrollbar(); |
1212 | 1247 |
1213 updateLastScrollbarUnderMouse(scrollbar, !m_mousePressed); | 1248 updateLastScrollbarUnderMouse(scrollbar, !m_mousePressed); |
1214 if (onlyUpdateScrollbars) | 1249 if (onlyUpdateScrollbars) |
1215 return true; | 1250 return WebInputEventResult::HandledSuppressed; |
1216 } | 1251 } |
1217 | 1252 |
1218 bool swallowEvent = false; | 1253 WebInputEventResult eventResult = WebInputEventResult::NotHandled; |
1219 RefPtrWillBeRawPtr<LocalFrame> newSubframe = m_capturingMouseEventsNode.get( ) ? subframeForTargetNode(m_capturingMouseEventsNode.get()) : subframeForHitTest Result(mev); | 1254 RefPtrWillBeRawPtr<LocalFrame> newSubframe = m_capturingMouseEventsNode.get( ) ? subframeForTargetNode(m_capturingMouseEventsNode.get()) : subframeForHitTest Result(mev); |
1220 | 1255 |
1221 // We want mouseouts to happen first, from the inside out. First send a mov e event to the last subframe so that it will fire mouseouts. | 1256 // We want mouseouts to happen first, from the inside out. First send a mov e event to the last subframe so that it will fire mouseouts. |
1222 if (m_lastMouseMoveEventSubframe && m_lastMouseMoveEventSubframe->tree().isD escendantOf(m_frame) && m_lastMouseMoveEventSubframe != newSubframe) | 1257 if (m_lastMouseMoveEventSubframe && m_lastMouseMoveEventSubframe->tree().isD escendantOf(m_frame) && m_lastMouseMoveEventSubframe != newSubframe) |
1223 m_lastMouseMoveEventSubframe->eventHandler().handleMouseLeaveEvent(mouse Event); | 1258 m_lastMouseMoveEventSubframe->eventHandler().handleMouseLeaveEvent(mouse Event); |
1224 | 1259 |
1225 if (newSubframe) { | 1260 if (newSubframe) { |
1226 // Update over/out state before passing the event to the subframe. | 1261 // Update over/out state before passing the event to the subframe. |
1227 updateMouseEventTargetNode(mev.innerNode(), mouseEvent); | 1262 updateMouseEventTargetNode(mev.innerNode(), mouseEvent); |
1228 | 1263 |
1229 // Event dispatch in updateMouseEventTargetNode may have caused the subf rame of the target | 1264 // Event dispatch in updateMouseEventTargetNode may have caused the subf rame of the target |
1230 // node to be detached from its FrameView, in which case the event shoul d not be passed. | 1265 // node to be detached from its FrameView, in which case the event shoul d not be passed. |
1231 if (newSubframe->view()) | 1266 if (newSubframe->view()) |
1232 swallowEvent |= passMouseMoveEventToSubframe(mev, newSubframe.get(), hoveredNode); | 1267 eventResult = passMouseMoveEventToSubframe(mev, newSubframe.get(), h overedNode); |
1233 } else { | 1268 } else { |
1234 if (scrollbar && !m_mousePressed) | 1269 if (scrollbar && !m_mousePressed) |
1235 scrollbar->mouseMoved(mouseEvent); // Handle hover effects on platfo rms that support visual feedback on scrollbar hovering. | 1270 scrollbar->mouseMoved(mouseEvent); // Handle hover effects on platfo rms that support visual feedback on scrollbar hovering. |
1236 if (FrameView* view = m_frame->view()) { | 1271 if (FrameView* view = m_frame->view()) { |
1237 OptionalCursor optionalCursor = selectCursor(mev.hitTestResult()); | 1272 OptionalCursor optionalCursor = selectCursor(mev.hitTestResult()); |
1238 if (optionalCursor.isCursorChange()) { | 1273 if (optionalCursor.isCursorChange()) { |
1239 view->setCursor(optionalCursor.cursor()); | 1274 view->setCursor(optionalCursor.cursor()); |
1240 } | 1275 } |
1241 } | 1276 } |
1242 } | 1277 } |
1243 | 1278 |
1244 m_lastMouseMoveEventSubframe = newSubframe; | 1279 m_lastMouseMoveEventSubframe = newSubframe; |
1245 | 1280 |
1246 if (swallowEvent) | 1281 if (eventResult != WebInputEventResult::NotHandled) |
1247 return true; | 1282 return eventResult; |
1248 | 1283 |
1249 swallowEvent = updatePointerTargetAndDispatchEvents(EventTypeNames::mousemov e, mev.innerNode(), 0, mouseEvent); | 1284 eventResult = updatePointerTargetAndDispatchEvents(EventTypeNames::mousemove , mev.innerNode(), 0, mouseEvent); |
1285 if (eventResult != WebInputEventResult::NotHandled) | |
1286 return eventResult; | |
1250 | 1287 |
1251 if (!swallowEvent) | 1288 return handleMouseDraggedEvent(mev); |
1252 swallowEvent = handleMouseDraggedEvent(mev); | |
1253 | |
1254 return swallowEvent; | |
1255 } | 1289 } |
1256 | 1290 |
1257 void EventHandler::invalidateClick() | 1291 void EventHandler::invalidateClick() |
1258 { | 1292 { |
1259 m_clickCount = 0; | 1293 m_clickCount = 0; |
1260 m_clickNode = nullptr; | 1294 m_clickNode = nullptr; |
1261 } | 1295 } |
1262 | 1296 |
1263 static ContainerNode* parentForClickEvent(const Node& node) | 1297 static ContainerNode* parentForClickEvent(const Node& node) |
1264 { | 1298 { |
1265 // IE doesn't dispatch click events for mousedown/mouseup events across form | 1299 // IE doesn't dispatch click events for mousedown/mouseup events across form |
1266 // controls. | 1300 // controls. |
1267 if (node.isHTMLElement() && toHTMLElement(node).isInteractiveContent()) | 1301 if (node.isHTMLElement() && toHTMLElement(node).isInteractiveContent()) |
1268 return nullptr; | 1302 return nullptr; |
1269 | 1303 |
1270 return ComposedTreeTraversal::parent(node); | 1304 return ComposedTreeTraversal::parent(node); |
1271 } | 1305 } |
1272 | 1306 |
1273 bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent) | 1307 WebInputEventResult EventHandler::handleMouseReleaseEvent(const PlatformMouseEve nt& mouseEvent) |
1274 { | 1308 { |
1275 TRACE_EVENT0("blink", "EventHandler::handleMouseReleaseEvent"); | 1309 TRACE_EVENT0("blink", "EventHandler::handleMouseReleaseEvent"); |
1276 | 1310 |
1277 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 1311 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
1278 | 1312 |
1279 m_frame->selection().setCaretBlinkingSuspended(false); | 1313 m_frame->selection().setCaretBlinkingSuspended(false); |
1280 | 1314 |
1281 OwnPtr<UserGestureIndicator> gestureIndicator; | 1315 OwnPtr<UserGestureIndicator> gestureIndicator; |
1282 | 1316 |
1283 if (m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToke n) | 1317 if (m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToke n) |
1284 gestureIndicator = adoptPtr(new UserGestureIndicator(m_frame->localFrame Root()->eventHandler().m_lastMouseDownUserGestureToken.release())); | 1318 gestureIndicator = adoptPtr(new UserGestureIndicator(m_frame->localFrame Root()->eventHandler().m_lastMouseDownUserGestureToken.release())); |
1285 else | 1319 else |
1286 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessin gUserGesture)); | 1320 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessin gUserGesture)); |
1287 | 1321 |
1288 #if OS(WIN) | 1322 #if OS(WIN) |
1289 if (Page* page = m_frame->page()) | 1323 if (Page* page = m_frame->page()) |
1290 page->autoscrollController().handleMouseReleaseForPanScrolling(m_frame, mouseEvent); | 1324 page->autoscrollController().handleMouseReleaseForPanScrolling(m_frame, mouseEvent); |
1291 #endif | 1325 #endif |
1292 | 1326 |
1293 m_mousePressed = false; | 1327 m_mousePressed = false; |
1294 setLastKnownMousePosition(mouseEvent); | 1328 setLastKnownMousePosition(mouseEvent); |
1295 | 1329 |
1296 if (m_svgPan) { | 1330 if (m_svgPan) { |
1297 m_svgPan = false; | 1331 m_svgPan = false; |
1298 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->ro otFrameToContents(m_lastKnownMousePosition)); | 1332 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->ro otFrameToContents(m_lastKnownMousePosition)); |
1299 return true; | 1333 return WebInputEventResult::HandledSuppressed; |
1300 } | 1334 } |
1301 | 1335 |
1302 if (m_frameSetBeingResized) | 1336 if (m_frameSetBeingResized) |
1303 return dispatchMouseEvent(EventTypeNames::mouseup, m_frameSetBeingResize d.get(), m_clickCount, mouseEvent); | 1337 return dispatchMouseEvent(EventTypeNames::mouseup, m_frameSetBeingResize d.get(), m_clickCount, mouseEvent); |
1304 | 1338 |
1305 if (m_lastScrollbarUnderMouse) { | 1339 if (m_lastScrollbarUnderMouse) { |
1306 invalidateClick(); | 1340 invalidateClick(); |
1307 m_lastScrollbarUnderMouse->mouseUp(mouseEvent); | 1341 m_lastScrollbarUnderMouse->mouseUp(mouseEvent); |
1308 return dispatchMouseEvent(EventTypeNames::mouseup, m_nodeUnderMouse.get( ), m_clickCount, mouseEvent); | 1342 return dispatchMouseEvent(EventTypeNames::mouseup, m_nodeUnderMouse.get( ), m_clickCount, mouseEvent); |
1309 } | 1343 } |
1310 | 1344 |
1311 // Mouse events simulated from touch should not hit-test again. | 1345 // Mouse events simulated from touch should not hit-test again. |
1312 ASSERT(!mouseEvent.fromTouch()); | 1346 ASSERT(!mouseEvent.fromTouch()); |
1313 | 1347 |
1314 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Release; | 1348 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Release; |
1315 HitTestRequest request(hitType); | 1349 HitTestRequest request(hitType); |
1316 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); | 1350 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); |
1317 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); | 1351 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); |
1318 if (m_eventHandlerWillResetCapturingMouseEventsNode) | 1352 if (m_eventHandlerWillResetCapturingMouseEventsNode) |
1319 m_capturingMouseEventsNode = nullptr; | 1353 m_capturingMouseEventsNode = nullptr; |
1320 if (subframe && passMouseReleaseEventToSubframe(mev, subframe)) | 1354 if (subframe) |
1321 return true; | 1355 return passMouseReleaseEventToSubframe(mev, subframe); |
1322 | 1356 |
1323 bool swallowUpEvent = updatePointerTargetAndDispatchEvents(EventTypeNames::m ouseup, mev.innerNode(), m_clickCount, mouseEvent); | 1357 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mouseup, mev.innerNode(), m_clickCount, mouseEvent); |
1324 | 1358 |
1325 // TODO(crbug/545647): This state should reset with pointercancel too. | 1359 // TODO(crbug/545647): This state should reset with pointercancel too. |
1326 m_preventMouseEventForPointerTypeMouse = false; | 1360 m_preventMouseEventForPointerTypeMouse = false; |
1327 | 1361 |
1328 bool contextMenuEvent = mouseEvent.button() == RightButton; | 1362 bool contextMenuEvent = mouseEvent.button() == RightButton; |
1329 #if OS(MACOSX) | 1363 #if OS(MACOSX) |
1330 // FIXME: The Mac port achieves the same behavior by checking whether the co ntext menu is currently open in WebPage::mouseEvent(). Consider merging the impl ementations. | 1364 // FIXME: The Mac port achieves the same behavior by checking whether the co ntext menu is currently open in WebPage::mouseEvent(). Consider merging the impl ementations. |
1331 if (mouseEvent.button() == LeftButton && mouseEvent.modifiers() & PlatformEv ent::CtrlKey) | 1365 if (mouseEvent.button() == LeftButton && mouseEvent.modifiers() & PlatformEv ent::CtrlKey) |
1332 contextMenuEvent = true; | 1366 contextMenuEvent = true; |
1333 #endif | 1367 #endif |
1334 | 1368 |
1335 bool swallowClickEvent = false; | 1369 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; |
1336 if (m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode && mev.innerNode()->canParticipateInComposedTree() && m_clickNode->canParticipat eInComposedTree()) { | 1370 if (m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode && mev.innerNode()->canParticipateInComposedTree() && m_clickNode->canParticipat eInComposedTree()) { |
1337 // Updates distribution because a 'mouseup' event listener can make the | 1371 // Updates distribution because a 'mouseup' event listener can make the |
1338 // tree dirty at dispatchMouseEvent() invocation above. | 1372 // tree dirty at dispatchMouseEvent() invocation above. |
1339 // Unless distribution is updated, commonAncestor would hit ASSERT. | 1373 // Unless distribution is updated, commonAncestor would hit ASSERT. |
1340 // Both m_clickNode and mev.innerNode() don't need to be updated | 1374 // Both m_clickNode and mev.innerNode() don't need to be updated |
1341 // because commonAncestor() will exit early if their documents are diffe rent. | 1375 // because commonAncestor() will exit early if their documents are diffe rent. |
1342 m_clickNode->updateDistribution(); | 1376 m_clickNode->updateDistribution(); |
1343 if (Node* clickTargetNode = mev.innerNode()->commonAncestor( | 1377 if (Node* clickTargetNode = mev.innerNode()->commonAncestor( |
1344 *m_clickNode, parentForClickEvent)) { | 1378 *m_clickNode, parentForClickEvent)) { |
1345 | 1379 |
1346 // Dispatch mouseup directly w/o calling updateMouseEventTargetNode | 1380 // Dispatch mouseup directly w/o calling updateMouseEventTargetNode |
1347 // because the mouseup dispatch above has already updated it | 1381 // because the mouseup dispatch above has already updated it |
1348 // correctly. Moreover, clickTargetNode is different from | 1382 // correctly. Moreover, clickTargetNode is different from |
1349 // mev.innerNode at drag-release. | 1383 // mev.innerNode at drag-release. |
1350 clickTargetNode->dispatchMouseEvent(mouseEvent, | 1384 if (clickTargetNode->dispatchMouseEvent(mouseEvent, |
kotenkov
2016/01/12 20:55:00
There should be a negation here: |EventTarget::dis
dtapuska
2016/01/12 21:06:48
Thanks for the find; you are correct. This is in f
| |
1351 EventTypeNames::click, m_clickCount); | 1385 EventTypeNames::click, m_clickCount)) { |
1386 clickEventResult = WebInputEventResult::HandledApplication; | |
1387 } | |
1352 } | 1388 } |
1353 } | 1389 } |
1354 | 1390 |
1355 if (m_resizeScrollableArea) { | 1391 if (m_resizeScrollableArea) { |
1356 m_resizeScrollableArea->setInResizeMode(false); | 1392 m_resizeScrollableArea->setInResizeMode(false); |
1357 m_resizeScrollableArea = nullptr; | 1393 m_resizeScrollableArea = nullptr; |
1358 } | 1394 } |
1359 | 1395 |
1360 bool swallowMouseReleaseEvent = false; | 1396 if (eventResult == WebInputEventResult::NotHandled) |
1361 if (!swallowUpEvent) | 1397 eventResult = handleMouseReleaseEvent(mev); |
1362 swallowMouseReleaseEvent = handleMouseReleaseEvent(mev); | |
1363 | 1398 |
1364 invalidateClick(); | 1399 invalidateClick(); |
1365 | 1400 |
1366 return swallowUpEvent || swallowClickEvent || swallowMouseReleaseEvent; | 1401 return mergeEventResult(clickEventResult, eventResult); |
1367 } | 1402 } |
1368 | 1403 |
1369 bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Node* dragTa rget, const PlatformMouseEvent& event, DataTransfer* dataTransfer) | 1404 WebInputEventResult EventHandler::dispatchDragEvent(const AtomicString& eventTyp e, Node* dragTarget, const PlatformMouseEvent& event, DataTransfer* dataTransfer ) |
1370 { | 1405 { |
1371 FrameView* view = m_frame->view(); | 1406 FrameView* view = m_frame->view(); |
1372 | 1407 |
1373 // FIXME: We might want to dispatch a dragleave even if the view is gone. | 1408 // FIXME: We might want to dispatch a dragleave even if the view is gone. |
1374 if (!view) | 1409 if (!view) |
1375 return false; | 1410 return WebInputEventResult::NotHandled; |
1376 | 1411 |
1377 RefPtrWillBeRawPtr<DragEvent> me = DragEvent::create(eventType, | 1412 RefPtrWillBeRawPtr<DragEvent> me = DragEvent::create(eventType, |
1378 true, true, m_frame->document()->domWindow(), | 1413 true, true, m_frame->document()->domWindow(), |
1379 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(), | 1414 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(), |
1380 event.movementDelta().x(), event.movementDelta().y(), | 1415 event.movementDelta().x(), event.movementDelta().y(), |
1381 event.modifiers(), | 1416 event.modifiers(), |
1382 0, MouseEvent::platformModifiersToButtons(event.modifiers()), nullptr, e vent.timestamp(), dataTransfer, event.syntheticEventType()); | 1417 0, MouseEvent::platformModifiersToButtons(event.modifiers()), nullptr, e vent.timestamp(), dataTransfer, event.syntheticEventType()); |
1383 | 1418 |
1384 dragTarget->dispatchEvent(me.get()); | 1419 bool dispatchResult = dragTarget->dispatchEvent(me.get()); |
1385 return me->defaultPrevented(); | 1420 return eventToEventResult(me, dispatchResult); |
1386 } | 1421 } |
1387 | 1422 |
1388 static bool targetIsFrame(Node* target, LocalFrame*& frame) | 1423 static bool targetIsFrame(Node* target, LocalFrame*& frame) |
1389 { | 1424 { |
1390 if (!isHTMLFrameElementBase(target)) | 1425 if (!isHTMLFrameElementBase(target)) |
1391 return false; | 1426 return false; |
1392 | 1427 |
1393 // Cross-process drag and drop is not yet supported. | 1428 // Cross-process drag and drop is not yet supported. |
1394 if (toHTMLFrameElementBase(target)->contentFrame() && !toHTMLFrameElementBas e(target)->contentFrame()->isLocalFrame()) | 1429 if (toHTMLFrameElementBase(target)->contentFrame() && !toHTMLFrameElementBas e(target)->contentFrame()->isLocalFrame()) |
1395 return false; | 1430 return false; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1430 break; | 1465 break; |
1431 } | 1466 } |
1432 if (matched) { | 1467 if (matched) { |
1433 dataTransfer->setDropEffect(convertDragOperationToDropZoneOperation( dragOperation)); | 1468 dataTransfer->setDropEffect(convertDragOperationToDropZoneOperation( dragOperation)); |
1434 return true; | 1469 return true; |
1435 } | 1470 } |
1436 } | 1471 } |
1437 return false; | 1472 return false; |
1438 } | 1473 } |
1439 | 1474 |
1440 bool EventHandler::updateDragAndDrop(const PlatformMouseEvent& event, DataTransf er* dataTransfer) | 1475 WebInputEventResult EventHandler::updateDragAndDrop(const PlatformMouseEvent& ev ent, DataTransfer* dataTransfer) |
1441 { | 1476 { |
1442 bool accept = false; | 1477 WebInputEventResult eventResult = WebInputEventResult::NotHandled; |
1443 | 1478 |
1444 if (!m_frame->view()) | 1479 if (!m_frame->view()) |
1445 return false; | 1480 return eventResult; |
1446 | 1481 |
1447 HitTestRequest request(HitTestRequest::ReadOnly); | 1482 HitTestRequest request(HitTestRequest::ReadOnly); |
1448 MouseEventWithHitTestResults mev = prepareMouseEvent(request, event); | 1483 MouseEventWithHitTestResults mev = prepareMouseEvent(request, event); |
1449 | 1484 |
1450 // Drag events should never go to text nodes (following IE, and proper mouse over/out dispatch) | 1485 // Drag events should never go to text nodes (following IE, and proper mouse over/out dispatch) |
1451 RefPtrWillBeRawPtr<Node> newTarget = mev.innerNode(); | 1486 RefPtrWillBeRawPtr<Node> newTarget = mev.innerNode(); |
1452 if (newTarget && newTarget->isTextNode()) | 1487 if (newTarget && newTarget->isTextNode()) |
1453 newTarget = ComposedTreeTraversal::parent(*newTarget); | 1488 newTarget = ComposedTreeTraversal::parent(*newTarget); |
1454 | 1489 |
1455 if (AutoscrollController* controller = autoscrollController()) | 1490 if (AutoscrollController* controller = autoscrollController()) |
1456 controller->updateDragAndDrop(newTarget.get(), event.position(), event.t imestamp()); | 1491 controller->updateDragAndDrop(newTarget.get(), event.position(), event.t imestamp()); |
1457 | 1492 |
1458 if (m_dragTarget != newTarget) { | 1493 if (m_dragTarget != newTarget) { |
1459 // FIXME: this ordering was explicitly chosen to match WinIE. However, | 1494 // FIXME: this ordering was explicitly chosen to match WinIE. However, |
1460 // it is sometimes incorrect when dragging within subframes, as seen wit h | 1495 // it is sometimes incorrect when dragging within subframes, as seen wit h |
1461 // LayoutTests/fast/events/drag-in-frames.html. | 1496 // LayoutTests/fast/events/drag-in-frames.html. |
1462 // | 1497 // |
1463 // Moreover, this ordering conforms to section 7.9.4 of the HTML 5 spec. <http://dev.w3.org/html5/spec/Overview.html#drag-and-drop-processing-model>. | 1498 // Moreover, this ordering conforms to section 7.9.4 of the HTML 5 spec. <http://dev.w3.org/html5/spec/Overview.html#drag-and-drop-processing-model>. |
1464 LocalFrame* targetFrame; | 1499 LocalFrame* targetFrame; |
1465 if (targetIsFrame(newTarget.get(), targetFrame)) { | 1500 if (targetIsFrame(newTarget.get(), targetFrame)) { |
1466 if (targetFrame) | 1501 if (targetFrame) |
1467 accept = targetFrame->eventHandler().updateDragAndDrop(event, da taTransfer); | 1502 eventResult = targetFrame->eventHandler().updateDragAndDrop(even t, dataTransfer); |
1468 } else if (newTarget) { | 1503 } else if (newTarget) { |
1469 // As per section 7.9.4 of the HTML 5 spec., we must always fire a d rag event before firing a dragenter, dragleave, or dragover event. | 1504 // As per section 7.9.4 of the HTML 5 spec., we must always fire a d rag event before firing a dragenter, dragleave, or dragover event. |
1470 if (dragState().m_dragSrc) { | 1505 if (dragState().m_dragSrc) { |
1471 // for now we don't care if event handler cancels default behavi or, since there is none | 1506 // for now we don't care if event handler cancels default behavi or, since there is none |
1472 dispatchDragSrcEvent(EventTypeNames::drag, event); | 1507 dispatchDragSrcEvent(EventTypeNames::drag, event); |
1473 } | 1508 } |
1474 accept = dispatchDragEvent(EventTypeNames::dragenter, newTarget.get( ), event, dataTransfer); | 1509 eventResult = dispatchDragEvent(EventTypeNames::dragenter, newTarget .get(), event, dataTransfer); |
1475 if (!accept) | 1510 if (eventResult == WebInputEventResult::NotHandled && findDropZone(n ewTarget.get(), dataTransfer)) |
1476 accept = findDropZone(newTarget.get(), dataTransfer); | 1511 eventResult = WebInputEventResult::HandledSystem; |
1477 } | 1512 } |
1478 | 1513 |
1479 if (targetIsFrame(m_dragTarget.get(), targetFrame)) { | 1514 if (targetIsFrame(m_dragTarget.get(), targetFrame)) { |
1480 if (targetFrame) | 1515 if (targetFrame) |
1481 accept = targetFrame->eventHandler().updateDragAndDrop(event, da taTransfer); | 1516 eventResult = targetFrame->eventHandler().updateDragAndDrop(even t, dataTransfer); |
1482 } else if (m_dragTarget) { | 1517 } else if (m_dragTarget) { |
1483 dispatchDragEvent(EventTypeNames::dragleave, m_dragTarget.get(), eve nt, dataTransfer); | 1518 dispatchDragEvent(EventTypeNames::dragleave, m_dragTarget.get(), eve nt, dataTransfer); |
1484 } | 1519 } |
1485 | 1520 |
1486 if (newTarget) { | 1521 if (newTarget) { |
1487 // We do not explicitly call dispatchDragEvent here because it could ultimately result in the appearance that | 1522 // We do not explicitly call dispatchDragEvent here because it could ultimately result in the appearance that |
1488 // two dragover events fired. So, we mark that we should only fire a dragover event on the next call to this function. | 1523 // two dragover events fired. So, we mark that we should only fire a dragover event on the next call to this function. |
1489 m_shouldOnlyFireDragOverEvent = true; | 1524 m_shouldOnlyFireDragOverEvent = true; |
1490 } | 1525 } |
1491 } else { | 1526 } else { |
1492 LocalFrame* targetFrame; | 1527 LocalFrame* targetFrame; |
1493 if (targetIsFrame(newTarget.get(), targetFrame)) { | 1528 if (targetIsFrame(newTarget.get(), targetFrame)) { |
1494 if (targetFrame) | 1529 if (targetFrame) |
1495 accept = targetFrame->eventHandler().updateDragAndDrop(event, da taTransfer); | 1530 eventResult = targetFrame->eventHandler().updateDragAndDrop(even t, dataTransfer); |
1496 } else if (newTarget) { | 1531 } else if (newTarget) { |
1497 // Note, when dealing with sub-frames, we may need to fire only a dr agover event as a drag event may have been fired earlier. | 1532 // Note, when dealing with sub-frames, we may need to fire only a dr agover event as a drag event may have been fired earlier. |
1498 if (!m_shouldOnlyFireDragOverEvent && dragState().m_dragSrc) { | 1533 if (!m_shouldOnlyFireDragOverEvent && dragState().m_dragSrc) { |
1499 // for now we don't care if event handler cancels default behavi or, since there is none | 1534 // for now we don't care if event handler cancels default behavi or, since there is none |
1500 dispatchDragSrcEvent(EventTypeNames::drag, event); | 1535 dispatchDragSrcEvent(EventTypeNames::drag, event); |
1501 } | 1536 } |
1502 accept = dispatchDragEvent(EventTypeNames::dragover, newTarget.get() , event, dataTransfer); | 1537 eventResult = dispatchDragEvent(EventTypeNames::dragover, newTarget. get(), event, dataTransfer); |
1503 if (!accept) | 1538 if (eventResult == WebInputEventResult::NotHandled && findDropZone(n ewTarget.get(), dataTransfer)) |
1504 accept = findDropZone(newTarget.get(), dataTransfer); | 1539 eventResult = WebInputEventResult::HandledSystem; |
1505 m_shouldOnlyFireDragOverEvent = false; | 1540 m_shouldOnlyFireDragOverEvent = false; |
1506 } | 1541 } |
1507 } | 1542 } |
1508 m_dragTarget = newTarget; | 1543 m_dragTarget = newTarget; |
1509 | 1544 |
1510 return accept; | 1545 return eventResult; |
1511 } | 1546 } |
1512 | 1547 |
1513 void EventHandler::cancelDragAndDrop(const PlatformMouseEvent& event, DataTransf er* dataTransfer) | 1548 void EventHandler::cancelDragAndDrop(const PlatformMouseEvent& event, DataTransf er* dataTransfer) |
1514 { | 1549 { |
1515 LocalFrame* targetFrame; | 1550 LocalFrame* targetFrame; |
1516 if (targetIsFrame(m_dragTarget.get(), targetFrame)) { | 1551 if (targetIsFrame(m_dragTarget.get(), targetFrame)) { |
1517 if (targetFrame) | 1552 if (targetFrame) |
1518 targetFrame->eventHandler().cancelDragAndDrop(event, dataTransfer); | 1553 targetFrame->eventHandler().cancelDragAndDrop(event, dataTransfer); |
1519 } else if (m_dragTarget.get()) { | 1554 } else if (m_dragTarget.get()) { |
1520 if (dragState().m_dragSrc) | 1555 if (dragState().m_dragSrc) |
1521 dispatchDragSrcEvent(EventTypeNames::drag, event); | 1556 dispatchDragSrcEvent(EventTypeNames::drag, event); |
1522 dispatchDragEvent(EventTypeNames::dragleave, m_dragTarget.get(), event, dataTransfer); | 1557 dispatchDragEvent(EventTypeNames::dragleave, m_dragTarget.get(), event, dataTransfer); |
1523 } | 1558 } |
1524 clearDragState(); | 1559 clearDragState(); |
1525 } | 1560 } |
1526 | 1561 |
1527 bool EventHandler::performDragAndDrop(const PlatformMouseEvent& event, DataTrans fer* dataTransfer) | 1562 WebInputEventResult EventHandler::performDragAndDrop(const PlatformMouseEvent& e vent, DataTransfer* dataTransfer) |
1528 { | 1563 { |
1529 LocalFrame* targetFrame; | 1564 LocalFrame* targetFrame; |
1530 bool preventedDefault = false; | 1565 WebInputEventResult result = WebInputEventResult::NotHandled; |
1531 if (targetIsFrame(m_dragTarget.get(), targetFrame)) { | 1566 if (targetIsFrame(m_dragTarget.get(), targetFrame)) { |
1532 if (targetFrame) | 1567 if (targetFrame) |
1533 preventedDefault = targetFrame->eventHandler().performDragAndDrop(ev ent, dataTransfer); | 1568 result = targetFrame->eventHandler().performDragAndDrop(event, dataT ransfer); |
1534 } else if (m_dragTarget.get()) { | 1569 } else if (m_dragTarget.get()) { |
1535 preventedDefault = dispatchDragEvent(EventTypeNames::drop, m_dragTarget. get(), event, dataTransfer); | 1570 result = dispatchDragEvent(EventTypeNames::drop, m_dragTarget.get(), eve nt, dataTransfer); |
1536 } | 1571 } |
1537 clearDragState(); | 1572 clearDragState(); |
1538 return preventedDefault; | 1573 return result; |
1539 } | 1574 } |
1540 | 1575 |
1541 void EventHandler::clearDragState() | 1576 void EventHandler::clearDragState() |
1542 { | 1577 { |
1543 stopAutoscroll(); | 1578 stopAutoscroll(); |
1544 m_dragTarget = nullptr; | 1579 m_dragTarget = nullptr; |
1545 m_capturingMouseEventsNode = nullptr; | 1580 m_capturingMouseEventsNode = nullptr; |
1546 m_shouldOnlyFireDragOverEvent = false; | 1581 m_shouldOnlyFireDragOverEvent = false; |
1547 } | 1582 } |
1548 | 1583 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1605 | 1640 |
1606 if (lastNodeUnderMouse && lastNodeUnderMouse->document() != m_frame->documen t()) { | 1641 if (lastNodeUnderMouse && lastNodeUnderMouse->document() != m_frame->documen t()) { |
1607 lastNodeUnderMouse = nullptr; | 1642 lastNodeUnderMouse = nullptr; |
1608 m_lastScrollbarUnderMouse = nullptr; | 1643 m_lastScrollbarUnderMouse = nullptr; |
1609 } | 1644 } |
1610 | 1645 |
1611 if (lastNodeUnderMouse != m_nodeUnderMouse) | 1646 if (lastNodeUnderMouse != m_nodeUnderMouse) |
1612 sendMouseEventsForNodeTransition(lastNodeUnderMouse.get(), m_nodeUnderMo use.get(), mouseEvent); | 1647 sendMouseEventsForNodeTransition(lastNodeUnderMouse.get(), m_nodeUnderMo use.get(), mouseEvent); |
1613 } | 1648 } |
1614 | 1649 |
1615 bool EventHandler::dispatchPointerEvent(Node* target, const AtomicString& eventT ype, | 1650 WebInputEventResult EventHandler::dispatchPointerEvent(Node* target, const Atomi cString& eventType, |
1616 const PlatformMouseEvent& mouseEvent, Node* relatedTarget) | 1651 const PlatformMouseEvent& mouseEvent, Node* relatedTarget) |
1617 { | 1652 { |
1618 if (!RuntimeEnabledFeatures::pointerEventEnabled()) | 1653 if (!RuntimeEnabledFeatures::pointerEventEnabled()) |
1619 return false; | 1654 return WebInputEventResult::NotHandled; |
1620 | 1655 |
1621 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create(eventTy pe, true, | 1656 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent::create(eventTy pe, true, |
1622 mouseEvent, relatedTarget, m_frame->document()->domWindow()); | 1657 mouseEvent, relatedTarget, m_frame->document()->domWindow()); |
1623 target->dispatchEvent(pointerEvent.get()); | 1658 |
1624 return pointerEvent->defaultPrevented() || pointerEvent->defaultHandled(); | 1659 bool dispatchResult = target->dispatchEvent(pointerEvent.get()); |
1660 return eventToEventResult(pointerEvent, dispatchResult); | |
1625 } | 1661 } |
1626 | 1662 |
1627 void EventHandler::sendMouseEventsForNodeTransition(Node* exitedNode, Node* ente redNode, | 1663 void EventHandler::sendMouseEventsForNodeTransition(Node* exitedNode, Node* ente redNode, |
1628 const PlatformMouseEvent& mouseEvent) | 1664 const PlatformMouseEvent& mouseEvent) |
1629 { | 1665 { |
1630 ASSERT(exitedNode != enteredNode); | 1666 ASSERT(exitedNode != enteredNode); |
1631 | 1667 |
1632 // Dispatch pointerout/mouseout events | 1668 // Dispatch pointerout/mouseout events |
1633 if (isNodeInDocument(exitedNode)) { | 1669 if (isNodeInDocument(exitedNode)) { |
1634 dispatchPointerEvent(exitedNode, EventTypeNames::pointerout, mouseEvent, enteredNode); | 1670 dispatchPointerEvent(exitedNode, EventTypeNames::pointerout, mouseEvent, enteredNode); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1720 for (size_t i = enteredAncestorIndex; i > 0; i--) { | 1756 for (size_t i = enteredAncestorIndex; i > 0; i--) { |
1721 if (enteredNodeHasCapturingAncestor || enteredAncestors[i-1]->hasEventLi steners(EventTypeNames::pointerenter)) { | 1757 if (enteredNodeHasCapturingAncestor || enteredAncestors[i-1]->hasEventLi steners(EventTypeNames::pointerenter)) { |
1722 dispatchPointerEvent(enteredAncestors[i-1].get(), EventTypeNames::po interenter, mouseEvent, | 1758 dispatchPointerEvent(enteredAncestors[i-1].get(), EventTypeNames::po interenter, mouseEvent, |
1723 exitedNode); | 1759 exitedNode); |
1724 } | 1760 } |
1725 if (enteredNodeHasCapturingAncestor || enteredAncestors[i-1]->hasEventLi steners(EventTypeNames::mouseenter)) | 1761 if (enteredNodeHasCapturingAncestor || enteredAncestors[i-1]->hasEventLi steners(EventTypeNames::mouseenter)) |
1726 enteredAncestors[i-1]->dispatchMouseEvent(mouseEvent, EventTypeNames ::mouseenter, 0, exitedNode); | 1762 enteredAncestors[i-1]->dispatchMouseEvent(mouseEvent, EventTypeNames ::mouseenter, 0, exitedNode); |
1727 } | 1763 } |
1728 } | 1764 } |
1729 | 1765 |
1730 bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targe tNode, int clickCount, const PlatformMouseEvent& mouseEvent) | 1766 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent) |
1731 { | 1767 { |
1732 updateMouseEventTargetNode(targetNode, mouseEvent); | 1768 updateMouseEventTargetNode(targetNode, mouseEvent); |
1733 return m_nodeUnderMouse && !m_nodeUnderMouse->dispatchMouseEvent(mouseEvent, eventType, clickCount); | 1769 if (!m_nodeUnderMouse) |
1770 return WebInputEventResult::NotHandled; | |
1771 | |
1772 RefPtrWillBeRawPtr<MouseEvent> event = MouseEvent::create(eventType, m_nodeU nderMouse->document().domWindow(), mouseEvent, clickCount, nullptr); | |
1773 bool dispatchResult = m_nodeUnderMouse->dispatchEvent(event); | |
1774 return eventToEventResult(event, dispatchResult); | |
1734 } | 1775 } |
1735 | 1776 |
1736 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler. | 1777 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler. |
1737 bool EventHandler::updatePointerTargetAndDispatchEvents(const AtomicString& mous eEventType, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEve nt) | 1778 WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents(const Ato micString& mouseEventType, Node* targetNode, int clickCount, const PlatformMouse Event& mouseEvent) |
1738 { | 1779 { |
1739 ASSERT(mouseEventType == EventTypeNames::mousedown | 1780 ASSERT(mouseEventType == EventTypeNames::mousedown |
1740 || mouseEventType == EventTypeNames::mousemove | 1781 || mouseEventType == EventTypeNames::mousemove |
1741 || mouseEventType == EventTypeNames::mouseup); | 1782 || mouseEventType == EventTypeNames::mouseup); |
1742 | 1783 |
1743 updateMouseEventTargetNode(targetNode, mouseEvent); | 1784 updateMouseEventTargetNode(targetNode, mouseEvent); |
1744 if (!m_nodeUnderMouse) | 1785 if (!m_nodeUnderMouse) |
1745 return false; | 1786 return WebInputEventResult::NotHandled; |
1746 | 1787 |
1747 bool swallowEvent = dispatchPointerEvent(m_nodeUnderMouse.get(), | 1788 WebInputEventResult result = dispatchPointerEvent(m_nodeUnderMouse.get(), |
1748 pointerEventNameForMouseEventName(mouseEventType), | 1789 pointerEventNameForMouseEventName(mouseEventType), |
1749 mouseEvent); | 1790 mouseEvent); |
1750 | 1791 |
1751 if (swallowEvent && mouseEventType == EventTypeNames::mousedown) { | 1792 if (result != WebInputEventResult::NotHandled && mouseEventType == EventType Names::mousedown) { |
1752 m_preventMouseEventForPointerTypeMouse = true; | 1793 m_preventMouseEventForPointerTypeMouse = true; |
1753 } | 1794 } |
1754 | 1795 |
1755 if (!m_preventMouseEventForPointerTypeMouse) { | 1796 if (!m_preventMouseEventForPointerTypeMouse) { |
1756 swallowEvent |= !m_nodeUnderMouse->dispatchMouseEvent(mouseEvent, mouseE ventType, clickCount); | 1797 RefPtrWillBeRawPtr<MouseEvent> event = MouseEvent::create(mouseEventType , m_nodeUnderMouse->document().domWindow(), mouseEvent, clickCount, nullptr); |
1798 bool dispatchResult = m_nodeUnderMouse->dispatchEvent(event); | |
1799 result = mergeEventResult(result, eventToEventResult(event, dispatchResu lt)); | |
1757 } | 1800 } |
1758 | 1801 |
1759 return swallowEvent; | 1802 return result; |
1760 } | 1803 } |
1761 | 1804 |
1762 bool EventHandler::handleMouseFocus(const MouseEventWithHitTestResults& targeted Event, InputDeviceCapabilities* sourceCapabilities) | 1805 WebInputEventResult EventHandler::handleMouseFocus(const MouseEventWithHitTestRe sults& targetedEvent, InputDeviceCapabilities* sourceCapabilities) |
1763 { | 1806 { |
1764 // If clicking on a frame scrollbar, do not mess up with content focus. | 1807 // If clicking on a frame scrollbar, do not mess up with content focus. |
1765 if (targetedEvent.hitTestResult().scrollbar() && m_frame->contentLayoutObjec t()) { | 1808 if (targetedEvent.hitTestResult().scrollbar() && m_frame->contentLayoutObjec t()) { |
1766 if (targetedEvent.hitTestResult().scrollbar()->scrollableArea() == m_fra me->contentLayoutObject()->scrollableArea()) | 1809 if (targetedEvent.hitTestResult().scrollbar()->scrollableArea() == m_fra me->contentLayoutObject()->scrollableArea()) |
1767 return false; | 1810 return WebInputEventResult::NotHandled; |
1768 } | 1811 } |
1769 | 1812 |
1770 // The layout needs to be up to date to determine if an element is focusable . | 1813 // The layout needs to be up to date to determine if an element is focusable . |
1771 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1814 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
1772 | 1815 |
1773 Element* element = nullptr; | 1816 Element* element = nullptr; |
1774 if (m_nodeUnderMouse) | 1817 if (m_nodeUnderMouse) |
1775 element = m_nodeUnderMouse->isElementNode() ? toElement(m_nodeUnderMouse ) : m_nodeUnderMouse->parentOrShadowHostElement(); | 1818 element = m_nodeUnderMouse->isElementNode() ? toElement(m_nodeUnderMouse ) : m_nodeUnderMouse->parentOrShadowHostElement(); |
1776 for (; element; element = element->parentOrShadowHostElement()) { | 1819 for (; element; element = element->parentOrShadowHostElement()) { |
1777 if (element->isFocusable() && element->isFocusedElementInDocument()) | 1820 if (element->isFocusable() && element->isFocusedElementInDocument()) |
1778 return false; | 1821 return WebInputEventResult::NotHandled; |
1779 if (element->isMouseFocusable()) | 1822 if (element->isMouseFocusable()) |
1780 break; | 1823 break; |
1781 } | 1824 } |
1782 ASSERT(!element || element->isMouseFocusable()); | 1825 ASSERT(!element || element->isMouseFocusable()); |
1783 | 1826 |
1784 // To fix <rdar://problem/4895428> Can't drag selected ToDo, we don't focus | 1827 // To fix <rdar://problem/4895428> Can't drag selected ToDo, we don't focus |
1785 // a node on mouse down if it's selected and inside a focused node. It will | 1828 // a node on mouse down if it's selected and inside a focused node. It will |
1786 // be focused if the user does a mouseup over it, however, because the | 1829 // be focused if the user does a mouseup over it, however, because the |
1787 // mouseup will set a selection inside it, which will call | 1830 // mouseup will set a selection inside it, which will call |
1788 // FrameSelection::setFocusedNodeIfNeeded. | 1831 // FrameSelection::setFocusedNodeIfNeeded. |
1789 if (element && m_frame->selection().isRange()) { | 1832 if (element && m_frame->selection().isRange()) { |
1790 // TODO(yosin) We should not create |Range| object for calling | 1833 // TODO(yosin) We should not create |Range| object for calling |
1791 // |isNodeFullyContained()|. | 1834 // |isNodeFullyContained()|. |
1792 if (createRange(m_frame->selection().selection().toNormalizedEphemeralRa nge())->isNodeFullyContained(*element) | 1835 if (createRange(m_frame->selection().selection().toNormalizedEphemeralRa nge())->isNodeFullyContained(*element) |
1793 && element->isDescendantOf(m_frame->document()->focusedElement())) | 1836 && element->isDescendantOf(m_frame->document()->focusedElement())) |
1794 return false; | 1837 return WebInputEventResult::NotHandled; |
1795 } | 1838 } |
1796 | 1839 |
1797 | 1840 |
1798 // Only change the focus when clicking scrollbars if it can transfered to a | 1841 // Only change the focus when clicking scrollbars if it can transfered to a |
1799 // mouse focusable node. | 1842 // mouse focusable node. |
1800 if (!element && targetedEvent.hitTestResult().scrollbar()) | 1843 if (!element && targetedEvent.hitTestResult().scrollbar()) |
1801 return true; | 1844 return WebInputEventResult::HandledSystem; |
1802 | 1845 |
1803 if (Page* page = m_frame->page()) { | 1846 if (Page* page = m_frame->page()) { |
1804 // If focus shift is blocked, we eat the event. Note we should never | 1847 // If focus shift is blocked, we eat the event. Note we should never |
1805 // clear swallowEvent if the page already set it (e.g., by canceling | 1848 // clear swallowEvent if the page already set it (e.g., by canceling |
1806 // default behavior). | 1849 // default behavior). |
1807 if (element) { | 1850 if (element) { |
1808 if (slideFocusOnShadowHostIfNecessary(*element)) | 1851 if (slideFocusOnShadowHostIfNecessary(*element)) |
1809 return true; | 1852 return WebInputEventResult::HandledSystem; |
1810 if (!page->focusController().setFocusedElement(element, m_frame, Foc usParams(SelectionBehaviorOnFocus::None, WebFocusTypeMouse, sourceCapabilities)) ) | 1853 if (!page->focusController().setFocusedElement(element, m_frame, Foc usParams(SelectionBehaviorOnFocus::None, WebFocusTypeMouse, sourceCapabilities)) ) |
1811 return true; | 1854 return WebInputEventResult::HandledSystem; |
1812 } else { | 1855 } else { |
1813 // We call setFocusedElement even with !element in order to blur | 1856 // We call setFocusedElement even with !element in order to blur |
1814 // current focus element when a link is clicked; this is expected by | 1857 // current focus element when a link is clicked; this is expected by |
1815 // some sites that rely on onChange handlers running from form | 1858 // some sites that rely on onChange handlers running from form |
1816 // fields before the button click is processed. | 1859 // fields before the button click is processed. |
1817 if (!page->focusController().setFocusedElement(nullptr, m_frame, Foc usParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, sourceCapabilities))) | 1860 if (!page->focusController().setFocusedElement(nullptr, m_frame, Foc usParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, sourceCapabilities))) |
1818 return true; | 1861 return WebInputEventResult::HandledSystem; |
1819 } | 1862 } |
1820 } | 1863 } |
1821 | 1864 |
1822 return false; | 1865 return WebInputEventResult::NotHandled; |
1823 } | 1866 } |
1824 | 1867 |
1825 bool EventHandler::slideFocusOnShadowHostIfNecessary(const Element& element) | 1868 bool EventHandler::slideFocusOnShadowHostIfNecessary(const Element& element) |
1826 { | 1869 { |
1827 if (element.authorShadowRoot() && element.authorShadowRoot()->delegatesFocus ()) { | 1870 if (element.authorShadowRoot() && element.authorShadowRoot()->delegatesFocus ()) { |
1828 Document* doc = m_frame->document(); | 1871 Document* doc = m_frame->document(); |
1829 if (element.containsIncludingShadowDOM(doc->focusedElement())) { | 1872 if (element.containsIncludingShadowDOM(doc->focusedElement())) { |
1830 // If the inner element is already focused, do nothing. | 1873 // If the inner element is already focused, do nothing. |
1831 return true; | 1874 return true; |
1832 } | 1875 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1873 ScrollResult result; | 1916 ScrollResult result; |
1874 result.didScrollY = resultY.didScroll; | 1917 result.didScrollY = resultY.didScroll; |
1875 result.didScrollX = resultX.didScroll; | 1918 result.didScrollX = resultX.didScroll; |
1876 result.unusedScrollDeltaY = resultY.unusedScrollDelta; | 1919 result.unusedScrollDeltaY = resultY.unusedScrollDelta; |
1877 result.unusedScrollDeltaX = resultX.unusedScrollDelta; | 1920 result.unusedScrollDeltaX = resultX.unusedScrollDelta; |
1878 return result; | 1921 return result; |
1879 } | 1922 } |
1880 | 1923 |
1881 } // namespace | 1924 } // namespace |
1882 | 1925 |
1883 bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event) | 1926 WebInputEventResult EventHandler::handleWheelEvent(const PlatformWheelEvent& eve nt) |
1884 { | 1927 { |
1885 #define RETURN_WHEEL_EVENT_HANDLED() \ | |
1886 { \ | |
1887 setFrameWasScrolledByUser(); \ | |
1888 return true; \ | |
1889 } | |
1890 | |
1891 Document* doc = m_frame->document(); | 1928 Document* doc = m_frame->document(); |
1892 | 1929 |
1893 if (!doc->layoutView()) | 1930 if (!doc->layoutView()) |
1894 return false; | 1931 return WebInputEventResult::NotHandled; |
1895 | 1932 |
1896 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 1933 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
1897 | 1934 |
1898 FrameView* view = m_frame->view(); | 1935 FrameView* view = m_frame->view(); |
1899 if (!view) | 1936 if (!view) |
1900 return false; | 1937 return WebInputEventResult::NotHandled; |
1901 | 1938 |
1902 LayoutPoint vPoint = view->rootFrameToContents(event.position()); | 1939 LayoutPoint vPoint = view->rootFrameToContents(event.position()); |
1903 | 1940 |
1904 HitTestRequest request(HitTestRequest::ReadOnly); | 1941 HitTestRequest request(HitTestRequest::ReadOnly); |
1905 HitTestResult result(request, vPoint); | 1942 HitTestResult result(request, vPoint); |
1906 doc->layoutView()->hitTest(result); | 1943 doc->layoutView()->hitTest(result); |
1907 | 1944 |
1908 Node* node = result.innerNode(); | 1945 Node* node = result.innerNode(); |
1909 // Wheel events should not dispatch to text nodes. | 1946 // Wheel events should not dispatch to text nodes. |
1910 if (node && node->isTextNode()) | 1947 if (node && node->isTextNode()) |
1911 node = ComposedTreeTraversal::parent(*node); | 1948 node = ComposedTreeTraversal::parent(*node); |
1912 | 1949 |
1913 if (m_previousWheelScrolledNode) | 1950 if (m_previousWheelScrolledNode) |
1914 m_previousWheelScrolledNode = nullptr; | 1951 m_previousWheelScrolledNode = nullptr; |
1915 | 1952 |
1916 bool isOverWidget = result.isOverWidget(); | 1953 bool isOverWidget = result.isOverWidget(); |
1917 | 1954 |
1918 if (node) { | 1955 if (node) { |
1919 // Figure out which view to send the event to. | 1956 // Figure out which view to send the event to. |
1920 LayoutObject* target = node->layoutObject(); | 1957 LayoutObject* target = node->layoutObject(); |
1921 | 1958 |
1922 if (isOverWidget && target && target->isLayoutPart()) { | 1959 if (isOverWidget && target && target->isLayoutPart()) { |
1923 Widget* widget = toLayoutPart(target)->widget(); | 1960 if (Widget* widget = toLayoutPart(target)->widget()) { |
1924 if (widget && passWheelEventToWidget(event, *widget)) | 1961 WebInputEventResult result = passWheelEventToWidget(event, *widg et); |
1925 RETURN_WHEEL_EVENT_HANDLED(); | 1962 if (result != WebInputEventResult::NotHandled) { |
1963 setFrameWasScrolledByUser(); | |
1964 return result; | |
1965 } | |
1966 } | |
1926 } | 1967 } |
1927 | 1968 |
1928 if (node && !node->dispatchWheelEvent(event)) | 1969 RefPtrWillBeRawPtr<Event> domEvent = WheelEvent::create(event, node->doc ument().domWindow()); |
1929 RETURN_WHEEL_EVENT_HANDLED(); | 1970 if (!node->dispatchEvent(domEvent)) { |
1971 setFrameWasScrolledByUser(); | |
1972 return eventToEventResult(domEvent, false); | |
1973 } | |
1930 } | 1974 } |
1931 | 1975 |
1932 // We do another check on the frame view because the event handler can run | 1976 // We do another check on the frame view because the event handler can run |
1933 // JS which results in the frame getting destroyed. | 1977 // JS which results in the frame getting destroyed. |
1934 view = m_frame->view(); | 1978 view = m_frame->view(); |
1935 if (!view) | 1979 if (!view) |
1936 return false; | 1980 return WebInputEventResult::NotHandled; |
1937 | 1981 |
1938 // Wheel events which do not scroll are used to trigger zooming. | 1982 // Wheel events which do not scroll are used to trigger zooming. |
1939 if (!event.canScroll()) | 1983 if (!event.canScroll()) |
1940 return false; | 1984 return WebInputEventResult::NotHandled; |
1941 | 1985 |
1942 ScrollResult scrollResult = scrollAreaWithWheelEvent(event, *view->scrollabl eArea()); | 1986 ScrollResult scrollResult = scrollAreaWithWheelEvent(event, *view->scrollabl eArea()); |
1943 if (m_frame->settings() && m_frame->settings()->reportWheelOverscroll()) | 1987 if (m_frame->settings() && m_frame->settings()->reportWheelOverscroll()) |
1944 handleOverscroll(scrollResult); | 1988 handleOverscroll(scrollResult); |
1945 if (scrollResult.didScroll()) | 1989 if (scrollResult.didScroll()) { |
1946 RETURN_WHEEL_EVENT_HANDLED(); | 1990 setFrameWasScrolledByUser(); |
1991 return WebInputEventResult::HandledSystem; | |
1992 } | |
1947 | 1993 |
1948 return false; | 1994 return WebInputEventResult::NotHandled; |
1949 #undef RETURN_WHEEL_EVENT_HANDLED | |
1950 } | 1995 } |
1951 | 1996 |
1952 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv ent) | 1997 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv ent) |
1953 { | 1998 { |
1954 if (!startNode || !wheelEvent) | 1999 if (!startNode || !wheelEvent) |
1955 return; | 2000 return; |
1956 | 2001 |
1957 // When the wheelEvent do not scroll, we trigger zoom in/out instead. | 2002 // When the wheelEvent do not scroll, we trigger zoom in/out instead. |
1958 if (!wheelEvent->canScroll()) | 2003 if (!wheelEvent->canScroll()) |
1959 return; | 2004 return; |
(...skipping 10 matching lines...) Expand all Loading... | |
1970 && scroll(ScrollRightIgnoringWritingMode, granularity, startNode, &stopN ode, wheelEvent->deltaX(), absolutePosition).didScroll) | 2015 && scroll(ScrollRightIgnoringWritingMode, granularity, startNode, &stopN ode, wheelEvent->deltaX(), absolutePosition).didScroll) |
1971 wheelEvent->setDefaultHandled(); | 2016 wheelEvent->setDefaultHandled(); |
1972 | 2017 |
1973 if (wheelEvent->railsMode() != Event::RailsModeHorizontal | 2018 if (wheelEvent->railsMode() != Event::RailsModeHorizontal |
1974 && scroll(ScrollDownIgnoringWritingMode, granularity, startNode, &stopNo de, wheelEvent->deltaY(), absolutePosition).didScroll) | 2019 && scroll(ScrollDownIgnoringWritingMode, granularity, startNode, &stopNo de, wheelEvent->deltaY(), absolutePosition).didScroll) |
1975 wheelEvent->setDefaultHandled(); | 2020 wheelEvent->setDefaultHandled(); |
1976 | 2021 |
1977 m_previousWheelScrolledNode = stopNode; | 2022 m_previousWheelScrolledNode = stopNode; |
1978 } | 2023 } |
1979 | 2024 |
1980 bool EventHandler::handleGestureShowPress() | 2025 WebInputEventResult EventHandler::handleGestureShowPress() |
1981 { | 2026 { |
1982 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); | 2027 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); |
1983 | 2028 |
1984 FrameView* view = m_frame->view(); | 2029 FrameView* view = m_frame->view(); |
1985 if (!view) | 2030 if (!view) |
1986 return false; | 2031 return WebInputEventResult::NotHandled; |
1987 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) | 2032 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) |
1988 scrollAnimator->cancelAnimations(); | 2033 scrollAnimator->cancelAnimations(); |
1989 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); | 2034 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); |
1990 if (!areas) | 2035 if (!areas) |
1991 return false; | 2036 return WebInputEventResult::NotHandled; |
1992 for (const ScrollableArea* scrollableArea : *areas) { | 2037 for (const ScrollableArea* scrollableArea : *areas) { |
1993 ScrollAnimatorBase* animator = scrollableArea->existingScrollAnimator(); | 2038 ScrollAnimatorBase* animator = scrollableArea->existingScrollAnimator(); |
1994 if (animator) | 2039 if (animator) |
1995 animator->cancelAnimations(); | 2040 animator->cancelAnimations(); |
1996 } | 2041 } |
1997 return false; | 2042 return WebInputEventResult::NotHandled; |
1998 } | 2043 } |
1999 | 2044 |
2000 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) | 2045 WebInputEventResult EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) |
2001 { | 2046 { |
2002 // Propagation to inner frames is handled below this function. | 2047 // Propagation to inner frames is handled below this function. |
2003 ASSERT(m_frame == m_frame->localFrameRoot()); | 2048 ASSERT(m_frame == m_frame->localFrameRoot()); |
2004 | 2049 |
2005 // Scrolling-related gesture events invoke EventHandler recursively for each frame down | 2050 // Scrolling-related gesture events invoke EventHandler recursively for each frame down |
2006 // the chain, doing a single-frame hit-test per frame. This matches handleWh eelEvent. | 2051 // the chain, doing a single-frame hit-test per frame. This matches handleWh eelEvent. |
2007 // FIXME: Add a test that traverses this path, e.g. for devtools overlay. | 2052 // FIXME: Add a test that traverses this path, e.g. for devtools overlay. |
2008 if (gestureEvent.isScrollEvent()) | 2053 if (gestureEvent.isScrollEvent()) |
2009 return handleGestureScrollEvent(gestureEvent); | 2054 return handleGestureScrollEvent(gestureEvent); |
2010 | 2055 |
2011 // Hit test across all frames and do touch adjustment as necessary for the e vent type. | 2056 // Hit test across all frames and do touch adjustment as necessary for the e vent type. |
2012 GestureEventWithHitTestResults targetedEvent = targetGestureEvent(gestureEve nt); | 2057 GestureEventWithHitTestResults targetedEvent = targetGestureEvent(gestureEve nt); |
2013 | 2058 |
2014 return handleGestureEvent(targetedEvent); | 2059 return handleGestureEvent(targetedEvent); |
2015 } | 2060 } |
2016 | 2061 |
2017 bool EventHandler::handleGestureEvent(const GestureEventWithHitTestResults& targ etedEvent) | 2062 WebInputEventResult EventHandler::handleGestureEvent(const GestureEventWithHitTe stResults& targetedEvent) |
2018 { | 2063 { |
2019 TRACE_EVENT0("input", "EventHandler::handleGestureEvent"); | 2064 TRACE_EVENT0("input", "EventHandler::handleGestureEvent"); |
2020 | 2065 |
2021 // Propagation to inner frames is handled below this function. | 2066 // Propagation to inner frames is handled below this function. |
2022 ASSERT(m_frame == m_frame->localFrameRoot()); | 2067 ASSERT(m_frame == m_frame->localFrameRoot()); |
2023 | 2068 |
2024 // Non-scrolling related gesture events do a single cross-frame hit-test and jump | 2069 // Non-scrolling related gesture events do a single cross-frame hit-test and jump |
2025 // directly to the inner most frame. This matches handleMousePressEvent etc. | 2070 // directly to the inner most frame. This matches handleMousePressEvent etc. |
2026 ASSERT(!targetedEvent.event().isScrollEvent()); | 2071 ASSERT(!targetedEvent.event().isScrollEvent()); |
2027 | 2072 |
2028 // update mouseout/leave/over/enter events before jumping directly to the in ner most frame | 2073 // update mouseout/leave/over/enter events before jumping directly to the in ner most frame |
2029 if (targetedEvent.event().type() == PlatformEvent::GestureTap) | 2074 if (targetedEvent.event().type() == PlatformEvent::GestureTap) |
2030 updateGestureTargetNodeForMouseEvent(targetedEvent); | 2075 updateGestureTargetNodeForMouseEvent(targetedEvent); |
2031 | 2076 |
2032 // Route to the correct frame. | 2077 // Route to the correct frame. |
2033 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) | 2078 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) |
2034 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t); | 2079 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t); |
2035 | 2080 |
2036 // No hit test result, handle in root instance. Perhaps we should just retur n false instead? | 2081 // No hit test result, handle in root instance. Perhaps we should just retur n false instead? |
2037 return handleGestureEventInFrame(targetedEvent); | 2082 return handleGestureEventInFrame(targetedEvent); |
2038 } | 2083 } |
2039 | 2084 |
2040 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent) | 2085 WebInputEventResult EventHandler::handleGestureEventInFrame(const GestureEventWi thHitTestResults& targetedEvent) |
2041 { | 2086 { |
2042 ASSERT(!targetedEvent.event().isScrollEvent()); | 2087 ASSERT(!targetedEvent.event().isScrollEvent()); |
2043 | 2088 |
2044 RefPtrWillBeRawPtr<Node> eventTarget = targetedEvent.hitTestResult().innerNo de(); | 2089 RefPtrWillBeRawPtr<Node> eventTarget = targetedEvent.hitTestResult().innerNo de(); |
2045 RefPtrWillBeRawPtr<Scrollbar> scrollbar = targetedEvent.hitTestResult().scro llbar(); | 2090 RefPtrWillBeRawPtr<Scrollbar> scrollbar = targetedEvent.hitTestResult().scro llbar(); |
2046 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 2091 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
2047 | 2092 |
2048 if (scrollbar) { | 2093 if (scrollbar) { |
2049 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); | 2094 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); |
2050 if (gestureEvent.type() == PlatformEvent::GestureTapDown && eventSwallow ed) | 2095 if (gestureEvent.type() == PlatformEvent::GestureTapDown && eventSwallow ed) |
2051 m_scrollbarHandlingScrollGesture = scrollbar; | 2096 m_scrollbarHandlingScrollGesture = scrollbar; |
2052 if (eventSwallowed) | 2097 if (eventSwallowed) |
2053 return true; | 2098 return WebInputEventResult::HandledSuppressed; |
2054 } | 2099 } |
2055 | 2100 |
2056 if (eventTarget && eventTarget->dispatchGestureEvent(gestureEvent)) | 2101 if (eventTarget) { |
2057 return true; | 2102 RefPtrWillBeRawPtr<GestureEvent> gestureDomEvent = GestureEvent::create( eventTarget->document().domWindow(), gestureEvent); |
2103 // TODO(dtapuska): dispatchEvent is inverted for Gesture Events | |
2104 // crbug.com/560357 | |
2105 if (gestureDomEvent.get() && eventTarget->dispatchEvent(gestureDomEvent) ) | |
2106 return eventToEventResult(gestureDomEvent, false); | |
2107 } | |
2058 | 2108 |
2059 switch (gestureEvent.type()) { | 2109 switch (gestureEvent.type()) { |
2060 case PlatformEvent::GestureTap: | 2110 case PlatformEvent::GestureTap: |
2061 return handleGestureTap(targetedEvent); | 2111 return handleGestureTap(targetedEvent); |
2062 case PlatformEvent::GestureShowPress: | 2112 case PlatformEvent::GestureShowPress: |
2063 return handleGestureShowPress(); | 2113 return handleGestureShowPress(); |
2064 case PlatformEvent::GestureLongPress: | 2114 case PlatformEvent::GestureLongPress: |
2065 return handleGestureLongPress(targetedEvent); | 2115 return handleGestureLongPress(targetedEvent); |
2066 case PlatformEvent::GestureLongTap: | 2116 case PlatformEvent::GestureLongTap: |
2067 return handleGestureLongTap(targetedEvent); | 2117 return handleGestureLongTap(targetedEvent); |
2068 case PlatformEvent::GestureTwoFingerTap: | 2118 case PlatformEvent::GestureTwoFingerTap: |
2069 return sendContextMenuEventForGesture(targetedEvent); | 2119 return sendContextMenuEventForGesture(targetedEvent); |
2070 case PlatformEvent::GestureTapDown: | 2120 case PlatformEvent::GestureTapDown: |
2071 case PlatformEvent::GesturePinchBegin: | 2121 case PlatformEvent::GesturePinchBegin: |
2072 case PlatformEvent::GesturePinchEnd: | 2122 case PlatformEvent::GesturePinchEnd: |
2073 case PlatformEvent::GesturePinchUpdate: | 2123 case PlatformEvent::GesturePinchUpdate: |
2074 case PlatformEvent::GestureTapDownCancel: | 2124 case PlatformEvent::GestureTapDownCancel: |
2075 case PlatformEvent::GestureTapUnconfirmed: | 2125 case PlatformEvent::GestureTapUnconfirmed: |
2076 break; | 2126 break; |
2077 default: | 2127 default: |
2078 ASSERT_NOT_REACHED(); | 2128 ASSERT_NOT_REACHED(); |
2079 } | 2129 } |
2080 | 2130 |
2081 return false; | 2131 return WebInputEventResult::NotHandled; |
2082 } | 2132 } |
2083 | 2133 |
2084 bool EventHandler::handleGestureScrollEvent(const PlatformGestureEvent& gestureE vent) | 2134 WebInputEventResult EventHandler::handleGestureScrollEvent(const PlatformGesture Event& gestureEvent) |
2085 { | 2135 { |
2086 TRACE_EVENT0("input", "EventHandler::handleGestureScrollEvent"); | 2136 TRACE_EVENT0("input", "EventHandler::handleGestureScrollEvent"); |
2087 | 2137 |
2088 RefPtrWillBeRawPtr<Node> eventTarget = nullptr; | 2138 RefPtrWillBeRawPtr<Node> eventTarget = nullptr; |
2089 RefPtrWillBeRawPtr<Scrollbar> scrollbar = nullptr; | 2139 RefPtrWillBeRawPtr<Scrollbar> scrollbar = nullptr; |
2090 if (gestureEvent.type() != PlatformEvent::GestureScrollBegin) { | 2140 if (gestureEvent.type() != PlatformEvent::GestureScrollBegin) { |
2091 scrollbar = m_scrollbarHandlingScrollGesture.get(); | 2141 scrollbar = m_scrollbarHandlingScrollGesture.get(); |
2092 eventTarget = m_scrollGestureHandlingNode.get(); | 2142 eventTarget = m_scrollGestureHandlingNode.get(); |
2093 } | 2143 } |
2094 | 2144 |
2095 if (!eventTarget) { | 2145 if (!eventTarget) { |
2096 Document* document = m_frame->document(); | 2146 Document* document = m_frame->document(); |
2097 if (!document->layoutView()) | 2147 if (!document->layoutView()) |
2098 return false; | 2148 return WebInputEventResult::NotHandled; |
2099 | 2149 |
2100 FrameView* view = m_frame->view(); | 2150 FrameView* view = m_frame->view(); |
2101 LayoutPoint viewPoint = view->rootFrameToContents(gestureEvent.position( )); | 2151 LayoutPoint viewPoint = view->rootFrameToContents(gestureEvent.position( )); |
2102 HitTestRequest request(HitTestRequest::ReadOnly); | 2152 HitTestRequest request(HitTestRequest::ReadOnly); |
2103 HitTestResult result(request, viewPoint); | 2153 HitTestResult result(request, viewPoint); |
2104 document->layoutView()->hitTest(result); | 2154 document->layoutView()->hitTest(result); |
2105 | 2155 |
2106 eventTarget = result.innerNode(); | 2156 eventTarget = result.innerNode(); |
2107 | 2157 |
2108 m_lastGestureScrollOverWidget = result.isOverWidget(); | 2158 m_lastGestureScrollOverWidget = result.isOverWidget(); |
2109 m_scrollGestureHandlingNode = eventTarget; | 2159 m_scrollGestureHandlingNode = eventTarget; |
2110 m_previousGestureScrolledNode = nullptr; | 2160 m_previousGestureScrolledNode = nullptr; |
2111 | 2161 |
2112 if (!scrollbar) | 2162 if (!scrollbar) |
2113 scrollbar = result.scrollbar(); | 2163 scrollbar = result.scrollbar(); |
2114 } | 2164 } |
2115 | 2165 |
2116 if (scrollbar) { | 2166 if (scrollbar) { |
2117 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); | 2167 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); |
2118 if (gestureEvent.type() == PlatformEvent::GestureScrollEnd | 2168 if (gestureEvent.type() == PlatformEvent::GestureScrollEnd |
2119 || gestureEvent.type() == PlatformEvent::GestureFlingStart | 2169 || gestureEvent.type() == PlatformEvent::GestureFlingStart |
2120 || !eventSwallowed) { | 2170 || !eventSwallowed) { |
2121 m_scrollbarHandlingScrollGesture = nullptr; | 2171 m_scrollbarHandlingScrollGesture = nullptr; |
2122 } | 2172 } |
2123 if (eventSwallowed) | 2173 if (eventSwallowed) |
2124 return true; | 2174 return WebInputEventResult::HandledSuppressed; |
2125 } | 2175 } |
2126 | 2176 |
2127 if (eventTarget) { | 2177 if (eventTarget) { |
2128 bool eventSwallowed = handleScrollGestureOnResizer(eventTarget.get(), ge stureEvent); | 2178 if (handleScrollGestureOnResizer(eventTarget.get(), gestureEvent)) |
2129 if (!eventSwallowed) | 2179 return WebInputEventResult::HandledSuppressed; |
2130 eventSwallowed = eventTarget->dispatchGestureEvent(gestureEvent); | 2180 |
2131 if (eventSwallowed) | 2181 RefPtrWillBeRawPtr<GestureEvent> gestureDomEvent = GestureEvent::create( eventTarget->document().domWindow(), gestureEvent); |
2132 return true; | 2182 // TODO(dtapuska): dispatchEvent is inverted for Gesture Events |
2183 // crbug.com/560357 | |
2184 if (gestureDomEvent.get() && eventTarget->dispatchEvent(gestureDomEvent) ) | |
2185 return eventToEventResult(gestureDomEvent, false); | |
2133 } | 2186 } |
2134 | 2187 |
2135 switch (gestureEvent.type()) { | 2188 switch (gestureEvent.type()) { |
2136 case PlatformEvent::GestureScrollBegin: | 2189 case PlatformEvent::GestureScrollBegin: |
2137 return handleGestureScrollBegin(gestureEvent); | 2190 return handleGestureScrollBegin(gestureEvent); |
2138 case PlatformEvent::GestureScrollUpdate: | 2191 case PlatformEvent::GestureScrollUpdate: |
2139 return handleGestureScrollUpdate(gestureEvent); | 2192 return handleGestureScrollUpdate(gestureEvent); |
2140 case PlatformEvent::GestureScrollEnd: | 2193 case PlatformEvent::GestureScrollEnd: |
2141 return handleGestureScrollEnd(gestureEvent); | 2194 return handleGestureScrollEnd(gestureEvent); |
2142 case PlatformEvent::GestureFlingStart: | 2195 case PlatformEvent::GestureFlingStart: |
2143 case PlatformEvent::GesturePinchBegin: | 2196 case PlatformEvent::GesturePinchBegin: |
2144 case PlatformEvent::GesturePinchEnd: | 2197 case PlatformEvent::GesturePinchEnd: |
2145 case PlatformEvent::GesturePinchUpdate: | 2198 case PlatformEvent::GesturePinchUpdate: |
2146 return false; | 2199 return WebInputEventResult::NotHandled; |
2147 default: | 2200 default: |
2148 ASSERT_NOT_REACHED(); | 2201 ASSERT_NOT_REACHED(); |
2149 return false; | 2202 return WebInputEventResult::NotHandled; |
2150 } | 2203 } |
2151 } | 2204 } |
2152 | 2205 |
2153 bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target edEvent) | 2206 WebInputEventResult EventHandler::handleGestureTap(const GestureEventWithHitTest Results& targetedEvent) |
2154 { | 2207 { |
2155 RefPtrWillBeRawPtr<FrameView> frameView(m_frame->view()); | 2208 RefPtrWillBeRawPtr<FrameView> frameView(m_frame->view()); |
2156 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 2209 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
2157 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); | 2210 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); |
2158 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion(); | 2211 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion(); |
2159 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); | 2212 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); |
2160 | 2213 |
2161 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | 2214 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); |
2162 | 2215 |
2163 HitTestResult currentHitTest = targetedEvent.hitTestResult(); | 2216 HitTestResult currentHitTest = targetedEvent.hitTestResult(); |
(...skipping 29 matching lines...) Expand all Loading... | |
2193 RefPtrWillBeRawPtr<Node> tappedNode = m_clickNode; | 2246 RefPtrWillBeRawPtr<Node> tappedNode = m_clickNode; |
2194 IntPoint tappedPosition = gestureEvent.position(); | 2247 IntPoint tappedPosition = gestureEvent.position(); |
2195 | 2248 |
2196 if (m_clickNode && m_clickNode->isTextNode()) | 2249 if (m_clickNode && m_clickNode->isTextNode()) |
2197 m_clickNode = ComposedTreeTraversal::parent(*m_clickNode); | 2250 m_clickNode = ComposedTreeTraversal::parent(*m_clickNode); |
2198 | 2251 |
2199 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa lPosition(), | 2252 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa lPosition(), |
2200 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), | 2253 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), |
2201 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut tonDown), | 2254 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut tonDown), |
2202 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2255 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
2203 bool swallowMouseDownEvent = dispatchMouseEvent(EventTypeNames::mousedown, c urrentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown); | 2256 WebInputEventResult mouseDownEventResult = dispatchMouseEvent(EventTypeNames ::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown) ; |
2204 selectionController().initializeSelectionState(); | 2257 selectionController().initializeSelectionState(); |
2205 if (!swallowMouseDownEvent) | 2258 if (mouseDownEventResult == WebInputEventResult::NotHandled) |
2206 swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fa keMouseDown, currentHitTest), InputDeviceCapabilities::firesTouchEventsSourceCap abilities()); | 2259 mouseDownEventResult = handleMouseFocus(MouseEventWithHitTestResults(fak eMouseDown, currentHitTest), InputDeviceCapabilities::firesTouchEventsSourceCapa bilities()); |
2207 if (!swallowMouseDownEvent) | 2260 if (mouseDownEventResult == WebInputEventResult::NotHandled) |
2208 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul ts(fakeMouseDown, currentHitTest)); | 2261 mouseDownEventResult = handleMousePressEvent(MouseEventWithHitTestResult s(fakeMouseDown, currentHitTest)); |
2209 | 2262 |
2210 if (currentHitTest.innerNode()) { | 2263 if (currentHitTest.innerNode()) { |
2211 ASSERT(gestureEvent.type() == PlatformEvent::GestureTap); | 2264 ASSERT(gestureEvent.type() == PlatformEvent::GestureTap); |
2212 HitTestResult result = currentHitTest; | 2265 HitTestResult result = currentHitTest; |
2213 result.setToShadowHostIfInUserAgentShadowRoot(); | 2266 result.setToShadowHostIfInUserAgentShadowRoot(); |
2214 m_frame->chromeClient().onMouseDown(result.innerNode()); | 2267 m_frame->chromeClient().onMouseDown(result.innerNode()); |
2215 } | 2268 } |
2216 | 2269 |
2217 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug. com/398920 | 2270 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug. com/398920 |
2218 if (currentHitTest.innerNode()) { | 2271 if (currentHitTest.innerNode()) { |
2219 LocalFrame* mainFrame = m_frame->localFrameRoot(); | 2272 LocalFrame* mainFrame = m_frame->localFrameRoot(); |
2220 if (mainFrame && mainFrame->view()) | 2273 if (mainFrame && mainFrame->view()) |
2221 mainFrame->view()->updateAllLifecyclePhases(); | 2274 mainFrame->view()->updateAllLifecyclePhases(); |
2222 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); | 2275 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); |
2223 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType); | 2276 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType); |
2224 } | 2277 } |
2225 PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalP osition(), | 2278 PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalP osition(), |
2226 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(), | 2279 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(), |
2227 static_cast<PlatformEvent::Modifiers>(modifiers), | 2280 static_cast<PlatformEvent::Modifiers>(modifiers), |
2228 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2281 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
2229 bool swallowMouseUpEvent = dispatchMouseEvent(EventTypeNames::mouseup, curre ntHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseUp); | 2282 WebInputEventResult mouseUpEventResult = dispatchMouseEvent(EventTypeNames:: mouseup, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseUp); |
2230 | 2283 |
2231 bool swallowClickEvent = false; | 2284 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; |
2232 if (m_clickNode) { | 2285 if (m_clickNode) { |
2233 if (currentHitTest.innerNode()) { | 2286 if (currentHitTest.innerNode()) { |
2234 // Updates distribution because a mouseup (or mousedown) event liste ner can make the | 2287 // Updates distribution because a mouseup (or mousedown) event liste ner can make the |
2235 // tree dirty at dispatchMouseEvent() invocation above. | 2288 // tree dirty at dispatchMouseEvent() invocation above. |
2236 // Unless distribution is updated, commonAncestor would hit ASSERT. | 2289 // Unless distribution is updated, commonAncestor would hit ASSERT. |
2237 // Both m_clickNode and currentHitTest.innerNode()) don't need to be updated | 2290 // Both m_clickNode and currentHitTest.innerNode()) don't need to be updated |
2238 // because commonAncestor() will exit early if their documents are d ifferent. | 2291 // because commonAncestor() will exit early if their documents are d ifferent. |
2239 m_clickNode->updateDistribution(); | 2292 m_clickNode->updateDistribution(); |
2240 Node* clickTargetNode = currentHitTest.innerNode()->commonAncestor(* m_clickNode, parentForClickEvent); | 2293 Node* clickTargetNode = currentHitTest.innerNode()->commonAncestor(* m_clickNode, parentForClickEvent); |
2241 swallowClickEvent = dispatchMouseEvent(EventTypeNames::click, clickT argetNode, gestureEvent.tapCount(), fakeMouseUp); | 2294 clickEventResult = dispatchMouseEvent(EventTypeNames::click, clickTa rgetNode, gestureEvent.tapCount(), fakeMouseUp); |
2242 } | 2295 } |
2243 m_clickNode = nullptr; | 2296 m_clickNode = nullptr; |
2244 } | 2297 } |
2245 | 2298 |
2246 if (!swallowMouseUpEvent) | 2299 if (mouseUpEventResult == WebInputEventResult::NotHandled) |
2247 swallowMouseUpEvent = handleMouseReleaseEvent(MouseEventWithHitTestResul ts(fakeMouseUp, currentHitTest)); | 2300 mouseUpEventResult = handleMouseReleaseEvent(MouseEventWithHitTestResult s(fakeMouseUp, currentHitTest)); |
2248 | 2301 |
2249 bool swallowed = swallowMouseDownEvent | swallowMouseUpEvent | swallowClickE vent; | 2302 WebInputEventResult eventResult = mergeEventResult(mergeEventResult(mouseDow nEventResult, mouseUpEventResult), clickEventResult); |
2250 if (!swallowed && tappedNode && m_frame->page()) { | 2303 if (eventResult == WebInputEventResult::NotHandled && tappedNode && m_frame- >page()) { |
2251 bool domTreeChanged = preDispatchDomTreeVersion != m_frame->document()-> domTreeVersion(); | 2304 bool domTreeChanged = preDispatchDomTreeVersion != m_frame->document()-> domTreeVersion(); |
2252 bool styleChanged = preDispatchStyleVersion != m_frame->document()->styl eVersion(); | 2305 bool styleChanged = preDispatchStyleVersion != m_frame->document()->styl eVersion(); |
2253 | 2306 |
2254 IntPoint tappedPositionInViewport = m_frame->page()->frameHost().visualV iewport().rootFrameToViewport(tappedPosition); | 2307 IntPoint tappedPositionInViewport = m_frame->page()->frameHost().visualV iewport().rootFrameToViewport(tappedPosition); |
2255 m_frame->chromeClient().showUnhandledTapUIIfNeeded(tappedPositionInViewp ort, tappedNode.get(), domTreeChanged || styleChanged); | 2308 m_frame->chromeClient().showUnhandledTapUIIfNeeded(tappedPositionInViewp ort, tappedNode.get(), domTreeChanged || styleChanged); |
2256 } | 2309 } |
2257 return swallowed; | 2310 return eventResult; |
2258 } | 2311 } |
2259 | 2312 |
2260 bool EventHandler::handleGestureLongPress(const GestureEventWithHitTestResults& targetedEvent) | 2313 WebInputEventResult EventHandler::handleGestureLongPress(const GestureEventWithH itTestResults& targetedEvent) |
2261 { | 2314 { |
2262 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 2315 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
2263 IntPoint adjustedPoint = gestureEvent.position(); | 2316 IntPoint adjustedPoint = gestureEvent.position(); |
2264 | 2317 |
2265 unsigned modifiers = gestureEvent.modifiers(); | 2318 unsigned modifiers = gestureEvent.modifiers(); |
2266 | 2319 |
2267 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests here (re-using the | 2320 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests here (re-using the |
2268 // supplied HitTestResult), but that will require some overhaul of the touch drag-and-drop code | 2321 // supplied HitTestResult), but that will require some overhaul of the touch drag-and-drop code |
2269 // and LongPress is such a special scenario that it's unlikely to matter muc h in practice. | 2322 // and LongPress is such a special scenario that it's unlikely to matter muc h in practice. |
2270 | 2323 |
2271 m_longTapShouldInvokeContextMenu = false; | 2324 m_longTapShouldInvokeContextMenu = false; |
2272 if (m_frame->settings() && m_frame->settings()->touchDragDropEnabled() && m_ frame->view()) { | 2325 if (m_frame->settings() && m_frame->settings()->touchDragDropEnabled() && m_ frame->view()) { |
2273 PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosi tion(), LeftButton, PlatformEvent::MousePressed, 1, | 2326 PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosi tion(), LeftButton, PlatformEvent::MousePressed, 1, |
2274 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef tButtonDown), | 2327 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef tButtonDown), |
2275 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime()); | 2328 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime()); |
2276 m_mouseDown = mouseDownEvent; | 2329 m_mouseDown = mouseDownEvent; |
2277 | 2330 |
2278 PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosi tion(), LeftButton, PlatformEvent::MouseMoved, 1, | 2331 PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosi tion(), LeftButton, PlatformEvent::MouseMoved, 1, |
2279 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef tButtonDown), | 2332 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef tButtonDown), |
2280 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime()); | 2333 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime()); |
2281 HitTestRequest request(HitTestRequest::ReadOnly); | 2334 HitTestRequest request(HitTestRequest::ReadOnly); |
2282 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragE vent); | 2335 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragE vent); |
2283 m_mouseDownMayStartDrag = true; | 2336 m_mouseDownMayStartDrag = true; |
2284 dragState().m_dragSrc = nullptr; | 2337 dragState().m_dragSrc = nullptr; |
2285 m_mouseDownPos = m_frame->view()->rootFrameToContents(mouseDragEvent.pos ition()); | 2338 m_mouseDownPos = m_frame->view()->rootFrameToContents(mouseDragEvent.pos ition()); |
2286 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 2339 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
2287 if (handleDrag(mev, DragInitiator::Touch)) { | 2340 if (handleDrag(mev, DragInitiator::Touch)) { |
2288 m_longTapShouldInvokeContextMenu = true; | 2341 m_longTapShouldInvokeContextMenu = true; |
2289 return true; | 2342 return WebInputEventResult::HandledSystem; |
2290 } | 2343 } |
2291 } | 2344 } |
2292 | 2345 |
2293 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(gestureEvent.po sition()); | 2346 IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(gestureEvent.po sition()); |
2294 HitTestResult result = hitTestResultAtPoint(hitTestPoint); | 2347 HitTestResult result = hitTestResultAtPoint(hitTestPoint); |
2295 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 2348 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
2296 if (selectionController().handleGestureLongPress(gestureEvent, result)) { | 2349 if (selectionController().handleGestureLongPress(gestureEvent, result)) { |
2297 focusDocumentView(); | 2350 focusDocumentView(); |
2298 return true; | 2351 return WebInputEventResult::HandledSystem; |
2299 } | 2352 } |
2300 | 2353 |
2301 return sendContextMenuEventForGesture(targetedEvent); | 2354 return sendContextMenuEventForGesture(targetedEvent); |
2302 } | 2355 } |
2303 | 2356 |
2304 bool EventHandler::handleGestureLongTap(const GestureEventWithHitTestResults& ta rgetedEvent) | 2357 WebInputEventResult EventHandler::handleGestureLongTap(const GestureEventWithHit TestResults& targetedEvent) |
2305 { | 2358 { |
2306 #if !OS(ANDROID) | 2359 #if !OS(ANDROID) |
2307 if (m_longTapShouldInvokeContextMenu) { | 2360 if (m_longTapShouldInvokeContextMenu) { |
2308 m_longTapShouldInvokeContextMenu = false; | 2361 m_longTapShouldInvokeContextMenu = false; |
2309 return sendContextMenuEventForGesture(targetedEvent); | 2362 return sendContextMenuEventForGesture(targetedEvent); |
2310 } | 2363 } |
2311 #endif | 2364 #endif |
2312 return false; | 2365 return WebInputEventResult::NotHandled; |
2313 } | 2366 } |
2314 | 2367 |
2315 bool EventHandler::handleScrollGestureOnResizer(Node* eventTarget, const Platfor mGestureEvent& gestureEvent) | 2368 bool EventHandler::handleScrollGestureOnResizer(Node* eventTarget, const Platfor mGestureEvent& gestureEvent) |
2316 { | 2369 { |
2317 if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) { | 2370 if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) { |
2318 PaintLayer* layer = eventTarget->layoutObject() ? eventTarget->layoutObj ect()->enclosingLayer() : nullptr; | 2371 PaintLayer* layer = eventTarget->layoutObject() ? eventTarget->layoutObj ect()->enclosingLayer() : nullptr; |
2319 IntPoint p = m_frame->view()->rootFrameToContents(gestureEvent.position( )); | 2372 IntPoint p = m_frame->view()->rootFrameToContents(gestureEvent.position( )); |
2320 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint InResizeControl(p, ResizerForTouch)) { | 2373 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint InResizeControl(p, ResizerForTouch)) { |
2321 m_resizeScrollableArea = layer->scrollableArea(); | 2374 m_resizeScrollableArea = layer->scrollableArea(); |
2322 m_resizeScrollableArea->setInResizeMode(true); | 2375 m_resizeScrollableArea->setInResizeMode(true); |
2323 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p)); | 2376 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p)); |
2324 return true; | 2377 return true; |
2325 } | 2378 } |
2326 } else if (gestureEvent.type() == PlatformEvent::GestureScrollUpdate) { | 2379 } else if (gestureEvent.type() == PlatformEvent::GestureScrollUpdate) { |
2327 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { | 2380 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { |
2328 m_resizeScrollableArea->resize(gestureEvent, m_offsetFromResizeCorne r); | 2381 m_resizeScrollableArea->resize(gestureEvent, m_offsetFromResizeCorne r); |
2329 return true; | 2382 return true; |
2330 } | 2383 } |
2331 } else if (gestureEvent.type() == PlatformEvent::GestureScrollEnd) { | 2384 } else if (gestureEvent.type() == PlatformEvent::GestureScrollEnd) { |
2332 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { | 2385 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { |
2333 m_resizeScrollableArea->setInResizeMode(false); | 2386 m_resizeScrollableArea->setInResizeMode(false); |
2334 m_resizeScrollableArea = nullptr; | 2387 m_resizeScrollableArea = nullptr; |
2335 return false; | 2388 return false; |
2336 } | 2389 } |
2337 } | 2390 } |
2338 | 2391 |
2339 return false; | 2392 return false; |
2340 } | 2393 } |
2341 | 2394 |
2342 bool EventHandler::passScrollGestureEventToWidget(const PlatformGestureEvent& ge stureEvent, LayoutObject* layoutObject) | 2395 WebInputEventResult EventHandler::passScrollGestureEventToWidget(const PlatformG estureEvent& gestureEvent, LayoutObject* layoutObject) |
2343 { | 2396 { |
2344 ASSERT(gestureEvent.isScrollEvent()); | 2397 ASSERT(gestureEvent.isScrollEvent()); |
2345 | 2398 |
2346 if (!m_lastGestureScrollOverWidget) | 2399 if (!m_lastGestureScrollOverWidget || !layoutObject || !layoutObject->isLayo utPart()) |
2347 return false; | 2400 return WebInputEventResult::NotHandled; |
2348 | |
2349 if (!layoutObject || !layoutObject->isLayoutPart()) | |
2350 return false; | |
2351 | 2401 |
2352 Widget* widget = toLayoutPart(layoutObject)->widget(); | 2402 Widget* widget = toLayoutPart(layoutObject)->widget(); |
2353 | 2403 |
2354 if (!widget || !widget->isFrameView()) | 2404 if (!widget || !widget->isFrameView()) |
2355 return false; | 2405 return WebInputEventResult::NotHandled; |
2356 | 2406 |
2357 return toFrameView(widget)->frame().eventHandler().handleGestureScrollEvent( gestureEvent); | 2407 return toFrameView(widget)->frame().eventHandler().handleGestureScrollEvent( gestureEvent); |
2358 } | 2408 } |
2359 | 2409 |
2360 bool EventHandler::handleGestureScrollEnd(const PlatformGestureEvent& gestureEve nt) | 2410 WebInputEventResult EventHandler::handleGestureScrollEnd(const PlatformGestureEv ent& gestureEvent) |
2361 { | 2411 { |
2362 RefPtrWillBeRawPtr<Node> node = m_scrollGestureHandlingNode; | 2412 RefPtrWillBeRawPtr<Node> node = m_scrollGestureHandlingNode; |
2363 | 2413 |
2364 if (node) { | 2414 if (node) { |
2365 passScrollGestureEventToWidget(gestureEvent, node->layoutObject()); | 2415 passScrollGestureEventToWidget(gestureEvent, node->layoutObject()); |
2366 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { | 2416 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { |
2367 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create( | 2417 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create( |
2368 0, 0, 0, 0, 0, gestureEvent.inertial(), /* isBeginning */ | 2418 0, 0, 0, 0, 0, gestureEvent.inertial(), /* isBeginning */ |
2369 false, /* isEnding */ true, /* fromUserInput */ true); | 2419 false, /* isEnding */ true, /* fromUserInput */ true); |
2370 customizedScroll(*node.get(), *scrollState); | 2420 customizedScroll(*node.get(), *scrollState); |
2371 } | 2421 } |
2372 } | 2422 } |
2373 | 2423 |
2374 clearGestureScrollState(); | 2424 clearGestureScrollState(); |
2375 return false; | 2425 return WebInputEventResult::NotHandled; |
2376 } | 2426 } |
2377 | 2427 |
2378 bool EventHandler::handleGestureScrollBegin(const PlatformGestureEvent& gestureE vent) | 2428 WebInputEventResult EventHandler::handleGestureScrollBegin(const PlatformGesture Event& gestureEvent) |
2379 { | 2429 { |
2380 Document* document = m_frame->document(); | 2430 Document* document = m_frame->document(); |
2381 if (!document->layoutView()) | 2431 if (!document->layoutView()) |
2382 return false; | 2432 return WebInputEventResult::NotHandled; |
2383 | 2433 |
2384 FrameView* view = m_frame->view(); | 2434 FrameView* view = m_frame->view(); |
2385 if (!view) | 2435 if (!view) |
2386 return false; | 2436 return WebInputEventResult::NotHandled; |
2387 | 2437 |
2388 // If there's no layoutObject on the node, send the event to the nearest anc estor with a layoutObject. | 2438 // If there's no layoutObject on the node, send the event to the nearest anc estor with a layoutObject. |
2389 // Needed for <option> and <optgroup> elements so we can touch scroll <selec t>s | 2439 // Needed for <option> and <optgroup> elements so we can touch scroll <selec t>s |
2390 while (m_scrollGestureHandlingNode && !m_scrollGestureHandlingNode->layoutOb ject()) | 2440 while (m_scrollGestureHandlingNode && !m_scrollGestureHandlingNode->layoutOb ject()) |
2391 m_scrollGestureHandlingNode = m_scrollGestureHandlingNode->parentOrShado wHostNode(); | 2441 m_scrollGestureHandlingNode = m_scrollGestureHandlingNode->parentOrShado wHostNode(); |
2392 | 2442 |
2393 if (!m_scrollGestureHandlingNode) { | 2443 if (!m_scrollGestureHandlingNode) { |
2394 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) | 2444 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) |
2395 m_scrollGestureHandlingNode = m_frame->document()->documentElement() ; | 2445 m_scrollGestureHandlingNode = m_frame->document()->documentElement() ; |
2396 else | 2446 else |
2397 return false; | 2447 return WebInputEventResult::NotHandled; |
2398 } | 2448 } |
2399 ASSERT(m_scrollGestureHandlingNode); | 2449 ASSERT(m_scrollGestureHandlingNode); |
2400 | 2450 |
2401 passScrollGestureEventToWidget(gestureEvent, m_scrollGestureHandlingNode->la youtObject()); | 2451 passScrollGestureEventToWidget(gestureEvent, m_scrollGestureHandlingNode->la youtObject()); |
2402 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { | 2452 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { |
2403 m_currentScrollChain.clear(); | 2453 m_currentScrollChain.clear(); |
2404 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create( | 2454 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create( |
2405 0, 0, 0, 0, 0, /* inInertialPhase */ false, /* isBeginning */ | 2455 0, 0, 0, 0, 0, /* inInertialPhase */ false, /* isBeginning */ |
2406 true, /* isEnding */ false, /* fromUserInput */ true); | 2456 true, /* isEnding */ false, /* fromUserInput */ true); |
2407 customizedScroll(*m_scrollGestureHandlingNode.get(), *scrollState); | 2457 customizedScroll(*m_scrollGestureHandlingNode.get(), *scrollState); |
2408 } else { | 2458 } else { |
2409 if (m_frame->isMainFrame()) | 2459 if (m_frame->isMainFrame()) |
2410 m_frame->host()->topControls().scrollBegin(); | 2460 m_frame->host()->topControls().scrollBegin(); |
2411 } | 2461 } |
2412 return true; | 2462 return WebInputEventResult::HandledSystem; |
2413 } | 2463 } |
2414 | 2464 |
2415 void EventHandler::resetOverscroll(bool didScrollX, bool didScrollY) | 2465 void EventHandler::resetOverscroll(bool didScrollX, bool didScrollY) |
2416 { | 2466 { |
2417 if (didScrollX) | 2467 if (didScrollX) |
2418 m_accumulatedRootOverscroll.setWidth(0); | 2468 m_accumulatedRootOverscroll.setWidth(0); |
2419 if (didScrollY) | 2469 if (didScrollY) |
2420 m_accumulatedRootOverscroll.setHeight(0); | 2470 m_accumulatedRootOverscroll.setHeight(0); |
2421 } | 2471 } |
2422 | 2472 |
(...skipping 11 matching lines...) Expand all Loading... | |
2434 { | 2484 { |
2435 FloatSize unusedDelta(scrollResult.unusedScrollDeltaX, scrollResult.unusedSc rollDeltaY); | 2485 FloatSize unusedDelta(scrollResult.unusedScrollDeltaX, scrollResult.unusedSc rollDeltaY); |
2436 unusedDelta = adjustOverscoll(unusedDelta); | 2486 unusedDelta = adjustOverscoll(unusedDelta); |
2437 resetOverscroll(scrollResult.didScrollX, scrollResult.didScrollY); | 2487 resetOverscroll(scrollResult.didScrollX, scrollResult.didScrollY); |
2438 if (unusedDelta != FloatSize()) { | 2488 if (unusedDelta != FloatSize()) { |
2439 m_accumulatedRootOverscroll += unusedDelta; | 2489 m_accumulatedRootOverscroll += unusedDelta; |
2440 m_frame->chromeClient().didOverscroll(unusedDelta, m_accumulatedRootOver scroll, position, velocity); | 2490 m_frame->chromeClient().didOverscroll(unusedDelta, m_accumulatedRootOver scroll, position, velocity); |
2441 } | 2491 } |
2442 } | 2492 } |
2443 | 2493 |
2444 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture Event) | 2494 WebInputEventResult EventHandler::handleGestureScrollUpdate(const PlatformGestur eEvent& gestureEvent) |
2445 { | 2495 { |
2446 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); | 2496 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); |
2447 | 2497 |
2448 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY()); | 2498 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY()); |
2449 if (delta.isZero()) | 2499 if (delta.isZero()) |
2450 return false; | 2500 return WebInputEventResult::NotHandled; |
2451 | 2501 |
2452 Node* node = m_scrollGestureHandlingNode.get(); | 2502 Node* node = m_scrollGestureHandlingNode.get(); |
2453 if (node) { | 2503 if (node) { |
2454 LayoutObject* layoutObject = node->layoutObject(); | 2504 LayoutObject* layoutObject = node->layoutObject(); |
2455 if (!layoutObject) | 2505 if (!layoutObject) |
2456 return false; | 2506 return WebInputEventResult::NotHandled; |
2457 | 2507 |
2458 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 2508 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
2459 | 2509 |
2460 Node* stopNode = nullptr; | 2510 Node* stopNode = nullptr; |
2461 | 2511 |
2462 // Try to send the event to the correct view. | 2512 // Try to send the event to the correct view. |
2463 if (passScrollGestureEventToWidget(gestureEvent, layoutObject)) { | 2513 WebInputEventResult result = passScrollGestureEventToWidget(gestureEvent , layoutObject); |
2514 if (result != WebInputEventResult::NotHandled) { | |
2464 if (gestureEvent.preventPropagation() | 2515 if (gestureEvent.preventPropagation() |
2465 && !RuntimeEnabledFeatures::scrollCustomizationEnabled()) { | 2516 && !RuntimeEnabledFeatures::scrollCustomizationEnabled()) { |
2466 // This is an optimization which doesn't apply with | 2517 // This is an optimization which doesn't apply with |
2467 // scroll customization enabled. | 2518 // scroll customization enabled. |
2468 m_previousGestureScrolledNode = m_scrollGestureHandlingNode; | 2519 m_previousGestureScrolledNode = m_scrollGestureHandlingNode; |
2469 } | 2520 } |
2470 // FIXME: we should allow simultaneous scrolling of nested | 2521 // FIXME: we should allow simultaneous scrolling of nested |
2471 // iframes along perpendicular axes. See crbug.com/466991. | 2522 // iframes along perpendicular axes. See crbug.com/466991. |
2472 m_deltaConsumedForScrollSequence = true; | 2523 m_deltaConsumedForScrollSequence = true; |
2473 return true; | 2524 return result; |
2474 } | 2525 } |
2475 | 2526 |
2476 bool scrolled = false; | 2527 bool scrolled = false; |
2477 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { | 2528 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { |
2478 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create( | 2529 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create( |
2479 gestureEvent.deltaX(), gestureEvent.deltaY(), | 2530 gestureEvent.deltaX(), gestureEvent.deltaY(), |
2480 0, gestureEvent.velocityX(), gestureEvent.velocityY(), | 2531 0, gestureEvent.velocityX(), gestureEvent.velocityY(), |
2481 gestureEvent.inertial(), /* isBeginning */ | 2532 gestureEvent.inertial(), /* isBeginning */ |
2482 false, /* isEnding */ false, /* fromUserInput */ true, | 2533 false, /* isEnding */ false, /* fromUserInput */ true, |
2483 !gestureEvent.preventPropagation(), m_deltaConsumedForScrollSequ ence); | 2534 !gestureEvent.preventPropagation(), m_deltaConsumedForScrollSequ ence); |
(...skipping 24 matching lines...) Expand all Loading... | |
2508 bool verticalScroll = result.didScroll; | 2559 bool verticalScroll = result.didScroll; |
2509 scrolled = horizontalScroll || verticalScroll; | 2560 scrolled = horizontalScroll || verticalScroll; |
2510 | 2561 |
2511 if (gestureEvent.preventPropagation()) | 2562 if (gestureEvent.preventPropagation()) |
2512 m_previousGestureScrolledNode = stopNode; | 2563 m_previousGestureScrolledNode = stopNode; |
2513 | 2564 |
2514 resetOverscroll(horizontalScroll, verticalScroll); | 2565 resetOverscroll(horizontalScroll, verticalScroll); |
2515 } | 2566 } |
2516 if (scrolled) { | 2567 if (scrolled) { |
2517 setFrameWasScrolledByUser(); | 2568 setFrameWasScrolledByUser(); |
2518 return true; | 2569 return WebInputEventResult::HandledSystem; |
2519 } | 2570 } |
2520 } | 2571 } |
2521 | 2572 |
2522 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) | 2573 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) |
2523 return false; | 2574 return WebInputEventResult::NotHandled; |
2524 | 2575 |
2525 // Try to scroll the frame view. | 2576 // Try to scroll the frame view. |
2526 ScrollResult scrollResult = m_frame->applyScrollDelta(delta, false); | 2577 ScrollResult scrollResult = m_frame->applyScrollDelta(delta, false); |
2527 FloatPoint position = FloatPoint(gestureEvent.position().x(), gestureEvent.p osition().y()); | 2578 FloatPoint position = FloatPoint(gestureEvent.position().x(), gestureEvent.p osition().y()); |
2528 FloatSize velocity = FloatSize(gestureEvent.velocityX(), gestureEvent.veloci tyY()); | 2579 FloatSize velocity = FloatSize(gestureEvent.velocityX(), gestureEvent.veloci tyY()); |
2529 handleOverscroll(scrollResult, position, velocity); | 2580 handleOverscroll(scrollResult, position, velocity); |
2530 if (scrollResult.didScroll()) { | 2581 if (scrollResult.didScroll()) { |
2531 setFrameWasScrolledByUser(); | 2582 setFrameWasScrolledByUser(); |
2532 return true; | 2583 return WebInputEventResult::HandledSystem; |
2533 } | 2584 } |
2534 | 2585 |
2535 return false; | 2586 return WebInputEventResult::NotHandled; |
2536 } | 2587 } |
2537 | 2588 |
2538 void EventHandler::clearGestureScrollState() | 2589 void EventHandler::clearGestureScrollState() |
2539 { | 2590 { |
2540 m_scrollGestureHandlingNode = nullptr; | 2591 m_scrollGestureHandlingNode = nullptr; |
2541 m_previousGestureScrolledNode = nullptr; | 2592 m_previousGestureScrolledNode = nullptr; |
2542 m_deltaConsumedForScrollSequence = false; | 2593 m_deltaConsumedForScrollSequence = false; |
2543 m_currentScrollChain.clear(); | 2594 m_currentScrollChain.clear(); |
2544 m_accumulatedRootOverscroll = FloatSize(); | 2595 m_accumulatedRootOverscroll = FloatSize(); |
2545 } | 2596 } |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2863 } | 2914 } |
2864 | 2915 |
2865 // Update the hit-test result to be a point-based result instead of a rect-b ased result. | 2916 // Update the hit-test result to be a point-based result instead of a rect-b ased result. |
2866 // FIXME: We should do this even when no candidate matches the node filter. crbug.com/398914 | 2917 // FIXME: We should do this even when no candidate matches the node filter. crbug.com/398914 |
2867 if (adjusted) { | 2918 if (adjusted) { |
2868 hitTestResult->resolveRectBasedTest(adjustedNode, m_frame->view()->rootF rameToContents(adjustedPoint)); | 2919 hitTestResult->resolveRectBasedTest(adjustedNode, m_frame->view()->rootF rameToContents(adjustedPoint)); |
2869 gestureEvent->applyTouchAdjustment(adjustedPoint); | 2920 gestureEvent->applyTouchAdjustment(adjustedPoint); |
2870 } | 2921 } |
2871 } | 2922 } |
2872 | 2923 |
2873 bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event, Node* o verrideTargetNode) | 2924 WebInputEventResult EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event, Node* overrideTargetNode) |
2874 { | 2925 { |
2875 FrameView* v = m_frame->view(); | 2926 FrameView* v = m_frame->view(); |
2876 if (!v) | 2927 if (!v) |
2877 return false; | 2928 return WebInputEventResult::NotHandled; |
2878 | 2929 |
2879 // Clear mouse press state to avoid initiating a drag while context menu is up. | 2930 // Clear mouse press state to avoid initiating a drag while context menu is up. |
2880 m_mousePressed = false; | 2931 m_mousePressed = false; |
2881 LayoutPoint positionInContents = v->rootFrameToContents(event.position()); | 2932 LayoutPoint positionInContents = v->rootFrameToContents(event.position()); |
2882 HitTestRequest request(HitTestRequest::Active); | 2933 HitTestRequest request(HitTestRequest::Active); |
2883 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re quest, positionInContents, event); | 2934 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re quest, positionInContents, event); |
2884 | 2935 |
2885 selectionController().sendContextMenuEvent(mev, positionInContents); | 2936 selectionController().sendContextMenuEvent(mev, positionInContents); |
2886 | 2937 |
2887 Node* targetNode = overrideTargetNode ? overrideTargetNode : mev.innerNode() ; | 2938 Node* targetNode = overrideTargetNode ? overrideTargetNode : mev.innerNode() ; |
2888 return dispatchMouseEvent(EventTypeNames::contextmenu, targetNode, 0, event) ; | 2939 return dispatchMouseEvent(EventTypeNames::contextmenu, targetNode, 0, event) ; |
2889 } | 2940 } |
2890 | 2941 |
2891 bool EventHandler::sendContextMenuEventForKey(Element* overrideTargetElement) | 2942 WebInputEventResult EventHandler::sendContextMenuEventForKey(Element* overrideTa rgetElement) |
2892 { | 2943 { |
2893 FrameView* view = m_frame->view(); | 2944 FrameView* view = m_frame->view(); |
2894 if (!view) | 2945 if (!view) |
2895 return false; | 2946 return WebInputEventResult::NotHandled; |
2896 | 2947 |
2897 Document* doc = m_frame->document(); | 2948 Document* doc = m_frame->document(); |
2898 if (!doc) | 2949 if (!doc) |
2899 return false; | 2950 return WebInputEventResult::NotHandled; |
2900 | 2951 |
2901 // Clear mouse press state to avoid initiating a drag while context menu is up. | 2952 // Clear mouse press state to avoid initiating a drag while context menu is up. |
2902 m_mousePressed = false; | 2953 m_mousePressed = false; |
2903 | 2954 |
2904 static const int kContextMenuMargin = 1; | 2955 static const int kContextMenuMargin = 1; |
2905 | 2956 |
2906 #if OS(WIN) | 2957 #if OS(WIN) |
2907 int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); | 2958 int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); |
2908 #else | 2959 #else |
2909 int rightAligned = 0; | 2960 int rightAligned = 0; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2953 // This is required for web compatibility. | 3004 // This is required for web compatibility. |
2954 PlatformEvent::Type eventType = PlatformEvent::MousePressed; | 3005 PlatformEvent::Type eventType = PlatformEvent::MousePressed; |
2955 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) | 3006 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) |
2956 eventType = PlatformEvent::MouseReleased; | 3007 eventType = PlatformEvent::MouseReleased; |
2957 | 3008 |
2958 PlatformMouseEvent mouseEvent(locationInRootFrame, globalPosition, RightButt on, eventType, 1, PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistin guishable, WTF::monotonicallyIncreasingTime()); | 3009 PlatformMouseEvent mouseEvent(locationInRootFrame, globalPosition, RightButt on, eventType, 1, PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistin guishable, WTF::monotonicallyIncreasingTime()); |
2959 | 3010 |
2960 return sendContextMenuEvent(mouseEvent, overrideTargetElement); | 3011 return sendContextMenuEvent(mouseEvent, overrideTargetElement); |
2961 } | 3012 } |
2962 | 3013 |
2963 bool EventHandler::sendContextMenuEventForGesture(const GestureEventWithHitTestR esults& targetedEvent) | 3014 WebInputEventResult EventHandler::sendContextMenuEventForGesture(const GestureEv entWithHitTestResults& targetedEvent) |
2964 { | 3015 { |
2965 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 3016 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
2966 unsigned modifiers = gestureEvent.modifiers(); | 3017 unsigned modifiers = gestureEvent.modifiers(); |
2967 | 3018 |
2968 // Send MouseMoved event prior to handling (https://crbug.com/485290). | 3019 // Send MouseMoved event prior to handling (https://crbug.com/485290). |
2969 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(), | 3020 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(), |
2970 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, | 3021 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, |
2971 static_cast<PlatformEvent::Modifiers>(modifiers), | 3022 static_cast<PlatformEvent::Modifiers>(modifiers), |
2972 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 3023 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
2973 dispatchMouseEvent(EventTypeNames::mousemove, targetedEvent.hitTestResult(). innerNode(), 0, fakeMouseMove); | 3024 dispatchMouseEvent(EventTypeNames::mousemove, targetedEvent.hitTestResult(). innerNode(), 0, fakeMouseMove); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3141 if ((evt.modifiers() & (PlatformEvent::KeyModifiers & ~PlatformEvent::ShiftK ey)) != accessKeyModifiers()) | 3192 if ((evt.modifiers() & (PlatformEvent::KeyModifiers & ~PlatformEvent::ShiftK ey)) != accessKeyModifiers()) |
3142 return false; | 3193 return false; |
3143 String key = evt.unmodifiedText(); | 3194 String key = evt.unmodifiedText(); |
3144 Element* elem = m_frame->document()->getElementByAccessKey(key.lower()); | 3195 Element* elem = m_frame->document()->getElementByAccessKey(key.lower()); |
3145 if (!elem) | 3196 if (!elem) |
3146 return false; | 3197 return false; |
3147 elem->accessKeyAction(false); | 3198 elem->accessKeyAction(false); |
3148 return true; | 3199 return true; |
3149 } | 3200 } |
3150 | 3201 |
3151 bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent) | 3202 WebInputEventResult EventHandler::keyEvent(const PlatformKeyboardEvent& initialK eyEvent) |
3152 { | 3203 { |
3153 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 3204 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
3154 m_frame->chromeClient().setToolTip(String(), LTR); | 3205 m_frame->chromeClient().setToolTip(String(), LTR); |
3155 | 3206 |
3156 if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) | 3207 if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) |
3157 capsLockStateMayHaveChanged(); | 3208 capsLockStateMayHaveChanged(); |
3158 | 3209 |
3159 #if OS(WIN) | 3210 #if OS(WIN) |
3160 if (panScrollInProgress()) { | 3211 if (panScrollInProgress()) { |
3161 // If a key is pressed while the panScroll is in progress then we want t o stop | 3212 // If a key is pressed while the panScroll is in progress then we want t o stop |
3162 if (initialKeyEvent.type() == PlatformEvent::KeyDown || initialKeyEvent. type() == PlatformEvent::RawKeyDown) | 3213 if (initialKeyEvent.type() == PlatformEvent::KeyDown || initialKeyEvent. type() == PlatformEvent::RawKeyDown) |
3163 stopAutoscroll(); | 3214 stopAutoscroll(); |
3164 | 3215 |
3165 // If we were in panscroll mode, we swallow the key event | 3216 // If we were in panscroll mode, we swallow the key event |
3166 return true; | 3217 return WebInputEventResult::HandledSuppressed; |
3167 } | 3218 } |
3168 #endif | 3219 #endif |
3169 | 3220 |
3170 // Check for cases where we are too early for events -- possible unmatched k ey up | 3221 // Check for cases where we are too early for events -- possible unmatched k ey up |
3171 // from pressing return in the location bar. | 3222 // from pressing return in the location bar. |
3172 RefPtrWillBeRawPtr<Node> node = eventTargetNodeForDocument(m_frame->document ()); | 3223 RefPtrWillBeRawPtr<Node> node = eventTargetNodeForDocument(m_frame->document ()); |
3173 if (!node) | 3224 if (!node) |
3174 return false; | 3225 return WebInputEventResult::NotHandled; |
3175 | 3226 |
3176 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | 3227 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); |
3177 | 3228 |
3178 // In IE, access keys are special, they are handled after default keydown pr ocessing, but cannot be canceled - this is hard to match. | 3229 // In IE, access keys are special, they are handled after default keydown pr ocessing, but cannot be canceled - this is hard to match. |
3179 // On Mac OS X, we process them before dispatching keydown, as the default k eydown handler implements Emacs key bindings, which may conflict | 3230 // On Mac OS X, we process them before dispatching keydown, as the default k eydown handler implements Emacs key bindings, which may conflict |
3180 // with access keys. Then we dispatch keydown, but suppress its default hand ling. | 3231 // with access keys. Then we dispatch keydown, but suppress its default hand ling. |
3181 // On Windows, WebKit explicitly calls handleAccessKey() instead of dispatch ing a keypress event for WM_SYSCHAR messages. | 3232 // On Windows, WebKit explicitly calls handleAccessKey() instead of dispatch ing a keypress event for WM_SYSCHAR messages. |
3182 // Other platforms currently match either Mac or Windows behavior, depending on whether they send combined KeyDown events. | 3233 // Other platforms currently match either Mac or Windows behavior, depending on whether they send combined KeyDown events. |
3183 bool matchedAnAccessKey = false; | 3234 bool matchedAnAccessKey = false; |
3184 if (initialKeyEvent.type() == PlatformEvent::KeyDown) | 3235 if (initialKeyEvent.type() == PlatformEvent::KeyDown) |
3185 matchedAnAccessKey = handleAccessKey(initialKeyEvent); | 3236 matchedAnAccessKey = handleAccessKey(initialKeyEvent); |
3186 | 3237 |
3187 // FIXME: it would be fair to let an input method handle KeyUp events before DOM dispatch. | 3238 // FIXME: it would be fair to let an input method handle KeyUp events before DOM dispatch. |
3188 if (initialKeyEvent.type() == PlatformEvent::KeyUp || initialKeyEvent.type() == PlatformEvent::Char) | 3239 if (initialKeyEvent.type() == PlatformEvent::KeyUp || initialKeyEvent.type() == PlatformEvent::Char) { |
3189 return !node->dispatchKeyEvent(initialKeyEvent); | 3240 RefPtrWillBeRawPtr<KeyboardEvent> domEvent = KeyboardEvent::create(initi alKeyEvent, m_frame->document()->domWindow()); |
3241 | |
3242 bool dispatchResult = node->dispatchEvent(domEvent); | |
3243 return eventToEventResult(domEvent, dispatchResult); | |
3244 } | |
3190 | 3245 |
3191 PlatformKeyboardEvent keyDownEvent = initialKeyEvent; | 3246 PlatformKeyboardEvent keyDownEvent = initialKeyEvent; |
3192 if (keyDownEvent.type() != PlatformEvent::RawKeyDown) | 3247 if (keyDownEvent.type() != PlatformEvent::RawKeyDown) |
3193 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown); | 3248 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown); |
3194 RefPtrWillBeRawPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEve nt, m_frame->document()->domWindow()); | 3249 RefPtrWillBeRawPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEve nt, m_frame->document()->domWindow()); |
3195 if (matchedAnAccessKey) | 3250 if (matchedAnAccessKey) |
3196 keydown->setDefaultPrevented(true); | 3251 keydown->setDefaultPrevented(true); |
3197 keydown->setTarget(node); | 3252 keydown->setTarget(node); |
3198 | 3253 |
3199 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown) { | 3254 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown) { |
3200 node->dispatchEvent(keydown); | 3255 if (!node->dispatchEvent(keydown)) |
3256 return eventToEventResult(keydown, false); | |
3201 // If frame changed as a result of keydown dispatch, then return true to avoid sending a subsequent keypress message to the new frame. | 3257 // If frame changed as a result of keydown dispatch, then return true to avoid sending a subsequent keypress message to the new frame. |
3202 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page() ->focusController().focusedOrMainFrame(); | 3258 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page() ->focusController().focusedOrMainFrame(); |
3203 return keydown->defaultHandled() || keydown->defaultPrevented() || chang edFocusedFrame; | 3259 if (changedFocusedFrame) |
3260 return WebInputEventResult::HandledSystem; | |
3261 return WebInputEventResult::NotHandled; | |
3204 } | 3262 } |
3205 | 3263 |
3206 node->dispatchEvent(keydown); | 3264 if (!node->dispatchEvent(keydown)) |
3265 return eventToEventResult(keydown, false); | |
3207 // If frame changed as a result of keydown dispatch, then return early to av oid sending a subsequent keypress message to the new frame. | 3266 // If frame changed as a result of keydown dispatch, then return early to av oid sending a subsequent keypress message to the new frame. |
3208 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->fo cusController().focusedOrMainFrame(); | 3267 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->fo cusController().focusedOrMainFrame(); |
3209 bool keydownResult = keydown->defaultHandled() || keydown->defaultPrevented( ) || changedFocusedFrame; | 3268 if (changedFocusedFrame) |
3210 if (keydownResult) | 3269 return WebInputEventResult::HandledSystem; |
3211 return keydownResult; | |
3212 | 3270 |
3213 // Focus may have changed during keydown handling, so refetch node. | 3271 // Focus may have changed during keydown handling, so refetch node. |
3214 // But if we are dispatching a fake backward compatibility keypress, then we pretend that the keypress happened on the original node. | 3272 // But if we are dispatching a fake backward compatibility keypress, then we pretend that the keypress happened on the original node. |
3215 node = eventTargetNodeForDocument(m_frame->document()); | 3273 node = eventTargetNodeForDocument(m_frame->document()); |
3216 if (!node) | 3274 if (!node) |
3217 return false; | 3275 return WebInputEventResult::NotHandled; |
3218 | 3276 |
3219 PlatformKeyboardEvent keyPressEvent = initialKeyEvent; | 3277 PlatformKeyboardEvent keyPressEvent = initialKeyEvent; |
3220 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char); | 3278 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char); |
3221 if (keyPressEvent.text().isEmpty()) | 3279 if (keyPressEvent.text().isEmpty()) |
3222 return keydownResult; | 3280 return WebInputEventResult::NotHandled; |
3223 RefPtrWillBeRawPtr<KeyboardEvent> keypress = KeyboardEvent::create(keyPressE vent, m_frame->document()->domWindow()); | 3281 RefPtrWillBeRawPtr<KeyboardEvent> keypress = KeyboardEvent::create(keyPressE vent, m_frame->document()->domWindow()); |
3224 keypress->setTarget(node); | 3282 keypress->setTarget(node); |
3225 if (keydownResult) | 3283 bool dispatchResult = node->dispatchEvent(keypress); |
3226 keypress->setDefaultPrevented(true); | 3284 return eventToEventResult(keypress, dispatchResult); |
3227 node->dispatchEvent(keypress); | |
3228 | |
3229 return keydownResult || keypress->defaultPrevented() || keypress->defaultHan dled(); | |
3230 } | 3285 } |
3231 | 3286 |
3232 static WebFocusType focusDirectionForKey(const AtomicString& keyIdentifier) | 3287 static WebFocusType focusDirectionForKey(const AtomicString& keyIdentifier) |
3233 { | 3288 { |
3234 DEFINE_STATIC_LOCAL(AtomicString, Down, ("Down", AtomicString::ConstructFrom Literal)); | 3289 DEFINE_STATIC_LOCAL(AtomicString, Down, ("Down", AtomicString::ConstructFrom Literal)); |
3235 DEFINE_STATIC_LOCAL(AtomicString, Up, ("Up", AtomicString::ConstructFromLite ral)); | 3290 DEFINE_STATIC_LOCAL(AtomicString, Up, ("Up", AtomicString::ConstructFromLite ral)); |
3236 DEFINE_STATIC_LOCAL(AtomicString, Left, ("Left", AtomicString::ConstructFrom Literal)); | 3291 DEFINE_STATIC_LOCAL(AtomicString, Left, ("Left", AtomicString::ConstructFrom Literal)); |
3237 DEFINE_STATIC_LOCAL(AtomicString, Right, ("Right", AtomicString::ConstructFr omLiteral)); | 3292 DEFINE_STATIC_LOCAL(AtomicString, Right, ("Right", AtomicString::ConstructFr omLiteral)); |
3238 | 3293 |
3239 WebFocusType retVal = WebFocusTypeNone; | 3294 WebFocusType retVal = WebFocusTypeNone; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3337 } | 3392 } |
3338 | 3393 |
3339 void EventHandler::updateDragStateAfterEditDragIfNeeded(Element* rootEditableEle ment) | 3394 void EventHandler::updateDragStateAfterEditDragIfNeeded(Element* rootEditableEle ment) |
3340 { | 3395 { |
3341 // If inserting the dragged contents removed the drag source, we still want to fire dragend at the root editble element. | 3396 // If inserting the dragged contents removed the drag source, we still want to fire dragend at the root editble element. |
3342 if (dragState().m_dragSrc && !dragState().m_dragSrc->inDocument()) | 3397 if (dragState().m_dragSrc && !dragState().m_dragSrc->inDocument()) |
3343 dragState().m_dragSrc = rootEditableElement; | 3398 dragState().m_dragSrc = rootEditableElement; |
3344 } | 3399 } |
3345 | 3400 |
3346 // returns if we should continue "default processing", i.e., whether eventhandle r canceled | 3401 // returns if we should continue "default processing", i.e., whether eventhandle r canceled |
3347 bool EventHandler::dispatchDragSrcEvent(const AtomicString& eventType, const Pla tformMouseEvent& event) | 3402 WebInputEventResult EventHandler::dispatchDragSrcEvent(const AtomicString& event Type, const PlatformMouseEvent& event) |
3348 { | 3403 { |
3349 return dispatchDragEvent(eventType, dragState().m_dragSrc.get(), event, drag State().m_dragDataTransfer.get()); | 3404 return dispatchDragEvent(eventType, dragState().m_dragSrc.get(), event, drag State().m_dragDataTransfer.get()); |
3350 } | 3405 } |
3351 | 3406 |
3352 bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, DragIni tiator initiator) | 3407 bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, DragIni tiator initiator) |
3353 { | 3408 { |
3354 ASSERT(event.event().type() == PlatformEvent::MouseMoved); | 3409 ASSERT(event.event().type() == PlatformEvent::MouseMoved); |
3355 // Callers must protect the reference to FrameView, since this function may dispatch DOM | 3410 // Callers must protect the reference to FrameView, since this function may dispatch DOM |
3356 // events, causing page/FrameView to go away. | 3411 // events, causing page/FrameView to go away. |
3357 ASSERT(m_frame); | 3412 ASSERT(m_frame); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3426 DragController& dragController = m_frame->page()->dragController(); | 3481 DragController& dragController = m_frame->page()->dragController(); |
3427 if (!dragController.populateDragDataTransfer(m_frame, dragState(), m_mouseDo wnPos)) | 3482 if (!dragController.populateDragDataTransfer(m_frame, dragState(), m_mouseDo wnPos)) |
3428 return false; | 3483 return false; |
3429 | 3484 |
3430 // If dispatching dragstart brings about another mouse down -- one way | 3485 // If dispatching dragstart brings about another mouse down -- one way |
3431 // this will happen is if a DevTools user breaks within a dragstart | 3486 // this will happen is if a DevTools user breaks within a dragstart |
3432 // handler and then clicks on the suspended page -- the drag state is | 3487 // handler and then clicks on the suspended page -- the drag state is |
3433 // reset. Hence, need to check if this particular drag operation can | 3488 // reset. Hence, need to check if this particular drag operation can |
3434 // continue even if dispatchEvent() indicates no (direct) cancellation. | 3489 // continue even if dispatchEvent() indicates no (direct) cancellation. |
3435 // Do that by checking if m_dragSrc is still set. | 3490 // Do that by checking if m_dragSrc is still set. |
3436 m_mouseDownMayStartDrag = !dispatchDragSrcEvent(EventTypeNames::dragstart, m _mouseDown) | 3491 m_mouseDownMayStartDrag = dispatchDragSrcEvent(EventTypeNames::dragstart, m_ mouseDown) == WebInputEventResult::NotHandled |
3437 && !m_frame->selection().isInPasswordField() && dragState().m_dragSrc; | 3492 && !m_frame->selection().isInPasswordField() && dragState().m_dragSrc; |
3438 | 3493 |
3439 // Invalidate clipboard here against anymore pasteboard writing for security . The drag | 3494 // Invalidate clipboard here against anymore pasteboard writing for security . The drag |
3440 // image can still be changed as we drag, but not the pasteboard data. | 3495 // image can still be changed as we drag, but not the pasteboard data. |
3441 dragState().m_dragDataTransfer->setAccessPolicy(DataTransferImageWritable); | 3496 dragState().m_dragDataTransfer->setAccessPolicy(DataTransferImageWritable); |
3442 | 3497 |
3443 if (m_mouseDownMayStartDrag) { | 3498 if (m_mouseDownMayStartDrag) { |
3444 // Dispatching the event could cause Page to go away. Make sure it's sti ll valid before trying to use DragController. | 3499 // Dispatching the event could cause Page to go away. Make sure it's sti ll valid before trying to use DragController. |
3445 if (m_frame->page() && dragController.startDrag(m_frame, dragState(), ev ent.event(), m_mouseDownPos)) | 3500 if (m_frame->page() && dragController.startDrag(m_frame, dragState(), ev ent.event(), m_mouseDownPos)) |
3446 return true; | 3501 return true; |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3727 // instance represents. | 3782 // instance represents. |
3728 RefPtrWillBeMember<TouchList> m_touches; | 3783 RefPtrWillBeMember<TouchList> m_touches; |
3729 | 3784 |
3730 using EventTargetSet = WillBeHeapHashSet<RefPtrWillBeMember<EventTarget>>; | 3785 using EventTargetSet = WillBeHeapHashSet<RefPtrWillBeMember<EventTarget>>; |
3731 // Set of targets involved in m_touches. | 3786 // Set of targets involved in m_touches. |
3732 EventTargetSet m_targets; | 3787 EventTargetSet m_targets; |
3733 }; | 3788 }; |
3734 | 3789 |
3735 } // namespace | 3790 } // namespace |
3736 | 3791 |
3737 bool EventHandler::dispatchTouchEvents(const PlatformTouchEvent& event, | 3792 WebInputEventResult EventHandler::dispatchTouchEvents(const PlatformTouchEvent& event, |
3738 WillBeHeapVector<TouchInfo>& touchInfos, bool freshTouchEvents, bool allTouc hReleased) | 3793 WillBeHeapVector<TouchInfo>& touchInfos, bool freshTouchEvents, bool allTouc hReleased) |
3739 { | 3794 { |
3740 // Build up the lists to use for the 'touches', 'targetTouches' and | 3795 // Build up the lists to use for the 'touches', 'targetTouches' and |
3741 // 'changedTouches' attributes in the JS event. See | 3796 // 'changedTouches' attributes in the JS event. See |
3742 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these | 3797 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these |
3743 // lists fit together. | 3798 // lists fit together. |
3744 | 3799 |
3745 // Holds the complete set of touches on the screen. | 3800 // Holds the complete set of touches on the screen. |
3746 RefPtrWillBeRawPtr<TouchList> touches = TouchList::create(); | 3801 RefPtrWillBeRawPtr<TouchList> touches = TouchList::create(); |
3747 | 3802 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3799 changedTouches[pointState].m_touches = TouchList::create(); | 3854 changedTouches[pointState].m_touches = TouchList::create(); |
3800 changedTouches[pointState].m_touches->append(touch); | 3855 changedTouches[pointState].m_touches->append(touch); |
3801 changedTouches[pointState].m_targets.add(touchInfo.touchTarget); | 3856 changedTouches[pointState].m_targets.add(touchInfo.touchTarget); |
3802 } | 3857 } |
3803 } | 3858 } |
3804 if (allTouchReleased) { | 3859 if (allTouchReleased) { |
3805 m_touchSequenceDocument.clear(); | 3860 m_touchSequenceDocument.clear(); |
3806 m_touchSequenceUserGestureToken.clear(); | 3861 m_touchSequenceUserGestureToken.clear(); |
3807 } | 3862 } |
3808 | 3863 |
3809 bool swallowedEvent = false; | 3864 WebInputEventResult eventResult = WebInputEventResult::NotHandled; |
3810 | 3865 |
3811 // Now iterate through the changedTouches list and m_targets within it, send ing | 3866 // Now iterate through the changedTouches list and m_targets within it, send ing |
3812 // TouchEvents to the targets as required. | 3867 // TouchEvents to the targets as required. |
3813 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state ) { | 3868 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state ) { |
3814 if (!changedTouches[state].m_touches) | 3869 if (!changedTouches[state].m_touches) |
3815 continue; | 3870 continue; |
3816 | 3871 |
3817 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::State>(state))); | 3872 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::State>(state))); |
3818 for (const auto& eventTarget : changedTouches[state].m_targets) { | 3873 for (const auto& eventTarget : changedTouches[state].m_targets) { |
3819 EventTarget* touchEventTarget = eventTarget.get(); | 3874 EventTarget* touchEventTarget = eventTarget.get(); |
3820 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create( | 3875 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create( |
3821 touches.get(), touchesByTarget.get(touchEventTarget), changedTou ches[state].m_touches.get(), | 3876 touches.get(), touchesByTarget.get(touchEventTarget), changedTou ches[state].m_touches.get(), |
3822 eventName, touchEventTarget->toNode()->document().domWindow(), | 3877 eventName, touchEventTarget->toNode()->document().domWindow(), |
3823 event.modifiers(), event.cancelable(), event.causesScrollingIfUn canceled(), event.timestamp()); | 3878 event.modifiers(), event.cancelable(), event.causesScrollingIfUn canceled(), event.timestamp()); |
3824 | 3879 |
3825 touchEventTarget->dispatchEvent(touchEvent.get()); | 3880 bool dispatchResult = touchEventTarget->dispatchEvent(touchEvent.get ()); |
3826 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() || touchEvent->defaultHandled(); | 3881 eventResult = mergeEventResult(eventResult, eventToEventResult(touch Event, dispatchResult)); |
3827 } | 3882 } |
3828 } | 3883 } |
3829 | 3884 |
3830 return swallowedEvent; | 3885 return eventResult; |
3831 } | 3886 } |
3832 | 3887 |
3833 bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) | 3888 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt) |
3834 { | 3889 { |
3835 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); | 3890 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); |
3836 | 3891 |
3837 const Vector<PlatformTouchPoint>& points = event.touchPoints(); | 3892 const Vector<PlatformTouchPoint>& points = event.touchPoints(); |
3838 | 3893 |
3839 bool freshTouchEvents = true; | 3894 bool freshTouchEvents = true; |
3840 bool allTouchReleased = true; | 3895 bool allTouchReleased = true; |
3841 for (unsigned i = 0; i < points.size(); ++i) { | 3896 for (unsigned i = 0; i < points.size(); ++i) { |
3842 const PlatformTouchPoint& point = points[i]; | 3897 const PlatformTouchPoint& point = points[i]; |
3843 | 3898 |
(...skipping 18 matching lines...) Expand all Loading... | |
3862 gestureIndicator = adoptPtr(new UserGestureIndicator(m_touchSequenceUser GestureToken.release())); | 3917 gestureIndicator = adoptPtr(new UserGestureIndicator(m_touchSequenceUser GestureToken.release())); |
3863 else | 3918 else |
3864 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessin gUserGesture)); | 3919 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessin gUserGesture)); |
3865 | 3920 |
3866 m_touchSequenceUserGestureToken = gestureIndicator->currentToken(); | 3921 m_touchSequenceUserGestureToken = gestureIndicator->currentToken(); |
3867 | 3922 |
3868 ASSERT(m_frame->view()); | 3923 ASSERT(m_frame->view()); |
3869 if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touc hSequenceDocument->frame()->view())) { | 3924 if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touc hSequenceDocument->frame()->view())) { |
3870 // If the active touch document has no frame or view, it's probably bein g destroyed | 3925 // If the active touch document has no frame or view, it's probably bein g destroyed |
3871 // so we can't dispatch events. | 3926 // so we can't dispatch events. |
3872 return false; | 3927 return WebInputEventResult::NotHandled; |
3873 } | 3928 } |
3874 | 3929 |
3875 // First do hit tests for any new touch points. | 3930 // First do hit tests for any new touch points. |
3876 for (unsigned i = 0; i < points.size(); ++i) { | 3931 for (unsigned i = 0; i < points.size(); ++i) { |
3877 const PlatformTouchPoint& point = points[i]; | 3932 const PlatformTouchPoint& point = points[i]; |
3878 | 3933 |
3879 // Touch events implicitly capture to the touched node, and don't change | 3934 // Touch events implicitly capture to the touched node, and don't change |
3880 // active/hover states themselves (Gesture events do). So we only need | 3935 // active/hover states themselves (Gesture events do). So we only need |
3881 // to hit-test on touchstart, and it can be read-only. | 3936 // to hit-test on touchstart, and it can be read-only. |
3882 if (point.state() == PlatformTouchPoint::TouchPressed) { | 3937 if (point.state() == PlatformTouchPoint::TouchPressed) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3925 m_touchPressed = !allTouchReleased; | 3980 m_touchPressed = !allTouchReleased; |
3926 | 3981 |
3927 // If there's no document receiving touch events, or no handlers on the | 3982 // If there's no document receiving touch events, or no handlers on the |
3928 // document set to receive the events, then we can skip all the rest of | 3983 // document set to receive the events, then we can skip all the rest of |
3929 // this work. | 3984 // this work. |
3930 if (!m_touchSequenceDocument || !m_touchSequenceDocument->frameHost() || !m_ touchSequenceDocument->frameHost()->eventHandlerRegistry().hasEventHandlers(Even tHandlerRegistry::TouchEvent) || !m_touchSequenceDocument->frame()) { | 3985 if (!m_touchSequenceDocument || !m_touchSequenceDocument->frameHost() || !m_ touchSequenceDocument->frameHost()->eventHandlerRegistry().hasEventHandlers(Even tHandlerRegistry::TouchEvent) || !m_touchSequenceDocument->frame()) { |
3931 if (allTouchReleased) { | 3986 if (allTouchReleased) { |
3932 m_touchSequenceDocument.clear(); | 3987 m_touchSequenceDocument.clear(); |
3933 m_touchSequenceUserGestureToken.clear(); | 3988 m_touchSequenceUserGestureToken.clear(); |
3934 } | 3989 } |
3935 return false; | 3990 return WebInputEventResult::NotHandled; |
3936 } | 3991 } |
3937 | 3992 |
3938 // Compute and store the common info used by both PointerEvent and TouchEven t. | 3993 // Compute and store the common info used by both PointerEvent and TouchEven t. |
3939 WillBeHeapVector<TouchInfo> touchInfos(points.size()); | 3994 WillBeHeapVector<TouchInfo> touchInfos(points.size()); |
3940 | 3995 |
3941 for (unsigned i = 0; i < points.size(); ++i) { | 3996 for (unsigned i = 0; i < points.size(); ++i) { |
3942 const PlatformTouchPoint& point = points[i]; | 3997 const PlatformTouchPoint& point = points[i]; |
3943 PlatformTouchPoint::State pointState = point.state(); | 3998 PlatformTouchPoint::State pointState = point.state(); |
3944 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr; | 3999 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr; |
3945 | 4000 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4004 // Note that the disposition of any pointer events affects only the gene ration of touch | 4059 // Note that the disposition of any pointer events affects only the gene ration of touch |
4005 // events. If all pointer events were handled (and hence no touch events were fired), that | 4060 // events. If all pointer events were handled (and hence no touch events were fired), that |
4006 // is still equivalent to the touch events going unhandled because point er event handler | 4061 // is still equivalent to the touch events going unhandled because point er event handler |
4007 // don't block scroll gesture generation. | 4062 // don't block scroll gesture generation. |
4008 } | 4063 } |
4009 | 4064 |
4010 // TODO(crbug.com/507408): If PE handlers always call preventDefault, we won 't see TEs until after | 4065 // TODO(crbug.com/507408): If PE handlers always call preventDefault, we won 't see TEs until after |
4011 // scrolling starts because the scrolling would suppress upcoming PEs. This sudden "break" in TE | 4066 // scrolling starts because the scrolling would suppress upcoming PEs. This sudden "break" in TE |
4012 // suppression can make the visible TEs inconsistent (e.g. touchmove without a touchstart). | 4067 // suppression can make the visible TEs inconsistent (e.g. touchmove without a touchstart). |
4013 | 4068 |
4014 bool swallowedTouchEvent = dispatchTouchEvents(event, touchInfos, freshTouch Events, | 4069 WebInputEventResult eventResult = dispatchTouchEvents(event, touchInfos, fre shTouchEvents, |
4015 allTouchReleased); | 4070 allTouchReleased); |
4016 | 4071 |
4017 if (!m_inPointerCanceledState) { | 4072 if (!m_inPointerCanceledState) { |
4018 // Check if we need to stop firing pointer events because of a touch act ion. | 4073 // Check if we need to stop firing pointer events because of a touch act ion. |
4019 // See: www.w3.org/TR/pointerevents/#declaring-candidate-regions-for-def ault-touch-behaviors | 4074 // See: www.w3.org/TR/pointerevents/#declaring-candidate-regions-for-def ault-touch-behaviors |
4020 if (event.causesScrollingIfUncanceled() && !swallowedTouchEvent) { | 4075 if (event.causesScrollingIfUncanceled() && eventResult == WebInputEventR esult::NotHandled) { |
4021 m_inPointerCanceledState = true; | 4076 m_inPointerCanceledState = true; |
4022 sendPointerCancels(touchInfos); | 4077 sendPointerCancels(touchInfos); |
4023 } | 4078 } |
4024 } else if (allTouchReleased) { | 4079 } else if (allTouchReleased) { |
4025 m_inPointerCanceledState = false; | 4080 m_inPointerCanceledState = false; |
4026 } | 4081 } |
4027 | 4082 |
4028 return swallowedTouchEvent; | 4083 return eventResult; |
4029 } | 4084 } |
4030 | 4085 |
4031 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) | 4086 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) |
4032 { | 4087 { |
4033 m_mousePositionIsUnknown = false; | 4088 m_mousePositionIsUnknown = false; |
4034 m_lastKnownMousePosition = event.position(); | 4089 m_lastKnownMousePosition = event.position(); |
4035 m_lastKnownMouseGlobalPosition = event.globalPosition(); | 4090 m_lastKnownMouseGlobalPosition = event.globalPosition(); |
4036 } | 4091 } |
4037 | 4092 |
4038 void EventHandler::conditionallyEnableMouseEventForPointerTypeMouse(const Platfo rmMouseEvent& event) | 4093 void EventHandler::conditionallyEnableMouseEventForPointerTypeMouse(const Platfo rmMouseEvent& event) |
4039 { | 4094 { |
4040 if (event.button() == NoButton) | 4095 if (event.button() == NoButton) |
4041 m_preventMouseEventForPointerTypeMouse = false; | 4096 m_preventMouseEventForPointerTypeMouse = false; |
4042 } | 4097 } |
4043 | 4098 |
4044 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m ev, LocalFrame* subframe) | 4099 WebInputEventResult EventHandler::passMousePressEventToSubframe(MouseEventWithHi tTestResults& mev, LocalFrame* subframe) |
4045 { | 4100 { |
4046 selectionController().passMousePressEventToSubframe(mev); | 4101 selectionController().passMousePressEventToSubframe(mev); |
4047 subframe->eventHandler().handleMousePressEvent(mev.event()); | 4102 WebInputEventResult result = subframe->eventHandler().handleMousePressEvent( mev.event()); |
4048 return true; | 4103 if (result != WebInputEventResult::NotHandled) |
4104 return result; | |
4105 return WebInputEventResult::HandledSystem; | |
4049 } | 4106 } |
4050 | 4107 |
4051 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& me v, LocalFrame* subframe, HitTestResult* hoveredNode) | 4108 WebInputEventResult EventHandler::passMouseMoveEventToSubframe(MouseEventWithHit TestResults& mev, LocalFrame* subframe, HitTestResult* hoveredNode) |
4052 { | 4109 { |
4053 if (m_mouseDownMayStartDrag) | 4110 if (m_mouseDownMayStartDrag) |
4054 return false; | 4111 return WebInputEventResult::NotHandled; |
4055 subframe->eventHandler().handleMouseMoveOrLeaveEvent(mev.event(), hoveredNod e); | 4112 WebInputEventResult result = subframe->eventHandler().handleMouseMoveOrLeave Event(mev.event(), hoveredNode); |
4056 return true; | 4113 if (result != WebInputEventResult::NotHandled) |
4114 return result; | |
4115 return WebInputEventResult::HandledSystem; | |
4057 } | 4116 } |
4058 | 4117 |
4059 bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, LocalFrame* subframe) | 4118 WebInputEventResult EventHandler::passMouseReleaseEventToSubframe(MouseEventWith HitTestResults& mev, LocalFrame* subframe) |
4060 { | 4119 { |
4061 subframe->eventHandler().handleMouseReleaseEvent(mev.event()); | 4120 WebInputEventResult result = subframe->eventHandler().handleMouseReleaseEven t(mev.event()); |
4062 return true; | 4121 if (result != WebInputEventResult::NotHandled) |
4122 return result; | |
4123 return WebInputEventResult::HandledSystem; | |
4063 } | 4124 } |
4064 | 4125 |
4065 bool EventHandler::passWheelEventToWidget(const PlatformWheelEvent& wheelEvent, Widget& widget) | 4126 WebInputEventResult EventHandler::passWheelEventToWidget(const PlatformWheelEven t& wheelEvent, Widget& widget) |
4066 { | 4127 { |
4067 // If not a FrameView, then probably a plugin widget. Those will receive | 4128 // If not a FrameView, then probably a plugin widget. Those will receive |
4068 // the event via an EventTargetNode dispatch when this returns false. | 4129 // the event via an EventTargetNode dispatch when this returns false. |
4069 if (!widget.isFrameView()) | 4130 if (!widget.isFrameView()) |
4070 return false; | 4131 return WebInputEventResult::NotHandled; |
4071 | 4132 |
4072 return toFrameView(&widget)->frame().eventHandler().handleWheelEvent(wheelEv ent); | 4133 return toFrameView(&widget)->frame().eventHandler().handleWheelEvent(wheelEv ent); |
4073 } | 4134 } |
4074 | 4135 |
4075 DataTransfer* EventHandler::createDraggingDataTransfer() const | 4136 DataTransfer* EventHandler::createDraggingDataTransfer() const |
4076 { | 4137 { |
4077 return DataTransfer::create(DataTransfer::DragAndDrop, DataTransferWritable, DataObject::create()); | 4138 return DataTransfer::create(DataTransfer::DragAndDrop, DataTransferWritable, DataObject::create()); |
4078 } | 4139 } |
4079 | 4140 |
4080 void EventHandler::focusDocumentView() | 4141 void EventHandler::focusDocumentView() |
4081 { | 4142 { |
4082 Page* page = m_frame->page(); | 4143 Page* page = m_frame->page(); |
4083 if (!page) | 4144 if (!page) |
4084 return; | 4145 return; |
4085 page->focusController().focusDocumentView(m_frame); | 4146 page->focusController().focusDocumentView(m_frame); |
4086 } | 4147 } |
4087 | 4148 |
4088 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() | 4149 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() |
4089 { | 4150 { |
4090 #if OS(MACOSX) | 4151 #if OS(MACOSX) |
4091 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); | 4152 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); |
4092 #else | 4153 #else |
4093 return PlatformEvent::AltKey; | 4154 return PlatformEvent::AltKey; |
4094 #endif | 4155 #endif |
4095 } | 4156 } |
4096 | 4157 |
4097 } // namespace blink | 4158 } // namespace blink |
OLD | NEW |