#ifndef PrintContext_h
#define PrintContext_h
#include <wtf/Forward.h>
#include <wtf/Vector.h>
namespace WebCore {
class Element;
class Frame;
class FloatRect;
class FloatSize;
class GraphicsContext;
class IntRect;
class PrintContext {
public:
WEBCORE_EXPORT explicit PrintContext(Frame*);
WEBCORE_EXPORT ~PrintContext();
Frame* frame() const { return m_frame; }
WEBCORE_EXPORT void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight, bool allowHorizontalTiling = false);
WEBCORE_EXPORT void computePageRectsWithPageSize(const FloatSize& pageSizeInPixels, bool allowHorizontalTiling);
size_t pageCount() const { return m_pageRects.size(); }
const IntRect& pageRect(size_t pageNumber) const { return m_pageRects[pageNumber]; }
const Vector<IntRect>& pageRects() const { return m_pageRects; }
WEBCORE_EXPORT float computeAutomaticScaleFactor(const FloatSize& availablePaperSize);
WEBCORE_EXPORT void begin(float width, float height = 0);
WEBCORE_EXPORT void spoolPage(GraphicsContext& ctx, int pageNumber, float width);
WEBCORE_EXPORT void spoolRect(GraphicsContext& ctx, const IntRect&);
WEBCORE_EXPORT void end();
WEBCORE_EXPORT static int pageNumberForElement(Element*, const FloatSize& pageSizeInPixels); WEBCORE_EXPORT static String pageProperty(Frame*, const char* propertyName, int pageNumber);
WEBCORE_EXPORT static bool isPageBoxVisible(Frame*, int pageNumber);
WEBCORE_EXPORT static String pageSizeAndMarginsInPixels(Frame*, int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft);
WEBCORE_EXPORT static int numberOfPages(Frame*, const FloatSize& pageSizeInPixels);
WEBCORE_EXPORT static void spoolAllPagesWithBoundaries(Frame*, GraphicsContext&, const FloatSize& pageSizeInPixels);
protected:
Frame* m_frame;
Vector<IntRect> m_pageRects;
private:
void computePageRectsWithPageSizeInternal(const FloatSize& pageSizeInPixels, bool allowHorizontalTiling);
bool m_isPrinting;
};
}
#endif