Bug 693014 - Respect event.preventDefault() for click events on <video>. r=dolske
authorDão Gottwald <dao@mozilla.com>
Fri, 06 Jan 2012 11:37:11 +0100
changeset 85147 3f4c460bb95ef86da937ffdbdcb03c470157b11f
parent 85146 5fbe5ee99a271022d28707068506b858f94c5483
child 85148 f97fcb931525f63f135fc23bf08d12c52e6da1fe
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs693014
milestone12.0a1
Bug 693014 - Respect event.preventDefault() for click events on <video>. r=dolske
toolkit/content/widgets/videocontrols.xml
--- a/toolkit/content/widgets/videocontrols.xml
+++ b/toolkit/content/widgets/videocontrols.xml
@@ -1274,18 +1274,30 @@
                     // The "error" event listener must capture, so that it can trap error events
                     // from the <source> children, which don't bubble.
                     for each (let event in this.videoEvents)
                         this.video.addEventListener(event, this, (event == "error") ? true : false);
 
                     var self = this;
                     this.muteButton.addEventListener("command", function() { self.toggleMute(); }, false);
                     this.playButton.addEventListener("command", function() { self.togglePause(); }, false);
-                    this.controlsSpacer.addEventListener("click", function(e) { if (e.button == 0 && !self.hasError()) { self.togglePause(); } }, false);
                     this.fullscreenButton.addEventListener("command", function() { self.toggleFullscreen(); }, false );
+
+                    this.controlsSpacer.addEventListener("click", function spacerClickHandler(e) {
+                      if (e.button != 0 || self.hasError())
+                        return;
+                      // Read defaultPrevented asynchronously, since Web content
+                      // may want to consume the "click" event but will only
+                      // receive it after us (bug 693014).
+                      setTimeout(function togglePauseCallback() {
+                        if (!e.defaultPrevented)
+                          self.togglePause();
+                      }, 0);
+                    }, false);
+
                     if (!this.isAudioOnly) {
                       this.muteButton.addEventListener("mouseover",  function(e) { self.onVolumeMouseInOut(e); }, false);
                       this.muteButton.addEventListener("mouseout",   function(e) { self.onVolumeMouseInOut(e); }, false);
                       this.volumeStack.addEventListener("mouseover", function(e) { self.onVolumeMouseInOut(e); }, false);
                       this.volumeStack.addEventListener("mouseout",  function(e) { self.onVolumeMouseInOut(e); }, false);
                     }
 
                     this.videocontrols.addEventListener("transitionend", function(e) { self.onTransitionEnd(e); }, false);