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

Side by Side Diff: third_party/WebKit/Source/core/events/MouseEvent.cpp

Issue 2832073003: Send mouse events for disabled form controls. (Closed)
Patch Set: Rebase Created 3 years, 7 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 /* 1 /*
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 MouseEvent& MouseEventDispatchMediator::Event() const { 432 MouseEvent& MouseEventDispatchMediator::Event() const {
433 return ToMouseEvent(EventDispatchMediator::GetEvent()); 433 return ToMouseEvent(EventDispatchMediator::GetEvent());
434 } 434 }
435 435
436 DispatchEventResult MouseEventDispatchMediator::DispatchEvent( 436 DispatchEventResult MouseEventDispatchMediator::DispatchEvent(
437 EventDispatcher& dispatcher) const { 437 EventDispatcher& dispatcher) const {
438 MouseEvent& mouse_event = Event(); 438 MouseEvent& mouse_event = Event();
439 mouse_event.GetEventPath().AdjustForRelatedTarget( 439 mouse_event.GetEventPath().AdjustForRelatedTarget(
440 dispatcher.GetNode(), mouse_event.relatedTarget()); 440 dispatcher.GetNode(), mouse_event.relatedTarget());
441 441
442 bool is_click = mouse_event.type() == EventTypeNames::click;
443 bool send_to_disabled_forms =
jbroman 2017/04/24 18:19:49 super-nit: send_to_disabled_controls or something
dtapuska 2017/04/24 19:14:39 Done.
444 RuntimeEnabledFeatures::sendMouseEventsDisabledFormControlsEnabled();
445
446 if (send_to_disabled_forms && is_click &&
447 mouse_event.GetEventPath().DisabledFormControlExistsInPath()) {
448 return DispatchEventResult::kCanceledBeforeDispatch;
449 }
450
442 if (!mouse_event.isTrusted()) 451 if (!mouse_event.isTrusted())
jbroman 2017/04/24 18:19:49 Does the layout test cover the logic beyond this p
dtapuska 2017/04/24 19:14:39 Yes that is correct. But the changed logic is *bef
443 return dispatcher.Dispatch(); 452 return dispatcher.Dispatch();
444 453
445 if (IsDisabledFormControl(&dispatcher.GetNode())) 454 if (!send_to_disabled_forms && IsDisabledFormControl(&dispatcher.GetNode()))
446 return DispatchEventResult::kCanceledBeforeDispatch; 455 return DispatchEventResult::kCanceledBeforeDispatch;
447 456
448 if (mouse_event.type().IsEmpty()) 457 if (mouse_event.type().IsEmpty())
449 return DispatchEventResult::kNotCanceled; // Shouldn't happen. 458 return DispatchEventResult::kNotCanceled; // Shouldn't happen.
450 459
451 DCHECK(!mouse_event.target() || 460 DCHECK(!mouse_event.target() ||
452 mouse_event.target() != mouse_event.relatedTarget()); 461 mouse_event.target() != mouse_event.relatedTarget());
453 462
454 EventTarget* related_target = mouse_event.relatedTarget(); 463 EventTarget* related_target = mouse_event.relatedTarget();
455 464
456 DispatchEventResult dispatch_result = dispatcher.Dispatch(); 465 DispatchEventResult dispatch_result = dispatcher.Dispatch();
457 466
458 if (mouse_event.type() != EventTypeNames::click || mouse_event.detail() != 2) 467 if (!is_click || mouse_event.detail() != 2)
459 return dispatch_result; 468 return dispatch_result;
460 469
461 // Special case: If it's a double click event, we also send the dblclick 470 // Special case: If it's a double click event, we also send the dblclick
462 // event. This is not part of the DOM specs, but is used for compatibility 471 // event. This is not part of the DOM specs, but is used for compatibility
463 // with the ondblclick="" attribute. This is treated as a separate event in 472 // with the ondblclick="" attribute. This is treated as a separate event in
464 // other DOM-compliant browsers like Firefox, and so we do the same. 473 // other DOM-compliant browsers like Firefox, and so we do the same.
465 MouseEvent* double_click_event = MouseEvent::Create(); 474 MouseEvent* double_click_event = MouseEvent::Create();
466 double_click_event->InitMouseEventInternal( 475 double_click_event->InitMouseEventInternal(
467 EventTypeNames::dblclick, mouse_event.bubbles(), mouse_event.cancelable(), 476 EventTypeNames::dblclick, mouse_event.bubbles(), mouse_event.cancelable(),
468 mouse_event.view(), mouse_event.detail(), mouse_event.screenX(), 477 mouse_event.view(), mouse_event.detail(), mouse_event.screenX(),
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 584
576 int MouseEvent::offsetY() { 585 int MouseEvent::offsetY() {
577 if (!HasPosition()) 586 if (!HasPosition())
578 return 0; 587 return 0;
579 if (!has_cached_relative_position_) 588 if (!has_cached_relative_position_)
580 ComputeRelativePosition(); 589 ComputeRelativePosition();
581 return std::round(offset_location_.Y()); 590 return std::round(offset_location_.Y());
582 } 591 }
583 592
584 } // namespace blink 593 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698