[Chromium] Use overloaded printBegin() webkit API to support auto fit to page functio...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2012 22:11:12 +0000 (22:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2012 22:11:12 +0000 (22:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=86684

Patch by Kausalya Madhusudhanan <kmadhusu@chromium.org> on 2012-05-22
Reviewed by Darin Fisher.

Source/WebKit/chromium:

* public/WebFrame.h:
(WebFrame):
* public/WebPlugin.h:
(WebPlugin):
* public/WebPrintParams.h:
(WebKit::WebPrintParams::WebPrintParams):
(WebPrintParams):
* src/WebFrameImpl.cpp:
(WebKit):
* src/WebFrameImpl.h:
(WebFrameImpl):
* src/WebPluginContainerImpl.cpp:
(WebKit::WebPluginContainerImpl::printBegin):

Tools:

* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::numberOfPages):
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::printPage):

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

Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebFrame.h
Source/WebKit/chromium/public/WebPlugin.h
Source/WebKit/chromium/public/WebPrintParams.h
Source/WebKit/chromium/src/WebFrameImpl.cpp
Source/WebKit/chromium/src/WebFrameImpl.h
Source/WebKit/chromium/src/WebPluginContainerImpl.cpp
Tools/ChangeLog
Tools/DumpRenderTree/chromium/LayoutTestController.cpp
Tools/DumpRenderTree/chromium/WebViewHost.cpp

index 9ab821a..fc169e6 100644 (file)
@@ -1,3 +1,24 @@
+2012-05-22  Kausalya Madhusudhanan  <kmadhusu@chromium.org>
+
+        [Chromium] Use overloaded printBegin() webkit API to support auto fit to page functionality.
+        https://bugs.webkit.org/show_bug.cgi?id=86684
+
+        Reviewed by Darin Fisher.
+
+        * public/WebFrame.h:
+        (WebFrame):
+        * public/WebPlugin.h:
+        (WebPlugin):
+        * public/WebPrintParams.h:
+        (WebKit::WebPrintParams::WebPrintParams):
+        (WebPrintParams):
+        * src/WebFrameImpl.cpp:
+        (WebKit):
+        * src/WebFrameImpl.h:
+        (WebFrameImpl):
+        * src/WebPluginContainerImpl.cpp:
+        (WebKit::WebPluginContainerImpl::printBegin):
+
 2012-05-22  Adam Barth  <abarth@webkit.org>
 
         [Chromium] Expose setMediaPlaybackRequiresUserGesture via WebSettings
index 87659ee..6f76ef9 100644 (file)
@@ -455,23 +455,6 @@ public:
 
     // Printing ------------------------------------------------------------
 
-    // Reformats the WebFrame for printing. printContentSize is the print
-    // content size in points (a point is 1/72 of an inch). If constrainToNode
-    // node is specified, then only the given node is printed (for now only
-    // plugins are supported), instead of the entire frame. printerDPI is the
-    // user selected, DPI for the printer. Returns the number of pages that can
-    // be printed at the given page size. The out param useBrowserOverlays
-    // specifies whether the browser process should use its overlays (header,
-    // footer, margins etc) or whether the renderer controls this.
-    //
-    // FIXME: This is a temporary interface to avoid the compile errors. Remove
-    // this interface after fixing crbug.com/85132. We will use the overloaded
-    // printBegin function.
-    virtual int printBegin(const WebSize& printContentSize,
-                           const WebNode& constrainToNode = WebNode(),
-                           int printerDPI = 72,
-                           bool* useBrowserOverlays = 0) = 0;
-
     // Reformats the WebFrame for printing. WebPrintParams specifies the printable
     // content size, paper size, printable area size, printer DPI and print
     // scaling option. If constrainToNode node is specified, then only the given node
index 717f6a7..5b911d0 100644 (file)
@@ -98,12 +98,6 @@ public:
     // the printer's printable area.
     virtual bool isPrintScalingDisabled() { return false; }
 
-    // Sets up printing at the given print rect and printer DPI.
-    // printContentArea is in points ( a point is 1/72 of an inch). Returns the
-    // number of pages to be printed at these settings.
-    // FIXME: Remove this function after fixing crbug.com/85132. For detailed
-    // information, please refer to the comments in WebFrame.h
-    virtual int printBegin(const WebRect& printContentArea, int printerDPI) { return 0; }
     // Sets up printing with the specified printParams. Returns the number of
     // pages to be printed at these settings.
     virtual int printBegin(const WebPrintParams& printParams) { return 0; }
index d2d25bd..bd117c3 100644 (file)
@@ -59,6 +59,13 @@ struct WebPrintParams {
         : printerDPI(72)
         , printScalingOption(WebPrintScalingOptionFitToPrintableArea) { }
 
+    WebPrintParams(const WebSize& paperSize)
+        : printContentArea(WebRect(0, 0, paperSize.width, paperSize.height))
+        , printableArea(WebRect(0, 0, paperSize.width, paperSize.height))
+        , paperSize(paperSize)
+        , printerDPI(72)
+        , printScalingOption(WebPrintScalingOptionSourceSize) { }
+
     WebPrintParams(const WebRect& printContentArea, const WebRect& printableArea, const WebSize& paperSize, int printerDPI, WebPrintScalingOption printScalingOption)
         : printContentArea(printContentArea)
         , printableArea(printableArea)
index 1464f92..fadb8c0 100644 (file)
@@ -1449,21 +1449,6 @@ VisiblePosition WebFrameImpl::visiblePositionForWindowPoint(const WebPoint& poin
     return node->renderer()->positionForPoint(result.localPoint());
 }
 
-// TODO(kmadhusu@chromium.org): Remove this function after fixing
-// crbug.com/85132. For more information, please refer to the comments in
-// WebFrame.h
-int WebFrameImpl::printBegin(const WebSize& printContentSize,
-                             const WebNode& constrainToNode,
-                             int printerDPI,
-                             bool* useBrowserOverlays) {
-    WebRect printableArea(0, 0, printContentSize.width, printContentSize.height);
-    WebSize paperSize(printContentSize);
-    WebRect printContentArea(0, 0, printContentSize.width, printContentSize.height);
-    WebPrintParams printParams(printContentArea, printableArea, paperSize,
-                               printerDPI, WebPrintScalingOptionSourceSize);
-    return printBegin(printParams, constrainToNode, useBrowserOverlays);
-}
-
 int WebFrameImpl::printBegin(const WebPrintParams& printParams,
                              const WebNode& constrainToNode,
                              bool* useBrowserOverlays)
index 5061cfa..d8ae6dc 100644 (file)
@@ -178,12 +178,6 @@ public:
     virtual bool selectWordAroundCaret();
     virtual void selectRange(const WebPoint& start, const WebPoint& end);
     virtual void selectRange(const WebRange&);
-    // FIXME: Remove this function after fixing crbug.com/85132. For detailed
-    // information, please refer to the comments in WebFrame.h
-    virtual int printBegin(const WebSize& printContentSize,
-                           const WebNode& constrainToNode,
-                           int printerDPI,
-                           bool* useBrowserOverlays);
     virtual int printBegin(const WebPrintParams&,
                            const WebNode& constrainToNode,
                            bool* useBrowserOverlays);
index 400aabb..e10e0ae 100644 (file)
@@ -254,10 +254,7 @@ bool WebPluginContainerImpl::isPrintScalingDisabled() const
 
 int WebPluginContainerImpl::printBegin(const WebPrintParams& printParams) const
 {
-    return m_webPlugin->printBegin(printParams.printContentArea, printParams.printerDPI);
-    // FIXME: After committing this CL, update the chrome plugin printBegin()
-    // function to use the overloaded printBegin function.
-    // return m_webPlugin->printBegin(printParams);
+    return m_webPlugin->printBegin(printParams);
 }
 
 bool WebPluginContainerImpl::printPage(int pageNumber,
index 406c4c3..c088f5d 100644 (file)
@@ -1 +1,13 @@
+2012-05-22  Kausalya Madhusudhanan  <kmadhusu@chromium.org>
+
+        [Chromium] Use overloaded printBegin() webkit API to support auto fit to page functionality.
+        https://bugs.webkit.org/show_bug.cgi?id=86684
+
+        Reviewed by Darin Fisher.
+
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::numberOfPages):
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::printPage):
+
 == Rolled over to ChangeLog-2012-05-22 ==
index 078562c..38c2ad6 100644 (file)
@@ -54,6 +54,7 @@
 #include "WebKit.h"
 #include "WebNotificationPresenter.h"
 #include "WebPermissions.h"
+#include "WebPrintParams.h"
 #include "WebScriptSource.h"
 #include "WebSecurityPolicy.h"
 #include "platform/WebSerializedScriptValue.h"
@@ -1807,8 +1808,8 @@ void LayoutTestController::numberOfPages(const CppArgumentList& arguments, CppVa
     WebFrame* frame = m_shell->webView()->mainFrame();
     if (!frame)
         return;
-    WebSize size(pageWidthInPixels, pageHeightInPixels);
-    int numberOfPages = frame->printBegin(size);
+    WebPrintParams printParams(WebSize(pageWidthInPixels, pageHeightInPixels));
+    int numberOfPages = frame->printBegin(printParams);
     frame->printEnd();
     result->set(numberOfPages);
 }
index 9da8e83..491fb05 100644 (file)
@@ -55,6 +55,7 @@
 #include "WebPluginParams.h"
 #include "WebPopupMenu.h"
 #include "WebPopupType.h"
+#include "WebPrintParams.h"
 #include "WebRange.h"
 #include "platform/WebRect.h"
 #include "WebScreenInfo.h"
@@ -1853,7 +1854,7 @@ void WebViewHost::displayRepaintMask()
 void WebViewHost::printPage(WebKit::WebFrame* frame)
 {
     WebSize pageSizeInPixels = webWidget()->size();
-
-    frame->printBegin(pageSizeInPixels);
+    WebPrintParams printParams(pageSizeInPixels);
+    frame->printBegin(printParams);
     frame->printEnd();
 }