Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / page / PrintContext.cpp
index 9ce4085..af46d6a 100644 (file)
@@ -26,7 +26,7 @@
 #include "core/rendering/RenderView.h"
 #include "platform/graphics/GraphicsContext.h"
 
-namespace WebCore {
+namespace blink {
 
 // By imaging to a width a little wider than the available pixels,
 // thin pages will be scaled down a little, matching the way they
@@ -54,7 +54,7 @@ PrintContext::~PrintContext()
         end();
 }
 
-void PrintContext::computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight, bool allowHorizontalTiling)
+void PrintContext::computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight)
 {
     m_pageRects.clear();
     outPageHeight = 0;
@@ -81,7 +81,7 @@ void PrintContext::computePageRects(const FloatRect& printRect, float headerHeig
         return;
     }
 
-    computePageRectsWithPageSizeInternal(FloatSize(pageWidth / userScaleFactor, pageHeight / userScaleFactor), allowHorizontalTiling);
+    computePageRectsWithPageSizeInternal(FloatSize(pageWidth / userScaleFactor, pageHeight / userScaleFactor), false);
 }
 
 void PrintContext::computePageRectsWithPageSize(const FloatSize& pageSizeInPixels, bool allowHorizontalTiling)
@@ -171,22 +171,6 @@ void PrintContext::begin(float width, float height)
     m_frame->setPrinting(true, minLayoutSize, originalPageSize, printingMaximumShrinkFactor / printingMinimumShrinkFactor);
 }
 
-void PrintContext::spoolPage(GraphicsContext& ctx, int pageNumber, float width)
-{
-    // FIXME: Not correct for vertical text.
-    IntRect pageRect = m_pageRects[pageNumber];
-    float scale = width / pageRect.width();
-
-    ctx.save();
-    ctx.scale(scale, scale);
-    ctx.translate(-pageRect.x(), -pageRect.y());
-    ctx.clip(pageRect);
-    m_frame->view()->paintContents(&ctx, pageRect);
-    if (ctx.supportsURLFragments())
-        outputLinkedDestinations(ctx, m_frame->document(), pageRect);
-    ctx.restore();
-}
-
 void PrintContext::end()
 {
     ASSERT(m_isPrinting);
@@ -263,8 +247,8 @@ void PrintContext::outputLinkedDestinations(GraphicsContext& graphicsContext, No
         m_linkedDestinationsValid = true;
     }
 
-    HashMap<String, Element*>::const_iterator end = m_linkedDestinations.end();
-    for (HashMap<String, Element*>::const_iterator it = m_linkedDestinations.begin(); it != end; ++it) {
+    WillBeHeapHashMap<String, RawPtrWillBeMember<Element> >::const_iterator end = m_linkedDestinations.end();
+    for (WillBeHeapHashMap<String, RawPtrWillBeMember<Element> >::const_iterator it = m_linkedDestinations.begin(); it != end; ++it) {
         RenderObject* renderer = it->value->renderer();
         if (renderer) {
             IntRect boundingBox = renderer->absoluteBoundingBoxRect();
@@ -331,52 +315,11 @@ int PrintContext::numberOfPages(LocalFrame* frame, const FloatSize& pageSizeInPi
     return printContext.pageCount();
 }
 
-void PrintContext::spoolAllPagesWithBoundaries(LocalFrame* frame, GraphicsContext& graphicsContext, const FloatSize& pageSizeInPixels)
+void PrintContext::trace(Visitor* visitor)
 {
-    if (!frame->document() || !frame->view() || !frame->document()->renderView())
-        return;
-
-    frame->document()->updateLayout();
-
-    PrintContext printContext(frame);
-    printContext.begin(pageSizeInPixels.width(), pageSizeInPixels.height());
-
-    float pageHeight;
-    printContext.computePageRects(FloatRect(FloatPoint(0, 0), pageSizeInPixels), 0, 0, 1, pageHeight);
-
-    const float pageWidth = pageSizeInPixels.width();
-    const Vector<IntRect>& pageRects = printContext.pageRects();
-    int totalHeight = pageRects.size() * (pageSizeInPixels.height() + 1) - 1;
-
-    // Fill the whole background by white.
-    graphicsContext.setFillColor(Color(255, 255, 255));
-    graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight));
-
-    graphicsContext.save();
-    graphicsContext.translate(0, totalHeight);
-    graphicsContext.scale(1, -1);
-
-    int currentHeight = 0;
-    for (size_t pageIndex = 0; pageIndex < pageRects.size(); pageIndex++) {
-        // Draw a line for a page boundary if this isn't the first page.
-        if (pageIndex > 0) {
-            graphicsContext.save();
-            graphicsContext.setStrokeColor(Color(0, 0, 255));
-            graphicsContext.setFillColor(Color(0, 0, 255));
-            graphicsContext.drawLine(IntPoint(0, currentHeight),
-                                     IntPoint(pageWidth, currentHeight));
-            graphicsContext.restore();
-        }
-
-        graphicsContext.save();
-        graphicsContext.translate(0, currentHeight);
-        printContext.spoolPage(graphicsContext, pageIndex, pageWidth);
-        graphicsContext.restore();
-
-        currentHeight += pageSizeInPixels.height() + 1;
-    }
-
-    graphicsContext.restore();
+#if ENABLE(OILPAN)
+    visitor->trace(m_linkedDestinations);
+#endif
 }
 
 }