Changeset 80398 in webkit
- Timestamp:
- Mar 4, 2011 5:21:09 PM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r80395 r80398 1 2011-03-04 Jon Honeycutt <jhoneycutt@apple.com> 2 3 WK2 needs printing support on Windows 4 https://bugs.webkit.org/show_bug.cgi?id=55800 5 <rdar://problem/8903808> 6 7 Reviewed by Darin Adler. 8 9 * UIProcess/API/C/WKPage.cpp: 10 (ComputedPagesContext::ComputedPagesContext): 11 (computedPagesCallback): 12 From the Vector of WebCore::IntRects, build up a Vector of WKRects. 13 Call the callback, passing these rects and the scale factor. 14 (printInfoFromWKPrintInfo): 15 Return a PrintInfo structure from the WKPrintInfo. 16 (WKPageComputePagesForPrinting): 17 Call WebPageProxy::computePagesForPrinting(). Pass 18 computedPagesCallback as the callback function, so that we can 19 translate the WebCore rect type to WKRect before calling the caller's 20 callback function. 21 (WKPageBeginPrinting): 22 Call WebPageProxy::beginPrinting(). 23 (WKPageDrawPagesToPDF): 24 Call WebPageProxy::drawPagesToPDF(). 25 26 * UIProcess/API/C/WKPagePrivate.h: 27 Declare the WKPrintInfo type and new functions. 28 29 * UIProcess/WebPageProxy.cpp: 30 Compile this code on Windows. 31 32 * UIProcess/WebPageProxy.h: 33 Ditto. 34 35 * UIProcess/win/WebView.cpp: 36 (WebKit::WebView::paint): 37 We're painting the window; leave printing mode. 38 39 * WebProcess/WebPage/WebPage.cpp: 40 Compile this code on Windows. 41 42 * WebProcess/WebPage/WebPage.h: 43 Ditto. 44 45 * WebProcess/WebPage/WebPage.messages.in: 46 Ditto. 47 1 48 2011-03-04 Steve Falkenburg <sfalken@apple.com> 2 49 -
trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp
r80394 r80398 28 28 #include "WKPagePrivate.h" 29 29 30 #include "PrintInfo.h" 30 31 #include "WKAPICast.h" 31 32 #include "WebBackForwardList.h" … … 503 504 toImpl(pageRef)->executeEditCommand(toImpl(command)->string()); 504 505 } 506 507 #if PLATFORM(MAC) || PLATFORM(WIN) 508 struct ComputedPagesContext { 509 ComputedPagesContext(WKPageComputePagesForPrintingFunction callback, void* context) 510 : callback(callback) 511 , context(context) 512 { 513 } 514 WKPageComputePagesForPrintingFunction callback; 515 void* context; 516 }; 517 518 static void computedPagesCallback(const Vector<WebCore::IntRect>& rects, double scaleFactor, WKErrorRef error, void* untypedContext) 519 { 520 OwnPtr<ComputedPagesContext> context = adoptPtr(static_cast<ComputedPagesContext*>(untypedContext)); 521 Vector<WKRect> wkRects(rects.size()); 522 for (size_t i = 0; i < rects.size(); ++i) 523 wkRects[i] = toAPI(rects[i]); 524 context->callback(wkRects.data(), wkRects.size(), scaleFactor, error, context->context); 525 } 526 527 static PrintInfo printInfoFromWKPrintInfo(const WKPrintInfo& printInfo) 528 { 529 PrintInfo result; 530 result.pageSetupScaleFactor = printInfo.pageSetupScaleFactor; 531 result.availablePaperWidth = printInfo.availablePaperWidth; 532 result.availablePaperHeight = printInfo.availablePaperHeight; 533 return result; 534 } 535 536 void WKPageComputePagesForPrinting(WKPageRef page, WKFrameRef frame, const WKPrintInfo& printInfo, WKPageComputePagesForPrintingFunction callback, void* context) 537 { 538 toImpl(page)->computePagesForPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo), ComputedPagesCallback::create(new ComputedPagesContext(callback, context), computedPagesCallback)); 539 } 540 541 void WKPageBeginPrinting(WKPageRef page, WKFrameRef frame, const WKPrintInfo& printInfo) 542 { 543 toImpl(page)->beginPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo)); 544 } 545 546 void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context) 547 { 548 toImpl(page)->drawPagesToPDF(toImpl(frame), first, count, DataCallback::create(context, callback)); 549 } 550 #endif 551 -
trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h
r78488 r80398 51 51 WK_EXPORT WKPageDebugPaintFlags WKPageGetDebugPaintFlags(void); 52 52 53 struct WKPrintInfo { 54 float pageSetupScaleFactor; 55 float availablePaperWidth; 56 float availablePaperHeight; 57 }; 58 typedef void (*WKPageComputePagesForPrintingFunction)(WKRect* pageRects, uint32_t pageCount, double resultPageScaleFactor, WKErrorRef error, void* functionContext); 59 WK_EXPORT void WKPageComputePagesForPrinting(WKPageRef page, WKFrameRef frame, const WKPrintInfo&, WKPageComputePagesForPrintingFunction, void* context); 60 61 typedef void (*WKPageDrawToPDFFunction)(WKDataRef data, WKErrorRef error, void* functionContext); 62 WK_EXPORT void WKPageBeginPrinting(WKPageRef page, WKFrameRef frame, const WKPrintInfo&); 63 WK_EXPORT void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context); 64 53 65 #ifdef __cplusplus 54 66 } -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r80394 r80398 2779 2779 } 2780 2780 2781 #if PLATFORM(MAC) 2781 #if PLATFORM(MAC) || PLATFORM(WIN) 2782 2782 void WebPageProxy::drawRectToPDF(WebFrameProxy* frame, const IntRect& rect, PassRefPtr<DataCallback> callback) 2783 2783 { -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r80394 r80398 446 446 void endPrinting(); 447 447 void computePagesForPrinting(WebFrameProxy*, const PrintInfo&, PassRefPtr<ComputedPagesCallback>); 448 #if PLATFORM(MAC) 448 #if PLATFORM(MAC) || PLATFORM(WIN) 449 449 void drawRectToPDF(WebFrameProxy*, const WebCore::IntRect&, PassRefPtr<DataCallback>); 450 450 void drawPagesToPDF(WebFrameProxy*, uint32_t first, uint32_t count, PassRefPtr<DataCallback>); -
trunk/Source/WebKit2/UIProcess/win/WebView.cpp
r80394 r80398 415 415 void WebView::paint(HDC hdc, const IntRect& dirtyRect) 416 416 { 417 m_page->endPrinting(); 417 418 if (useNewDrawingArea()) { 418 419 if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(m_page->drawingArea())) { -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r80394 r80398 1989 1989 } 1990 1990 1991 #if PLATFORM(MAC) 1992 // FIXME: Find a better place for Mac specific code. 1991 #if PLATFORM(MAC) || PLATFORM(WIN) 1993 1992 void WebPage::drawRectToPDF(uint64_t frameID, const WebCore::IntRect& rect, uint64_t callbackID) 1994 1993 { -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r80394 r80398 330 330 void endPrinting(); 331 331 void computePagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID); 332 #if PLATFORM(MAC) 332 #if PLATFORM(MAC) || PLATFORM(WIN) 333 333 void drawRectToPDF(uint64_t frameID, const WebCore::IntRect&, uint64_t callbackID); 334 334 void drawPagesToPDF(uint64_t frameID, uint32_t first, uint32_t count, uint64_t callbackID); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r80394 r80398 157 157 EndPrinting(); 158 158 ComputePagesForPrinting(uint64_t frameID, WebKit::PrintInfo printInfo, uint64_t callbackID) 159 #if PLATFORM(MAC) 159 #if PLATFORM(MAC) || PLATFORM(WIN) 160 160 DrawRectToPDF(uint64_t frameID, WebCore::IntRect rect, uint64_t callbackID) 161 161 DrawPagesToPDF(uint64_t frameID, uint32_t first, uint32_t count, uint64_t callbackID)
Note: See TracChangeset
for help on using the changeset viewer.