mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 23:23:33 +00:00
Bug 1074971 - Add support for reserved commandkey combinations that can't be handled by content (e10s-only feature). r=smaug
This commit is contained in:
parent
30104842ba
commit
5d2847b10c
@ -333,19 +333,27 @@ nsXBLWindowKeyHandler::HandleEventOnCapture(nsIDOMKeyEvent* aEvent)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!HasHandlerForEvent(aEvent)) {
|
||||
bool aReservedForChrome = false;
|
||||
if (!HasHandlerForEvent(aEvent, &aReservedForChrome)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If this event hasn't been marked as mNoCrossProcessBoundaryForwarding
|
||||
// yet, it means it wasn't processed by content. We'll not call any
|
||||
// of the handlers at this moment, and will wait for the event to be
|
||||
// redispatched with mNoCrossProcessBoundaryForwarding = 1 to process it.
|
||||
if (aReservedForChrome) {
|
||||
// For reserved commands (such as Open New Tab), we don't to wait for
|
||||
// the content to answer (so mWantReplyFromContentProcess remains false),
|
||||
// neither to give a chance for content to override its behavior.
|
||||
widgetEvent->mFlags.mNoCrossProcessBoundaryForwarding = true;
|
||||
} else {
|
||||
// Inform the child process that this is a event that we want a reply
|
||||
// from.
|
||||
widgetEvent->mFlags.mWantReplyFromContentProcess = true;
|
||||
|
||||
// Inform the child process that this is a event that we want a reply
|
||||
// from.
|
||||
widgetEvent->mFlags.mWantReplyFromContentProcess = 1;
|
||||
aEvent->StopPropagation();
|
||||
// If this event hadn't been marked as mNoCrossProcessBoundaryForwarding
|
||||
// yet, it means it wasn't processed by content. We'll not call any
|
||||
// of the handlers at this moment, and will wait for the event to be
|
||||
// redispatched with mNoCrossProcessBoundaryForwarding = 1 to process it.
|
||||
aEvent->StopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@ -429,14 +437,16 @@ bool
|
||||
nsXBLWindowKeyHandler::WalkHandlersInternal(nsIDOMKeyEvent* aKeyEvent,
|
||||
nsIAtom* aEventType,
|
||||
nsXBLPrototypeHandler* aHandler,
|
||||
bool aExecute)
|
||||
bool aExecute,
|
||||
bool* aOutReservedForChrome)
|
||||
{
|
||||
nsAutoTArray<nsShortcutCandidate, 10> accessKeys;
|
||||
nsContentUtils::GetAccelKeyCandidates(aKeyEvent, accessKeys);
|
||||
|
||||
if (accessKeys.IsEmpty()) {
|
||||
return WalkHandlersAndExecute(aKeyEvent, aEventType, aHandler,
|
||||
0, IgnoreModifierState(), aExecute);
|
||||
0, IgnoreModifierState(),
|
||||
aExecute, aOutReservedForChrome);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < accessKeys.Length(); ++i) {
|
||||
@ -444,7 +454,8 @@ nsXBLWindowKeyHandler::WalkHandlersInternal(nsIDOMKeyEvent* aKeyEvent,
|
||||
IgnoreModifierState ignoreModifierState;
|
||||
ignoreModifierState.mShift = key.mIgnoreShift;
|
||||
if (WalkHandlersAndExecute(aKeyEvent, aEventType, aHandler,
|
||||
key.mCharCode, ignoreModifierState, aExecute)) {
|
||||
key.mCharCode, ignoreModifierState,
|
||||
aExecute, aOutReservedForChrome)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -458,7 +469,8 @@ nsXBLWindowKeyHandler::WalkHandlersAndExecute(
|
||||
nsXBLPrototypeHandler* aHandler,
|
||||
uint32_t aCharCode,
|
||||
const IgnoreModifierState& aIgnoreModifierState,
|
||||
bool aExecute)
|
||||
bool aExecute,
|
||||
bool* aOutReservedForChrome)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -519,6 +531,12 @@ nsXBLWindowKeyHandler::WalkHandlersAndExecute(
|
||||
if (value.IsEmpty()) {
|
||||
continue; // nothing to do
|
||||
}
|
||||
|
||||
if (aOutReservedForChrome) {
|
||||
// The caller wants to know if this is a reserved command
|
||||
commandElt->GetAttribute(NS_LITERAL_STRING("reserved"), value);
|
||||
*aOutReservedForChrome = value.EqualsLiteral("true");
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<EventTarget> piTarget;
|
||||
@ -560,7 +578,8 @@ nsXBLWindowKeyHandler::WalkHandlersAndExecute(
|
||||
}
|
||||
|
||||
bool
|
||||
nsXBLWindowKeyHandler::HasHandlerForEvent(nsIDOMKeyEvent* aEvent)
|
||||
nsXBLWindowKeyHandler::HasHandlerForEvent(nsIDOMKeyEvent* aEvent,
|
||||
bool* aOutReservedForChrome)
|
||||
{
|
||||
if (!aEvent->InternalDOMEvent()->IsTrusted()) {
|
||||
return false;
|
||||
@ -580,7 +599,8 @@ nsXBLWindowKeyHandler::HasHandlerForEvent(nsIDOMKeyEvent* aEvent)
|
||||
nsCOMPtr<nsIAtom> eventTypeAtom = do_GetAtom(eventType);
|
||||
NS_ENSURE_TRUE(eventTypeAtom, false);
|
||||
|
||||
return WalkHandlersInternal(aEvent, eventTypeAtom, mHandler, false);
|
||||
return WalkHandlersInternal(aEvent, eventTypeAtom, mHandler, false,
|
||||
aOutReservedForChrome);
|
||||
}
|
||||
|
||||
already_AddRefed<Element>
|
||||
|
@ -42,7 +42,8 @@ protected:
|
||||
bool WalkHandlersInternal(nsIDOMKeyEvent* aKeyEvent,
|
||||
nsIAtom* aEventType,
|
||||
nsXBLPrototypeHandler* aHandler,
|
||||
bool aExecute);
|
||||
bool aExecute,
|
||||
bool* aOutReservedForChrome = nullptr);
|
||||
|
||||
// walk the handlers for aEvent, aCharCode and aIgnoreModifierState. Execute
|
||||
// it if aExecute = true.
|
||||
@ -50,13 +51,17 @@ protected:
|
||||
nsXBLPrototypeHandler* aHandler,
|
||||
uint32_t aCharCode,
|
||||
const IgnoreModifierState& aIgnoreModifierState,
|
||||
bool aExecute);
|
||||
bool aExecute,
|
||||
bool* aOutReservedForChrome = nullptr);
|
||||
|
||||
// HandleEvent function for the capturing phase.
|
||||
void HandleEventOnCapture(nsIDOMKeyEvent* aEvent);
|
||||
|
||||
// Check if any handler would handle the given event.
|
||||
bool HasHandlerForEvent(nsIDOMKeyEvent* aEvent);
|
||||
// Check if any handler would handle the given event. Optionally returns
|
||||
// whether the command handler for the event is marked with the "reserved"
|
||||
// attribute.
|
||||
bool HasHandlerForEvent(nsIDOMKeyEvent* aEvent,
|
||||
bool* aOutReservedForChrome = nullptr);
|
||||
|
||||
// lazily load the handlers. Overridden to handle being attached
|
||||
// to a particular element rather than the document
|
||||
|
Loading…
x
Reference in New Issue
Block a user