Serialize LayoutOptions to DocumentDimensions
Add ToVar() and FromVar() methods to DocumentLayout::Options, allowing
serialization to and from a pp::Var. This serialization is then used to
pass layout options (such as default page orientation) to and from
JavaScript (via the "documentDimensions" message).
pp::Var is non-trivial to unit test, due to dependencies on the
browser's PPAPI interfaces. Instead, this change adds 2 browser_tests,
PDFExtensionTest.Layout3 and PDFExtensionTest.Layout4. Each runs the
same layout_test.js suite over two slightly different test PDF files,
test-layout3.pdf (with 3 pages) and test-layout4.pdf (with 4 pages).
There's currently no coverage of deserialization, as we're not doing
anything with the layout options sent back from JavaScript yet. We'll
start using FromVar() in an upcoming CL (such as crrev.com/c/1747170).
Bug: 885110
Change-Id: I8c93b74062576ee07445070e0b4a82f0f861a82e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1830398
Reviewed-by: Lei Zhang <[email protected]>
Commit-Queue: K Moon <[email protected]>
Auto-Submit: K Moon <[email protected]>
Cr-Commit-Position: refs/heads/master@{#702324}
diff --git a/pdf/document_layout.h b/pdf/document_layout.h
index 13cc51b..f67ae58 100644
--- a/pdf/document_layout.h
+++ b/pdf/document_layout.h
@@ -14,6 +14,10 @@
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/size.h"
+namespace pp {
+class Var;
+} // namespace pp
+
namespace chrome_pdf {
// Layout of pages within a PDF document. Pages are placed as rectangles
@@ -35,6 +39,12 @@
~Options();
+ // Serializes layout options to a pp::Var.
+ pp::Var ToVar() const;
+
+ // Deserializes layout options from a pp::Var.
+ void FromVar(const pp::Var& var);
+
PageOrientation default_page_orientation() const {
return default_page_orientation_;
}