Bug 1380065 - Disable arrow-panel animations if the cosmeticAnimations pref is set to false. r?sfoster draft
authorSam Foster <sfoster@mozilla.com>
Thu, 13 Jul 2017 14:30:38 -0400
changeset 608469 1ac5bdfe98351f798cd27332e58a80fb466fabaa
parent 606958 6fec4855b5345eb63fef57089e61829b88f5f4eb
child 637314 883dd52b6f2987dcffa0b32455cff3a7974b5ac8
push id68288
push userbmo:jaws@mozilla.com
push dateThu, 13 Jul 2017 18:32:45 +0000
reviewerssfoster
bugs1380065
milestone56.0a1
Bug 1380065 - Disable arrow-panel animations if the cosmeticAnimations pref is set to false. r?sfoster I tried out the patch that you had uploaded for feedback and wasn't able to reproduce the bug where the popup would reopen when clicking on the anchor. I did however have issues with getting the animation to properly disable when changing the pref through about:config. This patch works fine for me though, and also restores the value of animate=false if it was already on the popup before opening. MozReview-Commit-ID: IvA2ySPPmeJ
toolkit/content/widgets/popup.xml
--- a/toolkit/content/widgets/popup.xml
+++ b/toolkit/content/widgets/popup.xml
@@ -384,16 +384,17 @@
         </xul:box>
         <xul:box class="panel-arrowcontent" xbl:inherits="side,align,dir,orient,pack" flex="1">
           <children/>
         </xul:box>
       </xul:vbox>
     </content>
     <implementation>
       <field name="_fadeTimer">null</field>
+      <field name="_previousAnimateAttrValue">null</field>
       <method name="sizeTo">
         <parameter name="aWidth"/>
         <parameter name="aHeight"/>
         <body>
         <![CDATA[
           this.popupBoxObject.sizeTo(aWidth, aHeight);
           if (this.state == "open") {
             this.adjustArrowPosition();
@@ -469,16 +470,24 @@
         }
         ]]>
         </body>
       </method>
     </implementation>
     <handlers>
       <handler event="popupshowing" phase="target">
       <![CDATA[
+        let animationsEnabled = Services.prefs.getBoolPref("toolkit.cosmeticAnimations.enabled");
+        if (!animationsEnabled) {
+          this._previousAnimateAttrValue = this.getAttribute("animate");
+          this.setAttribute("animate", "false");
+        } else {
+          this._previousAnimateAttrValue = null;
+        }
+
         var arrow = document.getAnonymousElementByAttribute(this, "anonid", "arrow");
         arrow.hidden = this.anchorNode == null;
         document.getAnonymousElementByAttribute(this, "anonid", "arrowbox")
                 .style.removeProperty("transform");
 
         this.adjustArrowPosition();
 
         if (this.getAttribute("animate") != "false") {
@@ -511,17 +520,20 @@
           this.setAttribute("animate", "cancel");
         }
       </handler>
       <handler event="popupshown" phase="target">
         this.setAttribute("panelopen", "true");
       </handler>
       <handler event="popuphidden" phase="target">
         this.removeAttribute("panelopen");
-        if (this.getAttribute("animate") != "false") {
+
+        if (this._previousAnimateAttrValue == "false") {
+          this.setAttribute("animate", this._previousAnimateAttrValue);
+        } else {
           this.removeAttribute("animate");
         }
       </handler>
       <handler event="popuppositioned" phase="target">
         this.adjustArrowPosition();
       </handler>
     </handlers>
   </binding>