Bug 1260480 - Remove mozNoMarginBoxes. r=dbaron
authorTobias Schneider <schneider@jancona.com>
Wed, 06 Apr 2016 09:53:00 +0200
changeset 292055 3000c58d1d8e355889bc9a4ea1c9f56bc2f2f665
parent 292054 0ed5e2650d6a8bf871154ac549d3351a137c4fa1
child 292056 0bf2e38c87feda9543d378ea151a9eed5b6370de
push id18587
push userkwierso@gmail.com
push dateThu, 07 Apr 2016 20:50:13 +0000
treeherderfx-team@dfd17abadcdf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1260480
milestone48.0a1
Bug 1260480 - Remove mozNoMarginBoxes. r=dbaron
dom/base/nsGkAtomList.h
embedding/components/printingui/ipc/PPrintingTypes.ipdlh
layout/base/nsDocumentViewer.cpp
layout/printing/nsPrintEngine.cpp
layout/printing/nsPrintEngine.h
widget/nsIPrintSettings.idl
widget/nsPrintOptionsImpl.cpp
widget/nsPrintSettingsImpl.cpp
widget/nsPrintSettingsImpl.h
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -36,17 +36,16 @@ GK_ATOM(moz, "_moz")
 GK_ATOM(mozframetype, "mozframetype")
 GK_ATOM(_moz_abspos, "_moz_activated")
 GK_ATOM(_moz_activated, "_moz_activated")
 GK_ATOM(_moz_resizing, "_moz_resizing")
 GK_ATOM(mozallowfullscreen, "mozallowfullscreen")
 GK_ATOM(moztype, "_moz-type")
 GK_ATOM(mozdirty, "_moz_dirty")
 GK_ATOM(mozdisallowselectionprint, "mozdisallowselectionprint")
-GK_ATOM(moznomarginboxes, "moznomarginboxes")
 GK_ATOM(mozdonotsend, "moz-do-not-send")
 GK_ATOM(mozeditorbogusnode, "_moz_editor_bogus_node")
 GK_ATOM(mozgeneratedcontentbefore, "_moz_generated_content_before")
 GK_ATOM(mozgeneratedcontentafter, "_moz_generated_content_after")
 GK_ATOM(mozgeneratedcontentimage, "_moz_generated_content_image")
 GK_ATOM(mozquote, "_moz_quote")
 GK_ATOM(mozsignature, "moz-signature")
 GK_ATOM(_moz_is_glyph, "-moz-is-glyph")
--- a/embedding/components/printingui/ipc/PPrintingTypes.ipdlh
+++ b/embedding/components/printingui/ipc/PPrintingTypes.ipdlh
@@ -63,17 +63,16 @@ struct PrintData {
   bool printToFile;
   nsString toFileName;
   short outputFormat;
   int32_t printPageDelay;
   int32_t resolution;
   int32_t duplex;
   bool isInitializedFromPrinter;
   bool isInitializedFromPrefs;
-  bool persistMarginBoxSettings;
   int32_t optionFlags;
 
   /* Windows-specific things */
   nsString driverName;
   nsString deviceName;
   double printableWidthInInches;
   double printableHeightInInches;
   bool isFramesetDocument;
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -3674,19 +3674,16 @@ nsDocumentViewer::Print(nsIPrintSettings
   }
   if (mPrintEngine->HasPrintCallbackCanvas()) {
     mBeforeAndAfterPrint = beforeAndAfterPrint;
   }
   dom::Element* root = mDocument->GetRootElement();
   if (root && root->HasAttr(kNameSpaceID_None, nsGkAtoms::mozdisallowselectionprint)) {
     mPrintEngine->SetDisallowSelectionPrint(true);
   }
-  if (root && root->HasAttr(kNameSpaceID_None, nsGkAtoms::moznomarginboxes)) {
-    mPrintEngine->SetNoMarginBoxes(true);
-  }
   rv = mPrintEngine->Print(aPrintSettings, aWebProgressListener);
   if (NS_FAILED(rv)) {
     OnDonePrinting();
   }
   return rv;
 }
 
 NS_IMETHODIMP
@@ -3749,20 +3746,16 @@ nsDocumentViewer::PrintPreview(nsIPrintS
   if (mPrintEngine->HasPrintCallbackCanvas()) {
     mBeforeAndAfterPrint = beforeAndAfterPrint;
   }
   dom::Element* root = doc->GetRootElement();
   if (root && root->HasAttr(kNameSpaceID_None, nsGkAtoms::mozdisallowselectionprint)) {
     PR_PL(("PrintPreview: found mozdisallowselectionprint"));
     mPrintEngine->SetDisallowSelectionPrint(true);
   }
-  if (root && root->HasAttr(kNameSpaceID_None, nsGkAtoms::moznomarginboxes)) {
-    PR_PL(("PrintPreview: found moznomarginboxes"));
-    mPrintEngine->SetNoMarginBoxes(true);
-  }
   rv = mPrintEngine->PrintPreview(aPrintSettings, aChildDOMWin, aWebProgressListener);
   mPrintPreviewZoomed = false;
   if (NS_FAILED(rv)) {
     OnDonePrinting();
   }
   return rv;
 #else
   return NS_ERROR_FAILURE;
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -222,18 +222,17 @@ nsPrintEngine::nsPrintEngine() :
   mPagePrintTimer(nullptr),
   mPageSeqFrame(nullptr),
   mPrtPreview(nullptr),
   mOldPrtPreview(nullptr),
   mDebugFile(nullptr),
   mLoadCounter(0),
   mDidLoadDataForPrinting(false),
   mIsDestroying(false),
-  mDisallowSelectionPrint(false),
-  mNoMarginBoxes(false)
+  mDisallowSelectionPrint(false)
 {
 }
 
 //-------------------------------------------------------
 nsPrintEngine::~nsPrintEngine()
 {
   Destroy(); // for insurance
 }
@@ -458,31 +457,16 @@ nsPrintEngine::DoCommonPrint(bool       
   }
 
   rv = CheckForPrinters(mPrt->mPrintSettings);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mPrt->mPrintSettings->SetIsCancelled(false);
   mPrt->mPrintSettings->GetShrinkToFit(&mPrt->mShrinkToFit);
 
-  // In the case the margin boxes are not printed store the print settings for
-  // the footer/header to be used as default print setting for follow up prints.
-  mPrt->mPrintSettings->SetPersistMarginBoxSettings(!mNoMarginBoxes);
-
-  if (mNoMarginBoxes) {
-    // Set the footer/header to blank.
-    const char16_t* emptyString = EmptyString().get();
-    mPrt->mPrintSettings->SetHeaderStrLeft(emptyString);
-    mPrt->mPrintSettings->SetHeaderStrCenter(emptyString);
-    mPrt->mPrintSettings->SetHeaderStrRight(emptyString);
-    mPrt->mPrintSettings->SetFooterStrLeft(emptyString);
-    mPrt->mPrintSettings->SetFooterStrCenter(emptyString);
-    mPrt->mPrintSettings->SetFooterStrRight(emptyString);
-  }
-
   if (aIsPrintPreview) {
     SetIsCreatingPrintPreview(true);
     SetIsPrintPreview(true);
     nsCOMPtr<nsIContentViewer> viewer =
       do_QueryInterface(mDocViewerPrint);
     if (viewer) {
       viewer->SetTextZoom(1.0f);
       viewer->SetFullZoom(1.0f);
--- a/layout/printing/nsPrintEngine.h
+++ b/layout/printing/nsPrintEngine.h
@@ -198,20 +198,16 @@ public:
     return mIsCreatingPrintPreview;
   }
 
   void SetDisallowSelectionPrint(bool aDisallowSelectionPrint)
   {
     mDisallowSelectionPrint = aDisallowSelectionPrint;
   }
 
-  void SetNoMarginBoxes(bool aNoMarginBoxes) {
-    mNoMarginBoxes = aNoMarginBoxes;
-  }
-
 protected:
   ~nsPrintEngine();
 
   nsresult CommonPrint(bool aIsPrintPreview, nsIPrintSettings* aPrintSettings,
                        nsIWebProgressListener* aWebProgressListener,
                        nsIDOMDocument* aDoc);
 
   nsresult DoCommonPrint(bool aIsPrintPreview, nsIPrintSettings* aPrintSettings,
@@ -273,17 +269,16 @@ protected:
   nsCOMPtr<nsIDocument>   mDocument;
 
   FILE* mDebugFile;
 
   int32_t mLoadCounter;
   bool mDidLoadDataForPrinting;
   bool mIsDestroying;
   bool mDisallowSelectionPrint;
-  bool mNoMarginBoxes;
 
   nsresult AfterNetworkPrint(bool aHandleError);
 
   nsresult SetRootView(nsPrintObject* aPO,
                        bool& aDoReturn,
                        bool& aDocumentIsTopLevel,
                        nsSize& aAdjSize);
   nsView* GetParentViewForRoot();
--- a/widget/nsIPrintSettings.idl
+++ b/widget/nsIPrintSettings.idl
@@ -258,22 +258,16 @@ interface nsIPrintSettings : nsISupports
   /**
    * This attribute tracks whether the PS has been initialized 
    * from prefs. If a different name is set into the "printerName" 
    * attribute than the one it was initialized with the PS
    * will then get intialized from prefs again.
    */
   attribute boolean isInitializedFromPrefs;
 
-  /**
-   * This attribute tracks if the settings made on the margin box is
-   * stored in the prefs or not.
-   */
-  attribute boolean persistMarginBoxSettings;
-
   /* C++ Helper Functions */
   [noscript] void SetMarginInTwips(in nsNativeIntMarginRef aMargin);
   [noscript] void SetEdgeInTwips(in nsNativeIntMarginRef aEdge);
   /* Purposely made this an "in" arg */
   [noscript] void GetMarginInTwips(in nsNativeIntMarginRef aMargin);
   [noscript] void GetEdgeInTwips(in nsNativeIntMarginRef aEdge);
 
   /**
--- a/widget/nsPrintOptionsImpl.cpp
+++ b/widget/nsPrintOptionsImpl.cpp
@@ -197,17 +197,16 @@ nsPrintOptions::SerializeToPrintData(nsI
   data->toFileName() = toFileName;
 
   aSettings->GetOutputFormat(&data->outputFormat());
   aSettings->GetPrintPageDelay(&data->printPageDelay());
   aSettings->GetResolution(&data->resolution());
   aSettings->GetDuplex(&data->duplex());
   aSettings->GetIsInitializedFromPrinter(&data->isInitializedFromPrinter());
   aSettings->GetIsInitializedFromPrefs(&data->isInitializedFromPrefs());
-  aSettings->GetPersistMarginBoxSettings(&data->persistMarginBoxSettings());
 
   aSettings->GetPrintOptionsBits(&data->optionFlags());
 
   // Initialize the platform-specific values that don't
   // default-initialize, so that we don't send uninitialized data over
   // IPC (which leads to valgrind warnings, and, for bools, fatal
   // assertions).
   // data->driverName() default-initializes
@@ -309,17 +308,16 @@ nsPrintOptions::DeserializeToPrintSettin
   settings->SetToFileName(data.toFileName().get());
 
   settings->SetOutputFormat(data.outputFormat());
   settings->SetPrintPageDelay(data.printPageDelay());
   settings->SetResolution(data.resolution());
   settings->SetDuplex(data.duplex());
   settings->SetIsInitializedFromPrinter(data.isInitializedFromPrinter());
   settings->SetIsInitializedFromPrefs(data.isInitializedFromPrefs());
-  settings->SetPersistMarginBoxSettings(data.persistMarginBoxSettings());
 
   settings->SetPrintOptionsBits(data.optionFlags());
 
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
@@ -707,19 +705,16 @@ nsPrintOptions::ReadPrefs(nsIPrintSettin
  *  @update 1/12/01 rods
  */
 nsresult 
 nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName,
                            uint32_t aFlags)
 {
   NS_ENSURE_ARG_POINTER(aPS);
 
-  bool persistMarginBoxSettings;
-  aPS->GetPersistMarginBoxSettings(&persistMarginBoxSettings);
-
   nsIntMargin margin;
   if (aFlags & nsIPrintSettings::kInitSaveMargins) {
     if (NS_SUCCEEDED(aPS->GetMarginInTwips(margin))) {
       WriteInchesFromTwipsPref(GetPrefName(kMarginTop, aPrinterName),
                                margin.top);
       DUMP_INT(kWriteStr, kMarginTop, margin.top);
       WriteInchesFromTwipsPref(GetPrefName(kMarginLeft, aPrinterName),
                                margin.left);
@@ -810,63 +805,61 @@ nsPrintOptions::WritePrefs(nsIPrintSetti
   if (aFlags & nsIPrintSettings::kInitSaveOddEvenPages) {
     if (NS_SUCCEEDED(aPS->GetPrintOptions(nsIPrintSettings::kPrintOddPages,
                                           &b))) {
           DUMP_BOOL(kWriteStr, kPrintOddPages, b);
           Preferences::SetBool(GetPrefName(kPrintOddPages, aPrinterName), b);
         }
   }
 
-  if (persistMarginBoxSettings) {
-    if (aFlags & nsIPrintSettings::kInitSaveHeaderLeft) {
-      if (NS_SUCCEEDED(aPS->GetHeaderStrLeft(&uStr))) {
-        DUMP_STR(kWriteStr, kPrintHeaderStrLeft, uStr);
-        Preferences::SetString(GetPrefName(kPrintHeaderStrLeft, aPrinterName),
-                               uStr);
-      }
+  if (aFlags & nsIPrintSettings::kInitSaveHeaderLeft) {
+    if (NS_SUCCEEDED(aPS->GetHeaderStrLeft(&uStr))) {
+      DUMP_STR(kWriteStr, kPrintHeaderStrLeft, uStr);
+      Preferences::SetString(GetPrefName(kPrintHeaderStrLeft, aPrinterName),
+                             uStr);
     }
+  }
 
-    if (aFlags & nsIPrintSettings::kInitSaveHeaderCenter) {
-      if (NS_SUCCEEDED(aPS->GetHeaderStrCenter(&uStr))) {
-        DUMP_STR(kWriteStr, kPrintHeaderStrCenter, uStr);
-        Preferences::SetString(GetPrefName(kPrintHeaderStrCenter, aPrinterName),
-                               uStr);
-      }
+  if (aFlags & nsIPrintSettings::kInitSaveHeaderCenter) {
+    if (NS_SUCCEEDED(aPS->GetHeaderStrCenter(&uStr))) {
+      DUMP_STR(kWriteStr, kPrintHeaderStrCenter, uStr);
+      Preferences::SetString(GetPrefName(kPrintHeaderStrCenter, aPrinterName),
+                             uStr);
     }
+  }
 
-    if (aFlags & nsIPrintSettings::kInitSaveHeaderRight) {
-      if (NS_SUCCEEDED(aPS->GetHeaderStrRight(&uStr))) {
-        DUMP_STR(kWriteStr, kPrintHeaderStrRight, uStr);
-        Preferences::SetString(GetPrefName(kPrintHeaderStrRight, aPrinterName),
-                               uStr);
-      }
+  if (aFlags & nsIPrintSettings::kInitSaveHeaderRight) {
+    if (NS_SUCCEEDED(aPS->GetHeaderStrRight(&uStr))) {
+      DUMP_STR(kWriteStr, kPrintHeaderStrRight, uStr);
+      Preferences::SetString(GetPrefName(kPrintHeaderStrRight, aPrinterName),
+                             uStr);
     }
+  }
 
-    if (aFlags & nsIPrintSettings::kInitSaveFooterLeft) {
-      if (NS_SUCCEEDED(aPS->GetFooterStrLeft(&uStr))) {
-        DUMP_STR(kWriteStr, kPrintFooterStrLeft, uStr);
-        Preferences::SetString(GetPrefName(kPrintFooterStrLeft, aPrinterName),
-                               uStr);
-      }
+  if (aFlags & nsIPrintSettings::kInitSaveFooterLeft) {
+    if (NS_SUCCEEDED(aPS->GetFooterStrLeft(&uStr))) {
+      DUMP_STR(kWriteStr, kPrintFooterStrLeft, uStr);
+      Preferences::SetString(GetPrefName(kPrintFooterStrLeft, aPrinterName),
+                             uStr);
     }
+  }
 
-    if (aFlags & nsIPrintSettings::kInitSaveFooterCenter) {
-      if (NS_SUCCEEDED(aPS->GetFooterStrCenter(&uStr))) {
-        DUMP_STR(kWriteStr, kPrintFooterStrCenter, uStr);
-        Preferences::SetString(GetPrefName(kPrintFooterStrCenter, aPrinterName),
-                               uStr);
-      }
+  if (aFlags & nsIPrintSettings::kInitSaveFooterCenter) {
+    if (NS_SUCCEEDED(aPS->GetFooterStrCenter(&uStr))) {
+      DUMP_STR(kWriteStr, kPrintFooterStrCenter, uStr);
+      Preferences::SetString(GetPrefName(kPrintFooterStrCenter, aPrinterName),
+                             uStr);
     }
+  }
 
-    if (aFlags & nsIPrintSettings::kInitSaveFooterRight) {
-      if (NS_SUCCEEDED(aPS->GetFooterStrRight(&uStr))) {
-        DUMP_STR(kWriteStr, kPrintFooterStrRight, uStr);
-        Preferences::SetString(GetPrefName(kPrintFooterStrRight, aPrinterName),
-                               uStr);
-      }
+  if (aFlags & nsIPrintSettings::kInitSaveFooterRight) {
+    if (NS_SUCCEEDED(aPS->GetFooterStrRight(&uStr))) {
+      DUMP_STR(kWriteStr, kPrintFooterStrRight, uStr);
+      Preferences::SetString(GetPrefName(kPrintFooterStrRight, aPrinterName),
+                             uStr);
     }
   }
 
   if (aFlags & nsIPrintSettings::kInitSaveBGColors) {
     if (NS_SUCCEEDED(aPS->GetPrintBGColors(&b))) {
       DUMP_BOOL(kWriteStr, kPrintBGColors, b);
       Preferences::SetBool(GetPrefName(kPrintBGColors, aPrinterName), b);
     }
--- a/widget/nsPrintSettingsImpl.cpp
+++ b/widget/nsPrintSettingsImpl.cpp
@@ -39,18 +39,17 @@ nsPrintSettings::nsPrintSettings() :
   mPaperSizeUnit(kPaperSizeInches),
   mPrintReversed(false),
   mPrintInColor(true),
   mOrientation(kPortraitOrientation),
   mNumCopies(1),
   mPrintToFile(false),
   mOutputFormat(kOutputFormatNative),
   mIsInitedFromPrinter(false),
-  mIsInitedFromPrefs(false),
-  mPersistMarginBoxSettings(true)
+  mIsInitedFromPrefs(false)
 {
 
   /* member initializers and constructor code */
   int32_t marginWidth = NS_INCHES_TO_INT_TWIPS(DEFAULT_MARGIN_WIDTH);
   mMargin.SizeTo(marginWidth, marginWidth, marginWidth, marginWidth);
   mEdge.SizeTo(0, 0, 0, 0);
   mUnwriteableMargin.SizeTo(0,0,0,0);
 
@@ -296,28 +295,16 @@ NS_IMETHODIMP nsPrintSettings::GetIsInit
   return NS_OK;
 }
 NS_IMETHODIMP nsPrintSettings::SetIsInitializedFromPrefs(bool aInitializedFromPrefs)
 {
   mIsInitedFromPrefs = (bool)aInitializedFromPrefs;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsPrintSettings::GetPersistMarginBoxSettings(bool *aPersistMarginBoxSettings)
-{
-  NS_ENSURE_ARG_POINTER(aPersistMarginBoxSettings);
-  *aPersistMarginBoxSettings = mPersistMarginBoxSettings;
-  return NS_OK;
-}
-NS_IMETHODIMP nsPrintSettings::SetPersistMarginBoxSettings(bool aPersistMarginBoxSettings)
-{
-  mPersistMarginBoxSettings = aPersistMarginBoxSettings;
-  return NS_OK;
-}
-
 NS_IMETHODIMP nsPrintSettings::GetMarginTop(double *aMarginTop)
 {
   NS_ENSURE_ARG_POINTER(aMarginTop);
   *aMarginTop = NS_TWIPS_TO_INCHES(mMargin.top);
   return NS_OK;
 }
 NS_IMETHODIMP nsPrintSettings::SetMarginTop(double aMarginTop)
 {
--- a/widget/nsPrintSettingsImpl.h
+++ b/widget/nsPrintSettingsImpl.h
@@ -92,12 +92,11 @@ protected:
   int32_t       mDuplex;
   int32_t       mNumCopies;
   nsXPIDLString mPrinter;
   bool          mPrintToFile;
   nsString      mToFileName;
   int16_t       mOutputFormat;
   bool          mIsInitedFromPrinter;
   bool          mIsInitedFromPrefs;
-  bool          mPersistMarginBoxSettings;
 };
 
 #endif /* nsPrintSettings_h__ */