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

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

Issue 2832073003: Send mouse events for disabled form controls. (Closed)
Patch Set: Fix nits 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_form_controls =
444 RuntimeEnabledFeatures::sendMouseEventsDisabledFormControlsEnabled();
445
446 if (send_to_disabled_form_controls && is_click &&
447 mouse_event.GetEventPath().DisabledFormControlExistsInPath()) {
448 return DispatchEventResult::kCanceledBeforeDispatch;
449 }
450
442 if (!mouse_event.isTrusted()) 451 if (!mouse_event.isTrusted())
443 return dispatcher.Dispatch(); 452 return dispatcher.Dispatch();
444 453
445 if (IsDisabledFormControl(&dispatcher.GetNode())) 454 if (!send_to_disabled_form_controls &&
455 IsDisabledFormControl(&dispatcher.GetNode()))
446 return DispatchEventResult::kCanceledBeforeDispatch; 456 return DispatchEventResult::kCanceledBeforeDispatch;
447 457
448 if (mouse_event.type().IsEmpty()) 458 if (mouse_event.type().IsEmpty())
449 return DispatchEventResult::kNotCanceled; // Shouldn't happen. 459 return DispatchEventResult::kNotCanceled; // Shouldn't happen.
450 460
451 DCHECK(!mouse_event.target() || 461 DCHECK(!mouse_event.target() ||
452 mouse_event.target() != mouse_event.relatedTarget()); 462 mouse_event.target() != mouse_event.relatedTarget());
453 463
454 EventTarget* related_target = mouse_event.relatedTarget(); 464 EventTarget* related_target = mouse_event.relatedTarget();
455 465
456 DispatchEventResult dispatch_result = dispatcher.Dispatch(); 466 DispatchEventResult dispatch_result = dispatcher.Dispatch();
457 467
458 if (mouse_event.type() != EventTypeNames::click || mouse_event.detail() != 2) 468 if (!is_click || mouse_event.detail() != 2)
459 return dispatch_result; 469 return dispatch_result;
460 470
461 // Special case: If it's a double click event, we also send the dblclick 471 // 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 472 // 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 473 // 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. 474 // other DOM-compliant browsers like Firefox, and so we do the same.
465 MouseEvent* double_click_event = MouseEvent::Create(); 475 MouseEvent* double_click_event = MouseEvent::Create();
466 double_click_event->InitMouseEventInternal( 476 double_click_event->InitMouseEventInternal(
467 EventTypeNames::dblclick, mouse_event.bubbles(), mouse_event.cancelable(), 477 EventTypeNames::dblclick, mouse_event.bubbles(), mouse_event.cancelable(),
468 mouse_event.view(), mouse_event.detail(), mouse_event.screenX(), 478 mouse_event.view(), mouse_event.detail(), mouse_event.screenX(),
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 585
576 int MouseEvent::offsetY() { 586 int MouseEvent::offsetY() {
577 if (!HasPosition()) 587 if (!HasPosition())
578 return 0; 588 return 0;
579 if (!has_cached_relative_position_) 589 if (!has_cached_relative_position_)
580 ComputeRelativePosition(); 590 ComputeRelativePosition();
581 return std::round(offset_location_.Y()); 591 return std::round(offset_location_.Y());
582 } 592 }
583 593
584 } // namespace blink 594 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698