Title: [198363] trunk
- Revision
- 198363
- Author
- [email protected]
- Date
- 2016-03-17 17:50:46 -0700 (Thu, 17 Mar 2016)
Log Message
Find-in-page indicator in Mail viewer is the wrong scale and cut off
https://bugs.webkit.org/show_bug.cgi?id=155605
<rdar://problem/23948165>
Reviewed by Simon Fraser.
Source/WebKit2:
* UIProcess/mac/WKTextFinderClient.mm:
(-[WKTextFinderClient didGetImageForMatchResult:]):
Initialize the NSImage with the correct size, instead of inferring the
size from the bitmap, so that we don't lose information about device pixel ratio.
Tools:
* TestWebKitAPI/Tests/WebKit2Cocoa/FindInPage.mm:
(TEST):
Add a test that ensures that the find result image is correctly @2x.
The NSImage size should be in points.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (198362 => 198363)
--- trunk/Source/WebKit2/ChangeLog 2016-03-18 00:46:04 UTC (rev 198362)
+++ trunk/Source/WebKit2/ChangeLog 2016-03-18 00:50:46 UTC (rev 198363)
@@ -1,3 +1,16 @@
+2016-03-17 Tim Horton <[email protected]>
+
+ Find-in-page indicator in Mail viewer is the wrong scale and cut off
+ https://bugs.webkit.org/show_bug.cgi?id=155605
+ <rdar://problem/23948165>
+
+ Reviewed by Simon Fraser.
+
+ * UIProcess/mac/WKTextFinderClient.mm:
+ (-[WKTextFinderClient didGetImageForMatchResult:]):
+ Initialize the NSImage with the correct size, instead of inferring the
+ size from the bitmap, so that we don't lose information about device pixel ratio.
+
2016-03-17 Anders Carlsson <[email protected]>
Remove use of dyld_register_image_state_change_handler() in PluginProcessMac.mm
Modified: trunk/Source/WebKit2/UIProcess/mac/WKTextFinderClient.mm (198362 => 198363)
--- trunk/Source/WebKit2/UIProcess/mac/WKTextFinderClient.mm 2016-03-18 00:46:04 UTC (rev 198362)
+++ trunk/Source/WebKit2/UIProcess/mac/WKTextFinderClient.mm 2016-03-18 00:50:46 UTC (rev 198363)
@@ -248,8 +248,11 @@
if (_imageReplyCallbacks.isEmpty())
return;
+ IntSize size = image->bitmap()->size();
+ size.scale(1 / _page->deviceScaleFactor());
+
auto imageCallback = _imageReplyCallbacks.takeFirst();
- imageCallback([[[NSImage alloc] initWithCGImage:image->bitmap()->makeCGImage().get() size:NSZeroSize] autorelease]);
+ imageCallback(adoptNS([[NSImage alloc] initWithCGImage:image->bitmap()->makeCGImage().get() size:size]).get());
}
#pragma mark - WKTextFinderMatch callbacks
Modified: trunk/Tools/ChangeLog (198362 => 198363)
--- trunk/Tools/ChangeLog 2016-03-18 00:46:04 UTC (rev 198362)
+++ trunk/Tools/ChangeLog 2016-03-18 00:50:46 UTC (rev 198363)
@@ -1,3 +1,16 @@
+2016-03-17 Tim Horton <[email protected]>
+
+ Find-in-page indicator in Mail viewer is the wrong scale and cut off
+ https://bugs.webkit.org/show_bug.cgi?id=155605
+ <rdar://problem/23948165>
+
+ Reviewed by Simon Fraser.
+
+ * TestWebKitAPI/Tests/WebKit2Cocoa/FindInPage.mm:
+ (TEST):
+ Add a test that ensures that the find result image is correctly @2x.
+ The NSImage size should be in points.
+
2016-03-16 Commit Queue <[email protected]>
Unreviewed, rolling out r198187.
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FindInPage.mm (198362 => 198363)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FindInPage.mm 2016-03-18 00:46:04 UTC (rev 198362)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FindInPage.mm 2016-03-18 00:50:46 UTC (rev 198363)
@@ -37,6 +37,7 @@
@protocol NSTextFinderAsynchronousDocumentFindMatch <NSObject>
@property (retain, nonatomic, readonly) NSArray *textRects;
+- (void)generateTextImage:(void (^)(NSImage *generatedImage))completionHandler;
@end
@interface WKWebView (NSTextFinderSupport)
@@ -63,6 +64,7 @@
TEST(WebKit2, FindInPage)
{
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]);
+ [webView _setOverrideDeviceScaleFactor:2];
RetainPtr<FindInPageNavigationDelegate> delegate = adoptNS([[FindInPageNavigationDelegate alloc] init]);
[webView setNavigationDelegate:delegate.get()];
@@ -119,6 +121,24 @@
}];
TestWebKitAPI::Util::run(&findMatchesDone);
+ findMatchesDone = false;
+
+ // Ensure that the generated image has the correct DPI.
+ [webView findMatchesForString:@"Birthday" relativeToMatch:nil findOptions:noFindOptions maxResults:NSUIntegerMax resultCollector:^(NSArray *matches, BOOL didWrap) {
+ EXPECT_EQ((NSUInteger)360, matches.count);
+
+ id <NSTextFinderAsynchronousDocumentFindMatch> firstMatch = [matches objectAtIndex:0];
+ [firstMatch generateTextImage:^(NSImage *image) {
+ CGImageRef CGImage = [image CGImageForProposedRect:nil context:nil hints:nil];
+ EXPECT_EQ(image.size.width, CGImageGetWidth(CGImage) / 2);
+ EXPECT_EQ(image.size.height, CGImageGetHeight(CGImage) / 2);
+
+ findMatchesDone = true;
+ }];
+ }];
+
+ TestWebKitAPI::Util::run(&findMatchesDone);
+ findMatchesDone = false;
}
#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes