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

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 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 { 1845 {
1846 TRACE_EVENT0("input", "EventHandler::handleGestureEvent"); 1846 TRACE_EVENT0("input", "EventHandler::handleGestureEvent");
1847 1847
1848 // Propagation to inner frames is handled below this function. 1848 // Propagation to inner frames is handled below this function.
1849 ASSERT(m_frame == m_frame->localFrameRoot()); 1849 ASSERT(m_frame == m_frame->localFrameRoot());
1850 1850
1851 // Non-scrolling related gesture events do a single cross-frame hit-test and jump 1851 // Non-scrolling related gesture events do a single cross-frame hit-test and jump
1852 // directly to the inner most frame. This matches handleMousePressEvent etc. 1852 // directly to the inner most frame. This matches handleMousePressEvent etc.
1853 ASSERT(!targetedEvent.event().isScrollEvent()); 1853 ASSERT(!targetedEvent.event().isScrollEvent());
1854 1854
1855 // update mouseout/leave/over/enter events before jumping directly to the in ner most frame
1856 if (targetedEvent.event().type() == PlatformEvent::GestureTap)
1857 updateGestureTargetNodeForMouseEvent(targetedEvent);
1858
1855 // Route to the correct frame. 1859 // Route to the correct frame.
1856 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) 1860 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame())
1857 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t); 1861 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t);
1858 1862
1859 // No hit test result, handle in root instance. Perhaps we should just retur n false instead? 1863 // No hit test result, handle in root instance. Perhaps we should just retur n false instead?
1860 return handleGestureEventInFrame(targetedEvent); 1864 return handleGestureEventInFrame(targetedEvent);
1861 } 1865 }
1862 1866
1863 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent) 1867 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent)
1864 { 1868 {
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 // we should clear the old hovered node from the old hovered frame. 2478 // we should clear the old hovered node from the old hovered frame.
2475 if (newHoverFrame != oldHoverFrame) 2479 if (newHoverFrame != oldHoverFrame)
2476 doc->updateHoverActiveState(request, nullptr); 2480 doc->updateHoverActiveState(request, nullptr);
2477 } 2481 }
2478 } 2482 }
2479 2483
2480 // Recursively set the new active/hover states on every frame in the chain o f innerElement. 2484 // Recursively set the new active/hover states on every frame in the chain o f innerElement.
2481 m_frame->document()->updateHoverActiveState(request, innerElement); 2485 m_frame->document()->updateHoverActiveState(request, innerElement);
2482 } 2486 }
2483 2487
2488 // Update the mouseover/mouseenter/mouseout/mouseleave events across all frames for this gesture,
2489 // before passing the targeted gesture event directly to a hit frame.
2490 void EventHandler::updateGestureTargetNodeForMouseEvent(const GestureEventWithHi tTestResults& targetedEvent)
2491 {
2492 ASSERT(m_frame == m_frame->localFrameRoot());
2493
2494 // Behaviour of this function is as follows:
2495 // - Create the chain of all entered frames.
2496 // - Compare the last frame chain under the gesture to newly entered frame c hain from the main frame one by one.
2497 // - If the last frame doesn't match with the entered frame, then create the chain of exited frames from the last frame chain.
2498 // - Dispatch mouseout/mouseleave events of the exited frames from the insid e out.
2499 // - Dispatch mouseover/mouseenter events of the entered frames into the ins ide.
2500
2501 // Insert the ancestors of the frame having the new target node to the enter ed frame chain
2502 WillBeHeapVector<LocalFrame*> enteredFrameChain;
2503 LocalFrame* enteredFrameInDocument = targetedEvent.hitTestResult().innerNode Frame();
2504 while (enteredFrameInDocument) {
2505 enteredFrameChain.append(enteredFrameInDocument);
2506 Frame* parentFrame = enteredFrameInDocument->tree().parent();
2507 enteredFrameInDocument = parentFrame && parentFrame->isLocalFrame() ? to LocalFrame(parentFrame) : nullptr;
2508 }
2509
2510 size_t indexEnteredFrameChain = enteredFrameChain.size();
2511 LocalFrame* exitedFrameInDocument = m_frame;
2512 WillBeHeapVector<LocalFrame*> exitedFrameChain;
2513 // Insert the frame from the disagreement between last frames and entered fr ames
2514 while (exitedFrameInDocument) {
2515 Node* lastNodeUnderTap = exitedFrameInDocument->eventHandler().m_lastNod eUnderMouse.get();
2516 if (!lastNodeUnderTap)
2517 break;
2518
2519 LocalFrame* nextExitedFrameInDocument = nullptr;
2520 if (lastNodeUnderTap->isFrameOwnerElement()) {
2521 HTMLFrameOwnerElement* owner = toHTMLFrameOwnerElement(lastNodeUnder Tap);
2522 if (owner->contentFrame() && owner->contentFrame()->isLocalFrame())
2523 nextExitedFrameInDocument = toLocalFrame(owner->contentFrame());
2524 }
2525
2526 if (exitedFrameChain.size() > 0) {
2527 exitedFrameChain.append(exitedFrameInDocument);
2528 } else {
2529 LocalFrame* lastEnteredFrameInDocument = indexEnteredFrameChain ? en teredFrameChain[indexEnteredFrameChain-1] : nullptr;
2530 if (exitedFrameInDocument != lastEnteredFrameInDocument)
2531 exitedFrameChain.append(exitedFrameInDocument);
2532 else if (nextExitedFrameInDocument && indexEnteredFrameChain)
2533 --indexEnteredFrameChain;
2534 }
2535 exitedFrameInDocument = nextExitedFrameInDocument;
2536 }
2537
2538 const PlatformGestureEvent& gestureEvent = targetedEvent.event();
2539 unsigned modifiers = gestureEvent.modifiers();
2540 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(),
2541 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0,
2542 static_cast<PlatformEvent::Modifiers>(modifiers),
2543 PlatformMouseEvent::FromTouch, gestureEvent.timestamp());
2544
2545 // Update the mouseout/mouseleave event
2546 size_t indexExitedFrameChain = exitedFrameChain.size();
2547 while (indexExitedFrameChain) {
2548 LocalFrame* leaveFrame = exitedFrameChain[--indexExitedFrameChain];
2549 leaveFrame->eventHandler().updateMouseEventTargetNode(nullptr, fakeMouse Move, true);
2550 }
2551
2552 // update the mouseover/mouseenter event
2553 while (indexEnteredFrameChain) {
2554 Frame* parentFrame = enteredFrameChain[--indexEnteredFrameChain]->tree() .parent();
2555 if (parentFrame && parentFrame->isLocalFrame())
2556 toLocalFrame(parentFrame)->eventHandler().updateMouseEventTargetNode (toHTMLFrameOwnerElement(enteredFrameChain[indexEnteredFrameChain]->owner()), fa keMouseMove, true);
2557 }
2558 }
2559
2484 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly) 2560 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly)
2485 { 2561 {
2486 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); 2562 TRACE_EVENT0("input", "EventHandler::targetGestureEvent");
2487 2563
2488 ASSERT(m_frame == m_frame->localFrameRoot()); 2564 ASSERT(m_frame == m_frame->localFrameRoot());
2489 // Scrolling events get hit tested per frame (like wheel events do). 2565 // Scrolling events get hit tested per frame (like wheel events do).
2490 ASSERT(!gestureEvent.isScrollEvent()); 2566 ASSERT(!gestureEvent.isScrollEvent());
2491 2567
2492 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); 2568 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type());
2493 double activeInterval = 0; 2569 double activeInterval = 0;
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
3923 unsigned EventHandler::accessKeyModifiers() 3999 unsigned EventHandler::accessKeyModifiers()
3924 { 4000 {
3925 #if OS(MACOSX) 4001 #if OS(MACOSX)
3926 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 4002 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3927 #else 4003 #else
3928 return PlatformEvent::AltKey; 4004 return PlatformEvent::AltKey;
3929 #endif 4005 #endif
3930 } 4006 }
3931 4007
3932 } // namespace blink 4008 } // 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