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

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

Issue 7633040: CL removing inheritance of SkDevice from PlatformDevice. Flavours of PlatformDevice classes now ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Add mac changes. Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | printing/pdf_metafile_skia.cc » ('j') | skia/ext/bitmap_platform_device_linux.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 21 matching lines...) Expand all
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
33 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
34 34
35 #if defined(OS_POSIX) 35 #if defined(OS_POSIX)
36 #include "content/common/view_messages.h" 36 #include "content/common/view_messages.h"
37 #endif 37 #endif
38 38
39 #if defined(USE_SKIA) 39 #if defined(USE_SKIA)
40 #include "base/string_number_conversions.h" 40 #include "base/string_number_conversions.h"
41 #include "skia/ext/vector_canvas.h" 41 #include "skia/ext/vector_canvas.h"
42 #include "skia/ext/vector_platform_device_skia.h"
43 #include "third_party/skia/include/core/SkTypeface.h" 42 #include "third_party/skia/include/core/SkTypeface.h"
43 #include "third_party/skia/include/pdf/SkPDFDevice.h"
44 #endif // defined(USE_SKIA) 44 #endif // defined(USE_SKIA)
45 45
46 using base::Time; 46 using base::Time;
47 using printing::ConvertPixelsToPoint; 47 using printing::ConvertPixelsToPoint;
48 using printing::ConvertPixelsToPointDouble; 48 using printing::ConvertPixelsToPointDouble;
49 using printing::ConvertUnit; 49 using printing::ConvertUnit;
50 using printing::ConvertUnitDouble; 50 using printing::ConvertUnitDouble;
51 using printing::GetHeaderFooterSegmentWidth; 51 using printing::GetHeaderFooterSegmentWidth;
52 using WebKit::WebConsoleMessage; 52 using WebKit::WebConsoleMessage;
53 using WebKit::WebDocument; 53 using WebKit::WebDocument;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 #if defined(USE_SKIA) 183 #if defined(USE_SKIA)
184 // static - Not anonymous so that platform implementations can use it. 184 // static - Not anonymous so that platform implementations can use it.
185 void PrintWebViewHelper::PrintHeaderAndFooter( 185 void PrintWebViewHelper::PrintHeaderAndFooter(
186 SkDevice* device, 186 SkDevice* device,
187 skia::VectorCanvas* canvas, 187 skia::VectorCanvas* canvas,
188 int page_number, 188 int page_number,
189 int total_pages, 189 int total_pages,
190 float webkit_scale_factor, 190 float webkit_scale_factor,
191 const PageSizeMargins& page_layout, 191 const PageSizeMargins& page_layout,
192 const DictionaryValue& header_footer_info) { 192 const DictionaryValue& header_footer_info) {
193 static_cast<skia::VectorPlatformDeviceSkia*>(device)->setDrawingArea( 193 static_cast<SkPDFDevice*>(device)->setDrawingArea(
194 SkPDFDevice::kMargin_DrawingArea); 194 SkPDFDevice::kMargin_DrawingArea);
195 195
196 SkPaint paint; 196 SkPaint paint;
197 paint.setColor(SK_ColorBLACK); 197 paint.setColor(SK_ColorBLACK);
198 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); 198 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
199 paint.setTextSize(printing::kSettingHeaderFooterFontSize); 199 paint.setTextSize(printing::kSettingHeaderFooterFontSize);
200 paint.setTypeface(SkTypeface::CreateFromName( 200 paint.setTypeface(SkTypeface::CreateFromName(
201 printing::kSettingHeaderFooterFontFamilyName, SkTypeface::kNormal)); 201 printing::kSettingHeaderFooterFontFamilyName, SkTypeface::kNormal));
202 202
203 // Print the headers onto the |canvas| if there is enough space to print 203 // Print the headers onto the |canvas| if there is enough space to print
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 printing::kSettingHeaderFooterInterstice + footer_bounds.height(); 244 printing::kSettingHeaderFooterInterstice + footer_bounds.height();
245 if (text_height <= page_layout.margin_bottom) { 245 if (text_height <= page_layout.margin_bottom) {
246 PrintHeaderFooterText(page_of_total_pages, canvas, paint, 246 PrintHeaderFooterText(page_of_total_pages, canvas, paint,
247 webkit_scale_factor, page_layout, printing::RIGHT, 247 webkit_scale_factor, page_layout, printing::RIGHT,
248 printing::BOTTOM, footer_bounds.bottom()); 248 printing::BOTTOM, footer_bounds.bottom());
249 PrintHeaderFooterText(url, canvas, paint, webkit_scale_factor, page_layout, 249 PrintHeaderFooterText(url, canvas, paint, webkit_scale_factor, page_layout,
250 printing::LEFT, printing::BOTTOM, 250 printing::LEFT, printing::BOTTOM,
251 footer_bounds.bottom()); 251 footer_bounds.bottom());
252 } 252 }
253 253
254 static_cast<skia::VectorPlatformDeviceSkia*>(device)->setDrawingArea( 254 static_cast<SkPDFDevice*>(device)->setDrawingArea(
255 SkPDFDevice::kContent_DrawingArea); 255 SkPDFDevice::kContent_DrawingArea);
256 } 256 }
257 #endif // defined(USE_SKIA) 257 #endif // defined(USE_SKIA)
258 258
259 PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint( 259 PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint(
260 const PrintMsg_Print_Params& print_params, 260 const PrintMsg_Print_Params& print_params,
261 WebFrame* frame, 261 WebFrame* frame,
262 WebNode* node) 262 WebNode* node)
263 : frame_(frame), 263 : frame_(frame),
264 web_view_(frame->view()), 264 web_view_(frame->view()),
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 const gfx::Size& 1295 const gfx::Size&
1296 PrintWebViewHelper::PrintPreviewContext::GetPrintCanvasSize() const { 1296 PrintWebViewHelper::PrintPreviewContext::GetPrintCanvasSize() const {
1297 return prep_frame_view_->GetPrintCanvasSize(); 1297 return prep_frame_view_->GetPrintCanvasSize();
1298 } 1298 }
1299 1299
1300 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { 1300 void PrintWebViewHelper::PrintPreviewContext::ClearContext() {
1301 prep_frame_view_.reset(); 1301 prep_frame_view_.reset();
1302 metafile_.reset(); 1302 metafile_.reset();
1303 rendered_pages_.clear(); 1303 rendered_pages_.clear();
1304 } 1304 }
OLDNEW
« no previous file with comments | « no previous file | printing/pdf_metafile_skia.cc » ('j') | skia/ext/bitmap_platform_device_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698