diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-27 20:01:27 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-27 20:01:27 +0000 |
commit | c6321d8e201af8f7b91cd0b134d4ad32844f66c1 (patch) | |
tree | 3ed92a2f921e6165692c64bfad0b1582a76aad11 /webkit/glue/webframe_impl.cc | |
parent | 891acc9b216198f8a143a8b0f1a0dada8d989299 (diff) | |
download | chromium_src-c6321d8e201af8f7b91cd0b134d4ad32844f66c1.zip chromium_src-c6321d8e201af8f7b91cd0b134d4ad32844f66c1.tar.gz chromium_src-c6321d8e201af8f7b91cd0b134d4ad32844f66c1.tar.bz2 |
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 contributed by Marshall Greenblatt <magreenblatt@gmail.com>
Review: http://codereview.chromium.org/99058
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14639 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webframe_impl.cc')
-rw-r--r-- | webkit/glue/webframe_impl.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index dfed0aa..3b87d4f 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -307,6 +307,10 @@ class ChromePrintContext : public WebCore::PrintContext { printed_page_width_ = width; WebCore::PrintContext::begin(printed_page_width_); } + float getPageShrink(int pageNumber) const { + IntRect pageRect = m_pageRects[pageNumber]; + return printed_page_width_ / pageRect.width(); + } // Spools the printed page, a subrect of m_frame. // Skip the scale step. NativeTheme doesn't play well with scaling. Scaling // is done browser side instead. @@ -1884,6 +1888,16 @@ bool WebFrameImpl::BeginPrint(const WebSize& page_size_px, return true; } +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, skia::PlatformCanvas* canvas) { // Ensure correct state. if (!print_context_.get() || page < 0 || !frame() || !frame()->document()) { |