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

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

Issue 9699040: PrintPreview: Hide/Show the header footer option based on print frame margins. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: '' Created 8 years, 9 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
OLDNEW
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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 16 matching lines...) Expand all
27 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
34 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h"
35 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon se.h" 35 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon se.h"
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
37 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
vandebo (ex-Chrome) 2012/03/19 17:11:30 #include "ui/gfx/rect.h"
kmadhusu 2012/03/19 18:45:31 Done.
38 #include "webkit/glue/webpreferences.h" 38 #include "webkit/glue/webpreferences.h"
39 39
40 #if defined(OS_POSIX) 40 #if defined(OS_POSIX)
41 #include "base/process_util.h" 41 #include "base/process_util.h"
42 #endif 42 #endif
43 43
44 #if defined(USE_SKIA) 44 #if defined(USE_SKIA)
45 #include "skia/ext/vector_canvas.h" 45 #include "skia/ext/vector_canvas.h"
46 #include "skia/ext/vector_platform_device_skia.h" 46 #include "skia/ext/vector_platform_device_skia.h"
47 #include "third_party/skia/include/core/SkTypeface.h" 47 #include "third_party/skia/include/core/SkTypeface.h"
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 if (!print_preview_context_.CreatePreviewDocument(&print_params, pages, 866 if (!print_preview_context_.CreatePreviewDocument(&print_params, pages,
867 ignore_css_margins_, 867 ignore_css_margins_,
868 fit_to_page_)) { 868 fit_to_page_)) {
869 return false; 869 return false;
870 } 870 }
871 871
872 PageSizeMargins default_page_layout; 872 PageSizeMargins default_page_layout;
873 ComputePageLayoutInPointsForCss(print_preview_context_.frame(), 0, 873 ComputePageLayoutInPointsForCss(print_preview_context_.frame(), 0,
874 print_params, ignore_css_margins_, 874 print_params, ignore_css_margins_,
875 fit_to_page_, NULL, &default_page_layout); 875 fit_to_page_, NULL, &default_page_layout);
876
876 if (!old_print_pages_params_.get() || 877 if (!old_print_pages_params_.get() ||
877 !PageLayoutIsEqual(*old_print_pages_params_, *print_pages_params_)) { 878 !PageLayoutIsEqual(*old_print_pages_params_, *print_pages_params_)) {
878 bool has_page_size_style = PrintingFrameHasPageSizeStyle( 879 bool has_page_size_style = PrintingFrameHasPageSizeStyle(
879 print_preview_context_.frame(), 880 print_preview_context_.frame(),
880 print_preview_context_.total_page_count()); 881 print_preview_context_.total_page_count());
882 int dpi = GetDPI(&print_params);
883 gfx::Rect printable_area_in_points(
884 ConvertUnit(print_pages_params_->params.printable_area.x(),
885 dpi, printing::kPointsPerInch),
886 ConvertUnit(print_pages_params_->params.printable_area.y(),
887 dpi, printing::kPointsPerInch),
888 ConvertUnit(print_pages_params_->params.printable_area.width(),
889 dpi, printing::kPointsPerInch),
890 ConvertUnit(print_pages_params_->params.printable_area.height(),
891 dpi, printing::kPointsPerInch));
892
881 // Margins: Send default page layout to browser process. 893 // Margins: Send default page layout to browser process.
882 Send(new PrintHostMsg_DidGetDefaultPageLayout(routing_id(), 894 Send(new PrintHostMsg_DidGetDefaultPageLayout(routing_id(),
883 default_page_layout, 895 default_page_layout,
896 printable_area_in_points,
884 has_page_size_style)); 897 has_page_size_style));
885 } 898 }
886 899
887 PrintHostMsg_DidGetPreviewPageCount_Params params; 900 PrintHostMsg_DidGetPreviewPageCount_Params params;
888 params.page_count = print_preview_context_.total_page_count(); 901 params.page_count = print_preview_context_.total_page_count();
889 params.is_modifiable = print_preview_context_.IsModifiable(); 902 params.is_modifiable = print_preview_context_.IsModifiable();
890 params.document_cookie = print_pages_params_->params.document_cookie; 903 params.document_cookie = print_pages_params_->params.document_cookie;
891 params.preview_request_id = print_pages_params_->params.preview_request_id; 904 params.preview_request_id = print_pages_params_->params.preview_request_id;
892 params.clear_preview_data = print_preview_context_.generate_draft_pages(); 905 params.clear_preview_data = print_preview_context_.generate_draft_pages();
893 Send(new PrintHostMsg_DidGetPreviewPageCount(routing_id(), params)); 906 Send(new PrintHostMsg_DidGetPreviewPageCount(routing_id(), params));
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 DCHECK(IsRendering()); 1787 DCHECK(IsRendering());
1775 return prep_frame_view_->GetPrintCanvasSize(); 1788 return prep_frame_view_->GetPrintCanvasSize();
1776 } 1789 }
1777 1790
1778 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { 1791 void PrintWebViewHelper::PrintPreviewContext::ClearContext() {
1779 prep_frame_view_.reset(); 1792 prep_frame_view_.reset();
1780 metafile_.reset(); 1793 metafile_.reset();
1781 pages_to_render_.clear(); 1794 pages_to_render_.clear();
1782 error_ = PREVIEW_ERROR_NONE; 1795 error_ = PREVIEW_ERROR_NONE;
1783 } 1796 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698