Context: I'm trying to make Thunderbird E10s-compatible. We have
<browser>s that can display web content or email messages. For now,
email messages are going to have to be in the parent process. So, I need
to be able to switch the remoteness of a <browser> in both directions.
I may be barking up the wrong tree completely here. Don't laugh at me. :-)
I've borrowed this code from Firefox
<https://searchfox.org/mozilla-central/source/browser/base/content/tabbrowser.js#1832-1851>
and that works perfectly (well, after I fix a few other things that
aren't relevant here). I can put that in a wrapper function to decide
which remote type to use, do the switch if necessary, and load the page.
If I switch to a non-remote browser then load a message, that works too.
However. The code for displaying messages is C++ all the way down. I
want to be able to switch to the parent process and continue as before.
Here's what I've managed to figure out:
nsCOMPtr<nsPIDOMWindowOuter> win = nsPIDOMWindowOuter::From(mWindow);
nsIDocShell* rootShell = win->GetDocShell();
RefPtr<mozilla::dom::Element> el =
rootShell->GetDocument()->GetElementById(u"messagepane"_ns);
RefPtr<mozilla::dom::XULFrameElement> frame =
mozilla::dom::XULFrameElement::FromNodeOrNull(el);
uint64_t browserId = frame->BrowserId();
RefPtr<CanonicalBrowsingContext> browsingContext =
CanonicalBrowsingContext::Cast(
BrowsingContext::GetCurrentTopByBrowserId(browserId));
browsingContext->ChangeRemoteness(NOT_REMOTE_TYPE, 1, false, 0)
->Then(
GetMainThreadSerialEventTarget(), __func__,
[&](BrowserParent* aBrowserParent) {
fprintf(stderr, "success\n");
/* Can I get a docShell here?!! */
return NS_OK;
},
[&](nsresult aStatusCode) {
fprintf(stderr, "failure\n");
});
This works, the browser changes remoteness. Now I need a docShell for
the next piece of the process, and this is where I'm stuck.
I'm not sure I've got the arguments to ChangeRemoteness right. I made up
the second as a non-zero value is required, I think I understand the
third but browsingContext is discarded regardless, and I don't know
anything about the fourth.
What do I do here?
GL
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform