Created
March 13, 2015 10:50
-
-
Save koenbok/b4ce1f6cd79228e96bf6 to your computer and use it in GitHub Desktop.
WKWebInspector.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/WebKit/webkit/blob/master/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h | |
@interface WKWebView (WKPrivate) | |
@property (nonatomic, setter=_setAllowsRemoteInspection:) BOOL _allowsRemoteInspection; | |
@property (copy, setter=_setCustomUserAgent:) NSString *_customUserAgent; | |
@end | |
@interface WKPreferences (WKPrivate) | |
@property (nonatomic, setter=_setCompositingBordersVisible:) BOOL _compositingBordersVisible; | |
@property (nonatomic, setter=_setCompositingRepaintCountersVisible:) BOOL _compositingRepaintCountersVisible; | |
@property (nonatomic, setter=_setTiledScrollingIndicatorVisible:) BOOL _tiledScrollingIndicatorVisible; | |
@property (nonatomic, setter=_setDeveloperExtrasEnabled:) BOOL _developerExtrasEnabled; | |
@end | |
// Web Inspector C API: | |
// https://github.com/WebKit/webkit/blob/master/Source/WebKit2/Shared/API/c/WKBase.h | |
typedef const struct OpaqueWKPage* WKPageRef; | |
typedef const struct OpaqueWKPageGroup* WKPageGroupRef; | |
typedef const struct OpaqueWKInspector* WKInspectorRef; | |
typedef const struct OpaqueWKPreferences* WKPreferencesRef; | |
// https://github.com/WebKit/webkit/blob/master/Source/WebKit2/UIProcess/API/C/WKInspector.h | |
WKInspectorRef WKPageGetInspector(WKPageRef pageRef); | |
void WKInspectorShow(WKInspectorRef inspector); | |
void WKInspectorShowConsole(WKInspectorRef inspector); | |
@interface WKView | |
@property (readonly) WKPageRef pageRef; | |
@end | |
@interface WKWebView (Extras) | |
@property (nonatomic, readonly) WKView *wkView; | |
@end | |
@implementation WKWebView (Extras) | |
- (WKView *)wkView | |
{ | |
return [(NSValue *)[self valueForKey:@"_wkView"] pointerValue]; | |
} | |
@end | |
- (void)showInspector:(BOOL)show | |
{ | |
WKInspectorShowConsole(WKPageGetInspector(_webView2.wkView.pageRef)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment