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

Side by Side Diff: components/printing/renderer/print_web_view_helper.cc

Issue 2788343003: Remove desired DPI (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « components/printing/common/print_messages.cc ('k') | components/printing/test/mock_printer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/printing/renderer/print_web_view_helper.h" 5 #include "components/printing/renderer/print_web_view_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // on dpi. 113 // on dpi.
114 return kPointsPerInch; 114 return kPointsPerInch;
115 #else 115 #else
116 return static_cast<int>(print_params->dpi); 116 return static_cast<int>(print_params->dpi);
117 #endif // defined(OS_MACOSX) 117 #endif // defined(OS_MACOSX)
118 } 118 }
119 119
120 bool PrintMsg_Print_Params_IsValid(const PrintMsg_Print_Params& params) { 120 bool PrintMsg_Print_Params_IsValid(const PrintMsg_Print_Params& params) {
121 return !params.content_size.IsEmpty() && !params.page_size.IsEmpty() && 121 return !params.content_size.IsEmpty() && !params.page_size.IsEmpty() &&
122 !params.printable_area.IsEmpty() && params.document_cookie && 122 !params.printable_area.IsEmpty() && params.document_cookie &&
123 params.desired_dpi && params.dpi && params.margin_top >= 0 && 123 params.dpi && params.margin_top >= 0 && params.margin_left >= 0 &&
124 params.margin_left >= 0 && params.dpi > kMinDpi && 124 params.dpi > kMinDpi && params.document_cookie != 0;
125 params.document_cookie != 0;
126 } 125 }
127 126
128 // Helper function to check for fit to page 127 // Helper function to check for fit to page
129 bool IsWebPrintScalingOptionFitToPage(const PrintMsg_Print_Params& params) { 128 bool IsWebPrintScalingOptionFitToPage(const PrintMsg_Print_Params& params) {
130 return params.print_scaling_option == 129 return params.print_scaling_option ==
131 blink::WebPrintScalingOptionFitToPrintableArea; 130 blink::WebPrintScalingOptionFitToPrintableArea;
132 } 131 }
133 132
134 PrintMsg_Print_Params GetCssPrintParams( 133 PrintMsg_Print_Params GetCssPrintParams(
135 blink::WebLocalFrame* frame, 134 blink::WebLocalFrame* frame,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 281 }
283 282
284 void ComputeWebKitPrintParamsInDesiredDpi( 283 void ComputeWebKitPrintParamsInDesiredDpi(
285 const PrintMsg_Print_Params& print_params, 284 const PrintMsg_Print_Params& print_params,
286 blink::WebPrintParams* webkit_print_params) { 285 blink::WebPrintParams* webkit_print_params) {
287 int dpi = GetDPI(&print_params); 286 int dpi = GetDPI(&print_params);
288 webkit_print_params->printerDPI = dpi; 287 webkit_print_params->printerDPI = dpi;
289 webkit_print_params->rasterizePDF = print_params.rasterize_pdf; 288 webkit_print_params->rasterizePDF = print_params.rasterize_pdf;
290 webkit_print_params->printScalingOption = print_params.print_scaling_option; 289 webkit_print_params->printScalingOption = print_params.print_scaling_option;
291 290
292 webkit_print_params->printContentArea.width = ConvertUnit( 291 webkit_print_params->printContentArea.width =
293 print_params.content_size.width(), dpi, print_params.desired_dpi); 292 ConvertUnit(print_params.content_size.width(), dpi, kPointsPerInch);
294 webkit_print_params->printContentArea.height = ConvertUnit( 293 webkit_print_params->printContentArea.height =
295 print_params.content_size.height(), dpi, print_params.desired_dpi); 294 ConvertUnit(print_params.content_size.height(), dpi, kPointsPerInch);
296 295
297 webkit_print_params->printableArea.x = ConvertUnit( 296 webkit_print_params->printableArea.x =
298 print_params.printable_area.x(), dpi, print_params.desired_dpi); 297 ConvertUnit(print_params.printable_area.x(), dpi, kPointsPerInch);
299 webkit_print_params->printableArea.y = ConvertUnit( 298 webkit_print_params->printableArea.y =
300 print_params.printable_area.y(), dpi, print_params.desired_dpi); 299 ConvertUnit(print_params.printable_area.y(), dpi, kPointsPerInch);
301 webkit_print_params->printableArea.width = ConvertUnit( 300 webkit_print_params->printableArea.width =
302 print_params.printable_area.width(), dpi, print_params.desired_dpi); 301 ConvertUnit(print_params.printable_area.width(), dpi, kPointsPerInch);
303 webkit_print_params->printableArea.height = ConvertUnit( 302 webkit_print_params->printableArea.height =
304 print_params.printable_area.height(), dpi, print_params.desired_dpi); 303 ConvertUnit(print_params.printable_area.height(), dpi, kPointsPerInch);
305 304
306 webkit_print_params->paperSize.width = ConvertUnit( 305 webkit_print_params->paperSize.width =
307 print_params.page_size.width(), dpi, print_params.desired_dpi); 306 ConvertUnit(print_params.page_size.width(), dpi, kPointsPerInch);
308 webkit_print_params->paperSize.height = ConvertUnit( 307 webkit_print_params->paperSize.height =
309 print_params.page_size.height(), dpi, print_params.desired_dpi); 308 ConvertUnit(print_params.page_size.height(), dpi, kPointsPerInch);
310 } 309 }
311 310
312 blink::WebPlugin* GetPlugin(const blink::WebLocalFrame* frame) { 311 blink::WebPlugin* GetPlugin(const blink::WebLocalFrame* frame) {
313 return frame->document().isPluginDocument() 312 return frame->document().isPluginDocument()
314 ? frame->document().to<blink::WebPluginDocument>().plugin() 313 ? frame->document().to<blink::WebPluginDocument>().plugin()
315 : NULL; 314 : NULL;
316 } 315 }
317 316
318 bool PrintingNodeOrPdfFrame(const blink::WebLocalFrame* frame, 317 bool PrintingNodeOrPdfFrame(const blink::WebLocalFrame* frame,
319 const blink::WebNode& node) { 318 const blink::WebNode& node) {
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 blink::WebConsoleMessage::LevelWarning, message)); 2368 blink::WebConsoleMessage::LevelWarning, message));
2370 return false; 2369 return false;
2371 } 2370 }
2372 2371
2373 void PrintWebViewHelper::ScriptingThrottler::Reset() { 2372 void PrintWebViewHelper::ScriptingThrottler::Reset() {
2374 // Reset counter on successful print. 2373 // Reset counter on successful print.
2375 count_ = 0; 2374 count_ = 0;
2376 } 2375 }
2377 2376
2378 } // namespace printing 2377 } // namespace printing
OLDNEW
« no previous file with comments | « components/printing/common/print_messages.cc ('k') | components/printing/test/mock_printer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698