зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1500257 part 7 - Modify RenderFrame to hold onto TabParent instead of nsFrameLoader. r=aosmond
A TabParent for a remote subframe will have the same owner content as the top-level remote browser. This means that 'TabParent::GetFrameLoader()' will return the frame loader of the top-level remote browser. This is fine for getting the layer manager and compositor for connecting layer trees, but the frame loader is also used to acquire a TabParent for its process ID. This is incorrect in the remote subframe case, and will lead to the compositor rejecting layer transactions for the remote subframe because it will only accept them from the top-level remote browser's process. This commit switches RenderFrame to just hold on to TabParent, and acquire the nsFrameLoader as necessary. Another change is to RenderFrame::SetOwnerContent. Previously this method would take the new owner content and check an assertion. I don't see much value in the assertion, so I've removed it. Additionally, now that we acquire the owner content, and therefore the layer manager, from TabParent, we need to ensure that RenderFrame::SetOwnerContent is ran after the TabParent has had it's owner content updated. So the callsite has been moved into TabParent. This resolved a test failure with frame loader swapping. Differential Revision: https://phabricator.services.mozilla.com/D17447 --HG-- extra : source : 4c85fb68f2ed297828bf4646301c2d80d1c8e0a1 extra : intermediate-source : 62ad54fb95eb76f88865f43da1a5d556421e7884 extra : histedit_source : 6b7085118bca83433b26fcec3983a385bd536672
This commit is contained in:
Родитель
17b0dd2cd6
Коммит
a0478b2152
|
@ -1758,10 +1758,6 @@ void nsFrameLoader::SetOwnerContent(Element* aContent) {
|
|||
UpdateReflectorGlobal(jsapi.cx(), wrapper, rv);
|
||||
Unused << NS_WARN_IF(rv.Failed());
|
||||
}
|
||||
|
||||
if (RenderFrame* rfp = GetCurrentRenderFrame()) {
|
||||
rfp->OwnerContentChanged(aContent);
|
||||
}
|
||||
}
|
||||
|
||||
bool nsFrameLoader::OwnerIsMozBrowserFrame() {
|
||||
|
|
|
@ -304,6 +304,10 @@ void TabParent::SetOwnerElement(Element* aElement) {
|
|||
Unused << SendSetWidgetNativeData(widgetNativeData);
|
||||
}
|
||||
}
|
||||
|
||||
if (mRenderFrame.IsInitialized()) {
|
||||
mRenderFrame.OwnerContentChanged();
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP TabParent::GetOwnerElement(Element** aElement) {
|
||||
|
@ -617,16 +621,8 @@ void TabParent::LoadURL(nsIURI* aURI) {
|
|||
}
|
||||
|
||||
void TabParent::InitRendering() {
|
||||
RefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
|
||||
MOZ_ASSERT(!mRenderFrame.IsInitialized());
|
||||
MOZ_ASSERT(frameLoader);
|
||||
|
||||
if (!frameLoader) {
|
||||
return;
|
||||
}
|
||||
|
||||
mRenderFrame.Initialize(frameLoader);
|
||||
mRenderFrame.Initialize(this);
|
||||
MOZ_ASSERT(mRenderFrame.IsInitialized());
|
||||
|
||||
layers::LayersId layersId = mRenderFrame.GetLayersId();
|
||||
|
|
|
@ -28,43 +28,36 @@ using namespace mozilla::layers;
|
|||
namespace mozilla {
|
||||
namespace layout {
|
||||
|
||||
static already_AddRefed<LayerManager> GetLayerManager(
|
||||
nsFrameLoader* aFrameLoader) {
|
||||
if (nsIContent* content = aFrameLoader->GetOwnerContent()) {
|
||||
RefPtr<LayerManager> lm = nsContentUtils::LayerManagerForContent(content);
|
||||
if (lm) {
|
||||
static already_AddRefed<LayerManager> GetLayerManager(TabParent* aTabParent) {
|
||||
if (Element* element = aTabParent->GetOwnerElement()) {
|
||||
if (RefPtr<LayerManager> lm =
|
||||
nsContentUtils::LayerManagerForContent(element)) {
|
||||
return lm.forget();
|
||||
}
|
||||
return nsContentUtils::LayerManagerForDocument(element->OwnerDoc());
|
||||
}
|
||||
|
||||
Document* doc = aFrameLoader->GetOwnerDoc();
|
||||
if (!doc) {
|
||||
return nullptr;
|
||||
}
|
||||
return nsContentUtils::LayerManagerForDocument(doc);
|
||||
}
|
||||
|
||||
RenderFrame::RenderFrame()
|
||||
: mLayersId{0},
|
||||
mFrameLoader(nullptr),
|
||||
mTabParent(nullptr),
|
||||
mLayerManager(nullptr),
|
||||
mInitialized(false),
|
||||
mLayersConnected(false) {}
|
||||
|
||||
RenderFrame::~RenderFrame() {}
|
||||
|
||||
bool RenderFrame::Initialize(nsFrameLoader* aFrameLoader) {
|
||||
if (mInitialized || !aFrameLoader) {
|
||||
bool RenderFrame::Initialize(TabParent* aTabParent) {
|
||||
if (mInitialized || !aTabParent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mFrameLoader = aFrameLoader;
|
||||
RefPtr<LayerManager> lm = GetLayerManager(mFrameLoader);
|
||||
mTabParent = aTabParent;
|
||||
RefPtr<LayerManager> lm = GetLayerManager(mTabParent);
|
||||
PCompositorBridgeChild* compositor =
|
||||
lm ? lm->GetCompositorBridgeChild() : nullptr;
|
||||
|
||||
TabParent* browser = TabParent::GetFrom(aFrameLoader);
|
||||
mTabProcessId = browser->Manager()->AsContentParent()->OtherPid();
|
||||
mTabProcessId = mTabParent->Manager()->AsContentParent()->OtherPid();
|
||||
|
||||
// Our remote frame will push layers updates to the compositor,
|
||||
// and we'll keep an indirect reference to that tree.
|
||||
|
@ -81,12 +74,12 @@ void RenderFrame::Destroy() {
|
|||
GPUProcessManager::Get()->UnmapLayerTreeId(mLayersId, mTabProcessId);
|
||||
}
|
||||
|
||||
mFrameLoader = nullptr;
|
||||
mTabParent = nullptr;
|
||||
mLayerManager = nullptr;
|
||||
}
|
||||
|
||||
void RenderFrame::EnsureLayersConnected(CompositorOptions* aCompositorOptions) {
|
||||
RefPtr<LayerManager> lm = GetLayerManager(mFrameLoader);
|
||||
RefPtr<LayerManager> lm = GetLayerManager(mTabParent);
|
||||
if (!lm) {
|
||||
return;
|
||||
}
|
||||
|
@ -102,8 +95,8 @@ void RenderFrame::EnsureLayersConnected(CompositorOptions* aCompositorOptions) {
|
|||
|
||||
LayerManager* RenderFrame::AttachLayerManager() {
|
||||
RefPtr<LayerManager> lm;
|
||||
if (mFrameLoader) {
|
||||
lm = GetLayerManager(mFrameLoader);
|
||||
if (mTabParent) {
|
||||
lm = GetLayerManager(mTabParent);
|
||||
}
|
||||
|
||||
// Perhaps the document containing this frame currently has no presentation?
|
||||
|
@ -117,17 +110,11 @@ LayerManager* RenderFrame::AttachLayerManager() {
|
|||
return mLayerManager;
|
||||
}
|
||||
|
||||
void RenderFrame::OwnerContentChanged(nsIContent* aContent) {
|
||||
MOZ_ASSERT(!mFrameLoader || mFrameLoader->GetOwnerContent() == aContent,
|
||||
"Don't build new map if owner is same!");
|
||||
|
||||
Unused << AttachLayerManager();
|
||||
}
|
||||
void RenderFrame::OwnerContentChanged() { Unused << AttachLayerManager(); }
|
||||
|
||||
void RenderFrame::GetTextureFactoryIdentifier(
|
||||
TextureFactoryIdentifier* aTextureFactoryIdentifier) const {
|
||||
RefPtr<LayerManager> lm =
|
||||
mFrameLoader ? GetLayerManager(mFrameLoader) : nullptr;
|
||||
RefPtr<LayerManager> lm = mTabParent ? GetLayerManager(mTabParent) : nullptr;
|
||||
// Perhaps the document containing this frame currently has no presentation?
|
||||
if (lm) {
|
||||
*aTextureFactoryIdentifier = lm->GetTextureFactoryIdentifier();
|
||||
|
|
|
@ -21,6 +21,10 @@ class nsSubDocumentFrame;
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
namespace dom {
|
||||
class TabParent;
|
||||
} // namespace dom
|
||||
|
||||
namespace layers {
|
||||
struct TextureFactoryIdentifier;
|
||||
} // namespace layers
|
||||
|
@ -41,14 +45,13 @@ class RenderFrame final {
|
|||
RenderFrame();
|
||||
virtual ~RenderFrame();
|
||||
|
||||
bool Initialize(nsFrameLoader* aFrameLoader);
|
||||
bool Initialize(dom::TabParent* aTabParent);
|
||||
void Destroy();
|
||||
|
||||
void EnsureLayersConnected(CompositorOptions* aCompositorOptions);
|
||||
LayerManager* AttachLayerManager();
|
||||
void OwnerContentChanged(nsIContent* aContent);
|
||||
void OwnerContentChanged();
|
||||
|
||||
nsFrameLoader* GetFrameLoader() const { return mFrameLoader; }
|
||||
LayersId GetLayersId() const { return mLayersId; }
|
||||
CompositorOptions GetCompositorOptions() const { return mCompositorOptions; }
|
||||
|
||||
|
@ -69,7 +72,7 @@ class RenderFrame final {
|
|||
// mLayersConnected is true).
|
||||
CompositorOptions mCompositorOptions;
|
||||
|
||||
RefPtr<nsFrameLoader> mFrameLoader;
|
||||
dom::TabParent* mTabParent;
|
||||
RefPtr<LayerManager> mLayerManager;
|
||||
|
||||
bool mInitialized;
|
||||
|
|
Загрузка…
Ссылка в новой задаче