| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/gfx/size.h" | 9 #include "base/gfx/size.h" |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 const gfx::Size& canvas_size, | 197 const gfx::Size& canvas_size, |
| 198 WebFrame* frame) { | 198 WebFrame* frame) { |
| 199 #if defined(OS_WIN) | 199 #if defined(OS_WIN) |
| 200 // Generate a memory-based EMF file. The EMF will use the current screen's | 200 // Generate a memory-based EMF file. The EMF will use the current screen's |
| 201 // DPI. | 201 // DPI. |
| 202 gfx::Emf emf; | 202 gfx::Emf emf; |
| 203 | 203 |
| 204 emf.CreateDc(NULL, NULL); | 204 emf.CreateDc(NULL, NULL); |
| 205 HDC hdc = emf.hdc(); | 205 HDC hdc = emf.hdc(); |
| 206 DCHECK(hdc); | 206 DCHECK(hdc); |
| 207 skia::PlatformDeviceWin::InitializeDC(hdc); | 207 skia::PlatformDevice::InitializeDC(hdc); |
| 208 // Since WebKit extends the page width depending on the magical shrink | 208 // Since WebKit extends the page width depending on the magical shrink |
| 209 // factor we make sure the canvas covers the worst case scenario | 209 // factor we make sure the canvas covers the worst case scenario |
| 210 // (x2.0 currently). PrintContext will then set the correct clipping region. | 210 // (x2.0 currently). PrintContext will then set the correct clipping region. |
| 211 int size_x = static_cast<int>(canvas_size.width() * params.params.max_shrink); | 211 int size_x = static_cast<int>(canvas_size.width() * params.params.max_shrink); |
| 212 int size_y = static_cast<int>(canvas_size.height() * | 212 int size_y = static_cast<int>(canvas_size.height() * |
| 213 params.params.max_shrink); | 213 params.params.max_shrink); |
| 214 // Calculate the dpi adjustment. | 214 // Calculate the dpi adjustment. |
| 215 float shrink = static_cast<float>(canvas_size.width()) / | 215 float shrink = static_cast<float>(canvas_size.width()) / |
| 216 params.params.printable_size.width(); | 216 params.params.printable_size.width(); |
| 217 #if 0 | 217 #if 0 |
| 218 // TODO(maruel): This code is kept for testing until the 100% GDI drawing | 218 // TODO(maruel): This code is kept for testing until the 100% GDI drawing |
| 219 // code is stable. maruels use this code's output as a reference when the | 219 // code is stable. maruels use this code's output as a reference when the |
| 220 // GDI drawing code fails. | 220 // GDI drawing code fails. |
| 221 | 221 |
| 222 // Mix of Skia and GDI based. | 222 // Mix of Skia and GDI based. |
| 223 skia::PlatformCanvasWin canvas(size_x, size_y, true); | 223 skia::PlatformCanvas canvas(size_x, size_y, true); |
| 224 canvas.drawARGB(255, 255, 255, 255, SkPorterDuff::kSrc_Mode); | 224 canvas.drawARGB(255, 255, 255, 255, SkPorterDuff::kSrc_Mode); |
| 225 float webkit_shrink = frame->PrintPage(params.page_number, &canvas); | 225 float webkit_shrink = frame->PrintPage(params.page_number, &canvas); |
| 226 if (shrink <= 0) { | 226 if (shrink <= 0) { |
| 227 NOTREACHED() << "Printing page " << params.page_number << " failed."; | 227 NOTREACHED() << "Printing page " << params.page_number << " failed."; |
| 228 } else { | 228 } else { |
| 229 // Update the dpi adjustment with the "page shrink" calculated in webkit. | 229 // Update the dpi adjustment with the "page shrink" calculated in webkit. |
| 230 shrink /= webkit_shrink; | 230 shrink /= webkit_shrink; |
| 231 } | 231 } |
| 232 | 232 |
| 233 // Create a BMP v4 header that we can serialize. | 233 // Create a BMP v4 header that we can serialize. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 | 332 |
| 333 gfx::NativeViewId PrintWebViewHelper::GetContainingView(WebWidget* webwidget) { | 333 gfx::NativeViewId PrintWebViewHelper::GetContainingView(WebWidget* webwidget) { |
| 334 NOTREACHED(); | 334 NOTREACHED(); |
| 335 return gfx::NativeViewId(); | 335 return gfx::NativeViewId(); |
| 336 } | 336 } |
| 337 | 337 |
| 338 bool PrintWebViewHelper::IsHidden(WebWidget* webwidget) { | 338 bool PrintWebViewHelper::IsHidden(WebWidget* webwidget) { |
| 339 NOTREACHED(); | 339 NOTREACHED(); |
| 340 return true; | 340 return true; |
| 341 } | 341 } |
| OLD | NEW |