Bug 1337422 - Support multiple text lines for the last stub installer checkbox label. r=agashlin a=gchang
authorMatt Howell <mhowell@mozilla.com>
Tue, 07 Feb 2017 08:25:47 -0800
changeset 376439 e5daae0b3090976f617b894ac84bf72480792771
parent 376438 e0542e71607d68aaa91e9ef615bca553fcbfe0de
child 376440 09f5aa6b8913a6ba39d23f02a3016396024e1c64
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersagashlin, gchang
bugs1337422
milestone53.0a2
Bug 1337422 - Support multiple text lines for the last stub installer checkbox label. r=agashlin a=gchang MozReview-Commit-ID: Ke3cUKqm3uk
browser/installer/windows/nsis/stub.nsi
--- a/browser/installer/windows/nsis/stub.nsi
+++ b/browser/installer/windows/nsis/stub.nsi
@@ -107,16 +107,17 @@ Var OpenedDownloadPage
 Var DownloadServerIP
 Var PostSigningData
 Var PreviousInstallDir
 Var PreviousInstallArch
 
 Var ControlHeightPX
 Var ControlRightPX
 Var ControlTopAdjustment
+Var OptionsItemWidthPX
 
 ; Uncomment the following to prevent pinging the metrics server when testing
 ; the stub installer
 ;!define STUB_DEBUG
 
 !define StubURLVersion "v7"
 
 ; Successful install exit code
@@ -929,16 +930,26 @@ Function createOptions
     ${AndIf} "$HasRequiredSpaceAvailable" == "true"
       Abort ; Skip the options page
     ${EndIf}
   ${EndIf}
 
   StrCpy $ExistingTopDir ""
   StrCpy $ControlTopAdjustment 0
 
+  ; Convert the options item width to pixels, so we can tell when a text string
+  ; exceeds this width and needs multiple lines.
+  StrCpy $2 "${OPTIONS_ITEM_WIDTH_DU}" -1
+  IntOp $2 $2 - 14 ; subtract approximate width of a checkbox
+  System::Call "*(i r2,i,i,i) p .r3"
+  System::Call "user32::MapDialogRect(p $HWNDPARENT, p r3)"
+  System::Call "*$3(i .s,i,i,i)"
+  Pop $OptionsItemWidthPX
+  System::Free $3
+
   nsDialogs::Create /NOUNLOAD 1018
   Pop $Dialog
   ; Since the text color for controls is set in this Dialog the foreground and
   ; background colors of the Dialog must also be hardcoded.
   SetCtlColors $Dialog ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
 
   ${NSD_CreateLabel} ${OPTIONS_ITEM_EDGE_DU} 25u ${OPTIONS_ITEM_WIDTH_DU} \
                      12u "$(DEST_FOLDER)"
@@ -1023,17 +1034,17 @@ Function createOptions
   ${Else}
     StrCpy $0 "$(ADD_SC_DESKTOP_QUICKLAUNCHBAR)"
   ${EndIf}
 
   ; In some locales, this string may be too long to fit on one line.
   ; In that case, we'll need to give the control two lines worth of height.
   StrCpy $1 12 ; single line height
   ${GetTextExtent} $0 $FontNormal $R1 $R2
-  ${If} $R1 > ${OPTIONS_ITEM_WIDTH_DU}
+  ${If} $R1 > $OptionsItemWidthPX
     ; Add a second line to the control height.
     IntOp $1 $1 + 12
     ; The rest of the controls will have to be lower to account for this label
     ; needing two lines worth of height.
     IntOp $ControlTopAdjustment $ControlTopAdjustment + 12
   ${EndIf}
   ${NSD_CreateCheckbox} ${OPTIONS_ITEM_EDGE_DU} 100u \
                         ${OPTIONS_ITEM_WIDTH_DU} "$1u" "$0"
@@ -1045,24 +1056,24 @@ Function createOptions
   SendMessage $CheckboxShortcuts ${WM_SETFONT} $FontNormal 0
   ${NSD_Check} $CheckboxShortcuts
 
   IntOp $0 116 + $ControlTopAdjustment
   ; In some locales, this string may be too long to fit on one line.
   ; In that case, we'll need to give the control two lines worth of height.
   StrCpy $1 12 ; single line height
   ${GetTextExtent} "$(SEND_PING)" $FontNormal $R1 $R2
-  ${If} $R1 > ${OPTIONS_ITEM_WIDTH_DU}
+  ${If} $R1 > $OptionsItemWidthPX
     ; Add a second line to the control height.
     IntOp $1 $1 + 12
     ; The rest of the controls will have to be lower to account for this label
     ; needing two lines worth of height.
     IntOp $ControlTopAdjustment $ControlTopAdjustment + 12
   ${EndIf}
-  ${NSD_CreateCheckbox} ${OPTIONS_ITEM_EDGE_DU} "$0u" ${OPTIONS_SUBITEM_WIDTH_DU} \
+  ${NSD_CreateCheckbox} ${OPTIONS_ITEM_EDGE_DU} "$0u" ${OPTIONS_ITEM_WIDTH_DU} \
                         "$1u" "$(SEND_PING)"
   Pop $CheckboxSendPing
   ; The uxtheme must be disabled on checkboxes in order to override the system
   ; font color.
   System::Call 'uxtheme::SetWindowTheme(i $CheckboxSendPing, w " ", w " ")'
   SetCtlColors $CheckboxSendPing ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
   SendMessage $CheckboxSendPing ${WM_SETFONT} $FontNormal 0
   ${NSD_Check} $CheckboxSendPing
@@ -1090,18 +1101,29 @@ Function createOptions
     ${IfNot} ${Errors}
       DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
       ; Read the registry instead of using ServicesHelper::IsInstalled so the
       ; plugin isn't included in the stub installer to lessen its size.
       ClearErrors
       ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\services\MozillaMaintenance" "ImagePath"
       ${If} ${Errors}
         IntOp $0 132 + $ControlTopAdjustment
+        ; In some locales, this string may be too long to fit on one line.
+        ; In that case, we'll need to give the control two lines worth of height.
+        StrCpy $1 12 ; single line height
+        ${GetTextExtent} "$(INSTALL_MAINT_SERVICE)" $FontNormal $R1 $R2
+        ${If} $R1 > $OptionsItemWidthPX
+          ; Add a second line to the control height.
+          IntOp $1 $1 + 12
+          ; The rest of the controls will have to be lower to account for this label
+          ; needing two lines worth of height.
+          IntOp $ControlTopAdjustment $ControlTopAdjustment + 12
+        ${EndIf}
         ${NSD_CreateCheckbox} ${OPTIONS_ITEM_EDGE_DU} "$0u" ${OPTIONS_ITEM_WIDTH_DU} \
-                              12u "$(INSTALL_MAINT_SERVICE)"
+                              "$1u" "$(INSTALL_MAINT_SERVICE)"
         Pop $CheckboxInstallMaintSvc
         System::Call 'uxtheme::SetWindowTheme(i $CheckboxInstallMaintSvc, w " ", w " ")'
         SetCtlColors $CheckboxInstallMaintSvc ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
         SendMessage $CheckboxInstallMaintSvc ${WM_SETFONT} $FontNormal 0
         ${NSD_Check} $CheckboxInstallMaintSvc
         ; Since we're adding in an optional control, remember the lower the ones
         ; that come after it.
         IntOp $ControlTopAdjustment 20 + $ControlTopAdjustment