Bug 1561570 - Ensure the BrowserChild is updated with the new chrome offset after fullscreen changes happen. r=rhunt
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 01 Jul 2019 18:27:55 +0000
changeset 480832 4f8400c7d8e57315fa2afb1636344c0dd7ffd2fd
parent 480831 0d31da2473ba3a3785068d7c0c42cade6dfabd09
child 480833 2db482852bec317c0a2d270f178821095f4e3163
push id88928
push userkgupta@mozilla.com
push dateMon, 01 Jul 2019 19:34:49 +0000
treeherderautoland@4f8400c7d8e5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhunt
bugs1561570
milestone69.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 1561570 - Ensure the BrowserChild is updated with the new chrome offset after fullscreen changes happen. r=rhunt Apparently the GetChromeOffset() in BrowserChild becomes stale after exiting fullscreen, but it's not clear to me what is supposed to keep it updated. So this patch adds a fullscreenchange event listener that updates it. If we encounter other scenarios where this happens maybe we can find a better way to do this but without more knowledge of the scenarios this is the best option I have. Differential Revision: https://phabricator.services.mozilla.com/D36080
dom/ipc/BrowserParent.cpp
--- a/dom/ipc/BrowserParent.cpp
+++ b/dom/ipc/BrowserParent.cpp
@@ -550,29 +550,33 @@ void BrowserParent::CacheFrameLoader(nsF
 void BrowserParent::AddWindowListeners() {
   if (mFrameElement) {
     if (nsCOMPtr<nsPIDOMWindowOuter> window =
             mFrameElement->OwnerDoc()->GetWindow()) {
       nsCOMPtr<EventTarget> eventTarget = window->GetTopWindowRoot();
       if (eventTarget) {
         eventTarget->AddEventListener(NS_LITERAL_STRING("MozUpdateWindowPos"),
                                       this, false, false);
+        eventTarget->AddEventListener(NS_LITERAL_STRING("fullscreenchange"),
+                                      this, false, false);
       }
     }
   }
 }
 
 void BrowserParent::RemoveWindowListeners() {
   if (mFrameElement && mFrameElement->OwnerDoc()->GetWindow()) {
     nsCOMPtr<nsPIDOMWindowOuter> window =
         mFrameElement->OwnerDoc()->GetWindow();
     nsCOMPtr<EventTarget> eventTarget = window->GetTopWindowRoot();
     if (eventTarget) {
       eventTarget->RemoveEventListener(NS_LITERAL_STRING("MozUpdateWindowPos"),
                                        this, false);
+      eventTarget->RemoveEventListener(NS_LITERAL_STRING("fullscreenchange"),
+                                       this, false);
     }
   }
 }
 
 void BrowserParent::DestroyInternal() {
   PopFocus(this);
 
   RemoveWindowListeners();
@@ -3432,22 +3436,26 @@ PPaymentRequestParent* BrowserParent::Al
 bool BrowserParent::DeallocPPaymentRequestParent(
     PPaymentRequestParent* aActor) {
   RefPtr<PaymentRequestParent> actor =
       dont_AddRef(static_cast<PaymentRequestParent*>(aActor));
   return true;
 }
 
 nsresult BrowserParent::HandleEvent(Event* aEvent) {
+  if (mIsDestroyed) {
+    return NS_OK;
+  }
+
   nsAutoString eventType;
   aEvent->GetType(eventType);
-
-  if (eventType.EqualsLiteral("MozUpdateWindowPos") && !mIsDestroyed) {
-    // This event is sent when the widget moved.  Therefore we only update
-    // the position.
+  if (eventType.EqualsLiteral("MozUpdateWindowPos")
+      || eventType.EqualsLiteral("fullscreenchange")) {
+    // Events that signify the window moving are used to update the position
+    // and notify the BrowserChild.
     return UpdatePosition();
   }
   return NS_OK;
 }
 
 class FakeChannel final : public nsIChannel,
                           public nsIAuthPromptCallback,
                           public nsIInterfaceRequestor,