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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // 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 |
245 // context menu is currently open in WebPage::mouseEvent(). Consider merging | 245 // context menu is currently open in WebPage::mouseEvent(). Consider merging |
246 // the implementations. | 246 // the implementations. |
247 if (mouseEvent.button == WebPointerProperties::Button::Left && | 247 if (mouseEvent.button == WebPointerProperties::Button::Left && |
248 mouseEvent.modifiers() & WebInputEvent::Modifiers::ControlKey) | 248 mouseEvent.modifiers() & WebInputEvent::Modifiers::ControlKey) |
249 contextMenuEvent = true; | 249 contextMenuEvent = true; |
250 #endif | 250 #endif |
251 | 251 |
252 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; | 252 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; |
253 const bool shouldDispatchClickEvent = m_clickCount > 0 && !contextMenuEvent && | 253 const bool shouldDispatchClickEvent = m_clickCount > 0 && !contextMenuEvent && |
254 m_clickNode && | 254 target && m_clickNode && |
| 255 target->canParticipateInFlatTree() && |
255 m_clickNode->canParticipateInFlatTree(); | 256 m_clickNode->canParticipateInFlatTree(); |
256 if (shouldDispatchClickEvent) { | 257 if (shouldDispatchClickEvent) { |
257 Node* clickTargetNode = nullptr; | 258 Node* clickTargetNode = nullptr; |
258 // Updates distribution because a 'mouseup' event listener can make the | 259 // Updates distribution because a 'mouseup' event listener can make the |
259 // tree dirty at dispatchMouseEvent() invocation above. | 260 // tree dirty at dispatchMouseEvent() invocation above. |
260 // Unless distribution is updated, commonAncestor would hit ASSERT. | 261 // Unless distribution is updated, commonAncestor would hit ASSERT. |
261 if (target && target->canParticipateInFlatTree()) { | 262 if (m_clickNode == target) { |
262 if (m_clickNode == target) { | 263 clickTargetNode = m_clickNode; |
263 clickTargetNode = m_clickNode; | 264 clickTargetNode->updateDistribution(); |
264 clickTargetNode->updateDistribution(); | 265 } else if (m_clickNode->document() == target->document()) { |
265 } else if (m_clickNode->document() == target->document()) { | 266 m_clickNode->updateDistribution(); |
266 m_clickNode->updateDistribution(); | 267 target->updateDistribution(); |
267 target->updateDistribution(); | 268 clickTargetNode = target->commonAncestor( |
268 clickTargetNode = target->commonAncestor( | 269 *m_clickNode, EventHandlingUtil::parentForClickEvent); |
269 *m_clickNode, EventHandlingUtil::parentForClickEvent); | |
270 } | |
271 } | 270 } |
272 | 271 |
273 // This block is only for the purpose of gathering the metric and can be | 272 // 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. | 273 // removed as soon as we don't need the metric. |
275 if (targetWithoutCapture != target) { | 274 if (targetWithoutCapture != target) { |
276 Node* alternativeClickTargetNode = nullptr; | 275 Node* alternativeClickTargetNode = nullptr; |
277 if (targetWithoutCapture && | 276 if (m_clickNode == targetWithoutCapture) { |
278 targetWithoutCapture->canParticipateInFlatTree()) { | 277 alternativeClickTargetNode = m_clickNode; |
279 if (m_clickNode == targetWithoutCapture) { | 278 } else if (m_clickNode->document() == targetWithoutCapture->document()) { |
280 alternativeClickTargetNode = m_clickNode; | 279 alternativeClickTargetNode = targetWithoutCapture->commonAncestor( |
281 } else if (m_clickNode->document() == | 280 *m_clickNode, EventHandlingUtil::parentForClickEvent); |
282 targetWithoutCapture->document()) { | |
283 alternativeClickTargetNode = targetWithoutCapture->commonAncestor( | |
284 *m_clickNode, EventHandlingUtil::parentForClickEvent); | |
285 } | |
286 } | 281 } |
287 if (alternativeClickTargetNode != clickTargetNode) { | 282 if (alternativeClickTargetNode != clickTargetNode) { |
288 UseCounter::count(m_frame, | 283 UseCounter::count(m_frame, |
289 UseCounter::PointerEventClickRetargetCausedByCapture); | 284 UseCounter::PointerEventClickRetargetCausedByCapture); |
290 } | 285 } |
291 // TODO(crbug.com/699933): The following line removes the effect of | |
292 // pointer capture. | |
293 clickTargetNode = alternativeClickTargetNode; | |
294 } | 286 } |
295 | 287 |
296 if (clickTargetNode) { | 288 if (clickTargetNode) { |
297 clickEventResult = dispatchMouseEvent( | 289 clickEventResult = dispatchMouseEvent( |
298 clickTargetNode, | 290 clickTargetNode, |
299 !RuntimeEnabledFeatures::auxclickEnabled() || | 291 !RuntimeEnabledFeatures::auxclickEnabled() || |
300 (mouseEvent.button == WebPointerProperties::Button::Left) | 292 (mouseEvent.button == WebPointerProperties::Button::Left) |
301 ? EventTypeNames::click | 293 ? EventTypeNames::click |
302 : EventTypeNames::auxclick, | 294 : EventTypeNames::auxclick, |
303 mouseEvent, canvasRegionId, nullptr); | 295 mouseEvent, canvasRegionId, nullptr); |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 | 1037 |
1046 void MouseEventManager::setClickCount(int clickCount) { | 1038 void MouseEventManager::setClickCount(int clickCount) { |
1047 m_clickCount = clickCount; | 1039 m_clickCount = clickCount; |
1048 } | 1040 } |
1049 | 1041 |
1050 bool MouseEventManager::mouseDownMayStartDrag() { | 1042 bool MouseEventManager::mouseDownMayStartDrag() { |
1051 return m_mouseDownMayStartDrag; | 1043 return m_mouseDownMayStartDrag; |
1052 } | 1044 } |
1053 | 1045 |
1054 } // namespace blink | 1046 } // namespace blink |
OLD | NEW |