commit 79e3fdc22a4b4e0993a64eb57a03550c0e85c967 parent 7767650662d5872688c062303a14533e106e657e Author: Emilio Cobos Álvarez <emilio@crisal.io> Date: Mon, 17 Nov 2025 04:26:07 +0000 Bug 2000153 - Clean up widget event dispatch. r=masayuki Make all nsIWidgetListener::HandleEvent go through a single nsIWidget::DispatchEvent(). Differential Revision: https://phabricator.services.mozilla.com/D272601 Diffstat:
30 files changed, 110 insertions(+), 308 deletions(-)
diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp @@ -9630,10 +9630,7 @@ Result<bool, nsresult> nsContentUtils::SynthesizeMouseEvent( StaticPrefs::test_events_async_enabled()) { status = aWidget->DispatchInputEvent(&mouseOrPointerEvent).mContentStatus; } else { - nsresult rv = aWidget->DispatchEvent(&mouseOrPointerEvent, status); - if (NS_FAILED(rv)) { - return Err(rv); - } + aWidget->DispatchEvent(&mouseOrPointerEvent); } // The callback ID may be cleared when the event also needs to be dispatched diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp @@ -770,9 +770,7 @@ nsDOMWindowUtils::SendWheelEvent(float aX, float aY, double aDeltaX, StaticPrefs::test_events_async_enabled()) { widget->DispatchInputEvent(&wheelEvent); } else { - nsEventStatus status = nsEventStatus_eIgnore; - nsresult rv = widget->DispatchEvent(&wheelEvent, status); - NS_ENSURE_SUCCESS(rv, rv); + widget->DispatchEvent(&wheelEvent); } // The callback ID may be cleared when the event also needs to be dispatched @@ -942,7 +940,7 @@ nsresult nsDOMWindowUtils::SendTouchEventCommon( StaticPrefs::test_events_async_enabled()) { status = widget->DispatchInputEvent(&event).mContentStatus; } else { - MOZ_TRY(widget->DispatchEvent(&event, status)); + status = widget->DispatchEvent(&event); } if (aPreventDefault) { *aPreventDefault = (status == nsEventStatus_eConsumeNoDefault); @@ -1469,8 +1467,8 @@ nsDOMWindowUtils::SendSimpleGestureEvent(const nsAString& aType, float aX, event.mRefPoint = nsContentUtils::ToWidgetPoint(CSSPoint(aX, aY), offset, presContext); - nsEventStatus status; - return widget->DispatchEvent(&event, status); + widget->DispatchEvent(&event); + return NS_OK; } NS_IMETHODIMP @@ -2526,9 +2524,7 @@ nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType, int64_t aOffset, break; } - nsEventStatus status; - nsresult rv = targetWidget->DispatchEvent(&queryEvent, status); - NS_ENSURE_SUCCESS(rv, rv); + targetWidget->DispatchEvent(&queryEvent); auto* result = new nsQueryContentEventResult(std::move(queryEvent)); result->SetEventResult(widget); @@ -2557,9 +2553,7 @@ nsDOMWindowUtils::SendSelectionSetEvent(uint32_t aOffset, uint32_t aLength, selectionEvent.mUseNativeLineBreak = !(aAdditionalFlags & SELECTION_SET_FLAG_USE_XP_LINE_BREAK); - nsEventStatus status; - nsresult rv = widget->DispatchEvent(&selectionEvent, status); - NS_ENSURE_SUCCESS(rv, rv); + widget->DispatchEvent(&selectionEvent); *aResult = selectionEvent.mSucceeded; return NS_OK; @@ -2612,8 +2606,8 @@ nsDOMWindowUtils::SendContentCommandEvent(const nsAString& aType, event.mTransferable = aTransferable; } - nsEventStatus status; - return widget->DispatchEvent(&event, status); + widget->DispatchEvent(&event); + return NS_OK; } NS_IMETHODIMP diff --git a/dom/events/PointerEventHandler.cpp b/dom/events/PointerEventHandler.cpp @@ -773,8 +773,7 @@ void PointerEventHandler::SynthesizeMoveToDispatchBoundaryEvents( // cannot synthesize the pointermove/mousemove on the document since // dispatching events to the parent process is currently allowed only in // automation. - nsEventStatus eventStatus = nsEventStatus_eIgnore; - widget->DispatchEvent(&event, eventStatus); + widget->DispatchEvent(&event); } /* static */ diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -533,11 +533,10 @@ PresShell* APZCCallbackHelper::GetRootContentDocumentPresShellForContent( } nsEventStatus APZCCallbackHelper::DispatchWidgetEvent(WidgetGUIEvent& aEvent) { - nsEventStatus status = nsEventStatus_eConsumeNoDefault; if (aEvent.mWidget) { - aEvent.mWidget->DispatchEvent(&aEvent, status); + return aEvent.mWidget->DispatchEvent(&aEvent); } - return status; + return nsEventStatus_eConsumeNoDefault; } nsEventStatus APZCCallbackHelper::DispatchSynthesizedMouseEvent( diff --git a/gfx/layers/apz/util/APZEventState.cpp b/gfx/layers/apz/util/APZEventState.cpp @@ -387,8 +387,7 @@ void APZEventState::ProcessTouchEvent( touch->convertToPointer = true; } } - nsEventStatus status; - cancelEvent.mWidget->DispatchEvent(&cancelEvent, status); + cancelEvent.mWidget->DispatchEvent(&cancelEvent); } } diff --git a/gfx/tests/gtest/MockWidget.h b/gfx/tests/gtest/MockWidget.h @@ -71,11 +71,7 @@ class MockWidget : public nsIWidget { void Invalidate(const LayoutDeviceIntRect& aRect) override {} nsresult SetTitle(const nsAString& title) override { return NS_OK; } LayoutDeviceIntPoint WidgetToScreenOffset() override { - return LayoutDeviceIntPoint(0, 0); - } - nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) override { - return NS_OK; + return LayoutDeviceIntPoint(); } void SetInputContext(const InputContext& aContext, const InputContextAction& aAction) override {} diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp @@ -10819,8 +10819,7 @@ void PresShell::DelayedInputEvent::Dispatch() { return; } nsCOMPtr<nsIWidget> widget = mEvent->mWidget; - nsEventStatus status; - widget->DispatchEvent(mEvent, status); + widget->DispatchEvent(mEvent); } PresShell::DelayedMouseEvent::DelayedMouseEvent(WidgetMouseEvent* aEvent) { diff --git a/layout/base/TouchManager.cpp b/layout/base/TouchManager.cpp @@ -78,8 +78,7 @@ void TouchManager::EvictTouchPoint(RefPtr<Touch>& aTouch, if (nsCOMPtr<nsIWidget> widget = frame->GetNearestWidget()) { WidgetTouchEvent event(true, eTouchEnd, widget); event.mTouches.AppendElement(aTouch); - nsEventStatus status; - widget->DispatchEvent(&event, status); + widget->DispatchEvent(&event); } } } diff --git a/widget/ContentCache.cpp b/widget/ContentCache.cpp @@ -201,10 +201,9 @@ bool ContentCacheInChild::CacheSelection(nsIWidget* aWidget, return false; } - nsEventStatus status = nsEventStatus_eIgnore; WidgetQueryContentEvent querySelectedTextEvent(true, eQuerySelectedText, aWidget); - aWidget->DispatchEvent(&querySelectedTextEvent, status); + aWidget->DispatchEvent(&querySelectedTextEvent); if (NS_WARN_IF(querySelectedTextEvent.Failed())) { MOZ_LOG( sContentCacheLog, LogLevel::Error, @@ -251,10 +250,9 @@ bool ContentCacheInChild::CacheCaret(nsIWidget* aWidget, // XXX Should be mSelection.mFocus? const uint32_t offset = mSelection->StartOffset(); - nsEventStatus status = nsEventStatus_eIgnore; WidgetQueryContentEvent queryCaretRectEvent(true, eQueryCaretRect, aWidget); queryCaretRectEvent.InitForQueryCaretRect(offset); - aWidget->DispatchEvent(&queryCaretRectEvent, status); + aWidget->DispatchEvent(&queryCaretRectEvent); if (NS_WARN_IF(queryCaretRectEvent.Failed())) { MOZ_LOG(sContentCacheLog, LogLevel::Error, ("0x%p CacheCaret(), FAILED, couldn't retrieve the caret rect " @@ -277,9 +275,8 @@ bool ContentCacheInChild::CacheEditorRect( ("0x%p CacheEditorRect(aWidget=0x%p, aNotification=%s)", this, aWidget, GetNotificationName(aNotification))); - nsEventStatus status = nsEventStatus_eIgnore; WidgetQueryContentEvent queryEditorRectEvent(true, eQueryEditorRect, aWidget); - aWidget->DispatchEvent(&queryEditorRectEvent, status); + aWidget->DispatchEvent(&queryEditorRectEvent); if (NS_WARN_IF(queryEditorRectEvent.Failed())) { MOZ_LOG( sContentCacheLog, LogLevel::Error, @@ -322,11 +319,10 @@ bool ContentCacheInChild::CacheText(nsIWidget* aWidget, ("0x%p CacheText(aWidget=0x%p, aNotification=%s)", this, aWidget, GetNotificationName(aNotification))); - nsEventStatus status = nsEventStatus_eIgnore; WidgetQueryContentEvent queryTextContentEvent(true, eQueryTextContent, aWidget); queryTextContentEvent.InitForQueryTextContent(0, UINT32_MAX); - aWidget->DispatchEvent(&queryTextContentEvent, status); + aWidget->DispatchEvent(&queryTextContentEvent); if (NS_WARN_IF(queryTextContentEvent.Failed())) { MOZ_LOG(sContentCacheLog, LogLevel::Error, ("0x%p CacheText(), FAILED, couldn't retrieve whole text", this)); @@ -385,10 +381,9 @@ bool ContentCacheInChild::QueryCharRect(nsIWidget* aWidget, uint32_t aOffset, LayoutDeviceIntRect& aCharRect) const { aCharRect.SetEmpty(); - nsEventStatus status = nsEventStatus_eIgnore; WidgetQueryContentEvent queryTextRectEvent(true, eQueryTextRect, aWidget); queryTextRectEvent.InitForQueryTextRect(aOffset, 1); - aWidget->DispatchEvent(&queryTextRectEvent, status); + aWidget->DispatchEvent(&queryTextRectEvent); if (NS_WARN_IF(queryTextRectEvent.Failed())) { return false; } @@ -407,11 +402,10 @@ bool ContentCacheInChild::QueryCharRect(nsIWidget* aWidget, uint32_t aOffset, bool ContentCacheInChild::QueryCharRectArray(nsIWidget* aWidget, uint32_t aOffset, uint32_t aLength, RectArray& aCharRectArray) const { - nsEventStatus status = nsEventStatus_eIgnore; WidgetQueryContentEvent queryTextRectsEvent(true, eQueryTextRectArray, aWidget); queryTextRectsEvent.InitForQueryTextRectArray(aOffset, aLength); - aWidget->DispatchEvent(&queryTextRectsEvent, status); + aWidget->DispatchEvent(&queryTextRectsEvent); if (NS_WARN_IF(queryTextRectsEvent.Failed())) { aCharRectArray.Clear(); return false; @@ -566,11 +560,10 @@ bool ContentCacheInChild::CacheTextRects(nsIWidget* aWidget, // middle of different line. if (mSelection.isSome() && mSelection->mHasRange && !mSelection->IsCollapsed()) { - nsEventStatus status = nsEventStatus_eIgnore; WidgetQueryContentEvent queryTextRectEvent(true, eQueryTextRect, aWidget); queryTextRectEvent.InitForQueryTextRect(mSelection->StartOffset(), mSelection->Length()); - aWidget->DispatchEvent(&queryTextRectEvent, status); + aWidget->DispatchEvent(&queryTextRectEvent); if (NS_WARN_IF(queryTextRectEvent.Failed())) { MOZ_LOG(sContentCacheLog, LogLevel::Error, ("0x%p CacheTextRects(), FAILED, " diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp @@ -227,8 +227,7 @@ void PuppetWidget::InitEvent(WidgetGUIEvent& aEvent, } } -nsresult PuppetWidget::DispatchEvent(WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) { +nsEventStatus PuppetWidget::DispatchEvent(WidgetGUIEvent* aEvent) { #ifdef DEBUG debug_DumpEvent(stdout, aEvent->mWidget, aEvent, "PuppetWidget", 0); #endif @@ -237,8 +236,7 @@ nsresult PuppetWidget::DispatchEvent(WidgetGUIEvent* aEvent, aEvent->mFlags.mIsSynthesizedForTests || aEvent->AsKeyboardEvent()->AreAllEditCommandsInitialized(), "Non-sysnthesized keyboard events should have edit commands for " - "all types " - "before dispatched"); + "all types before dispatched"); if (aEvent->mClass == eCompositionEventClass) { // If we've already requested to commit/cancel the latest composition, @@ -248,8 +246,7 @@ nsresult PuppetWidget::DispatchEvent(WidgetGUIEvent* aEvent, // discard all unnecessary composition events here. if (mIgnoreCompositionEvents) { if (aEvent->mMessage != eCompositionStart) { - aStatus = nsEventStatus_eIgnore; - return NS_OK; + return nsEventStatus_eIgnore; } // Now, we receive new eCompositionStart. Let's restart to handle // composition in this process. @@ -301,21 +298,14 @@ nsresult PuppetWidget::DispatchEvent(WidgetGUIEvent* aEvent, } } - aStatus = nsEventStatus_eIgnore; - - if (GetCurrentWidgetListener()) { - aStatus = - GetCurrentWidgetListener()->HandleEvent(aEvent, mUseAttachedEvents); - } - - return NS_OK; + return nsIWidget::DispatchEvent(aEvent); } nsIWidget::ContentAndAPZEventStatus PuppetWidget::DispatchInputEvent( WidgetInputEvent* aEvent) { ContentAndAPZEventStatus status; if (!AsyncPanZoomEnabled()) { - DispatchEvent(aEvent, status.mContentStatus); + status.mContentStatus = DispatchEvent(aEvent); return status; } @@ -616,8 +606,7 @@ nsresult PuppetWidget::RequestIMEToCommitComposition(bool aCancel) { WidgetCompositionEvent compositionCommitEvent(true, eCompositionCommit, this); InitEvent(compositionCommitEvent, nullptr); compositionCommitEvent.mData = committedString; - nsEventStatus status = nsEventStatus_eIgnore; - DispatchEvent(&compositionCommitEvent, status); + DispatchEvent(&compositionCommitEvent); #ifdef DEBUG RefPtr<TextComposition> currentComposition = diff --git a/widget/PuppetWidget.h b/widget/PuppetWidget.h @@ -130,8 +130,7 @@ class PuppetWidget final : public nsIWidget, void InitEvent(WidgetGUIEvent& aEvent, LayoutDeviceIntPoint* aPoint = nullptr); - nsresult DispatchEvent(WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) override; + nsEventStatus DispatchEvent(WidgetGUIEvent* aEvent) override; ContentAndAPZEventStatus DispatchInputEvent( WidgetInputEvent* aEvent) override; void SetConfirmedTargetAPZC( diff --git a/widget/TextEventDispatcher.cpp b/widget/TextEventDispatcher.cpp @@ -252,9 +252,8 @@ Maybe<WritingMode> TextEventDispatcher::MaybeQueryWritingModeAtSelection() WidgetQueryContentEvent querySelectedTextEvent(true, eQuerySelectedText, mWidget); - nsEventStatus status = nsEventStatus_eIgnore; - const_cast<TextEventDispatcher*>(this)->DispatchEvent( - mWidget, querySelectedTextEvent, status); + const_cast<TextEventDispatcher*>(this)->DispatchEvent(mWidget, + querySelectedTextEvent); if (!querySelectedTextEvent.FoundSelection()) { return Nothing(); } @@ -262,22 +261,20 @@ Maybe<WritingMode> TextEventDispatcher::MaybeQueryWritingModeAtSelection() return Some(querySelectedTextEvent.mReply->mWritingMode); } -nsresult TextEventDispatcher::DispatchEvent(nsIWidget* aWidget, - WidgetGUIEvent& aEvent, - nsEventStatus& aStatus) { +nsEventStatus TextEventDispatcher::DispatchEvent(nsIWidget* aWidget, + WidgetGUIEvent& aEvent) { MOZ_ASSERT(!aEvent.AsInputEvent(), "Use DispatchInputEvent()"); RefPtr<TextEventDispatcher> kungFuDeathGrip(this); nsCOMPtr<nsIWidget> widget(aWidget); mDispatchingEvent++; - nsresult rv = widget->DispatchEvent(&aEvent, aStatus); + auto status = widget->DispatchEvent(&aEvent); mDispatchingEvent--; - return rv; + return status; } -nsresult TextEventDispatcher::DispatchInputEvent(nsIWidget* aWidget, - WidgetInputEvent& aEvent, - nsEventStatus& aStatus) { +nsEventStatus TextEventDispatcher::DispatchInputEvent( + nsIWidget* aWidget, WidgetInputEvent& aEvent) { RefPtr<TextEventDispatcher> kungFuDeathGrip(this); nsCOMPtr<nsIWidget> widget(aWidget); mDispatchingEvent++; @@ -286,15 +283,13 @@ nsresult TextEventDispatcher::DispatchInputEvent(nsIWidget* aWidget, // sends the event to the parent process first since APZ needs to handle it // first. However, some callers (e.g., keyboard apps on B2G and tests // expecting synchronous dispatch) don't want this to do that. - nsresult rv = NS_OK; - if (ShouldSendInputEventToAPZ()) { - aStatus = widget->DispatchInputEvent(&aEvent).mContentStatus; - } else { - rv = widget->DispatchEvent(&aEvent, aStatus); - } + nsEventStatus status = + ShouldSendInputEventToAPZ() + ? widget->DispatchInputEvent(&aEvent).mContentStatus + : widget->DispatchEvent(&aEvent); mDispatchingEvent--; - return rv; + return status; } nsresult TextEventDispatcher::StartComposition( @@ -319,11 +314,7 @@ nsresult TextEventDispatcher::StartComposition( if (aEventTime) { compositionStartEvent.AssignEventTime(*aEventTime); } - rv = DispatchEvent(mWidget, compositionStartEvent, aStatus); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - + DispatchEvent(mWidget, compositionStartEvent); return NS_OK; } @@ -409,11 +400,7 @@ nsresult TextEventDispatcher::CommitComposition( compositionCommitEvent.mData.ReplaceSubstring(u"\r\n"_ns, u"\n"_ns); compositionCommitEvent.mData.ReplaceSubstring(u"\r"_ns, u"\n"_ns); } - rv = DispatchEvent(widget, compositionCommitEvent, aStatus); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - + aStatus = DispatchEvent(widget, compositionCommitEvent); return NS_OK; } @@ -778,7 +765,7 @@ bool TextEventDispatcher::DispatchKeyboardEventInternal( keyEvent.InitAllEditCommands(mWritingMode); } - DispatchInputEvent(mWidget, keyEvent, aStatus); + aStatus = DispatchInputEvent(mWidget, keyEvent); return true; } @@ -1043,11 +1030,7 @@ nsresult TextEventDispatcher::PendingComposition::Flush( if (aStatus == nsEventStatus_eConsumeNoDefault) { return NS_OK; } - rv = aDispatcher->DispatchEvent(widget, compChangeEvent, aStatus); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - + aStatus = aDispatcher->DispatchEvent(widget, compChangeEvent); return NS_OK; } diff --git a/widget/TextEventDispatcher.h b/widget/TextEventDispatcher.h @@ -486,14 +486,13 @@ class TextEventDispatcher final { /** * DispatchEvent() dispatches aEvent on aWidget. */ - nsresult DispatchEvent(nsIWidget* aWidget, WidgetGUIEvent& aEvent, - nsEventStatus& aStatus); + nsEventStatus DispatchEvent(nsIWidget* aWidget, WidgetGUIEvent& aEvent); /** * DispatchInputEvent() dispatches aEvent on aWidget. */ - nsresult DispatchInputEvent(nsIWidget* aWidget, WidgetInputEvent& aEvent, - nsEventStatus& aStatus); + nsEventStatus DispatchInputEvent(nsIWidget* aWidget, + WidgetInputEvent& aEvent); /** * StartCompositionAutomaticallyIfNecessary() starts composition if it hasn't diff --git a/widget/android/GeckoEditableSupport.cpp b/widget/android/GeckoEditableSupport.cpp @@ -460,7 +460,6 @@ bool GeckoEditableSupport::RemoveComposition(RemoveCompositionFlag aFlag) { } nsEventStatus status = nsEventStatus_eIgnore; - NS_ENSURE_SUCCESS(BeginInputTransaction(mDispatcher), false); mDispatcher->CommitComposition( status, aFlag == CANCEL_IME_COMPOSITION ? &EmptyString() : nullptr); @@ -646,7 +645,6 @@ void GeckoEditableSupport::FlushIMEChanges(FlushChangesFlag aFlags) { }; TextRecord textTransaction; - nsEventStatus status = nsEventStatus_eIgnore; bool causedOnlyByComposition = mIMEPendingTextChange.IsValid() && mIMEPendingTextChange.mCausedOnlyByComposition; mIMETextChangedDuringFlush = false; @@ -682,7 +680,7 @@ void GeckoEditableSupport::FlushIMEChanges(FlushChangesFlag aFlags) { mIMEPendingTextChange.mStartOffset, mIMEPendingTextChange.mAddedEndOffset - mIMEPendingTextChange.mStartOffset); - widget->DispatchEvent(&queryTextContentEvent, status); + widget->DispatchEvent(&queryTextContentEvent); if (shouldAbort(NS_WARN_IF(queryTextContentEvent.Failed()))) { return; @@ -715,7 +713,7 @@ void GeckoEditableSupport::FlushIMEChanges(FlushChangesFlag aFlags) { // change. WidgetQueryContentEvent querySelectedTextEvent(true, eQuerySelectedText, widget); - widget->DispatchEvent(&querySelectedTextEvent, status); + widget->DispatchEvent(&querySelectedTextEvent); if (shouldAbort( NS_WARN_IF(querySelectedTextEvent.DidNotFindSelection()))) { @@ -819,13 +817,12 @@ void GeckoEditableSupport::UpdateCompositionRects() { jni::ObjectArray::LocalRef rects; if (composition) { - nsEventStatus status = nsEventStatus_eIgnore; uint32_t offset = composition->NativeOffsetOfStartComposition(); WidgetQueryContentEvent queryTextRectsEvent(true, eQueryTextRectArray, widget); queryTextRectsEvent.InitForQueryTextRectArray( offset, composition->String().Length()); - widget->DispatchEvent(&queryTextRectsEvent, status); + widget->DispatchEvent(&queryTextRectsEvent); rects = ConvertRectArrayToJavaRectFArray( queryTextRectsEvent.Succeeded() ? queryTextRectsEvent.mReply->mRectArray @@ -840,8 +837,7 @@ void GeckoEditableSupport::UpdateCompositionRects() { options.mRelativeToInsertionPoint = true; queryCaretRectEvent.InitForQueryCaretRect(0, options); - nsEventStatus status = nsEventStatus_eIgnore; - widget->DispatchEvent(&queryCaretRectEvent, status); + widget->DispatchEvent(&queryCaretRectEvent); auto caretRect = queryCaretRectEvent.Succeeded() ? java::sdk::RectF::New(queryCaretRectEvent.mReply->mRect.x, @@ -930,10 +926,9 @@ bool GeckoEditableSupport::DoReplaceText(int32_t aStart, int32_t aEnd, #ifdef NIGHTLY_BUILD { - nsEventStatus status = nsEventStatus_eIgnore; WidgetQueryContentEvent querySelectedTextEvent(true, eQuerySelectedText, widget); - widget->DispatchEvent(&querySelectedTextEvent, status); + widget->DispatchEvent(&querySelectedTextEvent); if (querySelectedTextEvent.Succeeded()) { ALOGIME( "IME: Current selection: %s", @@ -952,7 +947,7 @@ bool GeckoEditableSupport::DoReplaceText(int32_t aStart, int32_t aEnd, event.mLength = uint32_t(aEnd - aStart); event.mExpandToClusterBoundary = false; event.mReason = nsISelectionListener::IME_REASON; - widget->DispatchEvent(&event, status); + status = widget->DispatchEvent(&event); } if (!mIMEKeyEvents.IsEmpty()) { @@ -1029,7 +1024,7 @@ bool GeckoEditableSupport::DoReplaceText(int32_t aStart, int32_t aEnd, WidgetContentCommandEvent insertTextEvent(true, eContentCommandInsertText, widget); insertTextEvent.mString = Some(string); - widget->DispatchEvent(&insertTextEvent, status); + widget->DispatchEvent(&insertTextEvent); if (!mDispatcher || widget->Destroyed()) { return false; } @@ -1046,7 +1041,7 @@ bool GeckoEditableSupport::DoReplaceText(int32_t aStart, int32_t aEnd, } } else if (performDeletion) { WidgetContentCommandEvent event(true, eContentCommandDelete, widget); - widget->DispatchEvent(&event, status); + status = widget->DispatchEvent(&event); if (!mDispatcher || widget->Destroyed()) { return false; } @@ -1118,7 +1113,6 @@ bool GeckoEditableSupport::DoUpdateComposition(int32_t aStart, int32_t aEnd, } nsCOMPtr<nsIWidget> widget = GetWidget(); - nsEventStatus status = nsEventStatus_eIgnore; NS_ENSURE_TRUE(mDispatcher && widget, false); const bool keepCurrent = @@ -1139,7 +1133,7 @@ bool GeckoEditableSupport::DoUpdateComposition(int32_t aStart, int32_t aEnd, selEvent.mLength = std::max(aStart, aEnd) - selEvent.mOffset; selEvent.mReversed = aStart > aEnd; selEvent.mExpandToClusterBoundary = false; - widget->DispatchEvent(&selEvent, status); + widget->DispatchEvent(&selEvent); return compositionChanged; } @@ -1154,6 +1148,7 @@ bool GeckoEditableSupport::DoUpdateComposition(int32_t aStart, int32_t aEnd, RefPtr<TextComposition> composition(GetComposition()); MOZ_ASSERT(!composition || !composition->EditorIsHandlingLatestChange()); + nsEventStatus status = nsEventStatus_eIgnore; if (!composition || !mDispatcher->IsComposing() || uint32_t(aStart) != composition->NativeOffsetOfStartComposition() || uint32_t(aEnd) != composition->NativeOffsetOfStartComposition() + @@ -1174,13 +1169,13 @@ bool GeckoEditableSupport::DoUpdateComposition(int32_t aStart, int32_t aEnd, event.mLength = uint32_t(aEnd - aStart); event.mExpandToClusterBoundary = false; event.mReason = nsISelectionListener::IME_REASON; - widget->DispatchEvent(&event, status); + status = widget->DispatchEvent(&event); } { WidgetQueryContentEvent querySelectedTextEvent(true, eQuerySelectedText, widget); - widget->DispatchEvent(&querySelectedTextEvent, status); + status = widget->DispatchEvent(&querySelectedTextEvent); MOZ_ASSERT(querySelectedTextEvent.Succeeded()); if (querySelectedTextEvent.FoundSelection()) { string = querySelectedTextEvent.mReply->DataRef(); @@ -1231,8 +1226,7 @@ class MOZ_STACK_CLASS AutoSelectionRestore final { } WidgetQueryContentEvent querySelectedTextEvent(true, eQuerySelectedText, widget); - nsEventStatus status = nsEventStatus_eIgnore; - widget->DispatchEvent(&querySelectedTextEvent, status); + widget->DispatchEvent(&querySelectedTextEvent); if (querySelectedTextEvent.DidNotFindSelection()) { mOffset = UINT32_MAX; mLength = UINT32_MAX; @@ -1253,8 +1247,7 @@ class MOZ_STACK_CLASS AutoSelectionRestore final { selection.mLength = mLength; selection.mExpandToClusterBoundary = false; selection.mReason = nsISelectionListener::IME_REASON; - nsEventStatus status = nsEventStatus_eIgnore; - mWidget->DispatchEvent(&selection, status); + mWidget->DispatchEvent(&selection); } private: @@ -1725,8 +1718,7 @@ void GeckoEditableSupport::OnImeInsertImage(jni::ByteArray::Param aData, WidgetContentCommandEvent command(true, eContentCommandPasteTransferable, widget); command.mTransferable = trans.forget(); - nsEventStatus status; - widget->DispatchEvent(&command, status); + widget->DispatchEvent(&command); } void GeckoEditableSupport::PostHandleKeyEvent(WidgetKeyboardEvent* aEvent) { diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp @@ -2624,21 +2624,6 @@ LayoutDeviceIntPoint nsWindow::WidgetToScreenOffset() { return p; } -nsresult nsWindow::DispatchEvent(WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) { - aStatus = DispatchEvent(aEvent); - return NS_OK; -} - -nsEventStatus nsWindow::DispatchEvent(WidgetGUIEvent* aEvent) { - if (mAttachedWidgetListener) { - return mAttachedWidgetListener->HandleEvent(aEvent, mUseAttachedEvents); - } else if (mWidgetListener) { - return mWidgetListener->HandleEvent(aEvent, mUseAttachedEvents); - } - return nsEventStatus_eIgnore; -} - nsresult nsWindow::MakeFullScreen(bool aFullScreen) { AssertIsOnMainThread(); @@ -2961,8 +2946,7 @@ void nsWindow::DispatchHitTest(const WidgetTouchEvent& aEvent) { WidgetMouseEvent hittest(true, eMouseHitTest, this, WidgetMouseEvent::eReal); hittest.mRefPoint = aEvent.mTouches[0]->mRefPoint; - nsEventStatus status; - DispatchEvent(&hittest, status); + DispatchEvent(&hittest); } } diff --git a/widget/android/nsWindow.h b/widget/android/nsWindow.h @@ -177,9 +177,6 @@ class nsWindow final : public nsIWidget { LayoutDeviceIntRect GetScreenBounds() override; LayoutDeviceIntRect GetBounds() override { return mBounds; } LayoutDeviceIntPoint WidgetToScreenOffset() override; - nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) override; - nsEventStatus DispatchEvent(mozilla::WidgetGUIEvent* aEvent); nsresult MakeFullScreen(bool aFullScreen) override; void SetCursor(const Cursor& aDefaultCursor) override; void* GetNativeData(uint32_t aDataType) override; diff --git a/widget/cocoa/nsCocoaWindow.h b/widget/cocoa/nsCocoaWindow.h @@ -423,8 +423,7 @@ class nsCocoaWindow final : public nsIWidget { nsresult SetTitle(const nsAString& aTitle) override; void Invalidate(const LayoutDeviceIntRect& aRect) override; - nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) override; + nsEventStatus DispatchEvent(mozilla::WidgetGUIEvent* aEvent) override; void CaptureRollupEvents(bool aDoCapture) override; [[nodiscard]] nsresult GetAttention(int32_t aCycleCount) override; bool HasPendingInputEvent() override; diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm @@ -6,6 +6,7 @@ #include "nsCocoaWindow.h" +#include "mozilla/EventForwards.h" #include "nsArrayUtils.h" #include "MOZDynamicCursor.h" #include "nsIAppStartup.h" @@ -1429,7 +1430,6 @@ void nsCocoaWindow::DispatchAPZWheelInputEvent(InputData& aEvent) { return; } - nsEventStatus status; switch (aEvent.mInputType) { case PANGESTURE_INPUT: { if (MayStartSwipeForNonAPZ(aEvent.AsPanGestureInput())) { @@ -1447,7 +1447,7 @@ void nsCocoaWindow::DispatchAPZWheelInputEvent(InputData& aEvent) { return; } if (event.mMessage == eWheel && (event.mDeltaX != 0 || event.mDeltaY != 0)) { - DispatchEvent(&event, status); + DispatchEvent(&event); } } @@ -2409,8 +2409,7 @@ NSEvent* gLastDragMouseDownEvent = nil; // [strong] if (event.mMessage == eMouseExitFromWidget) { event.mExitFrom = Some(aExitFrom); } - nsEventStatus status; // ignored - mGeckoChild->DispatchEvent(&event, status); + mGeckoChild->DispatchEvent(&event); } - (void)handleMouseMoved:(NSEvent*)theEvent { @@ -6500,29 +6499,17 @@ bool nsCocoaWindow::DragEvent(unsigned int aMessage, } // Invokes callback and ProcessEvent methods on Event Listener object -nsresult nsCocoaWindow::DispatchEvent(WidgetGUIEvent* event, - nsEventStatus& aStatus) { +nsEventStatus nsCocoaWindow::DispatchEvent(WidgetGUIEvent* event) { RefPtr kungFuDeathGrip{this}; - aStatus = nsEventStatus_eIgnore; - if (event->mFlags.mIsSynthesizedForTests) { if (WidgetKeyboardEvent* keyEvent = event->AsKeyboardEvent()) { nsresult rv = mTextInputHandler->AttachNativeKeyEvent(*keyEvent); - NS_ENSURE_SUCCESS(rv, rv); + if (NS_FAILED(rv)) { + return nsEventStatus_eIgnore; + } } } - - // Top level windows can have a view attached which requires events be sent - // to the underlying base window and the view. Added when we combined the - // base chrome window with the main content child for custom titlebar - // rendering. - if (mAttachedWidgetListener) { - aStatus = mAttachedWidgetListener->HandleEvent(event, mUseAttachedEvents); - } else if (mWidgetListener) { - aStatus = mWidgetListener->HandleEvent(event, mUseAttachedEvents); - } - - return NS_OK; + return nsIWidget::DispatchEvent(event); } // aFullScreen should be the window's mInFullScreenMode. We don't have access to diff --git a/widget/gtk/IMContextWrapper.cpp b/widget/gtk/IMContextWrapper.cpp @@ -2553,11 +2553,10 @@ bool IMContextWrapper::DispatchCompositionCommitEvent( if (!dispatcher) { MOZ_ASSERT(aCommitString); MOZ_ASSERT(!aCommitString->IsEmpty()); - nsEventStatus status = nsEventStatus_eIgnore; WidgetContentCommandEvent insertTextEvent(true, eContentCommandInsertText, lastFocusedWindow); insertTextEvent.mString.emplace(*aCommitString); - lastFocusedWindow->DispatchEvent(&insertTextEvent, status); + lastFocusedWindow->DispatchEvent(&insertTextEvent); if (!insertTextEvent.mSucceeded) { MOZ_LOG(gIMELog, LogLevel::Error, @@ -2986,8 +2985,7 @@ void IMContextWrapper::SetCursorPosition(GtkIMContext* aContext) { mCompositionTargetRange.mOffset, 1); } } - nsEventStatus status; - mLastFocusedWindow->DispatchEvent(&queryCaretOrTextRectEvent, status); + mLastFocusedWindow->DispatchEvent(&queryCaretOrTextRectEvent); if (queryCaretOrTextRectEvent.Failed()) { MOZ_LOG(gIMELog, LogLevel::Error, ("0x%p SetCursorPosition(), FAILED, %s was failed", this, @@ -3027,8 +3025,6 @@ nsresult IMContextWrapper::GetCurrentParagraph(nsAString& aText, return NS_ERROR_NULL_POINTER; } - nsEventStatus status; - uint32_t selOffset = mCompositionStart; uint32_t selLength = mSelectedStringRemovedByComposition.Length(); @@ -3074,7 +3070,7 @@ nsresult IMContextWrapper::GetCurrentParagraph(nsAString& aText, WidgetQueryContentEvent queryTextContentEvent(true, eQueryTextContent, mLastFocusedWindow); queryTextContentEvent.InitForQueryTextContent(0, UINT32_MAX); - mLastFocusedWindow->DispatchEvent(&queryTextContentEvent, status); + mLastFocusedWindow->DispatchEvent(&queryTextContentEvent); if (NS_WARN_IF(queryTextContentEvent.Failed())) { return NS_ERROR_FAILURE; } @@ -3141,8 +3137,6 @@ nsresult IMContextWrapper::DeleteText(GtkIMContext* aContext, int32_t aOffset, } RefPtr<nsWindow> lastFocusedWindow(mLastFocusedWindow); - nsEventStatus status; - // First, we should cancel current composition because editor cannot // handle changing selection and deleting text. uint32_t selOffset; @@ -3177,7 +3171,7 @@ nsresult IMContextWrapper::DeleteText(GtkIMContext* aContext, int32_t aOffset, WidgetQueryContentEvent queryTextContentEvent(true, eQueryTextContent, mLastFocusedWindow); queryTextContentEvent.InitForQueryTextContent(0, UINT32_MAX); - mLastFocusedWindow->DispatchEvent(&queryTextContentEvent, status); + mLastFocusedWindow->DispatchEvent(&queryTextContentEvent); if (NS_WARN_IF(queryTextContentEvent.Failed())) { return NS_ERROR_FAILURE; } @@ -3231,7 +3225,7 @@ nsresult IMContextWrapper::DeleteText(GtkIMContext* aContext, int32_t aOffset, selectionEvent.mReversed = false; selectionEvent.mExpandToClusterBoundary = false; - lastFocusedWindow->DispatchEvent(&selectionEvent, status); + lastFocusedWindow->DispatchEvent(&selectionEvent); if (!selectionEvent.mSucceeded || lastFocusedWindow != mLastFocusedWindow || lastFocusedWindow->Destroyed()) { @@ -3255,7 +3249,7 @@ nsresult IMContextWrapper::DeleteText(GtkIMContext* aContext, int32_t aOffset, // Delete the selection WidgetContentCommandEvent contentCommandEvent(true, eContentCommandDelete, mLastFocusedWindow); - mLastFocusedWindow->DispatchEvent(&contentCommandEvent, status); + mLastFocusedWindow->DispatchEvent(&contentCommandEvent); if (!contentCommandEvent.mSucceeded || lastFocusedWindow != mLastFocusedWindow || @@ -3318,10 +3312,9 @@ bool IMContextWrapper::EnsureToCacheContentSelection( return false; } - nsEventStatus status; WidgetQueryContentEvent querySelectedTextEvent(true, eQuerySelectedText, dispatcherWindow); - dispatcherWindow->DispatchEvent(&querySelectedTextEvent, status); + dispatcherWindow->DispatchEvent(&querySelectedTextEvent); if (NS_WARN_IF(querySelectedTextEvent.Failed())) { MOZ_LOG(gIMELog, LogLevel::Error, ("0x%p EnsureToCacheContentSelection(), FAILED, due to " diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp @@ -619,21 +619,7 @@ nsIWidgetListener* nsWindow::GetListener() { return mAttachedWidgetListener ? mAttachedWidgetListener : mWidgetListener; } -nsresult nsWindow::DispatchEvent(WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) { -#ifdef DEBUG - debug_DumpEvent(stdout, aEvent->mWidget, aEvent, "something", 0); -#endif - aStatus = nsEventStatus_eIgnore; - nsIWidgetListener* listener = GetListener(); - if (listener) { - aStatus = listener->HandleEvent(aEvent, mUseAttachedEvents); - } - - return NS_OK; -} - -void nsWindow::OnDestroy(void) { +void nsWindow::OnDestroy() { if (mOnDestroyCalled) { return; } @@ -5250,17 +5236,15 @@ void nsWindow::OnContainerFocusOutEvent(GdkEventFocus* aEvent) { } bool nsWindow::DispatchCommandEvent(nsAtom* aCommand) { - nsEventStatus status; WidgetCommandEvent appCommandEvent(true, aCommand, this); - DispatchEvent(&appCommandEvent, status); - return TRUE; + DispatchEvent(&appCommandEvent); + return true; } bool nsWindow::DispatchContentCommandEvent(EventMessage aMsg) { - nsEventStatus status; WidgetContentCommandEvent event(true, aMsg, this); - DispatchEvent(&event, status); - return TRUE; + DispatchEvent(&event); + return true; } WidgetEventTime nsWindow::GetWidgetEventTime(guint32 aEventTime) { diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h @@ -167,9 +167,6 @@ class nsWindow final : public nsIWidget { NS_INLINE_DECL_REFCOUNTING_INHERITED(nsWindow, nsIWidget) - nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) override; - // called when we are destroyed void OnDestroy() override; diff --git a/widget/headless/HeadlessWidget.cpp b/widget/headless/HeadlessWidget.cpp @@ -401,23 +401,6 @@ bool HeadlessWidget::GetEditCommands(NativeKeyBindingsType aType, return true; } -nsresult HeadlessWidget::DispatchEvent(WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) { -#ifdef DEBUG - debug_DumpEvent(stdout, aEvent->mWidget, aEvent, "HeadlessWidget", 0); -#endif - - aStatus = nsEventStatus_eIgnore; - - if (mAttachedWidgetListener) { - aStatus = mAttachedWidgetListener->HandleEvent(aEvent, mUseAttachedEvents); - } else if (mWidgetListener) { - aStatus = mWidgetListener->HandleEvent(aEvent, mUseAttachedEvents); - } - - return NS_OK; -} - nsresult HeadlessWidget::SynthesizeNativeMouseEvent( LayoutDeviceIntPoint aPoint, NativeMouseMessage aNativeMessage, MouseButton aButton, nsIWidget::Modifiers aModifierFlags, diff --git a/widget/headless/HeadlessWidget.h b/widget/headless/HeadlessWidget.h @@ -94,9 +94,6 @@ class HeadlessWidget final : public nsIWidget { NativeKeyBindingsType aType, const WidgetKeyboardEvent& aEvent, nsTArray<CommandInt>& aCommands) override; - nsresult DispatchEvent(WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) override; - nsresult SynthesizeNativeMouseEvent( LayoutDeviceIntPoint aPoint, NativeMouseMessage aNativeMessage, mozilla::MouseButton aButton, nsIWidget::Modifiers aModifierFlags, diff --git a/widget/nsIWidget.cpp b/widget/nsIWidget.cpp @@ -676,6 +676,16 @@ LayoutDeviceIntSize nsIWidget::NormalSizeModeClientToWindowSizeDifference() { return {margin.LeftRight(), margin.TopBottom()}; } +nsEventStatus nsIWidget::DispatchEvent(WidgetGUIEvent* aEvent) { + if (mAttachedWidgetListener) { + return mAttachedWidgetListener->HandleEvent(aEvent, mUseAttachedEvents); + } + if (mWidgetListener) { + return mWidgetListener->HandleEvent(aEvent, mUseAttachedEvents); + } + return nsEventStatus_eIgnore; +} + RefPtr<mozilla::VsyncDispatcher> nsIWidget::GetVsyncDispatcher() { return nullptr; } @@ -1142,9 +1152,8 @@ nsEventStatus nsIWidget::ProcessUntransformedAPZEvent( // Make a copy of the original event for the APZCCallbackHelper helpers that // we call later, because the event passed to DispatchEvent can get mutated in // ways that we don't want (i.e. touch points can get stripped out). - nsEventStatus status; UniquePtr<WidgetEvent> original(aEvent->Duplicate()); - DispatchEvent(aEvent, status); + nsEventStatus status = DispatchEvent(aEvent); if (mAPZC && !InputAPZContext::WasRoutedToChildProcess() && !InputAPZContext::WasDropped() && inputBlockId) { @@ -1295,9 +1304,7 @@ void nsIWidget::DispatchTouchInput(MultiTouchInput& aInput) { ProcessUntransformedAPZEvent(&event, result); } else { WidgetTouchEvent event = aInput.ToWidgetEvent(this); - - nsEventStatus status; - DispatchEvent(&event, status); + DispatchEvent(&event); } } @@ -1315,8 +1322,7 @@ void nsIWidget::DispatchPanGestureInput(PanGestureInput& aInput) { ProcessUntransformedAPZEvent(&event, result); } else { WidgetWheelEvent event = aInput.ToWidgetEvent(this); - nsEventStatus status; - DispatchEvent(&event, status); + DispatchEvent(&event); } } @@ -1333,8 +1339,7 @@ void nsIWidget::DispatchPinchGestureInput(PinchGestureInput& aInput) { ProcessUntransformedAPZEvent(&event, result); } else { WidgetWheelEvent event = aInput.ToWidgetEvent(this); - nsEventStatus status; - DispatchEvent(&event, status); + DispatchEvent(&event); } } @@ -1403,7 +1408,7 @@ nsIWidget::ContentAndAPZEventStatus nsIWidget::DispatchInputEvent( } } - DispatchEvent(aEvent, status.mContentStatus); + status.mContentStatus = DispatchEvent(aEvent); return status; } @@ -1430,9 +1435,7 @@ void nsIWidget::DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) { } bool nsIWidget::DispatchWindowEvent(WidgetGUIEvent& event) { - nsEventStatus status; - DispatchEvent(&event, status); - return ConvertStatus(status); + return ConvertStatus(DispatchEvent(&event)); } Document* nsIWidget::GetDocument() const { @@ -2418,8 +2421,7 @@ bool nsIWidget::MayStartSwipeForNonAPZ(const PanGestureInput& aPanInput) { WidgetWheelEvent event = aPanInput.ToWidgetEvent(this); event.mCanTriggerSwipe = swipeInfo.wantsSwipe; - nsEventStatus status; - DispatchEvent(&event, status); + DispatchEvent(&event); if (swipeInfo.wantsSwipe) { if (context.WasRoutedToChildProcess()) { // We don't know whether this event can start a swipe, so we need diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h @@ -1494,8 +1494,7 @@ class nsIWidget : public nsSupportsWeakReference { /** * Dispatches an event to the widget */ - virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* event, - nsEventStatus& aStatus) = 0; + virtual nsEventStatus DispatchEvent(mozilla::WidgetGUIEvent*); /** * Dispatches an event to APZ only. diff --git a/widget/tests/gtest/MockWinWidget.h b/widget/tests/gtest/MockWinWidget.h @@ -57,10 +57,6 @@ class MockWinWidget : public nsIWidget { LayoutDeviceIntPoint WidgetToScreenOffset() override { return LayoutDeviceIntPoint(0, 0); } - nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) override { - return NS_OK; - } void SetInputContext(const InputContext& aContext, const InputContextAction& aAction) override {} InputContext GetInputContext() override { abort(); } diff --git a/widget/uikit/nsWindow.h b/widget/uikit/nsWindow.h @@ -84,8 +84,6 @@ class nsWindow final : public nsIWidget { nsresult SetTitle(const nsAString& aTitle) override { return NS_OK; } void Invalidate(const LayoutDeviceIntRect& aRect) override; - nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) override; void WillPaintWindow(); bool PaintWindow(LayoutDeviceIntRegion aRegion); diff --git a/widget/uikit/nsWindow.mm b/widget/uikit/nsWindow.mm @@ -247,8 +247,7 @@ class nsAutoRetainUIKitObject { event.mButton = MouseButton::ePrimary; event.mInputSource = mozilla::dom::MouseEvent_Binding::MOZ_SOURCE_UNKNOWN; - nsEventStatus status; - aWindow->DispatchEvent(&event, status); + aWindow->DispatchEvent(&event); } - (void)handleTap:(UITapGestureRecognizer*)sender { @@ -1034,21 +1033,6 @@ LayoutDeviceIntPoint nsWindow::WidgetToScreenOffset() { return offset; } -nsresult nsWindow::DispatchEvent(mozilla::WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) { - aStatus = nsEventStatus_eIgnore; - nsCOMPtr<nsIWidget> kungFuDeathGrip(aEvent->mWidget); - (void)kungFuDeathGrip; // Not used within this function - - if (mAttachedWidgetListener) { - aStatus = mAttachedWidgetListener->HandleEvent(aEvent, mUseAttachedEvents); - } else if (mWidgetListener) { - aStatus = mWidgetListener->HandleEvent(aEvent, mUseAttachedEvents); - } - - return NS_OK; -} - void nsWindow::SetInputContext(const InputContext& aContext, const InputContextAction& aAction) { NS_OBJC_BEGIN_TRY_IGNORE_BLOCK; diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp @@ -3998,34 +3998,6 @@ WidgetEventTime nsWindow::CurrentMessageWidgetEventTime() const { * **************************************************************/ -// Main event dispatch. Invokes callback and ProcessEvent method on -// Event Listener object. Part of nsIWidget. -nsresult nsWindow::DispatchEvent(WidgetGUIEvent* event, - nsEventStatus& aStatus) { -#ifdef WIDGET_DEBUG_OUTPUT - debug_DumpEvent(stdout, event->mWidget, event, "something", (int32_t)mWnd); -#endif // WIDGET_DEBUG_OUTPUT - - aStatus = nsEventStatus_eIgnore; - - // Top level windows can have a view attached which requires events be sent - // to the underlying base window and the view. Added when we combined the - // base chrome window with the main content child for nc client area (title - // bar) rendering. - if (mAttachedWidgetListener) { - aStatus = mAttachedWidgetListener->HandleEvent(event, mUseAttachedEvents); - } else if (mWidgetListener) { - aStatus = mWidgetListener->HandleEvent(event, mUseAttachedEvents); - } - - // the window can be destroyed during processing of seemingly innocuous events - // like, say, mousedowns due to the magic of scripting. mousedowns will return - // nsEventStatus_eIgnore, which causes problems with the deleted window. - // therefore: - if (mOnDestroyCalled) aStatus = nsEventStatus_eConsumeNoDefault; - return NS_OK; -} - bool nsWindow::DispatchStandardEvent(EventMessage aMsg) { WidgetGUIEvent event(true, aMsg, this); InitEvent(event); @@ -4040,8 +4012,7 @@ bool nsWindow::DispatchKeyboardEvent(WidgetKeyboardEvent* event) { } bool nsWindow::DispatchContentCommandEvent(WidgetContentCommandEvent* aEvent) { - nsEventStatus status; - DispatchEvent(aEvent, status); + nsEventStatus status = DispatchEvent(aEvent); return ConvertStatus(status); } @@ -5862,8 +5833,7 @@ bool nsWindow::ProcessMessageInternal(UINT msg, WPARAM& wParam, LPARAM& lParam, WidgetGestureNotifyEvent gestureNotifyEvent(true, eGestureNotify, this); gestureNotifyEvent.mRefPoint = LayoutDeviceIntPoint::FromUnknownPoint(touchPoint); - nsEventStatus status; - DispatchEvent(&gestureNotifyEvent, status); + DispatchEvent(&gestureNotifyEvent); mDisplayPanFeedback = gestureNotifyEvent.mDisplayPanFeedback; if (!mTouchWindow) { mGesture.SetWinGestureSupport(mWnd, gestureNotifyEvent.mPanDirection); @@ -6811,8 +6781,6 @@ bool nsWindow::OnGesture(WPARAM wParam, LPARAM lParam) { if (!mGesture.ProcessPanMessage(mWnd, wParam, lParam)) return false; // ignore - nsEventStatus status; - WidgetWheelEvent wheelEvent(true, eWheel, this); ModifierKeyState modifierKeyState; @@ -6825,7 +6793,7 @@ bool nsWindow::OnGesture(WPARAM wParam, LPARAM lParam) { bool endFeedback = true; if (mGesture.PanDeltaToPixelScroll(wheelEvent)) { - DispatchEvent(&wheelEvent, status); + DispatchEvent(&wheelEvent); } if (mDisplayPanFeedback) { @@ -6856,8 +6824,7 @@ bool nsWindow::OnGesture(WPARAM wParam, LPARAM lParam) { event.mTimeStamp = GetMessageTimeStamp(::GetMessageTime()); event.mInputSource = MouseEvent_Binding::MOZ_SOURCE_TOUCH; - nsEventStatus status; - DispatchEvent(&event, status); + nsEventStatus status = DispatchEvent(&event); if (status == nsEventStatus_eIgnore) { return false; // Ignored, fall through } diff --git a/widget/windows/nsWindow.h b/widget/windows/nsWindow.h @@ -237,8 +237,6 @@ class nsWindow final : public nsIWidget { void SetIcon(const nsAString& aIconSpec) override; LayoutDeviceIntPoint WidgetToScreenOffset() override; LayoutDeviceIntMargin NormalSizeModeClientToWindowMargin() override; - nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) override; void EnableDragDrop(bool aEnable) override; void CaptureMouse(bool aCapture); void CaptureRollupEvents(bool aDoCapture) override;