Title: [186237] trunk/Source/WebKit2
Revision
186237
Author
bfulg...@apple.com
Date
2015-07-02 15:17:42 -0700 (Thu, 02 Jul 2015)

Log Message

Provide delegate SPI for clients to notify WebKit about content inset changes
https://bugs.webkit.org/show_bug.cgi?id=146482
<rdar://problem/21602741>

Reviewed by Darin Adler.

Provide a new SPI for WebKit client applications to use to inform WebKit of planned
adjustments to the edge insets of the view.

* UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Add new optional delegate method.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView scrollViewWillEndDragging:withVelocity:targetContentOffset:]): If the new delegate
method exists, use the specified content insets, rather than the current state of the view.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (186236 => 186237)


--- trunk/Source/WebKit2/ChangeLog	2015-07-02 22:10:40 UTC (rev 186236)
+++ trunk/Source/WebKit2/ChangeLog	2015-07-02 22:17:42 UTC (rev 186237)
@@ -1,3 +1,19 @@
+2015-07-02  Brent Fulgham  <bfulg...@apple.com>
+
+        Provide delegate SPI for clients to notify WebKit about content inset changes
+        https://bugs.webkit.org/show_bug.cgi?id=146482
+        <rdar://problem/21602741>
+
+        Reviewed by Darin Adler.
+
+        Provide a new SPI for WebKit client applications to use to inform WebKit of planned
+        adjustments to the edge insets of the view.
+
+        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Add new optional delegate method.
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView scrollViewWillEndDragging:withVelocity:targetContentOffset:]): If the new delegate
+        method exists, use the specified content insets, rather than the current state of the view.
+
 2015-07-02  Beth Dakin  <bda...@apple.com>
 
         Allow the UIDelegate to customize an image preview

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (186236 => 186237)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h	2015-07-02 22:10:40 UTC (rev 186236)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h	2015-07-02 22:17:42 UTC (rev 186237)
@@ -30,11 +30,14 @@
 #import <WebKit/WKSecurityOrigin.h>
 #import <WebKit/_WKActivatedElementInfo.h>
 
+@class UIScrollView;
 @class UIViewController;
 @class _WKFrameHandle;
 
 @protocol WKUIDelegatePrivate <WKUIDelegate>
 
+struct UIEdgeInsets;
+
 @optional
 
 // FIXME: This should be handled by the WKWebsiteDataStore delegate.
@@ -59,6 +62,7 @@
 - (void)_webView:(WKWebView *)webView willPreviewImageWithURL:(NSURL *)imageURL WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 - (void)_webView:(WKWebView *)webView commitPreviewedImageWithURL:(NSURL *)imageURL WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 - (void)_webView:(WKWebView *)webView didDismissPreviewViewController:(UIViewController *)previewedViewController;
+- (UIEdgeInsets)_webView:(WKWebView *)webView finalObscuredInsetsForScrollView:(UIScrollView *)scrolView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset;
 #endif
 
 @end

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (186236 => 186237)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-07-02 22:10:40 UTC (rev 186236)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-07-02 22:17:42 UTC (rev 186237)
@@ -1461,7 +1461,16 @@
         CGSize maxScrollOffsets = CGSizeMake(scrollView.contentSize.width - scrollView.bounds.size.width, scrollView.contentSize.height - scrollView.bounds.size.height);
         
         CGRect fullViewRect = self.bounds;
-        CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, [self _computedContentInset]);
+
+        UIEdgeInsets contentInset;
+
+        id<WKUIDelegatePrivate> uiDelegatePrivate = static_cast<id <WKUIDelegatePrivate>>([self UIDelegate]);
+        if ([uiDelegatePrivate respondsToSelector:@selector(_webView:finalObscuredInsetsForScrollView:withVelocity:targetContentOffset:)])
+            contentInset = [uiDelegatePrivate _webView:self finalObscuredInsetsForScrollView:scrollView withVelocity:velocity targetContentOffset:targetContentOffset];
+        else
+            UIEdgeInsets contentInset = [self _computedContentInset];
+
+        CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, contentInset);
         
         coordinator->adjustTargetContentOffsetForSnapping(maxScrollOffsets, velocity, unobscuredRect.origin.y, targetContentOffset);
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to