[Cocoa][Mac] WKWebView should automatically set topContentInset when beneath a toolbar
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / Cocoa / WKWebView.mm
index d3b6d66..aa5975f 100644 (file)
@@ -306,6 +306,10 @@ static int32_t deviceOrientation()
     _wkView = [[WKView alloc] initWithFrame:bounds context:context configuration:std::move(webPageConfiguration) webView:self];
     [self addSubview:_wkView.get()];
     _page = WebKit::toImpl([_wkView pageRef]);
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+    [_wkView _setAutomaticallyAdjustsContentInsets:YES];
+#endif
 #endif
 
     _page->setBackgroundExtendsBeyondPage(true);
@@ -2240,14 +2244,28 @@ static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions)
 
 - (void)_setTopContentInset:(CGFloat)contentInset
 {
-    _page->setTopContentInset(contentInset);
+    [_wkView _setTopContentInset:contentInset];
 }
 
 - (CGFloat)_topContentInset
 {
-    return _page->topContentInset();
+    return [_wkView _topContentInset];
+}
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+
+- (void)_setAutomaticallyAdjustsContentInsets:(BOOL)automaticallyAdjustsContentInsets
+{
+    [_wkView _setAutomaticallyAdjustsContentInsets:automaticallyAdjustsContentInsets];
 }
 
+- (BOOL)_automaticallyAdjustsContentInsets
+{
+    return [_wkView _automaticallyAdjustsContentInsets];
+}
+
+#endif
+
 #endif
 
 @end