Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[iOS] Synchronize PDF resizing with device rotation
https://bugs.webkit.org/show_bug.cgi?id=186587
<rdar://problem/40922462>

Reviewed by Darin Adler.

Both -beginPDFViewRotation and -endPDFViewRotation need to be called as part of
the transition coordinator's -animateAlongsideTransition: block to be synchronized
with rotation. Additionally, updateBlock needs to be invoked between the two calls
so that PDFKit can capture the frame geometry before and after the update.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _beginAnimatedResizeWithUpdates:]):
* UIProcess/Cocoa/WKWebViewContentProvider.h:
* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView web_beginAnimatedResizeWithUpdates:]):
(-[WKPDFView web_beginAnimatedResize]): Renamed to web_beginAnimatedResizeWithUpdates:.
(-[WKPDFView web_endAnimatedResize]): Deleted.


Canonical link: https://commits.webkit.org/201914@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232794 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
aestes committed Jun 13, 2018
1 parent d9104ce commit ca20fb2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
21 changes: 21 additions & 0 deletions Source/WebKit/ChangeLog
@@ -1,3 +1,24 @@
2018-06-13 Andy Estes <aestes@apple.com>

[iOS] Synchronize PDF resizing with device rotation
https://bugs.webkit.org/show_bug.cgi?id=186587
<rdar://problem/40922462>

Reviewed by Darin Adler.

Both -beginPDFViewRotation and -endPDFViewRotation need to be called as part of
the transition coordinator's -animateAlongsideTransition: block to be synchronized
with rotation. Additionally, updateBlock needs to be invoked between the two calls
so that PDFKit can capture the frame geometry before and after the update.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _beginAnimatedResizeWithUpdates:]):
* UIProcess/Cocoa/WKWebViewContentProvider.h:
* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView web_beginAnimatedResizeWithUpdates:]):
(-[WKPDFView web_beginAnimatedResize]): Renamed to web_beginAnimatedResizeWithUpdates:.
(-[WKPDFView web_endAnimatedResize]): Deleted.

2018-06-12 Brent Fulgham <bfulgham@apple.com>

Turn CSS Spring Animations and Link Preload off by default for production builds.
Expand Down
10 changes: 4 additions & 6 deletions Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Expand Up @@ -5235,9 +5235,10 @@ - (void)_beginAnimatedResizeWithUpdates:(void (^)(void))updateBlock
WebCore::FloatRect oldUnobscuredContentRect = _page->unobscuredContentRect();

if (![self usesStandardContentView] || !_hasCommittedLoadForMainFrame || CGRectIsEmpty(oldBounds) || oldUnobscuredContentRect.isEmpty()) {
updateBlock();
if ([_customContentView respondsToSelector:@selector(web_beginAnimatedResize)])
[_customContentView web_beginAnimatedResize];
if ([_customContentView respondsToSelector:@selector(web_beginAnimatedResizeWithUpdates:)])
[_customContentView web_beginAnimatedResizeWithUpdates:updateBlock];
else
updateBlock();
return;
}

Expand Down Expand Up @@ -5358,9 +5359,6 @@ - (void)_endAnimatedResize
{
LOG_WITH_STREAM(VisibleRects, stream << "-[WKWebView " << _page->pageID() << " _endAnimatedResize:] " << " _dynamicViewportUpdateMode " << (int)_dynamicViewportUpdateMode);

if ([_customContentView respondsToSelector:@selector(web_endAnimatedResize)])
[_customContentView web_endAnimatedResize];

// If we already have an up-to-date layer tree, immediately complete
// the resize. Otherwise, we will defer completion until we do.
_waitingForEndAnimatedResize = NO;
Expand Down
3 changes: 1 addition & 2 deletions Source/WebKit/UIProcess/Cocoa/WKWebViewContentProvider.h
Expand Up @@ -59,8 +59,7 @@ struct UIEdgeInsets;
- (void)web_scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view;
- (void)web_scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale;
- (void)web_scrollViewDidZoom:(UIScrollView *)scrollView;
- (void)web_beginAnimatedResize;
- (void)web_endAnimatedResize;
- (void)web_beginAnimatedResizeWithUpdates:(void (^)(void))updateBlock;
@property (nonatomic, readonly) NSData *web_dataRepresentation;
@property (nonatomic, readonly) NSString *web_suggestedFilename;
@property (nonatomic, readonly) BOOL web_isBackground;
Expand Down
7 changes: 2 additions & 5 deletions Source/WebKit/UIProcess/ios/WKPDFView.mm
Expand Up @@ -352,13 +352,10 @@ - (void)web_scrollViewDidZoom:(UIScrollView *)scrollView
[_hostViewController updatePDFViewLayout];
}

- (void)web_beginAnimatedResize
- (void)web_beginAnimatedResizeWithUpdates:(void (^)(void))updateBlock
{
[_hostViewController beginPDFViewRotation];
}

- (void)web_endAnimatedResize
{
updateBlock();
[_hostViewController endPDFViewRotation];
}

Expand Down

0 comments on commit ca20fb2

Please sign in to comment.