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

Side by Side Diff: chrome/renderer/printing/print_web_view_helper_linux.cc

Issue 694213002: Remove calls to deprecated SkPDFDevice and SkPDFDocuemnt. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 1 month 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
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/printing/print_web_view_helper.h" 5 #include "chrome/renderer/printing/print_web_view_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/common/print_messages.h" 9 #include "chrome/common/print_messages.h"
10 #include "content/public/renderer/render_thread.h" 10 #include "content/public/renderer/render_thread.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 const PrintMsg_PrintPage_Params& params, 149 const PrintMsg_PrintPage_Params& params,
150 WebFrame* frame, 150 WebFrame* frame,
151 PdfMetafileSkia* metafile) { 151 PdfMetafileSkia* metafile) {
152 PageSizeMargins page_layout_in_points; 152 PageSizeMargins page_layout_in_points;
153 double scale_factor = 1.0f; 153 double scale_factor = 1.0f;
154 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params, 154 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params,
155 ignore_css_margins_, &scale_factor, 155 ignore_css_margins_, &scale_factor,
156 &page_layout_in_points); 156 &page_layout_in_points);
157 gfx::Size page_size; 157 gfx::Size page_size;
158 gfx::Rect content_area; 158 gfx::Rect content_area;
159 GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, &page_size, 159 GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, &page_size,
Vitaly Buka (NO REVIEWS) 2014/11/03 17:57:24 Similar code in and _win.cc, _mac.mm and android_w
hal.canary 2014/11/04 15:30:34 Done. Maybe a future CL can factor out the simila
160 &content_area); 160 &content_area);
161 gfx::Rect canvas_area = 161 gfx::Rect canvas_area = gfx::Rect(page_size); // Allow drawing on
162 params.params.display_header_footer ? gfx::Rect(page_size) : content_area; 162 // entire page.
163 skia::RefPtr<skia::VectorCanvas> canvas =
164 metafile->GetVectorCanvasForNewPage(page_size, canvas_area, scale_factor);
165 if (!canvas.get()) {
166 return;
167 }
163 168
164 SkBaseDevice* device = metafile->StartPageForVectorCanvas(page_size,
165 canvas_area,
166 scale_factor);
167 if (!device)
168 return;
169
170 // The printPage method take a reference to the canvas we pass down, so it
171 // can't be a stack object.
172 skia::RefPtr<skia::VectorCanvas> canvas =
173 skia::AdoptRef(new skia::VectorCanvas(device));
174 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); 169 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
175 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); 170 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_);
176 171
177 if (params.params.display_header_footer) { 172 if (params.params.display_header_footer) {
178 // |page_number| is 0-based, so 1 is added. 173 // |page_number| is 0-based, so 1 is added.
179 // TODO(vitalybuka) : why does it work only with 1.25? 174 // TODO(vitalybuka) : why does it work only with 1.25?
180 PrintHeaderAndFooter(canvas.get(), 175 PrintHeaderAndFooter(canvas.get(),
181 params.page_number + 1, 176 params.page_number + 1,
182 print_preview_context_.total_page_count(), 177 print_preview_context_.total_page_count(),
183 *frame, 178 *frame,
184 scale_factor / 1.25, 179 scale_factor / 1.25,
185 page_layout_in_points, 180 page_layout_in_points,
186 params.params); 181 params.params);
187 } 182 }
188 RenderPageContent(frame, params.page_number, canvas_area, content_area, 183 RenderPageContent(frame, params.page_number, canvas_area, content_area,
189 scale_factor, canvas.get()); 184 scale_factor, canvas.get());
185 canvas.clear();
190 186
191 // Done printing. Close the device context to retrieve the compiled metafile. 187 // Done printing. Close the device context to retrieve the compiled metafile.
192 if (!metafile->FinishPage()) 188 if (!metafile->FinishPage())
193 NOTREACHED() << "metafile failed"; 189 NOTREACHED() << "metafile failed";
194 } 190 }
195 191
196 } // namespace printing 192 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698