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, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
21 #include "core/page/PrintContext.h" | 21 #include "core/page/PrintContext.h" |
22 | 22 |
23 #include "core/frame/FrameView.h" | 23 #include "core/frame/FrameView.h" |
24 #include "core/frame/LocalFrame.h" | 24 #include "core/frame/LocalFrame.h" |
25 #include "core/layout/LayoutView.h" | 25 #include "core/layout/LayoutView.h" |
26 #include "platform/graphics/GraphicsContext.h" | 26 #include "platform/graphics/GraphicsContext.h" |
27 | 27 |
28 namespace blink { | 28 namespace blink { |
29 | 29 |
30 // By shrinking to a width of 75% (1.333f) we will render the correct physical | 30 // By imaging to a width a little wider than the available pixels, |
31 // dimensions in paged media (i.e. cm, pt,). The shrinkage used | 31 // thin pages will be scaled down a little, matching the way they |
32 // to be 80% (1.25f) to match other browsers - they have since moved on. | 32 // print in IE and Camino. This lets them use fewer sheets than they |
| 33 // would otherwise, which is presumably why other browsers do this. |
33 // Wide pages will be scaled down more than this. | 34 // Wide pages will be scaled down more than this. |
34 const float printingMinimumShrinkFactor = 1.333f; | 35 const float printingMinimumShrinkFactor = 1.25f; |
35 | 36 |
36 // This number determines how small we are willing to reduce the page content | 37 // This number determines how small we are willing to reduce the page content |
37 // in order to accommodate the widest line. If the page would have to be | 38 // in order to accommodate the widest line. If the page would have to be |
38 // reduced smaller to make the widest line fit, we just clip instead (this | 39 // reduced smaller to make the widest line fit, we just clip instead (this |
39 // behavior matches MacIE and Mozilla, at least). | 40 // behavior matches MacIE and Mozilla, at least) |
40 // TODO(rhogan): Decide if this quirk is still required. | |
41 const float printingMaximumShrinkFactor = 2; | 41 const float printingMaximumShrinkFactor = 2; |
42 | 42 |
43 PrintContext::PrintContext(LocalFrame* frame) | 43 PrintContext::PrintContext(LocalFrame* frame) |
44 : m_frame(frame) | 44 : m_frame(frame) |
45 , m_isPrinting(false) | 45 , m_isPrinting(false) |
46 , m_linkedDestinationsValid(false) | 46 , m_linkedDestinationsValid(false) |
47 { | 47 { |
48 } | 48 } |
49 | 49 |
50 PrintContext::~PrintContext() | 50 PrintContext::~PrintContext() |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSiz
eInPixels) | 92 void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSiz
eInPixels) |
93 { | 93 { |
94 if (!m_frame->document() || !m_frame->view() || !m_frame->document()->layout
View()) | 94 if (!m_frame->document() || !m_frame->view() || !m_frame->document()->layout
View()) |
95 return; | 95 return; |
96 | 96 |
97 LayoutView* view = m_frame->document()->layoutView(); | 97 LayoutView* view = m_frame->document()->layoutView(); |
98 | 98 |
99 IntRect docRect = view->documentRect(); | 99 IntRect docRect = view->documentRect(); |
100 | 100 |
101 int pageWidth = pageSizeInPixels.width(); | 101 int pageWidth = pageSizeInPixels.width(); |
102 // We scaled with floating point arithmetic and need to ensure results like
13329.99 | 102 int pageHeight = pageSizeInPixels.height(); |
103 // are treated as 13330 so that we don't mistakenly assign an extra page for
the | |
104 // stray pixel. | |
105 int pageHeight = pageSizeInPixels.height() + LayoutUnit::epsilon(); | |
106 | 103 |
107 bool isHorizontal = view->style()->isHorizontalWritingMode(); | 104 bool isHorizontal = view->style()->isHorizontalWritingMode(); |
108 | 105 |
109 int docLogicalHeight = isHorizontal ? docRect.height() : docRect.width(); | 106 int docLogicalHeight = isHorizontal ? docRect.height() : docRect.width(); |
110 int pageLogicalHeight = isHorizontal ? pageHeight : pageWidth; | 107 int pageLogicalHeight = isHorizontal ? pageHeight : pageWidth; |
111 int pageLogicalWidth = isHorizontal ? pageWidth : pageHeight; | 108 int pageLogicalWidth = isHorizontal ? pageWidth : pageHeight; |
112 | 109 |
113 int inlineDirectionStart; | 110 int inlineDirectionStart; |
114 int inlineDirectionEnd; | 111 int inlineDirectionEnd; |
115 int blockDirectionStart; | 112 int blockDirectionStart; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 314 |
318 DEFINE_TRACE(PrintContext) | 315 DEFINE_TRACE(PrintContext) |
319 { | 316 { |
320 #if ENABLE(OILPAN) | 317 #if ENABLE(OILPAN) |
321 visitor->trace(m_frame); | 318 visitor->trace(m_frame); |
322 visitor->trace(m_linkedDestinations); | 319 visitor->trace(m_linkedDestinations); |
323 #endif | 320 #endif |
324 } | 321 } |
325 | 322 |
326 } // namespace blink | 323 } // namespace blink |
OLD | NEW |