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: http://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 9dff9d985e82117a2663b9ed9a1549104a8e7d8e..dafe1bcd9885f5a78e6ee2c453810b7bc2980065 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 6a007e7452b496dd287c29bd15218aeb2f3261d1..fe3764616bdad70269c8d1de8c38b1803aec1ae6 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 807044bac0d4a07320a9f28c8659dd2a0c3d6c95..0cb8eb30c270b6a8a3e53b810d6cb97556da2622 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 cca2d7c1cde55e1b5c9e57c7359d64635a965b8d..f85d82469c63da432ce4c2f8129398e1c7aa5314 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 ad8424e195f7c32368f3d328955d948727d3255e..962a68df858fa9e7b6d3281fe2e9d3c9f67c9ffc 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 7b63efff1f834e64c26cd2e663fd5149d00cab6d..1f7243dc01788db311b36875e25bdb2c055266d3 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 90c7e56645e18a6d8e75260a9ad1f05e34905c37..65f4ac3f09db0a3afd4fc6ec7b6f6a78a881684b 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 802848c7d4ea5d1b065e692ed59c395f9fd8854b..0acfb47d0ca0c75961f734a774936579ba667664 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 b3b32cd96609fd95827b70cb846fd22128ad4846..b10846fd947316f5b708726567261b68eb75efbc 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 c764d225c411530d03e740587ad01523ab9e48d3..685630ce36d1a5833e63140632a15d089d25297e 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 733195705c96bf9985c8b5b84f147ad21afac88d..1a733ce794e43080707fb6018260b9eab665bd47 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 de9927171e11af1c7bbdd7608f161d4c3062c192..1a68426bc992619159414abc5c460b831233ee72 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);