Modified: branches/safari-608-branch/Tools/ChangeLog (248725 => 248726)
--- branches/safari-608-branch/Tools/ChangeLog 2019-08-15 17:20:59 UTC (rev 248725)
+++ branches/safari-608-branch/Tools/ChangeLog 2019-08-15 17:21:02 UTC (rev 248726)
@@ -1,3 +1,36 @@
+2019-08-15 Alan Coon <alanc...@apple.com>
+
+ Cherry-pick r248701. rdar://problem/54333796
+
+ [iOS](REGRESSION: r200487): WebKit.RequestActivatedElementInfoForRotatedImage fails on iOS 13
+ https://bugs.webkit.org/show_bug.cgi?id=200726
+
+ Patch by Said Abou-Hallawa <sabouhall...@apple.com> on 2019-08-14
+ Reviewed by Simon Fraser.
+
+ To get the pixels as an array of colors, draw the image into a memory
+ context. The backing memory buffer can then be accessed to get the image
+ pixels' colors.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm:
+ (TestWebKitAPI::TEST):
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248701 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-08-14 Said Abou-Hallawa <sabouhall...@apple.com>
+
+ [iOS](REGRESSION: r200487): WebKit.RequestActivatedElementInfoForRotatedImage fails on iOS 13
+ https://bugs.webkit.org/show_bug.cgi?id=200726
+
+ Reviewed by Simon Fraser.
+
+ To get the pixels as an array of colors, draw the image into a memory
+ context. The backing memory buffer can then be accessed to get the image
+ pixels' colors.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm:
+ (TestWebKitAPI::TEST):
+
2019-08-13 Alan Coon <alanc...@apple.com>
Cherry-pick r248598. rdar://problem/54282797
Modified: branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm (248725 => 248726)
--- branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm 2019-08-15 17:20:59 UTC (rev 248725)
+++ branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm 2019-08-15 17:21:02 UTC (rev 248726)
@@ -33,6 +33,7 @@
#import <WebKit/WKWebViewConfigurationPrivate.h>
#import <WebKit/_WKActivatedElementInfo.h>
#import <wtf/RetainPtr.h>
+#import <wtf/Vector.h>
#if PLATFORM(IOS_FAMILY)
@@ -107,21 +108,34 @@
__block bool finished = false;
[webView _requestActivatedElementAtPosition:CGPointMake(50, 50) completionBlock: ^(_WKActivatedElementInfo *elementInfo) {
-
- auto image = elementInfo.image.CGImage;
- auto data = ""
- auto buffer = reinterpret_cast<const unsigned*>(CFDataGetBytePtr(data.get()));
-
- auto pixelAt = [&](unsigned x, unsigned y) {
- unsigned i = y * elementInfo.image.size.width + x;
- return buffer[i];
- };
-
static const unsigned yellow = 0xFFFFFF00;
static const unsigned red = 0xFFF51900;
static const unsigned green = 0xFF278000;
static const unsigned blue = 0xFF0000FF;
+ auto imagePixels = [](CGImageRef image) -> Vector<unsigned> {
+ static const size_t bytesPerPixel = 4;
+ static const size_t bitsPerComponent = 8;
+ size_t width = CGImageGetWidth(image);
+ size_t height = CGImageGetHeight(image);
+ size_t bytesPerRow = bytesPerPixel * width;
+
+ static_assert(bytesPerPixel == sizeof(unsigned));
+ Vector<unsigned> pixels(height * width);
+
+ RetainPtr<CGColorSpaceRef> colorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
+ RetainPtr<CGContextRef> context = adoptCF(CGBitmapContextCreate(pixels.data(), width, height, bitsPerComponent, bytesPerRow, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGImageByteOrder32Little));
+
+ CGContextDrawImage(context.get(), CGRectMake(0, 0, width, height), image);
+ return pixels;
+ };
+
+ auto indexOf = [&](unsigned x, unsigned y) -> unsigned {
+ return y * elementInfo.image.size.width + x;
+ };
+
+ auto pixels = imagePixels(elementInfo.image.CGImage);
+
EXPECT_TRUE(elementInfo.type == _WKActivatedElementTypeImage);
EXPECT_WK_STREQ(elementInfo.imageURL.lastPathComponent, "exif-orientation-8-llo.jpg");
EXPECT_NOT_NULL(elementInfo.image);
@@ -130,10 +144,10 @@
EXPECT_EQ(elementInfo.image.size.width, 50);
EXPECT_EQ(elementInfo.image.size.height, 100);
- EXPECT_EQ(pixelAt(0, 0), yellow);
- EXPECT_EQ(pixelAt(elementInfo.image.size.width - 1, 0), red);
- EXPECT_EQ(pixelAt(0, elementInfo.image.size.height - 1), green);
- EXPECT_EQ(pixelAt(elementInfo.image.size.width - 1, elementInfo.image.size.height - 1), blue);
+ EXPECT_EQ(pixels[indexOf(0, 0)], yellow);
+ EXPECT_EQ(pixels[indexOf(elementInfo.image.size.width - 1, 0)], red);
+ EXPECT_EQ(pixels[indexOf(0, elementInfo.image.size.height - 1)], green);
+ EXPECT_EQ(pixels[indexOf(elementInfo.image.size.width - 1, elementInfo.image.size.height - 1)], blue);
finished = true;
}];