Update animation when presenting QuickLook
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 May 2018 10:36:07 +0000 (10:36 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 May 2018 10:36:07 +0000 (10:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=185648
<rdar://problem/39652624>

Reviewed by Antoine Quint.

Implement the QuickLook delegate on _WKPreviewControllerDelegate that
produces a zoom-like animation when the QLPreviewController appears.

* UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
(-[_WKPreviewControllerDelegate previewController:frameForPreviewItem:inSourceView:]):
* UIProcess/SystemPreviewController.h: Add a reference back to the page, so that
the delegate implementation can access the presentingViewController.
(WebKit::SystemPreviewController::page):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm
Source/WebKit/UIProcess/SystemPreviewController.h

index dac7438..6e6c1d0 100644 (file)
@@ -1,3 +1,20 @@
+2018-05-15  Dean Jackson  <dino@apple.com>
+
+        Update animation when presenting QuickLook
+        https://bugs.webkit.org/show_bug.cgi?id=185648
+        <rdar://problem/39652624>
+
+        Reviewed by Antoine Quint.
+
+        Implement the QuickLook delegate on _WKPreviewControllerDelegate that
+        produces a zoom-like animation when the QLPreviewController appears.
+
+        * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
+        (-[_WKPreviewControllerDelegate previewController:frameForPreviewItem:inSourceView:]):
+        * UIProcess/SystemPreviewController.h: Add a reference back to the page, so that
+        the delegate implementation can access the presentingViewController.
+        (WebKit::SystemPreviewController::page):
+
 2018-05-14  Dean Jackson  <dino@apple.com>
 
         Download and present System Preview
index 4baaeba..d5e7d18 100644 (file)
@@ -126,6 +126,25 @@ SOFT_LINK_CLASS(QuickLook, QLItem);
     if (_previewController)
         _previewController->cancel();
 }
+
+- (CGRect)previewController:(QLPreviewController *)controller frameForPreviewItem:(id <QLPreviewItem>)item inSourceView:(UIView * *)view
+{
+    if (!_previewController)
+        return CGRectZero;
+
+    UIViewController *presentingViewController = _previewController->page().uiClient().presentingViewController();
+
+    if (!presentingViewController)
+        return CGRectZero;
+
+    CGRect frame = presentingViewController.view.frame;
+    // Create a smaller rectangle centered in the frame.
+    CGFloat halfWidth = frame.size.width / 2;
+    CGFloat halfHeight = frame.size.height / 2;
+    frame = CGRectMake(CGRectGetMidX(frame) - halfWidth / 2, CGRectGetMidY(frame) - halfHeight / 2, halfWidth, halfHeight);
+    return frame;
+}
+
 @end
 
 namespace WebKit {
index f9d4c9a..804b228 100644 (file)
@@ -51,6 +51,8 @@ public:
     void finish(WebCore::URL);
     void cancel();
 
+    WebPageProxy& page() { return m_webPageProxy; }
+
 private:
     WebPageProxy& m_webPageProxy;
 #if USE(QUICK_LOOK)