mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 15:28:39 +09:00
Issue #12 Part 2: Stop using nsIDOMEvent in IsAcceptableInputEvent.
This commit is contained in:
parent
32326ee192
commit
550c8977c1
9 changed files with 87 additions and 54 deletions
|
|
@ -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<nsIContent> 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue