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

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

Issue 2747763002: Add use count for click retargeting due to capture (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/input/MouseEventManager.h" 5 #include "core/input/MouseEventManager.h"
6 6
7 #include "core/clipboard/DataObject.h" 7 #include "core/clipboard/DataObject.h"
8 #include "core/clipboard/DataTransfer.h" 8 #include "core/clipboard/DataTransfer.h"
9 #include "core/dom/Element.h" 9 #include "core/dom/Element.h"
10 #include "core/dom/ElementTraversal.h" 10 #include "core/dom/ElementTraversal.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 226
227 setNodeUnderMouse(targetNode, canvasRegionId, webMouseEvent); 227 setNodeUnderMouse(targetNode, canvasRegionId, webMouseEvent);
228 228
229 return dispatchMouseEvent(m_nodeUnderMouse, eventType, webMouseEvent, 229 return dispatchMouseEvent(m_nodeUnderMouse, eventType, webMouseEvent,
230 canvasRegionId, nullptr); 230 canvasRegionId, nullptr);
231 } 231 }
232 232
233 WebInputEventResult MouseEventManager::dispatchMouseClickIfNeeded( 233 WebInputEventResult MouseEventManager::dispatchMouseClickIfNeeded(
234 Node* target, 234 Node* target,
235 const WebMouseEvent& mouseEvent, 235 const WebMouseEvent& mouseEvent,
236 const String& canvasRegionId) { 236 const String& canvasRegionId,
237 Node* targetWithoutCapture) {
237 // We only prevent click event when the click may cause contextmenu to popup. 238 // We only prevent click event when the click may cause contextmenu to popup.
238 // However, we always send auxclick. 239 // However, we always send auxclick.
239 bool contextMenuEvent = 240 bool contextMenuEvent =
240 !RuntimeEnabledFeatures::auxclickEnabled() && 241 !RuntimeEnabledFeatures::auxclickEnabled() &&
241 mouseEvent.button == WebPointerProperties::Button::Right; 242 mouseEvent.button == WebPointerProperties::Button::Right;
242 #if OS(MACOSX) 243 #if OS(MACOSX)
243 // FIXME: The Mac port achieves the same behavior by checking whether the 244 // FIXME: The Mac port achieves the same behavior by checking whether the
244 // context menu is currently open in WebPage::mouseEvent(). Consider merging 245 // context menu is currently open in WebPage::mouseEvent(). Consider merging
245 // the implementations. 246 // the implementations.
246 if (mouseEvent.button == WebPointerProperties::Button::Left && 247 if (mouseEvent.button == WebPointerProperties::Button::Left &&
(...skipping 13 matching lines...) Expand all
260 // Unless distribution is updated, commonAncestor would hit ASSERT. 261 // Unless distribution is updated, commonAncestor would hit ASSERT.
261 if (m_clickNode == target) { 262 if (m_clickNode == target) {
262 clickTargetNode = m_clickNode; 263 clickTargetNode = m_clickNode;
263 clickTargetNode->updateDistribution(); 264 clickTargetNode->updateDistribution();
264 } else if (m_clickNode->document() == target->document()) { 265 } else if (m_clickNode->document() == target->document()) {
265 m_clickNode->updateDistribution(); 266 m_clickNode->updateDistribution();
266 target->updateDistribution(); 267 target->updateDistribution();
267 clickTargetNode = target->commonAncestor( 268 clickTargetNode = target->commonAncestor(
268 *m_clickNode, EventHandlingUtil::parentForClickEvent); 269 *m_clickNode, EventHandlingUtil::parentForClickEvent);
269 } 270 }
271
272 // This block is only for the purpose of gathering the metric and can be
273 // removed as soon as we don't need the metric.
274 if (targetWithoutCapture != target) {
275 Node* alternativeClickTargetNode = nullptr;
276 if (m_clickNode == targetWithoutCapture) {
277 alternativeClickTargetNode = m_clickNode;
278 } else if (m_clickNode->document() == targetWithoutCapture->document()) {
279 alternativeClickTargetNode = targetWithoutCapture->commonAncestor(
280 *m_clickNode, EventHandlingUtil::parentForClickEvent);
281 }
282 if (alternativeClickTargetNode != clickTargetNode) {
283 UseCounter::count(m_frame,
284 UseCounter::PointerEventClickRetargetCausedByCapture);
285 }
286 }
287
270 if (clickTargetNode) { 288 if (clickTargetNode) {
271 clickEventResult = dispatchMouseEvent( 289 clickEventResult = dispatchMouseEvent(
272 clickTargetNode, 290 clickTargetNode,
273 !RuntimeEnabledFeatures::auxclickEnabled() || 291 !RuntimeEnabledFeatures::auxclickEnabled() ||
274 (mouseEvent.button == WebPointerProperties::Button::Left) 292 (mouseEvent.button == WebPointerProperties::Button::Left)
275 ? EventTypeNames::click 293 ? EventTypeNames::click
276 : EventTypeNames::auxclick, 294 : EventTypeNames::auxclick,
277 mouseEvent, canvasRegionId, nullptr); 295 mouseEvent, canvasRegionId, nullptr);
278 } 296 }
279 } 297 }
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 1037
1020 void MouseEventManager::setClickCount(int clickCount) { 1038 void MouseEventManager::setClickCount(int clickCount) {
1021 m_clickCount = clickCount; 1039 m_clickCount = clickCount;
1022 } 1040 }
1023 1041
1024 bool MouseEventManager::mouseDownMayStartDrag() { 1042 bool MouseEventManager::mouseDownMayStartDrag() {
1025 return m_mouseDownMayStartDrag; 1043 return m_mouseDownMayStartDrag;
1026 } 1044 }
1027 1045
1028 } // namespace blink 1046 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/MouseEventManager.h ('k') | third_party/WebKit/Source/core/input/PointerEventManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698