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

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

Issue 1731353003: Prevent propagation of wheel events to dispatch event in parent iframe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 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 | « third_party/WebKit/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 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 1783
1784 HitTestRequest request(HitTestRequest::ReadOnly); 1784 HitTestRequest request(HitTestRequest::ReadOnly);
1785 HitTestResult result(request, vPoint); 1785 HitTestResult result(request, vPoint);
1786 doc->layoutView()->hitTest(result); 1786 doc->layoutView()->hitTest(result);
1787 1787
1788 Node* node = result.innerNode(); 1788 Node* node = result.innerNode();
1789 // Wheel events should not dispatch to text nodes. 1789 // Wheel events should not dispatch to text nodes.
1790 if (node && node->isTextNode()) 1790 if (node && node->isTextNode())
1791 node = FlatTreeTraversal::parent(*node); 1791 node = FlatTreeTraversal::parent(*node);
1792 1792
1793 bool isOverWidget = result.isOverWidget(); 1793 bool sendDOMEvent = true;
1794 LocalFrame* subframe = subframeForTargetNode(node);
1795 if (subframe) {
1796 WebInputEventResult result = subframe->eventHandler().handleWheelEvent(e vent);
1797 if (result != WebInputEventResult::NotHandled) {
1798 setFrameWasScrolledByUser();
1799 return result;
1800 }
1801 // TODO(dtapuska): Remove this once wheel gesture scroll has
1802 // been enabled everywhere; as we can just return early.
1803 // http://crbug.com/568183
1804 // Don't propagate the DOM event into the parent iframe
1805 // but do dispatch the scroll event.
1806 sendDOMEvent = false;
1807 }
1794 1808
1795 if (node) { 1809 if (node && sendDOMEvent) {
1796 // Figure out which view to send the event to.
1797 LayoutObject* target = node->layoutObject();
1798
1799 if (isOverWidget && target && target->isLayoutPart()) {
1800 if (Widget* widget = toLayoutPart(target)->widget()) {
1801 WebInputEventResult result = passWheelEventToWidget(event, *widg et);
1802 if (result != WebInputEventResult::NotHandled) {
1803 setFrameWasScrolledByUser();
1804 return result;
1805 }
1806 }
1807 }
1808
1809 RefPtrWillBeRawPtr<Event> domEvent = WheelEvent::create(event, node->doc ument().domWindow()); 1810 RefPtrWillBeRawPtr<Event> domEvent = WheelEvent::create(event, node->doc ument().domWindow());
1810 DispatchEventResult domEventResult = node->dispatchEvent(domEvent); 1811 DispatchEventResult domEventResult = node->dispatchEvent(domEvent);
1811 if (domEventResult != DispatchEventResult::NotCanceled) { 1812 if (domEventResult != DispatchEventResult::NotCanceled) {
1812 setFrameWasScrolledByUser(); 1813 setFrameWasScrolledByUser();
1813 return toWebInputEventResult(domEventResult); 1814 return toWebInputEventResult(domEventResult);
1814 } 1815 }
1815 } 1816 }
1816 1817
1817 // We do another check on the frame view because the event handler can run 1818 // We do another check on the frame view because the event handler can run
1818 // JS which results in the frame getting destroyed. 1819 // JS which results in the frame getting destroyed.
(...skipping 2123 matching lines...) Expand 10 before | Expand all | Expand 10 after
3942 } 3943 }
3943 3944
3944 WebInputEventResult EventHandler::passMouseReleaseEventToSubframe(MouseEventWith HitTestResults& mev, LocalFrame* subframe) 3945 WebInputEventResult EventHandler::passMouseReleaseEventToSubframe(MouseEventWith HitTestResults& mev, LocalFrame* subframe)
3945 { 3946 {
3946 WebInputEventResult result = subframe->eventHandler().handleMouseReleaseEven t(mev.event()); 3947 WebInputEventResult result = subframe->eventHandler().handleMouseReleaseEven t(mev.event());
3947 if (result != WebInputEventResult::NotHandled) 3948 if (result != WebInputEventResult::NotHandled)
3948 return result; 3949 return result;
3949 return WebInputEventResult::HandledSystem; 3950 return WebInputEventResult::HandledSystem;
3950 } 3951 }
3951 3952
3952 WebInputEventResult EventHandler::passWheelEventToWidget(const PlatformWheelEven t& wheelEvent, Widget& widget)
3953 {
3954 // If not a FrameView, then probably a plugin widget. Those will receive
3955 // the event via an EventTargetNode dispatch when this returns false.
3956 if (!widget.isFrameView())
3957 return WebInputEventResult::NotHandled;
3958
3959 return toFrameView(&widget)->frame().eventHandler().handleWheelEvent(wheelEv ent);
3960 }
3961
3962 DataTransfer* EventHandler::createDraggingDataTransfer() const 3953 DataTransfer* EventHandler::createDraggingDataTransfer() const
3963 { 3954 {
3964 return DataTransfer::create(DataTransfer::DragAndDrop, DataTransferWritable, DataObject::create()); 3955 return DataTransfer::create(DataTransfer::DragAndDrop, DataTransferWritable, DataObject::create());
3965 } 3956 }
3966 3957
3967 void EventHandler::focusDocumentView() 3958 void EventHandler::focusDocumentView()
3968 { 3959 {
3969 Page* page = m_frame->page(); 3960 Page* page = m_frame->page();
3970 if (!page) 3961 if (!page)
3971 return; 3962 return;
3972 page->focusController().focusDocumentView(m_frame); 3963 page->focusController().focusDocumentView(m_frame);
3973 } 3964 }
3974 3965
3975 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 3966 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
3976 { 3967 {
3977 #if OS(MACOSX) 3968 #if OS(MACOSX)
3978 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 3969 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
3979 #else 3970 #else
3980 return PlatformEvent::AltKey; 3971 return PlatformEvent::AltKey;
3981 #endif 3972 #endif
3982 } 3973 }
3983 3974
3984 } // namespace blink 3975 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698