mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-04 22:37:29 +09:00
parent
04b285b848
commit
75d698133f
22 changed files with 16 additions and 879 deletions
|
|
@ -319,8 +319,6 @@ private:
|
|||
};
|
||||
|
||||
namespace {
|
||||
StaticRefPtr<TabChild> sPreallocatedTab;
|
||||
|
||||
std::map<TabId, RefPtr<TabChild>>&
|
||||
NestedTabChildMap()
|
||||
{
|
||||
|
|
@ -341,91 +339,13 @@ TabChild::FindTabChild(const TabId& aTabId)
|
|||
return tabChild.forget();
|
||||
}
|
||||
|
||||
static void
|
||||
PreloadSlowThingsPostFork(void* aUnused)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
observerService->NotifyObservers(nullptr, "preload-postfork", nullptr);
|
||||
|
||||
MOZ_ASSERT(sPreallocatedTab);
|
||||
// Initialize initial reflow of the PresShell has to happen after fork
|
||||
// because about:blank content viewer is created in the above observer
|
||||
// notification.
|
||||
nsCOMPtr<nsIDocShell> docShell =
|
||||
do_GetInterface(sPreallocatedTab->WebNavigation());
|
||||
if (nsIPresShell* presShell = docShell->GetPresShell()) {
|
||||
// Initialize and do an initial reflow of the about:blank
|
||||
// PresShell to let it preload some things for us.
|
||||
presShell->Initialize(0, 0);
|
||||
nsIDocument* doc = presShell->GetDocument();
|
||||
doc->FlushPendingNotifications(Flush_Layout);
|
||||
// ... but after it's done, make sure it doesn't do any more
|
||||
// work.
|
||||
presShell->MakeZombie();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static bool sPreloaded = false;
|
||||
|
||||
/*static*/ void
|
||||
TabChild::PreloadSlowThings()
|
||||
{
|
||||
if (sPreloaded) {
|
||||
// If we are alredy initialized in Nuwa, don't redo preloading.
|
||||
return;
|
||||
}
|
||||
sPreloaded = true;
|
||||
|
||||
// Pass nullptr to aManager since at this point the TabChild is
|
||||
// not connected to any manager. Any attempt to use the TabChild
|
||||
// in IPC will crash.
|
||||
RefPtr<TabChild> tab(new TabChild(nullptr,
|
||||
TabId(0),
|
||||
TabContext(), /* chromeFlags */ 0));
|
||||
if (!NS_SUCCEEDED(tab->Init()) ||
|
||||
!tab->InitTabChildGlobal(DONT_LOAD_SCRIPTS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Just load and compile these scripts, but don't run them.
|
||||
tab->TryCacheLoadAndCompileScript(BROWSER_ELEMENT_CHILD_SCRIPT, true);
|
||||
// Load, compile, and run these scripts.
|
||||
tab->RecvLoadRemoteScript(
|
||||
NS_LITERAL_STRING("chrome://global/content/preload.js"),
|
||||
true);
|
||||
|
||||
sPreallocatedTab = tab;
|
||||
ClearOnShutdown(&sPreallocatedTab);
|
||||
|
||||
PreloadSlowThingsPostFork(nullptr);
|
||||
}
|
||||
|
||||
/*static*/ already_AddRefed<TabChild>
|
||||
TabChild::Create(nsIContentChild* aManager,
|
||||
const TabId& aTabId,
|
||||
const TabContext &aContext,
|
||||
uint32_t aChromeFlags)
|
||||
{
|
||||
if (sPreallocatedTab &&
|
||||
sPreallocatedTab->mChromeFlags == aChromeFlags &&
|
||||
aContext.IsMozBrowser()) {
|
||||
|
||||
RefPtr<TabChild> child = sPreallocatedTab.get();
|
||||
sPreallocatedTab = nullptr;
|
||||
|
||||
MOZ_ASSERT(!child->mTriedBrowserInit);
|
||||
|
||||
child->mManager = aManager;
|
||||
child->SetTabId(aTabId);
|
||||
child->SetTabContext(aContext);
|
||||
child->NotifyTabContextUpdated(true);
|
||||
return child.forget();
|
||||
}
|
||||
|
||||
RefPtr<TabChild> iframe = new TabChild(aManager, aTabId,
|
||||
aContext, aChromeFlags);
|
||||
RefPtr<TabChild> iframe = new TabChild(aManager, aTabId, aContext, aChromeFlags);
|
||||
return NS_SUCCEEDED(iframe->Init()) ? iframe.forget() : nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -614,13 +534,6 @@ TabChild::DoUpdateZoomConstraints(const uint32_t& aPresShellId,
|
|||
const ViewID& aViewId,
|
||||
const Maybe<ZoomConstraints>& aConstraints)
|
||||
{
|
||||
if (sPreallocatedTab == this) {
|
||||
// If we're the preallocated tab, bail out because doing IPC will crash.
|
||||
// Once we get used for something we'll get another zoom constraints update
|
||||
// and all will be well.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mApzcTreeManager) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2446,7 +2359,7 @@ TabChild::DeallocPRenderFrameChild(PRenderFrameChild* aFrame)
|
|||
}
|
||||
|
||||
bool
|
||||
TabChild::InitTabChildGlobal(FrameScriptLoading aScriptLoading)
|
||||
TabChild::InitTabChildGlobal()
|
||||
{
|
||||
if (!mGlobal && !mTabChildGlobal) {
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation());
|
||||
|
|
@ -2470,7 +2383,7 @@ TabChild::InitTabChildGlobal(FrameScriptLoading aScriptLoading)
|
|||
root->SetParentTarget(scope);
|
||||
}
|
||||
|
||||
if (aScriptLoading != DONT_LOAD_SCRIPTS && !mTriedBrowserInit) {
|
||||
if (!mTriedBrowserInit) {
|
||||
mTriedBrowserInit = true;
|
||||
// Initialize the child side of the browser element machinery,
|
||||
// if appropriate.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue