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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 436 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
437 Node* innerNode = event.targetNode(); | 437 Node* innerNode = event.targetNode(); |
438 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) | 438 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) |
439 return false; | 439 return false; |
440 | 440 |
441 // Extend the selection if the Shift key is down, unless the click is in a l
ink. | 441 // Extend the selection if the Shift key is down, unless the click is in a l
ink. |
442 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); | 442 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); |
443 | 443 |
444 // Don't restart the selection when the mouse is pressed on an | 444 // Don't restart the selection when the mouse is pressed on an |
445 // existing selection so we can allow for text dragging. | 445 // existing selection so we can allow for text dragging. |
446 if (FrameView* view = m_frame->view()) { | 446 LayoutPoint vPoint = event.event().position(); |
447 LayoutPoint vPoint = view->windowToContents(event.event().position()); | 447 if (!extendSelection && m_frame->selection().contains(vPoint)) { |
448 if (!extendSelection && m_frame->selection().contains(vPoint)) { | 448 m_mouseDownWasSingleClickInSelection = true; |
449 m_mouseDownWasSingleClickInSelection = true; | 449 return false; |
450 return false; | |
451 } | |
452 } | 450 } |
453 | 451 |
454 VisiblePosition visiblePos(innerNode->renderer()->positionForPoint(event.loc
alPoint())); | 452 VisiblePosition visiblePos(innerNode->renderer()->positionForPoint(event.loc
alPoint())); |
455 if (visiblePos.isNull()) | 453 if (visiblePos.isNull()) |
456 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOW
NSTREAM); | 454 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOW
NSTREAM); |
457 Position pos = visiblePos.deepEquivalent(); | 455 Position pos = visiblePos.deepEquivalent(); |
458 | 456 |
459 VisibleSelection newSelection = m_frame->selection().selection(); | 457 VisibleSelection newSelection = m_frame->selection().selection(); |
460 TextGranularity granularity = CharacterGranularity; | 458 TextGranularity granularity = CharacterGranularity; |
461 | 459 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 } | 507 } |
510 | 508 |
511 bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
nt) | 509 bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
nt) |
512 { | 510 { |
513 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); | 511 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); |
514 | 512 |
515 cancelFakeMouseMoveEvent(); | 513 cancelFakeMouseMoveEvent(); |
516 | 514 |
517 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 515 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
518 | 516 |
519 if (ScrollView* scrollView = m_frame->view()) { | |
520 if (scrollView->isPointInScrollbarCorner(event.event().position())) | |
521 return false; | |
522 } | |
523 | |
524 bool singleClick = event.event().clickCount() <= 1; | 517 bool singleClick = event.event().clickCount() <= 1; |
525 | 518 |
526 // If we got the event back, that must mean it wasn't prevented, | 519 // If we got the event back, that must mean it wasn't prevented, |
527 // so it's allowed to start a drag or selection if it wasn't in a scrollbar. | 520 // so it's allowed to start a drag or selection if it wasn't in a scrollbar. |
528 m_mouseDownMayStartSelect = canMouseDownStartSelect(event.targetNode()) && !
event.scrollbar(); | 521 m_mouseDownMayStartSelect = canMouseDownStartSelect(event.targetNode()) && !
event.scrollbar(); |
529 | 522 |
530 m_mouseDownMayStartDrag = singleClick; | 523 m_mouseDownMayStartDrag = singleClick; |
531 | 524 |
532 m_mouseDownWasSingleClickInSelection = false; | 525 m_mouseDownWasSingleClickInSelection = false; |
533 | 526 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 void EventHandler::updateSelectionForMouseDrag() | 601 void EventHandler::updateSelectionForMouseDrag() |
609 { | 602 { |
610 FrameView* view = m_frame->view(); | 603 FrameView* view = m_frame->view(); |
611 if (!view) | 604 if (!view) |
612 return; | 605 return; |
613 RenderView* renderer = m_frame->contentRenderer(); | 606 RenderView* renderer = m_frame->contentRenderer(); |
614 if (!renderer) | 607 if (!renderer) |
615 return; | 608 return; |
616 | 609 |
617 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H
itTestRequest::Move); | 610 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H
itTestRequest::Move); |
618 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); | 611 HitTestResult result(m_lastKnownMousePosition); |
619 renderer->hitTest(request, result); | 612 renderer->hitTest(request, result); |
620 updateSelectionForMouseDrag(result); | 613 updateSelectionForMouseDrag(result); |
621 } | 614 } |
622 | 615 |
623 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
t) | 616 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
t) |
624 { | 617 { |
625 if (!m_mouseDownMayStartSelect) | 618 if (!m_mouseDownMayStartSelect) |
626 return; | 619 return; |
627 | 620 |
628 Node* target = hitTestResult.targetNode(); | 621 Node* target = hitTestResult.targetNode(); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 return false; | 796 return false; |
804 } | 797 } |
805 | 798 |
806 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g
ranularity, Node* startingNode) | 799 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g
ranularity, Node* startingNode) |
807 { | 800 { |
808 // The layout needs to be up to date to determine if we can scroll. We may b
e | 801 // The layout needs to be up to date to determine if we can scroll. We may b
e |
809 // here because of an onLoad event, in which case the final layout hasn't be
en performed yet. | 802 // here because of an onLoad event, in which case the final layout hasn't be
en performed yet. |
810 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 803 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
811 if (scroll(direction, granularity, startingNode)) | 804 if (scroll(direction, granularity, startingNode)) |
812 return true; | 805 return true; |
813 LocalFrame* frame = m_frame; | |
814 FrameView* view = frame->view(); | |
815 if (view && view->scroll(direction, granularity)) | |
816 return true; | |
817 return false; | 806 return false; |
818 } | 807 } |
819 | 808 |
820 IntPoint EventHandler::lastKnownMousePosition() const | 809 IntPoint EventHandler::lastKnownMousePosition() const |
821 { | 810 { |
822 return m_lastKnownMousePosition; | 811 return m_lastKnownMousePosition; |
823 } | 812 } |
824 | 813 |
825 bool EventHandler::useHandCursor(Node* node, bool isOverLink) | 814 bool EventHandler::useHandCursor(Node* node, bool isOverLink) |
826 { | 815 { |
(...skipping 20 matching lines...) Expand all Loading... |
847 if (!view || !view->shouldSetCursor()) | 836 if (!view || !view->shouldSetCursor()) |
848 return; | 837 return; |
849 | 838 |
850 RenderView* renderView = view->renderView(); | 839 RenderView* renderView = view->renderView(); |
851 if (!renderView) | 840 if (!renderView) |
852 return; | 841 return; |
853 | 842 |
854 m_frame->document()->updateLayout(); | 843 m_frame->document()->updateLayout(); |
855 | 844 |
856 HitTestRequest request(HitTestRequest::ReadOnly); | 845 HitTestRequest request(HitTestRequest::ReadOnly); |
857 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); | 846 HitTestResult result(m_lastKnownMousePosition); |
858 renderView->hitTest(request, result); | 847 renderView->hitTest(request, result); |
859 | 848 |
860 OptionalCursor optionalCursor = selectCursor(result); | 849 OptionalCursor optionalCursor = selectCursor(result); |
861 if (optionalCursor.isCursorChange()) { | 850 if (optionalCursor.isCursorChange()) { |
862 m_currentMouseCursor = optionalCursor.cursor(); | 851 m_currentMouseCursor = optionalCursor.cursor(); |
863 view->setCursor(m_currentMouseCursor); | 852 view->setCursor(m_currentMouseCursor); |
864 } | 853 } |
865 } | 854 } |
866 | 855 |
867 OptionalCursor EventHandler::selectCursor(const HitTestResult& result) | 856 OptionalCursor EventHandler::selectCursor(const HitTestResult& result) |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 return iBeam; | 1014 return iBeam; |
1026 } | 1015 } |
1027 | 1016 |
1028 if ((editable || (renderer && renderer->isText() && node->canStartSelection(
))) && !inResizer && !result.scrollbar()) | 1017 if ((editable || (renderer && renderer->isText() && node->canStartSelection(
))) && !inResizer && !result.scrollbar()) |
1029 return iBeam; | 1018 return iBeam; |
1030 return pointerCursor(); | 1019 return pointerCursor(); |
1031 } | 1020 } |
1032 | 1021 |
1033 static LayoutPoint documentPointForWindowPoint(LocalFrame* frame, const IntPoint
& windowPoint) | 1022 static LayoutPoint documentPointForWindowPoint(LocalFrame* frame, const IntPoint
& windowPoint) |
1034 { | 1023 { |
1035 FrameView* view = frame->view(); | 1024 // FIXME(sky): remove |
1036 // FIXME: Is it really OK to use the wrong coordinates here when view is 0? | 1025 return windowPoint; |
1037 // Historically the code would just crash; this is clearly no worse than tha
t. | |
1038 return view ? view->windowToContents(windowPoint) : windowPoint; | |
1039 } | 1026 } |
1040 | 1027 |
1041 bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) | 1028 bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) |
1042 { | 1029 { |
1043 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); | 1030 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); |
1044 | 1031 |
1045 RefPtr<FrameView> protector(m_frame->view()); | 1032 RefPtr<FrameView> protector(m_frame->view()); |
1046 | 1033 |
1047 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | 1034 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); |
1048 m_frame->eventHandler().m_lastMouseDownUserGestureToken = gestureIndicator.c
urrentToken(); | 1035 m_frame->eventHandler().m_lastMouseDownUserGestureToken = gestureIndicator.c
urrentToken(); |
1049 | 1036 |
1050 cancelFakeMouseMoveEvent(); | 1037 cancelFakeMouseMoveEvent(); |
1051 if (m_eventHandlerWillResetCapturingMouseEventsNode) | 1038 if (m_eventHandlerWillResetCapturingMouseEventsNode) |
1052 m_capturingMouseEventsNode = nullptr; | 1039 m_capturingMouseEventsNode = nullptr; |
1053 m_mousePressed = true; | 1040 m_mousePressed = true; |
1054 m_capturesDragging = true; | 1041 m_capturesDragging = true; |
1055 setLastKnownMousePosition(mouseEvent); | 1042 setLastKnownMousePosition(mouseEvent); |
1056 m_mouseDownTimestamp = mouseEvent.timestamp(); | 1043 m_mouseDownTimestamp = mouseEvent.timestamp(); |
1057 m_mouseDownMayStartDrag = false; | 1044 m_mouseDownMayStartDrag = false; |
1058 m_mouseDownMayStartSelect = false; | 1045 m_mouseDownMayStartSelect = false; |
1059 m_mouseDownMayStartAutoscroll = false; | 1046 m_mouseDownMayStartAutoscroll = false; |
1060 if (FrameView* view = m_frame->view()) | 1047 if (m_frame->view()) |
1061 m_mouseDownPos = view->windowToContents(mouseEvent.position()); | 1048 m_mouseDownPos = mouseEvent.position(); |
1062 else { | 1049 else { |
| 1050 // FIXME(sky): Why do we have this else block at all? |
1063 invalidateClick(); | 1051 invalidateClick(); |
1064 return false; | 1052 return false; |
1065 } | 1053 } |
1066 | 1054 |
1067 // Mouse events simulated from touch should not hit-test again. | 1055 // Mouse events simulated from touch should not hit-test again. |
1068 ASSERT(!mouseEvent.fromTouch()); | 1056 ASSERT(!mouseEvent.fromTouch()); |
1069 | 1057 |
1070 HitTestRequest request(HitTestRequest::Active); | 1058 HitTestRequest request(HitTestRequest::Active); |
1071 // Save the document point we generate in case the window coordinate is inva
lidated by what happens | 1059 // Save the document point we generate in case the window coordinate is inva
lidated by what happens |
1072 // when we dispatch the event. | 1060 // when we dispatch the event. |
1073 LayoutPoint documentPoint = documentPointForWindowPoint(m_frame, mouseEvent.
position()); | 1061 LayoutPoint documentPoint = documentPointForWindowPoint(m_frame, mouseEvent.
position()); |
1074 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re
quest, documentPoint, mouseEvent); | 1062 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re
quest, documentPoint, mouseEvent); |
1075 | 1063 |
1076 if (!mev.targetNode()) { | 1064 if (!mev.targetNode()) { |
1077 invalidateClick(); | 1065 invalidateClick(); |
1078 return false; | 1066 return false; |
1079 } | 1067 } |
1080 | 1068 |
1081 m_mousePressNode = mev.targetNode(); | 1069 m_mousePressNode = mev.targetNode(); |
1082 | 1070 |
1083 m_clickCount = mouseEvent.clickCount(); | 1071 m_clickCount = mouseEvent.clickCount(); |
1084 m_clickNode = mev.targetNode()->isTextNode() ? NodeRenderingTraversal::pare
nt(mev.targetNode()) : mev.targetNode(); | 1072 m_clickNode = mev.targetNode()->isTextNode() ? NodeRenderingTraversal::pare
nt(mev.targetNode()) : mev.targetNode(); |
1085 | 1073 |
1086 if (FrameView* view = m_frame->view()) { | 1074 RenderLayer* layer = mev.targetNode()->renderer() ? mev.targetNode()->render
er()->enclosingLayer() : 0; |
1087 RenderLayer* layer = mev.targetNode()->renderer() ? mev.targetNode()->re
nderer()->enclosingLayer() : 0; | 1075 IntPoint p = mouseEvent.position(); |
1088 IntPoint p = view->windowToContents(mouseEvent.position()); | 1076 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPointInRe
sizeControl(p, ResizerForPointer)) { |
1089 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint
InResizeControl(p, ResizerForPointer)) { | 1077 m_resizeScrollableArea = layer->scrollableArea(); |
1090 m_resizeScrollableArea = layer->scrollableArea(); | 1078 m_resizeScrollableArea->setInResizeMode(true); |
1091 m_resizeScrollableArea->setInResizeMode(true); | 1079 m_offsetFromResizeCorner = m_resizeScrollableArea->offsetFromResizeCorne
r(p); |
1092 m_offsetFromResizeCorner = m_resizeScrollableArea->offsetFromResizeC
orner(p); | 1080 invalidateClick(); |
1093 invalidateClick(); | 1081 return true; |
1094 return true; | |
1095 } | |
1096 } | 1082 } |
1097 | 1083 |
1098 m_frame->selection().setCaretBlinkingSuspended(true); | 1084 m_frame->selection().setCaretBlinkingSuspended(true); |
1099 | 1085 |
1100 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.targe
tNode(), m_clickCount, mouseEvent, true); | 1086 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.targe
tNode(), m_clickCount, mouseEvent, true); |
1101 swallowEvent = swallowEvent || handleMouseFocus(mouseEvent); | 1087 swallowEvent = swallowEvent || handleMouseFocus(mouseEvent); |
1102 m_capturesDragging = !swallowEvent || mev.scrollbar(); | 1088 m_capturesDragging = !swallowEvent || mev.scrollbar(); |
1103 | 1089 |
1104 // If the hit testing originally determined the event was in a scrollbar, re
fetch the MouseEventWithHitTestResults | 1090 // If the hit testing originally determined the event was in a scrollbar, re
fetch the MouseEventWithHitTestResults |
1105 // in case the scrollbar widget was destroyed when the mouse event was handl
ed. | 1091 // in case the scrollbar widget was destroyed when the mouse event was handl
ed. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 | 1148 |
1163 Page* page = m_frame->page(); | 1149 Page* page = m_frame->page(); |
1164 if (!page) | 1150 if (!page) |
1165 return result; | 1151 return result; |
1166 | 1152 |
1167 if (RenderLayer* layer = layerForNode(hoveredNode.innerNode())) { | 1153 if (RenderLayer* layer = layerForNode(hoveredNode.innerNode())) { |
1168 if (ScrollableArea* layerScrollableArea = associatedScrollableArea(layer
)) | 1154 if (ScrollableArea* layerScrollableArea = associatedScrollableArea(layer
)) |
1169 layerScrollableArea->mouseMovedInContentArea(); | 1155 layerScrollableArea->mouseMovedInContentArea(); |
1170 } | 1156 } |
1171 | 1157 |
1172 if (FrameView* frameView = m_frame->view()) | |
1173 frameView->mouseMovedInContentArea(); | |
1174 | |
1175 page->chrome().mouseDidMoveOverElement(hoveredNode, event.modifierFlags()); | 1158 page->chrome().mouseDidMoveOverElement(hoveredNode, event.modifierFlags()); |
1176 page->chrome().setToolTip(hoveredNode); | 1159 page->chrome().setToolTip(hoveredNode); |
1177 | 1160 |
1178 return result; | 1161 return result; |
1179 } | 1162 } |
1180 | 1163 |
1181 void EventHandler::handleMouseLeaveEvent(const PlatformMouseEvent& event) | 1164 void EventHandler::handleMouseLeaveEvent(const PlatformMouseEvent& event) |
1182 { | 1165 { |
1183 TRACE_EVENT0("blink", "EventHandler::handleMouseLeaveEvent"); | 1166 TRACE_EVENT0("blink", "EventHandler::handleMouseLeaveEvent"); |
1184 | 1167 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 HitTestRequest request(hitType); | 1209 HitTestRequest request(hitType); |
1227 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); | 1210 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); |
1228 if (hoveredNode) | 1211 if (hoveredNode) |
1229 *hoveredNode = mev.hitTestResult(); | 1212 *hoveredNode = mev.hitTestResult(); |
1230 | 1213 |
1231 Scrollbar* scrollbar = 0; | 1214 Scrollbar* scrollbar = 0; |
1232 | 1215 |
1233 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) | 1216 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) |
1234 m_resizeScrollableArea->resize(mouseEvent, m_offsetFromResizeCorner); | 1217 m_resizeScrollableArea->resize(mouseEvent, m_offsetFromResizeCorner); |
1235 else { | 1218 else { |
1236 if (FrameView* view = m_frame->view()) | 1219 scrollbar = mev.scrollbar(); |
1237 scrollbar = view->scrollbarAtPoint(mouseEvent.position()); | |
1238 | |
1239 if (!scrollbar) | |
1240 scrollbar = mev.scrollbar(); | |
1241 | |
1242 updateLastScrollbarUnderMouse(scrollbar, !m_mousePressed); | 1220 updateLastScrollbarUnderMouse(scrollbar, !m_mousePressed); |
1243 if (onlyUpdateScrollbars) | 1221 if (onlyUpdateScrollbars) |
1244 return true; | 1222 return true; |
1245 } | 1223 } |
1246 | 1224 |
1247 bool swallowEvent = false; | 1225 bool swallowEvent = false; |
1248 | 1226 |
1249 if (scrollbar && !m_mousePressed) | 1227 if (scrollbar && !m_mousePressed) |
1250 scrollbar->mouseMoved(mouseEvent); // Handle hover effects on platforms
that support visual feedback on scrollbar hovering. | 1228 scrollbar->mouseMoved(mouseEvent); // Handle hover effects on platforms
that support visual feedback on scrollbar hovering. |
1251 if (FrameView* view = m_frame->view()) { | 1229 if (FrameView* view = m_frame->view()) { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 result = NodeRenderingTraversal::parent(result); | 1373 result = NodeRenderingTraversal::parent(result); |
1396 } | 1374 } |
1397 m_nodeUnderMouse = result; | 1375 m_nodeUnderMouse = result; |
1398 | 1376 |
1399 // Fire mouseout/mouseover if the mouse has shifted to a different node. | 1377 // Fire mouseout/mouseover if the mouse has shifted to a different node. |
1400 if (fireMouseOverOut) { | 1378 if (fireMouseOverOut) { |
1401 RenderLayer* layerForLastNode = layerForNode(m_lastNodeUnderMouse.get())
; | 1379 RenderLayer* layerForLastNode = layerForNode(m_lastNodeUnderMouse.get())
; |
1402 RenderLayer* layerForNodeUnderMouse = layerForNode(m_nodeUnderMouse.get(
)); | 1380 RenderLayer* layerForNodeUnderMouse = layerForNode(m_nodeUnderMouse.get(
)); |
1403 Page* page = m_frame->page(); | 1381 Page* page = m_frame->page(); |
1404 | 1382 |
1405 if (m_lastNodeUnderMouse && (!m_nodeUnderMouse || m_nodeUnderMouse->docu
ment() != m_frame->document())) { | 1383 if (page && (layerForLastNode && (!layerForNodeUnderMouse || layerForNod
eUnderMouse != layerForLastNode))) { |
1406 // The mouse has moved between frames. | |
1407 if (LocalFrame* frame = m_lastNodeUnderMouse->document().frame()) { | |
1408 if (FrameView* frameView = frame->view()) | |
1409 frameView->mouseExitedContentArea(); | |
1410 } | |
1411 } else if (page && (layerForLastNode && (!layerForNodeUnderMouse || laye
rForNodeUnderMouse != layerForLastNode))) { | |
1412 // The mouse has moved between layers. | 1384 // The mouse has moved between layers. |
1413 if (ScrollableArea* scrollableAreaForLastNode = associatedScrollable
Area(layerForLastNode)) | 1385 if (ScrollableArea* scrollableAreaForLastNode = associatedScrollable
Area(layerForLastNode)) |
1414 scrollableAreaForLastNode->mouseExitedContentArea(); | 1386 scrollableAreaForLastNode->mouseExitedContentArea(); |
1415 } | 1387 } |
1416 | 1388 |
1417 if (m_nodeUnderMouse && (!m_lastNodeUnderMouse || m_lastNodeUnderMouse->
document() != m_frame->document())) { | 1389 if (page && (layerForNodeUnderMouse && (!layerForLastNode || layerForNod
eUnderMouse != layerForLastNode))) { |
1418 // The mouse has moved between frames. | |
1419 if (LocalFrame* frame = m_nodeUnderMouse->document().frame()) { | |
1420 if (FrameView* frameView = frame->view()) | |
1421 frameView->mouseEnteredContentArea(); | |
1422 } | |
1423 } else if (page && (layerForNodeUnderMouse && (!layerForLastNode || laye
rForNodeUnderMouse != layerForLastNode))) { | |
1424 // The mouse has moved between layers. | 1390 // The mouse has moved between layers. |
1425 if (ScrollableArea* scrollableAreaForNodeUnderMouse = associatedScro
llableArea(layerForNodeUnderMouse)) | 1391 if (ScrollableArea* scrollableAreaForNodeUnderMouse = associatedScro
llableArea(layerForNodeUnderMouse)) |
1426 scrollableAreaForNodeUnderMouse->mouseEnteredContentArea(); | 1392 scrollableAreaForNodeUnderMouse->mouseEnteredContentArea(); |
1427 } | 1393 } |
1428 | 1394 |
1429 if (m_lastNodeUnderMouse && m_lastNodeUnderMouse->document() != m_frame-
>document()) { | 1395 if (m_lastNodeUnderMouse && m_lastNodeUnderMouse->document() != m_frame-
>document()) { |
1430 m_lastNodeUnderMouse = nullptr; | 1396 m_lastNodeUnderMouse = nullptr; |
1431 m_lastScrollbarUnderMouse = nullptr; | 1397 m_lastScrollbarUnderMouse = nullptr; |
1432 } | 1398 } |
1433 | 1399 |
(...skipping 12 matching lines...) Expand all Loading... |
1446 // The return value means 'continue default handling.' | 1412 // The return value means 'continue default handling.' |
1447 bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targe
tNode, int clickCount, const PlatformMouseEvent& mouseEvent, bool setUnder) | 1413 bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targe
tNode, int clickCount, const PlatformMouseEvent& mouseEvent, bool setUnder) |
1448 { | 1414 { |
1449 updateMouseEventTargetNode(targetNode, mouseEvent, setUnder); | 1415 updateMouseEventTargetNode(targetNode, mouseEvent, setUnder); |
1450 return !m_nodeUnderMouse || m_nodeUnderMouse->dispatchMouseEvent(mouseEvent,
eventType, clickCount); | 1416 return !m_nodeUnderMouse || m_nodeUnderMouse->dispatchMouseEvent(mouseEvent,
eventType, clickCount); |
1451 } | 1417 } |
1452 | 1418 |
1453 // The return value means 'swallow event' (was handled), as for other handle* fu
nctions. | 1419 // The return value means 'swallow event' (was handled), as for other handle* fu
nctions. |
1454 bool EventHandler::handleMouseFocus(const PlatformMouseEvent& mouseEvent) | 1420 bool EventHandler::handleMouseFocus(const PlatformMouseEvent& mouseEvent) |
1455 { | 1421 { |
1456 // If clicking on a frame scrollbar, do not mess up with content focus. | |
1457 if (FrameView* view = m_frame->view()) { | |
1458 if (view->scrollbarAtPoint(mouseEvent.position())) | |
1459 return false; | |
1460 } | |
1461 | |
1462 // The layout needs to be up to date to determine if an element is focusable
. | 1422 // The layout needs to be up to date to determine if an element is focusable
. |
1463 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1423 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
1464 | 1424 |
1465 Element* element = 0; | 1425 Element* element = 0; |
1466 if (m_nodeUnderMouse) | 1426 if (m_nodeUnderMouse) |
1467 element = m_nodeUnderMouse->isElementNode() ? toElement(m_nodeUnderMouse
) : m_nodeUnderMouse->parentOrShadowHostElement(); | 1427 element = m_nodeUnderMouse->isElementNode() ? toElement(m_nodeUnderMouse
) : m_nodeUnderMouse->parentOrShadowHostElement(); |
1468 for (; element; element = element->parentOrShadowHostElement()) { | 1428 for (; element; element = element->parentOrShadowHostElement()) { |
1469 if (element->isFocusable() && element->focused()) | 1429 if (element->isFocusable() && element->focused()) |
1470 return false; | 1430 return false; |
1471 if (element->isMouseFocusable()) | 1431 if (element->isMouseFocusable()) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 | 1493 |
1534 if (!doc->renderView()) | 1494 if (!doc->renderView()) |
1535 return false; | 1495 return false; |
1536 | 1496 |
1537 RefPtr<FrameView> protector(m_frame->view()); | 1497 RefPtr<FrameView> protector(m_frame->view()); |
1538 | 1498 |
1539 FrameView* view = m_frame->view(); | 1499 FrameView* view = m_frame->view(); |
1540 if (!view) | 1500 if (!view) |
1541 return false; | 1501 return false; |
1542 | 1502 |
1543 LayoutPoint vPoint = view->windowToContents(event.position()); | 1503 LayoutPoint vPoint = event.position(); |
1544 | 1504 |
1545 HitTestRequest request(HitTestRequest::ReadOnly); | 1505 HitTestRequest request(HitTestRequest::ReadOnly); |
1546 HitTestResult result(vPoint); | 1506 HitTestResult result(vPoint); |
1547 doc->renderView()->hitTest(request, result); | 1507 doc->renderView()->hitTest(request, result); |
1548 | 1508 |
1549 Node* node = result.innerNode(); | 1509 Node* node = result.innerNode(); |
1550 // Wheel events should not dispatch to text nodes. | 1510 // Wheel events should not dispatch to text nodes. |
1551 if (node && node->isTextNode()) | 1511 if (node && node->isTextNode()) |
1552 node = NodeRenderingTraversal::parent(node); | 1512 node = NodeRenderingTraversal::parent(node); |
1553 | 1513 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 m_previousWheelScrolledNode = stopNode; | 1577 m_previousWheelScrolledNode = stopNode; |
1618 } | 1578 } |
1619 | 1579 |
1620 bool EventHandler::handleGestureShowPress() | 1580 bool EventHandler::handleGestureShowPress() |
1621 { | 1581 { |
1622 m_lastShowPressTimestamp = WTF::currentTime(); | 1582 m_lastShowPressTimestamp = WTF::currentTime(); |
1623 | 1583 |
1624 FrameView* view = m_frame->view(); | 1584 FrameView* view = m_frame->view(); |
1625 if (!view) | 1585 if (!view) |
1626 return false; | 1586 return false; |
1627 if (ScrollAnimator* scrollAnimator = view->existingScrollAnimator()) | |
1628 scrollAnimator->cancelAnimations(); | |
1629 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); | 1587 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); |
1630 if (!areas) | 1588 if (!areas) |
1631 return false; | 1589 return false; |
1632 for (FrameView::ScrollableAreaSet::const_iterator it = areas->begin(); it !=
areas->end(); ++it) { | 1590 for (FrameView::ScrollableAreaSet::const_iterator it = areas->begin(); it !=
areas->end(); ++it) { |
1633 ScrollableArea* sa = *it; | 1591 ScrollableArea* sa = *it; |
1634 ScrollAnimator* animator = sa->existingScrollAnimator(); | 1592 ScrollAnimator* animator = sa->existingScrollAnimator(); |
1635 if (animator) | 1593 if (animator) |
1636 animator->cancelAnimations(); | 1594 animator->cancelAnimations(); |
1637 } | 1595 } |
1638 return false; | 1596 return false; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1713 if (gestureEvent.type() != PlatformEvent::GestureScrollBegin) { | 1671 if (gestureEvent.type() != PlatformEvent::GestureScrollBegin) { |
1714 scrollbar = m_scrollbarHandlingScrollGesture.get(); | 1672 scrollbar = m_scrollbarHandlingScrollGesture.get(); |
1715 eventTarget = m_scrollGestureHandlingNode.get(); | 1673 eventTarget = m_scrollGestureHandlingNode.get(); |
1716 } | 1674 } |
1717 | 1675 |
1718 if (!eventTarget) { | 1676 if (!eventTarget) { |
1719 Document* document = m_frame->document(); | 1677 Document* document = m_frame->document(); |
1720 if (!document->renderView()) | 1678 if (!document->renderView()) |
1721 return false; | 1679 return false; |
1722 | 1680 |
1723 FrameView* view = m_frame->view(); | 1681 LayoutPoint viewPoint = gestureEvent.position(); |
1724 LayoutPoint viewPoint = view->windowToContents(gestureEvent.position()); | |
1725 HitTestRequest request(HitTestRequest::ReadOnly); | 1682 HitTestRequest request(HitTestRequest::ReadOnly); |
1726 HitTestResult result(viewPoint); | 1683 HitTestResult result(viewPoint); |
1727 document->renderView()->hitTest(request, result); | 1684 document->renderView()->hitTest(request, result); |
1728 | 1685 |
1729 eventTarget = result.innerNode(); | 1686 eventTarget = result.innerNode(); |
1730 | 1687 |
1731 m_lastGestureScrollOverWidget = result.isOverWidget(); | 1688 m_lastGestureScrollOverWidget = result.isOverWidget(); |
1732 m_scrollGestureHandlingNode = eventTarget; | 1689 m_scrollGestureHandlingNode = eventTarget; |
1733 m_previousGestureScrolledNode = nullptr; | 1690 m_previousGestureScrolledNode = nullptr; |
1734 | 1691 |
1735 if (!scrollbar) | 1692 if (!scrollbar) |
1736 scrollbar = view->scrollbarAtPoint(gestureEvent.position()); | |
1737 if (!scrollbar) | |
1738 scrollbar = result.scrollbar(); | 1693 scrollbar = result.scrollbar(); |
1739 } | 1694 } |
1740 | 1695 |
1741 if (scrollbar) { | 1696 if (scrollbar) { |
1742 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); | 1697 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); |
1743 if (gestureEvent.type() == PlatformEvent::GestureScrollEnd | 1698 if (gestureEvent.type() == PlatformEvent::GestureScrollEnd |
1744 || gestureEvent.type() == PlatformEvent::GestureFlingStart | 1699 || gestureEvent.type() == PlatformEvent::GestureFlingStart |
1745 || !eventSwallowed) { | 1700 || !eventSwallowed) { |
1746 m_scrollbarHandlingScrollGesture = nullptr; | 1701 m_scrollbarHandlingScrollGesture = nullptr; |
1747 } | 1702 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 if (gestureEvent.metaKey()) | 1746 if (gestureEvent.metaKey()) |
1792 modifierFlags |= PlatformEvent::MetaKey; | 1747 modifierFlags |= PlatformEvent::MetaKey; |
1793 if (gestureEvent.shiftKey()) | 1748 if (gestureEvent.shiftKey()) |
1794 modifierFlags |= PlatformEvent::ShiftKey; | 1749 modifierFlags |= PlatformEvent::ShiftKey; |
1795 PlatformEvent::Modifiers modifiers = static_cast<PlatformEvent::Modifiers>(m
odifierFlags); | 1750 PlatformEvent::Modifiers modifiers = static_cast<PlatformEvent::Modifiers>(m
odifierFlags); |
1796 | 1751 |
1797 HitTestResult currentHitTest = targetedEvent.hitTestResult(); | 1752 HitTestResult currentHitTest = targetedEvent.hitTestResult(); |
1798 | 1753 |
1799 // We use the adjusted position so the application isn't surprised to see a
event with | 1754 // We use the adjusted position so the application isn't surprised to see a
event with |
1800 // co-ordinates outside the target's bounds. | 1755 // co-ordinates outside the target's bounds. |
1801 IntPoint adjustedPoint = m_frame->view()->windowToContents(gestureEvent.posi
tion()); | 1756 IntPoint adjustedPoint = gestureEvent.position(); |
1802 | 1757 |
1803 PlatformMouseEvent fakeMouseMove(adjustedPoint, gestureEvent.globalPosition(
), | 1758 PlatformMouseEvent fakeMouseMove(adjustedPoint, gestureEvent.globalPosition(
), |
1804 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, | 1759 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, |
1805 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 1760 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
1806 dispatchMouseEvent(EventTypeNames::mousemove, currentHitTest.innerNode(), 0,
fakeMouseMove, true); | 1761 dispatchMouseEvent(EventTypeNames::mousemove, currentHitTest.innerNode(), 0,
fakeMouseMove, true); |
1807 | 1762 |
1808 // Do a new hit-test in case the mousemove event changed the DOM. | 1763 // Do a new hit-test in case the mousemove event changed the DOM. |
1809 // Note that if the original hit test wasn't over an element (eg. was over a
scrollbar) we | 1764 // Note that if the original hit test wasn't over an element (eg. was over a
scrollbar) we |
1810 // don't want to re-hit-test because it may be in the wrong frame (and there
's no way the page | 1765 // don't want to re-hit-test because it may be in the wrong frame (and there
's no way the page |
1811 // could have seen the event anyway). | 1766 // could have seen the event anyway). |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests
here (re-using the | 1810 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests
here (re-using the |
1856 // supplied HitTestResult), but that will require some overhaul of the touch
drag-and-drop code | 1811 // supplied HitTestResult), but that will require some overhaul of the touch
drag-and-drop code |
1857 // and LongPress is such a special scenario that it's unlikely to matter muc
h in practice. | 1812 // and LongPress is such a special scenario that it's unlikely to matter muc
h in practice. |
1858 | 1813 |
1859 #if OS(ANDROID) | 1814 #if OS(ANDROID) |
1860 bool shouldLongPressSelectWord = true; | 1815 bool shouldLongPressSelectWord = true; |
1861 #else | 1816 #else |
1862 bool shouldLongPressSelectWord = m_frame->settings() && m_frame->settings()-
>touchEditingEnabled(); | 1817 bool shouldLongPressSelectWord = m_frame->settings() && m_frame->settings()-
>touchEditingEnabled(); |
1863 #endif | 1818 #endif |
1864 if (shouldLongPressSelectWord) { | 1819 if (shouldLongPressSelectWord) { |
1865 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.p
osition()); | 1820 IntPoint hitTestPoint = gestureEvent.position(); |
1866 HitTestResult result = hitTestResultAtPoint(hitTestPoint); | 1821 HitTestResult result = hitTestResultAtPoint(hitTestPoint); |
1867 Node* innerNode = result.targetNode(); | 1822 Node* innerNode = result.targetNode(); |
1868 if (!result.isLiveLink() && innerNode && (innerNode->isContentEditable()
|| innerNode->isTextNode())) { | 1823 if (!result.isLiveLink() && innerNode && (innerNode->isContentEditable()
|| innerNode->isTextNode())) { |
1869 selectClosestWordFromHitTestResult(result, DontAppendTrailingWhitesp
ace); | 1824 selectClosestWordFromHitTestResult(result, DontAppendTrailingWhitesp
ace); |
1870 if (m_frame->selection().isRange()) { | 1825 if (m_frame->selection().isRange()) { |
1871 focusDocumentView(); | 1826 focusDocumentView(); |
1872 return true; | 1827 return true; |
1873 } | 1828 } |
1874 } | 1829 } |
1875 } | 1830 } |
1876 return true; | 1831 return true; |
1877 } | 1832 } |
1878 | 1833 |
1879 bool EventHandler::handleGestureLongTap(const GestureEventWithHitTestResults& ta
rgetedEvent) | 1834 bool EventHandler::handleGestureLongTap(const GestureEventWithHitTestResults& ta
rgetedEvent) |
1880 { | 1835 { |
1881 return false; | 1836 return false; |
1882 } | 1837 } |
1883 | 1838 |
1884 bool EventHandler::handleScrollGestureOnResizer(Node* eventTarget, const Platfor
mGestureEvent& gestureEvent) { | 1839 bool EventHandler::handleScrollGestureOnResizer(Node* eventTarget, const Platfor
mGestureEvent& gestureEvent) { |
1885 if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) { | 1840 if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) { |
1886 RenderLayer* layer = eventTarget->renderer() ? eventTarget->renderer()->
enclosingLayer() : 0; | 1841 RenderLayer* layer = eventTarget->renderer() ? eventTarget->renderer()->
enclosingLayer() : 0; |
1887 IntPoint p = m_frame->view()->windowToContents(gestureEvent.position()); | 1842 IntPoint p = gestureEvent.position(); |
1888 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint
InResizeControl(p, ResizerForTouch)) { | 1843 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint
InResizeControl(p, ResizerForTouch)) { |
1889 m_resizeScrollableArea = layer->scrollableArea(); | 1844 m_resizeScrollableArea = layer->scrollableArea(); |
1890 m_resizeScrollableArea->setInResizeMode(true); | 1845 m_resizeScrollableArea->setInResizeMode(true); |
1891 m_offsetFromResizeCorner = m_resizeScrollableArea->offsetFromResizeC
orner(p); | 1846 m_offsetFromResizeCorner = m_resizeScrollableArea->offsetFromResizeC
orner(p); |
1892 return true; | 1847 return true; |
1893 } | 1848 } |
1894 } else if (gestureEvent.type() == PlatformEvent::GestureScrollUpdate || | 1849 } else if (gestureEvent.type() == PlatformEvent::GestureScrollUpdate || |
1895 gestureEvent.type() == PlatformEvent::GestureScrollUpdateWithoutP
ropagation) { | 1850 gestureEvent.type() == PlatformEvent::GestureScrollUpdateWithoutP
ropagation) { |
1896 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { | 1851 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { |
1897 m_resizeScrollableArea->resize(gestureEvent, m_offsetFromResizeCorne
r); | 1852 m_resizeScrollableArea->resize(gestureEvent, m_offsetFromResizeCorne
r); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 | 2024 |
2070 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2025 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
2071 copyToVector(result.rectBasedTestResult(), nodes); | 2026 copyToVector(result.rectBasedTestResult(), nodes); |
2072 | 2027 |
2073 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. | 2028 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. |
2074 return findBestClickableCandidate(targetNode, targetPoint, touchCenter, touc
hRect, WillBeHeapVector<RefPtrWillBeMember<Node> > (nodes)); | 2029 return findBestClickableCandidate(targetNode, targetPoint, touchCenter, touc
hRect, WillBeHeapVector<RefPtrWillBeMember<Node> > (nodes)); |
2075 } | 2030 } |
2076 | 2031 |
2077 bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, co
nst IntSize& touchRadius, IntRect& targetArea, Node*& targetNode) | 2032 bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, co
nst IntSize& touchRadius, IntRect& targetArea, Node*& targetNode) |
2078 { | 2033 { |
2079 IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter); | 2034 HitTestResult result = hitTestResultAtPoint(touchCenter, HitTestRequest::Rea
dOnly | HitTestRequest::Active, touchRadius); |
2080 HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::Re
adOnly | HitTestRequest::Active, touchRadius); | |
2081 | 2035 |
2082 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); | 2036 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); |
2083 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2037 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
2084 copyToVector(result.rectBasedTestResult(), nodes); | 2038 copyToVector(result.rectBasedTestResult(), nodes); |
2085 | 2039 |
2086 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. | 2040 // FIXME: the explicit Vector conversion copies into a temporary and is wast
eful. |
2087 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect,
WillBeHeapVector<RefPtrWillBeMember<Node> >(nodes)); | 2041 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect,
WillBeHeapVector<RefPtrWillBeMember<Node> >(nodes)); |
2088 } | 2042 } |
2089 | 2043 |
2090 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe
stureEvent& gestureEvent, bool readOnly) | 2044 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe
stureEvent& gestureEvent, bool readOnly) |
(...skipping 12 matching lines...) Expand all Loading... |
2103 // for at least a couple of frames. | 2057 // for at least a couple of frames. |
2104 activeInterval = WTF::currentTime() - m_lastShowPressTimestamp; | 2058 activeInterval = WTF::currentTime() - m_lastShowPressTimestamp; |
2105 shouldKeepActiveForMinInterval = m_lastShowPressTimestamp && activeInter
val < minimumActiveInterval; | 2059 shouldKeepActiveForMinInterval = m_lastShowPressTimestamp && activeInter
val < minimumActiveInterval; |
2106 if (shouldKeepActiveForMinInterval) | 2060 if (shouldKeepActiveForMinInterval) |
2107 hitType |= HitTestRequest::ReadOnly; | 2061 hitType |= HitTestRequest::ReadOnly; |
2108 } | 2062 } |
2109 | 2063 |
2110 // Perform the rect-based hit-test. Note that we don't yet apply hover/activ
e state here | 2064 // Perform the rect-based hit-test. Note that we don't yet apply hover/activ
e state here |
2111 // because we need to resolve touch adjustment first so that we apply hover/
active it to | 2065 // because we need to resolve touch adjustment first so that we apply hover/
active it to |
2112 // the final adjusted node. | 2066 // the final adjusted node. |
2113 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.posit
ion()); | 2067 IntPoint hitTestPoint = gestureEvent.position(); |
2114 IntSize touchRadius = gestureEvent.area(); | 2068 IntSize touchRadius = gestureEvent.area(); |
2115 touchRadius.scale(1.f / 2); | 2069 touchRadius.scale(1.f / 2); |
2116 // FIXME: We should not do a rect-based hit-test if touch adjustment is disa
bled. | 2070 // FIXME: We should not do a rect-based hit-test if touch adjustment is disa
bled. |
2117 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H
itTestRequest::ReadOnly, touchRadius); | 2071 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H
itTestRequest::ReadOnly, touchRadius); |
2118 | 2072 |
2119 // Hit-test the main frame scrollbars (in addition to the child-frame and Re
nderLayer | |
2120 // scroll bars checked by the hit-test code. | |
2121 if (!hitTestResult.scrollbar()) { | |
2122 if (FrameView* view = m_frame->view()) { | |
2123 hitTestResult.setScrollbar(view->scrollbarAtPoint(gestureEvent.posit
ion())); | |
2124 } | |
2125 } | |
2126 | |
2127 // Adjust the location of the gesture to the most likely nearby node, as app
ropriate for the | 2073 // Adjust the location of the gesture to the most likely nearby node, as app
ropriate for the |
2128 // type of event. | 2074 // type of event. |
2129 PlatformGestureEvent adjustedEvent = gestureEvent; | 2075 PlatformGestureEvent adjustedEvent = gestureEvent; |
2130 applyTouchAdjustment(&adjustedEvent, &hitTestResult); | 2076 applyTouchAdjustment(&adjustedEvent, &hitTestResult); |
2131 | 2077 |
2132 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa
ry because | 2078 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa
ry because |
2133 // rect-based hit testing and touch adjustment sometimes return a different
node than | 2079 // rect-based hit testing and touch adjustment sometimes return a different
node than |
2134 // what a point-based hit test would return for the same point. | 2080 // what a point-based hit test would return for the same point. |
2135 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h
ttp://crbug.com/398914 | 2081 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h
ttp://crbug.com/398914 |
2136 if (shouldApplyTouchAdjustment(gestureEvent)) { | 2082 if (shouldApplyTouchAdjustment(gestureEvent)) { |
2137 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); | 2083 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); |
2138 if (!hitFrame) | 2084 if (!hitFrame) |
2139 hitFrame = m_frame; | 2085 hitFrame = m_frame; |
2140 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->windowT
oContents(adjustedEvent.position()), hitType | HitTestRequest::ReadOnly); | 2086 hitTestResult = hitTestResultInFrame(hitFrame, adjustedEvent.position(),
hitType | HitTestRequest::ReadOnly); |
2141 // FIXME: HitTest entry points should really check for main frame scroll
bars themselves. | |
2142 if (!hitTestResult.scrollbar()) { | |
2143 if (FrameView* view = m_frame->view()) { | |
2144 hitTestResult.setScrollbar(view->scrollbarAtPoint(gestureEvent.p
osition())); | |
2145 } | |
2146 } | |
2147 } | 2087 } |
2148 | 2088 |
2149 // Now apply hover/active state to the final target. | 2089 // Now apply hover/active state to the final target. |
2150 // FIXME: This is supposed to send mouseenter/mouseleave events, but doesn't
because we | 2090 // FIXME: This is supposed to send mouseenter/mouseleave events, but doesn't
because we |
2151 // aren't passing a PlatformMouseEvent. | 2091 // aren't passing a PlatformMouseEvent. |
2152 HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent); | 2092 HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent); |
2153 if (!request.readOnly()) | 2093 if (!request.readOnly()) |
2154 m_frame->document()->updateHoverActiveState(request, hitTestResult.inner
Element()); | 2094 m_frame->document()->updateHoverActiveState(request, hitTestResult.inner
Element()); |
2155 | 2095 |
2156 if (shouldKeepActiveForMinInterval) { | 2096 if (shouldKeepActiveForMinInterval) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2207 case PlatformEvent::GestureTwoFingerTap: | 2147 case PlatformEvent::GestureTwoFingerTap: |
2208 adjusted = bestClickableNodeForHitTestResult(*hitTestResult, adjustedPoi
nt, adjustedNode); | 2148 adjusted = bestClickableNodeForHitTestResult(*hitTestResult, adjustedPoi
nt, adjustedNode); |
2209 break; | 2149 break; |
2210 default: | 2150 default: |
2211 ASSERT_NOT_REACHED(); | 2151 ASSERT_NOT_REACHED(); |
2212 } | 2152 } |
2213 | 2153 |
2214 // Update the hit-test result to be a point-based result instead of a rect-b
ased result. | 2154 // Update the hit-test result to be a point-based result instead of a rect-b
ased result. |
2215 // FIXME: We should do this even when no candidate matches the node filter.
crbug.com/398914 | 2155 // FIXME: We should do this even when no candidate matches the node filter.
crbug.com/398914 |
2216 if (adjusted) { | 2156 if (adjusted) { |
2217 hitTestResult->resolveRectBasedTest(adjustedNode, m_frame->view()->windo
wToContents(adjustedPoint)); | 2157 hitTestResult->resolveRectBasedTest(adjustedNode, adjustedPoint); |
2218 gestureEvent->applyTouchAdjustment(adjustedPoint); | 2158 gestureEvent->applyTouchAdjustment(adjustedPoint); |
2219 } | 2159 } |
2220 } | 2160 } |
2221 | 2161 |
2222 void EventHandler::scheduleHoverStateUpdate() | 2162 void EventHandler::scheduleHoverStateUpdate() |
2223 { | 2163 { |
2224 if (!m_hoverTimer.isActive()) | 2164 if (!m_hoverTimer.isActive()) |
2225 m_hoverTimer.startOneShot(0, FROM_HERE); | 2165 m_hoverTimer.startOneShot(0, FROM_HERE); |
2226 } | 2166 } |
2227 | 2167 |
(...skipping 28 matching lines...) Expand all Loading... |
2256 m_fakeMouseMoveEventTimer.startOneShot(fakeMouseMoveShortInterval, F
ROM_HERE); | 2196 m_fakeMouseMoveEventTimer.startOneShot(fakeMouseMoveShortInterval, F
ROM_HERE); |
2257 } | 2197 } |
2258 } | 2198 } |
2259 | 2199 |
2260 void EventHandler::dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad& quad) | 2200 void EventHandler::dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad& quad) |
2261 { | 2201 { |
2262 FrameView* view = m_frame->view(); | 2202 FrameView* view = m_frame->view(); |
2263 if (!view) | 2203 if (!view) |
2264 return; | 2204 return; |
2265 | 2205 |
2266 if (!quad.containsPoint(view->windowToContents(m_lastKnownMousePosition))) | 2206 if (!quad.containsPoint(m_lastKnownMousePosition)) |
2267 return; | 2207 return; |
2268 | 2208 |
2269 dispatchFakeMouseMoveEventSoon(); | 2209 dispatchFakeMouseMoveEventSoon(); |
2270 } | 2210 } |
2271 | 2211 |
2272 void EventHandler::fakeMouseMoveEventTimerFired(Timer<EventHandler>* timer) | 2212 void EventHandler::fakeMouseMoveEventTimerFired(Timer<EventHandler>* timer) |
2273 { | 2213 { |
2274 ASSERT_UNUSED(timer, timer == &m_fakeMouseMoveEventTimer); | 2214 ASSERT_UNUSED(timer, timer == &m_fakeMouseMoveEventTimer); |
2275 ASSERT(!m_mousePressed); | 2215 ASSERT(!m_mousePressed); |
2276 | 2216 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2315 } | 2255 } |
2316 | 2256 |
2317 void EventHandler::hoverTimerFired(Timer<EventHandler>*) | 2257 void EventHandler::hoverTimerFired(Timer<EventHandler>*) |
2318 { | 2258 { |
2319 m_hoverTimer.stop(); | 2259 m_hoverTimer.stop(); |
2320 | 2260 |
2321 ASSERT(m_frame); | 2261 ASSERT(m_frame); |
2322 ASSERT(m_frame->document()); | 2262 ASSERT(m_frame->document()); |
2323 | 2263 |
2324 if (RenderView* renderer = m_frame->contentRenderer()) { | 2264 if (RenderView* renderer = m_frame->contentRenderer()) { |
2325 if (FrameView* view = m_frame->view()) { | 2265 HitTestRequest request(HitTestRequest::Move); |
2326 HitTestRequest request(HitTestRequest::Move); | 2266 HitTestResult result(m_lastKnownMousePosition); |
2327 HitTestResult result(view->windowToContents(m_lastKnownMousePosition
)); | 2267 renderer->hitTest(request, result); |
2328 renderer->hitTest(request, result); | 2268 m_frame->document()->updateHoverActiveState(request, result.innerElement
()); |
2329 m_frame->document()->updateHoverActiveState(request, result.innerEle
ment()); | |
2330 } | |
2331 } | 2269 } |
2332 } | 2270 } |
2333 | 2271 |
2334 void EventHandler::activeIntervalTimerFired(Timer<EventHandler>*) | 2272 void EventHandler::activeIntervalTimerFired(Timer<EventHandler>*) |
2335 { | 2273 { |
2336 m_activeIntervalTimer.stop(); | 2274 m_activeIntervalTimer.stop(); |
2337 | 2275 |
2338 if (m_frame | 2276 if (m_frame |
2339 && m_frame->document() | 2277 && m_frame->document() |
2340 && m_lastDeferredTapElement) { | 2278 && m_lastDeferredTapElement) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2464 bool EventHandler::dragHysteresisExceeded(const FloatPoint& floatDragViewportLoc
ation) const | 2402 bool EventHandler::dragHysteresisExceeded(const FloatPoint& floatDragViewportLoc
ation) const |
2465 { | 2403 { |
2466 return dragHysteresisExceeded(flooredIntPoint(floatDragViewportLocation)); | 2404 return dragHysteresisExceeded(flooredIntPoint(floatDragViewportLocation)); |
2467 } | 2405 } |
2468 | 2406 |
2469 bool EventHandler::dragHysteresisExceeded(const IntPoint& dragViewportLocation)
const | 2407 bool EventHandler::dragHysteresisExceeded(const IntPoint& dragViewportLocation)
const |
2470 { | 2408 { |
2471 FrameView* view = m_frame->view(); | 2409 FrameView* view = m_frame->view(); |
2472 if (!view) | 2410 if (!view) |
2473 return false; | 2411 return false; |
2474 IntPoint dragLocation = view->windowToContents(dragViewportLocation); | 2412 IntPoint dragLocation = dragViewportLocation; |
2475 IntSize delta = dragLocation - m_mouseDownPos; | 2413 IntSize delta = dragLocation - m_mouseDownPos; |
2476 | 2414 |
2477 int threshold = 3; | 2415 int threshold = 3; |
2478 | 2416 |
2479 return abs(delta.width()) >= threshold || abs(delta.height()) >= threshold; | 2417 return abs(delta.width()) >= threshold || abs(delta.height()) >= threshold; |
2480 } | 2418 } |
2481 | 2419 |
2482 bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEve
nt, TextEventInputType inputType) | 2420 bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEve
nt, TextEventInputType inputType) |
2483 { | 2421 { |
2484 // Platforms should differentiate real commands like selectAll from text inp
ut in disguise (like insertNewline), | 2422 // Platforms should differentiate real commands like selectAll from text inp
ut in disguise (like insertNewline), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2534 } | 2472 } |
2535 | 2473 |
2536 void EventHandler::setFrameWasScrolledByUser() | 2474 void EventHandler::setFrameWasScrolledByUser() |
2537 { | 2475 { |
2538 if (FrameView* view = m_frame->view()) | 2476 if (FrameView* view = m_frame->view()) |
2539 view->setWasScrolledByUser(true); | 2477 view->setWasScrolledByUser(true); |
2540 } | 2478 } |
2541 | 2479 |
2542 bool EventHandler::passMousePressEventToScrollbar(MouseEventWithHitTestResults&
mev) | 2480 bool EventHandler::passMousePressEventToScrollbar(MouseEventWithHitTestResults&
mev) |
2543 { | 2481 { |
2544 // First try to use the frame scrollbar. | 2482 // FIXME(sky): Remove |
2545 FrameView* view = m_frame->view(); | 2483 return false; |
2546 Scrollbar* scrollbar = view ? view->scrollbarAtPoint(mev.event().position())
: 0; | |
2547 | |
2548 // Then try the scrollbar in the hit test. | |
2549 if (!scrollbar) | |
2550 scrollbar = mev.scrollbar(); | |
2551 | |
2552 updateLastScrollbarUnderMouse(scrollbar, true); | |
2553 | |
2554 if (!scrollbar || !scrollbar->enabled()) | |
2555 return false; | |
2556 setFrameWasScrolledByUser(); | |
2557 scrollbar->mouseDown(mev.event()); | |
2558 return true; | |
2559 } | 2484 } |
2560 | 2485 |
2561 // If scrollbar (under mouse) is different from last, send a mouse exited. Set | 2486 // If scrollbar (under mouse) is different from last, send a mouse exited. Set |
2562 // last to scrollbar if setLast is true; else set last to 0. | 2487 // last to scrollbar if setLast is true; else set last to 0. |
2563 void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, bool setL
ast) | 2488 void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, bool setL
ast) |
2564 { | 2489 { |
2565 if (m_lastScrollbarUnderMouse != scrollbar) { | 2490 if (m_lastScrollbarUnderMouse != scrollbar) { |
2566 // Send mouse exited to the old scrollbar. | 2491 // Send mouse exited to the old scrollbar. |
2567 if (m_lastScrollbarUnderMouse) | 2492 if (m_lastScrollbarUnderMouse) |
2568 m_lastScrollbarUnderMouse->mouseExited(); | 2493 m_lastScrollbarUnderMouse->mouseExited(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2653 | 2578 |
2654 // First do hit tests for any new touch points. | 2579 // First do hit tests for any new touch points. |
2655 for (i = 0; i < points.size(); ++i) { | 2580 for (i = 0; i < points.size(); ++i) { |
2656 const PlatformTouchPoint& point = points[i]; | 2581 const PlatformTouchPoint& point = points[i]; |
2657 | 2582 |
2658 // Touch events implicitly capture to the touched node, and don't change | 2583 // Touch events implicitly capture to the touched node, and don't change |
2659 // active/hover states themselves (Gesture events do). So we only need | 2584 // active/hover states themselves (Gesture events do). So we only need |
2660 // to hit-test on touchstart, and it can be read-only. | 2585 // to hit-test on touchstart, and it can be read-only. |
2661 if (point.state() == PlatformTouchPoint::TouchPressed) { | 2586 if (point.state() == PlatformTouchPoint::TouchPressed) { |
2662 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEv
ent | HitTestRequest::ReadOnly | HitTestRequest::Active; | 2587 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEv
ent | HitTestRequest::ReadOnly | HitTestRequest::Active; |
2663 LayoutPoint pagePoint = roundedLayoutPoint(m_frame->view()->windowTo
Contents(point.pos())); | 2588 LayoutPoint pagePoint = roundedLayoutPoint(point.pos()); |
2664 HitTestResult result; | 2589 HitTestResult result; |
2665 if (!m_touchSequenceDocument) { | 2590 if (!m_touchSequenceDocument) { |
2666 result = hitTestResultAtPoint(pagePoint, hitType); | 2591 result = hitTestResultAtPoint(pagePoint, hitType); |
2667 } else if (m_touchSequenceDocument->frame()) { | 2592 } else if (m_touchSequenceDocument->frame()) { |
2668 LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocum
ent->frame()->view()->windowToContents(point.pos())); | 2593 LayoutPoint framePoint = roundedLayoutPoint(point.pos()); |
2669 result = hitTestResultInFrame(m_touchSequenceDocument->frame(),
framePoint, hitType); | 2594 result = hitTestResultInFrame(m_touchSequenceDocument->frame(),
framePoint, hitType); |
2670 } else | 2595 } else |
2671 continue; | 2596 continue; |
2672 | 2597 |
2673 Node* node = result.innerNode(); | 2598 Node* node = result.innerNode(); |
2674 if (!node) | 2599 if (!node) |
2675 continue; | 2600 continue; |
2676 | 2601 |
2677 // Touch events should not go to text nodes | 2602 // Touch events should not go to text nodes |
2678 if (node->isTextNode()) | 2603 if (node->isTextNode()) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2776 // Document so that there's some valid node here. Perhaps this | 2701 // Document so that there's some valid node here. Perhaps this |
2777 // should really be LocalDOMWindow, but in all other cases the targe
t of | 2702 // should really be LocalDOMWindow, but in all other cases the targe
t of |
2778 // a Touch is a Node so using the window could be a breaking change. | 2703 // a Touch is a Node so using the window could be a breaking change. |
2779 // Since we know there was no handler invoked, the specific target | 2704 // Since we know there was no handler invoked, the specific target |
2780 // should be completely irrelevant to the application. | 2705 // should be completely irrelevant to the application. |
2781 touchTarget = m_touchSequenceDocument; | 2706 touchTarget = m_touchSequenceDocument; |
2782 targetFrame = m_touchSequenceDocument->frame(); | 2707 targetFrame = m_touchSequenceDocument->frame(); |
2783 } | 2708 } |
2784 ASSERT(targetFrame); | 2709 ASSERT(targetFrame); |
2785 | 2710 |
2786 // pagePoint should always be relative to the target elements | 2711 FloatPoint pagePoint = point.pos(); |
2787 // containing frame. | |
2788 FloatPoint pagePoint = targetFrame->view()->windowToContents(point.pos()
); | |
2789 | 2712 |
2790 float scaleFactor = 1.0f / targetFrame->pageZoomFactor(); | 2713 float scaleFactor = 1.0f / targetFrame->pageZoomFactor(); |
2791 | 2714 |
2792 FloatPoint adjustedPagePoint = pagePoint.scaledBy(scaleFactor); | 2715 FloatPoint adjustedPagePoint = pagePoint.scaledBy(scaleFactor); |
2793 FloatSize adjustedRadius = point.radius().scaledBy(scaleFactor); | 2716 FloatSize adjustedRadius = point.radius().scaledBy(scaleFactor); |
2794 | 2717 |
2795 RefPtrWillBeRawPtr<Touch> touch = Touch::create( | 2718 RefPtrWillBeRawPtr<Touch> touch = Touch::create( |
2796 targetFrame, touchTarget.get(), point.id(), point.screenPos(), adjus
tedPagePoint, adjustedRadius, point.rotationAngle(), point.force()); | 2719 targetFrame, touchTarget.get(), point.id(), point.screenPos(), adjus
tedPagePoint, adjustedRadius, point.rotationAngle(), point.force()); |
2797 | 2720 |
2798 // Ensure this target's touch list exists, even if it ends up empty, so | 2721 // Ensure this target's touch list exists, even if it ends up empty, so |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2930 unsigned EventHandler::accessKeyModifiers() | 2853 unsigned EventHandler::accessKeyModifiers() |
2931 { | 2854 { |
2932 #if OS(MACOSX) | 2855 #if OS(MACOSX) |
2933 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 2856 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
2934 #else | 2857 #else |
2935 return PlatformEvent::AltKey; | 2858 return PlatformEvent::AltKey; |
2936 #endif | 2859 #endif |
2937 } | 2860 } |
2938 | 2861 |
2939 } // namespace blink | 2862 } // namespace blink |
OLD | NEW |