зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1085655 - Improve TabChild::InitRenderingState() r=bent
This commit is contained in:
Родитель
7c94bec4c4
Коммит
148067068a
|
@ -1024,6 +1024,7 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
|
|||
}
|
||||
nsRefPtr<TabParent> tp(new TabParent(constructorSender, tabId,
|
||||
aContext, chromeFlags));
|
||||
tp->SetInitedByParent();
|
||||
tp->SetOwnerElement(aFrameElement);
|
||||
|
||||
PBrowserParent* browser = constructorSender->SendPBrowserConstructor(
|
||||
|
@ -1135,6 +1136,7 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
|
|||
uint32_t chromeFlags = 0;
|
||||
|
||||
nsRefPtr<TabParent> tp = new TabParent(parent, tabId, aContext, chromeFlags);
|
||||
tp->SetInitedByParent();
|
||||
tp->SetOwnerElement(aFrameElement);
|
||||
PBrowserParent* browser = parent->SendPBrowserConstructor(
|
||||
// DeallocPBrowserParent() releases this ref.
|
||||
|
|
|
@ -85,6 +85,12 @@ both:
|
|||
AsyncMessage(nsString aMessage, ClonedMessageData aData, CpowEntry[] aCpows,
|
||||
Principal aPrincipal);
|
||||
|
||||
/**
|
||||
* Create a layout frame (encapsulating a remote layer tree) for
|
||||
* the page that is currently loaded in the <browser>.
|
||||
*/
|
||||
PRenderFrame();
|
||||
|
||||
parent:
|
||||
/*
|
||||
* Creates a new remoted nsIWidget connection for windowed plugins
|
||||
|
@ -317,16 +323,6 @@ parent:
|
|||
*/
|
||||
PIndexedDBPermissionRequest(Principal principal);
|
||||
|
||||
/**
|
||||
* Create a layout frame (encapsulating a remote layer tree) for
|
||||
* the page that is currently loaded in the <browser>.
|
||||
*/
|
||||
sync PRenderFrame()
|
||||
returns (ScrollingBehavior scrolling,
|
||||
TextureFactoryIdentifier textureFactoryIdentifier, uint64_t layersId,
|
||||
bool success);
|
||||
|
||||
|
||||
/**
|
||||
* window.open from inside <iframe mozbrowser> is special. When the child
|
||||
* process calls window.open, it creates a new PBrowser (in its own
|
||||
|
@ -392,6 +388,11 @@ parent:
|
|||
*/
|
||||
async RemotePaintIsReady();
|
||||
|
||||
sync GetRenderFrameInfo(PRenderFrame aRenderFrame)
|
||||
returns (ScrollingBehavior scrolling,
|
||||
TextureFactoryIdentifier textureFactoryIdentifier,
|
||||
uint64_t layersId);
|
||||
|
||||
child:
|
||||
/**
|
||||
* Notify the remote browser that it has been Show()n on this
|
||||
|
@ -402,7 +403,11 @@ child:
|
|||
* content processes always render to a virtual <0, 0> top-left
|
||||
* point.
|
||||
*/
|
||||
Show(nsIntSize size);
|
||||
Show(nsIntSize size,
|
||||
ScrollingBehavior scrolling,
|
||||
TextureFactoryIdentifier textureFactoryIdentifier,
|
||||
uint64_t layersId,
|
||||
nullable PRenderFrame renderFrame);
|
||||
|
||||
LoadURL(nsCString uri);
|
||||
|
||||
|
|
|
@ -1511,9 +1511,22 @@ TabChild::BrowserFrameProvideWindow(nsIDOMWindow* aOpener,
|
|||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
ScrollingBehavior scrolling = DEFAULT_SCROLLING;
|
||||
TextureFactoryIdentifier textureFactoryIdentifier;
|
||||
uint64_t layersId = 0;
|
||||
PRenderFrameChild* renderFrame = newChild->SendPRenderFrameConstructor();
|
||||
newChild->SendGetRenderFrameInfo(renderFrame,
|
||||
&scrolling,
|
||||
&textureFactoryIdentifier,
|
||||
&layersId);
|
||||
if (layersId == 0) { // if renderFrame is invalid.
|
||||
PRenderFrameChild::Send__delete__(renderFrame);
|
||||
renderFrame = nullptr;
|
||||
}
|
||||
|
||||
// Unfortunately we don't get a window unless we've shown the frame. That's
|
||||
// pretty bogus; see bug 763602.
|
||||
newChild->DoFakeShow();
|
||||
newChild->DoFakeShow(scrolling, textureFactoryIdentifier, layersId, renderFrame);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> win = do_GetInterface(newChild->WebNavigation());
|
||||
win.forget(aReturn);
|
||||
|
@ -1828,9 +1841,12 @@ TabChild::CancelCachedFileDescriptorCallback(
|
|||
}
|
||||
|
||||
void
|
||||
TabChild::DoFakeShow()
|
||||
TabChild::DoFakeShow(const ScrollingBehavior& aScrolling,
|
||||
const TextureFactoryIdentifier& aTextureFactoryIdentifier,
|
||||
const uint64_t& aLayersId,
|
||||
PRenderFrameChild* aRenderFrame)
|
||||
{
|
||||
RecvShow(nsIntSize(0, 0));
|
||||
RecvShow(nsIntSize(0, 0), aScrolling, aTextureFactoryIdentifier, aLayersId, aRenderFrame);
|
||||
mDidFakeShow = true;
|
||||
}
|
||||
|
||||
|
@ -1893,8 +1909,13 @@ TabChild::MaybeRequestPreinitCamera()
|
|||
#endif
|
||||
|
||||
bool
|
||||
TabChild::RecvShow(const nsIntSize& size)
|
||||
TabChild::RecvShow(const nsIntSize& aSize,
|
||||
const ScrollingBehavior& aScrolling,
|
||||
const TextureFactoryIdentifier& aTextureFactoryIdentifier,
|
||||
const uint64_t& aLayersId,
|
||||
PRenderFrameChild* aRenderFrame)
|
||||
{
|
||||
MOZ_ASSERT((!mDidFakeShow && aRenderFrame) || (mDidFakeShow && !aRenderFrame));
|
||||
|
||||
if (mDidFakeShow) {
|
||||
return true;
|
||||
|
@ -1906,7 +1927,7 @@ TabChild::RecvShow(const nsIntSize& size)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!InitRenderingState()) {
|
||||
if (!InitRenderingState(aScrolling, aTextureFactoryIdentifier, aLayersId, aRenderFrame)) {
|
||||
// We can fail to initialize our widget if the <browser
|
||||
// remote> has already been destroyed, and we couldn't hook
|
||||
// into the parent-process's layer system. That's not a fatal
|
||||
|
@ -2748,10 +2769,7 @@ TabChild::RecvSetIsDocShellActive(const bool& aIsActive)
|
|||
}
|
||||
|
||||
PRenderFrameChild*
|
||||
TabChild::AllocPRenderFrameChild(ScrollingBehavior* aScrolling,
|
||||
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
||||
uint64_t* aLayersId,
|
||||
bool* aSuccess)
|
||||
TabChild::AllocPRenderFrameChild()
|
||||
{
|
||||
return new RenderFrameChild();
|
||||
}
|
||||
|
@ -2804,43 +2822,40 @@ TabChild::InitTabChildGlobal(FrameScriptLoading aScriptLoading)
|
|||
}
|
||||
|
||||
bool
|
||||
TabChild::InitRenderingState()
|
||||
TabChild::InitRenderingState(const ScrollingBehavior& aScrolling,
|
||||
const TextureFactoryIdentifier& aTextureFactoryIdentifier,
|
||||
const uint64_t& aLayersId,
|
||||
PRenderFrameChild* aRenderFrame)
|
||||
{
|
||||
static_cast<PuppetWidget*>(mWidget.get())->InitIMEState();
|
||||
|
||||
uint64_t id;
|
||||
bool success;
|
||||
RenderFrameChild* remoteFrame =
|
||||
static_cast<RenderFrameChild*>(SendPRenderFrameConstructor(
|
||||
&mScrolling,
|
||||
&mTextureFactoryIdentifier, &id,
|
||||
&success));
|
||||
RenderFrameChild* remoteFrame = static_cast<RenderFrameChild*>(aRenderFrame);
|
||||
if (!remoteFrame) {
|
||||
NS_WARNING("failed to construct RenderFrame");
|
||||
return false;
|
||||
}
|
||||
if (!success) {
|
||||
NS_WARNING("failed to construct RenderFrame");
|
||||
PRenderFrameChild::Send__delete__(remoteFrame);
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(id != 0);
|
||||
MOZ_ASSERT(aLayersId != 0);
|
||||
mScrolling = aScrolling;
|
||||
mTextureFactoryIdentifier = aTextureFactoryIdentifier;
|
||||
|
||||
// Pushing layers transactions directly to a separate
|
||||
// compositor context.
|
||||
PCompositorChild* compositorChild = CompositorChild::Get();
|
||||
if (!compositorChild) {
|
||||
NS_WARNING("failed to get CompositorChild instance");
|
||||
PRenderFrameChild::Send__delete__(remoteFrame);
|
||||
return false;
|
||||
}
|
||||
nsTArray<LayersBackend> backends;
|
||||
backends.AppendElement(mTextureFactoryIdentifier.mParentBackend);
|
||||
bool success;
|
||||
PLayerTransactionChild* shadowManager =
|
||||
compositorChild->SendPLayerTransactionConstructor(backends,
|
||||
id, &mTextureFactoryIdentifier, &success);
|
||||
aLayersId, &mTextureFactoryIdentifier, &success);
|
||||
if (!success) {
|
||||
NS_WARNING("failed to properly allocate layer transaction");
|
||||
PRenderFrameChild::Send__delete__(remoteFrame);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2860,13 +2875,13 @@ TabChild::InitRenderingState()
|
|||
ImageBridgeChild::IdentifyCompositorTextureHost(mTextureFactoryIdentifier);
|
||||
|
||||
mRemoteFrame = remoteFrame;
|
||||
if (id != 0) {
|
||||
if (aLayersId != 0) {
|
||||
if (!sTabChildren) {
|
||||
sTabChildren = new TabChildMap;
|
||||
}
|
||||
MOZ_ASSERT(!sTabChildren->Get(id));
|
||||
sTabChildren->Put(id, this);
|
||||
mLayersId = id;
|
||||
MOZ_ASSERT(!sTabChildren->Get(aLayersId));
|
||||
sTabChildren->Put(aLayersId, this);
|
||||
mLayersId = aLayersId;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
|
|
|
@ -316,7 +316,11 @@ public:
|
|||
virtual bool RecvCacheFileDescriptor(const nsString& aPath,
|
||||
const FileDescriptor& aFileDescriptor)
|
||||
MOZ_OVERRIDE;
|
||||
virtual bool RecvShow(const nsIntSize& size) MOZ_OVERRIDE;
|
||||
virtual bool RecvShow(const nsIntSize& aSize,
|
||||
const ScrollingBehavior& aScrolling,
|
||||
const TextureFactoryIdentifier& aTextureFactoryIdentifier,
|
||||
const uint64_t& aLayersId,
|
||||
PRenderFrameChild* aRenderFrame) MOZ_OVERRIDE;
|
||||
virtual bool RecvUpdateDimensions(const nsIntRect& rect,
|
||||
const nsIntSize& size,
|
||||
const ScreenOrientation& orientation) MOZ_OVERRIDE;
|
||||
|
@ -491,10 +495,7 @@ public:
|
|||
protected:
|
||||
virtual ~TabChild();
|
||||
|
||||
virtual PRenderFrameChild* AllocPRenderFrameChild(ScrollingBehavior* aScrolling,
|
||||
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
||||
uint64_t* aLayersId,
|
||||
bool* aSuccess) MOZ_OVERRIDE;
|
||||
virtual PRenderFrameChild* AllocPRenderFrameChild() MOZ_OVERRIDE;
|
||||
virtual bool DeallocPRenderFrameChild(PRenderFrameChild* aFrame) MOZ_OVERRIDE;
|
||||
virtual bool RecvDestroy() MOZ_OVERRIDE;
|
||||
virtual bool RecvSetUpdateHitRegion(const bool& aEnabled) MOZ_OVERRIDE;
|
||||
|
@ -536,12 +537,18 @@ private:
|
|||
|
||||
enum FrameScriptLoading { DONT_LOAD_SCRIPTS, DEFAULT_LOAD_SCRIPTS };
|
||||
bool InitTabChildGlobal(FrameScriptLoading aScriptLoading = DEFAULT_LOAD_SCRIPTS);
|
||||
bool InitRenderingState();
|
||||
bool InitRenderingState(const ScrollingBehavior& aScrolling,
|
||||
const TextureFactoryIdentifier& aTextureFactoryIdentifier,
|
||||
const uint64_t& aLayersId,
|
||||
PRenderFrameChild* aRenderFrame);
|
||||
void DestroyWindow();
|
||||
void SetProcessNameToAppName();
|
||||
|
||||
// Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow().
|
||||
void DoFakeShow();
|
||||
void DoFakeShow(const ScrollingBehavior& aScrolling,
|
||||
const TextureFactoryIdentifier& aTextureFactoryIdentifier,
|
||||
const uint64_t& aLayersId,
|
||||
PRenderFrameChild* aRenderFrame);
|
||||
|
||||
// These methods are used for tracking synthetic mouse events
|
||||
// dispatched for compatibility. On each touch event, we
|
||||
|
|
|
@ -248,6 +248,7 @@ TabParent::TabParent(nsIContentParent* aManager,
|
|||
, mAppPackageFileDescriptorSent(false)
|
||||
, mSendOfflineStatus(true)
|
||||
, mChromeFlags(aChromeFlags)
|
||||
, mInitedByParent(false)
|
||||
, mTabId(aTabId)
|
||||
{
|
||||
MOZ_ASSERT(aManager);
|
||||
|
@ -573,9 +574,33 @@ TabParent::Show(const nsIntSize& size)
|
|||
// sigh
|
||||
mShown = true;
|
||||
mDimensions = size;
|
||||
if (!mIsDestroyed) {
|
||||
unused << SendShow(size);
|
||||
if (mIsDestroyed) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScrollingBehavior scrolling = UseAsyncPanZoom() ? ASYNC_PAN_ZOOM : DEFAULT_SCROLLING;
|
||||
TextureFactoryIdentifier textureFactoryIdentifier;
|
||||
uint64_t layersId = 0;
|
||||
bool success = false;
|
||||
RenderFrameParent* renderFrame = nullptr;
|
||||
// If TabParent is initialized by parent side then the RenderFrame must also
|
||||
// be created here. If TabParent is initialized by child side,
|
||||
// child side will create RenderFrame.
|
||||
MOZ_ASSERT(!GetRenderFrame());
|
||||
if (IsInitedByParent()) {
|
||||
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
if (frameLoader) {
|
||||
renderFrame =
|
||||
new RenderFrameParent(frameLoader,
|
||||
scrolling,
|
||||
&textureFactoryIdentifier,
|
||||
&layersId,
|
||||
&success);
|
||||
MOZ_ASSERT(success);
|
||||
unused << SendPRenderFrameConstructor(renderFrame);
|
||||
}
|
||||
}
|
||||
unused << SendShow(size, scrolling, textureFactoryIdentifier, layersId, renderFrame);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1911,18 +1936,26 @@ TabParent::DeallocPColorPickerParent(PColorPickerParent* actor)
|
|||
}
|
||||
|
||||
PRenderFrameParent*
|
||||
TabParent::AllocPRenderFrameParent(ScrollingBehavior* aScrolling,
|
||||
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
||||
uint64_t* aLayersId, bool* aSuccess)
|
||||
TabParent::AllocPRenderFrameParent()
|
||||
{
|
||||
MOZ_ASSERT(ManagedPRenderFrameParent().IsEmpty());
|
||||
|
||||
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
*aScrolling = UseAsyncPanZoom() ? ASYNC_PAN_ZOOM : DEFAULT_SCROLLING;
|
||||
return new RenderFrameParent(frameLoader,
|
||||
*aScrolling,
|
||||
aTextureFactoryIdentifier, aLayersId,
|
||||
aSuccess);
|
||||
ScrollingBehavior scrolling = UseAsyncPanZoom() ? ASYNC_PAN_ZOOM : DEFAULT_SCROLLING;
|
||||
TextureFactoryIdentifier textureFactoryIdentifier;
|
||||
uint64_t layersId = 0;
|
||||
bool success = false;
|
||||
if(frameLoader) {
|
||||
PRenderFrameParent* renderFrame =
|
||||
new RenderFrameParent(frameLoader,
|
||||
scrolling,
|
||||
&textureFactoryIdentifier,
|
||||
&layersId,
|
||||
&success);
|
||||
MOZ_ASSERT(success);
|
||||
return renderFrame;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1932,6 +1965,19 @@ TabParent::DeallocPRenderFrameParent(PRenderFrameParent* aFrame)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TabParent::RecvGetRenderFrameInfo(PRenderFrameParent* aRenderFrame,
|
||||
ScrollingBehavior* aScrolling,
|
||||
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
||||
uint64_t* aLayersId)
|
||||
{
|
||||
RenderFrameParent* renderFrame = static_cast<RenderFrameParent*>(aRenderFrame);
|
||||
*aScrolling = renderFrame->UseAsyncPanZoom() ? ASYNC_PAN_ZOOM : DEFAULT_SCROLLING;
|
||||
renderFrame->GetTextureFactoryIdentifier(aTextureFactoryIdentifier);
|
||||
*aLayersId = renderFrame->GetLayersId();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TabParent::AllowContentIME()
|
||||
{
|
||||
|
@ -2021,16 +2067,6 @@ TabParent::RecvBrowserFrameOpenWindow(PBrowserParent* aOpener,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TabParent::RecvPRenderFrameConstructor(PRenderFrameParent* aActor,
|
||||
ScrollingBehavior* aScrolling,
|
||||
TextureFactoryIdentifier* aFactoryIdentifier,
|
||||
uint64_t* aLayersId,
|
||||
bool* aSuccess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TabParent::RecvZoomToRect(const uint32_t& aPresShellId,
|
||||
const ViewID& aViewId,
|
||||
|
|
|
@ -128,11 +128,6 @@ public:
|
|||
virtual bool RecvEvent(const RemoteDOMEvent& aEvent) MOZ_OVERRIDE;
|
||||
virtual bool RecvReplyKeyEvent(const WidgetKeyboardEvent& event);
|
||||
virtual bool RecvDispatchAfterKeyboardEvent(const WidgetKeyboardEvent& event);
|
||||
virtual bool RecvPRenderFrameConstructor(PRenderFrameParent* aActor,
|
||||
ScrollingBehavior* aScrolling,
|
||||
TextureFactoryIdentifier* aFactoryIdentifier,
|
||||
uint64_t* aLayersId,
|
||||
bool* aSuccess) MOZ_OVERRIDE;
|
||||
virtual bool RecvBrowserFrameOpenWindow(PBrowserParent* aOpener,
|
||||
const nsString& aURL,
|
||||
const nsString& aName,
|
||||
|
@ -341,6 +336,9 @@ public:
|
|||
virtual PPluginWidgetParent* AllocPPluginWidgetParent() MOZ_OVERRIDE;
|
||||
virtual bool DeallocPPluginWidgetParent(PPluginWidgetParent* aActor) MOZ_OVERRIDE;
|
||||
|
||||
void SetInitedByParent() { mInitedByParent = true; }
|
||||
bool IsInitedByParent() const { return mInitedByParent; }
|
||||
|
||||
protected:
|
||||
bool ReceiveMessage(const nsString& aMessage,
|
||||
bool aSync,
|
||||
|
@ -362,14 +360,16 @@ protected:
|
|||
|
||||
bool AllowContentIME();
|
||||
|
||||
virtual PRenderFrameParent* AllocPRenderFrameParent(ScrollingBehavior* aScrolling,
|
||||
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
||||
uint64_t* aLayersId,
|
||||
bool* aSuccess) MOZ_OVERRIDE;
|
||||
virtual PRenderFrameParent* AllocPRenderFrameParent() MOZ_OVERRIDE;
|
||||
virtual bool DeallocPRenderFrameParent(PRenderFrameParent* aFrame) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool RecvRemotePaintIsReady() MOZ_OVERRIDE;
|
||||
|
||||
virtual bool RecvGetRenderFrameInfo(PRenderFrameParent* aRenderFrame,
|
||||
ScrollingBehavior* aScrolling,
|
||||
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
||||
uint64_t* aLayersId) MOZ_OVERRIDE;
|
||||
|
||||
bool SendCompositionChangeEvent(mozilla::WidgetCompositionEvent& event);
|
||||
|
||||
// IME
|
||||
|
@ -445,6 +445,10 @@ private:
|
|||
|
||||
uint32_t mChromeFlags;
|
||||
|
||||
// When true, the TabParent is initialized without child side's request.
|
||||
// When false, the TabParent is initialized by window.open() from child side.
|
||||
bool mInitedByParent;
|
||||
|
||||
nsCOMPtr<nsILoadContext> mLoadContext;
|
||||
|
||||
TabId mTabId;
|
||||
|
|
|
@ -565,6 +565,19 @@ RenderFrameParent::HitTest(const nsRect& aRect)
|
|||
return mTouchRegion.Contains(aRect);
|
||||
}
|
||||
|
||||
void
|
||||
RenderFrameParent::GetTextureFactoryIdentifier(TextureFactoryIdentifier* aTextureFactoryIdentifier)
|
||||
{
|
||||
nsRefPtr<LayerManager> lm = GetFrom(mFrameLoader);
|
||||
// Perhaps the document containing this frame currently has no presentation?
|
||||
if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
||||
*aTextureFactoryIdentifier =
|
||||
static_cast<ClientLayerManager*>(lm.get())->GetTextureFactoryIdentifier();
|
||||
} else {
|
||||
*aTextureFactoryIdentifier = TextureFactoryIdentifier();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace layout
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -109,6 +109,11 @@ public:
|
|||
|
||||
bool HitTest(const nsRect& aRect);
|
||||
|
||||
bool UseAsyncPanZoom() { return !!mContentController; }
|
||||
|
||||
void GetTextureFactoryIdentifier(TextureFactoryIdentifier* aTextureFactoryIdentifier);
|
||||
|
||||
inline uint64_t GetLayersId() { return mLayersId; }
|
||||
protected:
|
||||
void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче