Changeset 103858 in webkit
- Timestamp:
- Dec 31, 2011, 12:29:46 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r103856 r103858 1 2011-12-31 Dan Bernstein <mitz@apple.com> 2 3 WebCore changes for <rdar://problem/8750356> REGRESSION (WebKit2): Printing a subframe containing a PDF prints the on-screen view instead of the entire PDF document 4 <http://webkit.org/b/75232> 5 6 Reviewed by Alexey Proskuryakov. 7 8 * WebCore.exp.in: Exported PluginDocument::pluginWidget(). 9 * WebCore.xcodeproj/project.pbxproj: Promoted PluginDocument.h to private. 10 * html/PluginDocument.h: Fixed a typo in a comment. 11 1 12 2011-12-30 Andreas Kling <awesomekling@apple.com> 2 13 -
trunk/Source/WebCore/WebCore.exp.in
r103790 r103858 357 357 __ZN7WebCore14FrameSelection9selectAllEv 358 358 __ZN7WebCore14FrameSelectionC1EPNS_5FrameE 359 __ZN7WebCore14PluginDocument12pluginWidgetEv 359 360 __ZN7WebCore14ResourceHandle20forceContentSniffingEv 360 361 __ZN7WebCore14ResourceHandle26synchronousLoadRunLoopModeEv -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r103643 r103858 3265 3265 97205AB81239291000B17380 /* MediaDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 97205AB41239291000B17380 /* MediaDocument.h */; }; 3266 3266 97205ABB1239292700B17380 /* PluginDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97205AB91239292700B17380 /* PluginDocument.cpp */; }; 3267 97205ABC1239292700B17380 /* PluginDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 97205ABA1239292700B17380 /* PluginDocument.h */; };3267 97205ABC1239292700B17380 /* PluginDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 97205ABA1239292700B17380 /* PluginDocument.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3268 3268 9728C3131268E4390041E89B /* MarkupAccumulator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9728C3111268E4390041E89B /* MarkupAccumulator.cpp */; }; 3269 3269 9728C3141268E4390041E89B /* MarkupAccumulator.h in Headers */ = {isa = PBXBuildFile; fileRef = 9728C3121268E4390041E89B /* MarkupAccumulator.h */; }; -
trunk/Source/WebCore/html/PluginDocument.h
r103692 r103858 1 1 /* 2 * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved.2 * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without -
trunk/Source/WebKit2/ChangeLog
r103843 r103858 1 2011-12-31 Dan Bernstein <mitz@apple.com> 2 3 <rdar://problem/8750356> REGRESSION (WebKit2): Printing a subframe containing a PDF prints the on-screen view instead of the entire PDF document 4 <http://webkit.org/b/75232> 5 6 Reviewed by Alexey Proskuryakov. 7 8 * UIProcess/API/C/WKPage.cpp: 9 (WKPageDrawPagesToPDF): Added WKPrintInfo parameter, which is passed through as a PrintInfo 10 to the WebPageProxy. 11 * UIProcess/API/C/WKPagePrivate.h: 12 * UIProcess/API/mac/WKPrintingView.mm: 13 (-[WKPrintingView _preparePDFDataForPrintingOnSecondaryThread]): Changed to pass the PrintInfo 14 down to WebPageProxy::drawPagesToPDF. 15 (-[WKPrintingView _drawPreview:]): Changed to pass the PrintInfo down to 16 WebPageProxy::drawRectToPDF. 17 * UIProcess/API/mac/WKView.mm: 18 (-[WKView canChangeFrameLayout:]): Changed to use WebFrameProxy::isDisplayingPDFDocument, which 19 works for subframes as well. 20 (-[WKView printOperationWithPrintInfo:forFrame:]): Added a FIXME. 21 * UIProcess/WebFrameProxy.cpp: 22 (WebKit::WebFrameProxy::isDisplayingPDFDocument): Added. 23 * UIProcess/WebFrameProxy.h: 24 * UIProcess/WebPageProxy.cpp: 25 (WebKit::WebPageProxy::drawRectToPDF): Added a PrintInfo parameter, which is passed through to 26 the Web process. 27 (WebKit::WebPageProxy::drawPagesToPDF): Ditto. 28 * UIProcess/WebPageProxy.h: 29 * WebProcess/Plugins/PDF/BuiltInPDFView.h: 30 Added an override of pdfDocumentForPrinting() which returns the PDFDocument. 31 * WebProcess/Plugins/Plugin.h: 32 (WebKit::Plugin::pdfDocumentForPrinting): Added. This base class implementation returns 0. 33 * WebProcess/Plugins/PluginView.h: 34 (WebKit::PluginView::pdfDocumentForPrinting): Added. Calls through to the Plugin. 35 * WebProcess/WebPage/WebPage.cpp: 36 (WebKit::pdfDocumentForPrintingFrame): Added this helper function. If the frame is displaying 37 a plug-in document, allows the plug-in to provide a PDF document for printing. 38 (WebKit::WebPage::beginPrinting): Added an early return if the frame provides a PDF document 39 for printing. 40 (WebKit::WebPage::computePagesForPrinting): If the frame provides a PDF document for printing, 41 create for each page in the PDF document a page rect with the size available for printing. 42 (WebKit::drawPDFPage): Added this helper function, which draws a page from the PDF document 43 into one of the aforementioned page rects. It rotates the PDF page 90 degrees if necessary to 44 better match the aspect ratio of the paper, then it centers it on the paper. This matches the 45 behavior of a PDFView when printed with default settings. 46 (WebKit::WebPage::drawRectToPDF): If the frame provides a PDF document for printing, draw the 47 PDF pages falling within the requested rect. 48 (WebKit::WebPage::drawPagesToPDF): If the frame provides a PDF document for printing, draw 49 the requested pages. 50 * WebProcess/WebPage/WebPage.h: 51 * WebProcess/WebPage/WebPage.messages.in: Added a PrintInfo parameter to DrawRectToPDF and 52 DrawPagesToPDF. 53 1 54 2011-12-30 Dan Bernstein <mitz@apple.com> 2 55 -
trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp
r101574 r103858 647 647 } 648 648 649 void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context)650 { 651 toImpl(page)->drawPagesToPDF(toImpl(frame), first, count, DataCallback::create(context, callback));649 void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context) 650 { 651 toImpl(page)->drawPagesToPDF(toImpl(frame), printInfoFromWKPrintInfo(printInfo), first, count, DataCallback::create(context, callback)); 652 652 } 653 653 #endif -
trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h
r101574 r103858 80 80 81 81 typedef void (*WKPageDrawToPDFFunction)(WKDataRef data, WKErrorRef error, void* functionContext); 82 WK_EXPORT void WKPageBeginPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo );83 WK_EXPORT void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context);82 WK_EXPORT void WKPageBeginPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo); 83 WK_EXPORT void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context); 84 84 85 85 // FIXME https://bugs.webkit.org/show_bug.cgi?id=66979: Remove this sync call. -
trunk/Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm
r98526 r103858 253 253 LOG(View, "WKPrintingView requesting PDF data for pages %u...%u", firstPage, lastPage); 254 254 255 PrintInfo printInfo([_printOperation printInfo]); 255 256 // Return to printing mode if we're already back to screen (e.g. due to window resizing). 256 _webFrame->page()->beginPrinting(_webFrame.get(), PrintInfo([_printOperation printInfo]));257 _webFrame->page()->beginPrinting(_webFrame.get(), printInfo); 257 258 258 259 IPCCallbackContext* context = new IPCCallbackContext; … … 263 264 context->callbackID = callback->callbackID(); 264 265 265 _webFrame->page()->drawPagesToPDF(_webFrame.get(), firstPage - 1, lastPage - firstPage + 1, callback.get());266 _webFrame->page()->drawPagesToPDF(_webFrame.get(), printInfo, firstPage - 1, lastPage - firstPage + 1, callback.get()); 266 267 } 267 268 … … 453 454 context->callbackID = callback->callbackID(); 454 455 455 _webFrame->page()->drawRectToPDF(_webFrame.get(), rect, callback.get());456 _webFrame->page()->drawRectToPDF(_webFrame.get(), PrintInfo([_printOperation printInfo]), rect, callback.get()); 456 457 return; 457 458 } -
trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm
r103643 r103858 2718 2718 { 2719 2719 // PDF documents are already paginated, so we can't change them to add headers and footers. 2720 return !toImpl(frameRef)->is MainFrame() || !_data->_pdfViewController;2720 return !toImpl(frameRef)->isDisplayingPDFDocument(); 2721 2721 } 2722 2722 … … 2731 2731 return _data->_pdfViewController->makePrintOperation(printInfo); 2732 2732 } else { 2733 // FIXME: If the frame cannot be printed (e.g. if it contains an encrypted PDF that disallows 2734 // printing), this function should return nil. 2733 2735 RetainPtr<WKPrintingView> printingView(AdoptNS, [[WKPrintingView alloc] initWithFrameProxy:toImpl(frameRef) view:self]); 2734 2736 // NSPrintOperation takes ownership of the view. -
trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp
r98513 r103858 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved.2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 130 130 } 131 131 132 bool WebFrameProxy::isDisplayingPDFDocument() const 133 { 134 if (m_MIMEType.isEmpty()) 135 return false; 136 137 return WebContext::pdfAndPostScriptMIMETypes().contains(m_MIMEType); 138 } 139 132 140 void WebFrameProxy::didStartProvisionalLoad(const String& url) 133 141 { -
trunk/Source/WebKit2/UIProcess/WebFrameProxy.h
r95901 r103858 107 107 bool isDisplayingStandaloneImageDocument() const; 108 108 bool isDisplayingMarkupDocument() const; 109 bool isDisplayingPDFDocument() const; 109 110 110 111 void getWebArchive(PassRefPtr<DataCallback>); -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r103281 r103858 3432 3432 3433 3433 #if PLATFORM(MAC) || PLATFORM(WIN) 3434 void WebPageProxy::drawRectToPDF(WebFrameProxy* frame, const IntRect& rect, PassRefPtr<DataCallback> prpCallback)3434 void WebPageProxy::drawRectToPDF(WebFrameProxy* frame, const PrintInfo& printInfo, const IntRect& rect, PassRefPtr<DataCallback> prpCallback) 3435 3435 { 3436 3436 RefPtr<DataCallback> callback = prpCallback; … … 3442 3442 uint64_t callbackID = callback->callbackID(); 3443 3443 m_dataCallbacks.set(callbackID, callback.get()); 3444 process()->send(Messages::WebPage::DrawRectToPDF(frame->frameID(), rect, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);3445 } 3446 3447 void WebPageProxy::drawPagesToPDF(WebFrameProxy* frame, uint32_t first, uint32_t count, PassRefPtr<DataCallback> prpCallback)3444 process()->send(Messages::WebPage::DrawRectToPDF(frame->frameID(), printInfo, rect, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0); 3445 } 3446 3447 void WebPageProxy::drawPagesToPDF(WebFrameProxy* frame, const PrintInfo& printInfo, uint32_t first, uint32_t count, PassRefPtr<DataCallback> prpCallback) 3448 3448 { 3449 3449 RefPtr<DataCallback> callback = prpCallback; … … 3455 3455 uint64_t callbackID = callback->callbackID(); 3456 3456 m_dataCallbacks.set(callbackID, callback.get()); 3457 process()->send(Messages::WebPage::DrawPagesToPDF(frame->frameID(), first, count, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);3457 process()->send(Messages::WebPage::DrawPagesToPDF(frame->frameID(), printInfo, first, count, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0); 3458 3458 } 3459 3459 #endif -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r103802 r103858 560 560 void computePagesForPrinting(WebFrameProxy*, const PrintInfo&, PassRefPtr<ComputedPagesCallback>); 561 561 #if PLATFORM(MAC) || PLATFORM(WIN) 562 void drawRectToPDF(WebFrameProxy*, const WebCore::IntRect&, PassRefPtr<DataCallback>);563 void drawPagesToPDF(WebFrameProxy*, uint32_t first, uint32_t count, PassRefPtr<DataCallback>);562 void drawRectToPDF(WebFrameProxy*, const PrintInfo&, const WebCore::IntRect&, PassRefPtr<DataCallback>); 563 void drawPagesToPDF(WebFrameProxy*, const PrintInfo&, uint32_t first, uint32_t count, PassRefPtr<DataCallback>); 564 564 #endif 565 565 -
trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h
r101290 r103858 114 114 virtual WebCore::Scrollbar* verticalScrollbar(); 115 115 116 virtual RetainPtr<CGPDFDocumentRef> pdfDocumentForPrinting() const OVERRIDE { return m_pdfDocument; } 117 116 118 // ScrollableArea methods. 117 119 virtual WebCore::IntRect scrollCornerRect() const; -
trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h
r99241 r103858 31 31 #include <WebCore/ScrollTypes.h> 32 32 #include <wtf/RefCounted.h> 33 #include <wtf/RetainPtr.h> 33 34 #include <wtf/Vector.h> 34 35 … … 219 220 virtual WebCore::Scrollbar* verticalScrollbar() = 0; 220 221 222 #if USE(CG) 223 virtual RetainPtr<CGPDFDocumentRef> pdfDocumentForPrinting() const { return 0; } 224 #endif 225 221 226 protected: 222 227 Plugin(); -
trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h
r103009 r103858 69 69 #endif 70 70 71 #if USE(CG) 72 RetainPtr<CGPDFDocumentRef> pdfDocumentForPrinting() const { return m_plugin->pdfDocumentForPrinting(); } 73 #endif 74 71 75 // FIXME: Remove this; nobody should have to know about the plug-in view's renderer except the plug-in view itself. 72 76 WebCore::RenderBoxModelObject* renderer() const; -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r103566 r103858 96 96 #include <WebCore/Page.h> 97 97 #include <WebCore/PlatformKeyboardEvent.h> 98 #include <WebCore/PluginDocument.h> 98 99 #include <WebCore/PrintContext.h> 99 100 #include <WebCore/RenderArena.h> … … 142 143 using namespace JSC; 143 144 using namespace WebCore; 145 using namespace std; 144 146 145 147 namespace WebKit { … … 2565 2567 #endif 2566 2568 2569 #if USE(CG) 2570 static RetainPtr<CGPDFDocumentRef> pdfDocumentForPrintingFrame(Frame* coreFrame) 2571 { 2572 Document* document = coreFrame->document(); 2573 if (!document) 2574 return 0; 2575 2576 if (!document->isPluginDocument()) 2577 return 0; 2578 2579 PluginView* pluginView = static_cast<PluginView*>(toPluginDocument(document)->pluginWidget()); 2580 if (!pluginView) 2581 return 0; 2582 2583 return pluginView->pdfDocumentForPrinting(); 2584 } 2585 #endif // USE(CG) 2586 2567 2587 void WebPage::beginPrinting(uint64_t frameID, const PrintInfo& printInfo) 2568 2588 { … … 2574 2594 if (!coreFrame) 2575 2595 return; 2596 2597 #if USE(CG) 2598 if (pdfDocumentForPrintingFrame(coreFrame)) 2599 return; 2600 #endif // USE(CG) 2576 2601 2577 2602 if (!m_printContext) … … 2600 2625 resultTotalScaleFactorForPrinting = m_printContext->computeAutomaticScaleFactor(FloatSize(printInfo.availablePaperWidth, printInfo.availablePaperHeight)) * printInfo.pageSetupScaleFactor; 2601 2626 } 2627 #if USE(CG) 2628 else { 2629 WebFrame* frame = WebProcess::shared().webFrame(frameID); 2630 Frame* coreFrame = frame ? frame->coreFrame() : 0; 2631 RetainPtr<CGPDFDocumentRef> pdfDocument = coreFrame ? pdfDocumentForPrintingFrame(coreFrame) : 0; 2632 if (pdfDocument && CGPDFDocumentAllowsPrinting(pdfDocument.get())) { 2633 CFIndex pageCount = CGPDFDocumentGetNumberOfPages(pdfDocument.get()); 2634 IntRect pageRect(0, 0, ceilf(printInfo.availablePaperWidth), ceilf(printInfo.availablePaperHeight)); 2635 for (CFIndex i = 1; i <= pageCount; ++i) { 2636 resultPageRects.append(pageRect); 2637 pageRect.move(0, pageRect.height()); 2638 } 2639 } 2640 } 2641 #endif // USE(CG) 2602 2642 2603 2643 // If we're asked to print, we should actually print at least a blank page. … … 2608 2648 } 2609 2649 2650 #if USE(CG) 2651 static inline CGFloat roundCGFloat(CGFloat f) 2652 { 2653 if (sizeof(CGFloat) == sizeof(float)) 2654 return roundf(static_cast<float>(f)); 2655 return static_cast<CGFloat>(round(f)); 2656 } 2657 2658 static void drawPDFPage(CGPDFDocumentRef pdfDocument, CFIndex pageIndex, CGContextRef context, CGFloat pageSetupScaleFactor, CGSize paperSize) 2659 { 2660 CGContextSaveGState(context); 2661 2662 CGContextScaleCTM(context, pageSetupScaleFactor, pageSetupScaleFactor); 2663 2664 CGPDFPageRef page = CGPDFDocumentGetPage(pdfDocument, pageIndex + 1); 2665 CGRect cropBox = CGPDFPageGetBoxRect(page, kCGPDFCropBox); 2666 if (CGRectIsEmpty(cropBox)) 2667 cropBox = CGRectIntersection(cropBox, CGPDFPageGetBoxRect(page, kCGPDFMediaBox)); 2668 else 2669 cropBox = CGPDFPageGetBoxRect(page, kCGPDFMediaBox); 2670 2671 bool shouldRotate = (paperSize.width < paperSize.height) != (cropBox.size.width < cropBox.size.height); 2672 if (shouldRotate) 2673 swap(cropBox.size.width, cropBox.size.height); 2674 2675 // Center. 2676 CGFloat widthDifference = paperSize.width / pageSetupScaleFactor - cropBox.size.width; 2677 CGFloat heightDifference = paperSize.height / pageSetupScaleFactor - cropBox.size.height; 2678 if (widthDifference || heightDifference) 2679 CGContextTranslateCTM(context, roundCGFloat(widthDifference / 2), roundCGFloat(heightDifference / 2)); 2680 2681 if (shouldRotate) { 2682 CGContextRotateCTM(context, M_PI_2); 2683 CGContextTranslateCTM(context, 0, -cropBox.size.width); 2684 } 2685 2686 CGContextDrawPDFPage(context, page); 2687 2688 CGContextRestoreGState(context); 2689 } 2690 #endif // USE(CG) 2691 2610 2692 #if PLATFORM(MAC) || PLATFORM(WIN) 2611 void WebPage::drawRectToPDF(uint64_t frameID, const WebCore::IntRect& rect, uint64_t callbackID)2693 void WebPage::drawRectToPDF(uint64_t frameID, const PrintInfo& printInfo, const WebCore::IntRect& rect, uint64_t callbackID) 2612 2694 { 2613 2695 WebFrame* frame = WebProcess::shared().webFrame(frameID); … … 2617 2699 2618 2700 if (coreFrame) { 2619 ASSERT(coreFrame->document()->printing()); 2701 ASSERT(coreFrame->document()->printing() 2702 #if USE(CG) 2703 || pdfDocumentForPrintingFrame(coreFrame) 2704 #endif 2705 ); 2620 2706 2621 2707 #if USE(CG) … … 2628 2714 CGPDFContextBeginPage(context.get(), pageInfo.get()); 2629 2715 2630 GraphicsContext ctx(context.get()); 2631 ctx.scale(FloatSize(1, -1)); 2632 ctx.translate(0, -rect.height()); 2633 m_printContext->spoolRect(ctx, rect); 2716 if (RetainPtr<CGPDFDocumentRef> pdfDocument = pdfDocumentForPrintingFrame(coreFrame)) { 2717 CFIndex pageCount = CGPDFDocumentGetNumberOfPages(pdfDocument.get()); 2718 IntSize paperSize(ceilf(printInfo.availablePaperWidth), ceilf(printInfo.availablePaperHeight)); 2719 IntRect pageRect(IntPoint(), paperSize); 2720 for (CFIndex i = 0; i < pageCount; ++i) { 2721 if (pageRect.intersects(rect)) { 2722 CGContextSaveGState(context.get()); 2723 2724 CGContextTranslateCTM(context.get(), pageRect.x() - rect.x(), pageRect.y() - rect.y()); 2725 drawPDFPage(pdfDocument.get(), i, context.get(), printInfo.pageSetupScaleFactor, paperSize); 2726 2727 CGContextRestoreGState(context.get()); 2728 } 2729 pageRect.move(0, pageRect.height()); 2730 } 2731 } else { 2732 GraphicsContext ctx(context.get()); 2733 ctx.scale(FloatSize(1, -1)); 2734 ctx.translate(0, -rect.height()); 2735 m_printContext->spoolRect(ctx, rect); 2736 } 2634 2737 2635 2738 CGPDFContextEndPage(context.get()); 2636 2739 CGPDFContextClose(context.get()); 2740 #else 2741 UNUSED_PARAM(printInfo); 2637 2742 #endif 2638 2743 } … … 2641 2746 } 2642 2747 2643 void WebPage::drawPagesToPDF(uint64_t frameID, uint32_t first, uint32_t count, uint64_t callbackID)2748 void WebPage::drawPagesToPDF(uint64_t frameID, const PrintInfo& printInfo, uint32_t first, uint32_t count, uint64_t callbackID) 2644 2749 { 2645 2750 WebFrame* frame = WebProcess::shared().webFrame(frameID); … … 2649 2754 2650 2755 if (coreFrame) { 2651 ASSERT(coreFrame->document()->printing()); 2652 2756 2757 ASSERT(coreFrame->document()->printing() 2653 2758 #if USE(CG) 2759 || pdfDocumentForPrintingFrame(coreFrame) 2760 #endif 2761 ); 2762 2763 #if USE(CG) 2764 RetainPtr<CGPDFDocumentRef> pdfDocument = pdfDocumentForPrintingFrame(coreFrame); 2765 2654 2766 // FIXME: Use CGDataConsumerCreate with callbacks to avoid copying the data. 2655 2767 RetainPtr<CGDataConsumerRef> pdfDataConsumer(AdoptCF, CGDataConsumerCreateWithCFData(pdfPageData.get())); 2656 2768 2657 CGRect mediaBox = m_printContext ->pageCount() ? m_printContext->pageRect(0) : CGRectMake(0, 0, 1, 1);2769 CGRect mediaBox = m_printContext && m_printContext->pageCount() ? m_printContext->pageRect(0) : CGRectMake(0, 0, printInfo.availablePaperWidth, printInfo.availablePaperHeight); 2658 2770 RetainPtr<CGContextRef> context(AdoptCF, CGPDFContextCreate(pdfDataConsumer.get(), &mediaBox, 0)); 2771 size_t pageCount = m_printContext ? m_printContext->pageCount() : CGPDFDocumentGetNumberOfPages(pdfDocument.get()); 2659 2772 for (uint32_t page = first; page < first + count; ++page) { 2660 if (page >= m_printContext->pageCount())2773 if (page >= pageCount) 2661 2774 break; 2662 2775 … … 2664 2777 CGPDFContextBeginPage(context.get(), pageInfo.get()); 2665 2778 2666 GraphicsContext ctx(context.get()); 2667 ctx.scale(FloatSize(1, -1)); 2668 ctx.translate(0, -m_printContext->pageRect(page).height()); 2669 m_printContext->spoolPage(ctx, page, m_printContext->pageRect(page).width()); 2779 if (pdfDocument) 2780 drawPDFPage(pdfDocument.get(), page, context.get(), printInfo.pageSetupScaleFactor, CGSizeMake(printInfo.availablePaperWidth, printInfo.availablePaperHeight)); 2781 else { 2782 GraphicsContext ctx(context.get()); 2783 ctx.scale(FloatSize(1, -1)); 2784 ctx.translate(0, -m_printContext->pageRect(page).height()); 2785 m_printContext->spoolPage(ctx, page, m_printContext->pageRect(page).width()); 2786 } 2670 2787 2671 2788 CGPDFContextEndPage(context.get()); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r103277 r103858 429 429 void computePagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID); 430 430 #if PLATFORM(MAC) || PLATFORM(WIN) 431 void drawRectToPDF(uint64_t frameID, const WebCore::IntRect&, uint64_t callbackID);432 void drawPagesToPDF(uint64_t frameID, uint32_t first, uint32_t count, uint64_t callbackID);431 void drawRectToPDF(uint64_t frameID, const PrintInfo&, const WebCore::IntRect&, uint64_t callbackID); 432 void drawPagesToPDF(uint64_t frameID, const PrintInfo&, uint32_t first, uint32_t count, uint64_t callbackID); 433 433 #endif 434 434 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r103277 r103858 180 180 ComputePagesForPrinting(uint64_t frameID, WebKit::PrintInfo printInfo, uint64_t callbackID) 181 181 #if PLATFORM(MAC) || PLATFORM(WIN) 182 DrawRectToPDF(uint64_t frameID, Web Core::IntRect rect, uint64_t callbackID)183 DrawPagesToPDF(uint64_t frameID, uint32_t first, uint32_t count, uint64_t callbackID)182 DrawRectToPDF(uint64_t frameID, WebKit::PrintInfo printInfo, WebCore::IntRect rect, uint64_t callbackID) 183 DrawPagesToPDF(uint64_t frameID, WebKit::PrintInfo printInfo, uint32_t first, uint32_t count, uint64_t callbackID) 184 184 #endif 185 185
Note:
See TracChangeset
for help on using the changeset viewer.