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

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

Issue 2163893003: Start sending auxclick instead of click for non-primary buttons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test to stable and remove redundant auxclick listener Created 4 years, 4 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 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 HitTestRequest request(hitType); 1143 HitTestRequest request(hitType);
1144 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); 1144 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent);
1145 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); 1145 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev);
1146 if (m_eventHandlerWillResetCapturingMouseEventsNode) 1146 if (m_eventHandlerWillResetCapturingMouseEventsNode)
1147 m_capturingMouseEventsNode = nullptr; 1147 m_capturingMouseEventsNode = nullptr;
1148 if (subframe) 1148 if (subframe)
1149 return passMouseReleaseEventToSubframe(mev, subframe); 1149 return passMouseReleaseEventToSubframe(mev, subframe);
1150 1150
1151 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mouseup, mev.innerNode(), m_clickCount, mev.event()); 1151 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mouseup, mev.innerNode(), m_clickCount, mev.event());
1152 1152
1153 bool contextMenuEvent = mouseEvent.button() == RightButton; 1153 // We only prevent click event when the click may cause contextmenu to popup .
1154 // However, we always send auxclick.
1155 bool macContextMenuEvent = false;
bokan 2016/08/12 15:29:17 Is this a change in behaviour? It looks like we'd
Navid Zolghadr 2016/08/12 15:39:16 That is correct. But not quite a change in the beh
bokan 2016/08/12 15:42:20 Got it. But if RuntimeEnabledFeatures::auxclickEna
Navid Zolghadr 2016/08/12 16:01:18 Right. Thanks for the catch. I'm surprised why the
1154 #if OS(MACOSX) 1156 #if OS(MACOSX)
1155 // FIXME: The Mac port achieves the same behavior by checking whether the co ntext menu is currently open in WebPage::mouseEvent(). Consider merging the impl ementations. 1157 // FIXME: The Mac port achieves the same behavior by checking whether the co ntext menu is currently open in WebPage::mouseEvent(). Consider merging the impl ementations.
1156 if (mouseEvent.button() == LeftButton && mouseEvent.getModifiers() & Platfor mEvent::CtrlKey) 1158 if (mouseEvent.button() == LeftButton && mouseEvent.getModifiers() & Platfor mEvent::CtrlKey)
1157 contextMenuEvent = true; 1159 macContextMenuEvent = true;
1158 #endif 1160 #endif
1159 1161
1160 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; 1162 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled;
1161 const bool shouldDispatchClickEvent = m_clickCount > 0 1163 const bool shouldDispatchClickEvent = m_clickCount > 0
1162 && !contextMenuEvent 1164 && !macContextMenuEvent
1163 && mev.innerNode() && m_clickNode 1165 && mev.innerNode() && m_clickNode
1164 && mev.innerNode()->canParticipateInFlatTree() && m_clickNode->canPartic ipateInFlatTree() 1166 && mev.innerNode()->canParticipateInFlatTree() && m_clickNode->canPartic ipateInFlatTree()
1165 && !(selectionController().hasExtendedSelection() && isLinkSelection(mev )); 1167 && !(selectionController().hasExtendedSelection() && isLinkSelection(mev ));
1166 if (shouldDispatchClickEvent) { 1168 if (shouldDispatchClickEvent) {
1167 Node* clickTargetNode = nullptr; 1169 Node* clickTargetNode = nullptr;
1168 // Updates distribution because a 'mouseup' event listener can make the 1170 // Updates distribution because a 'mouseup' event listener can make the
1169 // tree dirty at dispatchMouseEvent() invocation above. 1171 // tree dirty at dispatchMouseEvent() invocation above.
1170 // Unless distribution is updated, commonAncestor would hit ASSERT. 1172 // Unless distribution is updated, commonAncestor would hit ASSERT.
1171 if (m_clickNode == mev.innerNode()) { 1173 if (m_clickNode == mev.innerNode()) {
1172 clickTargetNode = m_clickNode; 1174 clickTargetNode = m_clickNode;
1173 clickTargetNode->updateDistribution(); 1175 clickTargetNode->updateDistribution();
1174 } else if (m_clickNode->document() == mev.innerNode()->document()) { 1176 } else if (m_clickNode->document() == mev.innerNode()->document()) {
1175 m_clickNode->updateDistribution(); 1177 m_clickNode->updateDistribution();
1176 mev.innerNode()->updateDistribution(); 1178 mev.innerNode()->updateDistribution();
1177 clickTargetNode = mev.innerNode()->commonAncestor( 1179 clickTargetNode = mev.innerNode()->commonAncestor(
1178 *m_clickNode, parentForClickEvent); 1180 *m_clickNode, parentForClickEvent);
1179 } 1181 }
1180 if (clickTargetNode) { 1182 if (clickTargetNode) {
1181 // Dispatch mouseup directly w/o calling updateMouseEventTargetNodeA ndSendEvents 1183 // Dispatch mouseup directly w/o calling updateMouseEventTargetNodeA ndSendEvents
1182 // because the mouseup dispatch above has already updated it 1184 // because the mouseup dispatch above has already updated it
1183 // correctly. Moreover, clickTargetNode is different from 1185 // correctly. Moreover, clickTargetNode is different from
1184 // mev.innerNode at drag-release. 1186 // mev.innerNode at drag-release.
1185 clickEventResult = toWebInputEventResult(clickTargetNode->dispatchMo useEvent(mev.event(), 1187 clickEventResult = toWebInputEventResult(clickTargetNode->dispatchMo useEvent(mev.event(),
1186 EventTypeNames::click, m_clickCount)); 1188 !RuntimeEnabledFeatures::auxclickEnabled() || (mev.event().butto n() == MouseButton::LeftButton)
1189 ? EventTypeNames::click
1190 : EventTypeNames::auxclick,
1191 m_clickCount));
1187 } 1192 }
1188 } 1193 }
1189 1194
1190 m_scrollManager.clearResizeScrollableArea(false); 1195 m_scrollManager.clearResizeScrollableArea(false);
1191 1196
1192 if (eventResult == WebInputEventResult::NotHandled) 1197 if (eventResult == WebInputEventResult::NotHandled)
1193 eventResult = handleMouseReleaseEvent(mev); 1198 eventResult = handleMouseReleaseEvent(mev);
1194 clearDragHeuristicState(); 1199 clearDragHeuristicState();
1195 1200
1196 invalidateClick(); 1201 invalidateClick();
(...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after
2581 2586
2582 FrameHost* EventHandler::frameHost() const 2587 FrameHost* EventHandler::frameHost() const
2583 { 2588 {
2584 if (!m_frame->page()) 2589 if (!m_frame->page())
2585 return nullptr; 2590 return nullptr;
2586 2591
2587 return &m_frame->page()->frameHost(); 2592 return &m_frame->page()->frameHost();
2588 } 2593 }
2589 2594
2590 } // namespace blink 2595 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698