| 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 #import <AppKit/AppKit.h> |    7 #import <AppKit/AppKit.h> | 
|    8  |    8  | 
|    9 #include "base/logging.h" |    9 #include "base/logging.h" | 
|   10 #include "base/mac/scoped_nsautorelease_pool.h" |   10 #include "base/mac/scoped_nsautorelease_pool.h" | 
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  105  |  105  | 
|  106   ComputePageLayoutInPointsForCss(frame, page_number, params, |  106   ComputePageLayoutInPointsForCss(frame, page_number, params, | 
|  107                                   ignore_css_margins_, &scale_factor, |  107                                   ignore_css_margins_, &scale_factor, | 
|  108                                   &page_layout_in_points); |  108                                   &page_layout_in_points); | 
|  109   GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, page_size, |  109   GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, page_size, | 
|  110                                           &content_area); |  110                                           &content_area); | 
|  111   if (content_rect) |  111   if (content_rect) | 
|  112     *content_rect = content_area; |  112     *content_rect = content_area; | 
|  113  |  113  | 
|  114   scale_factor *= webkit_shrink_factor; |  114   scale_factor *= webkit_shrink_factor; | 
 |  115  | 
 |  116   gfx::Rect canvas_area = | 
 |  117       params.display_header_footer ? gfx::Rect(*page_size) : content_area; | 
 |  118  | 
|  115   { |  119   { | 
|  116     SkDevice* device = metafile->StartPageForVectorCanvas( |  120     SkDevice* device = metafile->StartPageForVectorCanvas( | 
|  117         *page_size, content_area, scale_factor); |  121         *page_size, canvas_area, scale_factor); | 
|  118     if (!device) |  122     if (!device) | 
|  119       return; |  123       return; | 
|  120  |  124  | 
|  121     SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); |  125     SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); | 
|  122     canvas->unref();  // SkRefPtr and new both took a reference. |  126     canvas->unref();  // SkRefPtr and new both took a reference. | 
|  123     WebKit::WebCanvas* canvas_ptr = canvas.get(); |  127     WebKit::WebCanvas* canvas_ptr = canvas.get(); | 
|  124     printing::MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); |  128     printing::MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); | 
|  125     skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); |  129     skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); | 
|  126     skia::SetIsPreviewMetafile(*canvas, is_preview); |  130     skia::SetIsPreviewMetafile(*canvas, is_preview); | 
|  127  |  131  | 
|  128     frame->printPage(page_number, canvas_ptr); |  | 
|  129  |  | 
|  130     if (print_pages_params_->params.display_header_footer) { |  132     if (print_pages_params_->params.display_header_footer) { | 
|  131       // |page_number| is 0-based, so 1 is added. |  | 
|  132       PrintHeaderAndFooter(canvas_ptr, page_number + 1, |  133       PrintHeaderAndFooter(canvas_ptr, page_number + 1, | 
|  133                            print_preview_context_.total_page_count(), |  134                            print_preview_context_.total_page_count(), | 
|  134                            scale_factor, page_layout_in_points, |  135                            scale_factor, page_layout_in_points, | 
|  135                            *header_footer_info_, params); |  136                            *header_footer_info_, params); | 
|  136     } |  137     } | 
 |  138     RenderPageContent(frame, page_number, canvas_area, content_area, | 
 |  139                       scale_factor, canvas_ptr); | 
|  137   } |  140   } | 
|  138  |  141  | 
|  139   // Done printing. Close the device context to retrieve the compiled metafile. |  142   // Done printing. Close the device context to retrieve the compiled metafile. | 
|  140   metafile->FinishPage(); |  143   metafile->FinishPage(); | 
|  141 } |  144 } | 
| OLD | NEW |