Bug 1588791 - Cleanup threading of OwnerShowInfo. r=mattwoodrow

Right now we do the same thing in two pretty different code paths... That's not
great, so unify them.

Differential Revision: https://phabricator.services.mozilla.com/D59629

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2020-01-12 22:22:20 +00:00
Родитель 076eaa47d2
Коммит 874686801b
8 изменённых файлов: 30 добавлений и 45 удалений

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

@ -1018,31 +1018,25 @@ bool nsFrameLoader::ShowRemoteFrame(const ScreenIntSize& size,
return false;
}
if (RefPtr<BrowserBridgeChild> browserBridgeChild =
GetBrowserBridgeChild()) {
nsCOMPtr<nsISupports> container =
mOwnerContent->OwnerDoc()->GetContainer();
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(container);
nsCOMPtr<nsIWidget> mainWidget;
baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
nsSizeMode sizeMode =
mainWidget ? mainWidget->SizeMode() : nsSizeMode_Normal;
OwnerShowInfo info(size, ParentWindowIsActive(mOwnerContent->OwnerDoc()),
sizeMode);
Unused << browserBridgeChild->SendShow(info);
mRemoteBrowserShown = true;
return true;
}
if (!mRemoteBrowser->Show(
size, ParentWindowIsActive(mOwnerContent->OwnerDoc()))) {
nsCOMPtr<nsISupports> container = mOwnerContent->OwnerDoc()->GetContainer();
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(container);
nsCOMPtr<nsIWidget> mainWidget;
baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
nsSizeMode sizeMode =
mainWidget ? mainWidget->SizeMode() : nsSizeMode_Normal;
OwnerShowInfo info(size, GetScrollbarPreference(mOwnerContent),
ParentWindowIsActive(mOwnerContent->OwnerDoc()),
sizeMode);
if (!mRemoteBrowser->Show(info)) {
return false;
}
mRemoteBrowserShown = true;
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
if (os) {
os->NotifyObservers(ToSupports(this), "remote-browser-shown", nullptr);
// This notification doesn't apply to fission, apparently.
if (!GetBrowserBridgeChild()) {
if (nsCOMPtr<nsIObserverService> os = services::GetObserverService()) {
os->NotifyObservers(ToSupports(this), "remote-browser-shown", nullptr);
}
}
} else {
nsIntRect dimensions;

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

@ -58,14 +58,8 @@ void BrowserBridgeHost::DestroyComplete() {
mBridge = nullptr;
}
bool BrowserBridgeHost::Show(const ScreenIntSize& aSize, bool aParentIsActive) {
nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget) {
NS_WARNING("No widget found in BrowserBridgeHost::Show");
return false;
}
OwnerShowInfo info(aSize, aParentIsActive, widget->SizeMode());
Unused << mBridge->SendShow(info);
bool BrowserBridgeHost::Show(const OwnerShowInfo& aShowInfo) {
Unused << mBridge->SendShow(aShowInfo);
return true;
}

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

@ -11,6 +11,7 @@
#include "mozilla/dom/BrowserBridgeChild.h"
namespace mozilla {
namespace dom {
/**
@ -47,7 +48,7 @@ class BrowserBridgeHost : public RemoteBrowser {
void DestroyStart() override;
void DestroyComplete() override;
bool Show(const ScreenIntSize& aSize, bool aParentIsActive) override;
bool Show(const OwnerShowInfo&) override;
void UpdateDimensions(const nsIntRect& aRect,
const ScreenIntSize& aSize) override;

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

@ -125,8 +125,8 @@ void BrowserHost::DestroyComplete() {
}
}
bool BrowserHost::Show(const ScreenIntSize& aSize, bool aParentIsActive) {
return mRoot->Show(aSize, aParentIsActive);
bool BrowserHost::Show(const OwnerShowInfo& aShowInfo) {
return mRoot->Show(aShowInfo);
}
void BrowserHost::UpdateDimensions(const nsIntRect& aRect,

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

@ -85,7 +85,7 @@ class BrowserHost : public RemoteBrowser,
void DestroyStart() override;
void DestroyComplete() override;
bool Show(const ScreenIntSize& aSize, bool aParentIsActive) override;
bool Show(const OwnerShowInfo&) override;
void UpdateDimensions(const nsIntRect& aRect,
const ScreenIntSize& aSize) override;

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

@ -941,8 +941,8 @@ void BrowserParent::MaybeShowFrame() {
frameLoader->MaybeShowFrame();
}
bool BrowserParent::Show(const ScreenIntSize& size, bool aParentIsActive) {
mDimensions = size;
bool BrowserParent::Show(const OwnerShowInfo& aOwnerInfo) {
mDimensions = aOwnerInfo.size();
if (mIsDestroyed) {
return false;
}
@ -952,14 +952,8 @@ bool BrowserParent::Show(const ScreenIntSize& size, bool aParentIsActive) {
return false;
}
nsCOMPtr<nsISupports> container = mFrameElement->OwnerDoc()->GetContainer();
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(container);
nsCOMPtr<nsIWidget> mainWidget;
baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
mSizeMode = mainWidget ? mainWidget->SizeMode() : nsSizeMode_Normal;
OwnerShowInfo ownerInfo(size, aParentIsActive, mSizeMode);
Unused << SendShow(GetShowInfo(), ownerInfo);
mSizeMode = aOwnerInfo.sizeMode();
Unused << SendShow(GetShowInfo(), aOwnerInfo);
return true;
}

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

@ -515,7 +515,7 @@ class BrowserParent final : public PBrowserParent,
bool AttachLayerManager();
void MaybeShowFrame();
bool Show(const ScreenIntSize& aSize, bool aParentIsActive);
bool Show(const OwnerShowInfo&);
void UpdateDimensions(const nsIntRect& aRect, const ScreenIntSize& aSize);

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

@ -19,10 +19,12 @@
#include "Units.h"
namespace mozilla {
namespace dom {
class BrowserHost;
class BrowserBridgeHost;
class OwnerShowInfo;
/**
* An interface to control a browser hosted in another process.
@ -57,7 +59,7 @@ class RemoteBrowser : public nsISupports {
virtual void DestroyStart() = 0;
virtual void DestroyComplete() = 0;
virtual bool Show(const ScreenIntSize& aSize, bool aParentIsActive) = 0;
virtual bool Show(const OwnerShowInfo&) = 0;
virtual void UpdateDimensions(const nsIntRect& aRect,
const ScreenIntSize& aSize) = 0;