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

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

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

Powered by Google App Engine
This is Rietveld 408576698