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

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

Issue 2771463002: Revert "Send click event after pointer capturing retarget" (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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 if (targetNode && targetNode->isTextNode()) 225 if (targetNode && targetNode->isTextNode())
226 targetNode = FlatTreeTraversal::parent(*targetNode); 226 targetNode = FlatTreeTraversal::parent(*targetNode);
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 const MouseEventWithHitTestResults& mev) {
236 const WebMouseEvent& mouseEvent,
237 const String& canvasRegionId) {
238 // We only prevent click event when the click may cause contextmenu to popup. 236 // We only prevent click event when the click may cause contextmenu to popup.
239 // However, we always send auxclick. 237 // However, we always send auxclick.
240 bool contextMenuEvent = 238 bool contextMenuEvent =
241 !RuntimeEnabledFeatures::auxclickEnabled() && 239 !RuntimeEnabledFeatures::auxclickEnabled() &&
242 mouseEvent.button == WebPointerProperties::Button::Right; 240 mev.event().button == WebPointerProperties::Button::Right;
243 #if OS(MACOSX) 241 #if OS(MACOSX)
244 // FIXME: The Mac port achieves the same behavior by checking whether the 242 // FIXME: The Mac port achieves the same behavior by checking whether the
245 // context menu is currently open in WebPage::mouseEvent(). Consider merging 243 // context menu is currently open in WebPage::mouseEvent(). Consider merging
246 // the implementations. 244 // the implementations.
247 if (mouseEvent.button == WebPointerProperties::Button::Left && 245 if (mev.event().button == WebPointerProperties::Button::Left &&
248 mouseEvent.modifiers() & WebInputEvent::Modifiers::ControlKey) 246 mev.event().modifiers() & WebInputEvent::Modifiers::ControlKey)
249 contextMenuEvent = true; 247 contextMenuEvent = true;
250 #endif 248 #endif
251 249
252 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; 250 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled;
253 const bool shouldDispatchClickEvent = m_clickCount > 0 && !contextMenuEvent && 251 const bool shouldDispatchClickEvent =
254 target && m_clickNode && 252 m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode &&
255 target->canParticipateInFlatTree() && 253 mev.innerNode()->canParticipateInFlatTree() &&
256 m_clickNode->canParticipateInFlatTree(); 254 m_clickNode->canParticipateInFlatTree() &&
255 !(m_frame->eventHandler().selectionController().hasExtendedSelection() &&
256 isLinkSelection(mev));
257 if (shouldDispatchClickEvent) { 257 if (shouldDispatchClickEvent) {
258 Node* clickTargetNode = nullptr; 258 Node* clickTargetNode = nullptr;
259 // Updates distribution because a 'mouseup' event listener can make the 259 // Updates distribution because a 'mouseup' event listener can make the
260 // tree dirty at dispatchMouseEvent() invocation above. 260 // tree dirty at dispatchMouseEvent() invocation above.
261 // Unless distribution is updated, commonAncestor would hit ASSERT. 261 // Unless distribution is updated, commonAncestor would hit ASSERT.
262 if (m_clickNode == target) { 262 if (m_clickNode == mev.innerNode()) {
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() == mev.innerNode()->document()) {
266 m_clickNode->updateDistribution(); 266 m_clickNode->updateDistribution();
267 target->updateDistribution(); 267 mev.innerNode()->updateDistribution();
268 clickTargetNode = target->commonAncestor( 268 clickTargetNode = mev.innerNode()->commonAncestor(
269 *m_clickNode, EventHandlingUtil::parentForClickEvent); 269 *m_clickNode, EventHandlingUtil::parentForClickEvent);
270 } 270 }
271 if (clickTargetNode) { 271 if (clickTargetNode) {
272 clickEventResult = dispatchMouseEvent( 272 clickEventResult = dispatchMouseEvent(
273 clickTargetNode, 273 clickTargetNode,
274 !RuntimeEnabledFeatures::auxclickEnabled() || 274 !RuntimeEnabledFeatures::auxclickEnabled() ||
275 (mouseEvent.button == WebPointerProperties::Button::Left) 275 (mev.event().button == WebPointerProperties::Button::Left)
276 ? EventTypeNames::click 276 ? EventTypeNames::click
277 : EventTypeNames::auxclick, 277 : EventTypeNames::auxclick,
278 mouseEvent, canvasRegionId, nullptr); 278 mev.event(), mev.canvasRegionId(), nullptr);
279 } 279 }
280 } 280 }
281 return clickEventResult; 281 return clickEventResult;
282 } 282 }
283 283
284 void MouseEventManager::fakeMouseMoveEventTimerFired(TimerBase* timer) { 284 void MouseEventManager::fakeMouseMoveEventTimerFired(TimerBase* timer) {
285 TRACE_EVENT0("input", "MouseEventManager::fakeMouseMoveEventTimerFired"); 285 TRACE_EVENT0("input", "MouseEventManager::fakeMouseMoveEventTimerFired");
286 DCHECK(timer == &m_fakeMouseMoveEventTimer); 286 DCHECK(timer == &m_fakeMouseMoveEventTimer);
287 DCHECK(!m_mousePressed); 287 DCHECK(!m_mousePressed);
288 288
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 568 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
569 569
570 if (FrameView* frameView = m_frame->view()) { 570 if (FrameView* frameView = m_frame->view()) {
571 if (frameView->isPointInScrollbarCorner( 571 if (frameView->isPointInScrollbarCorner(
572 flooredIntPoint(event.event().positionInRootFrame()))) 572 flooredIntPoint(event.event().positionInRootFrame())))
573 return WebInputEventResult::NotHandled; 573 return WebInputEventResult::NotHandled;
574 } 574 }
575 575
576 bool singleClick = event.event().clickCount <= 1; 576 bool singleClick = event.event().clickCount <= 1;
577 577
578 m_mouseDownMayStartDrag = singleClick && !isSelectionOverLink(event) && 578 m_mouseDownMayStartDrag =
579 !isExtendingSelection(event); 579 singleClick && !isLinkSelection(event) && !isExtendingSelection(event);
580 580
581 m_frame->eventHandler().selectionController().handleMousePressEvent(event); 581 m_frame->eventHandler().selectionController().handleMousePressEvent(event);
582 582
583 m_mouseDown = event.event(); 583 m_mouseDown = event.event();
584 584
585 if (m_frame->document()->isSVGDocument() && 585 if (m_frame->document()->isSVGDocument() &&
586 m_frame->document()->accessSVGExtensions().zoomAndPanEnabled()) { 586 m_frame->document()->accessSVGExtensions().zoomAndPanEnabled()) {
587 if ((event.event().modifiers() & WebInputEvent::Modifiers::ShiftKey) && 587 if ((event.event().modifiers() & WebInputEvent::Modifiers::ShiftKey) &&
588 singleClick) { 588 singleClick) {
589 m_svgPan = true; 589 m_svgPan = true;
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 1022
1023 void MouseEventManager::setClickCount(int clickCount) { 1023 void MouseEventManager::setClickCount(int clickCount) {
1024 m_clickCount = clickCount; 1024 m_clickCount = clickCount;
1025 } 1025 }
1026 1026
1027 bool MouseEventManager::mouseDownMayStartDrag() { 1027 bool MouseEventManager::mouseDownMayStartDrag() {
1028 return m_mouseDownMayStartDrag; 1028 return m_mouseDownMayStartDrag;
1029 } 1029 }
1030 1030
1031 } // namespace blink 1031 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/MouseEventManager.h ('k') | third_party/WebKit/Source/core/input/PointerEventManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698