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 1209 matching lines...) Loading... |
1220 m_mouseDownMayStartSelect = false; | 1220 m_mouseDownMayStartSelect = false; |
1221 m_mouseDownMayStartAutoscroll = false; | 1221 m_mouseDownMayStartAutoscroll = false; |
1222 if (FrameView* view = m_frame->view()) | 1222 if (FrameView* view = m_frame->view()) |
1223 m_mouseDownPos = view->windowToContents(mouseEvent.position()); | 1223 m_mouseDownPos = view->windowToContents(mouseEvent.position()); |
1224 else { | 1224 else { |
1225 invalidateClick(); | 1225 invalidateClick(); |
1226 return false; | 1226 return false; |
1227 } | 1227 } |
1228 m_mouseDownWasInSubframe = false; | 1228 m_mouseDownWasInSubframe = false; |
1229 | 1229 |
1230 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Active; | 1230 // Mouse events simulated from touch should not hit-test again. |
1231 if (mouseEvent.fromTouch()) | 1231 ASSERT(!mouseEvent.fromTouch()); |
1232 hitType |= HitTestRequest::ReadOnly; | 1232 |
1233 HitTestRequest request(hitType); | 1233 HitTestRequest request(HitTestRequest::Active); |
1234 // Save the document point we generate in case the window coordinate is inva
lidated by what happens | 1234 // Save the document point we generate in case the window coordinate is inva
lidated by what happens |
1235 // when we dispatch the event. | 1235 // when we dispatch the event. |
1236 LayoutPoint documentPoint = documentPointForWindowPoint(m_frame, mouseEvent.
position()); | 1236 LayoutPoint documentPoint = documentPointForWindowPoint(m_frame, mouseEvent.
position()); |
1237 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re
quest, documentPoint, mouseEvent); | 1237 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re
quest, documentPoint, mouseEvent); |
1238 | 1238 |
1239 if (!mev.targetNode()) { | 1239 if (!mev.targetNode()) { |
1240 invalidateClick(); | 1240 invalidateClick(); |
1241 return false; | 1241 return false; |
1242 } | 1242 } |
1243 | 1243 |
(...skipping 158 matching lines...) Loading... |
1402 | 1402 |
1403 if (m_frameSetBeingResized) | 1403 if (m_frameSetBeingResized) |
1404 return !dispatchMouseEvent(EventTypeNames::mousemove, m_frameSetBeingRes
ized.get(), 0, mouseEvent, false); | 1404 return !dispatchMouseEvent(EventTypeNames::mousemove, m_frameSetBeingRes
ized.get(), 0, mouseEvent, false); |
1405 | 1405 |
1406 // Send events right to a scrollbar if the mouse is pressed. | 1406 // Send events right to a scrollbar if the mouse is pressed. |
1407 if (m_lastScrollbarUnderMouse && m_mousePressed) { | 1407 if (m_lastScrollbarUnderMouse && m_mousePressed) { |
1408 m_lastScrollbarUnderMouse->mouseMoved(mouseEvent); | 1408 m_lastScrollbarUnderMouse->mouseMoved(mouseEvent); |
1409 return true; | 1409 return true; |
1410 } | 1410 } |
1411 | 1411 |
| 1412 // Mouse events simulated from touch should not hit-test again. |
| 1413 ASSERT(!mouseEvent.fromTouch()); |
| 1414 |
1412 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Move; | 1415 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Move; |
1413 if (mouseEvent.fromTouch()) | |
1414 hitType |= HitTestRequest::ReadOnly; | |
1415 | |
1416 if (m_mousePressed) | 1416 if (m_mousePressed) |
1417 hitType |= HitTestRequest::Active; | 1417 hitType |= HitTestRequest::Active; |
1418 else if (onlyUpdateScrollbars) { | 1418 else if (onlyUpdateScrollbars) { |
1419 // Mouse events should be treated as "read-only" if we're updating only
scrollbars. This | 1419 // Mouse events should be treated as "read-only" if we're updating only
scrollbars. This |
1420 // means that :hover and :active freeze in the state they were in, rathe
r than updating | 1420 // means that :hover and :active freeze in the state they were in, rathe
r than updating |
1421 // for nodes the mouse moves while the window is not key (which will be
the case if | 1421 // for nodes the mouse moves while the window is not key (which will be
the case if |
1422 // onlyUpdateScrollbars is true). | 1422 // onlyUpdateScrollbars is true). |
1423 hitType |= HitTestRequest::ReadOnly; | 1423 hitType |= HitTestRequest::ReadOnly; |
1424 } | 1424 } |
1425 | 1425 |
(...skipping 107 matching lines...) Loading... |
1533 if (m_frameSetBeingResized) | 1533 if (m_frameSetBeingResized) |
1534 return !dispatchMouseEvent(EventTypeNames::mouseup, m_frameSetBeingResiz
ed.get(), m_clickCount, mouseEvent, false); | 1534 return !dispatchMouseEvent(EventTypeNames::mouseup, m_frameSetBeingResiz
ed.get(), m_clickCount, mouseEvent, false); |
1535 | 1535 |
1536 if (m_lastScrollbarUnderMouse) { | 1536 if (m_lastScrollbarUnderMouse) { |
1537 invalidateClick(); | 1537 invalidateClick(); |
1538 m_lastScrollbarUnderMouse->mouseUp(mouseEvent); | 1538 m_lastScrollbarUnderMouse->mouseUp(mouseEvent); |
1539 bool setUnder = false; | 1539 bool setUnder = false; |
1540 return !dispatchMouseEvent(EventTypeNames::mouseup, m_lastNodeUnderMouse
.get(), m_clickCount, mouseEvent, setUnder); | 1540 return !dispatchMouseEvent(EventTypeNames::mouseup, m_lastNodeUnderMouse
.get(), m_clickCount, mouseEvent, setUnder); |
1541 } | 1541 } |
1542 | 1542 |
| 1543 // Mouse events simulated from touch should not hit-test again. |
| 1544 ASSERT(!mouseEvent.fromTouch()); |
| 1545 |
1543 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Release; | 1546 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Release; |
1544 if (mouseEvent.fromTouch()) | |
1545 hitType |= HitTestRequest::ReadOnly; | |
1546 HitTestRequest request(hitType); | 1547 HitTestRequest request(hitType); |
1547 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); | 1548 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); |
1548 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN
ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); | 1549 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN
ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); |
1549 if (m_eventHandlerWillResetCapturingMouseEventsNode) | 1550 if (m_eventHandlerWillResetCapturingMouseEventsNode) |
1550 m_capturingMouseEventsNode = nullptr; | 1551 m_capturingMouseEventsNode = nullptr; |
1551 if (subframe && passMouseReleaseEventToSubframe(mev, subframe)) | 1552 if (subframe && passMouseReleaseEventToSubframe(mev, subframe)) |
1552 return true; | 1553 return true; |
1553 | 1554 |
1554 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, mev.
targetNode(), m_clickCount, mouseEvent, false); | 1555 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, mev.
targetNode(), m_clickCount, mouseEvent, false); |
1555 | 1556 |
(...skipping 648 matching lines...) Loading... |
2204 default: | 2205 default: |
2205 ASSERT_NOT_REACHED(); | 2206 ASSERT_NOT_REACHED(); |
2206 } | 2207 } |
2207 return false; | 2208 return false; |
2208 } | 2209 } |
2209 | 2210 |
2210 bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target
edEvent) | 2211 bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target
edEvent) |
2211 { | 2212 { |
2212 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 2213 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
2213 | 2214 |
2214 // FIXME: Refactor this code to not hit test multiple times. We use the adju
sted position to ensure that the correct node is targeted by the later redundant
hit tests. | |
2215 | |
2216 unsigned modifierFlags = 0; | 2215 unsigned modifierFlags = 0; |
2217 if (gestureEvent.altKey()) | 2216 if (gestureEvent.altKey()) |
2218 modifierFlags |= PlatformEvent::AltKey; | 2217 modifierFlags |= PlatformEvent::AltKey; |
2219 if (gestureEvent.ctrlKey()) | 2218 if (gestureEvent.ctrlKey()) |
2220 modifierFlags |= PlatformEvent::CtrlKey; | 2219 modifierFlags |= PlatformEvent::CtrlKey; |
2221 if (gestureEvent.metaKey()) | 2220 if (gestureEvent.metaKey()) |
2222 modifierFlags |= PlatformEvent::MetaKey; | 2221 modifierFlags |= PlatformEvent::MetaKey; |
2223 if (gestureEvent.shiftKey()) | 2222 if (gestureEvent.shiftKey()) |
2224 modifierFlags |= PlatformEvent::ShiftKey; | 2223 modifierFlags |= PlatformEvent::ShiftKey; |
2225 PlatformEvent::Modifiers modifiers = static_cast<PlatformEvent::Modifiers>(m
odifierFlags); | 2224 PlatformEvent::Modifiers modifiers = static_cast<PlatformEvent::Modifiers>(m
odifierFlags); |
2226 | 2225 |
| 2226 // We use the adjusted position so the application isn't surprised to see a
event with |
| 2227 // co-ordinates outside the target's bounds. |
2227 IntPoint adjustedPoint = gestureEvent.position(); | 2228 IntPoint adjustedPoint = gestureEvent.position(); |
2228 | 2229 |
2229 PlatformMouseEvent fakeMouseMove(adjustedPoint, gestureEvent.globalPosition(
), | 2230 PlatformMouseEvent fakeMouseMove(adjustedPoint, gestureEvent.globalPosition(
), |
2230 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, | 2231 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, |
2231 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2232 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
2232 handleMouseMoveEvent(fakeMouseMove); | 2233 dispatchMouseEvent(EventTypeNames::mousemove, targetedEvent.targetNode(), 0,
fakeMouseMove, true); |
2233 | 2234 |
2234 bool defaultPrevented = false; | |
2235 PlatformMouseEvent fakeMouseDown(adjustedPoint, gestureEvent.globalPosition(
), | 2235 PlatformMouseEvent fakeMouseDown(adjustedPoint, gestureEvent.globalPosition(
), |
2236 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), | 2236 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), |
2237 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2237 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
2238 defaultPrevented |= handleMousePressEvent(fakeMouseDown); | 2238 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, targetedE
vent.targetNode(), gestureEvent.tapCount(), fakeMouseDown, true); |
| 2239 swallowEvent = swallowEvent || !handleMouseFocus(fakeMouseDown); |
2239 | 2240 |
2240 PlatformMouseEvent fakeMouseUp(adjustedPoint, gestureEvent.globalPosition(), | 2241 PlatformMouseEvent fakeMouseUp(adjustedPoint, gestureEvent.globalPosition(), |
2241 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(), | 2242 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(), |
2242 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2243 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
2243 defaultPrevented |= handleMouseReleaseEvent(fakeMouseUp); | 2244 swallowEvent |= !dispatchMouseEvent(EventTypeNames::mouseup, targetedEvent.t
argetNode(), gestureEvent.tapCount(), fakeMouseUp, false); |
| 2245 swallowEvent |= !dispatchMouseEvent(EventTypeNames::click, targetedEvent.tar
getNode(), gestureEvent.tapCount(), fakeMouseUp, true); |
2244 | 2246 |
2245 return defaultPrevented; | 2247 return swallowEvent; |
2246 } | 2248 } |
2247 | 2249 |
2248 bool EventHandler::handleGestureLongPress(const GestureEventWithHitTestResults&
targetedEvent) | 2250 bool EventHandler::handleGestureLongPress(const GestureEventWithHitTestResults&
targetedEvent) |
2249 { | 2251 { |
2250 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 2252 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
2251 IntPoint adjustedPoint = gestureEvent.position(); | 2253 IntPoint adjustedPoint = gestureEvent.position(); |
2252 | 2254 |
2253 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests
here (re-using the | 2255 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests
here (re-using the |
2254 // supplied HitTestResult), but that will require some overhaul of the touch
drag-and-drop code | 2256 // supplied HitTestResult), but that will require some overhaul of the touch
drag-and-drop code |
2255 // and LongPress is such a special scenario that it's unlikely to matter muc
h in practice. | 2257 // and LongPress is such a special scenario that it's unlikely to matter muc
h in practice. |
(...skipping 1542 matching lines...) Loading... |
3798 unsigned EventHandler::accessKeyModifiers() | 3800 unsigned EventHandler::accessKeyModifiers() |
3799 { | 3801 { |
3800 #if OS(MACOSX) | 3802 #if OS(MACOSX) |
3801 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3803 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3802 #else | 3804 #else |
3803 return PlatformEvent::AltKey; | 3805 return PlatformEvent::AltKey; |
3804 #endif | 3806 #endif |
3805 } | 3807 } |
3806 | 3808 |
3807 } // namespace WebCore | 3809 } // namespace WebCore |
OLD | NEW |