Bug 1348786 - Move nsChildView::DispatchWindowEvent(WidgetGUIEvent&) into nsBaseWidget. r=tnikkel

Differential Revision: https://phabricator.services.mozilla.com/D134359
This commit is contained in:
Hiroyuki Ikezoe 2022-01-05 09:08:04 +00:00
Родитель 5c5873c68f
Коммит 6b5874286f
13 изменённых файлов: 34 добавлений и 47 удалений

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

@ -347,9 +347,6 @@ class nsChildView final : public nsBaseWidget {
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) override { return false; }
static bool ConvertStatus(nsEventStatus aStatus) {
return aStatus == nsEventStatus_eConsumeNoDefault;
}
virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, nsEventStatus& aStatus) override;
virtual bool WidgetTypeSupportsAcceleration() override;
@ -413,9 +410,6 @@ class nsChildView final : public nsBaseWidget {
uint32_t aModifierFlags) override;
// Mac specific methods
virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent& event);
void WillPaintWindow();
bool PaintWindow(LayoutDeviceIntRegion aRegion);
bool PaintWindowInDrawTarget(mozilla::gfx::DrawTarget* aDT, const LayoutDeviceIntRegion& aRegion,

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

@ -1298,12 +1298,6 @@ nsresult nsChildView::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatu
return NS_OK;
}
bool nsChildView::DispatchWindowEvent(WidgetGUIEvent& event) {
nsEventStatus status;
DispatchEvent(&event, status);
return ConvertStatus(status);
}
nsIWidget* nsChildView::GetWidgetForListenerEvents() {
// If there is no listener, use the parent popup's listener if that exists.
if (!mWidgetListener && mParentWidget && mParentWidget->WindowType() == eWindowType_popup) {

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

@ -1141,6 +1141,12 @@ void nsBaseWidget::DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) {
}
}
bool nsBaseWidget::DispatchWindowEvent(WidgetGUIEvent& event) {
nsEventStatus status;
DispatchEvent(&event, status);
return ConvertStatus(status);
}
Document* nsBaseWidget::GetDocument() const {
if (mWidgetListener) {
if (PresShell* presShell = mWidgetListener->GetPresShell()) {

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

@ -312,6 +312,8 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
mozilla::WidgetInputEvent* aEvent) override;
void DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) override;
bool DispatchWindowEvent(mozilla::WidgetGUIEvent& event) override;
void SetConfirmedTargetAPZC(
uint64_t aInputBlockId,
const nsTArray<ScrollableLayerGuid>& aTargets) const override;
@ -637,6 +639,10 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
void DispatchPanGestureInput(mozilla::PanGestureInput& aInput);
void DispatchPinchGestureInput(mozilla::PinchGestureInput& aInput);
static bool ConvertStatus(nsEventStatus aStatus) {
return aStatus == nsEventStatus_eConsumeNoDefault;
}
protected:
// Returns whether compositing should use an external surface size.
virtual bool UseExternalCompositingSurface() const { return false; }

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

@ -1330,6 +1330,12 @@ class nsIWidget : public nsISupports {
*/
virtual void DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) = 0;
/*
* Dispatch a gecko event for this widget.
* Returns true if it's consumed. Otherwise, false.
*/
virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent& event) = 0;
// A structure that groups the statuses from APZ dispatch and content
// dispatch.
struct ContentAndAPZEventStatus {

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

@ -1579,7 +1579,7 @@ void IMMHandler::DispatchEvent(nsWindow* aWindow, WidgetGUIEvent& aEvent) {
return;
}
aWindow->DispatchWindowEvent(&aEvent);
aWindow->DispatchWindowEvent(aEvent);
}
void IMMHandler::DispatchCompositionChangeEvent(nsWindow* aWindow,

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

@ -2167,7 +2167,7 @@ bool NativeKey::DispatchCommandEvent(uint32_t aEventCommand) const {
"%s app command event...",
this, nsAtomCString(command).get()));
bool ok =
mWidget->DispatchWindowEvent(&appCommandEvent) || mWidget->Destroyed();
mWidget->DispatchWindowEvent(appCommandEvent) || mWidget->Destroyed();
MOZ_LOG(
gKeyLog, LogLevel::Info,
("%p NativeKey::DispatchCommandEvent(), dispatched app command event, "
@ -2319,7 +2319,7 @@ bool NativeKey::HandleAppCommandMessage() const {
gKeyLog, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), dispatching %s event...",
this, ToChar(contentCommandMessage)));
mWidget->DispatchWindowEvent(&contentCommandEvent);
mWidget->DispatchWindowEvent(contentCommandEvent);
MOZ_LOG(gKeyLog, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), dispatched %s event",
this, ToChar(contentCommandMessage)));

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

@ -2260,7 +2260,7 @@ void TSFTextStore::DispatchEvent(WidgetGUIEvent& aEvent) {
if (!aEvent.AsQueryContentEvent()) {
mDeferNotifyingTSF = true;
}
mWidget->DispatchWindowEvent(&aEvent);
mWidget->DispatchWindowEvent(aEvent);
}
void TSFTextStore::FlushPendingActions() {

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

@ -1069,7 +1069,7 @@ bool IMEHandler::MaybeCreateNativeCaret(nsWindow* aWindow) {
options.mRelativeToInsertionPoint = true;
queryCaretRectEvent.InitForQueryCaretRect(0, options);
aWindow->DispatchWindowEvent(&queryCaretRectEvent);
aWindow->DispatchWindowEvent(queryCaretRectEvent);
if (NS_WARN_IF(queryCaretRectEvent.Failed())) {
return false;
}

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

@ -1303,7 +1303,7 @@ bool MouseScrollHandler::Device::Elantech::HandleKeyMessage(
// nullptr as an argument to indicate using the coordinate from the last
// available window message.
InitEvent(aWidget, appCommandEvent, nullptr);
aWidget->DispatchWindowEvent(&appCommandEvent);
aWidget->DispatchWindowEvent(appCommandEvent);
} else {
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
("MouseScroll::Device::Elantech::HandleKeyMessage(): Consumed"));

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

@ -4292,7 +4292,7 @@ bool nsWindow::DispatchStandardEvent(EventMessage aMsg) {
WidgetGUIEvent event(true, aMsg, this);
InitEvent(event);
bool result = DispatchWindowEvent(&event);
bool result = DispatchWindowEvent(event);
return result;
}
@ -4313,12 +4313,6 @@ bool nsWindow::DispatchWheelEvent(WidgetWheelEvent* aEvent) {
return ConvertStatus(status);
}
bool nsWindow::DispatchWindowEvent(WidgetGUIEvent* event) {
nsEventStatus status;
DispatchEvent(event, status);
return ConvertStatus(status);
}
// Recursively dispatch synchronous paints for nsIWidget
// descendants with invalidated rectangles.
BOOL CALLBACK nsWindow::DispatchStarvedPaints(HWND aWnd, LPARAM aMsg) {
@ -4707,10 +4701,6 @@ bool nsWindow::IsTopLevelMouseExit(HWND aWnd) {
return WinUtils::GetTopLevelHWND(aWnd) != mouseTopLevel;
}
bool nsWindow::ConvertStatus(nsEventStatus aStatus) {
return aStatus == nsEventStatus_eConsumeNoDefault;
}
/**************************************************************
*
* SECTION: IPC
@ -6149,38 +6139,38 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case WM_CLEAR: {
WidgetContentCommandEvent command(true, eContentCommandDelete, this);
DispatchWindowEvent(&command);
DispatchWindowEvent(command);
result = true;
} break;
case WM_CUT: {
WidgetContentCommandEvent command(true, eContentCommandCut, this);
DispatchWindowEvent(&command);
DispatchWindowEvent(command);
result = true;
} break;
case WM_COPY: {
WidgetContentCommandEvent command(true, eContentCommandCopy, this);
DispatchWindowEvent(&command);
DispatchWindowEvent(command);
result = true;
} break;
case WM_PASTE: {
WidgetContentCommandEvent command(true, eContentCommandPaste, this);
DispatchWindowEvent(&command);
DispatchWindowEvent(command);
result = true;
} break;
case EM_UNDO: {
WidgetContentCommandEvent command(true, eContentCommandUndo, this);
DispatchWindowEvent(&command);
DispatchWindowEvent(command);
*aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
result = true;
} break;
case EM_REDO: {
WidgetContentCommandEvent command(true, eContentCommandRedo, this);
DispatchWindowEvent(&command);
DispatchWindowEvent(command);
*aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
result = true;
} break;
@ -6191,7 +6181,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
if (wParam == 0 || wParam == CF_TEXT || wParam == CF_UNICODETEXT) {
WidgetContentCommandEvent command(true, eContentCommandPaste, this,
true);
DispatchWindowEvent(&command);
DispatchWindowEvent(command);
*aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
result = true;
}
@ -6199,14 +6189,14 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case EM_CANUNDO: {
WidgetContentCommandEvent command(true, eContentCommandUndo, this, true);
DispatchWindowEvent(&command);
DispatchWindowEvent(command);
*aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
result = true;
} break;
case EM_CANREDO: {
WidgetContentCommandEvent command(true, eContentCommandRedo, this, true);
DispatchWindowEvent(&command);
DispatchWindowEvent(command);
*aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
result = true;
} break;

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

@ -120,7 +120,6 @@ class nsWindow final : public nsWindowBase {
virtual void InitEvent(mozilla::WidgetGUIEvent& aEvent,
LayoutDeviceIntPoint* aPoint = nullptr) override;
virtual WidgetEventTime CurrentMessageWidgetEventTime() const override;
virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent* aEvent) override;
virtual bool DispatchKeyboardEvent(
mozilla::WidgetKeyboardEvent* aEvent) override;
virtual bool DispatchWheelEvent(mozilla::WidgetWheelEvent* aEvent) override;
@ -455,8 +454,6 @@ class nsWindow final : public nsWindowBase {
static bool EventIsInsideWindow(
nsWindow* aWindow,
mozilla::Maybe<POINT> aEventPoint = mozilla::Nothing());
// Convert nsEventStatus value to a windows boolean
static bool ConvertStatus(nsEventStatus aStatus);
static void PostSleepWakeNotification(const bool aIsSleepMode);
int32_t ClientMarginHitTestPoint(int32_t mx, int32_t my);
void SetWindowButtonRect(WindowButtonType aButtonType,

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

@ -52,12 +52,6 @@ class nsWindowBase : public nsBaseWidget {
*/
virtual WidgetEventTime CurrentMessageWidgetEventTime() const = 0;
/*
* Dispatch a gecko event for this widget.
* Returns true if it's consumed. Otherwise, false.
*/
virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent* aEvent) = 0;
/*
* Dispatch a gecko keyboard event for this widget. This
* is called by KeyboardLayout to dispatch gecko events.