diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-30 22:17:38 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-30 22:17:38 +0000 |
commit | e916edeebbac7a403adf06fe543dacb52962c230 (patch) | |
tree | 073e8fac5b86967ba41dda972cdc678bc73f8313 /webkit | |
parent | 96613eb98e8c56e3046d391e40d4fdadf696614e (diff) | |
download | chromium_src-e916edeebbac7a403adf06fe543dacb52962c230.zip chromium_src-e916edeebbac7a403adf06fe543dacb52962c230.tar.gz chromium_src-e916edeebbac7a403adf06fe543dacb52962c230.tar.bz2 |
Modify printing methods on WebFrame to be more inline with the version
specified in webkit/api/public/WebFrame.h.
Removes an unused method on WebFrame related to printing.
BUG=10034
TEST=none
R=brettw
Review URL: http://codereview.chromium.org/150027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19669 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/api/public/WebFrame.h | 16 | ||||
-rw-r--r-- | webkit/api/public/WebView.h | 36 | ||||
-rw-r--r-- | webkit/glue/webframe.h | 36 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.cc | 26 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.h | 8 |
5 files changed, 43 insertions, 79 deletions
diff --git a/webkit/api/public/WebFrame.h b/webkit/api/public/WebFrame.h index bf740da..be58d6c 100644 --- a/webkit/api/public/WebFrame.h +++ b/webkit/api/public/WebFrame.h @@ -229,6 +229,22 @@ namespace WebKit { virtual WebString selectionAsHTML() = 0; + // Printing ------------------------------------------------------------ + + // Reformats the WebFrame for printing. pageSize is the page size in + // pixels. Returns the number of pages that can be printed at the + // given page size. + virtual int printBegin(const WebSize& pageSize); + + // 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. + virtual float printPage(int pageToPrint, const WebCanvas&); + + // Reformats the WebFrame for screen display. + virtual void printEnd(); + + // Find-in-page -------------------------------------------------------- // FIXME diff --git a/webkit/api/public/WebView.h b/webkit/api/public/WebView.h index ec21703..70aa014 100644 --- a/webkit/api/public/WebView.h +++ b/webkit/api/public/WebView.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -75,7 +75,7 @@ namespace WebKit { // matches the given name. virtual WebFrame* findFrameByName(const WebString& name) = 0; - + // Focus --------------------------------------------------------------- virtual WebFrame* focusedFrame() = 0; @@ -108,34 +108,6 @@ namespace WebKit { // frame will be separated by an empty line. virtual WebString captureAsText(unsigned maxCharacters) = 0; - // Paints the contents of this WebView into a bitmapped image. This - // image will not have plugins drawn. Devices are cheap to copy because - // the data is internally ref-counted, so we allocate and return a new - // copy. - // - // Set scrollToZero to force all frames to be scrolled to 0,0 before - // being painted into the image. This will not send DOM events because - // it just draws the contents at a different place, but it does mean - // the scrollbars in the resulting image will appear to be wrong - // (they'll be painted as if the content was scrolled). - virtual WebImage captureAsImage(bool scrollToZero) = 0; - - - // Printing ------------------------------------------------------------ - - // Reformats the WebView for printing. pageSize is the page size in - // pixels. Returns the number of pages that can be printed at the - // given page size. - virtual int printBegin(const WebSize& pageSize); - - // 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. - virtual float printPage(int pageToPrint, const WebCanvas&); - - // Reformats the WebView for screen display. - virtual void printEnd(); - // Zoom ---------------------------------------------------------------- diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h index 1f5974c..c7927ea 100644 --- a/webkit/glue/webframe.h +++ b/webkit/glue/webframe.h @@ -11,7 +11,7 @@ #include "base/string16.h" #include "skia/ext/bitmap_platform_device.h" #include "skia/ext/platform_canvas.h" -#include "webkit/api/public/WebCommon.h" +#include "webkit/api/public/WebCanvas.h" class GURL; class WebView; @@ -384,28 +384,18 @@ class WebFrame { // The current scroll offset from the top of frame in pixels. virtual WebKit::WebSize ScrollOffset() const = 0; - // Reformats the web frame for printing. |page_size_px| is the page size in - // pixels. - // |width| is the resulting document width in pixel. - // |page_count| is the number of printed pages. - // Returns false if it fails. It'll fail if the main frame failed to load but - // will succeed even if a child frame failed to load. - virtual bool BeginPrint(const WebKit::WebSize& page_size_px, - int* page_count) = 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. |page| is 0-based. - // 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 PrintPage(int page, skia::PlatformCanvas* canvas) = 0; - - // Reformats the web frame for screen display. - virtual void EndPrint() = 0; + // Reformats the WebFrame for printing. page_size is the page size in + // pixels. Returns the number of pages that can be printed at the given page + // size. + virtual int PrintBegin(const WebKit::WebSize& page_size) = 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. + virtual float PrintPage(int page_to_print, WebKit::WebCanvas* canvas) = 0; + + // Reformats the WebFrame for screen display. + virtual void PrintEnd() = 0; // Only for test_shell virtual int PendingFrameUnloadEventCount() const = 0; diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index 8c13cb3..b5f2742 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -203,6 +203,7 @@ using WebCore::TextIterator; using WebCore::VisiblePosition; using WebCore::XPathResult; +using WebKit::WebCanvas; using WebKit::WebConsoleMessage; using WebKit::WebDataSource; using WebKit::WebFindOptions; @@ -1777,35 +1778,22 @@ void WebFrameImpl::SetAllowsScrolling(bool flag) { frame_->view()->setCanHaveScrollbars(flag); } -bool WebFrameImpl::BeginPrint(const WebSize& page_size_px, - int* page_count) { +int WebFrameImpl::PrintBegin(const WebSize& page_size) { DCHECK_EQ(frame()->document()->isFrameSet(), false); print_context_.reset(new ChromePrintContext(frame())); WebCore::FloatRect rect(0, 0, - static_cast<float>(page_size_px.width), - static_cast<float>(page_size_px.height)); + static_cast<float>(page_size.width), + static_cast<float>(page_size.height)); print_context_->begin(rect.width()); float page_height; // We ignore the overlays calculation for now since they are generated in the // browser. page_height is actually an output parameter. print_context_->computePageRects(rect, 0, 0, 1.0, page_height); - if (page_count) - *page_count = print_context_->pageCount(); - return true; -} - -float WebFrameImpl::GetPrintPageShrink(int page) { - // Ensure correct state. - if (!print_context_.get() || page < 0) { - NOTREACHED(); - return 0; - } - - return print_context_->getPageShrink(page); + return print_context_->pageCount(); } -float WebFrameImpl::PrintPage(int page, skia::PlatformCanvas* canvas) { +float WebFrameImpl::PrintPage(int page, WebCanvas* canvas) { // Ensure correct state. if (!print_context_.get() || page < 0 || !frame() || !frame()->document()) { NOTREACHED(); @@ -1824,7 +1812,7 @@ float WebFrameImpl::PrintPage(int page, skia::PlatformCanvas* canvas) { return print_context_->spoolPage(spool, page); } -void WebFrameImpl::EndPrint() { +void WebFrameImpl::PrintEnd() { DCHECK(print_context_.get()); if (print_context_.get()) print_context_->end(); diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h index f164214..8baab14 100644 --- a/webkit/glue/webframe_impl.h +++ b/webkit/glue/webframe_impl.h @@ -179,11 +179,9 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { virtual WebKit::WebSize ScrollOffset() const; - virtual bool BeginPrint(const WebKit::WebSize& page_size_px, - int* page_count); - virtual float GetPrintPageShrink(int page); - virtual float PrintPage(int page, skia::PlatformCanvas* canvas); - virtual void EndPrint(); + virtual int PrintBegin(const WebKit::WebSize& page_size); + virtual float PrintPage(int page, WebKit::WebCanvas* canvas); + virtual void PrintEnd(); PassRefPtr<WebCore::Frame> CreateChildFrame( const WebCore::FrameLoadRequest&, |