Bug 1353814 - Use PuppetWidget with windowless browsers. r=jrmuizel

During the creation of windowless browsers in non-headless mode there can
still be calls into GTK which isn't initialized with the HeadlessWidget.
This commit is contained in:
Brendan Dahl 2017-04-05 11:20:00 -04:00
parent 338a860d27
commit ea4ae58e28

View File

@ -44,6 +44,7 @@
#include "nsEmbedCID.h"
#include "nsIWebBrowser.h"
#include "nsIDocShell.h"
#include "gfxPlatform.h"
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
#include "EventTracer.h"
@ -523,12 +524,17 @@ nsAppShellService::CreateWindowlessBrowser(bool aIsChrome, nsIWindowlessBrowser
/* A windowless web browser doesn't have an associated OS level window. To
* accomplish this, we initialize the window associated with our instance of
* nsWebBrowser with an instance of PuppetWidget, which provides a stub
* implementation of nsIWidget.
* nsWebBrowser with an instance of HeadlessWidget/PuppetWidget, which provide
* a stub implementation of nsIWidget.
*/
nsCOMPtr<nsIWidget> widget = nsIWidget::CreateHeadlessWidget();
nsCOMPtr<nsIWidget> widget;
if (gfxPlatform::IsHeadless()) {
widget = nsIWidget::CreateHeadlessWidget();
} else {
widget = nsIWidget::CreatePuppetWidget(nullptr);
}
if (!widget) {
NS_ERROR("Couldn't create instance of PuppetWidget");
NS_ERROR("Couldn't create instance of stub widget");
return NS_ERROR_FAILURE;
}
nsresult rv =