[printing] Move WebPrintScalingOption to //printing/mojom/print.mojom
This CL moves blink::WebPrintScalingOption to print.mojom to pass it to Mojo interfaces and removes web_print_scaling_option.h. This is a precursor CL to mojofy PrintHostMsg_GetDefaultPrintSettings. Bug: 1008939 Change-Id: Ia951aebcfb397275e9a0367e773924ba84ee256d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216131 Commit-Queue: Dave Tapuska <dtapuska@chromium.org> Reviewed-by: Dave Tapuska <dtapuska@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Cr-Commit-Position: refs/heads/master@{#773691}
This commit is contained in:

committed by
Commit Bot

parent
e6559e9cab
commit
6e0eb6e5cb
components/printing
common
renderer
test
content/renderer/pepper
printing/mojom
third_party/blink/public
@ -75,7 +75,7 @@ PrintMsg_Print_Params::PrintMsg_Print_Params()
|
||||
preview_ui_id(-1),
|
||||
preview_request_id(0),
|
||||
is_first_request(false),
|
||||
print_scaling_option(blink::kWebPrintScalingOptionSourceSize),
|
||||
print_scaling_option(printing::mojom::PrintScalingOption::kSourceSize),
|
||||
print_to_pdf(false),
|
||||
display_header_footer(false),
|
||||
should_print_backgrounds(false),
|
||||
@ -104,7 +104,7 @@ void PrintMsg_Print_Params::Reset() {
|
||||
preview_ui_id = -1;
|
||||
preview_request_id = 0;
|
||||
is_first_request = false;
|
||||
print_scaling_option = blink::kWebPrintScalingOptionSourceSize;
|
||||
print_scaling_option = printing::mojom::PrintScalingOption::kSourceSize;
|
||||
print_to_pdf = false;
|
||||
display_header_footer = false;
|
||||
title = base::string16();
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "printing/mojom/print.mojom.h"
|
||||
#include "printing/page_range.h"
|
||||
#include "printing/print_job_constants.h"
|
||||
#include "third_party/blink/public/web/web_print_scaling_option.h"
|
||||
#include "ui/accessibility/ax_param_traits.h"
|
||||
#include "ui/gfx/geometry/point.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
@ -55,7 +54,7 @@ struct PrintMsg_Print_Params {
|
||||
int32_t preview_ui_id;
|
||||
int preview_request_id;
|
||||
bool is_first_request;
|
||||
blink::WebPrintScalingOption print_scaling_option;
|
||||
printing::mojom::PrintScalingOption print_scaling_option;
|
||||
bool print_to_pdf;
|
||||
bool display_header_footer;
|
||||
base::string16 title;
|
||||
@ -105,8 +104,8 @@ struct PrintHostMsg_PreviewIds {
|
||||
|
||||
#define IPC_MESSAGE_START PrintMsgStart
|
||||
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebPrintScalingOption,
|
||||
blink::kWebPrintScalingOptionLast)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(printing::mojom::PrintScalingOption,
|
||||
printing::mojom::PrintScalingOption::kMaxValue)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(printing::SkiaDocumentType,
|
||||
printing::SkiaDocumentType::MAX)
|
||||
|
||||
|
@ -143,9 +143,9 @@ bool PrintMsg_Print_Params_IsValid(const PrintMsg_Print_Params& params) {
|
||||
}
|
||||
|
||||
// Helper function to check for fit to page
|
||||
bool IsWebPrintScalingOptionFitToPage(const PrintMsg_Print_Params& params) {
|
||||
bool IsPrintScalingOptionFitToPage(const PrintMsg_Print_Params& params) {
|
||||
return params.print_scaling_option ==
|
||||
blink::kWebPrintScalingOptionFitToPrintableArea;
|
||||
mojom::PrintScalingOption::kFitToPrintableArea;
|
||||
}
|
||||
|
||||
mojom::PageOrientation FromBlinkPageOrientation(
|
||||
@ -258,7 +258,7 @@ void CalculatePageLayoutFromPrintParams(
|
||||
const PrintMsg_Print_Params& params,
|
||||
double scale_factor,
|
||||
mojom::PageSizeMargins* page_layout_in_points) {
|
||||
bool fit_to_page = IsWebPrintScalingOptionFitToPage(params);
|
||||
bool fit_to_page = IsPrintScalingOptionFitToPage(params);
|
||||
int dpi = GetDPI(params);
|
||||
int content_width = params.content_size.width();
|
||||
int content_height = params.content_size.height();
|
||||
@ -484,29 +484,29 @@ ScalingType ScalingTypeFromJobSettings(
|
||||
// option is disabled for initiator renderer plugin.
|
||||
//
|
||||
// In all other cases, we scale the source page to fit the printable area.
|
||||
blink::WebPrintScalingOption GetPrintScalingOption(
|
||||
mojom::PrintScalingOption GetPrintScalingOption(
|
||||
blink::WebLocalFrame* frame,
|
||||
const blink::WebNode& node,
|
||||
bool source_is_html,
|
||||
const base::DictionaryValue& job_settings,
|
||||
const PrintMsg_Print_Params& params) {
|
||||
if (params.print_to_pdf)
|
||||
return blink::kWebPrintScalingOptionSourceSize;
|
||||
return mojom::PrintScalingOption::kSourceSize;
|
||||
|
||||
if (!source_is_html) {
|
||||
ScalingType scaling_type = ScalingTypeFromJobSettings(job_settings);
|
||||
// The following conditions are ordered for an optimization that avoids
|
||||
// calling PDFShouldDisableScaling(), which has to make a call using PPAPI.
|
||||
if (scaling_type == DEFAULT || scaling_type == CUSTOM)
|
||||
return blink::kWebPrintScalingOptionNone;
|
||||
return mojom::PrintScalingOption::kNone;
|
||||
if (params.is_first_request &&
|
||||
PDFShouldDisableScaling(frame, node, params, true)) {
|
||||
return blink::kWebPrintScalingOptionNone;
|
||||
return mojom::PrintScalingOption::kNone;
|
||||
}
|
||||
if (scaling_type == FIT_TO_PAPER)
|
||||
return blink::kWebPrintScalingOptionFitToPaper;
|
||||
return mojom::PrintScalingOption::kFitToPaper;
|
||||
}
|
||||
return blink::kWebPrintScalingOptionFitToPrintableArea;
|
||||
return mojom::PrintScalingOption::kFitToPrintableArea;
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
||||
@ -862,7 +862,7 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint(
|
||||
bool source_is_pdf = IsPrintingNodeOrPdfFrame(frame, node_to_print_);
|
||||
if (!should_print_selection_only_) {
|
||||
bool fit_to_page =
|
||||
ignore_css_margins && IsWebPrintScalingOptionFitToPage(print_params);
|
||||
ignore_css_margins && IsPrintScalingOptionFitToPage(print_params);
|
||||
ComputeWebKitPrintParamsInDesiredDpi(params, source_is_pdf,
|
||||
&web_print_params_);
|
||||
frame->PrintBegin(web_print_params_, node_to_print_);
|
||||
@ -1818,7 +1818,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
{
|
||||
// PrintHostMsg_ScriptedPrint in GetPrintSettingsFromUser() will reset
|
||||
// |print_scaling_option|, so save the value here and restore it afterwards.
|
||||
blink::WebPrintScalingOption scaling_option =
|
||||
mojom::PrintScalingOption scaling_option =
|
||||
print_pages_params_->params.print_scaling_option;
|
||||
|
||||
PrintMsg_PrintPages_Params print_settings;
|
||||
@ -1831,7 +1831,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
|
||||
print_settings.params.print_scaling_option =
|
||||
print_settings.params.prefer_css_page_size
|
||||
? blink::kWebPrintScalingOptionSourceSize
|
||||
? mojom::PrintScalingOption::kSourceSize
|
||||
: scaling_option;
|
||||
SetPrintPagesParams(print_settings);
|
||||
if (print_settings.params.dpi.IsEmpty() ||
|
||||
@ -2019,7 +2019,7 @@ void PrintRenderFrameHelper::ComputePageLayoutInPointsForCss(
|
||||
double input_scale_factor = *scale_factor;
|
||||
PrintMsg_Print_Params params = CalculatePrintParamsForCss(
|
||||
frame, page_index, page_params, ignore_css_margins,
|
||||
IsWebPrintScalingOptionFitToPage(page_params), scale_factor);
|
||||
IsPrintScalingOptionFitToPage(page_params), scale_factor);
|
||||
CalculatePageLayoutFromPrintParams(params, input_scale_factor,
|
||||
page_layout_in_points);
|
||||
}
|
||||
@ -2076,8 +2076,8 @@ bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) {
|
||||
settings.pages.clear();
|
||||
|
||||
settings.params.print_scaling_option =
|
||||
fit_to_paper_size ? blink::kWebPrintScalingOptionFitToPrintableArea
|
||||
: blink::kWebPrintScalingOptionSourceSize;
|
||||
fit_to_paper_size ? mojom::PrintScalingOption::kFitToPrintableArea
|
||||
: mojom::PrintScalingOption::kSourceSize;
|
||||
|
||||
SetPrintPagesParams(settings);
|
||||
return result;
|
||||
|
@ -74,7 +74,7 @@ MockPrinter::MockPrinter()
|
||||
is_first_request_(true),
|
||||
print_to_pdf_(false),
|
||||
preview_request_id_(0),
|
||||
print_scaling_option_(blink::kWebPrintScalingOptionSourceSize),
|
||||
print_scaling_option_(printing::mojom::PrintScalingOption::kSourceSize),
|
||||
display_header_footer_(false),
|
||||
title_(base::ASCIIToUTF16("title")),
|
||||
url_(base::ASCIIToUTF16("url")),
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "printing/image.h"
|
||||
#include "third_party/blink/public/web/web_print_scaling_option.h"
|
||||
#include "printing/mojom/print.mojom.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
@ -148,7 +148,7 @@ class MockPrinter {
|
||||
|
||||
// Specifies whether to retain/crop/scale source page size to fit the
|
||||
// given printable area.
|
||||
blink::WebPrintScalingOption print_scaling_option_;
|
||||
printing::mojom::PrintScalingOption print_scaling_option_;
|
||||
|
||||
// Used for displaying headers and footers.
|
||||
bool display_header_footer_;
|
||||
|
@ -116,7 +116,6 @@
|
||||
#include "third_party/blink/public/web/web_plugin_script_forbidden_scope.h"
|
||||
#include "third_party/blink/public/web/web_print_params.h"
|
||||
#include "third_party/blink/public/web/web_print_preset_options.h"
|
||||
#include "third_party/blink/public/web/web_print_scaling_option.h"
|
||||
#include "third_party/blink/public/web/web_script_source.h"
|
||||
#include "third_party/blink/public/web/web_view.h"
|
||||
#include "third_party/khronos/GLES2/gl2.h"
|
||||
@ -174,7 +173,6 @@ using blink::WebLocalFrame;
|
||||
using blink::WebPlugin;
|
||||
using blink::WebPluginContainer;
|
||||
using blink::WebPrintParams;
|
||||
using blink::WebPrintScalingOption;
|
||||
using blink::WebString;
|
||||
using blink::WebURLError;
|
||||
using blink::WebAssociatedURLLoaderClient;
|
||||
@ -285,13 +283,13 @@ STATIC_ASSERT_MATCHING_ENUM(kMiddlePanningHorizontal,
|
||||
|
||||
#undef STATIC_ASSERT_MATCHING_ENUM
|
||||
|
||||
STATIC_ASSERT_ENUM(blink::kWebPrintScalingOptionNone,
|
||||
STATIC_ASSERT_ENUM(printing::mojom::PrintScalingOption::kNone,
|
||||
PP_PRINTSCALINGOPTION_NONE);
|
||||
STATIC_ASSERT_ENUM(blink::kWebPrintScalingOptionFitToPrintableArea,
|
||||
STATIC_ASSERT_ENUM(printing::mojom::PrintScalingOption::kFitToPrintableArea,
|
||||
PP_PRINTSCALINGOPTION_FIT_TO_PRINTABLE_AREA);
|
||||
STATIC_ASSERT_ENUM(blink::kWebPrintScalingOptionSourceSize,
|
||||
STATIC_ASSERT_ENUM(printing::mojom::PrintScalingOption::kSourceSize,
|
||||
PP_PRINTSCALINGOPTION_SOURCE_SIZE);
|
||||
STATIC_ASSERT_ENUM(blink::kWebPrintScalingOptionFitToPaper,
|
||||
STATIC_ASSERT_ENUM(printing::mojom::PrintScalingOption::kFitToPaper,
|
||||
PP_PRINTSCALINGOPTION_FIT_TO_PAPER);
|
||||
|
||||
#undef STATIC_ASSERT_ENUM
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "third_party/blink/public/web/web_plugin_params.h"
|
||||
#include "third_party/blink/public/web/web_print_params.h"
|
||||
#include "third_party/blink/public/web/web_print_preset_options.h"
|
||||
#include "third_party/blink/public/web/web_print_scaling_option.h"
|
||||
#include "ui/base/cursor/cursor.h"
|
||||
#include "ui/events/keycodes/keyboard_codes.h"
|
||||
#include "url/gurl.h"
|
||||
|
@ -25,3 +25,19 @@ struct PageSizeMargins {
|
||||
|
||||
// CSS @page page-orientation descriptor values.
|
||||
enum PageOrientation { kUpright, kRotateLeft, kRotateRight };
|
||||
|
||||
// Describes whether to reduce/enlarge/retain the print contents to fit the
|
||||
// printable area. (This is used only by plugin printing).
|
||||
enum PrintScalingOption {
|
||||
// Prints the upper left of a page without scaling. Crop the page contents
|
||||
// that don't fit on the paper.
|
||||
kNone,
|
||||
// Reduces or enlarges each page to fit the printable area of the selected
|
||||
// printer paper size.
|
||||
kFitToPrintableArea,
|
||||
// Print output page size is same as the actual source page size. Do not
|
||||
// scale/center/fit to printable area.
|
||||
kSourceSize,
|
||||
// Reduces or enlarges each page to fit the selected printer paper size.
|
||||
kFitToPaper,
|
||||
};
|
||||
|
1
third_party/blink/public/BUILD.gn
vendored
1
third_party/blink/public/BUILD.gn
vendored
@ -377,7 +377,6 @@ source_set("blink_headers") {
|
||||
"web/web_print_page_description.h",
|
||||
"web/web_print_params.h",
|
||||
"web/web_print_preset_options.h",
|
||||
"web/web_print_scaling_option.h",
|
||||
"web/web_range.h",
|
||||
"web/web_remote_frame.h",
|
||||
"web/web_remote_frame_client.h",
|
||||
|
@ -31,9 +31,9 @@
|
||||
#ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_PRINT_PARAMS_H_
|
||||
#define THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_PRINT_PARAMS_H_
|
||||
|
||||
#include "printing/mojom/print.mojom-shared.h"
|
||||
#include "third_party/blink/public/platform/web_rect.h"
|
||||
#include "third_party/blink/public/platform/web_size.h"
|
||||
#include "third_party/blink/public/web/web_print_scaling_option.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
@ -59,8 +59,8 @@ struct WebPrintParams {
|
||||
|
||||
// Specifies whether to reduce/enlarge/retain the print contents to fit the
|
||||
// printable area. (This is used only by plugin printing).
|
||||
WebPrintScalingOption print_scaling_option =
|
||||
kWebPrintScalingOptionFitToPrintableArea;
|
||||
printing::mojom::PrintScalingOption print_scaling_option =
|
||||
printing::mojom::PrintScalingOption::kFitToPrintableArea;
|
||||
|
||||
// Specifies whether printing layout needs to be applied.
|
||||
bool use_printing_layout = true;
|
||||
@ -77,7 +77,7 @@ struct WebPrintParams {
|
||||
: print_content_area(WebRect(0, 0, paper_size.width, paper_size.height)),
|
||||
printable_area(print_content_area),
|
||||
paper_size(paper_size),
|
||||
print_scaling_option(kWebPrintScalingOptionSourceSize),
|
||||
print_scaling_option(printing::mojom::PrintScalingOption::kSourceSize),
|
||||
use_printing_layout(use_printing_layout) {}
|
||||
};
|
||||
|
||||
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Google Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_PRINT_SCALING_OPTION_H_
|
||||
#define THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_PRINT_SCALING_OPTION_H_
|
||||
|
||||
namespace blink {
|
||||
|
||||
enum WebPrintScalingOption {
|
||||
kWebPrintScalingOptionNone, // Prints the upper left of a page without
|
||||
// scaling. Crop the page contents that don't fit
|
||||
// on the paper.
|
||||
kWebPrintScalingOptionFitToPrintableArea, // Reduces or enlarges each page to
|
||||
// fit the printable area of the
|
||||
// selected printer paper size.
|
||||
kWebPrintScalingOptionSourceSize, // Print output page size is same as the
|
||||
// actual source page size. Do not
|
||||
// scale/center/fit to printable area.
|
||||
kWebPrintScalingOptionFitToPaper, // Reduces or enlarges each page to fit the
|
||||
// selected printer paper size.
|
||||
kWebPrintScalingOptionLast = kWebPrintScalingOptionFitToPaper
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user