diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 8ae1b8576a40..80cbd65d2273 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -10775,11 +10775,7 @@ CompositorHitTestInfo nsIFrame::GetCompositorHitTestInfo( } } - nsIDocShell* docShell = nullptr; - if (PresShell()->GetDocument()) { - docShell = PresShell()->GetDocument()->GetDocShell(); - } - if (dom::TouchEvent::PrefEnabled(docShell)) { + if (aBuilder->IsTouchEventPrefEnabledDoc()) { // Inherit the touch-action flags from the parent, if there is one. We do // this because of how the touch-action on a frame combines the touch-action // from ancestor DOM elements. Refer to the documentation in diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 2b3619a2ff0f..b2765dc4b64f 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -25,6 +25,7 @@ #include "mozilla/dom/ServiceWorkerRegistrar.h" #include "mozilla/dom/ServiceWorkerRegistration.h" #include "mozilla/dom/SVGElement.h" +#include "mozilla/dom/TouchEvent.h" #include "mozilla/gfx/2D.h" #include "mozilla/layers/PLayerTransaction.h" #include "mozilla/ShapeUtils.h" @@ -1422,12 +1423,14 @@ void nsDisplayListBuilder::EnterPresShell(nsIFrame* aReferenceFrame, : nullptr; nsPresContext* pc = aReferenceFrame->PresContext(); - nsCOMPtr docShell = pc->GetDocShell(); + mIsInChromePresContext = pc->IsChrome(); + nsIDocShell* docShell = pc->GetDocShell(); + if (docShell) { docShell->GetWindowDraggingAllowed(&mWindowDraggingAllowed); } - mIsInChromePresContext = pc->IsChrome(); + state->mTouchEventPrefEnabledDoc = dom::TouchEvent::PrefEnabled(docShell); if (!buildCaret) { return; @@ -1518,11 +1521,11 @@ void nsDisplayListBuilder::LeavePresShell(nsIFrame* aReferenceFrame, } ResetMarkedFramesForDisplayList(aReferenceFrame); - mPresShellStates.SetLength(mPresShellStates.Length() - 1); + mPresShellStates.RemoveLastElement(); if (!mPresShellStates.IsEmpty()) { nsPresContext* pc = CurrentPresContext(); - nsCOMPtr docShell = pc->GetDocShell(); + nsIDocShell* docShell = pc->GetDocShell(); if (docShell) { docShell->GetWindowDraggingAllowed(&mWindowDraggingAllowed); } diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index 65b45955cae4..2f1c754e1be0 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -742,6 +742,10 @@ class nsDisplayListBuilder { return CurrentPresShellState()->mInsidePointerEventsNoneDoc; } + bool IsTouchEventPrefEnabledDoc() { + return CurrentPresShellState()->mTouchEventPrefEnabledDoc; + } + bool GetAncestorHasApzAwareEventHandler() const { return mAncestorHasApzAwareEventHandler; } @@ -1833,6 +1837,7 @@ class nsDisplayListBuilder { // in the document, and is set when we enter a subdocument for a pointer- // events:none frame. bool mInsidePointerEventsNoneDoc; + bool mTouchEventPrefEnabledDoc; nsIFrame* mPresShellIgnoreScrollFrame; };