mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-03 14:28:39 +09:00
Issue #2019 - Follow-up: Make autocomplete and satchel listen to keypress events in the system event group
The autocomplete module listens to keypress events for both printable keys and non-printable keys a lot. However, we're stopping dispatching keypress events for non-printable keys in the default event group of web content. This means that autocomplete should listen to keypress events in the system event group. Note that it's difficult to globally change keypress event listeners to keydown event listeners because if we stop keypress events at preceding keydown event in autocomplete or satchel modules, some other modules fail to handle keydown or keypress events before autocomplete, and it's not easy to investigate which keypress event listener in which modules should be changed to a keydown event listener. Therefore, this patch doesn't do that, and uses the event group approach.
This commit is contained in:
parent
5699d9673f
commit
808332c2c1
2 changed files with 49 additions and 29 deletions
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "nsFormFillController.h"
|
||||
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
|
||||
#include "nsIFormAutoComplete.h"
|
||||
|
|
@ -40,6 +41,7 @@
|
|||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsFocusManager.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION(nsFormFillController,
|
||||
|
|
@ -1188,23 +1190,29 @@ nsFormFillController::AddWindowListeners(nsPIDOMWindowOuter* aWindow)
|
|||
if (!target)
|
||||
return;
|
||||
|
||||
target->AddEventListener(NS_LITERAL_STRING("focus"), this,
|
||||
true, false);
|
||||
target->AddEventListener(NS_LITERAL_STRING("blur"), this,
|
||||
true, false);
|
||||
target->AddEventListener(NS_LITERAL_STRING("pagehide"), this,
|
||||
true, false);
|
||||
target->AddEventListener(NS_LITERAL_STRING("mousedown"), this,
|
||||
true, false);
|
||||
target->AddEventListener(NS_LITERAL_STRING("input"), this,
|
||||
true, false);
|
||||
target->AddEventListener(NS_LITERAL_STRING("keypress"), this, true, false);
|
||||
target->AddEventListener(NS_LITERAL_STRING("compositionstart"), this,
|
||||
true, false);
|
||||
target->AddEventListener(NS_LITERAL_STRING("compositionend"), this,
|
||||
true, false);
|
||||
target->AddEventListener(NS_LITERAL_STRING("contextmenu"), this,
|
||||
true, false);
|
||||
EventListenerManager* elm = target->GetOrCreateListenerManager();
|
||||
if (NS_WARN_IF(!elm)) {
|
||||
return;
|
||||
}
|
||||
|
||||
elm->AddEventListenerByType(this, NS_LITERAL_STRING("focus"),
|
||||
TrustedEventsAtCapture());
|
||||
elm->AddEventListenerByType(this, NS_LITERAL_STRING("blur"),
|
||||
TrustedEventsAtCapture());
|
||||
elm->AddEventListenerByType(this, NS_LITERAL_STRING("pagehide"),
|
||||
TrustedEventsAtCapture());
|
||||
elm->AddEventListenerByType(this, NS_LITERAL_STRING("mousedown"),
|
||||
TrustedEventsAtCapture());
|
||||
elm->AddEventListenerByType(this, NS_LITERAL_STRING("input"),
|
||||
TrustedEventsAtCapture());
|
||||
elm->AddEventListenerByType(this, NS_LITERAL_STRING("keypress"),
|
||||
TrustedEventsAtSystemGroupCapture());
|
||||
elm->AddEventListenerByType(this, NS_LITERAL_STRING("compositionstart"),
|
||||
TrustedEventsAtCapture());
|
||||
elm->AddEventListenerByType(this, NS_LITERAL_STRING("compositionend"),
|
||||
TrustedEventsAtCapture());
|
||||
elm->AddEventListenerByType(this, NS_LITERAL_STRING("contextmenu"),
|
||||
TrustedEventsAtCapture());
|
||||
|
||||
// Note that any additional listeners added should ensure that they ignore
|
||||
// untrusted events, which might be sent by content that's up to no good.
|
||||
|
|
@ -1226,17 +1234,29 @@ nsFormFillController::RemoveWindowListeners(nsPIDOMWindowOuter* aWindow)
|
|||
if (!target)
|
||||
return;
|
||||
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("focus"), this, true);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("blur"), this, true);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("pagehide"), this, true);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("mousedown"), this, true);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("input"), this, true);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("keypress"), this, true);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("compositionstart"), this,
|
||||
true);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("compositionend"), this,
|
||||
true);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("contextmenu"), this, true);
|
||||
EventListenerManager* elm = target->GetOrCreateListenerManager();
|
||||
if (NS_WARN_IF(!elm)) {
|
||||
return;
|
||||
}
|
||||
|
||||
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("focus"),
|
||||
TrustedEventsAtCapture());
|
||||
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("blur"),
|
||||
TrustedEventsAtCapture());
|
||||
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("pagehide"),
|
||||
TrustedEventsAtCapture());
|
||||
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("mousedown"),
|
||||
TrustedEventsAtCapture());
|
||||
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("input"),
|
||||
TrustedEventsAtCapture());
|
||||
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("keypress"),
|
||||
TrustedEventsAtSystemGroupCapture());
|
||||
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("compositionstart"),
|
||||
TrustedEventsAtCapture());
|
||||
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("compositionend"),
|
||||
TrustedEventsAtCapture());
|
||||
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("contextmenu"),
|
||||
TrustedEventsAtCapture());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue