fix: restore window event redispatching on mac (#27812)

Co-authored-by: clavin <cwatford@slack-corp.com>
This commit is contained in:
trop[bot]
2021-02-19 15:42:02 +09:00
committed by GitHub
parent 072bec5d01
commit ee95a258b3

View File

@@ -9,6 +9,7 @@
#include "content/public/browser/native_web_keyboard_event.h"
#include "shell/browser/ui/cocoa/event_dispatching_window.h"
#include "shell/browser/web_contents_preferences.h"
#include "ui/base/cocoa/command_dispatcher.h"
#include "ui/events/keycodes/keyboard_codes.h"
@interface NSWindow (EventDispatchingWindow)
@@ -48,6 +49,16 @@ bool CommonWebContentsDelegate::HandleKeyboardEvent(
// devtools windows as Widgets in order to take advantage of the
// pre-existing redispatch code in bridged_native_widget.
return false;
} else if (event.os_event.window &&
[event.os_event.window
conformsToProtocol:@protocol(CommandDispatchingWindow)]) {
NSObject<CommandDispatchingWindow>* window =
static_cast<NSObject<CommandDispatchingWindow>*>(event.os_event.window);
[[window commandDispatcher] redispatchKeyEvent:event.os_event];
// FIXME(clavin): Not exactly sure what to return here, likely the same
// situation as the branch above. If a future refactor removes
// |EventDispatchingWindow| then only this branch will need to remain.
return false;
}
return false;