LCOV - code coverage report
Current view: top level - layout/printing - nsPrintObject.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 52 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #include "nsPrintObject.h"
       7             : #include "nsIContentViewer.h"
       8             : #include "nsIDOMDocument.h"
       9             : #include "nsContentUtils.h" // for nsAutoScriptBlocker
      10             : #include "nsIInterfaceRequestorUtils.h"
      11             : #include "nsPIDOMWindow.h"
      12             : #include "nsGkAtoms.h"
      13             : #include "nsComponentManagerUtils.h"
      14             : #include "nsIDocShellTreeItem.h"
      15             : #include "nsIBaseWindow.h"
      16             : #include "nsIDocument.h"
      17             : 
      18             : //---------------------------------------------------
      19             : //-- nsPrintObject Class Impl
      20             : //---------------------------------------------------
      21           0 : nsPrintObject::nsPrintObject() :
      22             :   mContent(nullptr), mFrameType(eFrame), mParent(nullptr),
      23             :   mHasBeenPrinted(false), mDontPrint(true), mPrintAsIs(false),
      24             :   mInvisible(false), mDidCreateDocShell(false),
      25           0 :   mShrinkRatio(1.0), mZoomRatio(1.0)
      26             : {
      27           0 :   MOZ_COUNT_CTOR(nsPrintObject);
      28           0 : }
      29             : 
      30             : 
      31           0 : nsPrintObject::~nsPrintObject()
      32             : {
      33           0 :   MOZ_COUNT_DTOR(nsPrintObject);
      34             : 
      35           0 :   DestroyPresentation();
      36           0 :   if (mDidCreateDocShell && mDocShell) {
      37           0 :     nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(mDocShell));
      38           0 :     if (baseWin) {
      39           0 :       baseWin->Destroy();
      40             :     }
      41             :   }
      42           0 :   mDocShell = nullptr;
      43           0 :   mTreeOwner = nullptr; // mTreeOwner must be released after mDocShell;
      44           0 : }
      45             : 
      46             : //------------------------------------------------------------------
      47             : nsresult
      48           0 : nsPrintObject::Init(nsIDocShell* aDocShell, nsIDOMDocument* aDoc,
      49             :                     bool aPrintPreview)
      50             : {
      51           0 :   mPrintPreview = aPrintPreview;
      52             : 
      53           0 :   if (mPrintPreview || mParent) {
      54           0 :     mDocShell = aDocShell;
      55             :   } else {
      56           0 :     mTreeOwner = do_GetInterface(aDocShell);
      57             :     // Create a container docshell for printing.
      58           0 :     mDocShell = do_CreateInstance("@mozilla.org/docshell;1");
      59           0 :     NS_ENSURE_TRUE(mDocShell, NS_ERROR_OUT_OF_MEMORY);
      60           0 :     mDidCreateDocShell = true;
      61           0 :     mDocShell->SetItemType(aDocShell->ItemType());
      62           0 :     mDocShell->SetTreeOwner(mTreeOwner);
      63             :   }
      64           0 :   NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
      65             : 
      66             :   // Keep the document related to this docshell alive
      67           0 :   nsCOMPtr<nsIDOMDocument> dummy = do_GetInterface(mDocShell);
      68             :   mozilla::Unused << dummy;
      69             : 
      70           0 :   nsCOMPtr<nsIContentViewer> viewer;
      71           0 :   mDocShell->GetContentViewer(getter_AddRefs(viewer));
      72           0 :   NS_ENSURE_STATE(viewer);
      73             : 
      74           0 :   nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDoc);
      75           0 :   NS_ENSURE_STATE(doc);
      76             : 
      77           0 :   if (mParent) {
      78           0 :     nsCOMPtr<nsPIDOMWindowOuter> window = doc->GetWindow();
      79           0 :     if (window) {
      80           0 :       mContent = window->GetFrameElementInternal();
      81             :     }
      82           0 :     mDocument = doc;
      83           0 :     return NS_OK;
      84             :   }
      85             : 
      86           0 :   mDocument = doc->CreateStaticClone(mDocShell);
      87           0 :   nsCOMPtr<nsIDOMDocument> clonedDOMDoc = do_QueryInterface(mDocument);
      88           0 :   NS_ENSURE_STATE(clonedDOMDoc);
      89             : 
      90           0 :   viewer->SetDOMDocument(clonedDOMDoc);
      91           0 :   return NS_OK;
      92             : }
      93             : 
      94             : //------------------------------------------------------------------
      95             : // Resets PO by destroying the presentation
      96             : void
      97           0 : nsPrintObject::DestroyPresentation()
      98             : {
      99           0 :   if (mPresShell) {
     100           0 :     mPresShell->EndObservingDocument();
     101           0 :     nsAutoScriptBlocker scriptBlocker;
     102           0 :     nsCOMPtr<nsIPresShell> shell = mPresShell;
     103           0 :     mPresShell = nullptr;
     104           0 :     shell->Destroy();
     105             :   }
     106           0 :   mPresContext = nullptr;
     107           0 :   mViewManager = nullptr;
     108           0 : }
     109             : 

Generated by: LCOV version 1.13