[go: nahoru, domu]

Add Document::GetSingleViewLayout() and draw_utils::GetRectForSingleView().

Currently the generation of the single-view layout in PDFiumEngine is
untested. To make the generation of these layouts testable the following
helper functions are being added:

  draw_utils::GetRectForSingleView(), given the current document size
  and a page's size, returns a page rect formatted for single-view.

  Document::GetSingleViewLayout(), given a vector of page sizes,
  returns a vector of page rects formatted for single-view and updates
  the size of the document.

Bug: 51472
Change-Id: Ie9e746cc4fedda551ccfb22aab4b3b64822c6b89
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1739666
Commit-Queue: Jeremy Chinsen <chinsenj@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#684616}
diff --git a/pdf/document_layout.h b/pdf/document_layout.h
index b9155dda..a558fbb7 100644
--- a/pdf/document_layout.h
+++ b/pdf/document_layout.h
@@ -75,6 +75,13 @@
   // Sets the layout's total size.
   void set_size(const pp::Size& size) { size_ = size; }
 
+  // Given |page_sizes| and the layout's width set to the max width of the
+  // document's pages, return pp::Rects that represent |page_sizes|
+  // formatted for single view and update the layout's size to the size of the
+  // new single view layout.
+  std::vector<pp::Rect> GetSingleViewLayout(
+      const std::vector<pp::Size>& page_sizes);
+
   // Given |page_sizes| and the layout's width is set to the max page width of
   // the document's pages, return pp::Rects that represent |page_sizes|
   // formatted for two-up view and update the layout's size to the size of the