| OLD | NEW |
| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 227 |
| 228 setNodeUnderMouse(targetNode, canvasRegionId, webMouseEvent); | 228 setNodeUnderMouse(targetNode, canvasRegionId, webMouseEvent); |
| 229 | 229 |
| 230 return dispatchMouseEvent(m_nodeUnderMouse, eventType, webMouseEvent, | 230 return dispatchMouseEvent(m_nodeUnderMouse, eventType, webMouseEvent, |
| 231 canvasRegionId, nullptr); | 231 canvasRegionId, nullptr); |
| 232 } | 232 } |
| 233 | 233 |
| 234 WebInputEventResult MouseEventManager::dispatchMouseClickIfNeeded( | 234 WebInputEventResult MouseEventManager::dispatchMouseClickIfNeeded( |
| 235 Node* target, | 235 Node* target, |
| 236 const WebMouseEvent& mouseEvent, | 236 const WebMouseEvent& mouseEvent, |
| 237 const String& canvasRegionId, | 237 const String& canvasRegionId) { |
| 238 Node* targetWithoutCapture) { | |
| 239 // 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. |
| 240 // However, we always send auxclick. | 239 // However, we always send auxclick. |
| 241 bool contextMenuEvent = | 240 bool contextMenuEvent = |
| 242 !RuntimeEnabledFeatures::auxclickEnabled() && | 241 !RuntimeEnabledFeatures::auxclickEnabled() && |
| 243 mouseEvent.button == WebPointerProperties::Button::Right; | 242 mouseEvent.button == WebPointerProperties::Button::Right; |
| 244 #if OS(MACOSX) | 243 #if OS(MACOSX) |
| 245 // 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 |
| 246 // context menu is currently open in WebPage::mouseEvent(). Consider merging | 245 // context menu is currently open in WebPage::mouseEvent(). Consider merging |
| 247 // the implementations. | 246 // the implementations. |
| 248 if (mouseEvent.button == WebPointerProperties::Button::Left && | 247 if (mouseEvent.button == WebPointerProperties::Button::Left && |
| (...skipping 13 matching lines...) Expand all Loading... |
| 262 // Unless distribution is updated, commonAncestor would hit ASSERT. | 261 // Unless distribution is updated, commonAncestor would hit ASSERT. |
| 263 if (m_clickNode == target) { | 262 if (m_clickNode == target) { |
| 264 clickTargetNode = m_clickNode; | 263 clickTargetNode = m_clickNode; |
| 265 clickTargetNode->updateDistribution(); | 264 clickTargetNode->updateDistribution(); |
| 266 } else if (m_clickNode->document() == target->document()) { | 265 } else if (m_clickNode->document() == target->document()) { |
| 267 m_clickNode->updateDistribution(); | 266 m_clickNode->updateDistribution(); |
| 268 target->updateDistribution(); | 267 target->updateDistribution(); |
| 269 clickTargetNode = target->commonAncestor( | 268 clickTargetNode = target->commonAncestor( |
| 270 *m_clickNode, EventHandlingUtil::parentForClickEvent); | 269 *m_clickNode, EventHandlingUtil::parentForClickEvent); |
| 271 } | 270 } |
| 272 | |
| 273 // This block is only for the purpose of gathering the metric and can be | |
| 274 // removed as soon as we don't need the metric. | |
| 275 if (targetWithoutCapture != target) { | |
| 276 Node* alternativeClickTargetNode = nullptr; | |
| 277 if (m_clickNode == targetWithoutCapture) { | |
| 278 alternativeClickTargetNode = m_clickNode; | |
| 279 } else if (m_clickNode->document() == targetWithoutCapture->document()) { | |
| 280 alternativeClickTargetNode = targetWithoutCapture->commonAncestor( | |
| 281 *m_clickNode, EventHandlingUtil::parentForClickEvent); | |
| 282 } | |
| 283 if (alternativeClickTargetNode != clickTargetNode) { | |
| 284 UseCounter::count(m_frame, | |
| 285 UseCounter::PointerEventClickRetargetCausedByCapture); | |
| 286 } | |
| 287 } | |
| 288 | |
| 289 if (clickTargetNode) { | 271 if (clickTargetNode) { |
| 290 clickEventResult = dispatchMouseEvent( | 272 clickEventResult = dispatchMouseEvent( |
| 291 clickTargetNode, | 273 clickTargetNode, |
| 292 !RuntimeEnabledFeatures::auxclickEnabled() || | 274 !RuntimeEnabledFeatures::auxclickEnabled() || |
| 293 (mouseEvent.button == WebPointerProperties::Button::Left) | 275 (mouseEvent.button == WebPointerProperties::Button::Left) |
| 294 ? EventTypeNames::click | 276 ? EventTypeNames::click |
| 295 : EventTypeNames::auxclick, | 277 : EventTypeNames::auxclick, |
| 296 mouseEvent, canvasRegionId, nullptr); | 278 mouseEvent, canvasRegionId, nullptr); |
| 297 } | 279 } |
| 298 } | 280 } |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 | 1022 |
| 1041 void MouseEventManager::setClickCount(int clickCount) { | 1023 void MouseEventManager::setClickCount(int clickCount) { |
| 1042 m_clickCount = clickCount; | 1024 m_clickCount = clickCount; |
| 1043 } | 1025 } |
| 1044 | 1026 |
| 1045 bool MouseEventManager::mouseDownMayStartDrag() { | 1027 bool MouseEventManager::mouseDownMayStartDrag() { |
| 1046 return m_mouseDownMayStartDrag; | 1028 return m_mouseDownMayStartDrag; |
| 1047 } | 1029 } |
| 1048 | 1030 |
| 1049 } // namespace blink | 1031 } // namespace blink |
| OLD | NEW |