summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-13 18:53:59 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-13 18:53:59 +0000
commitec1f490fe96f63be82b701b10a2255eca4a0f28a (patch)
tree8d435b12610e0e5bf2998d1c455baa48dff23ae0 /webkit
parent9612e0a594ca40ff23a85b5d8af6de88dfc98dff (diff)
downloadchromium_src-ec1f490fe96f63be82b701b10a2255eca4a0f28a.zip
chromium_src-ec1f490fe96f63be82b701b10a2255eca4a0f28a.tar.gz
chromium_src-ec1f490fe96f63be82b701b10a2255eca4a0f28a.tar.bz2
Restore the WebFrame::getPrintPageShrink() method originally added in rev 14639
and later removed in rev 19669. From the original commit message: Rev 12100 changed the way that we spool and render printed output, most notably introducing use of the PrintContext class. The existing PrintContext::spoolPage() method applies a webkit scaling factor before rendering output to the graphics context. ChromePrintContext::spoolPage() (in webframe_impl.cc), which is used by chromium instead of PrintContext::spoolPage(), does not apply this scaling factor, but instead eventually returns the scaling factor via WebFrame::PrintPage(). This is a problem for the Chromium Embedded Framework (CEF) because, unlike chromium, the CEF renders directly to the printer device context. It is therefore important for CEF that we retrieve and apply the webkit scaling factor before calling PrintPage(). In order to support this capability the following adds a WebFrame::GetPrintPageShrink() method. Patch by Marshall Greenblatt R=darin BUG=none TEST=none git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23338 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/api/public/WebFrame.h5
-rw-r--r--webkit/glue/webframe_impl.cc10
-rw-r--r--webkit/glue/webframe_impl.h1
3 files changed, 16 insertions, 0 deletions
diff --git a/webkit/api/public/WebFrame.h b/webkit/api/public/WebFrame.h
index bb5be9c..be7ca8b 100644
--- a/webkit/api/public/WebFrame.h
+++ b/webkit/api/public/WebFrame.h
@@ -332,6 +332,11 @@ namespace WebKit {
// given page size.
virtual int printBegin(const WebSize& pageSize) = 0;
+ // Returns the page shrinking factor calculated by webkit (usually
+ // between 1/1.25 and 1/2). Returns 0 if the page number is invalid or
+ // not in printing mode.
+ virtual float getPrintPageShrink(int page) = 0;
+
// Prints one page, and returns the calculated page shrinking factor
// (usually between 1/1.25 and 1/2). Returns 0 if the page number is
// invalid or not in printing mode.
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc
index 2c4eb12..8dd7880 100644
--- a/webkit/glue/webframe_impl.cc
+++ b/webkit/glue/webframe_impl.cc
@@ -1045,6 +1045,16 @@ int WebFrameImpl::printBegin(const WebSize& page_size) {
return print_context_->pageCount();
}
+float WebFrameImpl::getPrintPageShrink(int page) {
+ // Ensure correct state.
+ if (!print_context_.get() || page < 0) {
+ NOTREACHED();
+ return 0;
+ }
+
+ return print_context_->getPageShrink(page);
+}
+
float WebFrameImpl::printPage(int page, WebCanvas* canvas) {
// Ensure correct state.
if (!print_context_.get() || page < 0 || !frame() || !frame()->document()) {
diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h
index db30142..3f898f9 100644
--- a/webkit/glue/webframe_impl.h
+++ b/webkit/glue/webframe_impl.h
@@ -147,6 +147,7 @@ class WebFrameImpl : public WebKit::WebFrame,
virtual WebKit::WebString selectionAsMarkup() const;
virtual int printBegin(const WebKit::WebSize& page_size);
virtual float printPage(int page_to_print, WebKit::WebCanvas* canvas);
+ virtual float getPrintPageShrink(int page);
virtual void printEnd();
virtual bool find(
int identifier, const WebKit::WebString& search_text,