OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 2 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
3 * Copyright (C) 2007 Apple Inc. | 3 * Copyright (C) 2007 Apple Inc. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "core/CoreExport.h" | 24 #include "core/CoreExport.h" |
25 #include "platform/heap/Handle.h" | 25 #include "platform/heap/Handle.h" |
26 #include "platform/wtf/Forward.h" | 26 #include "platform/wtf/Forward.h" |
27 #include "platform/wtf/HashMap.h" | 27 #include "platform/wtf/HashMap.h" |
28 #include "platform/wtf/Vector.h" | 28 #include "platform/wtf/Vector.h" |
29 #include "platform/wtf/text/WTFString.h" | 29 #include "platform/wtf/text/WTFString.h" |
30 | 30 |
31 namespace blink { | 31 namespace blink { |
32 | 32 |
33 class Element; | 33 class Element; |
34 class LocalFrame; | |
35 class FloatRect; | 34 class FloatRect; |
36 class FloatSize; | 35 class FloatSize; |
37 class GraphicsContext; | 36 class GraphicsContext; |
38 class IntRect; | 37 class IntRect; |
| 38 class LocalFrame; |
39 class Node; | 39 class Node; |
40 | 40 |
41 class CORE_EXPORT PrintContext | 41 class CORE_EXPORT PrintContext |
42 : public GarbageCollectedFinalized<PrintContext> { | 42 : public GarbageCollectedFinalized<PrintContext> { |
43 public: | 43 public: |
44 explicit PrintContext(LocalFrame*); | 44 explicit PrintContext(LocalFrame*); |
45 virtual ~PrintContext(); | 45 virtual ~PrintContext(); |
46 | 46 |
47 LocalFrame* GetFrame() const { return frame_; } | 47 LocalFrame* GetFrame() const { return frame_; } |
48 | 48 |
49 // Break up a page into rects without relayout. | 49 // Break up a page into rects without relayout. |
50 // FIXME: This means that CSS page breaks won't be on page boundary if the | 50 // FIXME: This means that CSS page breaks won't be on page boundary if the |
51 // size is different than what was passed to BeginPrintMode(). That's probably | 51 // size is different than what was passed to BeginPrintMode(). That's probably |
52 // not always desirable. | 52 // not always desirable. |
53 // FIXME: Header and footer height should be applied before layout, not after. | 53 // FIXME: Header and footer height should be applied before layout, not after. |
54 // FIXME: The printRect argument is only used to determine page aspect ratio, | 54 // FIXME: The printRect argument is only used to determine page aspect ratio, |
55 // it would be better to pass a FloatSize with page dimensions instead. | 55 // it would be better to pass a FloatSize with page dimensions instead. |
56 virtual void ComputePageRects(const FloatRect& print_rect, | 56 virtual void ComputePageRects(const FloatRect& print_rect, |
57 float header_height, | 57 float header_height, |
58 float footer_height, | 58 float footer_height, |
59 float user_scale_factor, | 59 float user_scale_factor, |
60 float& out_page_height); | 60 float& out_page_height); |
61 | 61 |
62 // Deprecated. Page size computation is already in this class, clients | 62 // Deprecated. Page size computation is already in this class, clients |
63 // shouldn't be copying it. | 63 // shouldn't be copying it. |
64 // FIXME: Everyone passes |false| for the second paramer. We should remove the | |
65 // second parameter. | |
66 virtual void ComputePageRectsWithPageSize( | 64 virtual void ComputePageRectsWithPageSize( |
67 const FloatSize& page_size_in_pixels); | 65 const FloatSize& page_size_in_pixels); |
68 | 66 |
69 // These are only valid after page rects are computed. | 67 // These are only valid after page rects are computed. |
70 size_t PageCount() const { return page_rects_.size(); } | 68 size_t PageCount() const { return page_rects_.size(); } |
71 const IntRect& PageRect(size_t page_number) const { | 69 const IntRect& PageRect(size_t page_number) const { |
72 return page_rects_[page_number]; | 70 return page_rects_[page_number]; |
73 } | 71 } |
74 const Vector<IntRect>& PageRects() const { return page_rects_; } | 72 const Vector<IntRect>& PageRects() const { return page_rects_; } |
75 | 73 |
(...skipping 19 matching lines...) Expand all Loading... |
95 int height, | 93 int height, |
96 int margin_top, | 94 int margin_top, |
97 int margin_right, | 95 int margin_right, |
98 int margin_bottom, | 96 int margin_bottom, |
99 int margin_left); | 97 int margin_left); |
100 static int NumberOfPages(LocalFrame*, const FloatSize& page_size_in_pixels); | 98 static int NumberOfPages(LocalFrame*, const FloatSize& page_size_in_pixels); |
101 | 99 |
102 DECLARE_VIRTUAL_TRACE(); | 100 DECLARE_VIRTUAL_TRACE(); |
103 | 101 |
104 protected: | 102 protected: |
| 103 friend class PrintContextTest; |
| 104 |
105 void OutputLinkedDestinations(GraphicsContext&, const IntRect& page_rect); | 105 void OutputLinkedDestinations(GraphicsContext&, const IntRect& page_rect); |
106 | 106 |
107 Member<LocalFrame> frame_; | 107 Member<LocalFrame> frame_; |
108 Vector<IntRect> page_rects_; | 108 Vector<IntRect> page_rects_; |
109 | 109 |
110 private: | 110 private: |
111 void ComputePageRectsWithPageSizeInternal( | 111 void ComputePageRectsWithPageSizeInternal( |
112 const FloatSize& page_size_in_pixels); | 112 const FloatSize& page_size_in_pixels); |
113 void CollectLinkedDestinations(Node*); | 113 void CollectLinkedDestinations(Node*); |
| 114 bool IsFrameValid() const; |
114 | 115 |
115 // Used to prevent misuses of BeginPrintMode() and EndPrintMode() (e.g., call | 116 // Used to prevent misuses of BeginPrintMode() and EndPrintMode() (e.g., call |
116 // EndPrintMode without BeginPrintMode). | 117 // EndPrintMode without BeginPrintMode). |
117 bool is_printing_; | 118 bool is_printing_; |
118 | 119 |
119 HeapHashMap<String, Member<Element>> linked_destinations_; | 120 HeapHashMap<String, Member<Element>> linked_destinations_; |
120 bool linked_destinations_valid_; | 121 bool linked_destinations_valid_; |
121 }; | 122 }; |
122 | 123 |
| 124 class ScopedPrintContext { |
| 125 STACK_ALLOCATED(); |
| 126 |
| 127 public: |
| 128 explicit ScopedPrintContext(LocalFrame*); |
| 129 ~ScopedPrintContext(); |
| 130 |
| 131 PrintContext* operator->() const { return context_.Get(); } |
| 132 |
| 133 private: |
| 134 Member<PrintContext> context_; |
| 135 |
| 136 DISALLOW_COPY_AND_ASSIGN(ScopedPrintContext); |
| 137 }; |
| 138 |
123 } // namespace blink | 139 } // namespace blink |
124 | 140 |
125 #endif | 141 #endif |
OLD | NEW |