Reviewed by Darin Adler.
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jan 2011 00:19:33 +0000 (00:19 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jan 2011 00:19:33 +0000 (00:19 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=52849
        Make window.print work with WebKit2

        * UIProcess/API/qt/qwkpage.cpp:
        (QWKPage::QWKPage):
        * UIProcess/WebPageProxy.cpp:
        (WebKit::WebPageProxy::printFrame):
        * UIProcess/WebPageProxy.h:
        * UIProcess/WebPageProxy.messages.in:
        * UIProcess/WebUIClient.cpp:
        (WebKit::WebUIClient::printFrame):
        * UIProcess/WebUIClient.h:
        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
        (WebKit::WebChromeClient::print):
        Just pass through deelagte call to a WebKit2 client.

        * UIProcess/API/C/WKPage.h: Also added "Callback" suffix to other printing related function
        types.

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

12 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKPage.h
Source/WebKit2/UIProcess/API/qt/qwkpage.cpp
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/WebUIClient.cpp
Source/WebKit2/UIProcess/WebUIClient.h
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Tools/ChangeLog
Tools/MiniBrowser/mac/BrowserWindowController.m
Tools/WebKitTestRunner/TestController.cpp

index 9dff9d9..dafe1bc 100644 (file)
@@ -1,3 +1,26 @@
+2011-01-20  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=52849
+        Make window.print work with WebKit2
+
+        * UIProcess/API/qt/qwkpage.cpp:
+        (QWKPage::QWKPage):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::printFrame):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/WebUIClient.cpp:
+        (WebKit::WebUIClient::printFrame):
+        * UIProcess/WebUIClient.h:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::print):
+        Just pass through deelagte call to a WebKit2 client.
+
+        * UIProcess/API/C/WKPage.h: Also added "Callback" suffix to other printing related function
+        types.
+
 2011-01-20  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Darin Adler.
index 6a007e7..fe37646 100644 (file)
@@ -177,10 +177,11 @@ typedef void (*WKPageDidScrollCallback)(WKPageRef page, const void *clientInfo);
 typedef unsigned long long (*WKPageExceededDatabaseQuotaCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentUsage, unsigned long long expectedUsage, const void *clientInfo);
 typedef void (*WKPageRunOpenPanelCallback)(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void *clientInfo);
 typedef void (*WKPageDecidePolicyForGeolocationPermissionRequestCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKGeolocationPermissionRequestRef permissionRequest, const void* clientInfo);
-typedef float (*WKPageHeaderHeight)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
-typedef float (*WKPageFooterHeight)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
-typedef void (*WKPageDrawHeader)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
-typedef void (*WKPageDrawFooter)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
+typedef float (*WKPageHeaderHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
+typedef float (*WKPageFooterHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
+typedef void (*WKPageDrawHeaderCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
+typedef void (*WKPageDrawFooterCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
+typedef void (*WKPagePrintFrameCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
 
 struct WKPageUIClient {
     int                                                                 version;
@@ -211,10 +212,11 @@ struct WKPageUIClient {
     WKPageExceededDatabaseQuotaCallback                                 exceededDatabaseQuota;
     WKPageRunOpenPanelCallback                                          runOpenPanel;
     WKPageDecidePolicyForGeolocationPermissionRequestCallback           decidePolicyForGeolocationPermissionRequest;
-    WKPageHeaderHeight                                                  headerHeight;
-    WKPageFooterHeight                                                  footerHeight;
-    WKPageDrawHeader                                                    drawHeader;
-    WKPageDrawFooter                                                    drawFooter;
+    WKPageHeaderHeightCallback                                          headerHeight;
+    WKPageFooterHeightCallback                                          footerHeight;
+    WKPageDrawHeaderCallback                                            drawHeader;
+    WKPageDrawFooterCallback                                            drawFooter;
+    WKPagePrintFrameCallback                                            printFrame;
 };
 typedef struct WKPageUIClient WKPageUIClient;
 
index 807044b..0cb8eb3 100644 (file)
@@ -457,7 +457,8 @@ QWKPage::QWKPage(QWKContext* context)
         0,  /* headerHeight */
         0,  /* footerHeight */
         0,  /* drawHeader */
-        0   /* drawFooter */
+        0,  /* drawFooter */
+        0   /* printFrame */
     };
     WKPageSetPageUIClient(pageRef(), &uiClient);
 }
index cca2d7c..f85d824 100644 (file)
@@ -1672,6 +1672,14 @@ void WebPageProxy::runOpenPanel(uint64_t frameID, const WebOpenPanelParameters::
         didCancelForOpenPanel();
 }
 
+void WebPageProxy::printFrame(uint64_t frameID)
+{
+    WebFrameProxy* frame = process()->webFrame(frameID);
+    MESSAGE_CHECK(frame);
+
+    m_uiClient.printFrame(this, frame);
+}
+
 #if PLATFORM(QT)
 void WebPageProxy::didChangeContentsSize(const WebCore::IntSize& size)
 {
index ad8424e..962a68d 100644 (file)
@@ -438,6 +438,7 @@ private:
     void didChangeViewportData(const WebCore::ViewportArguments&);
     void pageDidScroll();
     void runOpenPanel(uint64_t frameID, const WebOpenPanelParameters::Data&);
+    void printFrame(uint64_t frameID);
     void exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentUsage, uint64_t expectedUsage, uint64_t& newQuota);
     void requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier);
 
index 7b63eff..1f7243d 100644 (file)
@@ -53,6 +53,7 @@ messages -> WebPageProxy {
     RunBeforeUnloadConfirmPanel(WTF::String message, uint64_t frameID) -> (bool shouldClose)
     PageDidScroll()
     RunOpenPanel(uint64_t frameID, WebKit::WebOpenPanelParameters::Data parameters)
+    PrintFrame(uint64_t frameID) -> ()
 
 #if ENABLE(TILED_BACKING_STORE)
     PageDidRequestScroll(WebCore::IntSize delta)
index 90c7e56..65f4ac3 100644 (file)
@@ -305,4 +305,12 @@ void WebUIClient::drawFooter(WebPageProxy* page, WebFrameProxy* frame, const Web
     m_client.drawFooter(toAPI(page), toAPI(frame), toAPI(rect), m_client.clientInfo);
 }
 
+void WebUIClient::printFrame(WebPageProxy* page, WebFrameProxy* frame)
+{
+    if (!m_client.printFrame)
+        return;
+
+    m_client.printFrame(toAPI(page), toAPI(frame), m_client.clientInfo);
+}
+
 } // namespace WebKit
index 802848c..0acfb47 100644 (file)
@@ -92,6 +92,7 @@ public:
     float footerHeight(WebPageProxy*, WebFrameProxy*);
     void drawHeader(WebPageProxy*, WebFrameProxy*, const WebCore::FloatRect&);
     void drawFooter(WebPageProxy*, WebFrameProxy*, const WebCore::FloatRect&);
+    void printFrame(WebPageProxy*, WebFrameProxy*);
 };
 
 } // namespace WebKit
index b3b32cd..b10846f 100644 (file)
@@ -466,9 +466,10 @@ void WebChromeClient::setToolTip(const String& toolTip, TextDirection)
     m_page->send(Messages::WebPageProxy::SetToolTip(m_cachedToolTip));
 }
 
-void WebChromeClient::print(Frame*)
+void WebChromeClient::print(Frame* frame)
 {
-    notImplemented();
+    WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
+    m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply());
 }
 
 #if ENABLE(DATABASE)
index c764d22..685630c 100644 (file)
@@ -1,3 +1,17 @@
+2011-01-20  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=52849
+        Make window.print work with WebKit2
+
+        * MiniBrowser/mac/BrowserWindowController.m:
+        (-[BrowserWindowController awakeFromNib]):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::createOtherPage):
+        (WTR::TestController::initialize):
+        Added zeroes to WKPageUIClient structures to avoid build failures.
+
 2011-01-20  Dirk Pranke  <dpranke@chromium.org>
 
         Reviewed by Eric Seidel.
index 7331957..1a733ce 100644 (file)
@@ -643,6 +643,7 @@ static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParameters
         0, // footerHeight
         0, // drawHeader
         0, // drawFooter
+        0, // printFrame
     };
     WKPageSetPageUIClient(_webView.pageRef, &uiClient);
 }
index de99271..1a68426 100644 (file)
@@ -150,6 +150,7 @@ static WKPageRef createOtherPage(WKPageRef oldPage, WKDictionaryRef, WKEventModi
         0, // footerHeight
         0, // drawHeader
         0, // drawFooter
+        0, // printFrame
     };
     WKPageSetPageUIClient(newPage, &otherPageUIClient);
 
@@ -259,6 +260,7 @@ void TestController::initialize(int argc, const char* argv[])
         0, // footerHeight
         0, // drawHeader
         0, // drawFooter
+        0, // printFrame
     };
     WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient);