Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Unified Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 10083059: [Print Preview] Modified PP_PrintSettings_Dev interface to support auto fit to page functionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index ffb0c17a4f95a041e3ee9b3b2cc815af254f7a42..e9e054678156952e65fe937accf1c3a8d6f8b774 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -1137,7 +1137,10 @@ bool PluginInstance::IsPrintScalingDisabled() {
return plugin_print_interface_->IsScalingDisabled(pp_instance()) == PP_TRUE;
}
-int PluginInstance::PrintBegin(const gfx::Rect& printable_area,
+int PluginInstance::PrintBegin(const gfx::Rect& content_area,
+ const gfx::Rect& printable_area,
+ const gfx::Size& paper_size,
+ bool fit_to_paper_size,
int printer_dpi) {
// Keep a reference on the stack. See NOTE above.
scoped_refptr<PluginInstance> ref(this);
@@ -1152,9 +1155,12 @@ int PluginInstance::PrintBegin(const gfx::Rect& printable_area,
int num_pages = 0;
PP_PrintSettings_Dev print_settings;
print_settings.printable_area = PP_FromGfxRect(printable_area);
+ print_settings.content_area = PP_FromGfxRect(content_area);
+ print_settings.paper_size = PP_FromGfxSize(paper_size);
print_settings.dpi = printer_dpi;
print_settings.orientation = PP_PRINTORIENTATION_NORMAL;
print_settings.grayscale = PP_FALSE;
+ print_settings.fit_to_paper_size = PP_FromBool(fit_to_paper_size);
print_settings.format = format;
num_pages = plugin_print_interface_->Begin(pp_instance(),
&print_settings);
@@ -1456,7 +1462,7 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output,
CGContextRef cgContext = canvas;
CGContextSaveGState(cgContext);
CGContextTranslateCTM(cgContext, 0,
- current_print_settings_.printable_area.size.height);
+ current_print_settings_.content_area.size.height);
CGContextScaleCTM(cgContext, 1.0, -1.0);
CGRect page_rect;
page_rect.origin.x = current_print_settings_.printable_area.point.x;
@@ -1529,18 +1535,18 @@ bool PluginInstance::PrintRasterOutput(PP_Resource print_output,
src_rect.set(0, 0, bitmap->width(), bitmap->height());
SkRect dest_rect;
dest_rect.set(
- SkIntToScalar(current_print_settings_.printable_area.point.x),
- SkIntToScalar(current_print_settings_.printable_area.point.y),
- SkIntToScalar(current_print_settings_.printable_area.point.x +
- current_print_settings_.printable_area.size.width),
- SkIntToScalar(current_print_settings_.printable_area.point.y +
- current_print_settings_.printable_area.size.height));
+ SkIntToScalar(current_print_settings_.content_area.point.x),
+ SkIntToScalar(current_print_settings_.content_area.point.y),
+ SkIntToScalar(current_print_settings_.content_area.point.x +
+ current_print_settings_.content_area.size.width),
+ SkIntToScalar(current_print_settings_.content_area.point.y +
+ current_print_settings_.content_area.size.height));
bool draw_to_canvas = true;
gfx::Rect dest_rect_gfx;
- dest_rect_gfx.set_x(current_print_settings_.printable_area.point.x);
- dest_rect_gfx.set_y(current_print_settings_.printable_area.point.y);
- dest_rect_gfx.set_width(current_print_settings_.printable_area.size.width);
- dest_rect_gfx.set_height(current_print_settings_.printable_area.size.height);
+ dest_rect_gfx.set_x(current_print_settings_.content_area.point.x);
+ dest_rect_gfx.set_y(current_print_settings_.content_area.point.y);
+ dest_rect_gfx.set_width(current_print_settings_.content_area.size.width);
+ dest_rect_gfx.set_height(current_print_settings_.content_area.size.height);
#if defined(OS_WIN)
// Since this is a raster output, the size of the bitmap can be
@@ -1559,7 +1565,7 @@ bool PluginInstance::PrintRasterOutput(PP_Resource print_output,
#if defined(OS_MACOSX) && !defined(USE_SKIA)
draw_to_canvas = false;
DrawSkBitmapToCanvas(*bitmap, canvas, dest_rect_gfx,
- current_print_settings_.printable_area.size.height);
+ current_print_settings_.content_area.size.height);
// See comments in the header file.
last_printed_page_ = image;
#else // defined(OS_MACOSX) && !defined(USE_SKIA)

Powered by Google App Engine
This is Rietveld 408576698