Bug 329509 - allow dispatching event when element is disabled. r=annevk,smaug

Allow untrusted Events and Custom events to be dispatched at disabled form element. This is for interop and some developers have asked for this.

Differential Revision: https://phabricator.services.mozilla.com/D10000
This commit is contained in:
Marcos Cáceres
2018-10-31 08:55:33 +00:00
parent 4b3c93bd80
commit 62fdb0177b
17 changed files with 172 additions and 35 deletions

View File

@@ -2180,10 +2180,17 @@ nsGenericHTMLFormElement::FormIdUpdated(Element* aOldElement,
}
bool
nsGenericHTMLFormElement::IsElementDisabledForEvents(EventMessage aMessage,
nsGenericHTMLFormElement::IsElementDisabledForEvents(WidgetEvent* aEvent,
nsIFrame* aFrame)
{
switch (aMessage) {
MOZ_ASSERT(aEvent);
// Allow dispatch of CustomEvent and untrusted Events.
if (!aEvent->IsTrusted()) {
return false;
}
switch (aEvent->mMessage) {
case eMouseMove:
case eMouseOver:
case eMouseOut:
@@ -2440,8 +2447,9 @@ nsGenericHTMLFormElement::GetFormAction(nsString& aValue)
void
nsGenericHTMLElement::Click(CallerType aCallerType)
{
if (HandlingClick())
if (IsDisabled() || HandlingClick()) {
return;
}
// Strong in case the event kills it
nsCOMPtr<nsIDocument> doc = GetComposedDoc();