Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Avoid double fullscreen call (#3060)
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo authored Mar 27, 2020
1 parent 3db73db commit 9f5c1d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ public void releaseWidget() {
getSession().exitFullScreen();
}
mAttachedWindow.restoreBeforeFullscreenPlacement();
mAttachedWindow.setIsFullScreen(false);
mWidgetManager.popBackHandler(mFullScreenBackHandler);
}

Expand Down Expand Up @@ -557,7 +556,7 @@ protected void onDraw(Canvas canvas) {

private void enterFullScreenMode() {
mWidgetManager.pushBackHandler(mFullScreenBackHandler);
mAttachedWindow.setIsFullScreen(true);

AnimationHelper.fadeIn(mBinding.navigationBarFullscreen.fullScreenModeContainer, AnimationHelper.FADE_ANIMATION_DURATION, null);

AnimationHelper.fadeOut(mBinding.navigationBarNavigation.navigationBarContainer, 0, null);
Expand Down Expand Up @@ -610,7 +609,6 @@ private void exitFullScreenMode() {

mWidgetManager.updateWidget(mAttachedWindow);

mAttachedWindow.setIsFullScreen(false);
mWidgetManager.popBackHandler(mFullScreenBackHandler);

AnimationHelper.fadeIn(mBinding.navigationBarNavigation.navigationBarContainer, AnimationHelper.FADE_ANIMATION_DURATION, null);
Expand Down Expand Up @@ -799,16 +797,10 @@ private void closeFloatingMenus() {

// Content delegate

@Override
public void onFullScreen(@NonNull GeckoSession session, boolean aFullScreen) {
mViewModel.setIsFullscreen(aFullScreen);
}

private Observer<ObservableBoolean> mIsFullscreenObserver = isFullScreen -> {
if (isFullScreen.get()) {
if (!mAttachedWindow.isFullScreen()) {
enterFullScreenMode();
}
enterFullScreenMode();

if (mAttachedWindow.isResizing()) {
exitResizeMode(ResizeAction.KEEP_SIZE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public class WindowWidget extends UIWidget implements SessionChangeListener,
private WidgetPlacement mPlacementBeforeFullscreen;
private WidgetPlacement mPlacementBeforeResize;
private boolean mIsResizing;
private boolean mIsFullScreen;
private boolean mAfterFirstPaint;
private boolean mCaptureOnPageStop;
private PromptDelegate mPromptDelegate;
Expand Down Expand Up @@ -192,7 +191,6 @@ private void initialize(Context aContext) {
mPlacementBeforeFullscreen = new WidgetPlacement(aContext);
mPlacementBeforeResize = new WidgetPlacement(aContext);
mIsResizing = false;
mIsFullScreen = false;
initializeWidgetPlacement(mWidgetPlacement);
if (mSession.isPrivateMode()) {
mWidgetPlacement.clearColor = ViewUtils.ARGBtoRGBA(getContext().getColor(R.color.window_private_clear_color));
Expand Down Expand Up @@ -889,8 +887,7 @@ public boolean isResizing() {
}

public void setIsFullScreen(boolean isFullScreen) {
if (isFullScreen != mIsFullScreen) {
mIsFullScreen = isFullScreen;
if (mViewModel.getIsFullscreen().getValue().get() != isFullScreen) {
mViewModel.setIsFullscreen(isFullScreen);
for (WindowListener listener: mListeners) {
listener.onFullScreen(this, isFullScreen);
Expand All @@ -899,7 +896,7 @@ public void setIsFullScreen(boolean isFullScreen) {
}

public boolean isFullScreen() {
return mIsFullScreen;
return mViewModel.getIsFullscreen().getValue().get();
}

public void addWindowListener(WindowListener aListener) {
Expand Down Expand Up @@ -1554,6 +1551,11 @@ private void hideContextMenus() {

// GeckoSession.ContentDelegate

@Override
public void onFullScreen(@NonNull GeckoSession session, boolean aFullScreen) {
setIsFullScreen(aFullScreen);
}

@Override
public void onContextMenu(GeckoSession session, int screenX, int screenY, ContextElement element) {
if (element.type == ContextElement.TYPE_VIDEO) {
Expand Down

0 comments on commit 9f5c1d7

Please sign in to comment.