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

Side by Side Diff: chrome/renderer/print_web_view_helper_linux.cc

Issue 8585017: PrintPreview: Honor the print media page size and margin values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/renderer/print_web_view_helper.h" 5 #include "chrome/renderer/print_web_view_helper.h"
6 6
7 #include "base/file_descriptor_posix.h" 7 #include "base/file_descriptor_posix.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 #endif // defined(OS_CHROMEOS) 140 #endif // defined(OS_CHROMEOS)
141 } 141 }
142 142
143 bool PrintWebViewHelper::RenderPages(const PrintMsg_PrintPages_Params& params, 143 bool PrintWebViewHelper::RenderPages(const PrintMsg_PrintPages_Params& params,
144 WebKit::WebFrame* frame, 144 WebKit::WebFrame* frame,
145 const WebKit::WebNode& node, 145 const WebKit::WebNode& node,
146 int* page_count, 146 int* page_count,
147 PrepareFrameAndViewForPrint* prepare, 147 PrepareFrameAndViewForPrint* prepare,
148 printing::Metafile* metafile) { 148 printing::Metafile* metafile) {
149 PrintMsg_Print_Params print_params = params.params; 149 PrintMsg_Print_Params print_params = params.params;
150 UpdatePrintableSizeInPrintParameters(frame, node, prepare, &print_params); 150 UpdatePrintableSizeInPrintParameters(frame, node, prepare, &print_params,
151 default_margins_requested_);
151 152
152 *page_count = prepare->GetExpectedPageCount(); 153 *page_count = prepare->GetExpectedPageCount();
153 if (!*page_count) 154 if (!*page_count)
154 return false; 155 return false;
155 156
156 #if !defined(OS_CHROMEOS) 157 #if !defined(OS_CHROMEOS)
157 Send(new PrintHostMsg_DidGetPrintedPagesCount(routing_id(), 158 Send(new PrintHostMsg_DidGetPrintedPagesCount(routing_id(),
158 print_params.document_cookie, 159 print_params.document_cookie,
159 *page_count)); 160 *page_count));
160 #endif 161 #endif
(...skipping 18 matching lines...) Expand all
179 return true; 180 return true;
180 } 181 }
181 182
182 void PrintWebViewHelper::PrintPageInternal( 183 void PrintWebViewHelper::PrintPageInternal(
183 const PrintMsg_PrintPage_Params& params, 184 const PrintMsg_PrintPage_Params& params,
184 const gfx::Size& canvas_size, 185 const gfx::Size& canvas_size,
185 WebFrame* frame, 186 WebFrame* frame,
186 printing::Metafile* metafile) { 187 printing::Metafile* metafile) {
187 printing::PageSizeMargins page_layout_in_points; 188 printing::PageSizeMargins page_layout_in_points;
188 GetPageSizeAndMarginsInPoints(frame, params.page_number, params.params, 189 GetPageSizeAndMarginsInPoints(frame, params.page_number, params.params,
189 &page_layout_in_points); 190 &page_layout_in_points,
191 default_margins_requested_);
190 192
191 gfx::Size page_size( 193 gfx::Size page_size(
192 page_layout_in_points.content_width + 194 page_layout_in_points.content_width +
193 page_layout_in_points.margin_right + 195 page_layout_in_points.margin_right +
194 page_layout_in_points.margin_left, 196 page_layout_in_points.margin_left,
195 page_layout_in_points.content_height + 197 page_layout_in_points.content_height +
196 page_layout_in_points.margin_top + 198 page_layout_in_points.margin_top +
197 page_layout_in_points.margin_bottom); 199 page_layout_in_points.margin_bottom);
198 gfx::Rect content_area(page_layout_in_points.margin_left, 200 gfx::Rect content_area(page_layout_in_points.margin_left,
199 page_layout_in_points.margin_top, 201 page_layout_in_points.margin_top,
(...skipping 18 matching lines...) Expand all
218 // The scale factor on Linux is 1. 220 // The scale factor on Linux is 1.
219 PrintHeaderAndFooter(canvas.get(), params.page_number + 1, 221 PrintHeaderAndFooter(canvas.get(), params.page_number + 1,
220 print_preview_context_.total_page_count(), 1, 222 print_preview_context_.total_page_count(), 1,
221 page_layout_in_points, *header_footer_info_); 223 page_layout_in_points, *header_footer_info_);
222 } 224 }
223 225
224 // Done printing. Close the device context to retrieve the compiled metafile. 226 // Done printing. Close the device context to retrieve the compiled metafile.
225 if (!metafile->FinishPage()) 227 if (!metafile->FinishPage())
226 NOTREACHED() << "metafile failed"; 228 NOTREACHED() << "metafile failed";
227 } 229 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698