mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-30 20:37:31 +09:00
Issue #2030 - Allow child nodes of button to participate in mouse hit tests
This is needed for web compatibility, even if standards compliance is debatable.
This commit is contained in:
parent
4d310562d9
commit
4354c7a1bc
4 changed files with 28 additions and 18 deletions
|
|
@ -221,11 +221,14 @@ HTMLButtonElement::GetEventTargetParent(EventChainPreVisitor& aVisitor)
|
||||||
bool outerActivateEvent =
|
bool outerActivateEvent =
|
||||||
((mouseEvent && mouseEvent->IsLeftClickEvent()) ||
|
((mouseEvent && mouseEvent->IsLeftClickEvent()) ||
|
||||||
(aVisitor.mEvent->mMessage == eLegacyDOMActivate &&
|
(aVisitor.mEvent->mMessage == eLegacyDOMActivate &&
|
||||||
!mInInternalActivate));
|
!mInInternalActivate &&
|
||||||
|
aVisitor.mEvent->mOriginalTarget == this));
|
||||||
|
|
||||||
if (outerActivateEvent) {
|
if (outerActivateEvent) {
|
||||||
aVisitor.mItemFlags |= NS_OUTER_ACTIVATE_EVENT;
|
aVisitor.mItemFlags |= NS_OUTER_ACTIVATE_EVENT;
|
||||||
if (mType == NS_FORM_BUTTON_SUBMIT && mForm) {
|
if (mType == NS_FORM_BUTTON_SUBMIT && mForm &&
|
||||||
|
!aVisitor.mEvent->mFlags.mMultiplePreActionsPrevented) {
|
||||||
|
aVisitor.mEvent->mFlags.mMultiplePreActionsPrevented = true;
|
||||||
aVisitor.mItemFlags |= NS_IN_SUBMIT_CLICK;
|
aVisitor.mItemFlags |= NS_IN_SUBMIT_CLICK;
|
||||||
// tell the form that we are about to enter a click handler.
|
// tell the form that we are about to enter a click handler.
|
||||||
// that means that if there are scripted submissions, the
|
// that means that if there are scripted submissions, the
|
||||||
|
|
|
||||||
|
|
@ -143,11 +143,14 @@ namespace dom {
|
||||||
#define NS_ORIGINAL_CHECKED_VALUE (1 << 10)
|
#define NS_ORIGINAL_CHECKED_VALUE (1 << 10)
|
||||||
#define NS_NO_CONTENT_DISPATCH (1 << 11)
|
#define NS_NO_CONTENT_DISPATCH (1 << 11)
|
||||||
#define NS_ORIGINAL_INDETERMINATE_VALUE (1 << 12)
|
#define NS_ORIGINAL_INDETERMINATE_VALUE (1 << 12)
|
||||||
#define NS_CONTROL_TYPE(bits) ((bits) & ~( \
|
|
||||||
NS_OUTER_ACTIVATE_EVENT | NS_ORIGINAL_CHECKED_VALUE | NS_NO_CONTENT_DISPATCH | \
|
|
||||||
NS_ORIGINAL_INDETERMINATE_VALUE))
|
|
||||||
#define NS_PRE_HANDLE_BLUR_EVENT (1 << 13)
|
#define NS_PRE_HANDLE_BLUR_EVENT (1 << 13)
|
||||||
#define NS_PRE_HANDLE_INPUT_EVENT (1 << 14)
|
#define NS_PRE_HANDLE_INPUT_EVENT (1 << 14)
|
||||||
|
#define NS_IN_SUBMIT_CLICK (1 << 15)
|
||||||
|
#define NS_CONTROL_TYPE(bits) \
|
||||||
|
((bits) & ~(NS_OUTER_ACTIVATE_EVENT | NS_ORIGINAL_CHECKED_VALUE | \
|
||||||
|
NS_NO_CONTENT_DISPATCH | NS_ORIGINAL_INDETERMINATE_VALUE | \
|
||||||
|
NS_PRE_HANDLE_BLUR_EVENT | NS_PRE_HANDLE_INPUT_EVENT | \
|
||||||
|
NS_IN_SUBMIT_CLICK))
|
||||||
|
|
||||||
// whether textfields should be selected once focused:
|
// whether textfields should be selected once focused:
|
||||||
// -1: no, 1: yes, 0: uninitialized
|
// -1: no, 1: yes, 0: uninitialized
|
||||||
|
|
@ -3800,7 +3803,10 @@ HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor)
|
||||||
|
|
||||||
case NS_FORM_INPUT_SUBMIT:
|
case NS_FORM_INPUT_SUBMIT:
|
||||||
case NS_FORM_INPUT_IMAGE:
|
case NS_FORM_INPUT_IMAGE:
|
||||||
if (mForm) {
|
if (mForm && !aVisitor.mEvent->mFlags.mMultiplePreActionsPrevented) {
|
||||||
|
// Make sure other submit elements don't try to trigger submission.
|
||||||
|
aVisitor.mEvent->mFlags.mMultiplePreActionsPrevented = true;
|
||||||
|
aVisitor.mItemFlags |= NS_IN_SUBMIT_CLICK;
|
||||||
// tell the form that we are about to enter a click handler.
|
// tell the form that we are about to enter a click handler.
|
||||||
// that means that if there are scripted submissions, the
|
// that means that if there are scripted submissions, the
|
||||||
// latest one will be deferred until after the exit point of the handler.
|
// latest one will be deferred until after the exit point of the handler.
|
||||||
|
|
@ -4394,17 +4400,15 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outerActivateEvent) {
|
if ((aVisitor.mItemFlags & NS_IN_SUBMIT_CLICK) && mForm) {
|
||||||
switch(oldType) {
|
switch(oldType) {
|
||||||
case NS_FORM_INPUT_SUBMIT:
|
case NS_FORM_INPUT_SUBMIT:
|
||||||
case NS_FORM_INPUT_IMAGE:
|
case NS_FORM_INPUT_IMAGE:
|
||||||
if (mForm) {
|
|
||||||
// tell the form that we are about to exit a click handler
|
// tell the form that we are about to exit a click handler
|
||||||
// so the form knows not to defer subsequent submissions
|
// so the form knows not to defer subsequent submissions
|
||||||
// the pending ones that were created during the handler
|
// the pending ones that were created during the handler
|
||||||
// will be flushed or forgoten.
|
// will be flushed or forgoten.
|
||||||
mForm->OnSubmitClickEnd();
|
mForm->OnSubmitClickEnd();
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
@ -4770,7 +4774,8 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
||||||
if (outerActivateEvent) {
|
if (outerActivateEvent) {
|
||||||
if (mForm && (oldType == NS_FORM_INPUT_SUBMIT ||
|
if (mForm && (oldType == NS_FORM_INPUT_SUBMIT ||
|
||||||
oldType == NS_FORM_INPUT_IMAGE)) {
|
oldType == NS_FORM_INPUT_IMAGE)) {
|
||||||
if (mType != NS_FORM_INPUT_SUBMIT && mType != NS_FORM_INPUT_IMAGE) {
|
if (mType != NS_FORM_INPUT_SUBMIT && mType != NS_FORM_INPUT_IMAGE &&
|
||||||
|
aVisitor.mItemFlags & NS_IN_SUBMIT_CLICK) {
|
||||||
// If the type has changed to a non-submit type, then we want to
|
// If the type has changed to a non-submit type, then we want to
|
||||||
// flush the stored submission if there is one (as if the submit()
|
// flush the stored submission if there is one (as if the submit()
|
||||||
// was allowed to succeed)
|
// was allowed to succeed)
|
||||||
|
|
@ -4809,7 +4814,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
||||||
break;
|
break;
|
||||||
} //switch
|
} //switch
|
||||||
} //click or outer activate event
|
} //click or outer activate event
|
||||||
} else if (outerActivateEvent &&
|
} else if ((aVisitor.mItemFlags & NS_IN_SUBMIT_CLICK) &&
|
||||||
(oldType == NS_FORM_INPUT_SUBMIT ||
|
(oldType == NS_FORM_INPUT_SUBMIT ||
|
||||||
oldType == NS_FORM_INPUT_IMAGE) &&
|
oldType == NS_FORM_INPUT_IMAGE) &&
|
||||||
mForm) {
|
mForm) {
|
||||||
|
|
|
||||||
|
|
@ -118,8 +118,8 @@ nsHTMLButtonControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||||
|
|
||||||
nsDisplayListCollection set(aBuilder);
|
nsDisplayListCollection set(aBuilder);
|
||||||
|
|
||||||
// Do not allow the child subtree to receive events.
|
// HTMLInputElement buttons are opaque to hit tests, HTMLButtonElement buttons are not.
|
||||||
if (!isForEventDelivery) {
|
if (!(isForEventDelivery && this->IsInput())) {
|
||||||
DisplayListClipState::AutoSaveRestore clipState(aBuilder);
|
DisplayListClipState::AutoSaveRestore clipState(aBuilder);
|
||||||
|
|
||||||
if (ShouldClipPaintingToBorderBox()) {
|
if (ShouldClipPaintingToBorderBox()) {
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,8 @@ public:
|
||||||
// the first <label> element is clicked, that one may set this true.
|
// the first <label> element is clicked, that one may set this true.
|
||||||
// Then, the second <label> element won't handle the event.
|
// Then, the second <label> element won't handle the event.
|
||||||
bool mMultipleActionsPrevented : 1;
|
bool mMultipleActionsPrevented : 1;
|
||||||
|
// Similar to above but expected to be used during PreHandleEvent phase.
|
||||||
|
bool mMultiplePreActionsPrevented : 1;
|
||||||
// If mIsBeingDispatched is true, the DOM event created from the event is
|
// If mIsBeingDispatched is true, the DOM event created from the event is
|
||||||
// dispatching into the DOM tree and not completed.
|
// dispatching into the DOM tree and not completed.
|
||||||
bool mIsBeingDispatched : 1;
|
bool mIsBeingDispatched : 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue