Bug 1610821 - Part 2: Ensure most of event handling works on input elements which are disconnected from a document; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D60672
This commit is contained in:
@@ -3116,11 +3116,6 @@ void HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
|||||||
if (textControlFrame) textControlFrame->EnsureEditorInitialized();
|
if (textControlFrame) textControlFrame->EnsureEditorInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME Allow submission etc. also when there is no prescontext, Bug 329509.
|
|
||||||
if (!aVisitor.mPresContext) {
|
|
||||||
nsGenericHTMLFormElementWithState::GetEventTargetParent(aVisitor);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
// Web pages expect the value of a radio button or checkbox to be set
|
// Web pages expect the value of a radio button or checkbox to be set
|
||||||
// *before* onclick and DOMActivate fire, and they expect that if they set
|
// *before* onclick and DOMActivate fire, and they expect that if they set
|
||||||
@@ -3316,9 +3311,6 @@ void HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult HTMLInputElement::PreHandleEvent(EventChainVisitor& aVisitor) {
|
nsresult HTMLInputElement::PreHandleEvent(EventChainVisitor& aVisitor) {
|
||||||
if (!aVisitor.mPresContext) {
|
|
||||||
return nsGenericHTMLFormElementWithState::PreHandleEvent(aVisitor);
|
|
||||||
}
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
if (aVisitor.mItemFlags & NS_PRE_HANDLE_BLUR_EVENT) {
|
if (aVisitor.mItemFlags & NS_PRE_HANDLE_BLUR_EVENT) {
|
||||||
MOZ_ASSERT(aVisitor.mEvent->mMessage == eBlur);
|
MOZ_ASSERT(aVisitor.mEvent->mMessage == eBlur);
|
||||||
@@ -3594,12 +3586,6 @@ static bool IgnoreInputEventWithModifier(WidgetInputEvent* aEvent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
|
nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
|
||||||
if (!aVisitor.mPresContext) {
|
|
||||||
// Hack alert! In order to open file picker even in case the element isn't
|
|
||||||
// in document, try to init picker even without PresContext.
|
|
||||||
return MaybeInitPickers(aVisitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aVisitor.mEvent->mMessage == eFocus ||
|
if (aVisitor.mEvent->mMessage == eFocus ||
|
||||||
aVisitor.mEvent->mMessage == eBlur) {
|
aVisitor.mEvent->mMessage == eBlur) {
|
||||||
if (aVisitor.mEvent->mMessage == eBlur) {
|
if (aVisitor.mEvent->mMessage == eBlur) {
|
||||||
@@ -3638,7 +3624,9 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
|
|||||||
InternalUIEvent actEvent(true, eLegacyDOMActivate, mouseEvent);
|
InternalUIEvent actEvent(true, eLegacyDOMActivate, mouseEvent);
|
||||||
actEvent.mDetail = 1;
|
actEvent.mDetail = 1;
|
||||||
|
|
||||||
if (RefPtr<PresShell> presShell = aVisitor.mPresContext->GetPresShell()) {
|
if (RefPtr<PresShell> presShell =
|
||||||
|
aVisitor.mPresContext ? aVisitor.mPresContext->GetPresShell()
|
||||||
|
: nullptr) {
|
||||||
nsEventStatus status = nsEventStatus_eIgnore;
|
nsEventStatus status = nsEventStatus_eIgnore;
|
||||||
mInInternalActivate = true;
|
mInInternalActivate = true;
|
||||||
rv = presShell->HandleDOMEventWithTarget(this, &actEvent, &status);
|
rv = presShell->HandleDOMEventWithTarget(this, &actEvent, &status);
|
||||||
@@ -3782,7 +3770,8 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
|
|||||||
case NS_FORM_INPUT_CHECKBOX:
|
case NS_FORM_INPUT_CHECKBOX:
|
||||||
case NS_FORM_INPUT_RADIO: {
|
case NS_FORM_INPUT_RADIO: {
|
||||||
// Checkbox and Radio try to submit on Enter press
|
// Checkbox and Radio try to submit on Enter press
|
||||||
if (keyEvent->mKeyCode != NS_VK_SPACE) {
|
if (keyEvent->mKeyCode != NS_VK_SPACE &&
|
||||||
|
aVisitor.mPresContext) {
|
||||||
MaybeSubmitForm(MOZ_KnownLive(aVisitor.mPresContext));
|
MaybeSubmitForm(MOZ_KnownLive(aVisitor.mPresContext));
|
||||||
|
|
||||||
break; // If we are submitting, do not send click event
|
break; // If we are submitting, do not send click event
|
||||||
@@ -3861,8 +3850,10 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
|
|||||||
mType == NS_FORM_INPUT_NUMBER ||
|
mType == NS_FORM_INPUT_NUMBER ||
|
||||||
IsExperimentalMobileType(mType) || IsDateTimeInputType(mType))) {
|
IsExperimentalMobileType(mType) || IsDateTimeInputType(mType))) {
|
||||||
FireChangeEventIfNeeded();
|
FireChangeEventIfNeeded();
|
||||||
rv = MaybeSubmitForm(MOZ_KnownLive(aVisitor.mPresContext));
|
if (aVisitor.mPresContext) {
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
rv = MaybeSubmitForm(MOZ_KnownLive(aVisitor.mPresContext));
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aVisitor.mEvent->mMessage == eKeyPress &&
|
if (aVisitor.mEvent->mMessage == eKeyPress &&
|
||||||
|
|||||||
@@ -14,9 +14,3 @@
|
|||||||
[disabled checkbox still has activation behavior, part 2]
|
[disabled checkbox still has activation behavior, part 2]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[disconnected checkbox should be checked]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[disconnected radio should be checked]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
[checkbox-click-events.html]
|
|
||||||
[clicking and preventDefaulting a checkbox causes the checkbox to be checked during the click handler but reverted]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user