Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: Source/core/page/PrintContext.cpp

Issue 241643006: Remove more dead code from core/ folder (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/page/PrintContext.h ('k') | Source/core/page/scrolling/ScrollingCoordinator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // This function can be called multiple times to adjust printing parameters without going back to screen mode. 164 // This function can be called multiple times to adjust printing parameters without going back to screen mode.
165 m_isPrinting = true; 165 m_isPrinting = true;
166 166
167 FloatSize originalPageSize = FloatSize(width, height); 167 FloatSize originalPageSize = FloatSize(width, height);
168 FloatSize minLayoutSize = m_frame->resizePageRectsKeepingRatio(originalPageS ize, FloatSize(width * printingMinimumShrinkFactor, height * printingMinimumShri nkFactor)); 168 FloatSize minLayoutSize = m_frame->resizePageRectsKeepingRatio(originalPageS ize, FloatSize(width * printingMinimumShrinkFactor, height * printingMinimumShri nkFactor));
169 169
170 // This changes layout, so callers need to make sure that they don't paint t o screen while in printing mode. 170 // This changes layout, so callers need to make sure that they don't paint t o screen while in printing mode.
171 m_frame->setPrinting(true, minLayoutSize, originalPageSize, printingMaximumS hrinkFactor / printingMinimumShrinkFactor); 171 m_frame->setPrinting(true, minLayoutSize, originalPageSize, printingMaximumS hrinkFactor / printingMinimumShrinkFactor);
172 } 172 }
173 173
174 float PrintContext::computeAutomaticScaleFactor(const FloatSize& availablePaperS ize)
175 {
176 if (!m_frame->view())
177 return 1;
178
179 bool useViewWidth = true;
180 if (m_frame->document() && m_frame->document()->renderView())
181 useViewWidth = m_frame->document()->renderView()->style()->isHorizontalW ritingMode();
182
183 float viewLogicalWidth = useViewWidth ? m_frame->view()->contentsWidth() : m _frame->view()->contentsHeight();
184 if (viewLogicalWidth < 1)
185 return 1;
186
187 float maxShrinkToFitScaleFactor = 1 / printingMaximumShrinkFactor;
188 float shrinkToFitScaleFactor = (useViewWidth ? availablePaperSize.width() : availablePaperSize.height()) / viewLogicalWidth;
189 return max(maxShrinkToFitScaleFactor, shrinkToFitScaleFactor);
190 }
191
192 void PrintContext::spoolPage(GraphicsContext& ctx, int pageNumber, float width) 174 void PrintContext::spoolPage(GraphicsContext& ctx, int pageNumber, float width)
193 { 175 {
194 // FIXME: Not correct for vertical text. 176 // FIXME: Not correct for vertical text.
195 IntRect pageRect = m_pageRects[pageNumber]; 177 IntRect pageRect = m_pageRects[pageNumber];
196 float scale = width / pageRect.width(); 178 float scale = width / pageRect.width();
197 179
198 ctx.save(); 180 ctx.save();
199 ctx.scale(FloatSize(scale, scale)); 181 ctx.scale(FloatSize(scale, scale));
200 ctx.translate(-pageRect.x(), -pageRect.y()); 182 ctx.translate(-pageRect.x(), -pageRect.y());
201 ctx.clip(pageRect); 183 ctx.clip(pageRect);
202 m_frame->view()->paintContents(&ctx, pageRect); 184 m_frame->view()->paintContents(&ctx, pageRect);
203 if (ctx.supportsURLFragments()) 185 if (ctx.supportsURLFragments())
204 outputLinkedDestinations(ctx, m_frame->document(), pageRect); 186 outputLinkedDestinations(ctx, m_frame->document(), pageRect);
205 ctx.restore(); 187 ctx.restore();
206 } 188 }
207 189
208 void PrintContext::spoolRect(GraphicsContext& ctx, const IntRect& rect)
209 {
210 // FIXME: Not correct for vertical text.
211 ctx.save();
212 ctx.translate(-rect.x(), -rect.y());
213 ctx.clip(rect);
214 m_frame->view()->paintContents(&ctx, rect);
215 ctx.restore();
216 }
217
218 void PrintContext::end() 190 void PrintContext::end()
219 { 191 {
220 ASSERT(m_isPrinting); 192 ASSERT(m_isPrinting);
221 m_isPrinting = false; 193 m_isPrinting = false;
222 m_frame->setPrinting(false, FloatSize(), FloatSize(), 0); 194 m_frame->setPrinting(false, FloatSize(), FloatSize(), 0);
223 m_linkedDestinations.clear(); 195 m_linkedDestinations.clear();
224 m_linkedDestinationsValid = false; 196 m_linkedDestinationsValid = false;
225 } 197 }
226 198
227 static RenderBoxModelObject* enclosingBoxModelObject(RenderObject* object) 199 static RenderBoxModelObject* enclosingBoxModelObject(RenderObject* object)
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 printContext.spoolPage(graphicsContext, pageIndex, pageWidth); 373 printContext.spoolPage(graphicsContext, pageIndex, pageWidth);
402 graphicsContext.restore(); 374 graphicsContext.restore();
403 375
404 currentHeight += pageSizeInPixels.height() + 1; 376 currentHeight += pageSizeInPixels.height() + 1;
405 } 377 }
406 378
407 graphicsContext.restore(); 379 graphicsContext.restore();
408 } 380 }
409 381
410 } 382 }
OLDNEW
« no previous file with comments | « Source/core/page/PrintContext.h ('k') | Source/core/page/scrolling/ScrollingCoordinator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698