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