#ifndef PrintContext_h
#define PrintContext_h
#include "wtf/Forward.h"
#include "wtf/HashMap.h"
#include "wtf/Vector.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class Element;
class LocalFrame;
class FloatRect;
class FloatSize;
class GraphicsContext;
class IntRect;
class Node;
class PrintContext {
public:
explicit PrintContext(LocalFrame*);
~PrintContext();
LocalFrame* frame() const { return m_frame; }
void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight, bool allowHorizontalTiling = false);
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; }
float computeAutomaticScaleFactor(const FloatSize& availablePaperSize);
void begin(float width, float height = 0);
void spoolPage(GraphicsContext& ctx, int pageNumber, float width);
void spoolRect(GraphicsContext& ctx, const IntRect&);
void end();
static int pageNumberForElement(Element*, const FloatSize& pageSizeInPixels);
static String pageProperty(LocalFrame* frame, const char* propertyName, int pageNumber);
static bool isPageBoxVisible(LocalFrame* frame, int pageNumber);
static String pageSizeAndMarginsInPixels(LocalFrame* frame, int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft);
static int numberOfPages(LocalFrame*, const FloatSize& pageSizeInPixels);
static void spoolAllPagesWithBoundaries(LocalFrame*, GraphicsContext&, const FloatSize& pageSizeInPixels);
protected:
void outputLinkedDestinations(GraphicsContext&, Node*, const IntRect& pageRect);
LocalFrame* m_frame;
Vector<IntRect> m_pageRects;
private:
void computePageRectsWithPageSizeInternal(const FloatSize& pageSizeInPixels, bool allowHorizontalTiling);
void collectLinkedDestinations(Node*);
bool m_isPrinting;
HashMap<String, Element*> m_linkedDestinations;
bool m_linkedDestinationsValid;
};
}
#endif