Modified: trunk/Tools/ChangeLog (176879 => 176880)
--- trunk/Tools/ChangeLog 2014-12-05 23:25:31 UTC (rev 176879)
+++ trunk/Tools/ChangeLog 2014-12-05 23:33:55 UTC (rev 176880)
@@ -1,3 +1,38 @@
+2014-12-05 Daniel Bates <[email protected]>
+
+ [iOS] DumpRenderTree produces many reference test mismatches
+ https://bugs.webkit.org/show_bug.cgi?id=139314
+
+ Reviewed by Simon Fraser.
+
+ Fixes an issue where the scale factor used to render the snapshot taken by
+ DumpRenderTree may differ from the device scale factor. In particular, the
+ scale factor used to render a snapshot of a test may differ from the scale
+ factor used to render the snapshot of its expected result.
+
+ Currently DumpRenderTree uses SPI, -[UIView newSnapshotForRect], on iOS to
+ snapshot the UIWebBrowserView. This SPI always render using a scale factor
+ of one when the backing store for the LegacyTileLayer objects were out-of-
+ date regardless of the device scale factor. Instead we should use UIImage
+ and CALayer API to perform the snapshot with respect to the device scale
+ factor.
+
+ Additionally write iOS pixel dump support logic in terms of existing
+ DumpRenderTree abstractions so as to support generating and comparing
+ pixel dump checksums as well as make the iOS code more consistent with
+ the logic used by other ports.
+
+ * DumpRenderTree/PixelDumpSupport.cpp:
+ (dumpWebViewAsPixelsAndCompareWithExpected): Removed !PLATFORM(IOS)-guard.
+ * DumpRenderTree/ios/PixelDumpSupportIOS.mm:
+ (BitmapContext::createFromUIImage): Added.
+ (BitmapContext::pixelData): Added.
+ (BitmapContext::BitmapContext): Added.
+ (computeMD5HashStringForBitmapContext): Added.
+ (dumpBitmap): Added.
+ (createBitmapContextFromWebView): Moved logic from dumpWebViewAsPixelsAndCompareWithExpected() to here.
+ (dumpWebViewAsPixelsAndCompareWithExpected): Deleted.
+
2014-12-05 Anders Carlsson <[email protected]>
Give all web pages a website data store
Modified: trunk/Tools/DumpRenderTree/PixelDumpSupport.cpp (176879 => 176880)
--- trunk/Tools/DumpRenderTree/PixelDumpSupport.cpp 2014-12-05 23:25:31 UTC (rev 176879)
+++ trunk/Tools/DumpRenderTree/PixelDumpSupport.cpp 2014-12-05 23:33:55 UTC (rev 176880)
@@ -43,7 +43,6 @@
#include "PixelDumpSupportCairo.h"
#endif
-#if !PLATFORM(IOS)
void dumpWebViewAsPixelsAndCompareWithExpected(const std::string& expectedHash)
{
RefPtr<BitmapContext> context;
@@ -74,7 +73,6 @@
if (dumpImage)
dumpBitmap(context.get(), actualHash);
}
-#endif
static void appendIntToVector(unsigned number, Vector<unsigned char>& vector)
{
Modified: trunk/Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm (176879 => 176880)
--- trunk/Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm 2014-12-05 23:25:31 UTC (rev 176879)
+++ trunk/Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm 2014-12-05 23:33:55 UTC (rev 176880)
@@ -30,7 +30,6 @@
#import "PixelDumpSupport.h"
#import "DumpRenderTree.h"
-#import "PixelDumpSupportCG.h"
#define COMMON_DIGEST_FOR_OPENSSL
#import <CommonCrypto/CommonDigest.h>
@@ -40,38 +39,56 @@
#import <UIKit/UIView_Private.h>
#import <UIKit/UIWebBrowserView.h>
#import <WebKit/WebCoreThread.h>
-
+#import <WebKitSystemInterface.h>
+#import <wtf/RefCounted.h>
#import <wtf/RefPtr.h>
+#import <wtf/RetainPtr.h>
extern UIWebBrowserView *gWebBrowserView;
-PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally,
- bool drawSelectionRect)
+class BitmapContext : public RefCounted<BitmapContext> {
+public:
+ static PassRefPtr<BitmapContext> createFromUIImage(UIImage *image)
+ {
+ return adoptRef(new BitmapContext(image));
+ }
+
+ NSData *pixelData() const { return m_pixelData.get(); }
+
+private:
+ BitmapContext(UIImage *image)
+ : m_pixelData(UIImagePNGRepresentation(image))
+ {
+ }
+
+ RetainPtr<NSData> m_pixelData;
+};
+
+void computeMD5HashStringForBitmapContext(BitmapContext* context, char hashString[33])
{
- // FIXME: Implement; see PixelDumpSupportMac.mm.
- return 0;
+ unsigned char result[CC_MD5_DIGEST_LENGTH];
+ CC_MD5([context->pixelData() bytes], [context->pixelData() length], result);
+ hashString[0] = '\0';
+ for (int i = 0; i < 16; ++i)
+ snprintf(hashString, 33, "%s%02x", hashString, result[i]);
}
-void dumpWebViewAsPixelsAndCompareWithExpected(const std::string& expectedHash)
+void dumpBitmap(BitmapContext* context, const char* checksum)
{
+ printPNG(static_cast<const unsigned char*>([context->pixelData() bytes]), [context->pixelData() length], checksum);
+}
+
+PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect)
+{
// TODO: <rdar://problem/6558366> DumpRenderTree: Investigate testRepaintSweepHorizontally and dumpSelectionRect
WebThreadLock();
[gWebBrowserView layoutIfNeeded]; // Re-enables tile painting, which was disabled when committing the frame load.
[gWebBrowserView setNeedsDisplay];
- RetainPtr<CGImageRef> snapshot = adoptCF([gWebBrowserView newSnapshotWithRect:[[mainFrame webView] frame]]);
- NSData *pngData = UIImagePNGRepresentation([UIImage imageWithCGImage:snapshot.get()]);
-
- // Hash the PNG data
- char actualHash[33];
- unsigned char result[CC_MD5_DIGEST_LENGTH];
- CC_MD5([pngData bytes], [pngData length], result);
- actualHash[0] = '\0';
- for (int i = 0; i < 16; i++)
- snprintf(actualHash, 33, "%s%02x", actualHash, result[i]);
- printf("\nActualHash: %s\n", actualHash);
-
- // Print the image
- printf("Content-Type: image/png\n");
- printf("Content-Length: %lu\n", (unsigned long)[pngData length]);
- fwrite([pngData bytes], 1, [pngData length], stdout);
+
+ UIGraphicsBeginImageContextWithOptions([[mainFrame webView] frame].size, YES /* opaque */, WKGetScreenScaleFactor());
+ [[gWebBrowserView layer] renderInContext:UIGraphicsGetCurrentContext()];
+ RefPtr<BitmapContext> context = BitmapContext::createFromUIImage(UIGraphicsGetImageFromCurrentImageContext());
+ UIGraphicsEndImageContext();
+
+ return context.release();
}