Index: chrome/renderer/print_web_view_helper_linux.cc |
diff --git a/chrome/renderer/print_web_view_helper_linux.cc b/chrome/renderer/print_web_view_helper_linux.cc |
index 9255a007bfc51867ec19bdadb47c67e446c21ee6..5b3de1c5d88ef6e011669147f66b989280b6330a 100644 |
--- a/chrome/renderer/print_web_view_helper_linux.cc |
+++ b/chrome/renderer/print_web_view_helper_linux.cc |
@@ -8,13 +8,18 @@ |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/metrics/histogram.h" |
+#include "base/utf_string_conversions.h" |
#include "chrome/common/print_messages.h" |
#include "content/common/view_messages.h" |
#include "printing/metafile.h" |
#include "printing/metafile_impl.h" |
#include "printing/metafile_skia_wrapper.h" |
#include "skia/ext/vector_canvas.h" |
+#include "skia/ext/vector_platform_device_skia.h" |
+#include "third_party/skia/include/core/SkColor.h" |
+#include "third_party/skia/include/core/SkDraw.h" |
#include "third_party/skia/include/core/SkRefCnt.h" |
+#include "third_party/skia/include/core/SkTypeface.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
#include "ui/gfx/point.h" |
@@ -164,6 +169,7 @@ bool PrintWebViewHelper::RenderPages(const PrintMsg_PrintPages_Params& params, |
*page_count)); |
#endif |
} |
+ int total_pages = *page_count; |
kmadhusu
2011/07/14 01:50:15
|total_pages| is not required. At this point, you
Aayush Kumar
2011/07/19 01:20:30
Done.
|
base::TimeTicks begin_time = base::TimeTicks::Now(); |
base::TimeTicks page_begin_time = begin_time; |
@@ -174,7 +180,8 @@ bool PrintWebViewHelper::RenderPages(const PrintMsg_PrintPages_Params& params, |
if (params.pages.empty()) { |
for (int i = 0; i < *page_count; ++i) { |
page_params.page_number = i; |
- PrintPageInternal(page_params, canvas_size, frame, metafile); |
+ PrintPageInternal(page_params, canvas_size, frame, metafile, is_preview, |
+ total_pages); |
if (is_preview) { |
page_begin_time = ReportPreviewPageRenderTime(page_begin_time); |
if (!PreviewPageRendered(i)) |
@@ -184,7 +191,8 @@ bool PrintWebViewHelper::RenderPages(const PrintMsg_PrintPages_Params& params, |
} else { |
for (size_t i = 0; i < params.pages.size(); ++i) { |
page_params.page_number = params.pages[i]; |
- PrintPageInternal(page_params, canvas_size, frame, metafile); |
+ PrintPageInternal(page_params, canvas_size, frame, metafile, is_preview, |
+ total_pages); |
if (is_preview) { |
page_begin_time = ReportPreviewPageRenderTime(page_begin_time); |
if (!PreviewPageRendered(params.pages[i])) |
@@ -210,22 +218,12 @@ void PrintWebViewHelper::PrintPageInternal( |
const PrintMsg_PrintPage_Params& params, |
const gfx::Size& canvas_size, |
WebFrame* frame, |
- printing::Metafile* metafile) { |
- double content_width_in_points; |
- double content_height_in_points; |
- double margin_top_in_points; |
- double margin_right_in_points; |
- double margin_bottom_in_points; |
- double margin_left_in_points; |
+ printing::Metafile* metafile, |
+ bool is_preview, |
+ int total_pages) { |
kmadhusu
2011/07/14 01:50:15
You don't need |total_pages|. Just use |preview_pa
Aayush Kumar
2011/07/19 01:20:30
Done.
|
GetPageSizeAndMarginsInPoints(frame, |
params.page_number, |
- params.params, |
- &content_width_in_points, |
- &content_height_in_points, |
- &margin_top_in_points, |
- &margin_right_in_points, |
- &margin_bottom_in_points, |
- &margin_left_in_points); |
+ params.params); |
gfx::Size page_size( |
content_width_in_points + margin_right_in_points + |
@@ -245,6 +243,13 @@ void PrintWebViewHelper::PrintPageInternal( |
SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); |
canvas->unref(); // SkRefPtr and new both took a reference. |
printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile); |
+ |
+ if (is_preview && params.params.header_footer) { |
+ // The page_number count starts from '0', so, we add by '1'. |
+ // The scale factor on Linux is '1' which is the last parameter. |
+ PrintHeaderAndFooter(device, canvas, params.page_number+1, total_pages, 1); |
kmadhusu
2011/07/14 01:50:15
Why the scale factor on linux is '1'?
Aayush Kumar
2011/07/19 01:20:30
The scale factor on linux is not used and is not r
|
+ } |
+ |
frame->printPage(params.page_number, canvas.get()); |
// TODO(myhuang): We should render the header and the footer. |