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

Side by Side Diff: android_webview/renderer/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: comments from Vitaly 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
« no previous file with comments | « no previous file | chrome/renderer/printing/print_web_view_helper.cc » ('j') | printing/metafile.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // TODO(sgurun) copied from chrome/renderer. Remove after crbug.com/322276 5 // TODO(sgurun) copied from chrome/renderer. Remove after crbug.com/322276
6 6
7 #include "android_webview/renderer/print_web_view_helper.h" 7 #include "android_webview/renderer/print_web_view_helper.h"
8 8
9 #include "android_webview/common/print_messages.h" 9 #include "android_webview/common/print_messages.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 PdfMetafileSkia* metafile) { 156 PdfMetafileSkia* metafile) {
157 PageSizeMargins page_layout_in_points; 157 PageSizeMargins page_layout_in_points;
158 double scale_factor = 1.0f; 158 double scale_factor = 1.0f;
159 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params, 159 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params,
160 ignore_css_margins_, &scale_factor, 160 ignore_css_margins_, &scale_factor,
161 &page_layout_in_points); 161 &page_layout_in_points);
162 gfx::Size page_size; 162 gfx::Size page_size;
163 gfx::Rect content_area; 163 gfx::Rect content_area;
164 GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, &page_size, 164 GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, &page_size,
165 &content_area); 165 &content_area);
166 gfx::Rect canvas_area = 166 gfx::Rect canvas_area = gfx::Rect(page_size); // Allow drawing on
167 params.params.display_header_footer ? gfx::Rect(page_size) : content_area; 167 // entire page.
168 168
169 SkBaseDevice* device = metafile->StartPageForVectorCanvas(page_size, 169 skia::RefPtr<skia::VectorCanvas> canvas =
170 canvas_area, 170 metafile->GetVectorCanvasForNewPage(page_size, canvas_area, scale_factor);
171 scale_factor); 171 if (!canvas.get())
172 if (!device)
173 return; 172 return;
174 173
175 // The printPage method take a reference to the canvas we pass down, so it
176 // can't be a stack object.
177 skia::RefPtr<skia::VectorCanvas> canvas =
178 skia::AdoptRef(new skia::VectorCanvas(device));
179 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); 174 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
180 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); 175 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_);
181 176
182 if (params.params.display_header_footer) { 177 if (params.params.display_header_footer) {
183 // |page_number| is 0-based, so 1 is added. 178 // |page_number| is 0-based, so 1 is added.
184 // TODO(vitalybuka) : why does it work only with 1.25? 179 // TODO(vitalybuka) : why does it work only with 1.25?
185 PrintHeaderAndFooter(canvas.get(), params.page_number + 1, 180 PrintHeaderAndFooter(canvas.get(), params.page_number + 1,
186 print_preview_context_.total_page_count(), 181 print_preview_context_.total_page_count(),
187 scale_factor / 1.25, 182 scale_factor / 1.25,
188 page_layout_in_points, *header_footer_info_, 183 page_layout_in_points, *header_footer_info_,
189 params.params); 184 params.params);
190 } 185 }
191 RenderPageContent(frame, params.page_number, canvas_area, content_area, 186 RenderPageContent(frame, params.page_number, canvas_area, content_area,
192 scale_factor, canvas.get()); 187 scale_factor, canvas.get());
193 188
189 canvas.clear(); // Unref the canvas before calling FinishPage().
194 // Done printing. Close the device context to retrieve the compiled metafile. 190 // Done printing. Close the device context to retrieve the compiled metafile.
195 if (!metafile->FinishPage()) 191 if (!metafile->FinishPage())
196 NOTREACHED() << "metafile failed"; 192 NOTREACHED() << "metafile failed";
197 } 193 }
198 194
199 } // namespace printing 195 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/printing/print_web_view_helper.cc » ('j') | printing/metafile.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698