Title: [280214] trunk/Source/WebKit
- Revision
- 280214
- Author
- [email protected]
- Date
- 2021-07-22 19:14:10 -0700 (Thu, 22 Jul 2021)
Log Message
[iOS] Unable to open arxiv links on Chrome
https://bugs.webkit.org/show_bug.cgi?id=228205
rdar://78225849
Reviewed by Tim Horton.
-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:] currently
expects the width to be specified in pixels. However, the PDFKit SPI
used to snapshot a PDF expects a width in points. This led to WebKit
requesting extremely large snapshots, resulting in a crash in PDFKit.
To fix, use points instead of pixels in the PDF snapshotting path.
Also, ensure the scale factor of the returned image matches the
the scale used by PDFKit (the screen scale), as opposed to WebKit's
own "page" device scale factor, which can be overridden.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView takeSnapshotWithConfiguration:completionHandler:]):
* UIProcess/API/ios/WKWebViewIOS.mm:
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (280213 => 280214)
--- trunk/Source/WebKit/ChangeLog 2021-07-23 02:00:57 UTC (rev 280213)
+++ trunk/Source/WebKit/ChangeLog 2021-07-23 02:14:10 UTC (rev 280214)
@@ -1,3 +1,25 @@
+2021-07-22 Aditya Keerthi <[email protected]>
+
+ [iOS] Unable to open arxiv links on Chrome
+ https://bugs.webkit.org/show_bug.cgi?id=228205
+ rdar://78225849
+
+ Reviewed by Tim Horton.
+
+ -[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:] currently
+ expects the width to be specified in pixels. However, the PDFKit SPI
+ used to snapshot a PDF expects a width in points. This led to WebKit
+ requesting extremely large snapshots, resulting in a crash in PDFKit.
+
+ To fix, use points instead of pixels in the PDF snapshotting path.
+ Also, ensure the scale factor of the returned image matches the
+ the scale used by PDFKit (the screen scale), as opposed to WebKit's
+ own "page" device scale factor, which can be overridden.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView takeSnapshotWithConfiguration:completionHandler:]):
+ * UIProcess/API/ios/WKWebViewIOS.mm:
+
2021-07-22 Brent Fulgham <[email protected]>
REGRESSION (r278877) [Cocoa] WebAuthn stopped working for non-Safari browsers
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (280213 => 280214)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2021-07-23 02:00:57 UTC (rev 280213)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2021-07-23 02:14:10 UTC (rev 280214)
@@ -1213,10 +1213,13 @@
handler(image.get(), nil);
});
#else
- CGFloat deviceScale = _page->deviceScaleFactor();
+ auto useIntrinsicDeviceScaleFactor = [[_customContentView class] web_requiresCustomSnapshotting];
+
+ CGFloat deviceScale = useIntrinsicDeviceScaleFactor ? UIScreen.mainScreen.scale : _page->deviceScaleFactor();
+ CGFloat imageWidth = useIntrinsicDeviceScaleFactor ? snapshotWidth : snapshotWidth * deviceScale;
RetainPtr<WKWebView> strongSelf = self;
- auto callSnapshotRect = [strongSelf, rectInViewCoordinates, snapshotWidth, deviceScale, handler] {
- [strongSelf _snapshotRect:rectInViewCoordinates intoImageOfWidth:(snapshotWidth * deviceScale) completionHandler:[strongSelf, handler, deviceScale](CGImageRef snapshotImage) {
+ auto callSnapshotRect = [strongSelf, rectInViewCoordinates, imageWidth, deviceScale, handler] {
+ [strongSelf _snapshotRect:rectInViewCoordinates intoImageOfWidth:imageWidth completionHandler:[strongSelf, handler, deviceScale](CGImageRef snapshotImage) {
RetainPtr<NSError> error;
RetainPtr<UIImage> image;
Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (280213 => 280214)
--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2021-07-23 02:00:57 UTC (rev 280213)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2021-07-23 02:14:10 UTC (rev 280214)
@@ -3138,6 +3138,9 @@
[_contentView updateSoftwareKeyboardSuppressionStateFromWebView];
}
+// FIXME (<rdar://problem/80986330>): This method should be updated to take an image
+// width in points (for consistency) and a completion handler with a UIImage parameter
+// (to avoid redundant copies for PDFs), once it is no longer in use by internal clients.
- (void)_snapshotRect:(CGRect)rectInViewCoordinates intoImageOfWidth:(CGFloat)imageWidth completionHandler:(void(^)(CGImageRef))completionHandler
{
if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes