mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 813445 part.1 Make widget::EventFlags and remove NS_EVENT_FLAG_TRUSTED r=roc+smaug, feedback=emk
This commit is contained in:
parent
82531b0c6a
commit
c8090c380d
@ -1595,7 +1595,7 @@ Element::DispatchClickEvent(nsPresContext* aPresContext,
|
||||
NS_PRECONDITION(aSourceEvent, "Must have source event");
|
||||
NS_PRECONDITION(aStatus, "Null out param?");
|
||||
|
||||
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aSourceEvent), NS_MOUSE_CLICK,
|
||||
nsMouseEvent event(aSourceEvent->mFlags.mIsTrusted, NS_MOUSE_CLICK,
|
||||
aSourceEvent->widget, nsMouseEvent::eReal);
|
||||
event.refPoint = aSourceEvent->refPoint;
|
||||
uint32_t clickCount = 1;
|
||||
@ -2311,7 +2311,7 @@ Element::CheckHandleEventForLinksPrecondition(nsEventChainVisitor& aVisitor,
|
||||
nsIURI** aURI) const
|
||||
{
|
||||
if (aVisitor.mEventStatus == nsEventStatus_eConsumeNoDefault ||
|
||||
(!NS_IS_TRUSTED_EVENT(aVisitor.mEvent) &&
|
||||
(!aVisitor.mEvent->mFlags.mIsTrusted &&
|
||||
(aVisitor.mEvent->message != NS_MOUSE_CLICK) &&
|
||||
(aVisitor.mEvent->message != NS_KEY_PRESS) &&
|
||||
(aVisitor.mEvent->message != NS_UI_ACTIVATE)) ||
|
||||
@ -2446,7 +2446,7 @@ Element::PostHandleEventForLinks(nsEventChainPostVisitor& aVisitor)
|
||||
if (shell) {
|
||||
// single-click
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsUIEvent actEvent(NS_IS_TRUSTED_EVENT(aVisitor.mEvent),
|
||||
nsUIEvent actEvent(aVisitor.mEvent->mFlags.mIsTrusted,
|
||||
NS_UI_ACTIVATE, 1);
|
||||
|
||||
rv = shell->HandleDOMEventWithTarget(this, &actEvent, &status);
|
||||
@ -2463,7 +2463,8 @@ Element::PostHandleEventForLinks(nsEventChainPostVisitor& aVisitor)
|
||||
nsAutoString target;
|
||||
GetLinkTarget(target);
|
||||
nsContentUtils::TriggerLink(this, aVisitor.mPresContext, absURI, target,
|
||||
true, true, NS_IS_TRUSTED_EVENT(aVisitor.mEvent));
|
||||
true, true,
|
||||
aVisitor.mEvent->mFlags.mIsTrusted);
|
||||
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
}
|
||||
|
@ -5339,7 +5339,7 @@ nsContentUtils::GetDragSession()
|
||||
nsresult
|
||||
nsContentUtils::SetDataTransferInEvent(nsDragEvent* aDragEvent)
|
||||
{
|
||||
if (aDragEvent->dataTransfer || !NS_IS_TRUSTED_EVENT(aDragEvent))
|
||||
if (aDragEvent->dataTransfer || !aDragEvent->mFlags.mIsTrusted)
|
||||
return NS_OK;
|
||||
|
||||
// For draggesture and dragstart events, the data transfer object is
|
||||
|
@ -13,12 +13,11 @@
|
||||
nsAsyncDOMEvent::nsAsyncDOMEvent(nsINode *aEventNode, nsEvent &aEvent)
|
||||
: mEventNode(aEventNode), mDispatchChromeOnly(false)
|
||||
{
|
||||
bool trusted = NS_IS_TRUSTED_EVENT(&aEvent);
|
||||
nsEventDispatcher::CreateEvent(nullptr, &aEvent, EmptyString(),
|
||||
getter_AddRefs(mEvent));
|
||||
NS_ASSERTION(mEvent, "Should never fail to create an event");
|
||||
mEvent->DuplicatePrivateData();
|
||||
mEvent->SetTrusted(trusted);
|
||||
mEvent->SetTrusted(aEvent.mFlags.mIsTrusted);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAsyncDOMEvent::Run()
|
||||
|
@ -267,12 +267,7 @@ nsDOMEvent::GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget)
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::SetTrusted(bool aTrusted)
|
||||
{
|
||||
if (aTrusted) {
|
||||
mEvent->flags |= NS_EVENT_FLAG_TRUSTED;
|
||||
} else {
|
||||
mEvent->flags &= ~NS_EVENT_FLAG_TRUSTED;
|
||||
}
|
||||
|
||||
mEvent->mFlags.mIsTrusted = aTrusted;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -426,8 +421,7 @@ nsDOMEvent::PreventCapture()
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetIsTrusted(bool *aIsTrusted)
|
||||
{
|
||||
*aIsTrusted = NS_IS_TRUSTED_EVENT(mEvent);
|
||||
|
||||
*aIsTrusted = mEvent->mFlags.mIsTrusted;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -438,8 +432,7 @@ nsDOMEvent::PreventDefault()
|
||||
mEvent->flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
|
||||
// Need to set an extra flag for drag events.
|
||||
if (mEvent->eventStructType == NS_DRAG_EVENT &&
|
||||
NS_IS_TRUSTED_EVENT(mEvent)) {
|
||||
if (mEvent->eventStructType == NS_DRAG_EVENT && mEvent->mFlags.mIsTrusted) {
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(mEvent->currentTarget);
|
||||
if (!node) {
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(mEvent->currentTarget);
|
||||
@ -470,7 +463,7 @@ nsDOMEvent::InitEvent(const nsAString& aEventTypeArg, bool aCanBubbleArg, bool a
|
||||
// Make sure this event isn't already being dispatched.
|
||||
NS_ENSURE_TRUE(!NS_IS_EVENT_IN_DISPATCH(mEvent), NS_OK);
|
||||
|
||||
if (NS_IS_TRUSTED_EVENT(mEvent)) {
|
||||
if (mEvent->mFlags.mIsTrusted) {
|
||||
// Ensure the caller is permitted to dispatch trusted DOM events.
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
SetTrusted(false);
|
||||
@ -798,6 +791,7 @@ nsDOMEvent::DuplicatePrivateData()
|
||||
newEvent->currentTarget = mEvent->currentTarget;
|
||||
newEvent->originalTarget = mEvent->originalTarget;
|
||||
newEvent->flags = mEvent->flags;
|
||||
newEvent->mFlags = mEvent->mFlags;
|
||||
newEvent->time = mEvent->time;
|
||||
newEvent->refPoint = mEvent->refPoint;
|
||||
newEvent->userType = mEvent->userType;
|
||||
@ -934,7 +928,7 @@ nsDOMEvent::GetEventPopupControlState(nsEvent *aEvent)
|
||||
}
|
||||
break;
|
||||
case NS_KEY_EVENT :
|
||||
if (NS_IS_TRUSTED_EVENT(aEvent)) {
|
||||
if (aEvent->mFlags.mIsTrusted) {
|
||||
uint32_t key = static_cast<nsKeyEvent *>(aEvent)->keyCode;
|
||||
switch(aEvent->message) {
|
||||
case NS_KEY_PRESS :
|
||||
@ -959,7 +953,7 @@ nsDOMEvent::GetEventPopupControlState(nsEvent *aEvent)
|
||||
}
|
||||
break;
|
||||
case NS_MOUSE_EVENT :
|
||||
if (NS_IS_TRUSTED_EVENT(aEvent) &&
|
||||
if (aEvent->mFlags.mIsTrusted &&
|
||||
static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton) {
|
||||
switch(aEvent->message) {
|
||||
case NS_MOUSE_BUTTON_UP :
|
||||
|
@ -958,7 +958,7 @@ nsEventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
|
||||
if ((ls->mFlags & aFlags & ~NS_EVENT_FLAG_SYSTEM_EVENT) &&
|
||||
(ls->mFlags & NS_EVENT_FLAG_SYSTEM_EVENT) ==
|
||||
(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) &&
|
||||
(NS_IS_TRUSTED_EVENT(aEvent) ||
|
||||
(aEvent->mFlags.mIsTrusted ||
|
||||
ls->mFlags & NS_PRIV_EVENT_UNTRUSTED_PERMITTED)) {
|
||||
if (!*aDOMEvent) {
|
||||
nsEventDispatcher::CreateEvent(aPresContext, aEvent,
|
||||
|
@ -957,7 +957,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||
#endif
|
||||
// Store last known screenPoint and clientPoint so pointer lock
|
||||
// can use these values as constants.
|
||||
if (NS_IS_TRUSTED_EVENT(aEvent) &&
|
||||
if (aEvent->mFlags.mIsTrusted &&
|
||||
((NS_IS_MOUSE_EVENT_STRUCT(aEvent) &&
|
||||
IsMouseEventReal(aEvent)) ||
|
||||
aEvent->eventStructType == NS_WHEEL_EVENT)) {
|
||||
@ -969,7 +969,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||
|
||||
// Do not take account NS_MOUSE_ENTER/EXIT so that loading a page
|
||||
// when user is not active doesn't change the state to active.
|
||||
if (NS_IS_TRUSTED_EVENT(aEvent) &&
|
||||
if (aEvent->mFlags.mIsTrusted &&
|
||||
((aEvent->eventStructType == NS_MOUSE_EVENT &&
|
||||
IsMouseEventReal(aEvent) &&
|
||||
aEvent->message != NS_MOUSE_ENTER &&
|
||||
@ -1117,7 +1117,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||
break;
|
||||
case NS_WHEEL_WHEEL:
|
||||
{
|
||||
NS_ASSERTION(NS_IS_TRUSTED_EVENT(aEvent),
|
||||
NS_ASSERTION(aEvent->mFlags.mIsTrusted,
|
||||
"Untrusted wheel event shouldn't be here");
|
||||
|
||||
nsIContent* content = GetFocusedContent();
|
||||
@ -1243,7 +1243,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||
}
|
||||
break;
|
||||
case NS_COMPOSITION_START:
|
||||
if (NS_IS_TRUSTED_EVENT(aEvent)) {
|
||||
if (aEvent->mFlags.mIsTrusted) {
|
||||
// If the event is trusted event, set the selected text to data of
|
||||
// composition event.
|
||||
nsCompositionEvent *compositionEvent =
|
||||
@ -1437,10 +1437,9 @@ nsEventStateManager::HandleAccessKey(nsPresContext* aPresContext,
|
||||
if (mAccessKeys.Count() > 0 &&
|
||||
aModifierMask == GetAccessModifierMask(pcContainer)) {
|
||||
// Someone registered an accesskey. Find and activate it.
|
||||
bool isTrusted = NS_IS_TRUSTED_EVENT(aEvent);
|
||||
nsAutoTArray<uint32_t, 10> accessCharCodes;
|
||||
nsContentUtils::GetAccessKeyCandidates(aEvent, accessCharCodes);
|
||||
if (ExecuteAccessKey(accessCharCodes, isTrusted)) {
|
||||
if (ExecuteAccessKey(accessCharCodes, aEvent->mFlags.mIsTrusted)) {
|
||||
*aStatus = nsEventStatus_eConsumeNoDefault;
|
||||
return;
|
||||
}
|
||||
@ -1752,7 +1751,7 @@ nsEventStateManager::CreateClickHoldTimer(nsPresContext* inPresContext,
|
||||
nsIFrame* inDownFrame,
|
||||
nsGUIEvent* inMouseDownEvent)
|
||||
{
|
||||
if (!NS_IS_TRUSTED_EVENT(inMouseDownEvent))
|
||||
if (!inMouseDownEvent->mFlags.mIsTrusted)
|
||||
return;
|
||||
|
||||
// just to be anal (er, safe)
|
||||
@ -2105,10 +2104,12 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
|
||||
nsCOMPtr<nsIWidget> widget = mCurrentTarget->GetNearestWidget();
|
||||
|
||||
// get the widget from the target frame
|
||||
nsDragEvent startEvent(NS_IS_TRUSTED_EVENT(aEvent), NS_DRAGDROP_START, widget);
|
||||
nsDragEvent startEvent(aEvent->mFlags.mIsTrusted,
|
||||
NS_DRAGDROP_START, widget);
|
||||
FillInEventFromGestureDown(&startEvent);
|
||||
|
||||
nsDragEvent gestureEvent(NS_IS_TRUSTED_EVENT(aEvent), NS_DRAGDROP_GESTURE, widget);
|
||||
nsDragEvent gestureEvent(aEvent->mFlags.mIsTrusted,
|
||||
NS_DRAGDROP_GESTURE, widget);
|
||||
FillInEventFromGestureDown(&gestureEvent);
|
||||
|
||||
startEvent.dataTransfer = gestureEvent.dataTransfer = dataTransfer;
|
||||
@ -2654,7 +2655,7 @@ nsEventStateManager::SendLineScrollEvent(nsIFrame* aTargetFrame,
|
||||
targetContent = targetContent->GetParent();
|
||||
}
|
||||
|
||||
nsMouseScrollEvent event(NS_IS_TRUSTED_EVENT(aEvent), NS_MOUSE_SCROLL,
|
||||
nsMouseScrollEvent event(aEvent->mFlags.mIsTrusted, NS_MOUSE_SCROLL,
|
||||
aEvent->widget);
|
||||
if (*aStatus == nsEventStatus_eConsumeNoDefault) {
|
||||
event.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
@ -2690,7 +2691,7 @@ nsEventStateManager::SendPixelScrollEvent(nsIFrame* aTargetFrame,
|
||||
targetContent = targetContent->GetParent();
|
||||
}
|
||||
|
||||
nsMouseScrollEvent event(NS_IS_TRUSTED_EVENT(aEvent), NS_MOUSE_PIXEL_SCROLL,
|
||||
nsMouseScrollEvent event(aEvent->mFlags.mIsTrusted, NS_MOUSE_PIXEL_SCROLL,
|
||||
aEvent->widget);
|
||||
if (*aStatus == nsEventStatus_eConsumeNoDefault) {
|
||||
event.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
@ -3307,7 +3308,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
||||
break;
|
||||
case NS_WHEEL_WHEEL:
|
||||
{
|
||||
MOZ_ASSERT(NS_IS_TRUSTED_EVENT(aEvent));
|
||||
MOZ_ASSERT(aEvent->mFlags.mIsTrusted);
|
||||
|
||||
if (*aStatus == nsEventStatus_eConsumeNoDefault) {
|
||||
break;
|
||||
@ -3471,7 +3472,8 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
||||
getter_AddRefs(targetContent));
|
||||
|
||||
nsCOMPtr<nsIWidget> widget = mCurrentTarget->GetNearestWidget();
|
||||
nsDragEvent event(NS_IS_TRUSTED_EVENT(aEvent), NS_DRAGDROP_DRAGDROP, widget);
|
||||
nsDragEvent event(aEvent->mFlags.mIsTrusted,
|
||||
NS_DRAGDROP_DRAGDROP, widget);
|
||||
|
||||
nsMouseEvent* mouseEvent = static_cast<nsMouseEvent*>(aEvent);
|
||||
event.refPoint = mouseEvent->refPoint;
|
||||
@ -3906,7 +3908,7 @@ nsEventStateManager::DispatchMouseEvent(nsGUIEvent* aEvent, uint32_t aMessage,
|
||||
|
||||
SAMPLE_LABEL("Input", "DispatchMouseEvent");
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aEvent), aMessage, aEvent->widget,
|
||||
nsMouseEvent event(aEvent->mFlags.mIsTrusted, aMessage, aEvent->widget,
|
||||
nsMouseEvent::eReal);
|
||||
event.refPoint = aEvent->refPoint;
|
||||
event.modifiers = ((nsMouseEvent*)aEvent)->modifiers;
|
||||
@ -4368,7 +4370,7 @@ nsEventStateManager::FireDragEnterOrExit(nsPresContext* aPresContext,
|
||||
nsWeakFrame& aTargetFrame)
|
||||
{
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsDragEvent event(NS_IS_TRUSTED_EVENT(aEvent), aMsg, aEvent->widget);
|
||||
nsDragEvent event(aEvent->mFlags.mIsTrusted, aMsg, aEvent->widget);
|
||||
event.refPoint = aEvent->refPoint;
|
||||
event.modifiers = ((nsMouseEvent*)aEvent)->modifiers;
|
||||
event.buttons = ((nsMouseEvent*)aEvent)->buttons;
|
||||
@ -4522,8 +4524,8 @@ nsEventStateManager::CheckForAndDispatchClick(nsPresContext* aPresContext,
|
||||
sLeftClickOnly ? NS_EVENT_FLAG_NO_CONTENT_DISPATCH : NS_EVENT_FLAG_NONE;
|
||||
}
|
||||
|
||||
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aEvent), NS_MOUSE_CLICK, aEvent->widget,
|
||||
nsMouseEvent::eReal);
|
||||
nsMouseEvent event(aEvent->mFlags.mIsTrusted, NS_MOUSE_CLICK,
|
||||
aEvent->widget, nsMouseEvent::eReal);
|
||||
event.refPoint = aEvent->refPoint;
|
||||
event.clickCount = aEvent->clickCount;
|
||||
event.modifiers = aEvent->modifiers;
|
||||
@ -4541,7 +4543,7 @@ nsEventStateManager::CheckForAndDispatchClick(nsPresContext* aPresContext,
|
||||
mouseContent, aStatus);
|
||||
if (NS_SUCCEEDED(ret) && aEvent->clickCount == 2) {
|
||||
//fire double click
|
||||
nsMouseEvent event2(NS_IS_TRUSTED_EVENT(aEvent), NS_MOUSE_DOUBLECLICK,
|
||||
nsMouseEvent event2(aEvent->mFlags.mIsTrusted, NS_MOUSE_DOUBLECLICK,
|
||||
aEvent->widget, nsMouseEvent::eReal);
|
||||
event2.refPoint = aEvent->refPoint;
|
||||
event2.clickCount = aEvent->clickCount;
|
||||
|
@ -822,7 +822,7 @@ public:
|
||||
if (mIsMouseDown) {
|
||||
nsIPresShell::SetCapturingContent(nullptr, 0);
|
||||
nsIPresShell::AllowMouseCapture(true);
|
||||
if (aDocument && NS_IS_TRUSTED_EVENT(aEvent)) {
|
||||
if (aDocument && aEvent->mFlags.mIsTrusted) {
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm) {
|
||||
fm->SetMouseButtonDownHandlingDocument(aDocument);
|
||||
|
@ -549,7 +549,7 @@ nsIMEStateManager::DispatchCompositionEvent(nsINode* aEventTargetNode,
|
||||
{
|
||||
MOZ_ASSERT(aEvent->eventStructType == NS_COMPOSITION_EVENT ||
|
||||
aEvent->eventStructType == NS_TEXT_EVENT);
|
||||
if (!NS_IS_TRUSTED_EVENT(aEvent) ||
|
||||
if (!aEvent->mFlags.mIsTrusted ||
|
||||
(aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) != 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -3336,7 +3336,7 @@ nsGenericHTMLFormElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
nsresult
|
||||
nsGenericHTMLFormElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
||||
{
|
||||
if (NS_IS_TRUSTED_EVENT(aVisitor.mEvent)) {
|
||||
if (aVisitor.mEvent->mFlags.mIsTrusted) {
|
||||
switch (aVisitor.mEvent->message) {
|
||||
case NS_FOCUS_CONTENT:
|
||||
{
|
||||
|
@ -298,7 +298,7 @@ nsHTMLButtonElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
|
||||
if (aVisitor.mEventStatus != nsEventStatus_eConsumeNoDefault &&
|
||||
NS_IS_MOUSE_LEFT_CLICK(aVisitor.mEvent)) {
|
||||
nsUIEvent actEvent(NS_IS_TRUSTED_EVENT(aVisitor.mEvent), NS_UI_ACTIVATE, 1);
|
||||
nsUIEvent actEvent(aVisitor.mEvent->mFlags.mIsTrusted, NS_UI_ACTIVATE, 1);
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell = aVisitor.mPresContext->GetPresShell();
|
||||
if (shell) {
|
||||
@ -337,7 +337,7 @@ nsHTMLButtonElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
NS_KEY_UP == aVisitor.mEvent->message)) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
|
||||
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aVisitor.mEvent),
|
||||
nsMouseEvent event(aVisitor.mEvent->mFlags.mIsTrusted,
|
||||
NS_MOUSE_CLICK, nullptr,
|
||||
nsMouseEvent::eReal);
|
||||
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD;
|
||||
@ -354,7 +354,7 @@ nsHTMLButtonElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
if (aVisitor.mEvent->eventStructType == NS_MOUSE_EVENT) {
|
||||
if (static_cast<nsMouseEvent*>(aVisitor.mEvent)->button ==
|
||||
nsMouseEvent::eLeftButton) {
|
||||
if (NS_IS_TRUSTED_EVENT(aVisitor.mEvent)) {
|
||||
if (aVisitor.mEvent->mFlags.mIsTrusted) {
|
||||
nsEventStateManager* esm =
|
||||
aVisitor.mPresContext->EventStateManager();
|
||||
nsEventStateManager::SetActiveManager(
|
||||
|
@ -2250,7 +2250,7 @@ nsHTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
if (aVisitor.mEventStatus != nsEventStatus_eConsumeNoDefault &&
|
||||
!IsSingleLineTextControl(true) &&
|
||||
NS_IS_MOUSE_LEFT_CLICK(aVisitor.mEvent)) {
|
||||
nsUIEvent actEvent(NS_IS_TRUSTED_EVENT(aVisitor.mEvent), NS_UI_ACTIVATE, 1);
|
||||
nsUIEvent actEvent(aVisitor.mEvent->mFlags.mIsTrusted, NS_UI_ACTIVATE, 1);
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell = aVisitor.mPresContext->GetPresShell();
|
||||
if (shell) {
|
||||
@ -2392,7 +2392,7 @@ nsHTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
case NS_FORM_INPUT_SUBMIT:
|
||||
case NS_FORM_INPUT_IMAGE: // Bug 34418
|
||||
{
|
||||
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aVisitor.mEvent),
|
||||
nsMouseEvent event(aVisitor.mEvent->mFlags.mIsTrusted,
|
||||
NS_MOUSE_CLICK, nullptr, nsMouseEvent::eReal);
|
||||
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD;
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
@ -2429,7 +2429,7 @@ nsHTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
rv = selectedRadioButton->Focus();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aVisitor.mEvent),
|
||||
nsMouseEvent event(aVisitor.mEvent->mFlags.mIsTrusted,
|
||||
NS_MOUSE_CLICK, nullptr,
|
||||
nsMouseEvent::eReal);
|
||||
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD;
|
||||
|
@ -1155,7 +1155,7 @@ nsXULElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
||||
static_cast<nsInputEvent*>(aVisitor.mEvent);
|
||||
nsContentUtils::DispatchXULCommand(
|
||||
commandContent,
|
||||
NS_IS_TRUSTED_EVENT(aVisitor.mEvent),
|
||||
aVisitor.mEvent->mFlags.mIsTrusted,
|
||||
aVisitor.mDOMEvent,
|
||||
nullptr,
|
||||
orig->IsControl(),
|
||||
|
@ -2464,11 +2464,11 @@ nsGlobalWindow::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
||||
} else if (msg == NS_RESIZE_EVENT) {
|
||||
mIsHandlingResizeEvent = true;
|
||||
} else if (msg == NS_MOUSE_BUTTON_DOWN &&
|
||||
NS_IS_TRUSTED_EVENT(aVisitor.mEvent)) {
|
||||
aVisitor.mEvent->mFlags.mIsTrusted) {
|
||||
gMouseDown = true;
|
||||
} else if ((msg == NS_MOUSE_BUTTON_UP ||
|
||||
msg == NS_DRAGDROP_END) &&
|
||||
NS_IS_TRUSTED_EVENT(aVisitor.mEvent)) {
|
||||
aVisitor.mEvent->mFlags.mIsTrusted) {
|
||||
gMouseDown = false;
|
||||
if (gDragServiceDisabled) {
|
||||
nsCOMPtr<nsIDragService> ds =
|
||||
@ -2484,7 +2484,7 @@ nsGlobalWindow::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
||||
|
||||
// Handle 'active' event.
|
||||
if (!mIdleObservers.IsEmpty() &&
|
||||
NS_IS_TRUSTED_EVENT(aVisitor.mEvent) &&
|
||||
aVisitor.mEvent->mFlags.mIsTrusted &&
|
||||
(NS_IS_MOUSE_EVENT(aVisitor.mEvent) ||
|
||||
NS_IS_DRAG_EVENT(aVisitor.mEvent))) {
|
||||
mAddActiveEventFuzzTime = false;
|
||||
@ -2633,7 +2633,7 @@ nsGlobalWindow::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
if (aVisitor.mEvent->message == NS_RESIZE_EVENT) {
|
||||
mIsHandlingResizeEvent = false;
|
||||
} else if (aVisitor.mEvent->message == NS_PAGE_UNLOAD &&
|
||||
NS_IS_TRUSTED_EVENT(aVisitor.mEvent)) {
|
||||
aVisitor.mEvent->mFlags.mIsTrusted) {
|
||||
// Execute bindingdetached handlers before we tear ourselves
|
||||
// down.
|
||||
if (mDocument) {
|
||||
@ -2642,7 +2642,7 @@ nsGlobalWindow::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
}
|
||||
mIsDocumentLoaded = false;
|
||||
} else if (aVisitor.mEvent->message == NS_LOAD &&
|
||||
NS_IS_TRUSTED_EVENT(aVisitor.mEvent)) {
|
||||
aVisitor.mEvent->mFlags.mIsTrusted) {
|
||||
// This is page load event since load events don't propagate to |window|.
|
||||
// @see nsDocument::PreHandleEvent.
|
||||
mIsDocumentLoaded = true;
|
||||
@ -2663,7 +2663,7 @@ nsGlobalWindow::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
// onload event for the frame element.
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event(NS_IS_TRUSTED_EVENT(aVisitor.mEvent), NS_LOAD);
|
||||
nsEvent event(aVisitor.mEvent->mFlags.mIsTrusted, NS_LOAD);
|
||||
event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
|
||||
|
||||
// Most of the time we could get a pres context to pass in here,
|
||||
|
@ -1828,7 +1828,7 @@ nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
|
||||
nsEvent* theEvent = aFocusEvent->GetInternalNSEvent();
|
||||
if (theEvent) {
|
||||
// we only care about the message in ProcessEvent
|
||||
nsGUIEvent focusEvent(NS_IS_TRUSTED_EVENT(theEvent), theEvent->message,
|
||||
nsGUIEvent focusEvent(theEvent->mFlags.mIsTrusted, theEvent->message,
|
||||
nullptr);
|
||||
nsEventStatus rv = ProcessEvent(focusEvent);
|
||||
if (nsEventStatus_eConsumeNoDefault == rv) {
|
||||
@ -2002,7 +2002,7 @@ nsPluginInstanceOwner::HandleEvent(nsIDOMEvent* aEvent)
|
||||
nsCOMPtr<nsIDOMDragEvent> dragEvent(do_QueryInterface(aEvent));
|
||||
if (dragEvent && mInstance) {
|
||||
nsEvent* ievent = aEvent->GetInternalNSEvent();
|
||||
if ((ievent && NS_IS_TRUSTED_EVENT(ievent)) &&
|
||||
if ((ievent && ievent->mFlags.mIsTrusted) &&
|
||||
ievent->message != NS_DRAGDROP_ENTER && ievent->message != NS_DRAGDROP_OVER) {
|
||||
aEvent->PreventDefault();
|
||||
}
|
||||
|
@ -6371,7 +6371,7 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsEventStatus* aStatus)
|
||||
bool isHandlingUserInput = false;
|
||||
|
||||
// XXX How about IME events and input events for plugins?
|
||||
if (NS_IS_TRUSTED_EVENT(aEvent)) {
|
||||
if (aEvent->mFlags.mIsTrusted) {
|
||||
switch (aEvent->message) {
|
||||
case NS_KEY_PRESS:
|
||||
case NS_KEY_DOWN:
|
||||
@ -6517,7 +6517,7 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsEventStatus* aStatus)
|
||||
nsAutoHandlingUserInputStatePusher userInpStatePusher(isHandlingUserInput,
|
||||
aEvent, mDocument);
|
||||
|
||||
if (NS_IS_TRUSTED_EVENT(aEvent) && aEvent->message == NS_MOUSE_MOVE) {
|
||||
if (aEvent->mFlags.mIsTrusted && aEvent->message == NS_MOUSE_MOVE) {
|
||||
nsIPresShell::AllowMouseCapture(
|
||||
nsEventStateManager::GetActiveEventStateManager() == manager);
|
||||
}
|
||||
@ -6660,9 +6660,7 @@ PresShell::DispatchTouchEvent(nsEvent *aEvent,
|
||||
content = capturingContent;
|
||||
}
|
||||
// copy the event
|
||||
nsTouchEvent newEvent(NS_IS_TRUSTED_EVENT(touchEvent) ?
|
||||
true : false,
|
||||
touchEvent);
|
||||
nsTouchEvent newEvent(touchEvent->mFlags.mIsTrusted, touchEvent);
|
||||
newEvent.target = targetPtr;
|
||||
|
||||
nsRefPtr<PresShell> contentPresShell;
|
||||
|
@ -560,7 +560,7 @@ protected:
|
||||
public:
|
||||
nsDelayedMouseEvent(nsMouseEvent* aEvent) : nsDelayedInputEvent()
|
||||
{
|
||||
mEvent = new nsMouseEvent(NS_IS_TRUSTED_EVENT(aEvent),
|
||||
mEvent = new nsMouseEvent(aEvent->mFlags.mIsTrusted,
|
||||
aEvent->message,
|
||||
aEvent->widget,
|
||||
aEvent->reason,
|
||||
@ -580,7 +580,7 @@ protected:
|
||||
public:
|
||||
nsDelayedKeyEvent(nsKeyEvent* aEvent) : nsDelayedInputEvent()
|
||||
{
|
||||
mEvent = new nsKeyEvent(NS_IS_TRUSTED_EVENT(aEvent),
|
||||
mEvent = new nsKeyEvent(aEvent->mFlags.mIsTrusted,
|
||||
aEvent->message,
|
||||
aEvent->widget);
|
||||
Init(aEvent);
|
||||
|
@ -136,7 +136,7 @@ nsButtonBoxFrame::DoMouseClick(nsGUIEvent* aEvent, bool aTrustEvent)
|
||||
if (shell) {
|
||||
nsContentUtils::DispatchXULCommand(mContent,
|
||||
aEvent ?
|
||||
NS_IS_TRUSTED_EVENT(aEvent) : aTrustEvent,
|
||||
aEvent->mFlags.mIsTrusted : aTrustEvent,
|
||||
nullptr, shell,
|
||||
isControl, isAlt, isShift, isMeta);
|
||||
}
|
||||
|
@ -1226,7 +1226,7 @@ nsMenuFrame::CreateMenuCommandEvent(nsGUIEvent *aEvent, bool aFlipChecked)
|
||||
// Create a trusted event if the triggering event was trusted, or if
|
||||
// we're called from chrome code (since at least one of our caller
|
||||
// passes in a null event).
|
||||
bool isTrusted = aEvent ? NS_IS_TRUSTED_EVENT(aEvent) :
|
||||
bool isTrusted = aEvent ? aEvent->mFlags.mIsTrusted :
|
||||
nsContentUtils::IsCallerChrome();
|
||||
|
||||
bool shift = false, control = false, alt = false, meta = false;
|
||||
|
@ -545,6 +545,5 @@ nsResizerFrame::MouseClicked(nsPresContext* aPresContext, nsGUIEvent *aEvent)
|
||||
{
|
||||
// Execute the oncommand event handler.
|
||||
nsContentUtils::DispatchXULCommand(mContent,
|
||||
aEvent ?
|
||||
NS_IS_TRUSTED_EVENT(aEvent) : false);
|
||||
aEvent && aEvent->mFlags.mIsTrusted);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ nsAutoRepeatBoxFrame::HandleEvent(nsPresContext* aPresContext,
|
||||
case NS_MOUSE_ENTER_SYNTH:
|
||||
if (IsActivatedOnHover()) {
|
||||
StartRepeat();
|
||||
mTrustedEvent = NS_IS_TRUSTED_EVENT(aEvent);
|
||||
mTrustedEvent = aEvent->mFlags.mIsTrusted;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -119,7 +119,7 @@ nsAutoRepeatBoxFrame::HandlePress(nsPresContext* aPresContext,
|
||||
{
|
||||
if (!IsActivatedOnHover()) {
|
||||
StartRepeat();
|
||||
mTrustedEvent = NS_IS_TRUSTED_EVENT(aEvent);
|
||||
mTrustedEvent = aEvent->mFlags.mIsTrusted;
|
||||
DoMouseClick(aEvent, mTrustedEvent);
|
||||
}
|
||||
|
||||
|
@ -172,6 +172,5 @@ nsTitleBarFrame::MouseClicked(nsPresContext* aPresContext, nsGUIEvent* aEvent)
|
||||
{
|
||||
// Execute the oncommand event handler.
|
||||
nsContentUtils::DispatchXULCommand(mContent,
|
||||
aEvent ?
|
||||
NS_IS_TRUSTED_EVENT(aEvent) : false);
|
||||
aEvent && aEvent->mFlags.mIsTrusted);
|
||||
}
|
||||
|
@ -78,6 +78,8 @@ class nsPluginEvent;
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
struct EventFlags;
|
||||
|
||||
class WheelEvent;
|
||||
|
||||
// All modifier keys should be defined here. This is used for managing
|
||||
|
@ -109,7 +109,6 @@ enum nsEventStructType {
|
||||
// listener flags and event flags, but only some of them. You've been
|
||||
// warned!
|
||||
#define NS_EVENT_FLAG_NONE 0x0000
|
||||
#define NS_EVENT_FLAG_TRUSTED 0x0001
|
||||
#define NS_EVENT_FLAG_BUBBLE 0x0002
|
||||
#define NS_EVENT_FLAG_CAPTURE 0x0004
|
||||
#define NS_EVENT_FLAG_STOP_DISPATCH 0x0008
|
||||
@ -510,6 +509,50 @@ enum nsWindowZ {
|
||||
nsWindowZRelative // just below some specified widget
|
||||
};
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
struct EventFlags
|
||||
{
|
||||
public:
|
||||
// If mIsTrusted is true, the event is a trusted event. Otherwise, it's
|
||||
// an untrusted event.
|
||||
bool mIsTrusted : 1;
|
||||
|
||||
EventFlags()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
inline void Clear()
|
||||
{
|
||||
SetRawFlags(0);
|
||||
}
|
||||
inline EventFlags operator|(const EventFlags& aOther) const
|
||||
{
|
||||
EventFlags flags;
|
||||
flags.SetRawFlags(GetRawFlags() | aOther.GetRawFlags());
|
||||
return flags;
|
||||
}
|
||||
inline EventFlags& operator|=(const EventFlags& aOther)
|
||||
{
|
||||
SetRawFlags(GetRawFlags() | aOther.GetRawFlags());
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
inline void SetRawFlags(uint32_t aRawFlags)
|
||||
{
|
||||
memcpy(this, &aRawFlags, sizeof(EventFlags));
|
||||
}
|
||||
inline uint32_t GetRawFlags() const
|
||||
{
|
||||
uint32_t result = 0;
|
||||
memcpy(&result, this, sizeof(EventFlags));
|
||||
return result;
|
||||
}
|
||||
};
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
||||
/**
|
||||
* General event
|
||||
*/
|
||||
@ -523,10 +566,11 @@ protected:
|
||||
refPoint(0, 0),
|
||||
lastRefPoint(0, 0),
|
||||
time(0),
|
||||
flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
|
||||
flags(NS_EVENT_FLAG_NONE),
|
||||
userType(0)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsEvent);
|
||||
mFlags.mIsTrusted = isTrusted;
|
||||
}
|
||||
|
||||
nsEvent()
|
||||
@ -541,10 +585,11 @@ public:
|
||||
refPoint(0, 0),
|
||||
lastRefPoint(0, 0),
|
||||
time(0),
|
||||
flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
|
||||
flags(NS_EVENT_FLAG_NONE),
|
||||
userType(0)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsEvent);
|
||||
mFlags.mIsTrusted = isTrusted;
|
||||
}
|
||||
|
||||
~nsEvent()
|
||||
@ -573,6 +618,10 @@ public:
|
||||
// Flags to hold event flow stage and capture/bubble cancellation
|
||||
// status. This is used also to indicate whether the event is trusted.
|
||||
uint32_t flags;
|
||||
|
||||
// See EventFlags definition for the detail.
|
||||
mozilla::widget::EventFlags mFlags;
|
||||
|
||||
// Additional type info for user defined events
|
||||
nsCOMPtr<nsIAtom> userType;
|
||||
// Event targets, needed by DOM Events
|
||||
@ -1592,7 +1641,7 @@ public:
|
||||
}
|
||||
|
||||
nsSimpleGestureEvent(const nsSimpleGestureEvent& other)
|
||||
: nsMouseEvent_base((other.flags & NS_EVENT_FLAG_TRUSTED) != 0,
|
||||
: nsMouseEvent_base(other.mFlags.mIsTrusted,
|
||||
other.message, other.widget, NS_SIMPLE_GESTURE_EVENT),
|
||||
direction(other.direction), delta(other.delta), clickCount(0)
|
||||
{
|
||||
@ -1747,9 +1796,6 @@ enum nsDragDropEventStatus {
|
||||
(NS_IS_PLUGIN_EVENT(evnt) && \
|
||||
!(static_cast<nsPluginEvent*>(evnt)->retargetToFocusedDocument))
|
||||
|
||||
#define NS_IS_TRUSTED_EVENT(event) \
|
||||
(((event)->flags & NS_EVENT_FLAG_TRUSTED) != 0)
|
||||
|
||||
// Mark an event as being dispatching.
|
||||
#define NS_MARK_EVENT_DISPATCH_STARTED(event) \
|
||||
(event)->flags |= NS_EVENT_FLAG_DISPATCHING;
|
||||
|
@ -13,6 +13,23 @@
|
||||
namespace IPC
|
||||
{
|
||||
|
||||
template<>
|
||||
struct ParamTraits<mozilla::widget::EventFlags>
|
||||
{
|
||||
typedef mozilla::widget::EventFlags paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
aMsg->WriteBytes(&aParam, sizeof(paramType));
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
{
|
||||
return aMsg->ReadBytes(aIter, reinterpret_cast<const char**>(aResult),
|
||||
sizeof(paramType));
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<nsEvent>
|
||||
{
|
||||
@ -25,6 +42,7 @@ struct ParamTraits<nsEvent>
|
||||
WriteParam(aMsg, aParam.refPoint);
|
||||
WriteParam(aMsg, aParam.time);
|
||||
WriteParam(aMsg, aParam.flags);
|
||||
WriteParam(aMsg, aParam.mFlags);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
@ -34,7 +52,8 @@ struct ParamTraits<nsEvent>
|
||||
ReadParam(aMsg, aIter, &aResult->message) &&
|
||||
ReadParam(aMsg, aIter, &aResult->refPoint) &&
|
||||
ReadParam(aMsg, aIter, &aResult->time) &&
|
||||
ReadParam(aMsg, aIter, &aResult->flags);
|
||||
ReadParam(aMsg, aIter, &aResult->flags) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mFlags);
|
||||
aResult->eventStructType = static_cast<nsEventStructType>(eventStructType);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user