OLD | NEW |
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 "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/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 paint->SetFontSize(printing::kSettingHeaderFooterFontSize / | 446 paint->SetFontSize(printing::kSettingHeaderFooterFontSize / |
447 webkit_scale_factor); | 447 webkit_scale_factor); |
448 gfx::Size size(paint->GetStringSize()); | 448 gfx::Size size(paint->GetStringSize()); |
449 gfx::Rect rect(point.x(), point.y() - paint->GetBaseline(), | 449 gfx::Rect rect(point.x(), point.y() - paint->GetBaseline(), |
450 size.width(), size.height()); | 450 size.width(), size.height()); |
451 paint->SetDisplayRect(rect); | 451 paint->SetDisplayRect(rect); |
452 { | 452 { |
453 SkMatrix m = canvas->getTotalMatrix(); | 453 SkMatrix m = canvas->getTotalMatrix(); |
454 ui::ScaleFactor device_scale_factor = ui::GetScaleFactorFromScale( | 454 ui::ScaleFactor device_scale_factor = ui::GetScaleFactorFromScale( |
455 SkScalarAbs(m.getScaleX())); | 455 SkScalarAbs(m.getScaleX())); |
456 gfx::Canvas gfx_canvas(canvas, device_scale_factor, false); | 456 scoped_ptr<gfx::Canvas> gfx_canvas(gfx::Canvas::CreateCanvasWithoutScaling( |
457 paint->Draw(&gfx_canvas); | 457 canvas, device_scale_factor)); |
| 458 paint->Draw(gfx_canvas.get()); |
458 } | 459 } |
459 #else | 460 #else |
460 // TODO(arthurhsu): following code has issues with i18n BiDi, see | 461 // TODO(arthurhsu): following code has issues with i18n BiDi, see |
461 // crbug.com/108599. | 462 // crbug.com/108599. |
462 size_t text_byte_length = text.length() * sizeof(char16); | 463 size_t text_byte_length = text.length() * sizeof(char16); |
463 double text_width_in_points = SkScalarToDouble(paint.measureText( | 464 double text_width_in_points = SkScalarToDouble(paint.measureText( |
464 text.c_str(), text_byte_length)); | 465 text.c_str(), text_byte_length)); |
465 SkPoint point = GetHeaderFooterPosition(webkit_scale_factor, page_layout, | 466 SkPoint point = GetHeaderFooterPosition(webkit_scale_factor, page_layout, |
466 horizontal_position, | 467 horizontal_position, |
467 vertical_position, offset_to_baseline, | 468 vertical_position, offset_to_baseline, |
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1874 DCHECK(IsRendering()); | 1875 DCHECK(IsRendering()); |
1875 return prep_frame_view_->GetPrintCanvasSize(); | 1876 return prep_frame_view_->GetPrintCanvasSize(); |
1876 } | 1877 } |
1877 | 1878 |
1878 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 1879 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
1879 prep_frame_view_.reset(); | 1880 prep_frame_view_.reset(); |
1880 metafile_.reset(); | 1881 metafile_.reset(); |
1881 pages_to_render_.clear(); | 1882 pages_to_render_.clear(); |
1882 error_ = PREVIEW_ERROR_NONE; | 1883 error_ = PREVIEW_ERROR_NONE; |
1883 } | 1884 } |
OLD | NEW |