blob: 6859575eae7f8817ec8c068183485733c67c19e5 [file] [log] [blame]
K Moonbd80ce72019-07-26 19:27:501// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef PDF_DOCUMENT_LAYOUT_H_
6#define PDF_DOCUMENT_LAYOUT_H_
7
8#include "ppapi/cpp/size.h"
9
10namespace chrome_pdf {
11
12// Layout of pages within a PDF document. Pages are placed as rectangles
13// (possibly rotated) in a non-overlapping vertical sequence.
14//
15// All layout units are pixels.
16//
17// TODO(crbug.com/51472): Support multiple columns.
18class DocumentLayout final {
19 public:
20 DocumentLayout();
21
22 DocumentLayout(const DocumentLayout& other);
23 DocumentLayout& operator=(const DocumentLayout& other);
24
25 ~DocumentLayout();
26
27 // Returns an integer from 0 to 3 (inclusive), encoding the default
28 // orientation of the document's pages.
29 //
30 // A return value of 0 indicates the original page orientation, with each
31 // increment indicating clockwise rotation by an additional 90 degrees.
32 //
33 // TODO(kmoon): Return an enum (class) instead of an integer.
34 int default_page_orientation() const { return default_page_orientation_; }
35
36 // Rotates all pages 90 degrees clockwise. Does not recompute layout.
37 void RotatePagesClockwise();
38
39 // Rotates all pages 90 degrees counterclockwise. Does not recompute layout.
40 void RotatePagesCounterclockwise();
41
42 // Returns the layout's total size.
43 const pp::Size& size() const { return size_; }
44
45 // Sets the layout's total size.
46 void set_size(const pp::Size& size) { size_ = size; }
47
48 // Increases the layout's total height by |height|.
49 void EnlargeHeight(int height);
50
51 // Appends a rectangle of size |page_rect| to the layout. This will increase
52 // the layout's height by the page's height, and increase the layout's width
53 // to at least the page's width.
54 void AppendPageRect(const pp::Size& page_rect);
55
56 private:
57 // Orientations are non-negative integers modulo 4.
58 //
59 // TODO(kmoon): Doesn't match return type of default_page_orientation().
60 // Callers expect int, but internally, we want unsigned semantics. This will
61 // be cleaned up when we switch to an enum.
62 unsigned int default_page_orientation_ = 0;
63
64 // Layout's total size.
65 pp::Size size_;
66};
67
68} // namespace chrome_pdf
69
70#endif // PDF_DOCUMENT_LAYOUT_H_