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

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, 6 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
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 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 { 1850 {
1851 TRACE_EVENT0("input", "EventHandler::handleGestureEvent"); 1851 TRACE_EVENT0("input", "EventHandler::handleGestureEvent");
1852 1852
1853 // Propagation to inner frames is handled below this function. 1853 // Propagation to inner frames is handled below this function.
1854 ASSERT(m_frame == m_frame->localFrameRoot()); 1854 ASSERT(m_frame == m_frame->localFrameRoot());
1855 1855
1856 // Non-scrolling related gesture events do a single cross-frame hit-test and jump 1856 // Non-scrolling related gesture events do a single cross-frame hit-test and jump
1857 // directly to the inner most frame. This matches handleMousePressEvent etc. 1857 // directly to the inner most frame. This matches handleMousePressEvent etc.
1858 ASSERT(!targetedEvent.event().isScrollEvent()); 1858 ASSERT(!targetedEvent.event().isScrollEvent());
1859 1859
1860 // update mouseout/leave/over/enter events before jumping directly to the in ner most frame
1861 if (targetedEvent.event().type() == PlatformEvent::GestureTap)
1862 updateGestureTargetNodeForMouseEvent(targetedEvent);
1863
1860 // Route to the correct frame. 1864 // Route to the correct frame.
1861 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) 1865 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame())
1862 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t); 1866 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t);
1863 1867
1864 // No hit test result, handle in root instance. Perhaps we should just retur n false instead? 1868 // No hit test result, handle in root instance. Perhaps we should just retur n false instead?
1865 return handleGestureEventInFrame(targetedEvent); 1869 return handleGestureEventInFrame(targetedEvent);
1866 } 1870 }
1867 1871
1868 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent) 1872 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent)
1869 { 1873 {
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
2469 // we should clear the old hovered node from the old hovered frame. 2473 // we should clear the old hovered node from the old hovered frame.
2470 if (newHoverFrame != oldHoverFrame) 2474 if (newHoverFrame != oldHoverFrame)
2471 doc->updateHoverActiveState(request, nullptr); 2475 doc->updateHoverActiveState(request, nullptr);
2472 } 2476 }
2473 } 2477 }
2474 2478
2475 // Recursively set the new active/hover states on every frame in the chain o f innerElement. 2479 // Recursively set the new active/hover states on every frame in the chain o f innerElement.
2476 m_frame->document()->updateHoverActiveState(request, innerElement); 2480 m_frame->document()->updateHoverActiveState(request, innerElement);
2477 } 2481 }
2478 2482
2483 // Update the mouseover/mouseenter/mouseout/mouseleave events across all frames for this gesture,
2484 // before passing the targeted gesture event directly to a hit frame.
2485 void EventHandler::updateGestureTargetNodeForMouseEvent(const GestureEventWithHi tTestResults& targetedEvent)
2486 {
2487 ASSERT(m_frame == m_frame->localFrameRoot());
2488
2489 // Behaviour of this function is as follows:
2490 // - Create the chain of all entered frames.
2491 // - Compare the last frame chain under the gesture to newly entered frame c hain from the main frame one by one.
2492 // - If the last frame doesn't match with the entered frame, then create the chain of exited frames from the last frame chain.
2493 // - Dispatch mouseout/mouseleave events of the exited frames from the insid e out.
2494 // - Dispatch mouseover/mouseenter events of the entered frames into the ins ide.
2495
2496 // Insert the ancestors of the frame having the new target node to the enter ed frame chain
2497 WillBeHeapVector<LocalFrame*> enteredFrameChain;
2498 LocalFrame* enteredFrameInDocument = targetedEvent.hitTestResult().innerNode Frame();
2499 while (enteredFrameInDocument) {
2500 enteredFrameChain.append(enteredFrameInDocument);
2501 Frame* parentFrame = enteredFrameInDocument->tree().parent();
2502 enteredFrameInDocument = parentFrame && parentFrame->isLocalFrame() ? to LocalFrame(parentFrame) : nullptr;
2503 }
2504
2505 size_t indexEnteredFrameChain = enteredFrameChain.size();
2506 LocalFrame* exitedFrameInDocument = m_frame;
2507 WillBeHeapVector<LocalFrame*> exitedFrameChain;
2508 // Insert the frame from the disagreement between last frames and entered fr ames
2509 while (exitedFrameInDocument) {
2510 Node* lastNodeUnderTap = exitedFrameInDocument->eventHandler().m_lastNod eUnderMouse.get();
2511 if (!lastNodeUnderTap)
2512 break;
2513
2514 LocalFrame* nextExitedFrameInDocument = nullptr;
2515 if (lastNodeUnderTap->isFrameOwnerElement()) {
2516 HTMLFrameOwnerElement* owner = toHTMLFrameOwnerElement(lastNodeUnder Tap);
2517 if (owner->contentFrame() && owner->contentFrame()->isLocalFrame())
2518 nextExitedFrameInDocument = toLocalFrame(owner->contentFrame());
2519 }
2520
2521 if (exitedFrameChain.size() > 0) {
2522 exitedFrameChain.append(exitedFrameInDocument);
2523 } else {
2524 LocalFrame* enteredFrameInDocument = indexEnteredFrameChain ? entere dFrameChain[indexEnteredFrameChain-1] : nullptr;
mustaq 2015/07/02 20:37:29 Please avoid duplicate variable names with overlap
Miyoung Shin(c) 2015/07/05 12:39:33 I changed the name to lastEnteredFrameInDocument.
2525 // Avoid that unnecessary mouse events are fired on tapping across t he frames
2526 // If tapping is moved x1 to x2 , the last frame chains is,
2527 // Main frame-> A frame -> B frame -> C frame
2528 // and the new frame chains is,
2529 // Main frame -> A frame -> D frame -> E frame
2530 // |------Main frame--------------------|
2531 // | |----------------A---------------| |
2532 // | | |-----B-----| |-----D------| | |
2533 // | | | |---C---| | | |---E----| | | |
2534 // | | | | x1 | | | | x2 | | | |
2535 // | | | |-------| | | |--------| | | |
2536 // | | |-----------| |------------| | |
2537 // | |--------------------------------| |
2538 // |------------------------------------|
2539 // For mouseout/mouseleave events, we should make the exited frame chain like B frame -> C frame.
2540 // For mouseover/mouseenter events, we should make the entered fram e chain like D frame -> E frame.
2541 // In A frame we should update mouseout and mouseover events, and i n main frame we shouldn't fire any mouse events.
2542 if (exitedFrameInDocument != enteredFrameInDocument)
2543 exitedFrameChain.append(exitedFrameInDocument);
2544 else if (nextExitedFrameInDocument && indexEnteredFrameChain)
2545 --indexEnteredFrameChain;
2546 }
2547 exitedFrameInDocument = nextExitedFrameInDocument;
2548 }
2549
2550 const PlatformGestureEvent& gestureEvent = targetedEvent.event();
2551 unsigned modifiers = gestureEvent.modifiers();
2552 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(),
2553 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0,
2554 static_cast<PlatformEvent::Modifiers>(modifiers),
2555 PlatformMouseEvent::FromTouch, gestureEvent.timestamp());
2556
2557 // Update the mouseout/mouseleave event
2558 size_t indexExitedFrameChain = exitedFrameChain.size();
2559 while (indexExitedFrameChain) {
2560 LocalFrame* exitedFrameInDocument = exitedFrameChain[--indexExitedFrameC hain];
2561 exitedFrameInDocument->eventHandler().updateMouseEventTargetNode(nullptr , fakeMouseMove, true);
2562 }
2563
2564 // update the mouseover/mouseenter event
2565 while (indexEnteredFrameChain) {
2566 Frame* parent = enteredFrameChain[--indexEnteredFrameChain]->tree().pare nt();
2567 if (parent && parent->isLocalFrame()) {
2568 enteredFrameInDocument = toLocalFrame(parent);
2569 enteredFrameInDocument->eventHandler().updateMouseEventTargetNode(to HTMLFrameOwnerElement(enteredFrameChain[indexEnteredFrameChain]->owner()), fakeM ouseMove, true);
2570 }
2571 }
2572 }
2573
2479 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly) 2574 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly)
2480 { 2575 {
2481 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); 2576 TRACE_EVENT0("input", "EventHandler::targetGestureEvent");
2482 2577
2483 ASSERT(m_frame == m_frame->localFrameRoot()); 2578 ASSERT(m_frame == m_frame->localFrameRoot());
2484 // Scrolling events get hit tested per frame (like wheel events do). 2579 // Scrolling events get hit tested per frame (like wheel events do).
2485 ASSERT(!gestureEvent.isScrollEvent()); 2580 ASSERT(!gestureEvent.isScrollEvent());
2486 2581
2487 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); 2582 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type());
2488 double activeInterval = 0; 2583 double activeInterval = 0;
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
3761 unsigned EventHandler::accessKeyModifiers() 3856 unsigned EventHandler::accessKeyModifiers()
3762 { 3857 {
3763 #if OS(MACOSX) 3858 #if OS(MACOSX)
3764 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3859 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3765 #else 3860 #else
3766 return PlatformEvent::AltKey; 3861 return PlatformEvent::AltKey;
3767 #endif 3862 #endif
3768 } 3863 }
3769 3864
3770 } // namespace blink 3865 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698