| 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 8c6dad96e3268ae5d5a56d4fa4c2db015fef6fbc..783677310a32c435da5f3cf5d305599160c833b4 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"
|
|
|
| @@ -34,7 +39,8 @@ void PrintWebViewHelper::RenderPreviewPage(int page_number) {
|
| PrintPageInternal(page_params,
|
| print_preview_context_.GetPrintCanvasSize(),
|
| print_preview_context_.frame(),
|
| - print_preview_context_.metafile());
|
| + print_preview_context_.metafile(),
|
| + true);
|
| print_preview_context_.RenderedPreviewPage(
|
| base::TimeTicks::Now() - begin_time);
|
| PreviewPageRendered(page_number);
|
| @@ -148,12 +154,12 @@ 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, false);
|
| }
|
| } 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, false);
|
| }
|
| }
|
|
|
| @@ -168,30 +174,23 @@ 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;
|
| - 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);
|
| + printing::Metafile* metafile,
|
| + bool is_preview) {
|
| + PageSizeMargins page_size_margins_in_points =
|
| + GetPageSizeAndMarginsInPoints(frame, params.page_number, params.params);
|
|
|
| gfx::Size page_size(
|
| - content_width_in_points + margin_right_in_points +
|
| - margin_left_in_points,
|
| - content_height_in_points + margin_top_in_points +
|
| - margin_bottom_in_points);
|
| - gfx::Rect content_area(margin_left_in_points, margin_top_in_points,
|
| - content_width_in_points, content_height_in_points);
|
| + page_size_margins_in_points.content_width +
|
| + page_size_margins_in_points.margin_right +
|
| + page_size_margins_in_points.margin_left,
|
| + page_size_margins_in_points.content_height +
|
| + page_size_margins_in_points.margin_top +
|
| + page_size_margins_in_points.margin_bottom);
|
| +
|
| + gfx::Rect content_area(page_size_margins_in_points.margin_left,
|
| + page_size_margins_in_points.margin_top,
|
| + page_size_margins_in_points.content_width,
|
| + page_size_margins_in_points.content_height);
|
|
|
| SkDevice* device = metafile->StartPageForVectorCanvas(
|
| page_size, content_area, 1.0f);
|
| @@ -203,6 +202,15 @@ 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.display_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,
|
| + print_preview_context_.total_page_count(), 1,
|
| + page_size_margins_in_points, header_footer_info_);
|
| + }
|
| +
|
| frame->printPage(params.page_number, canvas.get());
|
|
|
| // TODO(myhuang): We should render the header and the footer.
|
|
|