From a965486fcbf3f199b5c7564bfc0526df72c862d5 Mon Sep 17 00:00:00 2001 From: athenian200 Date: Wed, 20 May 2020 23:25:37 -0500 Subject: Revert "Merge pull request #1357 from athenian200/form-disabled-issue" This reverts commit ed88b99849156004c04e4a0c87ea9b2360ef19b6, reversing changes made to c4b0715baaffc541670fd1158557aa7e61e521d3. --- dom/html/nsGenericHTMLElement.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'dom/html/nsGenericHTMLElement.cpp') diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index 3cf19ea8f..aa70f9cdf 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2108,6 +2108,14 @@ nsGenericHTMLFormElement::PreHandleEvent(EventChainVisitor& aVisitor) return nsGenericHTMLElement::PreHandleEvent(aVisitor); } +/* virtual */ +bool +nsGenericHTMLFormElement::IsDisabled() const +{ + return HasAttr(kNameSpaceID_None, nsGkAtoms::disabled) || + (mFieldSet && mFieldSet->IsDisabled()); +} + void nsGenericHTMLFormElement::ForgetFieldSet(nsIContent* aFieldset) { @@ -2299,13 +2307,14 @@ nsGenericHTMLFormElement::IsElementDisabledForEvents(EventMessage aMessage, break; } - // FIXME(emilio): This poking at the style of the frame is slightly bogus - // unless we flush before every event, which we don't really want to do. - if (aFrame && - aFrame->StyleUserInterface()->mUserInput == StyleUserInput::None) { - return true; + bool disabled = IsDisabled(); + if (!disabled && aFrame) { + const nsStyleUserInterface* uiStyle = aFrame->StyleUserInterface(); + disabled = uiStyle->mUserInput == StyleUserInput::None || + uiStyle->mUserInput == StyleUserInput::Disabled; + } - return IsDisabled(); + return disabled; } void -- cgit v1.2.3 From 0a19762d3bb5f6bcaa00a8f168e469d9fdda76b9 Mon Sep 17 00:00:00 2001 From: athenian200 Date: Thu, 21 May 2020 01:31:48 -0500 Subject: Issue #1557 - Allow event dispatch on disabled form controls. Based on https://bugzilla.mozilla.org/show_bug.cgi?id=329509 This seems to resolve #1356 without causing #1557. Also reverts previous changes as they no longer appear to serve a purpose. --- dom/html/nsGenericHTMLElement.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'dom/html/nsGenericHTMLElement.cpp') diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index aa70f9cdf..17dba6da9 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2285,10 +2285,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: @@ -2454,8 +2461,9 @@ nsGenericHTMLFormElement::IsLabelable() const void nsGenericHTMLElement::Click() { - if (HandlingClick()) + if (IsDisabled() || HandlingClick()) { return; + } // Strong in case the event kills it nsCOMPtr doc = GetComposedDoc(); -- cgit v1.2.3