[unseasoned-pdf] Propagate duplex type as a printing::mojom::DuplexMode
PDFEngine currently returns the duplex type enum as a type-unsafe int, which later gets cast to a PP_PrivateDuplexMode_Dev. In preparation for use with the Unseasoned viewer, return the duplex type as a printing::mojom::DuplexMode, and then convert it to a PP_PrivateDuplexMode_Dev enum in OutOfProcessInstance. Meanwhile, renamed PDFEngine::GetDuplexType() to PDFEngine::GetDuplexMode(). Bug: 1200000 Change-Id: Idb2ab28520c4621c7df85eb99aba8e1604154946 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2961652 Commit-Queue: Daniel Hosseinian <dhoss@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/master@{#892418}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
9ba9a784d3
commit
b02c48640f
@ -172,7 +172,10 @@ if (enable_pdf) {
|
||||
|
||||
configs += [ ":strict" ]
|
||||
|
||||
public_deps = [ "//skia" ]
|
||||
public_deps = [
|
||||
"//printing/mojom",
|
||||
"//skia",
|
||||
]
|
||||
|
||||
deps = [
|
||||
":accessibility_structs",
|
||||
@ -322,6 +325,7 @@ if (enable_pdf) {
|
||||
"//pdf:buildflags",
|
||||
"//ppapi/cpp:objects",
|
||||
"//ppapi/cpp/private:internal_module",
|
||||
"//printing/mojom",
|
||||
"//skia",
|
||||
"//third_party/blink/public/common:headers",
|
||||
"//ui/base",
|
||||
|
@ -59,6 +59,7 @@
|
||||
#include "ppapi/cpp/size.h"
|
||||
#include "ppapi/cpp/var_array_buffer.h"
|
||||
#include "ppapi/cpp/var_dictionary.h"
|
||||
#include "printing/mojom/print.mojom-shared.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
#include "third_party/blink/public/common/input/web_input_event.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
@ -622,10 +623,23 @@ void OutOfProcessInstance::DidChangeFocus(bool has_focus) {
|
||||
void OutOfProcessInstance::GetPrintPresetOptionsFromDocument(
|
||||
PP_PdfPrintPresetOptions_Dev* options) {
|
||||
options->is_scaling_disabled = PP_FromBool(IsPrintScalingDisabled());
|
||||
options->duplex =
|
||||
static_cast<PP_PrivateDuplexMode_Dev>(engine()->GetDuplexType());
|
||||
options->copies = engine()->GetCopiesToPrint();
|
||||
|
||||
switch (engine()->GetDuplexMode()) {
|
||||
case printing::mojom::DuplexMode::kUnknownDuplexMode:
|
||||
options->duplex = PP_PRIVATEDUPLEXMODE_NONE;
|
||||
break;
|
||||
case printing::mojom::DuplexMode::kSimplex:
|
||||
options->duplex = PP_PRIVATEDUPLEXMODE_SIMPLEX;
|
||||
break;
|
||||
case printing::mojom::DuplexMode::kLongEdge:
|
||||
options->duplex = PP_PRIVATEDUPLEXMODE_LONG_EDGE;
|
||||
break;
|
||||
case printing::mojom::DuplexMode::kShortEdge:
|
||||
options->duplex = PP_PRIVATEDUPLEXMODE_SHORT_EDGE;
|
||||
break;
|
||||
}
|
||||
|
||||
absl::optional<gfx::Size> uniform_page_size =
|
||||
engine()->GetUniformPageSizePoints();
|
||||
options->is_page_size_uniform = PP_FromBool(uniform_page_size.has_value());
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "ppapi/cpp/completion_callback.h"
|
||||
#include "ppapi/cpp/private/pdf.h"
|
||||
#include "ppapi/cpp/url_loader.h"
|
||||
#include "printing/mojom/print.mojom-forward.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
|
||||
@ -431,7 +432,7 @@ class PDFEngine {
|
||||
// Returns number of copies to be printed.
|
||||
virtual int GetCopiesToPrint() = 0;
|
||||
// Returns the duplex setting.
|
||||
virtual int GetDuplexType() = 0;
|
||||
virtual printing::mojom::DuplexMode GetDuplexMode() = 0;
|
||||
// Returns the uniform page size of the document in points. Returns
|
||||
// `absl::nullopt` if the document has more than one page size.
|
||||
virtual absl::optional<gfx::Size> GetUniformPageSizePoints() = 0;
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "pdf/url_loader_wrapper_impl.h"
|
||||
#include "ppapi/cpp/instance.h"
|
||||
#include "ppapi/cpp/private/pdf.h"
|
||||
#include "printing/mojom/print.mojom-shared.h"
|
||||
#include "printing/units.h"
|
||||
#include "third_party/blink/public/common/input/web_input_event.h"
|
||||
#include "third_party/blink/public/common/input/web_keyboard_event.h"
|
||||
@ -2610,8 +2611,17 @@ int PDFiumEngine::GetCopiesToPrint() {
|
||||
return FPDF_VIEWERREF_GetNumCopies(doc());
|
||||
}
|
||||
|
||||
int PDFiumEngine::GetDuplexType() {
|
||||
return static_cast<int>(FPDF_VIEWERREF_GetDuplex(doc()));
|
||||
printing::mojom::DuplexMode PDFiumEngine::GetDuplexMode() {
|
||||
switch (FPDF_VIEWERREF_GetDuplex(doc())) {
|
||||
case Simplex:
|
||||
return printing::mojom::DuplexMode::kSimplex;
|
||||
case DuplexFlipShortEdge:
|
||||
return printing::mojom::DuplexMode::kShortEdge;
|
||||
case DuplexFlipLongEdge:
|
||||
return printing::mojom::DuplexMode::kLongEdge;
|
||||
default:
|
||||
return printing::mojom::DuplexMode::kUnknownDuplexMode;
|
||||
}
|
||||
}
|
||||
|
||||
absl::optional<gfx::Size> PDFiumEngine::GetUniformPageSizePoints() {
|
||||
|
@ -159,7 +159,7 @@ class PDFiumEngine : public PDFEngine,
|
||||
uint32_t text_run_count) override;
|
||||
bool GetPrintScaling() override;
|
||||
int GetCopiesToPrint() override;
|
||||
int GetDuplexType() override;
|
||||
printing::mojom::DuplexMode GetDuplexMode() override;
|
||||
absl::optional<gfx::Size> GetUniformPageSizePoints() override;
|
||||
void AppendBlankPages(size_t num_pages) override;
|
||||
void AppendPage(PDFEngine* engine, int index) override;
|
||||
|
Reference in New Issue
Block a user