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 2243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2254 { | 2254 { |
2255 TRACE_EVENT0("input", "EventHandler::handleGestureEvent"); | 2255 TRACE_EVENT0("input", "EventHandler::handleGestureEvent"); |
2256 | 2256 |
2257 // Propagation to inner frames is handled below this function. | 2257 // Propagation to inner frames is handled below this function. |
2258 ASSERT(m_frame == m_frame->localFrameRoot()); | 2258 ASSERT(m_frame == m_frame->localFrameRoot()); |
2259 | 2259 |
2260 // Non-scrolling related gesture events do a single cross-frame hit-test and jump | 2260 // Non-scrolling related gesture events do a single cross-frame hit-test and jump |
2261 // directly to the inner most frame. This matches handleMousePressEvent etc. | 2261 // directly to the inner most frame. This matches handleMousePressEvent etc. |
2262 ASSERT(!targetedEvent.event().isScrollEvent()); | 2262 ASSERT(!targetedEvent.event().isScrollEvent()); |
2263 | 2263 |
2264 // update mouseout/leave/over/enter events before jumping directly to the in ner most frame | |
2265 if (targetedEvent.event().type() == PlatformEvent::GestureTap) | |
2266 updateGestureTargetNodeForMouseEvent(targetedEvent); | |
2267 | |
2264 // Route to the correct frame. | 2268 // Route to the correct frame. |
2265 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) | 2269 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) |
2266 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t); | 2270 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t); |
2267 | 2271 |
2268 // No hit test result, handle in root instance. Perhaps we should just retur n false instead? | 2272 // No hit test result, handle in root instance. Perhaps we should just retur n false instead? |
2269 return handleGestureEventInFrame(targetedEvent); | 2273 return handleGestureEventInFrame(targetedEvent); |
2270 } | 2274 } |
2271 | 2275 |
2272 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent) | 2276 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent) |
2273 { | 2277 { |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2855 // we should clear the old hovered node from the old hovered frame. | 2859 // we should clear the old hovered node from the old hovered frame. |
2856 if (newHoverFrame != oldHoverFrame) | 2860 if (newHoverFrame != oldHoverFrame) |
2857 doc->updateHoverActiveState(request, nullptr); | 2861 doc->updateHoverActiveState(request, nullptr); |
2858 } | 2862 } |
2859 } | 2863 } |
2860 | 2864 |
2861 // Recursively set the new active/hover states on every frame in the chain o f innerElement. | 2865 // Recursively set the new active/hover states on every frame in the chain o f innerElement. |
2862 m_frame->document()->updateHoverActiveState(request, innerElement); | 2866 m_frame->document()->updateHoverActiveState(request, innerElement); |
2863 } | 2867 } |
2864 | 2868 |
2869 // Update the mouseover/mouseenter/mouseout/mouseleave events across all frames for this gesture, | |
2870 // before passing the targeted gesture event directly to a hit frame. | |
2871 void EventHandler::updateGestureTargetNodeForMouseEvent(const GestureEventWithHi tTestResults& targetedEvent) | |
2872 { | |
2873 ASSERT(m_frame == m_frame->localFrameRoot()); | |
2874 | |
2875 // Behaviour of this function is as follows: | |
2876 // - Create the chain of all entered frames. | |
2877 // - Compare the last frame chain under the gesture to newly entered frame c hain from the main frame one by one. | |
2878 // - If the last frame doesn't match with the entered frame, then create the chain of exited frames from the last frame chain. | |
2879 // - Dispatch mouseout/mouseleave events of the exited frames from the insid e out. | |
2880 // - Dispatch mouseover/mouseenter events of the entered frames into the ins ide. | |
2881 | |
2882 // Insert the ancestors of the frame having the new target node to the enter ed frame chain | |
2883 WillBeHeapVector<LocalFrame*> enteredFrameChain; | |
2884 LocalFrame* enteredFrameInDocument = targetedEvent.hitTestResult().innerNode Frame(); | |
2885 while (enteredFrameInDocument) { | |
2886 enteredFrameChain.append(enteredFrameInDocument); | |
2887 Frame* parentFrame = enteredFrameInDocument->tree().parent(); | |
2888 enteredFrameInDocument = parentFrame && parentFrame->isLocalFrame() ? to LocalFrame(parentFrame) : nullptr; | |
2889 } | |
2890 | |
2891 size_t indexEnteredFrameChain = enteredFrameChain.size(); | |
2892 LocalFrame* exitedFrameInDocument = m_frame; | |
2893 WillBeHeapVector<LocalFrame*> exitedFrameChain; | |
2894 // Insert the frame from the disagreement between last frames and entered fr ames | |
2895 while (exitedFrameInDocument) { | |
2896 Node* lastNodeUnderTap = exitedFrameInDocument->eventHandler().lastNodeU nderMouse(); | |
2897 if (!lastNodeUnderTap) | |
2898 break; | |
2899 | |
2900 LocalFrame* nextExitedFrameInDocument = nullptr; | |
2901 if (lastNodeUnderTap->isFrameOwnerElement()) { | |
2902 HTMLFrameOwnerElement* owner = toHTMLFrameOwnerElement(lastNodeUnder Tap); | |
2903 if (owner->contentFrame() && owner->contentFrame()->isLocalFrame()) | |
2904 nextExitedFrameInDocument = toLocalFrame(owner->contentFrame()); | |
2905 } | |
2906 | |
2907 if (exitedFrameChain.size() > 0) { | |
2908 exitedFrameChain.append(exitedFrameInDocument); | |
2909 } else { | |
2910 LocalFrame* enteredFrameInDocument = indexEnteredFrameChain ? entere dFrameChain[indexEnteredFrameChain-1] : nullptr; | |
mustaq
2015/06/08 17:24:24
Could you please add a comment explaining the logi
Miyoung Shin(c)
2015/06/10 12:10:05
I tried to remain the comment in more detail at th
| |
2911 if (exitedFrameInDocument != enteredFrameInDocument) | |
2912 exitedFrameChain.append(exitedFrameInDocument); | |
2913 else if (nextExitedFrameInDocument && indexEnteredFrameChain) | |
2914 --indexEnteredFrameChain; | |
2915 } | |
2916 exitedFrameInDocument = nextExitedFrameInDocument; | |
2917 } | |
2918 | |
2919 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | |
2920 unsigned modifiers = gestureEvent.modifiers(); | |
2921 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(), | |
2922 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, | |
2923 static_cast<PlatformEvent::Modifiers>(modifiers), | |
2924 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | |
2925 | |
2926 // Update the mouseout/mouseleave event | |
2927 size_t indexExitedFrameChain = exitedFrameChain.size(); | |
2928 while (indexExitedFrameChain) { | |
2929 LocalFrame* exitedFrameInDocument = exitedFrameChain[--indexExitedFrameC hain]; | |
2930 exitedFrameInDocument->eventHandler().updateMouseEventTargetNode(nullptr , fakeMouseMove, true); | |
2931 } | |
2932 | |
2933 // update the mouseover/mouseenter event | |
2934 while (indexEnteredFrameChain > 1) { | |
2935 LocalFrame* enteredFrameInDocument = enteredFrameChain[--indexEnteredFra meChain]; | |
2936 Node* enteredFrameNode = enteredFrameChain[indexEnteredFrameChain-1]->de precatedLocalOwner(); | |
2937 enteredFrameInDocument->eventHandler().updateMouseEventTargetNode(entere dFrameNode, fakeMouseMove, true); | |
2938 } | |
2939 } | |
2940 | |
2865 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly) | 2941 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly) |
2866 { | 2942 { |
2867 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); | 2943 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); |
2868 | 2944 |
2869 ASSERT(m_frame == m_frame->localFrameRoot()); | 2945 ASSERT(m_frame == m_frame->localFrameRoot()); |
2870 // Scrolling events get hit tested per frame (like wheel events do). | 2946 // Scrolling events get hit tested per frame (like wheel events do). |
2871 ASSERT(!gestureEvent.isScrollEvent()); | 2947 ASSERT(!gestureEvent.isScrollEvent()); |
2872 | 2948 |
2873 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); | 2949 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); |
2874 double activeInterval = 0; | 2950 double activeInterval = 0; |
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4170 unsigned EventHandler::accessKeyModifiers() | 4246 unsigned EventHandler::accessKeyModifiers() |
4171 { | 4247 { |
4172 #if OS(MACOSX) | 4248 #if OS(MACOSX) |
4173 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4249 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
4174 #else | 4250 #else |
4175 return PlatformEvent::AltKey; | 4251 return PlatformEvent::AltKey; |
4176 #endif | 4252 #endif |
4177 } | 4253 } |
4178 | 4254 |
4179 } // namespace blink | 4255 } // namespace blink |
OLD | NEW |