Bug 1379466 - Make editor listen for auxclick mouse events. r=smaug,masayuki
Editable elements will no longer get click events for non-primary mouse buttons since they are being unshipped from the web in favour of auxclick events. Listen for auxclick as well so middle-click paste still works. Don't stop propagation after middle-click paste, instead ignore clicks on contenteditable elements in ClickHandlerChild. Update test_middle_click_paste.html for the new behaviour. Also remove the mNoContentDispatch overrides in HTMLInputElement and HTMLTextAreaElement that were needed for middle-pasting. Differential Revision: https://phabricator.services.mozilla.com/D26792
This commit is contained in:
@@ -127,16 +127,15 @@ namespace dom {
|
||||
// First bits are needed for the control type.
|
||||
#define NS_OUTER_ACTIVATE_EVENT (1 << 9)
|
||||
#define NS_ORIGINAL_CHECKED_VALUE (1 << 10)
|
||||
#define NS_NO_CONTENT_DISPATCH (1 << 11)
|
||||
// (1 << 11 is unused)
|
||||
#define NS_ORIGINAL_INDETERMINATE_VALUE (1 << 12)
|
||||
#define NS_PRE_HANDLE_BLUR_EVENT (1 << 13)
|
||||
#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))
|
||||
#define NS_CONTROL_TYPE(bits) \
|
||||
((bits) & ~(NS_OUTER_ACTIVATE_EVENT | NS_ORIGINAL_CHECKED_VALUE | \
|
||||
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:
|
||||
// -1: no, 1: yes, 0: uninitialized
|
||||
@@ -3202,19 +3201,6 @@ void HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
||||
aVisitor.mItemFlags |= NS_ORIGINAL_CHECKED_VALUE;
|
||||
}
|
||||
|
||||
// If mNoContentDispatch is true we will not allow content to handle
|
||||
// this event. But to allow middle mouse button paste to work we must allow
|
||||
// middle clicks to go to text fields anyway.
|
||||
if (aVisitor.mEvent->mFlags.mNoContentDispatch) {
|
||||
aVisitor.mItemFlags |= NS_NO_CONTENT_DISPATCH;
|
||||
}
|
||||
if (IsSingleLineTextControl(false) &&
|
||||
aVisitor.mEvent->mMessage == eMouseClick &&
|
||||
aVisitor.mEvent->AsMouseEvent()->button ==
|
||||
WidgetMouseEvent::eMiddleButton) {
|
||||
aVisitor.mEvent->mFlags.mNoContentDispatch = false;
|
||||
}
|
||||
|
||||
// We must cache type because mType may change during JS event (bug 2369)
|
||||
aVisitor.mItemFlags |= mType;
|
||||
|
||||
@@ -3705,7 +3691,6 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
|
||||
bool outerActivateEvent = !!(aVisitor.mItemFlags & NS_OUTER_ACTIVATE_EVENT);
|
||||
bool originalCheckedValue =
|
||||
!!(aVisitor.mItemFlags & NS_ORIGINAL_CHECKED_VALUE);
|
||||
bool noContentDispatch = !!(aVisitor.mItemFlags & NS_NO_CONTENT_DISPATCH);
|
||||
uint8_t oldType = NS_CONTROL_TYPE(aVisitor.mItemFlags);
|
||||
|
||||
// Ideally we would make the default action for click and space just dispatch
|
||||
@@ -3756,9 +3741,6 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the flag for other content besides this text field
|
||||
aVisitor.mEvent->mFlags.mNoContentDispatch = noContentDispatch;
|
||||
|
||||
// now check to see if the event was "cancelled"
|
||||
if (mCheckedIsToggled && outerActivateEvent) {
|
||||
if (aVisitor.mEventStatus == nsEventStatus_eConsumeNoDefault) {
|
||||
|
||||
Reference in New Issue
Block a user