Title: [181443] trunk/Source/WebKit2
- Revision
- 181443
- Author
- [email protected]
- Date
- 2015-03-12 10:27:26 -0700 (Thu, 12 Mar 2015)
Log Message
PDFs don't snapshot properly in iOS Safari
https://bugs.webkit.org/show_bug.cgi?id=142623
Patch by Ian Henderson <[email protected]> on 2015-03-12
Reviewed by Tim Horton.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]):
If we have a _customContentView, use UIView snapshotting instead of
trying to snapshot the web page.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (181442 => 181443)
--- trunk/Source/WebKit2/ChangeLog 2015-03-12 17:18:31 UTC (rev 181442)
+++ trunk/Source/WebKit2/ChangeLog 2015-03-12 17:27:26 UTC (rev 181443)
@@ -1,3 +1,15 @@
+2015-03-12 Ian Henderson <[email protected]>
+
+ PDFs don't snapshot properly in iOS Safari
+ https://bugs.webkit.org/show_bug.cgi?id=142623
+
+ Reviewed by Tim Horton.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]):
+ If we have a _customContentView, use UIView snapshotting instead of
+ trying to snapshot the web page.
+
2015-03-12 Eric Carlson <[email protected]>
[Mac] Update AirPlay handling
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (181442 => 181443)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-03-12 17:18:31 UTC (rev 181442)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-03-12 17:27:26 UTC (rev 181443)
@@ -2446,9 +2446,30 @@
- (void)_snapshotRect:(CGRect)rectInViewCoordinates intoImageOfWidth:(CGFloat)imageWidth completionHandler:(void(^)(CGImageRef))completionHandler
{
- CGRect snapshotRectInContentCoordinates = [self convertRect:rectInViewCoordinates toView:_contentView.get()];
- CGFloat imageHeight = imageWidth / snapshotRectInContentCoordinates.size.width * snapshotRectInContentCoordinates.size.height;
+ CGRect snapshotRectInContentCoordinates = [self convertRect:rectInViewCoordinates toView:self._currentContentView];
+ CGFloat imageScale = imageWidth / snapshotRectInContentCoordinates.size.width;
+ CGFloat imageHeight = imageScale * snapshotRectInContentCoordinates.size.height;
CGSize imageSize = CGSizeMake(imageWidth, imageHeight);
+
+ if (_customContentView) {
+ UIGraphicsBeginImageContextWithOptions(imageSize, YES, 1);
+
+ UIView *customContentView = _customContentView.get();
+ [customContentView.backgroundColor set];
+ UIRectFill(CGRectMake(0, 0, imageWidth, imageHeight));
+
+ CGRect destinationRect = customContentView.bounds;
+ destinationRect.origin.x = -snapshotRectInContentCoordinates.origin.x * imageScale;
+ destinationRect.origin.y = -snapshotRectInContentCoordinates.origin.y * imageScale;
+ destinationRect.size.width *= imageScale;
+ destinationRect.size.height *= imageScale;
+ [customContentView drawViewHierarchyInRect:destinationRect afterScreenUpdates:NO];
+
+ completionHandler([UIGraphicsGetImageFromCurrentImageContext() CGImage]);
+
+ UIGraphicsEndImageContext();
+ return;
+ }
void(^copiedCompletionHandler)(CGImageRef) = [completionHandler copy];
_page->takeSnapshot(WebCore::enclosingIntRect(snapshotRectInContentCoordinates), WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebKit::SnapshotOptionsExcludeDeviceScaleFactor, [=](const WebKit::ShareableBitmap::Handle& imageHandle, WebKit::CallbackBase::Error) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes