Bug 1264091 - Ensure we unblack the screen for a right after-paint event. r?dao draft
authorXidorn Quan <quanxunzhen@gmail.com>
Tue, 19 Apr 2016 10:15:37 +1000
changeset 352925 1cce4648458f189e1d6bf19ed965ccf29087a73e
parent 352870 aca57e8e88fc1dbfba5aedc4c74cfafd31853bbc
child 518786 c60a39684fe6404e523cc3b40da337264a91c61d
push id15843
push userxquan@mozilla.com
push dateTue, 19 Apr 2016 00:15:56 +0000
reviewersdao
bugs1264091
milestone48.0a1
Bug 1264091 - Ensure we unblack the screen for a right after-paint event. r?dao MozReview-Commit-ID: H2hCmQX8OLX
browser/base/content/tab-content.js
--- a/browser/base/content/tab-content.js
+++ b/browser/base/content/tab-content.js
@@ -610,30 +610,33 @@ var DOMFullscreenHandler = {
     if (!content) {
       return null;
     }
     return content.QueryInterface(Ci.nsIInterfaceRequestor)
                   .getInterface(Ci.nsIDOMWindowUtils);
   },
 
   receiveMessage: function(aMessage) {
+    let windowUtils = this._windowUtils;
     switch(aMessage.name) {
       case "DOMFullscreen:Entered": {
-        if (!this._windowUtils.handleFullscreenRequests() &&
+        this._lastTransactionId = windowUtils.lastTransactionId;
+        if (!windowUtils.handleFullscreenRequests() &&
             !content.document.fullscreenElement) {
           // If we don't actually have any pending fullscreen request
           // to handle, neither we have been in fullscreen, tell the
           // parent to just exit.
           sendAsyncMessage("DOMFullscreen:Exit");
         }
         break;
       }
       case "DOMFullscreen:CleanUp": {
-        if (this._windowUtils) {
-          this._windowUtils.exitFullscreen();
+        if (windowUtils) {
+          this._lastTransactionId = windowUtils.lastTransactionId;
+          windowUtils.exitFullscreen();
         }
         this._fullscreenDoc = null;
         break;
       }
     }
   },
 
   handleEvent: function(aEvent) {
@@ -660,18 +663,20 @@ var DOMFullscreenHandler = {
           // If we receive any fullscreen change event, and find we are
           // actually not in fullscreen, also ask the parent to exit to
           // ensure that the parent always exits fullscreen when we do.
           sendAsyncMessage("DOMFullscreen:Exit");
         }
         break;
       }
       case "MozAfterPaint": {
-        removeEventListener("MozAfterPaint", this);
-        sendAsyncMessage("DOMFullscreen:Painted");
+        if (aEvent.transactionId > this._lastTransactionId) {
+          removeEventListener("MozAfterPaint", this);
+          sendAsyncMessage("DOMFullscreen:Painted");
+        }
         break;
       }
     }
   }
 };
 DOMFullscreenHandler.init();
 
 var RefreshBlocker = {