Expose unobscuredSafeAreaInsets on WebView
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Jul 2017 18:55:31 +0000 (18:55 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Jul 2017 18:55:31 +0000 (18:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174075
<rdar://problem/33096997>

Reviewed by Beth Dakin.

* WebView/WebView.mm:
(-[WebView _setUnobscuredSafeAreaInsets:]):
(-[WebView _unobscuredSafeAreaInsets]):
* WebView/WebViewPrivate.h:
Expose unobscuredSafeAreaInsets as a new private property on WebView,
similar to how it is exposed in WebKit2.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219084 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/mac/WebView/WebViewPrivate.h

index 9a6e826..6823e8e 100644 (file)
@@ -1,3 +1,18 @@
+2017-07-03  Tim Horton  <timothy_horton@apple.com>
+
+        Expose unobscuredSafeAreaInsets on WebView
+        https://bugs.webkit.org/show_bug.cgi?id=174075
+        <rdar://problem/33096997>
+
+        Reviewed by Beth Dakin.
+
+        * WebView/WebView.mm:
+        (-[WebView _setUnobscuredSafeAreaInsets:]):
+        (-[WebView _unobscuredSafeAreaInsets]):
+        * WebView/WebViewPrivate.h:
+        Expose unobscuredSafeAreaInsets as a new private property on WebView,
+        similar to how it is exposed in WebKit2.
+
 2017-07-03  Andy Estes  <aestes@apple.com>
 
         [Xcode] Add an experimental setting to build with ccache
index f5e6102..3b6023c 100644 (file)
@@ -5160,6 +5160,27 @@ static Vector<String> toStringVector(NSArray* patterns)
 }
 #endif // PLATFORM(IOS)
 
+- (void)_setUnobscuredSafeAreaInsets:(WebEdgeInsets)insets
+{
+    if (auto page = _private->page)
+        page->setUnobscuredSafeAreaInsets(WebCore::FloatBoxExtent(insets.top, insets.right, insets.bottom, insets.left));
+}
+
+- (WebEdgeInsets)_unobscuredSafeAreaInsets
+{
+    WebEdgeInsets insets({ 0, 0, 0, 0 });
+
+    if (auto page = _private->page) {
+        auto unobscuredSafeAreaInsets = page->unobscuredSafeAreaInsets();
+        insets.top = unobscuredSafeAreaInsets.top();
+        insets.left = unobscuredSafeAreaInsets.left();
+        insets.bottom = unobscuredSafeAreaInsets.bottom();
+        insets.right = unobscuredSafeAreaInsets.right();
+    }
+
+    return insets;
+}
+
 - (void)_setSourceApplicationAuditData:(NSData *)sourceApplicationAuditData
 {
     if (_private->sourceApplicationAuditData == sourceApplicationAuditData)
index 4bbfe96..e2d132f 100644 (file)
@@ -917,6 +917,15 @@ Could be worth adding to the API.
 - (void)forceRequestCandidatesForTesting;
 - (BOOL)shouldRequestCandidates;
 
+typedef struct WebEdgeInsets {
+    CGFloat top;
+    CGFloat left;
+    CGFloat bottom;
+    CGFloat right;
+} WebEdgeInsets;
+
+@property (nonatomic, assign, setter=_setUnobscuredSafeAreaInsets:) WebEdgeInsets _unobscuredSafeAreaInsets;
+
 @end
 
 #if !TARGET_OS_IPHONE