OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 // Safari uses: 765 & 1224. Margins aren't exactly the same either. | 446 // Safari uses: 765 & 1224. Margins aren't exactly the same either. |
447 // Scale = 2.222 for MDI printer. | 447 // Scale = 2.222 for MDI printer. |
448 int pages; | 448 int pages; |
449 if (!frame->SetPrintingMode(true, | 449 if (!frame->SetPrintingMode(true, |
450 minLayoutWidth, | 450 minLayoutWidth, |
451 maxLayoutWidth, | 451 maxLayoutWidth, |
452 &printed_document_width_)) { | 452 &printed_document_width_)) { |
453 NOTREACHED(); | 453 NOTREACHED(); |
454 pages = 0; | 454 pages = 0; |
455 } else { | 455 } else { |
| 456 DCHECK_GT(printed_document_width_, 0); |
456 // Force to recalculate the height, otherwise it reuse the current window | 457 // Force to recalculate the height, otherwise it reuse the current window |
457 // height as the default. | 458 // height as the default. |
458 float effective_shrink = printed_document_width_ / paper_width; | 459 float effective_shrink = printed_document_width_ / paper_width; |
459 gfx::Size page_size(printed_document_width_, | 460 gfx::Size page_size(printed_document_width_, |
460 static_cast<int>(paper_height * effective_shrink) - 1); | 461 static_cast<int>(paper_height * effective_shrink) - 1); |
461 WebView* view = frame->GetView(); | 462 WebView* view = frame->GetView(); |
462 if (view) { | 463 if (view) { |
463 // Hack around an issue where if the current view height is higher than | 464 // Hack around an issue where if the current view height is higher than |
464 // the page height, empty pages will be printed even if the bottom of the | 465 // the page height, empty pages will be printed even if the bottom of the |
465 // web page is empty. | 466 // web page is empty. |
(...skipping 2260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2726 template_resource_id)); | 2727 template_resource_id)); |
2727 | 2728 |
2728 if (template_html.empty()) { | 2729 if (template_html.empty()) { |
2729 NOTREACHED() << "unable to load template. ID: " << template_resource_id; | 2730 NOTREACHED() << "unable to load template. ID: " << template_resource_id; |
2730 return ""; | 2731 return ""; |
2731 } | 2732 } |
2732 // "t" is the id of the templates root node. | 2733 // "t" is the id of the templates root node. |
2733 return jstemplate_builder::GetTemplateHtml( | 2734 return jstemplate_builder::GetTemplateHtml( |
2734 template_html, &error_strings, "t"); | 2735 template_html, &error_strings, "t"); |
2735 } | 2736 } |
OLD | NEW |