layout/html/base/src/nsPageFrame.cpp - Revision 3.80

There were 15 changes made.
Legend
   Added lines
   Changed lines
   Removed lines

layout/html/base/src/nsPageFrame.cpp,3.80
.
Disk File
Skipping to line 47. 
#include "nsIStyleSet.h"
.
#include "nsIStyleSet.h"
#include "nsIPresShell.h"
.
#include "nsIPresShell.h"
#include "nsIDeviceContext.h"
.
#include "nsIDeviceContext.h"
#include "nsReadableUtils.h"
.
#include "nsReadableUtils.h"
#include "nsIPrintPreviewContext.h"
.
#include "nsIPrintPreviewContext.h"
 
.
#include "nsIPrintContext.h"
 
.
 
#include "nsIView.h" // view flags for clipping
.
#include "nsIView.h" // view flags for clipping
#include "nsCSSRendering.h"
.
#include "nsCSSRendering.h"
 
.
 
#include "nsHTMLContainerFrame.h" // view creation
.
#include "nsHTMLContainerFrame.h" // view creation
Skipping to line 63. 
 
.
 
// Temporary
.
// Temporary
#include "nsIFontMetrics.h"
.
#include "nsIFontMetrics.h"
 
.
 
// Print Options
.
// Print Options
#include "nsIPrintOptions.h"
.
#include "nsIPrintSettings.h"
#include "nsGfxCIID.h"
.
#include "nsGfxCIID.h"
#include "nsIServiceManager.h"
.
#include "nsIServiceManager.h"
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
.
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
 
.
 
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
.
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
Skipping to line 124. 
{
.
{
  // only create a view for the area frame if we are printing the selection
.
  // only create a view for the area frame if we are printing the selection
  // (Also skip it if we are doing PrintPreview)
.
  // (Also skip it if we are doing PrintPreview)
  nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(aPresContext)
;
.
  nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(aPresContext)
;
  if (!ppContext) {
.
  if (!ppContext) {
    nsresult rv;
.
    nsCOMPtr<nsIPrintContext> prtContext = do_QueryInterface(aPresContext);
    nsCOMPtr<nsIPrintOptions> printService = do_GetService(kPrintOptionsCID, &
rv);
.
    if (prtContext) {
 
    if (NS_SUCCEEDED(rv)) {
.
      nsCOMPtr<nsIPrintSettings> printSettings;
      PRInt16 printRangeType = nsIPrintOptions::kRangeAllPages; 
.
      prtContext->GetPrintSettings(getter_AddRefs(printSettings));
      printService->GetPrintRange(&printRangeType);
.
      if (printSettings) {
      // make sure we are printing the selection
.
        PRInt16 printRangeType = nsIPrintSettings::kRangeAllPages; 
      if (printRangeType == nsIPrintOptions::kRangeSelection) {
.
        printSettings->GetPrintRange(&printRangeType);
        nsIView* view;
.
        // make sure we are printing the selection
        aChildList->GetView(aPresContext, &view);
.
        if (printRangeType == nsIPrintSettings::kRangeSelection) {
        if (view == nsnull) {
.
          nsIView* view;
          nsCOMPtr<nsIStyleContext> styleContext;
.
          aChildList->GetView(aPresContext, &view);
          aChildList->GetStyleContext(getter_AddRefs(styleContext));
.
          if (view == nsnull) {
          nsHTMLContainerFrame::CreateViewForFrame(aPresContext, aChildList,
.
            nsCOMPtr<nsIStyleContext> styleContext;
                                                   styleContext, nsnull, PR_TR
UE);
.
            aChildList->GetStyleContext(getter_AddRefs(styleContext));
 
 
 
.
            nsHTMLContainerFrame::CreateViewForFrame(aPresContext, aChildList,
 
 
.
                                                     styleContext, nsnull, PR_
TRUE);
 
.
          }
        }
.
        }
      }
.
      }
    }
.
    }
  }
.
  }
  return nsContainerFrame::SetInitialChildList(aPresContext, aListName, aChild
List);
.
  return nsContainerFrame::SetInitialChildList(aPresContext, aListName, aChild
List);
Skipping to line 378. 
 
.
 
  PRUnichar * kTitle = GetUStr("&T");
.
  PRUnichar * kTitle = GetUStr("&T");
  if (kTitle != nsnull) {
.
  if (kTitle != nsnull) {
    if (aStr.Find(kTitle) > -1) {
.
    if (aStr.Find(kTitle) > -1) {
      PRUnichar * uTitle;
.
      PRUnichar * uTitle;
      mPD->mPrintOptions->GetTitle(&uTitle);   // creates memory
.
      mPD->mPrintSettings->GetTitle(&uTitle);   // creates memory
      SubstValueForCode(aNewStr, kTitle, uTitle);
.
      SubstValueForCode(aNewStr, kTitle, uTitle);
      nsMemory::Free(uTitle);
.
      nsMemory::Free(uTitle);
      nsMemory::Free(kTitle);
.
      nsMemory::Free(kTitle);
      return;
.
      return;
    }
.
    }
Skipping to line 391. 
 
.
 
  PRUnichar * kDocURL = GetUStr("&U");
.
  PRUnichar * kDocURL = GetUStr("&U");
  if (kDocURL != nsnull) {
.
  if (kDocURL != nsnull) {
    if (aStr.Find(kDocURL) > -1) {
.
    if (aStr.Find(kDocURL) > -1) {
      PRUnichar * uDocURL;
.
      PRUnichar * uDocURL;
      mPD->mPrintOptions->GetDocURL(&uDocURL);   // creates memory
.
      mPD->mPrintSettings->GetDocURL(&uDocURL);   // creates memory
      SubstValueForCode(aNewStr, kDocURL, uDocURL);
.
      SubstValueForCode(aNewStr, kDocURL, uDocURL);
      nsMemory::Free(uDocURL);
.
      nsMemory::Free(uDocURL);
      nsMemory::Free(kDocURL);
.
      nsMemory::Free(kDocURL);
      return;
.
      return;
    }
.
    }
Skipping to line 413. 
  PRInt32 width;
.
  PRInt32 width;
  aRenderingContext.GetWidth(aStr, width);
.
  aRenderingContext.GetWidth(aStr, width);
 
.
 
  nscoord x = aRect.x;
.
  nscoord x = aRect.x;
  switch (aJust) {
.
  switch (aJust) {
    case nsIPrintOptions::kJustLeft:
.
    case nsIPrintSettings::kJustLeft:
      x += mPD->mExtraMargin.left + mPD->mHeadFooterGap;
.
      x += mPD->mExtraMargin.left + mPD->mHeadFooterGap;
      break;
.
      break;
 
.
 
    case nsIPrintOptions::kJustCenter:
.
    case nsIPrintSettings::kJustCenter:
      x += (aRect.width - width) / 2;
.
      x += (aRect.width - width) / 2;
      break;
.
      break;
 
.
 
    case nsIPrintOptions::kJustRight:
.
    case nsIPrintSettings::kJustRight:
      x += aRect.width - width - mPD->mExtraMargin.right - mPD->mHeadFooterGap
;
.
      x += aRect.width - width - mPD->mExtraMargin.right - mPD->mHeadFooterGap
;
      break;
.
      break;
  } // switch
.
  } // switch
 
.
 
  NS_ASSERTION(x >= 0, "x can't be less than zero");
.
  NS_ASSERTION(x >= 0, "x can't be less than zero");
Skipping to line 462. 
 
.
 
  if (numStrs == 0) return;
.
  if (numStrs == 0) return;
  nscoord strSpace = aRect.width / numStrs;
.
  nscoord strSpace = aRect.width / numStrs;
 
.
 
  if (!aStr1.IsEmpty()) {
.
  if (!aStr1.IsEmpty()) {
    DrawHeaderFooter(aRenderingContext, aFrame, aHeaderFooter, nsIPrintOptions
::kJustLeft, aStr1, aRect, aAscent, aHeight, strSpace);
.
    DrawHeaderFooter(aRenderingContext, aFrame, aHeaderFooter, nsIPrintSetting
s::kJustLeft, aStr1, aRect, aAscent, aHeight, strSpace);
  }
.
  }
  if (!aStr2.IsEmpty()) {
.
  if (!aStr2.IsEmpty()) {
    DrawHeaderFooter(aRenderingContext, aFrame, aHeaderFooter, nsIPrintOptions
::kJustCenter, aStr2, aRect, aAscent, aHeight, strSpace);
.
    DrawHeaderFooter(aRenderingContext, aFrame, aHeaderFooter, nsIPrintSetting
s::kJustCenter, aStr2, aRect, aAscent, aHeight, strSpace);
  }
.
  }
  if (!aStr3.IsEmpty()) {
.
  if (!aStr3.IsEmpty()) {
    DrawHeaderFooter(aRenderingContext, aFrame, aHeaderFooter, nsIPrintOptions
::kJustRight, aStr3, aRect, aAscent, aHeight, strSpace);
.
    DrawHeaderFooter(aRenderingContext, aFrame, aHeaderFooter, nsIPrintSetting
s::kJustRight, aStr3, aRect, aAscent, aHeight, strSpace);
  }
.
  }
}
.
}
 
.
 
//----------------------------------------------------------------------------
--
.
//----------------------------------------------------------------------------
--
// Draw a Header or footer text lrft,right or center justified
.
// Draw a Header or footer text lrft,right or center justified
Skipping to line 546. 
      PRINT_DEBUG_MSG2(" [%s]", s);
.
      PRINT_DEBUG_MSG2(" [%s]", s);
      nsMemory::Free(s);
.
      nsMemory::Free(s);
    }
.
    }
    char justStr[64];
.
    char justStr[64];
    switch (aJust) {
.
    switch (aJust) {
      case nsIPrintOptions::kJustLeft:strcpy(justStr, "Left");break;
.
      case nsIPrintSettings::kJustLeft:strcpy(justStr, "Left");break;
      case nsIPrintOptions::kJustCenter:strcpy(justStr, "Center");break;
.
      case nsIPrintSettings::kJustCenter:strcpy(justStr, "Center");break;
      case nsIPrintOptions::kJustRight:strcpy(justStr, "Right");break;
.
      case nsIPrintSettings::kJustRight:strcpy(justStr, "Right");break;
    } // switch
.
    } // switch
    PRINT_DEBUG_MSG2(" HF: %s ", aHeaderFooter==eHeader?"Header":"Footer");
.
    PRINT_DEBUG_MSG2(" HF: %s ", aHeaderFooter==eHeader?"Header":"Footer");
    PRINT_DEBUG_MSG2(" JST: %s ", justStr);
.
    PRINT_DEBUG_MSG2(" JST: %s ", justStr);
    PRINT_DEBUG_MSG3(" x,y: %d,%d", x, y);
.
    PRINT_DEBUG_MSG3(" x,y: %d,%d", x, y);
    PRINT_DEBUG_MSG2(" Hgt: %d \n", aHeight);
.
    PRINT_DEBUG_MSG2(" Hgt: %d \n", aHeight);
Skipping to line 633. 
  }
.
  }
#endif
.
#endif
 
.
 
  if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer && !mSupressHF) {
.
  if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer && !mSupressHF) {
    // get the current margin
.
    // get the current margin
    mPD->mPrintOptions->GetMarginInTwips(mMargin);
.
    mPD->mPrintSettings->GetMarginInTwips(mMargin);
 
.
 
    rect.SetRect(0, 0, mRect.width - mPD->mShadowSize.width, mRect.height - mP
D->mShadowSize.height);
.
    rect.SetRect(0, 0, mRect.width - mPD->mShadowSize.width, mRect.height - mP
D->mShadowSize.height);
 
.
 
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
.
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
    {
.
    {
Skipping to line 673. 
      fontMet->GetMaxAscent(ascent);
.
      fontMet->GetMaxAscent(ascent);
    }
.
    }
 
.
 
    // print document headers and footers
.
    // print document headers and footers
    PRUnichar * headers[3];
.
    PRUnichar * headers[3];
    mPD->mPrintOptions->GetHeaderStrLeft(&headers[0]);   // creates memory
.
    mPD->mPrintSettings->GetHeaderStrLeft(&headers[0]);   // creates memory
    mPD->mPrintOptions->GetHeaderStrCenter(&headers[1]); // creates memory
.
    mPD->mPrintSettings->GetHeaderStrCenter(&headers[1]); // creates memory
    mPD->mPrintOptions->GetHeaderStrRight(&headers[2]);  // creates memory
.
    mPD->mPrintSettings->GetHeaderStrRight(&headers[2]);  // creates memory
    DrawHeaderFooter(aRenderingContext, this, eHeader, nsIPrintOptions::kJustL
eft, 
.
    DrawHeaderFooter(aRenderingContext, this, eHeader, nsIPrintSettings::kJust
Left, 
                     nsAutoString(headers[0]), nsAutoString(headers[1]), nsAut
oString(headers[2]), 
.
                     nsAutoString(headers[0]), nsAutoString(headers[1]), nsAut
oString(headers[2]), 
                     rect, ascent, visibleHeight);
.
                     rect, ascent, visibleHeight);
    PRInt32 i;
.
    PRInt32 i;
    for (i=0;i<3;i++) nsMemory::Free(headers[i]);
.
    for (i=0;i<3;i++) nsMemory::Free(headers[i]);
 
.
 
Skipping to line 688. 
    mPD->mPrintOptions->GetFooterStrLeft(&footers[0]);   // creates memory
.
    mPD->mPrintSettings->GetFooterStrLeft(&footers[0]);   // creates memory
    mPD->mPrintOptions->GetFooterStrCenter(&footers[1]); // creates memory
.
    mPD->mPrintSettings->GetFooterStrCenter(&footers[1]); // creates memory
    mPD->mPrintOptions->GetFooterStrRight(&footers[2]);  // creates memory
.
    mPD->mPrintSettings->GetFooterStrRight(&footers[2]);  // creates memory
    DrawHeaderFooter(aRenderingContext, this, eFooter, nsIPrintOptions::kJustR
ight, 
.
    DrawHeaderFooter(aRenderingContext, this, eFooter, nsIPrintSettings::kJust
Right, 
                     nsAutoString(footers[0]), nsAutoString(footers[1]), nsAut
oString(footers[2]), 
.
                     nsAutoString(footers[0]), nsAutoString(footers[1]), nsAut
oString(footers[2]), 
                     rect, ascent, visibleHeight);
.
                     rect, ascent, visibleHeight);
    for (i=0;i<3;i++) nsMemory::Free(footers[i]);
.
    for (i=0;i<3;i++) nsMemory::Free(footers[i]);
 
.
 
  }
.
  }