Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: Source/core/input/EventHandler.cpp

Issue 1170513002: Update the mouse events on tapping of gesture across frames (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/input/EventHandler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 { 1842 {
1843 TRACE_EVENT0("input", "EventHandler::handleGestureEvent"); 1843 TRACE_EVENT0("input", "EventHandler::handleGestureEvent");
1844 1844
1845 // Propagation to inner frames is handled below this function. 1845 // Propagation to inner frames is handled below this function.
1846 ASSERT(m_frame == m_frame->localFrameRoot()); 1846 ASSERT(m_frame == m_frame->localFrameRoot());
1847 1847
1848 // Non-scrolling related gesture events do a single cross-frame hit-test and jump 1848 // Non-scrolling related gesture events do a single cross-frame hit-test and jump
1849 // directly to the inner most frame. This matches handleMousePressEvent etc. 1849 // directly to the inner most frame. This matches handleMousePressEvent etc.
1850 ASSERT(!targetedEvent.event().isScrollEvent()); 1850 ASSERT(!targetedEvent.event().isScrollEvent());
1851 1851
1852 // update mouseout/leave/over/enter events before jumping directly to the in ner most frame
1853 if (targetedEvent.event().type() == PlatformEvent::GestureTap)
1854 updateGestureTargetNodeForMouseEvent(targetedEvent);
1855
1852 // Route to the correct frame. 1856 // Route to the correct frame.
1853 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) 1857 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame())
1854 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t); 1858 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t);
1855 1859
1856 // No hit test result, handle in root instance. Perhaps we should just retur n false instead? 1860 // No hit test result, handle in root instance. Perhaps we should just retur n false instead?
1857 return handleGestureEventInFrame(targetedEvent); 1861 return handleGestureEventInFrame(targetedEvent);
1858 } 1862 }
1859 1863
1860 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent) 1864 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent)
1861 { 1865 {
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 // we should clear the old hovered node from the old hovered frame. 2475 // we should clear the old hovered node from the old hovered frame.
2472 if (newHoverFrame != oldHoverFrame) 2476 if (newHoverFrame != oldHoverFrame)
2473 doc->updateHoverActiveState(request, nullptr); 2477 doc->updateHoverActiveState(request, nullptr);
2474 } 2478 }
2475 } 2479 }
2476 2480
2477 // Recursively set the new active/hover states on every frame in the chain o f innerElement. 2481 // Recursively set the new active/hover states on every frame in the chain o f innerElement.
2478 m_frame->document()->updateHoverActiveState(request, innerElement); 2482 m_frame->document()->updateHoverActiveState(request, innerElement);
2479 } 2483 }
2480 2484
2485 // Update the mouseover/mouseenter/mouseout/mouseleave events across all frames for this gesture,
2486 // before passing the targeted gesture event directly to a hit frame.
2487 void EventHandler::updateGestureTargetNodeForMouseEvent(const GestureEventWithHi tTestResults& targetedEvent)
2488 {
2489 ASSERT(m_frame == m_frame->localFrameRoot());
2490
2491 // Behaviour of this function is as follows:
2492 // - Create the chain of all entered frames.
2493 // - Compare the last frame chain under the gesture to newly entered frame c hain from the main frame one by one.
2494 // - If the last frame doesn't match with the entered frame, then create the chain of exited frames from the last frame chain.
2495 // - Dispatch mouseout/mouseleave events of the exited frames from the insid e out.
2496 // - Dispatch mouseover/mouseenter events of the entered frames into the ins ide.
2497
2498 // Insert the ancestors of the frame having the new target node to the enter ed frame chain
2499 WillBeHeapVector<LocalFrame*> enteredFrameChain;
2500 LocalFrame* enteredFrameInDocument = targetedEvent.hitTestResult().innerNode Frame();
2501 while (enteredFrameInDocument) {
2502 enteredFrameChain.append(enteredFrameInDocument);
2503 Frame* parentFrame = enteredFrameInDocument->tree().parent();
2504 enteredFrameInDocument = parentFrame && parentFrame->isLocalFrame() ? to LocalFrame(parentFrame) : nullptr;
2505 }
2506
2507 size_t indexEnteredFrameChain = enteredFrameChain.size();
2508 LocalFrame* exitedFrameInDocument = m_frame;
2509 WillBeHeapVector<LocalFrame*> exitedFrameChain;
2510 // Insert the frame from the disagreement between last frames and entered fr ames
2511 while (exitedFrameInDocument) {
2512 Node* lastNodeUnderTap = exitedFrameInDocument->eventHandler().m_lastNod eUnderMouse.get();
2513 if (!lastNodeUnderTap)
2514 break;
2515
2516 LocalFrame* nextExitedFrameInDocument = nullptr;
2517 if (lastNodeUnderTap->isFrameOwnerElement()) {
2518 HTMLFrameOwnerElement* owner = toHTMLFrameOwnerElement(lastNodeUnder Tap);
2519 if (owner->contentFrame() && owner->contentFrame()->isLocalFrame())
2520 nextExitedFrameInDocument = toLocalFrame(owner->contentFrame());
2521 }
2522
2523 if (exitedFrameChain.size() > 0) {
2524 exitedFrameChain.append(exitedFrameInDocument);
2525 } else {
2526 LocalFrame* lastEnteredFrameInDocument = indexEnteredFrameChain ? en teredFrameChain[indexEnteredFrameChain-1] : nullptr;
2527 // Avoid that unnecessary mouse events are fired on tapping across t he frames
mustaq 2015/07/08 20:21:54 Forgot ask you before: please remove this comment
Miyoung Shin(c) 2015/07/09 11:59:44 Done.
2528 // If tapping is moved x1 to x2 , the last frame chains is,
2529 // Main frame-> A frame -> B frame -> C frame
2530 // and the new frame chains is,
2531 // Main frame -> A frame -> D frame -> E frame
2532 // |------Main frame--------------------|
2533 // | |----------------A---------------| |
2534 // | | |-----B-----| |-----D------| | |
2535 // | | | |---C---| | | |---E----| | | |
2536 // | | | | x1 | | | | x2 | | | |
2537 // | | | |-------| | | |--------| | | |
2538 // | | |-----------| |------------| | |
2539 // | |--------------------------------| |
2540 // |------------------------------------|
2541 // For mouseout/mouseleave events, we should make the exited frame chain like B frame -> C frame.
2542 // For mouseover/mouseenter events, we should make the entered fram e chain like D frame -> E frame.
2543 // In A frame we should update mouseout and mouseover events, and i n main frame we shouldn't fire any mouse events.
2544 if (exitedFrameInDocument != lastEnteredFrameInDocument)
2545 exitedFrameChain.append(exitedFrameInDocument);
2546 else if (nextExitedFrameInDocument && indexEnteredFrameChain)
2547 --indexEnteredFrameChain;
2548 }
2549 exitedFrameInDocument = nextExitedFrameInDocument;
2550 }
2551
2552 const PlatformGestureEvent& gestureEvent = targetedEvent.event();
2553 unsigned modifiers = gestureEvent.modifiers();
2554 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(),
2555 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0,
2556 static_cast<PlatformEvent::Modifiers>(modifiers),
2557 PlatformMouseEvent::FromTouch, gestureEvent.timestamp());
2558
2559 // Update the mouseout/mouseleave event
2560 size_t indexExitedFrameChain = exitedFrameChain.size();
2561 while (indexExitedFrameChain) {
2562 LocalFrame* exitedFrameInDocument = exitedFrameChain[--indexExitedFrameC hain];
mustaq 2015/07/08 20:21:54 Please rename "exitedFrameInDocument": a duplicate
Miyoung Shin(c) 2015/07/09 11:59:44 Done.
2563 exitedFrameInDocument->eventHandler().updateMouseEventTargetNode(nullptr , fakeMouseMove, true);
2564 }
2565
2566 // update the mouseover/mouseenter event
2567 while (indexEnteredFrameChain) {
2568 Frame* parentFrame = enteredFrameChain[--indexEnteredFrameChain]->tree() .parent();
2569 if (parentFrame && parentFrame->isLocalFrame())
2570 toLocalFrame(parentFrame)->eventHandler().updateMouseEventTargetNode (toHTMLFrameOwnerElement(enteredFrameChain[indexEnteredFrameChain]->owner()), fa keMouseMove, true);
2571 }
2572 }
2573
2481 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly) 2574 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly)
2482 { 2575 {
2483 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); 2576 TRACE_EVENT0("input", "EventHandler::targetGestureEvent");
2484 2577
2485 ASSERT(m_frame == m_frame->localFrameRoot()); 2578 ASSERT(m_frame == m_frame->localFrameRoot());
2486 // Scrolling events get hit tested per frame (like wheel events do). 2579 // Scrolling events get hit tested per frame (like wheel events do).
2487 ASSERT(!gestureEvent.isScrollEvent()); 2580 ASSERT(!gestureEvent.isScrollEvent());
2488 2581
2489 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); 2582 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type());
2490 double activeInterval = 0; 2583 double activeInterval = 0;
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after
3869 unsigned EventHandler::accessKeyModifiers() 3962 unsigned EventHandler::accessKeyModifiers()
3870 { 3963 {
3871 #if OS(MACOSX) 3964 #if OS(MACOSX)
3872 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3965 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3873 #else 3966 #else
3874 return PlatformEvent::AltKey; 3967 return PlatformEvent::AltKey;
3875 #endif 3968 #endif
3876 } 3969 }
3877 3970
3878 } // namespace blink 3971 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/input/EventHandler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698