18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/* 28e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Copyright (C) 2007 Alp Toker <alp@atoker.com> 38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Copyright (C) 2007 Apple Inc. 48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This library is free software; you can redistribute it and/or 68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * modify it under the terms of the GNU Library General Public 78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * License as published by the Free Software Foundation; either 88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * version 2 of the License, or (at your option) any later version. 98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This library is distributed in the hope that it will be useful, 118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * but WITHOUT ANY WARRANTY; without even the implied warranty of 128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Library General Public License for more details. 148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * You should have received a copy of the GNU Library General Public License 168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * along with this library; see the file COPYING.LIB. If not, write to 178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Boston, MA 02110-1301, USA. 198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#ifndef PrintContext_h 228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#define PrintContext_h 238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <wtf/Vector.h> 258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectnamespace WebCore { 278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 285e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Blockclass Element; 298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectclass Frame; 308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectclass FloatRect; 315e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Blockclass FloatSize; 328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectclass GraphicsContext; 338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectclass IntRect; 348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectclass PrintContext { 368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectpublic: 378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project PrintContext(Frame*); 388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project ~PrintContext(); 398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project int pageCount() const; 415e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block const IntRect& pageRect(int pageNumber) const; 428a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block const Vector<IntRect>& pageRects() const { return m_pageRects; } 438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight); 458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // TODO: eliminate width param 478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project void begin(float width); 488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // TODO: eliminate width param 508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project void spoolPage(GraphicsContext& ctx, int pageNumber, float width); 518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project void end(); 538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 545e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block // Used by layout tests. 555e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block static int pageNumberForElement(Element*, const FloatSize& pageSizeInPixels); 568a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block static int numberOfPages(Frame*, const FloatSize& pageSizeInPixels); 575e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block 588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectprotected: 595e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block void computePageRectsWithPageSize(const FloatSize& pageSizeInPixels, float userScaleFactor); 605e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block 618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project Frame* m_frame; 628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project Vector<IntRect> m_pageRects; 638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project}; 648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} 668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 68