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 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2230 { | 2230 { |
2231 TRACE_EVENT0("input", "EventHandler::handleGestureEvent"); | 2231 TRACE_EVENT0("input", "EventHandler::handleGestureEvent"); |
2232 | 2232 |
2233 // Propagation to inner frames is handled below this function. | 2233 // Propagation to inner frames is handled below this function. |
2234 ASSERT(m_frame == m_frame->localFrameRoot()); | 2234 ASSERT(m_frame == m_frame->localFrameRoot()); |
2235 | 2235 |
2236 // Non-scrolling related gesture events do a single cross-frame hit-test and jump | 2236 // Non-scrolling related gesture events do a single cross-frame hit-test and jump |
2237 // directly to the inner most frame. This matches handleMousePressEvent etc. | 2237 // directly to the inner most frame. This matches handleMousePressEvent etc. |
2238 ASSERT(!targetedEvent.event().isScrollEvent()); | 2238 ASSERT(!targetedEvent.event().isScrollEvent()); |
2239 | 2239 |
2240 // update mouseout/leave/over/enter events before jumping directly to the in ner most frame | |
2241 if (targetedEvent.event().type() == PlatformEvent::GestureTap) | |
2242 updateGestureTargetNodeForMouseEvent(targetedEvent); | |
2243 | |
2240 // Route to the correct frame. | 2244 // Route to the correct frame. |
2241 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) | 2245 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) |
2242 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t); | 2246 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t); |
2243 | 2247 |
2244 // No hit test result, handle in root instance. Perhaps we should just retur n false instead? | 2248 // No hit test result, handle in root instance. Perhaps we should just retur n false instead? |
2245 return handleGestureEventInFrame(targetedEvent); | 2249 return handleGestureEventInFrame(targetedEvent); |
2246 } | 2250 } |
2247 | 2251 |
2248 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent) | 2252 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent) |
2249 { | 2253 { |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2831 // we should clear the old hovered node from the old hovered frame. | 2835 // we should clear the old hovered node from the old hovered frame. |
2832 if (newHoverFrame != oldHoverFrame) | 2836 if (newHoverFrame != oldHoverFrame) |
2833 doc->updateHoverActiveState(request, nullptr); | 2837 doc->updateHoverActiveState(request, nullptr); |
2834 } | 2838 } |
2835 } | 2839 } |
2836 | 2840 |
2837 // Recursively set the new active/hover states on every frame in the chain o f innerElement. | 2841 // Recursively set the new active/hover states on every frame in the chain o f innerElement. |
2838 m_frame->document()->updateHoverActiveState(request, innerElement); | 2842 m_frame->document()->updateHoverActiveState(request, innerElement); |
2839 } | 2843 } |
2840 | 2844 |
2845 // Update the mouseover/mouseenter/mouseout/mouseleave events across all frames for this gesture, | |
2846 // before passing the targeted gesture event directly to a hit frame. | |
2847 void EventHandler::updateGestureTargetNodeForMouseEvent(const GestureEventWithHi tTestResults& targetedEvent) | |
2848 { | |
2849 ASSERT(m_frame == m_frame->localFrameRoot()); | |
2850 | |
2851 // Behaviour of this function is as follows: | |
2852 // - Create the chain of all entered frames. | |
2853 // - Compare the last frame chain under the gesture to newly entered frame c hain from the main frame one by one. | |
2854 // - If the last frame doesn't match with the entered frame, then create the chain of exited frames from the last frame chain. | |
2855 // - Dispatch mouseout/mouseleave events of the exited frames from the insid e out. | |
2856 // - Dispatch mouseover/mouseenter events of the entered frames into the ins ide. | |
2857 | |
2858 // Insert the ancestors of the frame having the new target node to the enter ed frame chain | |
2859 WillBeHeapVector<LocalFrame*> enteredFrameChain; | |
2860 LocalFrame* enteredFrameInDocument = targetedEvent.hitTestResult().innerNode Frame(); | |
2861 while (enteredFrameInDocument) { | |
2862 enteredFrameChain.append(enteredFrameInDocument); | |
2863 Frame* parentFrame = enteredFrameInDocument->tree().parent(); | |
2864 enteredFrameInDocument = parentFrame && parentFrame->isLocalFrame() ? to LocalFrame(parentFrame) : nullptr; | |
2865 } | |
2866 | |
2867 size_t indexEnteredFrameChain = enteredFrameChain.size(); | |
2868 LocalFrame* exitedFrameInDocument = m_frame; | |
2869 WillBeHeapVector<LocalFrame*> exitedFrameChain; | |
2870 // Insert the frame from the disagreement between last frames and entered fr ames | |
2871 while (exitedFrameInDocument) { | |
2872 Node* lastNodeUnderTap = exitedFrameInDocument->eventHandler().m_lastNod eUnderMouse.get(); | |
2873 if (!lastNodeUnderTap) | |
2874 break; | |
2875 | |
2876 LocalFrame* nextExitedFrameInDocument = nullptr; | |
2877 if (lastNodeUnderTap->isFrameOwnerElement()) { | |
2878 HTMLFrameOwnerElement* owner = toHTMLFrameOwnerElement(lastNodeUnder Tap); | |
2879 if (owner->contentFrame() && owner->contentFrame()->isLocalFrame()) | |
2880 nextExitedFrameInDocument = toLocalFrame(owner->contentFrame()); | |
2881 } | |
2882 | |
2883 if (exitedFrameChain.size() > 0) { | |
2884 exitedFrameChain.append(exitedFrameInDocument); | |
2885 } else { | |
2886 LocalFrame* enteredFrameInDocument = indexEnteredFrameChain ? entere dFrameChain[indexEnteredFrameChain-1] : nullptr; | |
2887 // Avoid that unnecessary mouse events are fired on tapping across t he frames | |
mustaq
2015/06/16 14:50:44
Thanks Miyoung, I was thinking about a scenario ex
Miyoung Shin(c)
2015/06/20 21:08:29
The iteration of this loop is to check frames from
mustaq
2015/07/02 20:37:29
Thanks for clarifying, and also for adding the ela
| |
2888 // If tapping is moved x1 to x2 , the last frame chains is, | |
2889 // Main frame-> A frame -> B frame -> C frame | |
2890 // and the new frame chains is, | |
2891 // Main frame -> A frame -> D frame -> E frame | |
2892 // |------Main frame--------------------| | |
2893 // | |----------------A---------------| | | |
2894 // | | |-----B-----| |-----D------| | | | |
2895 // | | | |---C---| | | |---E----| | | | | |
2896 // | | | | x1 | | | | x2 | | | | | |
2897 // | | | |-------| | | |--------| | | | | |
2898 // | | |-----------| |------------| | | | |
2899 // | |--------------------------------| | | |
2900 // |------------------------------------| | |
2901 // For mouseout/mouseleave events, we should make the exited frame chain like B frame -> C frame. | |
2902 // For mouseover/mouseenter events, we should make the entered fram e chain like D frame -> E frame. | |
2903 // And in main frame and A sub-frame we shouldn't fire any mouse ev ents. | |
2904 if (exitedFrameInDocument != enteredFrameInDocument) | |
2905 exitedFrameChain.append(exitedFrameInDocument); | |
2906 else if (nextExitedFrameInDocument && indexEnteredFrameChain) | |
2907 --indexEnteredFrameChain; | |
2908 } | |
2909 exitedFrameInDocument = nextExitedFrameInDocument; | |
2910 } | |
2911 | |
2912 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | |
2913 unsigned modifiers = gestureEvent.modifiers(); | |
2914 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(), | |
2915 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, | |
2916 static_cast<PlatformEvent::Modifiers>(modifiers), | |
2917 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | |
2918 | |
2919 // Update the mouseout/mouseleave event | |
2920 size_t indexExitedFrameChain = exitedFrameChain.size(); | |
2921 while (indexExitedFrameChain) { | |
2922 LocalFrame* exitedFrameInDocument = exitedFrameChain[--indexExitedFrameC hain]; | |
2923 exitedFrameInDocument->eventHandler().updateMouseEventTargetNode(nullptr , fakeMouseMove, true); | |
2924 } | |
2925 | |
2926 // update the mouseover/mouseenter event | |
2927 while (indexEnteredFrameChain > 1) { | |
Miyoung Shin(c)
2015/06/20 21:08:29
After updating the test, I found A sub frame didn'
mustaq
2015/07/02 20:37:29
The change makes sense. But this shouldn't influen
Miyoung Shin(c)
2015/07/05 12:39:33
Yes I got rid of A from list, but A is the parent
mustaq
2015/07/06 17:14:50
I think A shouldn't get any bubbling events from c
| |
2928 LocalFrame* enteredFrameInDocument = enteredFrameChain[--indexEnteredFra meChain]; | |
2929 Node* enteredFrameNode = enteredFrameChain[indexEnteredFrameChain-1]->de precatedLocalOwner(); | |
2930 enteredFrameInDocument->eventHandler().updateMouseEventTargetNode(entere dFrameNode, fakeMouseMove, true); | |
2931 } | |
2932 } | |
2933 | |
2841 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly) | 2934 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly) |
2842 { | 2935 { |
2843 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); | 2936 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); |
2844 | 2937 |
2845 ASSERT(m_frame == m_frame->localFrameRoot()); | 2938 ASSERT(m_frame == m_frame->localFrameRoot()); |
2846 // Scrolling events get hit tested per frame (like wheel events do). | 2939 // Scrolling events get hit tested per frame (like wheel events do). |
2847 ASSERT(!gestureEvent.isScrollEvent()); | 2940 ASSERT(!gestureEvent.isScrollEvent()); |
2848 | 2941 |
2849 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); | 2942 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); |
2850 double activeInterval = 0; | 2943 double activeInterval = 0; |
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4146 unsigned EventHandler::accessKeyModifiers() | 4239 unsigned EventHandler::accessKeyModifiers() |
4147 { | 4240 { |
4148 #if OS(MACOSX) | 4241 #if OS(MACOSX) |
4149 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4242 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
4150 #else | 4243 #else |
4151 return PlatformEvent::AltKey; | 4244 return PlatformEvent::AltKey; |
4152 #endif | 4245 #endif |
4153 } | 4246 } |
4154 | 4247 |
4155 } // namespace blink | 4248 } // namespace blink |
OLD | NEW |