Bug 1590551. Allow nsPresContext::GetNearestWidget to work when there is no frame tree. r=botond

Differential Revision: https://phabricator.services.mozilla.com/D50135

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Timothy Nikkel 2019-10-23 23:37:11 +00:00
Родитель 57dbb44533
Коммит ede6368cfb
3 изменённых файлов: 10 добавлений и 10 удалений

Просмотреть файл

@ -10506,15 +10506,13 @@ RefPtr<MobileViewportManager> PresShell::GetMobileViewportManager() const {
bool UseMobileViewportManager(PresShell* aPresShell, Document* aDocument) {
// If we're not using APZ, we won't be able to zoom, so there is no
// point in having an MVM.
if (nsViewManager* viewManager = aPresShell->GetViewManager()) {
if (nsView* view = viewManager->GetRootView()) {
if (nsIWidget* widget = view->GetNearestWidget(nullptr)) {
if (nsPresContext* presContext = aPresShell->GetPresContext()) {
if (nsIWidget* widget = presContext->GetNearestWidget()) {
if (!widget->AsyncPanZoomEnabled()) {
return false;
}
}
}
}
return nsLayoutUtils::ShouldHandleMetaViewport(aDocument) ||
nsLayoutUtils::AllowZoomingForDocument(aDocument);
}

Просмотреть файл

@ -817,9 +817,11 @@ nsPresContext* nsPresContext::GetToplevelContentDocumentPresContext() {
nsIWidget* nsPresContext::GetNearestWidget(nsPoint* aOffset) {
NS_ENSURE_TRUE(mPresShell, nullptr);
nsIFrame* frame = mPresShell->GetRootFrame();
NS_ENSURE_TRUE(frame, nullptr);
return frame->GetView()->GetNearestWidget(aOffset);
nsViewManager* vm = mPresShell->GetViewManager();
NS_ENSURE_TRUE(vm, nullptr);
nsView* rootView = vm->GetRootView();
NS_ENSURE_TRUE(rootView, nullptr);
return rootView->GetNearestWidget(aOffset);
}
nsIWidget* nsPresContext::GetRootWidget() const {

Просмотреть файл

@ -192,7 +192,7 @@ class nsPresContext : public nsISupports,
nsPresContext* GetToplevelContentDocumentPresContext();
/**
* Returns the nearest widget for the root frame of this.
* Returns the nearest widget for the root frame or view of this.
*
* @param aOffset If non-null the offset from the origin of the root
* frame's view to the widget's origin (usually positive)