Files
flipper/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIDUIApplicationDescriptor.mm
Lorenzo Blasa db7aa9eeaf OSS
Summary: Move UIDebugger plugin to OSS space.

Reviewed By: passy

Differential Revision: D47634848

fbshipit-source-id: 90e8c0181a2434d0e5d76bdb99b902051e6d702e
2023-07-21 04:47:13 -07:00

51 lines
1.2 KiB
Plaintext

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#if FB_SONARKIT_ENABLED
#import "UIDUIApplicationDescriptor.h"
#import <objc/runtime.h>
#import <string>
#import <unordered_set>
#import "UIDBounds.h"
#import "UIDSnapshot.h"
@implementation UIDUIApplicationDescriptor
- (NSArray<id<NSObject>>*)childrenOfNode:(UIApplication*)node {
static std::unordered_set<std::string> ignoredWindows(
{"FBStatusBarTrackingWindow",
"FBAccessibilityOverlayWindow",
"UITextEffectsWindow"});
NSMutableArray<UIWindow*>* children = [NSMutableArray new];
for (UIWindow* window in node.windows) {
if (ignoredWindows.find(class_getName(window.class)) !=
ignoredWindows.end()) {
continue;
}
[children addObject:window];
}
return children;
}
- (id<NSObject>)activeChildForNode:(UIApplication*)node {
return node.keyWindow;
}
- (UIDBounds*)boundsForNode:(UIApplication*)node {
return [UIDBounds fromRect:[UIScreen mainScreen].bounds];
}
- (UIImage*)snapshotForNode:(UIApplication*)node {
return UIDApplicationSnapshot(node, [self childrenOfNode:node]);
}
@end
#endif