From 9cd4a13d78cf177fd65b4cfd5e99a054f7569b51 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Mon, 27 Jun 2016 10:42:37 +1000 Subject: [PATCH] Bug 1274868 - Deactive opened menu when entering fullscreen. r=enn MozReview-Commit-ID: 9VOMfDQZ0eZ --HG-- extra : amend_source : 4bb215e2d9256725293ecc8fe66d9b93590af526 --- layout/xul/nsMenuBarFrame.cpp | 4 ++++ layout/xul/nsMenuBarListener.cpp | 14 ++++++++++++++ layout/xul/nsMenuBarListener.h | 1 + 3 files changed, 19 insertions(+) diff --git a/layout/xul/nsMenuBarFrame.cpp b/layout/xul/nsMenuBarFrame.cpp index 324c5014ee39..80aa98fbd7fd 100644 --- a/layout/xul/nsMenuBarFrame.cpp +++ b/layout/xul/nsMenuBarFrame.cpp @@ -85,6 +85,8 @@ nsMenuBarFrame::Init(nsIContent* aContent, mTarget->AddEventListener(NS_LITERAL_STRING("mousedown"), mMenuBarListener, true); mTarget->AddEventListener(NS_LITERAL_STRING("mousedown"), mMenuBarListener, false); mTarget->AddEventListener(NS_LITERAL_STRING("blur"), mMenuBarListener, true); + + mTarget->AddEventListener(NS_LITERAL_STRING("MozDOMFullscreen:Entered"), mMenuBarListener, false); } NS_IMETHODIMP @@ -423,6 +425,8 @@ nsMenuBarFrame::DestroyFrom(nsIFrame* aDestructRoot) mTarget->RemoveEventListener(NS_LITERAL_STRING("mousedown"), mMenuBarListener, false); mTarget->RemoveEventListener(NS_LITERAL_STRING("blur"), mMenuBarListener, true); + mTarget->RemoveEventListener(NS_LITERAL_STRING("MozDOMFullscreen:Entered"), mMenuBarListener, false); + mMenuBarListener->OnDestroyMenuBarFrame(); mMenuBarListener = nullptr; diff --git a/layout/xul/nsMenuBarListener.cpp b/layout/xul/nsMenuBarListener.cpp index c0a8bb9fbeef..35a33ba0661f 100644 --- a/layout/xul/nsMenuBarListener.cpp +++ b/layout/xul/nsMenuBarListener.cpp @@ -403,6 +403,17 @@ nsMenuBarListener::MouseDown(nsIDOMEvent* aMouseEvent) return NS_OK; // means I am NOT consuming event } +//////////////////////////////////////////////////////////////////////// + +nsresult +nsMenuBarListener::Fullscreen(nsIDOMEvent* aEvent) +{ + if (mMenuBarFrame->IsActive()) { + ToggleMenuActiveState(); + } + return NS_OK; +} + //////////////////////////////////////////////////////////////////////// nsresult nsMenuBarListener::HandleEvent(nsIDOMEvent* aEvent) @@ -433,6 +444,9 @@ nsMenuBarListener::HandleEvent(nsIDOMEvent* aEvent) if (eventType.EqualsLiteral("mousedown")) { return MouseDown(aEvent); } + if (eventType.EqualsLiteral("MozDOMFullscreen:Entered")) { + return Fullscreen(aEvent); + } NS_ABORT(); diff --git a/layout/xul/nsMenuBarListener.h b/layout/xul/nsMenuBarListener.h index c4b2673b2948..3656c89e21d7 100644 --- a/layout/xul/nsMenuBarListener.h +++ b/layout/xul/nsMenuBarListener.h @@ -35,6 +35,7 @@ public: nsresult KeyPress(nsIDOMEvent* aMouseEvent); nsresult Blur(nsIDOMEvent* aEvent); nsresult MouseDown(nsIDOMEvent* aMouseEvent); + nsresult Fullscreen(nsIDOMEvent* aEvent); static nsresult GetMenuAccessKey(int32_t* aAccessKey);