Bug 1274520 part 3 - Listen video events in system group. r=gijs
☠☠ backed out by ea60f9e94a80 ☠ ☠
authorXidorn Quan <me@upsuper.org>
Wed, 25 May 2016 09:45:56 +1000
changeset 337699 788365ddaf61746bc66479335ae72d3e566c38ec
parent 337698 6c204be833d119fa6daae408f757e6519a531046
child 337700 ea60f9e94a807a0be57df93c9716426b5651b21b
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgijs
bugs1274520
milestone49.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 1274520 part 3 - Listen video events in system group. r=gijs MozReview-Commit-ID: 4h9Oa9qMVc5
toolkit/content/widgets/videocontrols.xml
--- a/toolkit/content/widgets/videocontrols.xml
+++ b/toolkit/content/widgets/videocontrols.xml
@@ -626,18 +626,22 @@
                             // Nothing to do...
                             break;
                         default:
                             this.log("!!! event " + aEvent.type + " not handled!");
                     }
                 },
 
                 terminateEventListeners : function () {
-                    for (let event of this.videoEvents)
-                        this.video.removeEventListener(event, this, false);
+                    for (let event of this.videoEvents) {
+                        this.video.removeEventListener(event, this, {
+                            capture: true,
+                            mozSystemGroup: true
+                        });
+                    }
 
                     for (let element of this.controlListeners) {
                         element.item.removeEventListener(element.event, element.func,
                                                          { mozSystemGroup: true });
                     }
 
                     delete this.controlListeners;
 
@@ -1327,20 +1331,25 @@
                     this.fullscreenButton   = document.getAnonymousElementByAttribute(binding, "class", "fullscreenButton");
                     this.volumeForeground   = document.getAnonymousElementByAttribute(binding, "anonid", "volumeForeground");
 
                     this.isAudioOnly = (this.video instanceof HTMLAudioElement);
                     this.setupInitialState();
                     this.setupNewLoadState();
 
                     // Use the handleEvent() callback for all media events.
-                    // The "error" event listener must capture, so that it can trap error events
-                    // from the <source> children, which don't bubble.
-                    for (let event of this.videoEvents)
-                        this.video.addEventListener(event, this, (event == "error") ? true : false);
+                    // Only the "error" event listener must capture, so that it can trap error
+                    // events from <source> children, which don't bubble. But we use capture
+                    // for all events in order to simplify the event listener add/remove.
+                    for (let event of this.videoEvents) {
+                        this.video.addEventListener(event, this, {
+                            capture: true,
+                            mozSystemGroup: true
+                        });
+                    }
 
                     var self = this;
 
                     this.controlListeners = [];
 
                     // Helper function to add an event listener to the given element
                     function addListener(elem, eventName, func) {
                       let boundFunc = func.bind(self);
@@ -1666,17 +1675,17 @@
           this.randomID = 0;
           this.Utils = {
             randomID : 0,
             videoEvents : ["play",
                            "playing"],
             controlListeners: [],
             terminateEventListeners : function () {
               for (let event of this.videoEvents)
-                this.video.removeEventListener(event, this, false);
+                this.video.removeEventListener(event, this, { mozSystemGroup: true });
 
               for (let element of this.controlListeners) {
                 element.item.removeEventListener(element.event, element.func,
                                                  { mozSystemGroup: true });
               }
 
               delete this.controlListeners;
             },
@@ -1741,17 +1750,17 @@
                 let boundFunc = func.bind(self);
                 self.controlListeners.push({ item: elem, event: eventName, func: boundFunc });
                 elem.addEventListener(eventName, boundFunc, { mozSystemGroup: true });
               }
               addListener(this.clickToPlay, "click", this.clickToPlayClickHandler);
               addListener(this.video, "MozNoControlsBlockedVideo", this.blockedVideoHandler);
 
               for (let event of this.videoEvents) {
-                this.video.addEventListener(event, this, false);
+                this.video.addEventListener(event, this, { mozSystemGroup: true });
               }
 
               if (this.video.autoplay && !this.video.mozAutoplayEnabled) {
                 this.blockedVideoHandler();
               }
             }
           };
           this.Utils.init(this);