Backout 9eb6532ccfc3 for bustage on some slaves. r=me
authorBrian R. Bondy <netzen@gmail.com>
Thu, 28 Mar 2013 23:28:11 -0400
changeset 126668 85eedb253f255e287b80074668a8675435577529
parent 126667 77deab8dff65f9ca7fe79ca3904bd865a1bb5fcf
child 126669 088d73e55949ec3063b5da92ed3b76bcd25c6a34
push id25585
push userbbondy@mozilla.com
push dateFri, 29 Mar 2013 03:29:32 +0000
treeherdermozilla-inbound@088d73e55949 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
milestone22.0a1
backs out9eb6532ccfc3f0072dbaac5e60a6c62e3b587e11
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
Backout 9eb6532ccfc3 for bustage on some slaves. r=me
browser/metro/base/content/ContextCommands.js
browser/metro/base/content/browser-scripts.js
browser/metro/base/content/browser-ui.js
browser/metro/base/content/contenthandlers/ContextMenuHandler.js
browser/metro/base/content/pages/fullscreen-video.xhtml
browser/metro/base/content/video.js
browser/metro/base/jar.mn
browser/metro/modules/Makefile.in
browser/metro/modules/video.jsm
--- a/browser/metro/base/content/ContextCommands.js
+++ b/browser/metro/base/content/ContextCommands.js
@@ -211,16 +211,21 @@ var ContextCommands = {
     this.clipboard.copyString(ContextMenuUI.popupState.mediaURL,
                               this.docRef);
   },
 
   openVideoInNewTab: function cc_openVideoInNewTab() {
     BrowserUI.newTab(ContextMenuUI.popupState.mediaURL, Browser.selectedTab);
   },
 
+  openVideoInFullscreen: function cc_openVideoInFullscreen() {
+    // XXX currently isn't working.
+    this.sendCommand('videotab');
+  },
+
   // Bookmarks
 
   editBookmark: function cc_editBookmark() {
     let target = ContextMenuUI.popupState.target;
     target.startEditing();
   },
 
   removeBookmark: function cc_removeBookmark() {
--- a/browser/metro/base/content/browser-scripts.js
+++ b/browser/metro/base/content/browser-scripts.js
@@ -101,16 +101,17 @@ let ScriptContexts = {};
   ["AutofillMenuUI", "chrome://browser/content/helperui/MenuUI.js"],
   ["ContextMenuUI", "chrome://browser/content/helperui/MenuUI.js"],
   ["MenuControlUI", "chrome://browser/content/helperui/MenuUI.js"],
   ["MenuPopup", "chrome://browser/content/helperui/MenuUI.js"],
   ["IndexedDB", "chrome://browser/content/helperui/IndexedDB.js"],
   ["OfflineApps", "chrome://browser/content/helperui/OfflineApps.js"],
   ["SelectHelperUI", "chrome://browser/content/helperui/SelectHelperUI.js"],
   ["SelectionHelperUI", "chrome://browser/content/helperui/SelectionHelperUI.js"],
+  ["FullScreenVideo", "chrome://browser/content/video.js"],
   ["AnimatedZoom", "chrome://browser/content/AnimatedZoom.js"],
   ["CommandUpdater", "chrome://browser/content/commandUtil.js"],
   ["ContextCommands", "chrome://browser/content/ContextCommands.js"],
   ["Bookmarks", "chrome://browser/content/bookmarks.js"],
   ["Downloads", "chrome://browser/content/downloads.js"],
   ["BookmarksPanelView", "chrome://browser/content/bookmarks.js"],
   ["ConsolePanelView", "chrome://browser/content/console.js"],
   ["DownloadsPanelView", "chrome://browser/content/downloads.js"],
--- a/browser/metro/base/content/browser-ui.js
+++ b/browser/metro/base/content/browser-ui.js
@@ -140,16 +140,17 @@ var BrowserUI = {
       messageManager.addMessageListener("Browser:MozApplicationManifest", OfflineApps);
 
       try {
         BrowserUI._updateTabsOnly();
         Downloads.init();
         DialogUI.init();
         FormHelperUI.init();
         FindHelperUI.init();
+        FullScreenVideo.init();
         PdfJs.init();
 #ifdef MOZ_SERVICES_SYNC
         WeaveGlue.init();
 #endif
       } catch(ex) {
         Util.dumpLn("Exception in delay load module:", ex.message);
       }
 
--- a/browser/metro/base/content/contenthandlers/ContextMenuHandler.js
+++ b/browser/metro/base/content/contenthandlers/ContextMenuHandler.js
@@ -64,16 +64,31 @@ var ContextMenuHandler = {
       case "copy":
         this._onCopy();
         break;
 
       case "paste":
         this._onPaste();
         break;
 
+      case "play":
+      case "pause":
+        if (node instanceof Ci.nsIDOMHTMLMediaElement)
+          node[command]();
+        break;
+
+      case "videotab":
+        if (node instanceof Ci.nsIDOMHTMLVideoElement) {
+          node.pause();
+          Cu.import("resource:///modules/video.jsm");
+          Video.fullScreenSourceElement = node;
+          sendAsyncMessage("Browser:FullScreenVideo:Start");
+        }
+        break;
+
       case "select-all":
         this._onSelectAll();
         break;
 
       case "copy-image-contents":
         this._onCopyImage();
         break;
     }
new file mode 100644
--- /dev/null
+++ b/browser/metro/base/content/pages/fullscreen-video.xhtml
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<!--
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" accelerated="11">
+<head>
+
+<style type="text/css"><![CDATA[
+  html,
+  body,
+  video {
+    height: 100%;
+  }
+    
+  body {
+    margin: 0;
+    background: black;
+    overflow: -moz-hidden-unscrollable;
+  }
+    
+  video {
+    width: 100%;
+    max-height: 100%;
+  }
+]]></style>
+
+<script type="application/javascript;version=1.8"><![CDATA[
+
+var TheaterTab = {
+  videoElement: null,
+  idleTimer: 0,
+
+  init: function init() {
+    this.videoElement = document.querySelector("video");
+
+    /*
+     * video events
+     */
+
+    this.videoElement.addEventListener("loadeddata", TheaterTab.loadDataCallback, false);
+    this.videoElement.addEventListener("seeked", TheaterTab.seekComplete, false);
+    this.videoElement.addEventListener("pause", TheaterTab.pauseCallback, false);
+    this.videoElement.addEventListener("play", TheaterTab.playCallback, false);
+    this.videoElement.addEventListener("ended", TheaterTab.endedCallback, false);
+
+    /*
+     * window events
+     */
+
+    window.addEventListener("click", function () {
+      TheaterTab.togglePlay();
+      TheaterTab.resetIdleTimer();
+    }, false);
+
+    window.addEventListener("unload", function () {
+      if (TheaterTab.videoElement.currentSrc) {
+        contentVideo.currentTime = TheaterTab.videoElement.currentTime;
+        contentVideo.volume = TheaterTab.videoElement.volume;
+        contentVideo.muted = TheaterTab.videoElement.muted;
+        if (!TheaterTab.videoElement.paused && !TheaterTab.videoElement.ended) {
+          TheaterTab.videoElement.pause();
+        }
+      }
+    }, false);
+
+    window.addEventListener("keypress", function (event) {
+      TheaterTab.resetIdleTimer();
+    }, false);
+
+
+    // Load the video up and play it
+    this.videoElement.mozLoadFrom(contentVideo);
+  },
+
+  /*
+   * Video element callbacks
+   */
+
+  loadDataCallback: function loadDataCallback() {
+    dump("loadDataCallback()\n");
+    TheaterTab.videoElement.removeEventListener("loadeddata", arguments.callee, false);
+    TheaterTab.videoElement.volume = contentVideo.volume;
+    TheaterTab.videoElement.muted = contentVideo.muted;
+    TheaterTab.videoElement.poster = contentVideo.poster;
+
+    // If we are starting from mid stream, wait until we have
+    // seeked to the start location.
+    dump(contentVideo + "\n");
+    if (contentVideo.currentTime && !contentVideo.ended) {
+      // set up callback to play
+      TheaterTab.videoElement.addEventListener("seeked", function () {
+        TheaterTab.videoElement.removeEventListener("seeked", arguments.callee, false);
+          TheaterTab.seekComplete();
+        }, false);
+      // seek
+      TheaterTab.videoElement.currentTime = contentVideo.currentTime;
+      return;
+    }
+    TheaterTab.play();
+  },
+
+  seekComplete: function seekComplete() {
+    TheaterTab.play();
+  },
+
+  pauseCallback: function pauseCallback() {
+  },
+
+  playCallback: function playCallback() {
+  },
+
+  endedCallback: function endedCallback() {
+  },
+
+  /*
+   * Video control
+   */
+
+  play: function play() {
+    this.videoElement.play();
+  },
+
+  pause: function pause() {
+    this.videoElement.pause();
+  },
+
+  togglePlay: function togglePlay() {
+    if (this.videoElement.paused) {
+      this.play();
+    } else {
+      this.pause();
+    }
+  },
+
+};
+
+Components.utils.import("resource:///modules/video.jsm");
+
+// The video in the content tab we launched from
+var contentVideo = Video.fullScreenSourceElement;
+
+// ??
+Video.fullScreenSourceElement = null;
+
+]]></script>
+</head>
+
+<body onload="TheaterTab.init();">
+  <video controls="true"/>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/browser/metro/base/content/video.js
@@ -0,0 +1,66 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var FullScreenVideo = {
+  _tab: null,
+
+  init: function fsv_init() {
+    // These come in from content.js, currently we only use Start.
+    messageManager.addMessageListener("Browser:FullScreenVideo:Start", this.show.bind(this));
+    messageManager.addMessageListener("Browser:FullScreenVideo:Close", this.hide.bind(this));
+    messageManager.addMessageListener("Browser:FullScreenVideo:Play", this.play.bind(this));
+    messageManager.addMessageListener("Browser:FullScreenVideo:Pause", this.pause.bind(this));
+
+    // If the screen supports brightness locks, we will utilize that, see checkBrightnessLocking()
+    try {
+      this.screen = null;
+      let screenManager = Cc["@mozilla.org/gfx/screenmanager;1"].getService(Ci.nsIScreenManager);
+      this.screen = screenManager.primaryScreen;
+    }
+    catch (e) {} // The screen does not support brightness locks
+  },
+
+  play: function() {
+    this.playing = true;
+    this.checkBrightnessLocking();
+  },
+
+  pause: function() {
+    this.playing = false;
+    this.checkBrightnessLocking();
+  },
+
+  checkBrightnessLocking: function() {
+    // screen manager support for metro: bug 776113
+    var shouldLock = !!this.screen && !!window.fullScreen && !!this.playing;
+    var locking = !!this.brightnessLocked;
+    if (shouldLock == locking)
+      return;
+
+    if (shouldLock)
+      this.screen.lockMinimumBrightness(this.screen.BRIGHTNESS_FULL);
+    else
+      this.screen.unlockMinimumBrightness(this.screen.BRIGHTNESS_FULL);
+    this.brightnessLocked = shouldLock;
+  },
+
+  show: function fsv_show() {
+    this.createTab();
+    this.checkBrightnessLocking();
+  },
+
+  hide: function fsv_hide() {
+    this.checkBrightnessLocking();
+    this.destroyTab();
+  },
+
+  createTab: function fsv_createBrowser() {
+    this._tab = BrowserUI.newTab("chrome://browser/content/fullscreen-video.xhtml");
+  },
+
+  destroyTab: function fsv_destroyBrowser() {
+    Browser.closeTab(this._tab);
+    this._tab = null;
+  }
+};
--- a/browser/metro/base/jar.mn
+++ b/browser/metro/base/jar.mn
@@ -6,16 +6,17 @@
 
 chrome.jar:
 % content browser %content/
 
   content/aboutCertError.xhtml                 (content/pages/aboutCertError.xhtml)
   content/aboutRights.xhtml                    (content/pages/aboutRights.xhtml)
   content/aboutCrash.xhtml                     (content/pages/aboutCrash.xhtml)
   content/blockedSite.xhtml                    (content/pages/blockedSite.xhtml)
+  content/fullscreen-video.xhtml               (content/pages/fullscreen-video.xhtml)
   content/netError.xhtml                       (content/pages/netError.xhtml)
 
   content/bindings/bindings.xml                (content/bindings/bindings.xml)
   content/bindings/tabs.xml                    (content/bindings/tabs.xml)
   content/bindings/toggleswitch.xml            (content/bindings/toggleswitch.xml)
   content/bindings/browser.xml                 (content/bindings/browser.xml)
   content/bindings/browser.js                  (content/bindings/browser.js)
   content/bindings/downloads.xml               (content/bindings/downloads.xml)
@@ -79,15 +80,16 @@ chrome.jar:
   content/exceptions.js                        (content/exceptions.js)
   content/downloads.js                         (content/downloads.js)
   content/history.js                           (content/history.js)
   content/Site.js                              (content/Site.js)
   content/TopSites.js                          (content/TopSites.js)
   content/console.js                           (content/console.js)
   content/AnimatedZoom.js                      (content/AnimatedZoom.js)
   content/LoginManagerChild.js                 (content/LoginManagerChild.js)
+  content/video.js                             (content/video.js)
 #ifdef MOZ_SERVICES_SYNC
 * content/sync.js                              (content/sync.js)
   content/RemoteTabs.js                        (content/RemoteTabs.js)
 #endif
 
 % override chrome://global/content/config.xul chrome://browser/content/config.xul
 % override chrome://global/content/netError.xhtml chrome://browser/content/netError.xhtml
--- a/browser/metro/modules/Makefile.in
+++ b/browser/metro/modules/Makefile.in
@@ -5,9 +5,13 @@
 DEPTH      = @DEPTH@
 topsrcdir  = @top_srcdir@
 srcdir     = @srcdir@
 VPATH      = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/config.mk
 
+EXTRA_JS_MODULES = \
+  video.jsm \
+  $(NULL)
+
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/browser/metro/modules/video.jsm
@@ -0,0 +1,9 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+this.EXPORTED_SYMBOLS = ["Video"];
+
+this.Video = {
+  fullScreenSourceElement: null
+};