From a7bc62dcfe5495c8b53532c1b585af07171b4403 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Tue, 26 Jun 2018 13:53:12 +0200 Subject: Issue #12 Part 2: Stop using nsIDOMEvent in IsAcceptableInputEvent. --- editor/libeditor/EditorBase.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'editor/libeditor/EditorBase.cpp') diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index 0c4a2a41d..f7988cd1a 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -5092,19 +5092,16 @@ EditorBase::IsActiveInDOMWindow() } bool -EditorBase::IsAcceptableInputEvent(nsIDOMEvent* aEvent) +EditorBase::IsAcceptableInputEvent(WidgetGUIEvent* aGUIEvent) { // If the event is trusted, the event should always cause input. - NS_ENSURE_TRUE(aEvent, false); - - WidgetEvent* widgetEvent = aEvent->WidgetEventPtr(); - if (NS_WARN_IF(!widgetEvent)) { + if (NS_WARN_IF(!aGUIEvent)) { return false; } // If this is dispatched by using cordinates but this editor doesn't have // focus, we shouldn't handle it. - if (widgetEvent->IsUsingCoordinates()) { + if (aGUIEvent->IsUsingCoordinates()) { nsCOMPtr focusedContent = GetFocusedContent(); if (!focusedContent) { return false; @@ -5117,8 +5114,7 @@ EditorBase::IsAcceptableInputEvent(nsIDOMEvent* aEvent) // Note that if we allow to handle such events, editor may be confused by // strange event order. bool needsWidget = false; - WidgetGUIEvent* widgetGUIEvent = nullptr; - switch (widgetEvent->mMessage) { + switch (aGUIEvent->mMessage) { case eUnidentifiedEvent: // If events are not created with proper event interface, their message // are initialized with eUnidentifiedEvent. Let's ignore such event. @@ -5130,25 +5126,26 @@ EditorBase::IsAcceptableInputEvent(nsIDOMEvent* aEvent) case eCompositionCommitAsIs: // Don't allow composition events whose internal event are not // WidgetCompositionEvent. - widgetGUIEvent = aEvent->WidgetEventPtr()->AsCompositionEvent(); + if (!aGUIEvent->AsCompositionEvent()) { + return false; + } needsWidget = true; break; default: break; } - if (needsWidget && - (!widgetGUIEvent || !widgetGUIEvent->mWidget)) { + if (needsWidget && !aGUIEvent->mWidget) { return false; } // Accept all trusted events. - if (widgetEvent->IsTrusted()) { + if (aGUIEvent->IsTrusted()) { return true; } // Ignore untrusted mouse event. // XXX Why are we handling other untrusted input events? - if (widgetEvent->AsMouseEventBase()) { + if (aGUIEvent->AsMouseEventBase()) { return false; } -- cgit v1.2.3