Commit 59184f71 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Print selections with print media.

PrepareFrameAndViewForPrint::CopySelection() generates HTML + CSS to
support printing only the selection. By making it do the generation in
print mode, the generated output will have print media CSS applied.

BUG=889226

Change-Id: Ia57d4c0429b93d72cb412545eda7579b53570e6c
Reviewed-on: https://chromium-review.googlesource.com/c/1308604Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607118}
parent 33c10c78
......@@ -827,7 +827,7 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint(
weak_ptr_factory_(this) {
PrintMsg_Print_Params print_params = params;
bool source_is_pdf = PrintingNodeOrPdfFrame(frame, node_to_print_);
if (!should_print_selection_only_ || !source_is_pdf) {
if (!should_print_selection_only_) {
bool fit_to_page =
ignore_css_margins && IsWebPrintScalingOptionFitToPage(print_params);
ComputeWebKitPrintParamsInDesiredDpi(params, source_is_pdf,
......@@ -906,8 +906,11 @@ void PrepareFrameAndViewForPrint::CopySelectionIfNeeded(
void PrepareFrameAndViewForPrint::CopySelection(
const WebPreferences& preferences) {
ResizeForPrinting();
frame()->PrintBegin(web_print_params_, node_to_print_);
std::string html = frame()->SelectionAsMarkup().Utf8();
frame()->PrintEnd();
RestoreSize();
// Create a new WebView with the same settings as the current display one.
// Except that we disable javascript (don't want any active content running
// on the page).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment