Bug 1256589 part.6 Move the implementation of IsTrusted() from dom::Event to WidgetEvent r=smaug

MozReview-Commit-ID: 1SgMbTL8csl

--HG--
extra : rebase_source : 748fa8a594176edf7b2addd038b8031019d0dd35
extra : source : f4ce36e68ce06c405a6fab31facc120b94709aed
This commit is contained in:
Masayuki Nakano 2016-03-17 16:01:30 +09:00
Родитель 8c8cbe0e4c
Коммит cea0b9cf02
27 изменённых файлов: 81 добавлений и 82 удалений

Просмотреть файл

@ -2083,7 +2083,7 @@ Element::DispatchClickEvent(nsPresContext* aPresContext,
NS_PRECONDITION(aSourceEvent, "Must have source event");
NS_PRECONDITION(aStatus, "Null out param?");
WidgetMouseEvent event(aSourceEvent->mFlags.mIsTrusted, eMouseClick,
WidgetMouseEvent event(aSourceEvent->IsTrusted(), eMouseClick,
aSourceEvent->widget, WidgetMouseEvent::eReal);
event.refPoint = aSourceEvent->refPoint;
uint32_t clickCount = 1;
@ -2878,7 +2878,7 @@ Element::CheckHandleEventForLinksPrecondition(EventChainVisitor& aVisitor,
nsIURI** aURI) const
{
if (aVisitor.mEventStatus == nsEventStatus_eConsumeNoDefault ||
(!aVisitor.mEvent->mFlags.mIsTrusted &&
(!aVisitor.mEvent->IsTrusted() &&
(aVisitor.mEvent->mMessage != eMouseClick) &&
(aVisitor.mEvent->mMessage != eKeyPress) &&
(aVisitor.mEvent->mMessage != eLegacyDOMActivate)) ||

Просмотреть файл

@ -5227,8 +5227,9 @@ nsContentUtils::GetDragSession()
nsresult
nsContentUtils::SetDataTransferInEvent(WidgetDragEvent* aDragEvent)
{
if (aDragEvent->dataTransfer || !aDragEvent->mFlags.mIsTrusted)
if (aDragEvent->dataTransfer || !aDragEvent->IsTrusted()) {
return NS_OK;
}
// For draggesture and dragstart events, the data transfer object is
// created before the event fires, so it should already be set. For other

Просмотреть файл

@ -3119,7 +3119,7 @@ nsGlobalWindow::PreHandleEvent(EventChainPreVisitor& aVisitor)
gEntropyCollector->RandomUpdate((void*)&(aVisitor.mEvent->time),
sizeof(uint32_t));
}
} else if (msg == eResize && aVisitor.mEvent->mFlags.mIsTrusted) {
} else if (msg == eResize && aVisitor.mEvent->IsTrusted()) {
// QIing to window so that we can keep the old behavior also in case
// a child window is handling resize.
nsCOMPtr<nsPIDOMWindowInner> window =
@ -3127,10 +3127,10 @@ nsGlobalWindow::PreHandleEvent(EventChainPreVisitor& aVisitor)
if (window) {
mIsHandlingResizeEvent = true;
}
} else if (msg == eMouseDown && aVisitor.mEvent->mFlags.mIsTrusted) {
} else if (msg == eMouseDown && aVisitor.mEvent->IsTrusted()) {
gMouseDown = true;
} else if ((msg == eMouseUp || msg == eDragEnd) &&
aVisitor.mEvent->mFlags.mIsTrusted) {
aVisitor.mEvent->IsTrusted()) {
gMouseDown = false;
if (gDragServiceDisabled) {
nsCOMPtr<nsIDragService> ds =
@ -3146,7 +3146,7 @@ nsGlobalWindow::PreHandleEvent(EventChainPreVisitor& aVisitor)
// Handle 'active' event.
if (!mIdleObservers.IsEmpty() &&
aVisitor.mEvent->mFlags.mIsTrusted &&
aVisitor.mEvent->IsTrusted() &&
(aVisitor.mEvent->HasMouseEventMessage() ||
aVisitor.mEvent->HasDragEventMessage())) {
mAddActiveEventFuzzTime = false;
@ -3324,7 +3324,7 @@ nsGlobalWindow::PostHandleEvent(EventChainPostVisitor& aVisitor)
if (aVisitor.mEvent->mMessage == eResize) {
mIsHandlingResizeEvent = false;
} else if (aVisitor.mEvent->mMessage == eUnload &&
aVisitor.mEvent->mFlags.mIsTrusted) {
aVisitor.mEvent->IsTrusted()) {
// Execute bindingdetached handlers before we tear ourselves
// down.
if (mDoc) {
@ -3332,7 +3332,7 @@ nsGlobalWindow::PostHandleEvent(EventChainPostVisitor& aVisitor)
}
mIsDocumentLoaded = false;
} else if (aVisitor.mEvent->mMessage == eLoad &&
aVisitor.mEvent->mFlags.mIsTrusted) {
aVisitor.mEvent->IsTrusted()) {
// This is page load event since load events don't propagate to |window|.
// @see nsDocument::PreHandleEvent.
mIsDocumentLoaded = true;
@ -3345,7 +3345,7 @@ nsGlobalWindow::PostHandleEvent(EventChainPostVisitor& aVisitor)
// onload event for the frame element.
nsEventStatus status = nsEventStatus_eIgnore;
WidgetEvent event(aVisitor.mEvent->mFlags.mIsTrusted, eLoad);
WidgetEvent event(aVisitor.mEvent->IsTrusted(), eLoad);
event.mFlags.mBubbles = false;
// Most of the time we could get a pres context to pass in here,

Просмотреть файл

@ -30,7 +30,7 @@ AsyncEventDispatcher::AsyncEventDispatcher(EventTarget* aTarget,
mEvent = do_QueryInterface(event);
NS_ASSERTION(mEvent, "Should never fail to create an event");
mEvent->DuplicatePrivateData();
mEvent->SetTrusted(aEvent.mFlags.mIsTrusted);
mEvent->SetTrusted(aEvent.IsTrusted());
}
NS_IMETHODIMP

Просмотреть файл

@ -743,7 +743,7 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent)
}
break;
case eKeyboardEventClass:
if (aEvent->mFlags.mIsTrusted) {
if (aEvent->IsTrusted()) {
uint32_t key = aEvent->AsKeyboardEvent()->keyCode;
switch(aEvent->mMessage) {
case eKeyPress:
@ -773,7 +773,7 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent)
}
break;
case eTouchEventClass:
if (aEvent->mFlags.mIsTrusted) {
if (aEvent->IsTrusted()) {
switch (aEvent->mMessage) {
case eTouchStart:
if (PopupAllowedForEvent("touchstart")) {
@ -791,7 +791,7 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent)
}
break;
case eMouseEventClass:
if (aEvent->mFlags.mIsTrusted &&
if (aEvent->IsTrusted() &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
switch(aEvent->mMessage) {
case eMouseUp:

Просмотреть файл

@ -197,7 +197,7 @@ public:
bool IsTrusted() const
{
return mEvent->mFlags.mIsTrusted;
return mEvent->IsTrusted();
}
bool IsSynthesized() const

Просмотреть файл

@ -1222,8 +1222,7 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
hasListenerForCurrentGroup = hasListenerForCurrentGroup ||
listener->mFlags.mInSystemGroup == aEvent->mFlags.mInSystemGroup;
if (listener->IsListening(aEvent) &&
(aEvent->mFlags.mIsTrusted ||
listener->mFlags.mAllowUntrustedEvents)) {
(aEvent->IsTrusted() || listener->mFlags.mAllowUntrustedEvents)) {
if (!*aDOMEvent) {
// This is tiny bit slow, but happens only once per event.
nsCOMPtr<EventTarget> et =

Просмотреть файл

@ -528,7 +528,7 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
// Do not take account eMouseEnterIntoWidget/ExitFromWidget so that loading
// a page when user is not active doesn't change the state to active.
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (aEvent->mFlags.mIsTrusted &&
if (aEvent->IsTrusted() &&
((mouseEvent && mouseEvent->IsReal() &&
IsMessageMouseUserActivity(mouseEvent->mMessage)) ||
aEvent->mClass == eWheelEventClass ||
@ -576,7 +576,7 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
#endif
// Store last known screenPoint and clientPoint so pointer lock
// can use these values as constants.
if (aEvent->mFlags.mIsTrusted &&
if (aEvent->IsTrusted() &&
((mouseEvent && mouseEvent->IsReal()) ||
aEvent->mClass == eWheelEventClass) &&
!sIsPointerLocked) {
@ -736,7 +736,7 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
keyEvent->GetAccessKeyCandidates(accessCharCodes);
if (HandleAccessKey(aPresContext, accessCharCodes,
keyEvent->mFlags.mIsTrusted, modifierMask)) {
keyEvent->IsTrusted(), modifierMask)) {
*aStatus = nsEventStatus_eConsumeNoDefault;
}
}
@ -771,7 +771,7 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
case eWheelOperationStart:
case eWheelOperationEnd:
{
NS_ASSERTION(aEvent->mFlags.mIsTrusted,
NS_ASSERTION(aEvent->IsTrusted(),
"Untrusted wheel event shouldn't be here");
nsIContent* content = GetFocusedContent();
@ -816,7 +816,7 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
DoContentCommandScrollEvent(aEvent->AsContentCommandEvent());
break;
case eCompositionStart:
if (aEvent->mFlags.mIsTrusted) {
if (aEvent->IsTrusted()) {
// If the event is trusted event, set the selected text to data of
// composition event.
WidgetCompositionEvent* compositionEvent = aEvent->AsCompositionEvent();
@ -1376,7 +1376,7 @@ EventStateManager::CreateClickHoldTimer(nsPresContext* inPresContext,
nsIFrame* inDownFrame,
WidgetGUIEvent* inMouseDownEvent)
{
if (!inMouseDownEvent->mFlags.mIsTrusted ||
if (!inMouseDownEvent->IsTrusted() ||
IsRemoteTarget(mGestureDownContent) ||
sIsPointerLocked) {
return;
@ -1734,11 +1734,10 @@ EventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
nsCOMPtr<nsIWidget> widget = mCurrentTarget->GetNearestWidget();
// get the widget from the target frame
WidgetDragEvent startEvent(aEvent->mFlags.mIsTrusted,
eDragStart, widget);
WidgetDragEvent startEvent(aEvent->IsTrusted(), eDragStart, widget);
FillInEventFromGestureDown(&startEvent);
WidgetDragEvent gestureEvent(aEvent->mFlags.mIsTrusted,
WidgetDragEvent gestureEvent(aEvent->IsTrusted(),
eLegacyDragGesture, widget);
FillInEventFromGestureDown(&gestureEvent);
@ -2293,7 +2292,7 @@ EventStateManager::SendLineScrollEvent(nsIFrame* aTargetFrame,
targetContent = targetContent->GetParent();
}
WidgetMouseScrollEvent event(aEvent->mFlags.mIsTrusted,
WidgetMouseScrollEvent event(aEvent->IsTrusted(),
eLegacyMouseLineOrPageScroll, aEvent->widget);
event.mFlags.mDefaultPrevented = aState.mDefaultPrevented;
event.mFlags.mDefaultPreventedByContent = aState.mDefaultPreventedByContent;
@ -2333,7 +2332,7 @@ EventStateManager::SendPixelScrollEvent(nsIFrame* aTargetFrame,
targetContent = targetContent->GetParent();
}
WidgetMouseScrollEvent event(aEvent->mFlags.mIsTrusted,
WidgetMouseScrollEvent event(aEvent->IsTrusted(),
eLegacyMousePixelScroll, aEvent->widget);
event.mFlags.mDefaultPrevented = aState.mDefaultPrevented;
event.mFlags.mDefaultPreventedByContent = aState.mDefaultPreventedByContent;
@ -3134,7 +3133,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
break;
case eWheelOperationEnd:
{
MOZ_ASSERT(aEvent->mFlags.mIsTrusted);
MOZ_ASSERT(aEvent->IsTrusted());
ScrollbarsForWheel::MayInactivate();
WidgetWheelEvent* wheelEvent = aEvent->AsWheelEvent();
nsIScrollableFrame* scrollTarget =
@ -3148,7 +3147,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
case eWheel:
case eWheelOperationStart:
{
MOZ_ASSERT(aEvent->mFlags.mIsTrusted);
MOZ_ASSERT(aEvent->IsTrusted());
if (*aStatus == nsEventStatus_eConsumeNoDefault) {
ScrollbarsForWheel::Inactivate();
@ -3427,8 +3426,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
getter_AddRefs(targetContent));
nsCOMPtr<nsIWidget> widget = mCurrentTarget->GetNearestWidget();
WidgetDragEvent event(aEvent->mFlags.mIsTrusted,
eLegacyDragDrop, widget);
WidgetDragEvent event(aEvent->IsTrusted(), eLegacyDragDrop, widget);
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
event.refPoint = mouseEvent->refPoint;
@ -3854,7 +3852,7 @@ CreateMouseOrPointerWidgetEvent(WidgetMouseEvent* aMouseEvent,
nsAutoPtr<WidgetPointerEvent> newPointerEvent;
newPointerEvent =
new WidgetPointerEvent(aMouseEvent->mFlags.mIsTrusted, aMessage,
new WidgetPointerEvent(aMouseEvent->IsTrusted(), aMessage,
aMouseEvent->widget);
newPointerEvent->isPrimary = sourcePointer->isPrimary;
newPointerEvent->pointerId = sourcePointer->pointerId;
@ -3868,7 +3866,7 @@ CreateMouseOrPointerWidgetEvent(WidgetMouseEvent* aMouseEvent,
aNewEvent = newPointerEvent.forget();
} else {
aNewEvent =
new WidgetMouseEvent(aMouseEvent->mFlags.mIsTrusted, aMessage,
new WidgetMouseEvent(aMouseEvent->IsTrusted(), aMessage,
aMouseEvent->widget, WidgetMouseEvent::eReal);
aNewEvent->relatedTarget = aRelatedContent;
}
@ -4480,8 +4478,7 @@ EventStateManager::FireDragEnterOrExit(nsPresContext* aPresContext,
nsWeakFrame& aTargetFrame)
{
nsEventStatus status = nsEventStatus_eIgnore;
WidgetDragEvent event(aDragEvent->mFlags.mIsTrusted, aMessage,
aDragEvent->widget);
WidgetDragEvent event(aDragEvent->IsTrusted(), aMessage, aDragEvent->widget);
event.refPoint = aDragEvent->refPoint;
event.modifiers = aDragEvent->modifiers;
event.buttons = aDragEvent->buttons;
@ -4635,7 +4632,7 @@ EventStateManager::CheckForAndDispatchClick(WidgetMouseEvent* aEvent,
(aEvent->button == WidgetMouseEvent::eMiddleButton ||
aEvent->button == WidgetMouseEvent::eRightButton);
WidgetMouseEvent event(aEvent->mFlags.mIsTrusted, eMouseClick,
WidgetMouseEvent event(aEvent->IsTrusted(), eMouseClick,
aEvent->widget, WidgetMouseEvent::eReal);
event.refPoint = aEvent->refPoint;
event.clickCount = aEvent->clickCount;
@ -4669,7 +4666,7 @@ EventStateManager::CheckForAndDispatchClick(WidgetMouseEvent* aEvent,
if (NS_SUCCEEDED(ret) && aEvent->clickCount == 2 &&
mouseContent && mouseContent->IsInComposedDoc()) {
//fire double click
WidgetMouseEvent event2(aEvent->mFlags.mIsTrusted, eMouseDoubleClick,
WidgetMouseEvent event2(aEvent->IsTrusted(), eMouseDoubleClick,
aEvent->widget, WidgetMouseEvent::eReal);
event2.refPoint = aEvent->refPoint;
event2.clickCount = aEvent->clickCount;
@ -5897,7 +5894,7 @@ AutoHandlingUserInputStatePusher::AutoHandlingUserInputStatePusher(
nsIPresShell::SetCapturingContent(nullptr, 0);
nsIPresShell::AllowMouseCapture(true);
}
if (!aDocument || !aEvent || !aEvent->mFlags.mIsTrusted) {
if (!aDocument || !aEvent || !aEvent->IsTrusted()) {
return;
}
mResetFMMouseButtonHandlingState =

Просмотреть файл

@ -756,7 +756,7 @@ IMEContentObserver::OnMouseButtonEvent(nsPresContext* aPresContext,
if (!mUpdatePreference.WantMouseButtonEventOnChar()) {
return false;
}
if (!aMouseEvent->mFlags.mIsTrusted ||
if (!aMouseEvent->IsTrusted() ||
aMouseEvent->DefaultPrevented() ||
!aMouseEvent->widget) {
return false;

Просмотреть файл

@ -1164,7 +1164,7 @@ IMEStateManager::DispatchCompositionEvent(
GetBoolName(aCompositionEvent->mFlags.mPropagationStopped),
GetBoolName(aIsSynthesized), tabParent.get()));
if (!aCompositionEvent->mFlags.mIsTrusted ||
if (!aCompositionEvent->IsTrusted() ||
aCompositionEvent->mFlags.mPropagationStopped) {
return;
}
@ -1261,7 +1261,7 @@ IMEStateManager::HandleSelectionEvent(nsPresContext* aPresContext,
GetBoolName(aSelectionEvent->mFlags.mIsTrusted),
tabParent.get()));
if (!aSelectionEvent->mFlags.mIsTrusted) {
if (!aSelectionEvent->IsTrusted()) {
return;
}
@ -1303,7 +1303,7 @@ IMEStateManager::OnCompositionEventDiscarded(
GetBoolName(aCompositionEvent->widget->Destroyed()),
GetBoolName(aCompositionEvent->mFlags.mIsTrusted)));
if (!aCompositionEvent->mFlags.mIsTrusted) {
if (!aCompositionEvent->IsTrusted()) {
return;
}

Просмотреть файл

@ -118,7 +118,7 @@ TextComposition::CloneAndDispatchAs(
MOZ_ASSERT(IsValidStateForComposition(aCompositionEvent->widget),
"Should be called only when it's safe to dispatch an event");
WidgetCompositionEvent compositionEvent(aCompositionEvent->mFlags.mIsTrusted,
WidgetCompositionEvent compositionEvent(aCompositionEvent->IsTrusted(),
aMessage, aCompositionEvent->widget);
compositionEvent.time = aCompositionEvent->time;
compositionEvent.timeStamp = aCompositionEvent->timeStamp;
@ -159,7 +159,7 @@ TextComposition::OnCompositionEventDiscarded(
// Note that this method is never called for synthesized events for emulating
// commit or cancel composition.
MOZ_ASSERT(aCompositionEvent->mFlags.mIsTrusted,
MOZ_ASSERT(aCompositionEvent->IsTrusted(),
"Shouldn't be called with untrusted event");
if (mTabParent) {

Просмотреть файл

@ -292,7 +292,7 @@ HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
eKeyPress == aVisitor.mEvent->mMessage) ||
(keyEvent->keyCode == NS_VK_SPACE &&
eKeyUp == aVisitor.mEvent->mMessage)) {
DispatchSimulatedClick(this, aVisitor.mEvent->mFlags.mIsTrusted,
DispatchSimulatedClick(this, aVisitor.mEvent->IsTrusted(),
aVisitor.mPresContext);
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
}
@ -303,7 +303,7 @@ HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
if (mouseEvent->button == WidgetMouseEvent::eLeftButton) {
if (mouseEvent->mFlags.mIsTrusted) {
if (mouseEvent->IsTrusted()) {
EventStateManager* esm =
aVisitor.mPresContext->EventStateManager();
EventStateManager::SetActiveManager(

Просмотреть файл

@ -3338,8 +3338,7 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
}
}
if (mType == NS_FORM_INPUT_NUMBER &&
aVisitor.mEvent->mFlags.mIsTrusted) {
if (mType == NS_FORM_INPUT_NUMBER && aVisitor.mEvent->IsTrusted()) {
if (mNumberControlSpinnerIsSpinning) {
// If the timer is running the user has depressed the mouse on one of the
// spin buttons. If the mouse exits the button we either want to reverse
@ -3424,7 +3423,7 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
// We do this after calling the base class' PreHandleEvent so that
// nsIContent::PreHandleEvent doesn't reset any change we make to mCanHandle.
if (mType == NS_FORM_INPUT_NUMBER &&
aVisitor.mEvent->mFlags.mIsTrusted &&
aVisitor.mEvent->IsTrusted() &&
aVisitor.mEvent->originalTarget != this) {
// <input type=number> has an anonymous <input type=text> descendant. If
// 'input' or 'change' events are fired at that text control then we need
@ -3873,7 +3872,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
WidgetKeyboardEvent* keyEvent = aVisitor.mEvent->AsKeyboardEvent();
if (mType == NS_FORM_INPUT_NUMBER &&
keyEvent && keyEvent->mMessage == eKeyPress &&
aVisitor.mEvent->mFlags.mIsTrusted &&
aVisitor.mEvent->IsTrusted() &&
(keyEvent->keyCode == NS_VK_UP || keyEvent->keyCode == NS_VK_DOWN) &&
!(keyEvent->IsShift() || keyEvent->IsControl() ||
keyEvent->IsAlt() || keyEvent->IsMeta() ||
@ -3951,7 +3950,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
case NS_FORM_INPUT_IMAGE: // Bug 34418
case NS_FORM_INPUT_COLOR:
{
DispatchSimulatedClick(this, aVisitor.mEvent->mFlags.mIsTrusted,
DispatchSimulatedClick(this, aVisitor.mEvent->IsTrusted(),
aVisitor.mPresContext);
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
} // case
@ -3980,7 +3979,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
rv = selectedRadioButton->Focus();
if (NS_SUCCEEDED(rv)) {
rv = DispatchSimulatedClick(selectedRadioButton,
aVisitor.mEvent->mFlags.mIsTrusted,
aVisitor.mEvent->IsTrusted(),
aVisitor.mPresContext);
if (NS_SUCCEEDED(rv)) {
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
@ -4092,8 +4091,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
}
}
}
if (mType == NS_FORM_INPUT_NUMBER &&
aVisitor.mEvent->mFlags.mIsTrusted) {
if (mType == NS_FORM_INPUT_NUMBER && aVisitor.mEvent->IsTrusted()) {
if (mouseEvent->button == WidgetMouseEvent::eLeftButton &&
!(mouseEvent->IsShift() || mouseEvent->IsControl() ||
mouseEvent->IsAlt() || mouseEvent->IsMeta() ||

Просмотреть файл

@ -212,7 +212,7 @@ void
HTMLObjectElement::HandleFocusBlurPlugin(Element* aElement,
WidgetEvent* aEvent)
{
if (!aEvent->mFlags.mIsTrusted) {
if (!aEvent->IsTrusted()) {
return;
}
switch (aEvent->mMessage) {

Просмотреть файл

@ -2274,7 +2274,7 @@ nsGenericHTMLFormElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsresult
nsGenericHTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
if (aVisitor.mEvent->mFlags.mIsTrusted) {
if (aVisitor.mEvent->IsTrusted()) {
switch (aVisitor.mEvent->mMessage) {
case eFocus: {
// Check to see if focus has bubbled up from a form control's

Просмотреть файл

@ -1687,7 +1687,7 @@ nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
WidgetEvent* theEvent = aFocusEvent->WidgetEventPtr();
if (theEvent) {
WidgetGUIEvent focusEvent(theEvent->mFlags.mIsTrusted, theEvent->mMessage,
WidgetGUIEvent focusEvent(theEvent->IsTrusted(), theEvent->mMessage,
nullptr);
nsEventStatus rv = ProcessEvent(focusEvent);
if (nsEventStatus_eConsumeNoDefault == rv) {
@ -2046,7 +2046,7 @@ nsPluginInstanceOwner::HandleEvent(nsIDOMEvent* aEvent)
nsCOMPtr<nsIDOMDragEvent> dragEvent(do_QueryInterface(aEvent));
if (dragEvent && mInstance) {
WidgetEvent* ievent = aEvent->WidgetEventPtr();
if (ievent && ievent->mFlags.mIsTrusted &&
if (ievent && ievent->IsTrusted() &&
ievent->mMessage != eDragEnter && ievent->mMessage != eDragOver) {
aEvent->PreventDefault();
}

Просмотреть файл

@ -97,7 +97,7 @@ nsXBLKeyEventHandler::ExecuteMatchedHandlers(
for (uint32_t i = 0; i < mProtoHandlers.Length(); ++i) {
nsXBLPrototypeHandler* handler = mProtoHandlers[i];
bool hasAllowUntrustedAttr = handler->HasAllowUntrustedAttr();
if ((event->mFlags.mIsTrusted ||
if ((event->IsTrusted() ||
(hasAllowUntrustedAttr && handler->AllowUntrustedEvents()) ||
(!hasAllowUntrustedAttr && !mIsBoundToChrome && !mUsingContentXBLScope)) &&
handler->KeyEventMatched(aKeyEvent, aCharCode, aIgnoreModifierState)) {

Просмотреть файл

@ -1332,7 +1332,7 @@ nsXULElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
WidgetInputEvent* orig = aVisitor.mEvent->AsInputEvent();
nsContentUtils::DispatchXULCommand(
commandContent,
aVisitor.mEvent->mFlags.mIsTrusted,
aVisitor.mEvent->IsTrusted(),
aVisitor.mDOMEvent,
nullptr,
orig->IsControl(),

Просмотреть файл

@ -5102,7 +5102,7 @@ nsEditor::IsAcceptableInputEvent(nsIDOMEvent* aEvent)
}
// Accept all trusted events.
if (widgetEvent->mFlags.mIsTrusted) {
if (widgetEvent->IsTrusted()) {
return true;
}

Просмотреть файл

@ -6831,7 +6831,8 @@ DispatchPointerFromMouseOrTouch(PresShell* aShell,
continue;
}
WidgetPointerEvent event(touchEvent->mFlags.mIsTrusted, pointerMessage, touchEvent->widget);
WidgetPointerEvent event(touchEvent->IsTrusted(), pointerMessage,
touchEvent->widget);
event.isPrimary = i == 0;
event.pointerId = touch->Identifier();
event.refPoint = touch->mRefPoint;
@ -6966,7 +6967,7 @@ PresShell::DispatchBeforeKeyboardEventInternal(const nsTArray<nsCOMPtr<Element>
}
aChainIndex = i;
InternalBeforeAfterKeyboardEvent beforeEvent(aEvent.mFlags.mIsTrusted,
InternalBeforeAfterKeyboardEvent beforeEvent(aEvent.IsTrusted(),
message, aEvent.widget);
beforeEvent.AssignBeforeAfterKeyEventData(aEvent, false);
EventDispatcher::Dispatch(eventTarget, mPresContext, &beforeEvent);
@ -7000,7 +7001,7 @@ PresShell::DispatchAfterKeyboardEventInternal(const nsTArray<nsCOMPtr<Element> >
return;
}
InternalBeforeAfterKeyboardEvent afterEvent(aEvent.mFlags.mIsTrusted,
InternalBeforeAfterKeyboardEvent afterEvent(aEvent.IsTrusted(),
message, aEvent.widget);
afterEvent.AssignBeforeAfterKeyEventData(aEvent, false);
afterEvent.mEmbeddedCancelled.SetValue(embeddedCancelled);
@ -7917,7 +7918,7 @@ PresShell::HandleEventInternal(WidgetEvent* aEvent,
bool isHandlingUserInput = false;
// XXX How about IME events and input events for plugins?
if (aEvent->mFlags.mIsTrusted) {
if (aEvent->IsTrusted()) {
switch (aEvent->mMessage) {
case eKeyPress:
case eKeyDown:
@ -8017,7 +8018,7 @@ PresShell::HandleEventInternal(WidgetEvent* aEvent,
AutoHandlingUserInputStatePusher userInpStatePusher(isHandlingUserInput,
aEvent, mDocument);
if (aEvent->mFlags.mIsTrusted && aEvent->mMessage == eMouseMove) {
if (aEvent->IsTrusted() && aEvent->mMessage == eMouseMove) {
nsIPresShell::AllowMouseCapture(
EventStateManager::GetActiveEventStateManager() == manager);
}
@ -8216,7 +8217,7 @@ PresShell::DispatchTouchEventToDOM(WidgetEvent* aEvent,
content = capturingContent;
}
// copy the event
WidgetTouchEvent newEvent(touchEvent->mFlags.mIsTrusted,
WidgetTouchEvent newEvent(touchEvent->IsTrusted(),
touchEvent->mMessage, touchEvent->widget);
newEvent.AssignTouchEventData(*touchEvent, false);
newEvent.target = targetPtr;
@ -9673,7 +9674,7 @@ PresShell::DelayedMouseEvent::DelayedMouseEvent(WidgetMouseEvent* aEvent) :
DelayedInputEvent()
{
WidgetMouseEvent* mouseEvent =
new WidgetMouseEvent(aEvent->mFlags.mIsTrusted,
new WidgetMouseEvent(aEvent->IsTrusted(),
aEvent->mMessage,
aEvent->widget,
aEvent->reason,
@ -9686,7 +9687,7 @@ PresShell::DelayedKeyEvent::DelayedKeyEvent(WidgetKeyboardEvent* aEvent) :
DelayedInputEvent()
{
WidgetKeyboardEvent* keyEvent =
new WidgetKeyboardEvent(aEvent->mFlags.mIsTrusted,
new WidgetKeyboardEvent(aEvent->IsTrusted(),
aEvent->mMessage,
aEvent->widget);
keyEvent->AssignKeyEventData(*aEvent, false);

Просмотреть файл

@ -223,7 +223,7 @@ nsButtonBoxFrame::DoMouseClick(WidgetGUIEvent* aEvent, bool aTrustEvent)
if (shell) {
nsContentUtils::DispatchXULCommand(mContent,
aEvent ?
aEvent->mFlags.mIsTrusted : aTrustEvent,
aEvent->IsTrusted() : aTrustEvent,
nullptr, shell,
isControl, isAlt, isShift, isMeta);
}

Просмотреть файл

@ -1232,7 +1232,7 @@ nsMenuFrame::CreateMenuCommandEvent(WidgetGUIEvent* 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 ? aEvent->mFlags.mIsTrusted :
bool isTrusted = aEvent ? aEvent->IsTrusted() :
nsContentUtils::IsCallerChrome();
bool shift = false, control = false, alt = false, meta = false;

Просмотреть файл

@ -539,6 +539,5 @@ void
nsResizerFrame::MouseClicked(WidgetMouseEvent* aEvent)
{
// Execute the oncommand event handler.
nsContentUtils::DispatchXULCommand(mContent,
aEvent && aEvent->mFlags.mIsTrusted);
nsContentUtils::DispatchXULCommand(mContent, aEvent && aEvent->IsTrusted());
}

Просмотреть файл

@ -91,7 +91,7 @@ nsAutoRepeatBoxFrame::HandleEvent(nsPresContext* aPresContext,
case eMouseOver:
if (IsActivatedOnHover()) {
StartRepeat();
mTrustedEvent = aEvent->mFlags.mIsTrusted;
mTrustedEvent = aEvent->IsTrusted();
}
break;
@ -126,7 +126,7 @@ nsAutoRepeatBoxFrame::HandlePress(nsPresContext* aPresContext,
{
if (!IsActivatedOnHover()) {
StartRepeat();
mTrustedEvent = aEvent->mFlags.mIsTrusted;
mTrustedEvent = aEvent->IsTrusted();
DoMouseClick(aEvent, mTrustedEvent);
}

Просмотреть файл

@ -169,6 +169,5 @@ void
nsTitleBarFrame::MouseClicked(WidgetMouseEvent* aEvent)
{
// Execute the oncommand event handler.
nsContentUtils::DispatchXULCommand(mContent,
aEvent && aEvent->mFlags.mIsTrusted);
nsContentUtils::DispatchXULCommand(mContent, aEvent && aEvent->IsTrusted());
}

Просмотреть файл

@ -173,6 +173,10 @@ public:
MOZ_ASSERT(!mDefaultPreventedByContent || DefaultPrevented());
return mDefaultPreventedByContent;
}
inline bool IsTrusted() const
{
return mIsTrusted;
}
inline void Clear()
{
@ -368,6 +372,7 @@ public:
{
return mFlags.DefaultPreventedByContent();
}
bool IsTrusted() const { return mFlags.IsTrusted(); }
/**
* Utils for checking event types
@ -849,7 +854,7 @@ public:
: WidgetGUIEvent(aIsTrusted, aMessage, nullptr, eUIEventClass)
, detail(0)
, mCausedByUntrustedEvent(
aEventCausesThisEvent && !aEventCausesThisEvent->mFlags.mIsTrusted)
aEventCausesThisEvent && !aEventCausesThisEvent->IsTrusted())
{
}
@ -871,7 +876,7 @@ public:
// event, IsTrustable() returns what you expected.
bool IsTrustable() const
{
return mFlags.mIsTrusted && !mCausedByUntrustedEvent;
return IsTrusted() && !mCausedByUntrustedEvent;
}
void AssignUIEventData(const InternalUIEvent& aEvent, bool aCopyTargets)

Просмотреть файл

@ -106,7 +106,7 @@ public:
}
WidgetSimpleGestureEvent(const WidgetSimpleGestureEvent& aOther)
: WidgetMouseEventBase(aOther.mFlags.mIsTrusted, aOther.mMessage,
: WidgetMouseEventBase(aOther.IsTrusted(), aOther.mMessage,
aOther.widget, eSimpleGestureEventClass)
, allowedDirections(aOther.allowedDirections)
, direction(aOther.direction)
@ -167,7 +167,7 @@ public:
}
WidgetTouchEvent(const WidgetTouchEvent& aOther)
: WidgetInputEvent(aOther.mFlags.mIsTrusted, aOther.mMessage, aOther.widget,
: WidgetInputEvent(aOther.IsTrusted(), aOther.mMessage, aOther.widget,
eTouchEventClass)
{
MOZ_COUNT_CTOR(WidgetTouchEvent);