Bug 1362195 - 3. Call onFullScreen for full screen changes; r=snorp
authorJim Chen <nchen@mozilla.com>
Thu, 11 May 2017 16:40:17 -0400
changeset 357986 8e8e68c6e3ae1ff1539c0dec182b4eae040abfa9
parent 357985 2acf5f4b6943de39e799ed0eaa4af8a727d37f14
child 357987 5eb0e63fde7b0fed863d73859f23be5322e22ad7
push id31808
push usercbook@mozilla.com
push dateFri, 12 May 2017 12:37:49 +0000
treeherdermozilla-central@030c0a7c8781 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1362195
milestone55.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 1362195 - 3. Call onFullScreen for full screen changes; r=snorp Send an event from nsWindow to GeckoView when we enter/exit full screen mode, and call ContentListener.onFullScreen to notify the implementer.
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java
widget/android/nsWindow.cpp
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java
@@ -11,16 +11,17 @@ import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Set;
 
 import org.mozilla.gecko.annotation.ReflectionTarget;
 import org.mozilla.gecko.annotation.WrapForJNI;
 import org.mozilla.gecko.gfx.LayerView;
 import org.mozilla.gecko.mozglue.JNIObject;
+import org.mozilla.gecko.util.ActivityUtils;
 import org.mozilla.gecko.util.BundleEventListener;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.GeckoBundle;
 
 import android.app.Activity;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.SharedPreferences;
@@ -191,16 +192,18 @@ public class GeckoView extends LayerView
                 }
             };
     }
 
     private class Listener implements BundleEventListener {
         /* package */ void registerListeners() {
             getEventDispatcher().registerUiThreadListener(this,
                 "GeckoView:DOMTitleChanged",
+                "GeckoView:FullScreenEnter",
+                "GeckoView:FullScreenExit",
                 "GeckoView:LocationChange",
                 "GeckoView:PageStart",
                 "GeckoView:PageStop",
                 "GeckoView:Prompt",
                 "GeckoView:SecurityChanged",
                 null);
         }
 
@@ -210,16 +213,24 @@ public class GeckoView extends LayerView
             if (DEBUG) {
                 Log.d(LOGTAG, "handleMessage: event = " + event);
             }
 
             if ("GeckoView:DOMTitleChanged".equals(event)) {
                 if (mContentListener != null) {
                     mContentListener.onTitleChange(GeckoView.this, message.getString("title"));
                 }
+            } else if ("GeckoView:FullScreenEnter".equals(event)) {
+                if (mContentListener != null) {
+                    mContentListener.onFullScreen(GeckoView.this, true);
+                }
+            } else if ("GeckoView:FullScreenExit".equals(event)) {
+                if (mContentListener != null) {
+                    mContentListener.onFullScreen(GeckoView.this, false);
+                }
             } else if ("GeckoView:LocationChange".equals(event)) {
                 if (mNavigationListener == null) {
                     // We shouldn't be getting this event.
                     mEventDispatcher.dispatch("GeckoViewNavigation:Inactive", null);
                 } else {
                     mNavigationListener.onLocationChange(GeckoView.this, message.getString("uri"));
                     mNavigationListener.onCanGoBack(GeckoView.this, message.getBoolean("canGoBack"));
                     mNavigationListener.onCanGoForward(GeckoView.this, message.getBoolean("canGoForward"));
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1915,19 +1915,24 @@ nsWindow::DispatchEvent(WidgetGUIEvent* 
         return mWidgetListener->HandleEvent(aEvent, mUseAttachedEvents);
     }
     return nsEventStatus_eIgnore;
 }
 
 nsresult
 nsWindow::MakeFullScreen(bool aFullScreen, nsIScreen*)
 {
+    if (!mAndroidView) {
+        return NS_ERROR_NOT_AVAILABLE;
+    }
+
     mIsFullScreen = aFullScreen;
     mAwaitingFullScreen = true;
-    GeckoAppShell::SetFullScreen(aFullScreen);
+    mAndroidView->mEventDispatcher->Dispatch(aFullScreen ?
+            u"GeckoView:FullScreenEnter" : u"GeckoView:FullScreenExit");
     return NS_OK;
 }
 
 mozilla::layers::LayerManager*
 nsWindow::GetLayerManager(PLayerTransactionChild*, LayersBackend, LayerManagerPersistence)
 {
     if (mLayerManager) {
         return mLayerManager;