Unreviewed, rolling out r155069 and r155138.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 Sep 2013 18:10:56 +0000 (18:10 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 Sep 2013 18:10:56 +0000 (18:10 +0000)
http://trac.webkit.org/changeset/155069
http://trac.webkit.org/changeset/155138
https://bugs.webkit.org/show_bug.cgi?id=121008

Seems to have broken many tests (bug 120963) (Requested by ap
on #webkit).

Source/WebCore:

* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/cg/PDFDocumentImage.cpp:
(WebCore::PDFDocumentImage::PDFDocumentImage):
(WebCore::PDFDocumentImage::~PDFDocumentImage):
(WebCore::PDFDocumentImage::size):
(WebCore::PDFDocumentImage::dataChanged):
(WebCore::PDFDocumentImage::adjustCTM):
(WebCore::PDFDocumentImage::setCurrentPage):
(WebCore::PDFDocumentImage::pageCount):
(WebCore::PDFDocumentImage::draw):
* platform/graphics/cg/PDFDocumentImage.h:
(WebCore::PDFDocumentImage::create):
(WebCore::PDFDocumentImage::hasSingleSecurityOrigin):
(WebCore::PDFDocumentImage::destroyDecodedData):
(WebCore::PDFDocumentImage::decodedSize):
* platform/graphics/mac/PDFDocumentImageMac.mm: Removed.
* platform/mac/SoftLinking.h:

LayoutTests:

* fast/images/pdf-as-image-with-annotations-expected.html: Removed.
* fast/images/pdf-as-image-with-annotations.html: Removed.
* fast/images/resources/annotation.pdf: Removed.
* platform/mac/fast/images/pdf-as-image-landscape-expected.png:
* platform/mac/fast/images/pdf-as-image-landscape-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155306 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/images/pdf-as-image-with-annotations-expected.html [deleted file]
LayoutTests/fast/images/pdf-as-image-with-annotations.html [deleted file]
LayoutTests/fast/images/resources/annotation.pdf [deleted file]
LayoutTests/platform/mac/fast/images/pdf-as-image-landscape-expected.png
LayoutTests/platform/mac/fast/images/pdf-as-image-landscape-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
Source/WebCore/platform/graphics/cg/PDFDocumentImage.h
Source/WebCore/platform/graphics/mac/PDFDocumentImageMac.mm [deleted file]
Source/WebCore/platform/mac/SoftLinking.h

index 6b7cf0ea5ea69676e7a16e14a0454a580e6af02c..a0778281a41f79322d102f3e5164070c679300a2 100644 (file)
@@ -1,3 +1,19 @@
+2013-09-08  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r155069 and r155138.
+        http://trac.webkit.org/changeset/155069
+        http://trac.webkit.org/changeset/155138
+        https://bugs.webkit.org/show_bug.cgi?id=121008
+
+        Seems to have broken many tests (bug 120963) (Requested by ap
+        on #webkit).
+
+        * fast/images/pdf-as-image-with-annotations-expected.html: Removed.
+        * fast/images/pdf-as-image-with-annotations.html: Removed.
+        * fast/images/resources/annotation.pdf: Removed.
+        * platform/mac/fast/images/pdf-as-image-landscape-expected.png:
+        * platform/mac/fast/images/pdf-as-image-landscape-expected.txt:
+
 2013-09-07  Mark Lam  <mark.lam@apple.com>
 
         Change LayoutTests' u*-w* files to use pre and post js files in LayoutTests/resources.
diff --git a/LayoutTests/fast/images/pdf-as-image-with-annotations-expected.html b/LayoutTests/fast/images/pdf-as-image-with-annotations-expected.html
deleted file mode 100644 (file)
index 0a1c85a..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>
-<body style='margin: 0px'>
-<div style='background: lime; height: 100px; width: 100px; overflow: hidden;'>
-</div>
-</body>
-</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/images/pdf-as-image-with-annotations.html b/LayoutTests/fast/images/pdf-as-image-with-annotations.html
deleted file mode 100644 (file)
index 6ac5eac..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<html>
-<head>
-    <title>There should be a single 100x100 green square at 0x0.</title>
-</head>
-<body style='margin: 0px'>
-<div style='background: red; height: 100px; width: 100px; overflow: hidden;'>
-    <img src='resources/annotation.pdf'>
-</div>
-</body>
-</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/images/resources/annotation.pdf b/LayoutTests/fast/images/resources/annotation.pdf
deleted file mode 100644 (file)
index dce606e..0000000
Binary files a/LayoutTests/fast/images/resources/annotation.pdf and /dev/null differ
index 52aefe66004d6e3baf84bd3b59636333ed150fa7..72df0c04eb6246ed0a7eb4248c7963c66967526c 100644 (file)
Binary files a/LayoutTests/platform/mac/fast/images/pdf-as-image-landscape-expected.png and b/LayoutTests/platform/mac/fast/images/pdf-as-image-landscape-expected.png differ
index 293a3ad0c8b3a98a99aae9d90ad7821d23dd0e3f..a386f28f2fb295c47070470195500ec33c8b8b17 100644 (file)
@@ -1,12 +1,12 @@
-layer at (0,0) size 850x654
+layer at (0,0) size 850x653
   RenderView at (0,0) size 785x585
-layer at (0,0) size 785x654
-  RenderBlock {HTML} at (0,0) size 785x654
-    RenderBody {BODY} at (8,8) size 769x630
+layer at (0,0) size 785x653
+  RenderBlock {HTML} at (0,0) size 785x653
+    RenderBody {BODY} at (8,8) size 769x629
       RenderBlock (anonymous) at (0,0) size 769x18
         RenderText {#text} at (0,0) size 663x18
           text run at (0,0) width 349: "This test that we correctly orient landscape pdf images. "
           text run at (349,0) width 314: "The green rectangle should be wider than it is tall."
-      RenderBlock {P} at (0,34) size 769x596
-        RenderImage {IMG} at (0,0) size 842x596
+      RenderBlock {P} at (0,34) size 769x595
+        RenderImage {IMG} at (0,0) size 842x595
         RenderText {#text} at (0,0) size 0x0
index 2ba466275160b5e848ab188a2328c399239d733a..914536d06a7344e7235c83fd41bb391a1ef0226b 100644 (file)
@@ -1,3 +1,31 @@
+2013-09-08  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r155069 and r155138.
+        http://trac.webkit.org/changeset/155069
+        http://trac.webkit.org/changeset/155138
+        https://bugs.webkit.org/show_bug.cgi?id=121008
+
+        Seems to have broken many tests (bug 120963) (Requested by ap
+        on #webkit).
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/cg/PDFDocumentImage.cpp:
+        (WebCore::PDFDocumentImage::PDFDocumentImage):
+        (WebCore::PDFDocumentImage::~PDFDocumentImage):
+        (WebCore::PDFDocumentImage::size):
+        (WebCore::PDFDocumentImage::dataChanged):
+        (WebCore::PDFDocumentImage::adjustCTM):
+        (WebCore::PDFDocumentImage::setCurrentPage):
+        (WebCore::PDFDocumentImage::pageCount):
+        (WebCore::PDFDocumentImage::draw):
+        * platform/graphics/cg/PDFDocumentImage.h:
+        (WebCore::PDFDocumentImage::create):
+        (WebCore::PDFDocumentImage::hasSingleSecurityOrigin):
+        (WebCore::PDFDocumentImage::destroyDecodedData):
+        (WebCore::PDFDocumentImage::decodedSize):
+        * platform/graphics/mac/PDFDocumentImageMac.mm: Removed.
+        * platform/mac/SoftLinking.h:
+
 2013-09-08  Andreas Kling  <akling@apple.com>
 
         ScriptExecutionContext: Use FINAL instead of foo() { virtualFoo() }
index 146b821a3b7dcf7970c8e6c8fb6f7a7475a745a5..4238390c0ef98469a6acaa914f36b78bc2ffa77e 100644 (file)
                2D5A592F152525230036EE51 /* ImageOrientation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8748D7412CC3F89001FBA41 /* ImageOrientation.cpp */; };
                2D5A5931152525D00036EE51 /* ImageOrientation.h in Headers */ = {isa = PBXBuildFile; fileRef = A8748D6612CC3763001FBA41 /* ImageOrientation.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2D5BC42716F882EE007048D0 /* SecurityPolicyViolationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D5BC42516F882BE007048D0 /* SecurityPolicyViolationEvent.h */; };
-               2D6E468417D660F500ECF8BB /* PDFDocumentImageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D6E468217D660F500ECF8BB /* PDFDocumentImageMac.mm */; };
                2D8287F616E4A0380086BD00 /* HitTestLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D8287F416E4A0380086BD00 /* HitTestLocation.cpp */; };
                2D8287F716E4A0380086BD00 /* HitTestLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D8287F516E4A0380086BD00 /* HitTestLocation.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2D8FEBDC143E3EF70072502B /* CSSCrossfadeValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D8FEBDA143E3EF70072502B /* CSSCrossfadeValue.cpp */; };
                2D46F04F17B96FD2005647F0 /* IntSize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntSize.cpp; sourceTree = "<group>"; };
                2D5BC42516F882BE007048D0 /* SecurityPolicyViolationEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecurityPolicyViolationEvent.h; sourceTree = "<group>"; };
                2D5BC42616F882BE007048D0 /* SecurityPolicyViolationEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SecurityPolicyViolationEvent.idl; sourceTree = "<group>"; };
-               2D6E468217D660F500ECF8BB /* PDFDocumentImageMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PDFDocumentImageMac.mm; sourceTree = "<group>"; };
                2D8287F416E4A0380086BD00 /* HitTestLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HitTestLocation.cpp; sourceTree = "<group>"; };
                2D8287F516E4A0380086BD00 /* HitTestLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HitTestLocation.h; sourceTree = "<group>"; };
                2D8FEBDA143E3EF70072502B /* CSSCrossfadeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSCrossfadeValue.cpp; sourceTree = "<group>"; };
                                E4B41E100CBF90EF00AF2ECE /* MediaPlayerPrivateQTKit.h */,
                                E4B41E110CBF90EF00AF2ECE /* MediaPlayerPrivateQTKit.mm */,
                                0735EE690F40C5E4004A2604 /* MediaPlayerProxy.h */,
-                               2D6E468217D660F500ECF8BB /* PDFDocumentImageMac.mm */,
                                163E88F5118A39D200ED9231 /* SimpleFontDataCoreText.cpp */,
                                B2AFFC770D00A5C10030074D /* SimpleFontDataMac.mm */,
                                49FFBF3D11C93EE3006A7118 /* WebGLLayer.h */,
                                4ACBC0CA12713D0A0094F9B2 /* JSDOMSettableTokenList.cpp in Sources */,
                                C5137CF211A58378004ADB99 /* JSDOMStringList.cpp in Sources */,
                                9A1B6F97158869C80011A8C4 /* JSDOMStringListCustom.cpp in Sources */,
-                               2D6E468417D660F500ECF8BB /* PDFDocumentImageMac.mm in Sources */,
                                BC64649711D82349006455B0 /* JSDOMStringMap.cpp in Sources */,
                                BC64649C11D8238C006455B0 /* JSDOMStringMapCustom.cpp in Sources */,
                                7694563C1214D97C0007CBAE /* JSDOMTokenList.cpp in Sources */,
index 9af69cdc9e003b9a630c5c4481d1117c8631f4bc..ecd73ef130e1acce3511a31fac8babac59d2ab04 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006, 2013 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "ImageSourceCG.h"
 #endif
 
+using namespace std;
+
 namespace WebCore {
 
 PDFDocumentImage::PDFDocumentImage()
     : Image(0) // PDFs don't animate
+    , m_document(0)
     , m_rotation(0.0f)
-    , m_hasPage(false)
+    , m_currentPage(-1)
 {
 }
 
 PDFDocumentImage::~PDFDocumentImage()
 {
+    CGPDFDocumentRelease(m_document);
 }
 
 String PDFDocumentImage::filenameExtension() const
@@ -66,10 +70,10 @@ IntSize PDFDocumentImage::size() const
     const float cosa = cosf(-m_rotation);
     const float width = m_mediaBox.size().width();
     const float height = m_mediaBox.size().height();
-    const float rotWidth = fabsf(width * cosa - height * sina);
-    const float rotHeight = fabsf(width * sina + height * cosa);
+    const float rotWidth = width * cosa - height * sina;
+    const float rotHeight = width * sina + height * cosa;
     
-    return expandedIntSize(FloatSize(rotWidth, rotHeight));
+    return IntSize((int)(fabsf(rotWidth) + 0.5f), (int)(fabsf(rotHeight) + 0.5f));
 }
 
 void PDFDocumentImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
@@ -81,19 +85,27 @@ void PDFDocumentImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length
 
 bool PDFDocumentImage::dataChanged(bool allDataReceived)
 {
-    ASSERT(!m_document);
     if (allDataReceived && !m_document) {
-        createPDFDocument();
-
-        if (pageCount()) {
-            m_hasPage = true;
-            computeBoundsForCurrentPage();
-        }
+#if PLATFORM(MAC)
+        // On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge.  We use SharedBuffer's ability
+        // to wrap itself inside CFData to get around this, ensuring that ImageIO is really looking at the SharedBuffer.
+        RetainPtr<CFDataRef> data = adoptCF(this->data()->createCFData());
+        RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateWithCFData(data.get()));
+#else
+        // Create a CGDataProvider to wrap the SharedBuffer.
+        // We use the GetBytesAtPosition callback rather than the GetBytePointer one because SharedBuffer
+        // does not provide a way to lock down the byte pointer and guarantee that it won't move, which
+        // is a requirement for using the GetBytePointer callback.
+        CGDataProviderDirectCallbacks providerCallbacks = { 0, 0, 0, sharedBufferGetBytesAtPosition, 0 };
+        RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateDirect(this->data(), this->data()->size(), &providerCallbacks));
+#endif
+        m_document = CGPDFDocumentCreateWithProvider(dataProvider.get());
+        setCurrentPage(0);
     }
-    return m_document; // Return true if size is available.
+    return m_document; // return true if size is available
 }
 
-void PDFDocumentImage::applyRotationForPainting(GraphicsContext* context) const
+void PDFDocumentImage::adjustCTM(GraphicsContext* context) const
 {
     // rotate the crop box and calculate bounding box
     float sina = sinf(-m_rotation);
@@ -101,86 +113,88 @@ void PDFDocumentImage::applyRotationForPainting(GraphicsContext* context) const
     float width = m_cropBox.width();
     float height = m_cropBox.height();
 
-    // calculate rotated x and y edges of the crop box. if they're negative, it means part of the image has
+    // calculate rotated x and y edges of the corp box. if they're negative, it means part of the image has
     // been rotated outside of the bounds and we need to shift over the image so it lies inside the bounds again
     CGPoint rx = CGPointMake(width * cosa, width * sina);
     CGPoint ry = CGPointMake(-height * sina, height * cosa);
 
     // adjust so we are at the crop box origin
     const CGFloat zero = 0;
-    CGContextTranslateCTM(context->platformContext(), floorf(-std::min(zero, std::min(rx.x, ry.x))), floorf(-std::min(zero, std::min(rx.y, ry.y))));
+    CGContextTranslateCTM(context->platformContext(), floorf(-min(zero, min(rx.x, ry.x))), floorf(-min(zero, min(rx.y, ry.y))));
 
     // rotate -ve to remove rotation
     CGContextRotateCTM(context->platformContext(), -m_rotation);
+
+    // shift so we are completely within media box
+    CGContextTranslateCTM(context->platformContext(), m_mediaBox.x() - m_cropBox.x(), m_mediaBox.y() - m_cropBox.y());
 }
 
-void PDFDocumentImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator op, BlendMode)
+void PDFDocumentImage::setCurrentPage(int page)
 {
-    if (!m_document || !m_hasPage)
+    if (!m_document)
         return;
 
-    {
-        GraphicsContextStateSaver stateSaver(*context);
-
-        context->setCompositeOperation(op);
-
-        float hScale = dstRect.width() / srcRect.width();
-        float vScale = dstRect.height() / srcRect.height();
-
-        // Scale and translate so the document is rendered in the correct location,
-        // accounting for the fact that the GraphicsContext is flipped.
-        CGContextTranslateCTM(context->platformContext(), dstRect.x() - srcRect.x() * hScale, dstRect.y() - srcRect.y() * vScale);
-        CGContextScaleCTM(context->platformContext(), hScale, vScale);
-        CGContextScaleCTM(context->platformContext(), 1, -1);
-        CGContextTranslateCTM(context->platformContext(), 0, -srcRect.height());
-        CGContextClipToRect(context->platformContext(), CGRectIntegral(srcRect));
-
-        drawPDFPage(context);
-    }
+    if (page == m_currentPage)
+        return;
 
-    if (imageObserver())
-        imageObserver()->didDraw(this);
-}
+    if (!(page >= 0 && page < pageCount()))
+        return;
 
-#if !USE(PDFKIT_FOR_PDFDOCUMENTIMAGE)
-void PDFDocumentImage::createPDFDocument()
-{
-    RetainPtr<CFDataRef> data = adoptCF(this->data()->createCFData());
-    RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateWithCFData(data.get()));
-    m_document = CGPDFDocumentCreateWithProvider(dataProvider.get());
-}
+    m_currentPage = page;
 
-void PDFDocumentImage::computeBoundsForCurrentPage()
-{
-    CGPDFPageRef cgPage = CGPDFDocumentGetPage(m_document.get(), 1);
+    CGPDFPageRef cgPage = CGPDFDocumentGetPage(m_document, page + 1);
 
+    // get media box (guaranteed)
     m_mediaBox = CGPDFPageGetBoxRect(cgPage, kCGPDFMediaBox);
 
-    // Get crop box (not always there). If not, use media box.
+    // get crop box (not always there). if not, use media box
     CGRect r = CGPDFPageGetBoxRect(cgPage, kCGPDFCropBox);
     if (!CGRectIsEmpty(r))
         m_cropBox = r;
     else
         m_cropBox = m_mediaBox;
 
-    m_rotation = deg2rad(static_cast<float>(CGPDFPageGetRotationAngle(cgPage)));
+    // get page rotation angle
+    m_rotation = CGPDFPageGetRotationAngle(cgPage) * piFloat / 180.0f; // to radians
 }
 
-unsigned PDFDocumentImage::pageCount() const
+int PDFDocumentImage::pageCount() const
 {
-    return CGPDFDocumentGetNumberOfPages(m_document.get());
+    return m_document ? CGPDFDocumentGetNumberOfPages(m_document) : 0;
 }
 
-void PDFDocumentImage::drawPDFPage(GraphicsContext* context)
+void PDFDocumentImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator op, BlendMode)
 {
-    applyRotationForPainting(context);
+    if (!m_document || m_currentPage == -1)
+        return;
 
-    CGContextTranslateCTM(context->platformContext(), -m_cropBox.x(), -m_cropBox.y());
+    {
+        GraphicsContextStateSaver stateSaver(*context);
+
+        context->setCompositeOperation(op);
+
+        float hScale = dstRect.width() / srcRect.width();
+        float vScale = dstRect.height() / srcRect.height();
 
-    // CGPDF pages are indexed from 1.
-    CGContextDrawPDFPage(context->platformContext(), CGPDFDocumentGetPage(m_document.get(), 1));
+        // Scale and translate so the document is rendered in the correct location,
+        // including accounting for the fact that a GraphicsContext is always flipped
+        // and doing appropriate flipping.
+        CGContextTranslateCTM(context->platformContext(), dstRect.x() - srcRect.x() * hScale, dstRect.y() - srcRect.y() * vScale);
+        CGContextScaleCTM(context->platformContext(), hScale, vScale);
+        CGContextScaleCTM(context->platformContext(), 1, -1);
+        CGContextTranslateCTM(context->platformContext(), 0, -srcRect.height());
+        CGContextClipToRect(context->platformContext(), CGRectIntegral(srcRect));
+
+        // Rotate translate image into position according to doc properties.
+        adjustCTM(context);
+
+        CGContextTranslateCTM(context->platformContext(), -m_mediaBox.x(), -m_mediaBox.y());
+        CGContextDrawPDFPage(context->platformContext(), CGPDFDocumentGetPage(m_document, m_currentPage + 1));
+    }
+
+    if (imageObserver())
+        imageObserver()->didDraw(this);
 }
-#endif // !USE(PDFKIT_FOR_PDFDOCUMENTIMAGE)
 
 }
 
index 11b4505173c3e19c954f99ab3ff09bf59f0e65f9..689a0310e7fa717ffb21a9e54e4ce64d06b14612 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006, 2013 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #if USE(CG)
 
-#if PLATFORM(MAC) && !PLATFORM(IOS)
-#define WTF_USE_PDFKIT_FOR_PDFDOCUMENTIMAGE 1
-#endif
-
 typedef struct CGPDFDocument *CGPDFDocumentRef;
-OBJC_CLASS PDFDocument;
 
 namespace WebCore {
 
-class GraphicsContext;
-
-class PDFDocumentImage : public Image {
-public:
-    static PassRefPtr<PDFDocumentImage> create()
-    {
-        return adoptRef(new PDFDocumentImage);
-    }
-
-private:
-    PDFDocumentImage();
-    virtual ~PDFDocumentImage();
+    class GraphicsContext;
 
-    virtual String filenameExtension() const OVERRIDE;
+    class PDFDocumentImage : public Image {
+    public:
+        static PassRefPtr<PDFDocumentImage> create()
+        {
+            return adoptRef(new PDFDocumentImage);
+        }
 
-    virtual bool hasSingleSecurityOrigin() const OVERRIDE { return true; }
+    private:
+        virtual ~PDFDocumentImage();
 
-    virtual bool dataChanged(bool allDataReceived) OVERRIDE;
+        virtual String filenameExtension() const;
 
-    // FIXME: PDF Images are underreporting decoded sizes and will be unable
-    // to prune because these functions are not implemented yet.
-    virtual void destroyDecodedData(bool /*destroyAll*/ = true) OVERRIDE { }
-    virtual unsigned decodedSize() const OVERRIDE { return 0; }
+        virtual bool hasSingleSecurityOrigin() const { return true; }
 
-    virtual void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) OVERRIDE;
-    virtual IntSize size() const OVERRIDE;
+        virtual bool dataChanged(bool allDataReceived);
 
-    virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode) OVERRIDE;
+        // FIXME: PDF Images are underreporting decoded sizes and will be unable
+        // to prune because these functions are not implemented yet.
+        virtual void destroyDecodedData(bool /*destroyAll*/ = true) { }
+        virtual unsigned decodedSize() const { return 0; }
 
-    // FIXME: Implement this to be less conservative.
-    virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
+        virtual void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
+        virtual IntSize size() const;
 
-    void applyRotationForPainting(GraphicsContext*) const;
+        PDFDocumentImage();
+        virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
 
-    void createPDFDocument();
-    void computeBoundsForCurrentPage();
-    unsigned pageCount() const;
-    void drawPDFPage(GraphicsContext*);
+        // FIXME: Implement this to be less conservative.
+        virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
 
-#if USE(PDFKIT_FOR_PDFDOCUMENTIMAGE)
-    RetainPtr<PDFDocument> m_document;
-#else
-    RetainPtr<CGPDFDocumentRef> m_document;
-#endif
+        void setCurrentPage(int);
+        int pageCount() const;
+        void adjustCTM(GraphicsContext*) const;
 
-    FloatRect m_mediaBox;
-    FloatRect m_cropBox;
-    float m_rotation;
-    bool m_hasPage;
-};
+        CGPDFDocumentRef m_document;
+        FloatRect m_mediaBox;
+        FloatRect m_cropBox;
+        float m_rotation;
+        int m_currentPage;
+    };
 
 }
 
diff --git a/Source/WebCore/platform/graphics/mac/PDFDocumentImageMac.mm b/Source/WebCore/platform/graphics/mac/PDFDocumentImageMac.mm
deleted file mode 100644 (file)
index 276fabb..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "PDFDocumentImage.h"
-
-#if USE(PDFKIT_FOR_PDFDOCUMENTIMAGE)
-
-#import "LocalCurrentGraphicsContext.h"
-#import "SharedBuffer.h"
-#import "SoftLinking.h"
-#import <Quartz/Quartz.h>
-#import <objc/objc-class.h>
-#import <wtf/RetainPtr.h>
-
-SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, PDFKit)
-SOFT_LINK_CLASS(PDFKit, PDFDocument)
-
-namespace WebCore {
-
-void PDFDocumentImage::createPDFDocument()
-{
-    m_document = adoptNS([[getPDFDocumentClass() alloc] initWithData:data()->createNSData()]);
-}
-
-void PDFDocumentImage::computeBoundsForCurrentPage()
-{
-    PDFPage *pdfPage = [m_document pageAtIndex:0];
-
-    m_mediaBox = [pdfPage boundsForBox:kPDFDisplayBoxMediaBox];
-    m_cropBox = [pdfPage boundsForBox:kPDFDisplayBoxCropBox];
-
-    m_rotation = deg2rad(static_cast<float>([pdfPage rotation]));
-}
-
-unsigned PDFDocumentImage::pageCount() const
-{
-    return [m_document pageCount];
-}
-
-void PDFDocumentImage::drawPDFPage(GraphicsContext* context)
-{
-    CGContextTranslateCTM(context->platformContext(), -m_cropBox.x(), -m_cropBox.y());
-
-    LocalCurrentGraphicsContext localCurrentContext(context);
-    [[m_document pageAtIndex:0] drawWithBox:kPDFDisplayBoxCropBox];
-}
-
-}
-
-#endif // USE(PDFKIT_FOR_PDFDOCUMENTIMAGE)
index 81c510afb92bcd740e095eae0ba8ae1d89853b89..0c5fa4d2ca6be189d9a8ba298d733813038a1db3 100644 (file)
         return frameworkLibrary; \
     }
 
-#define SOFT_LINK_FRAMEWORK_IN_UMBRELLA(umbrella, framework) \
+#define SOFT_LINK_FRAMEWORK_IN_CORESERVICES_UMBRELLA(framework) \
     static void* framework##Library() \
     { \
-        static void* frameworkLibrary = dlopen("/System/Library/Frameworks/" #umbrella ".framework/Frameworks/" #framework ".framework/" #framework, RTLD_NOW); \
+        static void* frameworkLibrary = dlopen("/System/Library/Frameworks/CoreServices.framework/Frameworks/" #framework ".framework/" #framework, RTLD_NOW); \
         ASSERT_WITH_MESSAGE(frameworkLibrary, "%s", dlerror()); \
         return frameworkLibrary; \
     }