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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 WebKit::WebCanvas* canvas, | 421 WebKit::WebCanvas* canvas, |
422 HeaderFooterPaint paint, | 422 HeaderFooterPaint paint, |
423 float webkit_scale_factor, | 423 float webkit_scale_factor, |
424 const PageSizeMargins& page_layout, | 424 const PageSizeMargins& page_layout, |
425 printing::HorizontalHeaderFooterPosition horizontal_position, | 425 printing::HorizontalHeaderFooterPosition horizontal_position, |
426 printing::VerticalHeaderFooterPosition vertical_position, | 426 printing::VerticalHeaderFooterPosition vertical_position, |
427 double offset_to_baseline) { | 427 double offset_to_baseline) { |
428 // TODO(arthurhsu): Following code works on Windows only so far. | 428 // TODO(arthurhsu): Following code works on Windows only so far. |
429 // See crbug.com/108599 and its blockers for more information. | 429 // See crbug.com/108599 and its blockers for more information. |
430 scoped_ptr<gfx::RenderText> render_text(gfx::RenderText::CreateRenderText()); | 430 scoped_ptr<gfx::RenderText> render_text(gfx::RenderText::CreateRenderText()); |
| 431 // TODO(asvitkine): The below line is to workaround http://crbug.com/133548. |
| 432 // Remove it when the underlying Skia bug has been fixed. |
| 433 render_text->set_clip_to_display_rect(false); |
431 render_text->SetText(text); | 434 render_text->SetText(text); |
432 int font_size = printing::kSettingHeaderFooterFontSize / webkit_scale_factor; | 435 int font_size = printing::kSettingHeaderFooterFontSize / webkit_scale_factor; |
433 render_text->SetFontSize(font_size); | 436 render_text->SetFontSize(font_size); |
434 gfx::Size text_size = render_text->GetStringSize(); | 437 gfx::Size text_size = render_text->GetStringSize(); |
435 // Text height includes the configured gap between header/footer and the | 438 // Text height includes the configured gap between header/footer and the |
436 // context, plus the 1 point that we later substracted for ensuring the | 439 // context, plus the 1 point that we later substracted for ensuring the |
437 // overlapping between RenderText rect and the content area. | 440 // overlapping between RenderText rect and the content area. |
438 int text_height = text_size.height() + 1 + | 441 int text_height = text_size.height() + 1 + |
439 printing::kSettingHeaderFooterInterstice; | 442 printing::kSettingHeaderFooterInterstice; |
440 SkScalar margin_left = page_layout.margin_left / webkit_scale_factor; | 443 SkScalar margin_left = page_layout.margin_left / webkit_scale_factor; |
(...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 DCHECK(IsRendering()); | 1875 DCHECK(IsRendering()); |
1873 return prep_frame_view_->GetPrintCanvasSize(); | 1876 return prep_frame_view_->GetPrintCanvasSize(); |
1874 } | 1877 } |
1875 | 1878 |
1876 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 1879 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
1877 prep_frame_view_.reset(); | 1880 prep_frame_view_.reset(); |
1878 metafile_.reset(); | 1881 metafile_.reset(); |
1879 pages_to_render_.clear(); | 1882 pages_to_render_.clear(); |
1880 error_ = PREVIEW_ERROR_NONE; | 1883 error_ = PREVIEW_ERROR_NONE; |
1881 } | 1884 } |
OLD | NEW |