nsresult HTMLButtonElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = false; if (IsDisabledForEvents(aVisitor.mEvent->mMessage)) { return NS_OK; } // Track whether we're in the outermost Dispatch invocation that will // cause activation of the input. That is, if we're a click event, or a // DOMActivate that was dispatched directly, this will be set, but if we're // a DOMActivate dispatched from click handling, it will not be set. WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent(); bool outerActivateEvent = ((mouseEvent && mouseEvent->IsLeftClickEvent()) || (aVisitor.mEvent->mMessage == eLegacyDOMActivate && !mInInternalActivate)); if (outerActivateEvent) { aVisitor.mItemFlags |= NS_OUTER_ACTIVATE_EVENT; if (mType == NS_FORM_BUTTON_SUBMIT && mForm) { aVisitor.mItemFlags |= NS_IN_SUBMIT_CLICK; // tell the form that we are about to enter a click handler. // that means that if there are scripted submissions, the // latest one will be deferred until after the exit point of the handler. mForm->OnSubmitClickBegin(this); } } return nsGenericHTMLElement::GetEventTargetParent(aVisitor); }
void HTMLTextAreaElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = false; if (IsDisabledForEvents(aVisitor.mEvent)) { return; } // Don't dispatch a second select event if we are already handling // one. if (aVisitor.mEvent->mMessage == eFormSelect) { if (mHandlingSelect) { return; } mHandlingSelect = true; } // If noContentDispatch 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 (aVisitor.mEvent->mMessage == eMouseClick && aVisitor.mEvent->AsMouseEvent()->button == WidgetMouseEvent::eMiddleButton) { aVisitor.mEvent->mFlags.mNoContentDispatch = false; } if (aVisitor.mEvent->mMessage == eBlur) { // Set mWantsPreHandleEvent and fire change event in PreHandleEvent to // prevent it breaks event target chain creation. aVisitor.mWantsPreHandleEvent = true; } nsGenericHTMLFormElementWithState::GetEventTargetParent(aVisitor); }
nsresult HTMLTextAreaElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = false; if (IsDisabledForEvents(aVisitor.mEvent->message)) { return NS_OK; } // Don't dispatch a second select event if we are already handling // one. if (aVisitor.mEvent->message == NS_FORM_SELECTED) { if (mHandlingSelect) { return NS_OK; } mHandlingSelect = true; } // If noContentDispatch 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 (aVisitor.mEvent->message == NS_MOUSE_CLICK && aVisitor.mEvent->eventStructType == NS_MOUSE_EVENT && static_cast<nsMouseEvent*>(aVisitor.mEvent)->button == nsMouseEvent::eMiddleButton) { aVisitor.mEvent->mFlags.mNoContentDispatch = false; } // Fire onchange (if necessary), before we do the blur, bug 370521. if (aVisitor.mEvent->message == NS_BLUR_CONTENT) { FireChangeEventIfNeeded(); } return nsGenericHTMLFormElement::PreHandleEvent(aVisitor); }
nsresult HTMLTextAreaElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.mCanHandle = false; if (IsDisabledForEvents(aVisitor.mEvent->mMessage)) { return NS_OK; } // Don't dispatch a second select event if we are already handling // one. if (aVisitor.mEvent->mMessage == eFormSelect) { if (mHandlingSelect) { return NS_OK; } mHandlingSelect = true; } // If noContentDispatch 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 (aVisitor.mEvent->mMessage == eMouseClick && aVisitor.mEvent->AsMouseEvent()->button == WidgetMouseEvent::eMiddleButton) { aVisitor.mEvent->mFlags.mNoContentDispatch = false; } // Fire onchange (if necessary), before we do the blur, bug 370521. if (aVisitor.mEvent->mMessage == eBlur) { FireChangeEventIfNeeded(); } return nsGenericHTMLFormElementWithState::PreHandleEvent(aVisitor); }