Bug 678600: Don't add print frames options to Windows print dialog when they would be disabled anyway because there are no frames. r=roc, ui-review=faaborg
authorSteffen Wilberg <steffen.wilberg@web.de>
Sat, 24 Sep 2011 14:05:29 +0200
changeset 78816 8f064c1c1d4086e0b3fc050e9250b2208cf46425
parent 78811 8d288ef8e9d316f4953c6f84b4c8280588c4e655
child 78817 81a7f5489ebcbca01203c689ceb6c307c49a02fa
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs678600
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 678600: Don't add print frames options to Windows print dialog when they would be disabled anyway because there are no frames. r=roc, ui-review=faaborg
embedding/components/printingui/src/win/nsPrintDialogUtil.cpp
--- a/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp
+++ b/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp
@@ -545,16 +545,19 @@ static HWND CreateGroupBox(HINSTANCE    
 {
   return CreateControl("BUTTON", BS_GROUPBOX, aHInst, aHdlg, aId, aStr, aRect);
 }
 
 //--------------------------------------------------------
 // Localizes and initializes the radio buttons and group
 static void InitializeExtendedDialog(HWND hdlg, PRInt16 aHowToEnableFrameUI) 
 {
+  NS_ABORT_IF_FALSE(aHowToEnableFrameUI != nsIPrintSettings::kFrameEnableNone,
+                    "should not be called");
+
   // Localize the new controls in the print dialog
   nsCOMPtr<nsIStringBundle> strBundle;
   if (NS_SUCCEEDED(GetLocalizedBundle(PRINTDLG_PROPERTIES, getter_AddRefs(strBundle)))) {
     PRInt32 i = 0;
     while (gAllPropKeys[i].mKeyStr != NULL) {
       SetText(hdlg, gAllPropKeys[i].mKeyId, strBundle, gAllPropKeys[i].mKeyStr);
       i++;
     }
@@ -563,33 +566,23 @@ static void InitializeExtendedDialog(HWN
   // Set up radio buttons
   if (aHowToEnableFrameUI == nsIPrintSettings::kFrameEnableAll) {
     SetRadio(hdlg, rad4, PR_FALSE);  
     SetRadio(hdlg, rad5, PR_TRUE); 
     SetRadio(hdlg, rad6, PR_FALSE);
     // set default so user doesn't have to actually press on it
     gFrameSelectedRadioBtn = rad5;
 
-  } else if (aHowToEnableFrameUI == nsIPrintSettings::kFrameEnableAsIsAndEach) {
+  } else { // nsIPrintSettings::kFrameEnableAsIsAndEach
     SetRadio(hdlg, rad4, PR_FALSE);  
     SetRadio(hdlg, rad5, PR_FALSE, PR_FALSE); 
     SetRadio(hdlg, rad6, PR_TRUE);
     // set default so user doesn't have to actually press on it
     gFrameSelectedRadioBtn = rad6;
-
-
-  } else {  // nsIPrintSettings::kFrameEnableNone
-    // we are using this function to disabe the group box
-    SetRadio(hdlg, grp3, PR_FALSE, PR_FALSE); 
-    // now disable radiobuttons
-    SetRadio(hdlg, rad4, PR_FALSE, PR_FALSE); 
-    SetRadio(hdlg, rad5, PR_FALSE, PR_FALSE); 
-    SetRadio(hdlg, rad6, PR_FALSE, PR_FALSE); 
   }
-
 }
 
 
 //--------------------------------------------------------
 // Special Hook Procedure for handling the print dialog messages
 static UINT CALLBACK PrintHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) 
 {
 
@@ -600,16 +593,20 @@ static UINT CALLBACK PrintHookProc(HWND 
       SetRadioOfGroup(hdlg, id);
     }
 
   } else if (uiMsg == WM_INITDIALOG) {
     PRINTDLG * printDlg = (PRINTDLG *)lParam;
     if (printDlg == NULL) return 0L;
 
     PRInt16 howToEnableFrameUI = (PRInt16)printDlg->lCustData;
+    // don't add frame options if they would be disabled anyway
+    // because there are no frames
+    if (howToEnableFrameUI == nsIPrintSettings::kFrameEnableNone)
+      return TRUE;
 
     HINSTANCE hInst = (HINSTANCE)::GetWindowLongPtr(hdlg, GWLP_HINSTANCE);
     if (hInst == NULL) return 0L;
 
     // Start by getting the local rects of several of the controls
     // so we can calculate where the new controls are
     HWND wnd = ::GetDlgItem(hdlg, grp1);
     if (wnd == NULL) return 0L;
@@ -1101,16 +1098,21 @@ static BOOL APIENTRY PropSheetCallBack(H
     }
 
   } else if (uiMsg == WM_INITDIALOG) {
     // Create the groupbox and Radiobuttons on the "Options" Property Sheet
 
     // We temporarily borrowed the global value for initialization
     // now clear it before the dialog appears
     PRInt16 howToEnableFrameUI = gFrameSelectedRadioBtn;
+    // don't add frame options if they would be disabled anyway
+    // because there are no frames
+    if (howToEnableFrameUI == nsIPrintSettings::kFrameEnableNone)
+      return TRUE;
+
     gFrameSelectedRadioBtn     = 0;
 
     HINSTANCE hInst = (HINSTANCE)::GetWindowLongPtr(hdlg, GWLP_HINSTANCE);
     if (hInst == NULL) return 0L;
 
     // Get default font for the dialog & then its font metrics
     // we need the text height to determine the height of the radio buttons
     TEXTMETRIC metrics;