Bug 1124245, nsGlobalWindow::IsActive shouldn't depend on the state in nsFocusManager, r=Enn

--HG--
extra : rebase_source : 5fcd4611cc73651d9f7d1d498808847f26ff1d6b
This commit is contained in:
Olli Pettay 2015-02-06 18:26:29 +02:00
Родитель 009c1a2bcb
Коммит e964974938
11 изменённых файлов: 49 добавлений и 37 удалений

Просмотреть файл

@ -11,6 +11,10 @@ let browser1, browser2;
function test() {
waitForExplicitFinish();
waitForFocus(reallyRunTests);
}
function reallyRunTests() {
let tab1 = gBrowser.addTab();
let tab2 = gBrowser.addTab();

Просмотреть файл

@ -38,6 +38,7 @@
#include "nsBindingManager.h"
#include "nsStyleCoord.h"
#include "SelectionCarets.h"
#include "TabChild.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/dom/Element.h"
@ -174,7 +175,6 @@ static const char* kObservedPrefs[] = {
};
nsFocusManager::nsFocusManager()
: mParentFocusType(ParentFocusType_Ignore)
{ }
nsFocusManager::~nsFocusManager()
@ -712,7 +712,7 @@ nsFocusManager::WindowRaised(nsIDOMWindow* aWindow)
// If this is a parent or single process window, send the activate event.
// Events for child process windows will be sent when ParentActivated
// is called.
if (mParentFocusType == ParentFocusType_Ignore) {
if (XRE_GetProcessType() == GeckoProcessType_Default) {
ActivateOrDeactivate(window, true);
}
@ -777,7 +777,7 @@ nsFocusManager::WindowLowered(nsIDOMWindow* aWindow)
// If this is a parent or single process window, send the deactivate event.
// Events for child process windows will be sent when ParentActivated
// is called.
if (mParentFocusType == ParentFocusType_Ignore) {
if (XRE_GetProcessType() == GeckoProcessType_Default) {
ActivateOrDeactivate(window, false);
}
@ -889,6 +889,11 @@ nsFocusManager::WindowShown(nsIDOMWindow* aWindow, bool aNeedsFocus)
}
#endif
if (nsCOMPtr<nsITabChild> child = do_GetInterface(window->GetDocShell())) {
bool active = static_cast<TabChild*>(child.get())->ParentIsActive();
ActivateOrDeactivate(window, active);
}
if (mFocusedWindow != window)
return NS_OK;
@ -906,10 +911,6 @@ nsFocusManager::WindowShown(nsIDOMWindow* aWindow, bool aNeedsFocus)
EnsureCurrentWidgetFocused();
}
if (mParentFocusType == ParentFocusType_Active) {
ActivateOrDeactivate(window, true);
}
return NS_OK;
}
@ -1077,7 +1078,6 @@ nsFocusManager::ParentActivated(nsIDOMWindow* aWindow, bool aActive)
window = window->GetOuterWindow();
mParentFocusType = aActive ? ParentFocusType_Active : ParentFocusType_Inactive;
ActivateOrDeactivate(window, aActive);
return NS_OK;
}

Просмотреть файл

@ -26,12 +26,6 @@ class nsIMessageBroadcaster;
struct nsDelayedBlurOrFocusEvent;
enum ParentFocusType {
ParentFocusType_Ignore, // Parent or single process window or unknown
ParentFocusType_Active, // Child process window in active parent
ParentFocusType_Inactive, // Child process window in inactive parent
};
/**
* The focus manager keeps track of where the focus is, that is, the node
* which receives key events.
@ -97,11 +91,6 @@ public:
*/
void UpdateCaretForCaretBrowsingMode();
bool IsParentActivated()
{
return mParentFocusType == ParentFocusType_Active;
}
/**
* Returns the content node that would be focused if aWindow was in an
* active window. This will traverse down the frame hierarchy, starting at
@ -549,9 +538,6 @@ private:
// moving focus.
nsCOMPtr<nsIDocument> mMouseButtonEventHandlingDocument;
// Indicates a child process that is in an active window.
ParentFocusType mParentFocusType;
static bool sTestMode;
// the single focus manager

Просмотреть файл

@ -53,7 +53,8 @@
#include "nsISHistory.h"
#include "nsNullPrincipal.h"
#include "nsIScriptError.h"
#include "nsGlobalWindow.h"
#include "nsPIWindowRoot.h"
#include "nsLayoutUtils.h"
#include "nsView.h"
@ -898,7 +899,17 @@ nsFrameLoader::ShowRemoteFrame(const nsIntSize& size,
return false;
}
mRemoteBrowser->Show(size);
nsPIDOMWindow* win = mOwnerContent->OwnerDoc()->GetWindow();
bool parentIsActive = false;
if (win) {
nsCOMPtr<nsPIWindowRoot> windowRoot =
static_cast<nsGlobalWindow*>(win)->GetTopWindowRoot();
if (windowRoot) {
nsPIDOMWindow* topWin = windowRoot->GetWindow();
parentIsActive = topWin && topWin->IsActive();
}
}
mRemoteBrowser->Show(size, parentIsActive);
mRemoteBrowserShown = true;
EnsureMessageManager();

Просмотреть файл

@ -1227,12 +1227,6 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
if (sWindowsById) {
sWindowsById->Put(mWindowID, this);
}
// Ensure that the current active state is initialized for child process windows.
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) {
mIsActive = fm->IsParentActivated();
}
}
#ifdef DEBUG

Просмотреть файл

@ -34,6 +34,7 @@ using namespace mozilla::dom;
nsWindowRoot::nsWindowRoot(nsPIDOMWindow* aWindow)
{
mWindow = aWindow;
MOZ_ASSERT(mWindow->IsOuterWindow());
}
nsWindowRoot::~nsWindowRoot()

Просмотреть файл

@ -468,7 +468,8 @@ child:
ScrollingBehavior scrolling,
TextureFactoryIdentifier textureFactoryIdentifier,
uint64_t layersId,
nullable PRenderFrame renderFrame);
nullable PRenderFrame renderFrame,
bool parentIsActive);
LoadURL(nsCString uri);

Просмотреть файл

@ -880,6 +880,7 @@ TabChild::TabChild(nsIContentChild* aManager,
, mDPI(0)
, mDefaultScale(0)
, mIPCOpen(true)
, mParentIsActive(false)
{
if (!sActiveDurationMsSet) {
Preferences::AddIntVarCache(&sActiveDurationMs,
@ -1889,7 +1890,8 @@ TabChild::DoFakeShow(const ScrollingBehavior& aScrolling,
PRenderFrameChild* aRenderFrame)
{
ShowInfo info(EmptyString(), false, false, 0, 0);
RecvShow(nsIntSize(0, 0), info, aScrolling, aTextureFactoryIdentifier, aLayersId, aRenderFrame);
RecvShow(nsIntSize(0, 0), info, aScrolling, aTextureFactoryIdentifier,
aLayersId, aRenderFrame, mParentIsActive);
mDidFakeShow = true;
}
@ -1991,12 +1993,14 @@ TabChild::RecvShow(const nsIntSize& aSize,
const ScrollingBehavior& aScrolling,
const TextureFactoryIdentifier& aTextureFactoryIdentifier,
const uint64_t& aLayersId,
PRenderFrameChild* aRenderFrame)
PRenderFrameChild* aRenderFrame,
const bool& aParentIsActive)
{
MOZ_ASSERT((!mDidFakeShow && aRenderFrame) || (mDidFakeShow && !aRenderFrame));
if (mDidFakeShow) {
ApplyShowInfo(aInfo);
RecvParentActivated(aParentIsActive);
return true;
}
@ -2022,6 +2026,7 @@ TabChild::RecvShow(const nsIntSize& aSize,
bool res = InitTabChildGlobal();
ApplyShowInfo(aInfo);
RecvParentActivated(aParentIsActive);
return res;
}
@ -2272,6 +2277,8 @@ bool TabChild::RecvDeactivate()
bool TabChild::RecvParentActivated(const bool& aActivated)
{
mParentIsActive = aActivated;
nsFocusManager* fm = nsFocusManager::GetFocusManager();
NS_ENSURE_TRUE(fm, true);

Просмотреть файл

@ -321,7 +321,8 @@ public:
const ScrollingBehavior& aScrolling,
const TextureFactoryIdentifier& aTextureFactoryIdentifier,
const uint64_t& aLayersId,
PRenderFrameChild* aRenderFrame) MOZ_OVERRIDE;
PRenderFrameChild* aRenderFrame,
const bool& aParentIsActive) MOZ_OVERRIDE;
virtual bool RecvUpdateDimensions(const nsIntRect& rect,
const nsIntSize& size,
const ScreenOrientation& orientation,
@ -500,6 +501,11 @@ public:
bool IPCOpen() { return mIPCOpen; }
bool ParentIsActive()
{
return mParentIsActive;
}
protected:
virtual ~TabChild();
@ -665,6 +671,7 @@ private:
float mDPI;
double mDefaultScale;
bool mIPCOpen;
bool mParentIsActive;
DISALLOW_EVIL_CONSTRUCTORS(TabChild);
};

Просмотреть файл

@ -763,7 +763,7 @@ TabParent::LoadURL(nsIURI* aURI)
}
void
TabParent::Show(const nsIntSize& size)
TabParent::Show(const nsIntSize& size, bool aParentIsActive)
{
// sigh
mShown = true;
@ -809,7 +809,8 @@ TabParent::Show(const nsIntSize& size)
info = ShowInfo(name, allowFullscreen, isPrivate, mDPI, mDefaultScale.scale);
}
unused << SendShow(size, info, scrolling, textureFactoryIdentifier, layersId, renderFrame);
unused << SendShow(size, info, scrolling, textureFactoryIdentifier,
layersId, renderFrame, aParentIsActive);
}
bool

Просмотреть файл

@ -235,7 +235,7 @@ public:
// XXX/cjones: it's not clear what we gain by hiding these
// message-sending functions under a layer of indirection and
// eating the return values
void Show(const nsIntSize& size);
void Show(const nsIntSize& size, bool aParentIsActive);
void UpdateDimensions(const nsIntRect& rect, const nsIntSize& size,
const nsIntPoint& chromeDisp);
void UpdateFrame(const layers::FrameMetrics& aFrameMetrics);