Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Unified Diff: ui/base/test/scoped_fake_nswindow_focus.mm

Issue 1894383002: MacViews: Implement Full Keyboard Access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SetFocusBehavior
Patch Set: Rebased Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/base/test/scoped_fake_nswindow_focus.mm
diff --git a/ui/base/test/scoped_fake_nswindow_focus.mm b/ui/base/test/scoped_fake_nswindow_focus.mm
index b78680dba23dec94efc4996da2d114eccf24eafe..3d5573e5e7817ab87e3dfd9679fc1f98113d28ab 100644
--- a/ui/base/test/scoped_fake_nswindow_focus.mm
+++ b/ui/base/test/scoped_fake_nswindow_focus.mm
@@ -14,6 +14,7 @@ using base::mac::ScopedObjCClassSwizzler;
namespace {
NSWindow* g_fake_focused_window = nil;
+IMP g_order_out_impl_ = nullptr;
void SetFocus(NSWindow* window) {
g_fake_focused_window = window;
@@ -69,6 +70,13 @@ void ClearFocus() {
[self makeKeyWindow];
}
+- (void)orderOut:(id)sender {
+ NSWindow* selfAsWindow = base::mac::ObjCCastStrict<NSWindow>(self);
+ if (selfAsWindow == g_fake_focused_window)
+ ClearFocus();
+ g_order_out_impl_(self, _cmd, sender);
+}
+
@end
namespace ui {
@@ -90,7 +98,13 @@ ScopedFakeNSWindowFocus::ScopedFakeNSWindowFocus()
make_key_swizzler_(
new ScopedObjCClassSwizzler([NSWindow class],
[FakeNSWindowFocusDonor class],
- @selector(makeKeyWindow))) {}
+ @selector(makeKeyWindow))),
+ order_out_swizzler_(
+ new ScopedObjCClassSwizzler([NSWindow class],
+ [FakeNSWindowFocusDonor class],
+ @selector(orderOut:))) {
+ g_order_out_impl_ = order_out_swizzler_->GetOriginalImplementation();
+}
ScopedFakeNSWindowFocus::~ScopedFakeNSWindowFocus() {
ClearFocus();

Powered by Google App Engine
This is Rietveld 408576698