@@ -212,9 +212,7 @@ using namespace mozilla::layout;
212212using PaintFrameFlags = nsLayoutUtils::PaintFrameFlags;
213213typedef ScrollableLayerGuid::ViewID ViewID;
214214
215- CapturingContentInfo nsIPresShell::gCaptureInfo = {
216- false /* mAllowed */ , false /* mPointerLock */ ,
217- false /* mRetargetToElement */ , false /* mPreventDrag */ };
215+ PresShell::CapturingContentInfo PresShell::sCapturingContentInfo ;
218216
219217// RangePaintInfo is used to paint ranges to offscreen buffers
220218struct RangePaintInfo {
@@ -2442,7 +2440,8 @@ void PresShell::MaybeReleaseCapturingContent() {
24422440 if (frameSelection) {
24432441 frameSelection->SetDragState (false );
24442442 }
2445- if (gCaptureInfo .mContent && gCaptureInfo .mContent ->OwnerDoc () == mDocument ) {
2443+ if (sCapturingContentInfo .mContent &&
2444+ sCapturingContentInfo .mContent ->OwnerDoc () == mDocument ) {
24462445 PresShell::ReleaseCapturingContent ();
24472446 }
24482447}
@@ -3710,22 +3709,22 @@ void nsIPresShell::DispatchSynthMouseMove(WidgetGUIEvent* aEvent) {
37103709}
37113710
37123711void PresShell::ClearMouseCaptureOnView (nsView* aView) {
3713- if (gCaptureInfo .mContent ) {
3712+ if (sCapturingContentInfo .mContent ) {
37143713 if (aView) {
37153714 // if a view was specified, ensure that the captured content is within
37163715 // this view.
3717- nsIFrame* frame = gCaptureInfo .mContent ->GetPrimaryFrame ();
3716+ nsIFrame* frame = sCapturingContentInfo .mContent ->GetPrimaryFrame ();
37183717 if (frame) {
37193718 nsView* view = frame->GetClosestView ();
37203719 // if there is no view, capturing won't be handled any more, so
37213720 // just release the capture.
37223721 if (view) {
37233722 do {
37243723 if (view == aView) {
3725- gCaptureInfo .mContent = nullptr ;
3724+ sCapturingContentInfo .mContent = nullptr ;
37263725 // the view containing the captured content likely disappeared so
37273726 // disable capture for now.
3728- gCaptureInfo .mAllowed = false ;
3727+ sCapturingContentInfo .mAllowed = false ;
37293728 break ;
37303729 }
37313730
@@ -3737,38 +3736,38 @@ void PresShell::ClearMouseCaptureOnView(nsView* aView) {
37373736 }
37383737 }
37393738
3740- gCaptureInfo .mContent = nullptr ;
3739+ sCapturingContentInfo .mContent = nullptr ;
37413740 }
37423741
37433742 // disable mouse capture until the next mousedown as a dialog has opened
37443743 // or a drag has started. Otherwise, someone could start capture during
37453744 // the modal dialog or drag.
3746- gCaptureInfo .mAllowed = false ;
3745+ sCapturingContentInfo .mAllowed = false ;
37473746}
37483747
3749- void nsIPresShell ::ClearMouseCapture (nsIFrame* aFrame) {
3750- if (!gCaptureInfo .mContent ) {
3751- gCaptureInfo .mAllowed = false ;
3748+ void PresShell ::ClearMouseCapture (nsIFrame* aFrame) {
3749+ if (!sCapturingContentInfo .mContent ) {
3750+ sCapturingContentInfo .mAllowed = false ;
37523751 return ;
37533752 }
37543753
37553754 // null frame argument means clear the capture
37563755 if (!aFrame) {
3757- gCaptureInfo .mContent = nullptr ;
3758- gCaptureInfo .mAllowed = false ;
3756+ sCapturingContentInfo .mContent = nullptr ;
3757+ sCapturingContentInfo .mAllowed = false ;
37593758 return ;
37603759 }
37613760
3762- nsIFrame* capturingFrame = gCaptureInfo .mContent ->GetPrimaryFrame ();
3761+ nsIFrame* capturingFrame = sCapturingContentInfo .mContent ->GetPrimaryFrame ();
37633762 if (!capturingFrame) {
3764- gCaptureInfo .mContent = nullptr ;
3765- gCaptureInfo .mAllowed = false ;
3763+ sCapturingContentInfo .mContent = nullptr ;
3764+ sCapturingContentInfo .mAllowed = false ;
37663765 return ;
37673766 }
37683767
37693768 if (nsLayoutUtils::IsAncestorFrameCrossDoc (aFrame, capturingFrame)) {
3770- gCaptureInfo .mContent = nullptr ;
3771- gCaptureInfo .mAllowed = false ;
3769+ sCapturingContentInfo .mContent = nullptr ;
3770+ sCapturingContentInfo .mAllowed = false ;
37723771 }
37733772}
37743773
@@ -6133,27 +6132,28 @@ void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
61336132void PresShell::SetCapturingContent (nsIContent* aContent, CaptureFlags aFlags) {
61346133 // If capture was set for pointer lock, don't unlock unless we are coming
61356134 // out of pointer lock explicitly.
6136- if (!aContent && gCaptureInfo .mPointerLock &&
6135+ if (!aContent && sCapturingContentInfo .mPointerLock &&
61376136 !(aFlags & CaptureFlags::PointerLock)) {
61386137 return ;
61396138 }
61406139
6141- gCaptureInfo .mContent = nullptr ;
6140+ sCapturingContentInfo .mContent = nullptr ;
61426141
61436142 // only set capturing content if allowed or the
61446143 // CaptureFlags::IgnoreAllowedState or CaptureFlags::PointerLock are used.
6145- if ((aFlags & CaptureFlags::IgnoreAllowedState) || gCaptureInfo . mAllowed ||
6146- (aFlags & CaptureFlags::PointerLock)) {
6144+ if ((aFlags & CaptureFlags::IgnoreAllowedState) ||
6145+ sCapturingContentInfo . mAllowed || (aFlags & CaptureFlags::PointerLock)) {
61476146 if (aContent) {
6148- gCaptureInfo .mContent = aContent;
6147+ sCapturingContentInfo .mContent = aContent;
61496148 }
61506149 // CaptureFlags::PointerLock is the same as
61516150 // CaptureFlags::RetargetToElement & CaptureFlags::IgnoreAllowedState.
6152- gCaptureInfo .mRetargetToElement =
6151+ sCapturingContentInfo .mRetargetToElement =
61536152 !!(aFlags & CaptureFlags::RetargetToElement) ||
61546153 !!(aFlags & CaptureFlags::PointerLock);
6155- gCaptureInfo .mPreventDrag = !!(aFlags & CaptureFlags::PreventDragStart);
6156- gCaptureInfo .mPointerLock = !!(aFlags & CaptureFlags::PointerLock);
6154+ sCapturingContentInfo .mPreventDrag =
6155+ !!(aFlags & CaptureFlags::PreventDragStart);
6156+ sCapturingContentInfo .mPointerLock = !!(aFlags & CaptureFlags::PointerLock);
61576157 }
61586158}
61596159
@@ -6674,7 +6674,7 @@ nsresult PresShell::EventHandler::HandleEventUsingCoordinates(
66746674 // capture retargeting is being used, no frame was found or the frame's
66756675 // content is not a descendant of the capturing content.
66766676 if (capturingContent && !pointerCapturingContent &&
6677- (gCaptureInfo .mRetargetToElement ||
6677+ (PresShell:: sCapturingContentInfo .mRetargetToElement ||
66786678 !eventTargetData.mFrame ->GetContent () ||
66796679 !nsContentUtils::ContentIsCrossDocDescendantOf (
66806680 eventTargetData.mFrame ->GetContent (), capturingContent))) {
@@ -7013,7 +7013,7 @@ nsIContent* PresShell::EventHandler::GetCapturingContentFor(
70137013 return (aGUIEvent->mClass == ePointerEventClass ||
70147014 aGUIEvent->mClass == eWheelEventClass ||
70157015 aGUIEvent->HasMouseEventMessage ())
7016- ? nsIPresShell ::GetCapturingContent ()
7016+ ? PresShell ::GetCapturingContent ()
70177017 : nullptr ;
70187018}
70197019
@@ -7378,7 +7378,7 @@ PresShell::EventHandler::ComputeRootFrameToHandleEventWithCapturingContent(
73787378 return aRootFrameToHandleEvent;
73797379 }
73807380
7381- if (gCaptureInfo .mRetargetToElement ) {
7381+ if (PresShell:: sCapturingContentInfo .mRetargetToElement ) {
73827382 *aIsCaptureRetargeted = true ;
73837383 return aRootFrameToHandleEvent;
73847384 }
@@ -7847,7 +7847,7 @@ bool PresShell::EventHandler::PrepareToDispatchEvent(
78477847 GetPresContext () &&
78487848 GetPresContext ()->EventStateManager () ==
78497849 EventStateManager::GetActiveEventStateManager ();
7850- nsIPresShell ::AllowMouseCapture (allowCapture);
7850+ PresShell ::AllowMouseCapture (allowCapture);
78517851 *aIsUserInteraction = false ;
78527852 return true ;
78537853 }
@@ -7924,7 +7924,7 @@ void PresShell::EventHandler::FinalizeHandlingEvent(WidgetEvent* aEvent) {
79247924 PresShell::ReleaseCapturingContent ();
79257925 return ;
79267926 case eMouseMove:
7927- nsIPresShell ::AllowMouseCapture (false );
7927+ PresShell ::AllowMouseCapture (false );
79287928 return ;
79297929 case eDrag:
79307930 case eDragEnd:
@@ -8263,7 +8263,7 @@ void PresShell::EventHandler::DispatchTouchEventToDOM(
82638263 }
82648264
82658265 Document* doc = content->OwnerDoc ();
8266- nsIContent* capturingContent = nsIPresShell ::GetCapturingContent ();
8266+ nsIContent* capturingContent = PresShell ::GetCapturingContent ();
82678267 if (capturingContent) {
82688268 if (capturingContent->OwnerDoc () != doc) {
82698269 // Wrong document, don't dispatch anything.
0 commit comments