Bug 1572379 - adjust invitation related toolbarbuttons to make default actions work again. r+a=Fallen
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Mon, 12 Aug 2019 09:59:24 +0200
changeset 35292 c850972a72351538ece8d91ed11c2f810769df3f
parent 35291 4081e478928cf08b3eecda59423387a6eefd86eb
child 35293 6e72d79d8bcc64e9db8a6e97286370c0b6614d81
push id2477
push usermozilla@jorgk.com
push dateTue, 13 Aug 2019 21:14:23 +0000
treeherdercomm-beta@436d8b620b6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1572379, 1547233
Bug 1572379 - adjust invitation related toolbarbuttons to make default actions work again. r+a=Fallen Adjustment needed due to event target being different in custom element vs xbl. Bug 1547233 converted the toolbarbutton-menu-button binding to a Custom Element. Due to this the event target is now the toolbarbuttons no longer anonymous child element. There is no id to match on now, and therefore event propagation needs to be taken care of not to get child+parent event executions.
calendar/base/content/dialogs/calendar-summary-dialog.js
calendar/base/content/dialogs/calendar-summary-dialog.xul
calendar/lightning/content/imip-bar-overlay.xul
--- a/calendar/base/content/dialogs/calendar-summary-dialog.js
+++ b/calendar/base/content/dialogs/calendar-summary-dialog.js
@@ -298,49 +298,50 @@ document.addEventListener("dialogaccept"
 /**
  * Called when closing the dialog and any changes should be thrown away.
  */
 document.addEventListener("dialogcancel", () => {
     dispose();
 });
 
 /**
- * Updates the user's partstat, sends a notification if requested and closes the
- * dialog
+ * Updates the user's participation status (PARTSTAT from see RFC5545), and
+ * send a notification if requested. Then close the dialog.
  *
- * @param {string}  aResponse  a literal of one of the response modes defined
- *                               in calIItipItem (like 'NONE')
- * @param {string}  aPartStat  (optional) a partstat as per RfC5545
+ * @param {string} aResponseMode - a literal of one of the response modes defined
+ *                                 in calIItipItem (like 'NONE')
+ * @param {string} aPartStat - participation status; a PARTSTAT value
  */
-function reply(aResponse, aPartStat=null) {
-    if (aPartStat && window.attendee) {
+function reply(aResponseMode, aPartStat) {
+    // Set participation status.
+    if (window.attendee) {
         let aclEntry = window.calendarItem.calendar.aclEntry;
         if (aclEntry) {
             let userAddresses = aclEntry.getUserAddresses({});
             if (userAddresses.length > 0 &&
                 !cal.email.attendeeMatchesAddresses(window.attendee, userAddresses)) {
                 window.attendee.setProperty("SENT-BY", "mailto:" + userAddresses[0]);
             }
         }
         window.attendee.participationStatus = aPartStat;
         updateToolbar();
     }
-    saveAndClose(aResponse);
+
+    // Send notification and close window.
+    saveAndClose(aResponseMode);
 }
 
 /**
- * Stores the event in the calendar and closes the dialog
- *
- * @param {string}  aResponse  a literal of one of the response modes defined
- *                               in calIItipItem (like 'NONE')
+ * Stores the event in the calendar, sends a notification if requested and
+ * closes the dialog.
+ * @param {string} aResponseMode - a literal of one of the response modes defined
+ *                                 in calIItipItem (like 'NONE')
  */
-function saveAndClose(aResponse="NONE") {
-    // we use NONE as default since we don't want to send out notifications if
-    // the user just updates the reminder settings
-    window.responseMode = aResponse;
+function saveAndClose(aResponseMode) {
+    window.responseMode = aResponseMode;
     document.documentElement.acceptDialog();
 }
 
 function updateToolbar() {
     if (window.readOnly) {
         document.getElementById("summary-toolbar").setAttribute("hidden", "true");
         return;
     }
--- a/calendar/base/content/dialogs/calendar-summary-dialog.xul
+++ b/calendar/base/content/dialogs/calendar-summary-dialog.xul
@@ -59,70 +59,67 @@
              toolboxid="summary-toolbox"
              class="chromeclass-toolbar"
              customizable="false"
              labelalign="end"
              defaultlabelalign="end">
       <toolbarbutton id="saveandcloseButton"
                      tooltiptext="&summary.dialog.saveclose.tooltiptext;"
                      label="&summary.dialog.saveclose.label;"
-                     oncommand="saveAndClose();"
+                     oncommand="saveAndClose('NONE');"
                      class="cal-event-toolbarbutton toolbarbutton-1 saveandcloseButton"/>
       <toolbarbutton is="toolbarbutton-menu-button" id="acceptButton"
                      type="menu-button"
                      tooltiptext="&summary.dialog.accept.tooltiptext;"
                      label="&summary.dialog.accept.label;"
-                     oncommand="if (event.target.id == this.id) { reply('AUTO', 'ACCEPTED'); }"
-                     value="ACCEPTED"
+                     oncommand="reply('AUTO', 'ACCEPTED');"
                      class="cal-event-toolbarbutton toolbarbutton-1 replyButton">
         <menupopup id="acceptDropdown">
           <menuitem id="acceptButton_Send"
                     tooltiptext="&summary.dialog.send.tooltiptext;"
                     label="&summary.dialog.send.label;"
-                    oncommand="reply('AUTO', 'ACCEPTED');"/>
+                    oncommand="reply('AUTO', 'ACCEPTED'); event.stopPropagation();"/>
           <menuitem id="acceptButton_DontSend"
                     tooltiptext="&summary.dialog.dontsend.tooltiptext;"
                     label="&summary.dialog.dontsend.label;"
-                    oncommand="reply('NONE', 'ACCEPTED');"/>
+                    oncommand="reply('NONE', 'ACCEPTED'); event.stopPropagation();"/>
         </menupopup>
       </toolbarbutton>
       <toolbarbutton is="toolbarbutton-menu-button" id="tentativeButton"
                      type="menu-button"
                      tooltiptext="&summary.dialog.tentative.tooltiptext;"
                      label="&summary.dialog.tentative.label;"
-                     oncommand="if (event.target.id == this.id) { reply('AUTO', 'TENTATIVE'); }"
-                     value="TENTATIVE"
+                     oncommand="reply('AUTO', 'TENTATIVE');"
                      class="cal-event-toolbarbutton toolbarbutton-1 replyButton">
         <menupopup id="tentativeDropdown">
           <menuitem id="tenatativeButton_Send"
                     tooltiptext="&summary.dialog.send.tooltiptext;"
                     label="&summary.dialog.send.label;"
-                    oncommand="reply('AUTO', 'TENTATIVE');"/>
+                    oncommand="reply('AUTO', 'TENTATIVE'); event.stopPropagation();"/>
           <menuitem id="tenativeButton_DontSend"
                     tooltiptext="&summary.dialog.dontsend.tooltiptext;"
                     label="&summary.dialog.dontsend.label;"
-                    oncommand="reply('NONE', 'TENTATIVE');"/>
+                    oncommand="reply('NONE', 'TENTATIVE'); event.stopPropagation();"/>
         </menupopup>
       </toolbarbutton>
       <toolbarbutton is="toolbarbutton-menu-button" id="declineButton"
                      type="menu-button"
                      tooltiptext="&summary.dialog.decline.tooltiptext;"
                      label="&summary.dialog.decline.label;"
-                     oncommand="if (event.target.id == this.id) { reply('AUTO', 'DECLINED'); }"
-                     value="DECLINED"
+                     oncommand="reply('AUTO', 'DECLINED');"
                      class="cal-event-toolbarbutton toolbarbutton-1 replyButton">
         <menupopup id="declineDropdown">
           <menuitem id="declineButton_Send"
                     tooltiptext="&summary.dialog.send.tooltiptext;"
                     label="&summary.dialog.send.label;"
-                    oncommand="reply('AUTO', 'DECLINED');"/>
+                    oncommand="reply('AUTO', 'DECLINED'); event.stopPropagation();"/>
           <menuitem id="declineButton_DontSend"
                     tooltiptext="&summary.dialog.dontsend.tooltiptext;"
                     label="&summary.dialog.dontsend.label;"
-                    oncommand="reply('NONE', 'DECLINED');"/>
+                    oncommand="reply('NONE', 'DECLINED'); event.stopPropagation();"/>
         </menupopup>
       </toolbarbutton>
     </toolbar>
   </toolbox>
 
   <hbox id="status-notifications">
     <!-- notificationbox will be added here lazily. -->
   </hbox>
--- a/calendar/lightning/content/imip-bar-overlay.xul
+++ b/calendar/lightning/content/imip-bar-overlay.xul
@@ -45,26 +45,19 @@
              -    * must be hidden by default
              -    * menuitem inside must not be hidden by default
              - simple button:
              -    * must not have a type attribute
              -    * may have menupopup/menuitem within (not displayed though)
              - dropdown only:
              -    * must have type=menu
              -    * should have a menupopup with at least one menuitem
-             - smart-dropdown:
+             - smart-dropdown (toolbarbutton-menu-button)
              -    * must have type=menu-button
              -    * should have a menupopup with at least one menuitem
-             -    * bubbling up of events from menuitems to toolbarbutton must be prevented
-             -      by adding a trailing "if (event.target.id == this.id) " to the respective
-             -      ltnImipBar.executeAction(...)
-             -    * toolbarbutton's oncommand should end with the first menuitem's oncommand
-             -      to not break automated conforming
-             -      e.g. "if (event.target.id == this.id) ltnImipBar.executeAction('ACCEPTED');"
-             -      and "ltnImipBar.executeAction('ACCEPTED');"
              //-->
           <vbox id="imip-view-toolbox" class="inline-toolbox">
             <hbox id="imip-view-toolbar">
 
               <!-- show event/invitation details -->
               <toolbarbutton id="imipDetailsButton"
                              label="&lightning.imipbar.btnDetails.label;"
                              tooltiptext="&lightning.imipbar.btnDetails.tooltiptext;"
@@ -119,186 +112,186 @@
                              class="toolbarbutton-1 msgHeaderView-button imipReconfirmButton"
                              oncommand="ltnImipBar.executeAction()"
                              hidden="true"/>
 
               <!-- accept -->
               <toolbarbutton is="toolbarbutton-menu-button" id="imipAcceptButton"
                              tooltiptext="&lightning.imipbar.btnAccept2.tooltiptext;"
                              label="&lightning.imipbar.btnAccept.label;"
-                             oncommand="if (event.target.id == this.id) { ltnImipBar.executeAction('ACCEPTED', 'AUTO'); }"
+                             oncommand="ltnImipBar.executeAction('ACCEPTED', 'AUTO');"
                              type="menu-button"
                              class="imip-button toolbarbutton-1 msgHeaderView-button imipAcceptButton"
                              hidden="true">
                 <menupopup id="imipAcceptDropdown">
                   <label id="imipAcceptButton_AcceptLabel"
                          class="imipAcceptLabel"
                          tooltiptext="&lightning.imipbar.btnAccept2.tooltiptext;"
                          value="&lightning.imipbar.btnAccept.label;"/>
                   <menuitem id="imipAcceptButton_Accept"
                             tooltiptext="&lightning.imipbar.btnSend.tooltiptext;"
                             label="&lightning.imipbar.btnSend.label;"
-                            oncommand="ltnImipBar.executeAction('ACCEPTED', 'AUTO');"/>
+                            oncommand="ltnImipBar.executeAction('ACCEPTED', 'AUTO'); event.stopPropagation();"/>
                   <menuitem id="imipAcceptButton_AcceptDontSend"
                             tooltiptext="&lightning.imipbar.btnDontSend.tooltiptext;"
                             label="&lightning.imipbar.btnDontSend.label;"
-                            oncommand="ltnImipBar.executeAction('ACCEPTED', 'NONE');"/>
+                            oncommand="ltnImipBar.executeAction('ACCEPTED', 'NONE'); event.stopPropagation();"/>
                   <separatpor flex="1" class="groove"/>
                   <label id="imipAcceptButton_TentativeLabel"
                          class="imipAcceptLabel"
                          tooltiptext="&lightning.imipbar.btnTentative2.tooltiptext;"
                          value="&lightning.imipbar.btnTentative.label;"/>
                   <menuitem id="imipAcceptButton_Tentative"
                             tooltiptext="&lightning.imipbar.btnSend.tooltiptext;"
                             label="&lightning.imipbar.btnSend.label;"
-                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'AUTO');"/>
+                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'AUTO'); event.stopPropagation();"/>
                   <menuitem id="imipAcceptButton_TentativeDontSend"
                             tooltiptext="&lightning.imipbar.btnDontSend.tooltiptext;"
                             label="&lightning.imipbar.btnDontSend.label;"
-                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'NONE');"/>
+                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'NONE'); event.stopPropagation();"/>
                   <!-- add here more menuitem as needed -->
                 </menupopup>
               </toolbarbutton>
 
               <!-- accept recurrences -->
               <toolbarbutton is="toolbarbutton-menu-button" id="imipAcceptRecurrencesButton"
                              tooltiptext="&lightning.imipbar.btnAcceptRecurrences2.tooltiptext;"
                              label="&lightning.imipbar.btnAcceptRecurrences.label;"
-                             oncommand="if (event.target.id == this.id) { ltnImipBar.executeAction('ACCEPTED', 'AUTO'); }"
+                             oncommand="ltnImipBar.executeAction('ACCEPTED', 'AUTO');"
                              type="menu-button"
                              class="imip-button toolbarbutton-1 msgHeaderView-button imipAcceptRecurrencesButton"
                              hidden="true">
                 <menupopup id="imipAcceptRecurrencesDropdown">
                   <label id="imipAcceptRecurrencesButton_AcceptLabel"
                          class="imipAcceptLabel"
                          tooltiptext="&lightning.imipbar.btnAcceptRecurrences2.tooltiptext;"
                          value="&lightning.imipbar.btnAcceptRecurrences.label;"/>
                   <menuitem id="imipAcceptRecurrencesButton_Accept"
                             tooltiptext="&lightning.imipbar.btnSendSeries.tooltiptext;"
                             label="&lightning.imipbar.btnSend.label;"
-                            oncommand="ltnImipBar.executeAction('ACCEPTED', 'AUTO');"/>
+                            oncommand="ltnImipBar.executeAction('ACCEPTED', 'AUTO'); event.stopPropagation();"/>
                   <menuitem id="imipAcceptRecurrencesButton_AcceptDontSend"
                             tooltiptext="&lightning.imipbar.btnDontSendSeries.tooltiptext;"
                             label="&lightning.imipbar.btnDontSend.label;"
-                            oncommand="ltnImipBar.executeAction('ACCEPTED', 'NONE');"/>
+                            oncommand="ltnImipBar.executeAction('ACCEPTED', 'NONE'); event.stopPropagation();"/>
                   <separatpor flex="1" class="groove"/>
                   <label id="imipAcceptRecurrencesButton_TentativeLabel"
                          class="imipAcceptLabel"
                          tooltiptext="&lightning.imipbar.btnTentativeRecurrences2.tooltiptext;"
                          value="&lightning.imipbar.btnTentativeRecurrences.label;"/>
                   <menuitem id="imipAcceptRecurrencesButton_Tentative"
                             tooltiptext="&lightning.imipbar.btnSendSeries.tooltiptext;"
                             label="&lightning.imipbar.btnSend.label;"
-                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'AUTO');"/>
+                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'AUTO'); event.stopPropagation();"/>
                   <menuitem id="imipAcceptRecurrencesButton_TentativeDontSend"
                             tooltiptext="&lightning.imipbar.btnDontSendSeries.tooltiptext;"
                             label="&lightning.imipbar.btnDontSend.label;"
-                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'NONE');"/>
+                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'NONE'); event.stopPropagation();"/>
                   <!-- add here more menuitem as needed -->
                 </menupopup>
               </toolbarbutton>
 
               <!-- tentative; should only be used, if no imipMoreButton is used and
                  - imipDeclineButton/imipAcceptButton have no visible menuitems //-->
               <toolbarbutton is="toolbarbutton-menu-button" id="imipTentativeButton"
                              label="&lightning.imipbar.btnTentative.label;"
                              tooltiptext="&lightning.imipbar.btnTentative2.tooltiptext;"
                              class="toolbarbutton-1 msgHeaderView-button imipTentativeButton"
-                             oncommand="if (event.target.id == this.id) { ltnImipBar.executeAction('TENTATIVE', 'AUTO'); }"
+                             oncommand="ltnImipBar.executeAction('TENTATIVE', 'AUTO');"
                              type="menu-button"
                              hidden="true">
                 <menupopup id="imipTentativeDropdown">
                   <menuitem id="imipTentativeButton_Tentative"
                             tooltiptext="&lightning.imipbar.btnSend.tooltiptext;"
                             label="&lightning.imipbar.btnSend.label;"
-                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'AUTO');"/>
+                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'AUTO'); event.stopPropagation();"/>
                   <menuitem id="imipTentativeButton_TentativeDontSend"
                             tooltiptext="&lightning.imipbar.btnDontSend.tooltiptext;"
                             label="&lightning.imipbar.btnDontSend.label;"
-                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'NONE');"/>
+                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'NONE'); event.stopPropagation();"/>
                   <!-- add here more menuitem as needed -->
                 </menupopup>
               </toolbarbutton>
 
               <!-- tentative recurrences; should only be used, if no imipMoreButton is used and
                  - imipDeclineRecurrencesButton/imipAcceptRecurrencesButton have no visible menuitems //-->
               <toolbarbutton is="toolbarbutton-menu-button" id="imipTentativeRecurrencesButton"
                              label="&lightning.imipbar.btnTentativeRecurrences.label;"
                              tooltiptext="&lightning.imipbar.btnTentativeRecurrences2.tooltiptext;"
                              class="toolbarbutton-1 msgHeaderView-button imipTentativeRecurrencesButton"
-                             oncommand="if (event.target.id == this.id) { ltnImipBar.executeAction('TENTATIVE', 'AUTO'); }"
+                             oncommand="ltnImipBar.executeAction('TENTATIVE', 'AUTO');"
                              type="menu-button"
                              hidden="true">
                 <menupopup id="imipTentativeRecurrencesDropdown">
                   <menuitem id="imipTentativeRecurrencesButton_Tentative"
                             tooltiptext="&lightning.imipbar.btnSendSeries.tooltiptext;"
                             label="&lightning.imipbar.btnSend.label;"
-                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'AUTO');"/>
+                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'AUTO'); event.stopPropagation();"/>
                   <menuitem id="imipTentativeRecurrencesButton_TentativeDontSend"
                             tooltiptext="&lightning.imipbar.btnDontSendSeries.tooltiptext;"
                             label="&lightning.imipbar.btnDontSend.label;"
-                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'NONE');"/>
+                            oncommand="ltnImipBar.executeAction('TENTATIVE', 'NONE'); event.stopPropagation();"/>
                   <!-- add here more menuitem as needed -->
                 </menupopup>
               </toolbarbutton>
 
               <!-- decline -->
               <toolbarbutton is="toolbarbutton-menu-button" id="imipDeclineButton"
                              tooltiptext="&lightning.imipbar.btnDecline2.tooltiptext;"
                              label="&lightning.imipbar.btnDecline.label;"
-                             oncommand="if (event.target.id == this.id) { ltnImipBar.executeAction('DECLINED', 'AUTO'); }"
+                             oncommand="ltnImipBar.executeAction('DECLINED', 'AUTO');"
                              type="menu-button"
                              class="toolbarbutton-1 msgHeaderView-button imipDeclineButton"
                              hidden="true">
                 <menupopup id="imipDeclineDropdown">
                   <menuitem id="imipDeclineButton_Decline"
                             tooltiptext="&lightning.imipbar.btnSend.tooltiptext;"
                             label="&lightning.imipbar.btnSend.label;"
-                            oncommand="ltnImipBar.executeAction('DECLINED', 'AUTO');"/>
+                            oncommand="ltnImipBar.executeAction('DECLINED', 'AUTO'); event.stopPropagation();"/>
                   <menuitem id="imipDeclineButton_DeclineDontSend"
                             tooltiptext="&lightning.imipbar.btnDontSend.tooltiptext;"
                             label="&lightning.imipbar.btnDontSend.label;"
-                            oncommand="ltnImipBar.executeAction('DECLINED', 'NONE');"/>
+                            oncommand="ltnImipBar.executeAction('DECLINED', 'NONE'); event.stopPropagation();"/>
                   <!-- add here more menuitem as needed -->
                 </menupopup>
               </toolbarbutton>
 
               <!-- decline recurrences -->
               <toolbarbutton is="toolbarbutton-menu-button" id="imipDeclineRecurrencesButton"
                              tooltiptext="&lightning.imipbar.btnDeclineRecurrences2.tooltiptext;"
                              label="&lightning.imipbar.btnDeclineRecurrences.label;"
-                             oncommand="if (event.target.id == this.id) { ltnImipBar.executeAction('DECLINED'); }"
+                             oncommand="ltnImipBar.executeAction('DECLINED');"
                              type="menu-button"
                              class="toolbarbutton-1 msgHeaderView-button imipDeclineRecurrencesButton"
                              hidden="true">
                 <menupopup id="imipDeclineRecurrencesDropdown">
                   <menuitem id="imipDeclineRecurrencesButton_DeclineAll"
                             tooltiptext="&lightning.imipbar.btnSendSeries.tooltiptext;"
                             label="&lightning.imipbar.btnSend.label;"
-                            oncommand="ltnImipBar.executeAction('DECLINED');"/>
+                            oncommand="ltnImipBar.executeAction('DECLINED'); event.stopPropagation();"/>
                   <menuitem id="imipDeclineRecurrencesButton_DeclineAllDontSend"
                             tooltiptext="&lightning.imipbar.btnDontSendSeries.tooltiptext;"
                             label="&lightning.imipbar.btnDontSend.label;"
-                            oncommand="ltnImipBar.executeAction('DECLINED', 'NONE');"/>
+                            oncommand="ltnImipBar.executeAction('DECLINED', 'NONE'); event.stopPropagation();"/>
                   <!-- add here more menuitem as needed -->
                 </menupopup>
               </toolbarbutton>
 
               <!-- more options -->
               <toolbarbutton id="imipMoreButton"
                              type="menu"
                              tooltiptext="&lightning.imipbar.btnMore.tooltiptext;"
                              label="&lightning.imipbar.btnMore.label;"
                              class="toolbarbutton-1 msgHeaderView-button imipMoreButton"
                              hidden="true">
                 <menupopup id="imipMoreDropdown">
                   <menuitem id="imipMoreButton_SaveCopy"
                             tooltiptext="&lightning.imipbar.btnSaveCopy.tooltiptext;"
                             label="&lightning.imipbar.btnSaveCopy.label;"
-                            oncommand="ltnImipBar.executeAction('X-SAVECOPY');"/>
+                            oncommand="ltnImipBar.executeAction('X-SAVECOPY'); event.stopPropagation();"/>
                   <!-- add here a menuitem as needed -->
                 </menupopup>
               </toolbarbutton>
             </hbox>
           </vbox>
         </hbox>
       </vbox>
     </vbox>