Convert to Mask<FWL_EVENTFLAG>

Conversion found some places where ordinary ints were still
being used for flag values.

-- remove always-empty modifier arg from DoAction_NoJs()

Change-Id: Ib3d893c4fdb3d65c55c09f7eafe5be2d73bb638b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/84030
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_actionhandler.cpp b/fpdfsdk/cpdfsdk_actionhandler.cpp
index c3693ac..7f2d4bc 100644
--- a/fpdfsdk/cpdfsdk_actionhandler.cpp
+++ b/fpdfsdk/cpdfsdk_actionhandler.cpp
@@ -64,7 +64,7 @@
     const CPDF_Action& action,
     CPDF_AAction::AActionType type,
     CPDFSDK_FormFillEnvironment* form_fill_env,
-    int modifiers) {
+    Mask<FWL_EVENTFLAG> modifiers) {
   DCHECK(form_fill_env);
 
   if (!CPDF_AAction::IsUserInput(type))
@@ -150,7 +150,7 @@
     }
   } else {
     DoAction_NoJs(action, CPDF_AAction::AActionType::kDocumentOpen,
-                  pFormFillEnv, /*modifiers=*/0);
+                  pFormFillEnv);
   }
 
   for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
@@ -181,7 +181,7 @@
         RunDocumentPageJavaScript(pFormFillEnv, type, swJS);
     }
   } else {
-    DoAction_NoJs(action, type, pFormFillEnv, /*modifiers=*/0);
+    DoAction_NoJs(action, type, pFormFillEnv);
   }
 
   DCHECK(pFormFillEnv);
@@ -229,7 +229,7 @@
       }
     }
   } else {
-    DoAction_NoJs(action, type, pFormFillEnv, /*modifiers=*/0);
+    DoAction_NoJs(action, type, pFormFillEnv);
   }
 
   for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
@@ -245,8 +245,7 @@
 void CPDFSDK_ActionHandler::DoAction_NoJs(
     const CPDF_Action& action,
     CPDF_AAction::AActionType type,
-    CPDFSDK_FormFillEnvironment* pFormFillEnv,
-    int modifiers) {
+    CPDFSDK_FormFillEnvironment* pFormFillEnv) {
   DCHECK(pFormFillEnv);
 
   switch (action.GetType()) {
@@ -255,7 +254,7 @@
       break;
     case CPDF_Action::Type::kURI:
       if (CPDF_AAction::IsUserInput(type))
-        DoAction_URI(pFormFillEnv, action, modifiers);
+        DoAction_URI(pFormFillEnv, action, Mask<FWL_EVENTFLAG>{});
       break;
     case CPDF_Action::Type::kHide:
       DoAction_Hide(action, pFormFillEnv);
@@ -306,7 +305,7 @@
 void CPDFSDK_ActionHandler::DoAction_URI(
     CPDFSDK_FormFillEnvironment* pFormFillEnv,
     const CPDF_Action& action,
-    int modifiers) {
+    Mask<FWL_EVENTFLAG> modifiers) {
   DCHECK(action.GetDict());
   pFormFillEnv->DoURIAction(action.GetURI(pFormFillEnv->GetPDFDocument()),
                             modifiers);
diff --git a/fpdfsdk/cpdfsdk_actionhandler.h b/fpdfsdk/cpdfsdk_actionhandler.h
index c675ecd..f245055 100644
--- a/fpdfsdk/cpdfsdk_actionhandler.h
+++ b/fpdfsdk/cpdfsdk_actionhandler.h
@@ -13,7 +13,9 @@
 #include "core/fpdfdoc/cpdf_aaction.h"
 #include "core/fpdfdoc/cpdf_action.h"
 #include "core/fxcrt/fx_string.h"
+#include "core/fxcrt/mask.h"
 #include "fpdfsdk/cpdfsdk_fieldaction.h"
+#include "public/fpdf_fwlevent.h"
 
 class CPDFSDK_FormFillEnvironment;
 class CPDF_Dictionary;
@@ -46,7 +48,7 @@
   bool DoAction_Link(const CPDF_Action& action,
                      CPDF_AAction::AActionType type,
                      CPDFSDK_FormFillEnvironment* form_fill_env,
-                     int modifiers);
+                     Mask<FWL_EVENTFLAG> modifiers);
   bool DoAction_Destination(const CPDF_Dest& dest,
                             CPDFSDK_FormFillEnvironment* form_fill_env);
 
@@ -73,8 +75,7 @@
 
   void DoAction_NoJs(const CPDF_Action& action,
                      CPDF_AAction::AActionType type,
-                     CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                     int modifiers);
+                     CPDFSDK_FormFillEnvironment* pFormFillEnv);
   void RunDocumentPageJavaScript(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                                  CPDF_AAction::AActionType type,
                                  const WideString& script);
@@ -96,7 +97,7 @@
                        const CPDF_Action& action);
   void DoAction_URI(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                     const CPDF_Action& action,
-                    int modifiers);
+                    Mask<FWL_EVENTFLAG> modifiers);
   void DoAction_Named(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                       const CPDF_Action& action);
 
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.cpp b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
index b4b68f6..4fe7094 100644
--- a/fpdfsdk/cpdfsdk_annothandlermgr.cpp
+++ b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
@@ -154,7 +154,7 @@
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlags,
+    Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK(pAnnot->HasObservable());
   return GetAnnotHandler(pAnnot->Get())
@@ -164,7 +164,7 @@
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlags,
+    Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK(pAnnot->HasObservable());
   return GetAnnotHandler(pAnnot->Get())
@@ -174,7 +174,7 @@
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlags,
+    Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK(pAnnot->HasObservable());
   return GetAnnotHandler(pAnnot->Get())
@@ -184,7 +184,7 @@
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlags,
+    Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK(pAnnot->HasObservable());
   return GetAnnotHandler(pAnnot->Get())
@@ -194,7 +194,7 @@
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlags,
+    Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point,
     const CFX_Vector& delta) {
   DCHECK(pAnnot->HasObservable());
@@ -205,7 +205,7 @@
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlags,
+    Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK(pAnnot->HasObservable());
   return GetAnnotHandler(pAnnot->Get())
@@ -215,7 +215,7 @@
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlags,
+    Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK(pAnnot->HasObservable());
   return GetAnnotHandler(pAnnot->Get())
@@ -225,7 +225,7 @@
 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlag) {
+    Mask<FWL_EVENTFLAG> nFlag) {
   DCHECK(pAnnot->HasObservable());
   GetAnnotHandler(pAnnot->Get())->OnMouseEnter(pPageView, pAnnot, nFlag);
 }
@@ -233,21 +233,21 @@
 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlag) {
+    Mask<FWL_EVENTFLAG> nFlag) {
   DCHECK(pAnnot->HasObservable());
   GetAnnotHandler(pAnnot->Get())->OnMouseExit(pPageView, pAnnot, nFlag);
 }
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot,
                                            uint32_t nChar,
-                                           FWL_EventFlagMask nFlags) {
+                                           Mask<FWL_EVENTFLAG> nFlags) {
   return GetAnnotHandler(pAnnot)->OnChar(pAnnot, nChar, nFlags);
 }
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_PageView* pPageView,
                                               CPDFSDK_Annot* pAnnot,
                                               FWL_VKEYCODE nKeyCode,
-                                              FWL_EventFlagMask nFlag) {
+                                              Mask<FWL_EVENTFLAG> nFlag) {
   if (!pAnnot) {
     // If pressed key is not tab then no action is needed.
     if (nKeyCode != FWL_VKEY_Tab)
@@ -289,14 +289,14 @@
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlag) {
+    Mask<FWL_EVENTFLAG> nFlag) {
   DCHECK(pAnnot->HasObservable());
   return GetAnnotHandler(pAnnot->Get())->OnSetFocus(pAnnot, nFlag);
 }
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlag) {
+    Mask<FWL_EVENTFLAG> nFlag) {
   DCHECK(pAnnot->HasObservable());
   return GetAnnotHandler(pAnnot->Get())->OnKillFocus(pAnnot, nFlag);
 }
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.h b/fpdfsdk/cpdfsdk_annothandlermgr.h
index f6463ac..3abcd97 100644
--- a/fpdfsdk/cpdfsdk_annothandlermgr.h
+++ b/fpdfsdk/cpdfsdk_annothandlermgr.h
@@ -11,6 +11,7 @@
 
 #include "core/fpdfdoc/cpdf_annot.h"
 #include "core/fxcrt/fx_coordinates.h"
+#include "core/fxcrt/mask.h"
 #include "fpdfsdk/cpdfsdk_annot.h"
 #include "fpdfsdk/pwl/cpwl_wnd.h"
 #include "public/fpdf_fwlevent.h"
@@ -66,50 +67,50 @@
 
   void Annot_OnMouseEnter(CPDFSDK_PageView* pPageView,
                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                          FWL_EventFlagMask nFlags);
+                          Mask<FWL_EVENTFLAG> nFlags);
   void Annot_OnMouseExit(CPDFSDK_PageView* pPageView,
                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                         FWL_EventFlagMask nFlags);
+                         Mask<FWL_EVENTFLAG> nFlags);
   bool Annot_OnLButtonDown(CPDFSDK_PageView* pPageView,
                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                           FWL_EventFlagMask nFlags,
+                           Mask<FWL_EVENTFLAG> nFlags,
                            const CFX_PointF& point);
   bool Annot_OnLButtonUp(CPDFSDK_PageView* pPageView,
                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                         FWL_EventFlagMask nFlags,
+                         Mask<FWL_EVENTFLAG> nFlags,
                          const CFX_PointF& point);
   bool Annot_OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                              ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                             FWL_EventFlagMask nFlags,
+                             Mask<FWL_EVENTFLAG> nFlags,
                              const CFX_PointF& point);
   bool Annot_OnMouseMove(CPDFSDK_PageView* pPageView,
                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                         FWL_EventFlagMask nFlags,
+                         Mask<FWL_EVENTFLAG> nFlags,
                          const CFX_PointF& point);
   bool Annot_OnMouseWheel(CPDFSDK_PageView* pPageView,
                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                          FWL_EventFlagMask nFlags,
+                          Mask<FWL_EVENTFLAG> nFlags,
                           const CFX_PointF& point,
                           const CFX_Vector& delta);
   bool Annot_OnRButtonDown(CPDFSDK_PageView* pPageView,
                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                           FWL_EventFlagMask nFlags,
+                           Mask<FWL_EVENTFLAG> nFlags,
                            const CFX_PointF& point);
   bool Annot_OnRButtonUp(CPDFSDK_PageView* pPageView,
                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                         FWL_EventFlagMask nFlags,
+                         Mask<FWL_EVENTFLAG> nFlags,
                          const CFX_PointF& point);
   bool Annot_OnChar(CPDFSDK_Annot* pAnnot,
                     uint32_t nChar,
-                    FWL_EventFlagMask nFlags);
+                    Mask<FWL_EVENTFLAG> nFlags);
   bool Annot_OnKeyDown(CPDFSDK_PageView* pPageView,
                        CPDFSDK_Annot* pAnnot,
                        FWL_VKEYCODE nKeyCode,
-                       FWL_EventFlagMask nFlag);
+                       Mask<FWL_EVENTFLAG> nFlag);
   bool Annot_OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                        FWL_EventFlagMask nFlag);
+                        Mask<FWL_EVENTFLAG> nFlag);
   bool Annot_OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                         FWL_EventFlagMask nFlag);
+                         Mask<FWL_EVENTFLAG> nFlag);
   bool Annot_SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                               int index,
                               bool selected);
diff --git a/fpdfsdk/cpdfsdk_baannothandler.cpp b/fpdfsdk/cpdfsdk_baannothandler.cpp
index 4e19780..1ad6b74 100644
--- a/fpdfsdk/cpdfsdk_baannothandler.cpp
+++ b/fpdfsdk/cpdfsdk_baannothandler.cpp
@@ -97,7 +97,7 @@
 
 void CPDFSDK_BAAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
                                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                          FWL_EventFlagMask nFlag) {
+                                          Mask<FWL_EVENTFLAG> nFlag) {
   CPDFSDK_BAAnnot* pBAAnnot = (*pAnnot)->AsBAAnnot();
   pBAAnnot->SetOpenState(true);
   UpdateAnnotRects(pPageView, pBAAnnot);
@@ -105,7 +105,7 @@
 
 void CPDFSDK_BAAnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                         FWL_EventFlagMask nFlag) {
+                                         Mask<FWL_EVENTFLAG> nFlag) {
   CPDFSDK_BAAnnot* pBAAnnot = (*pAnnot)->AsBAAnnot();
   pBAAnnot->SetOpenState(false);
   UpdateAnnotRects(pPageView, pBAAnnot);
@@ -113,35 +113,35 @@
 
 bool CPDFSDK_BAAnnotHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
                                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                           FWL_EventFlagMask nFlags,
+                                           Mask<FWL_EVENTFLAG> nFlags,
                                            const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                         FWL_EventFlagMask nFlags,
+                                         Mask<FWL_EVENTFLAG> nFlags,
                                          const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                                              ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                             FWL_EventFlagMask nFlags,
+                                             Mask<FWL_EVENTFLAG> nFlags,
                                              const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                         FWL_EventFlagMask nFlags,
+                                         Mask<FWL_EVENTFLAG> nFlags,
                                          const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
                                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                          FWL_EventFlagMask nFlags,
+                                          Mask<FWL_EVENTFLAG> nFlags,
                                           const CFX_PointF& point,
                                           const CFX_Vector& delta) {
   return false;
@@ -149,34 +149,34 @@
 
 bool CPDFSDK_BAAnnotHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
                                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                           FWL_EventFlagMask nFlags,
+                                           Mask<FWL_EVENTFLAG> nFlags,
                                            const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                         FWL_EventFlagMask nFlags,
+                                         Mask<FWL_EVENTFLAG> nFlags,
                                          const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView,
                                              ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                             FWL_EventFlagMask nFlags,
+                                             Mask<FWL_EVENTFLAG> nFlags,
                                              const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot,
                                     uint32_t nChar,
-                                    FWL_EventFlagMask nFlags) {
+                                    Mask<FWL_EVENTFLAG> nFlags) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
                                        FWL_VKEYCODE nKeyCode,
-                                       FWL_EventFlagMask nFlag) {
+                                       Mask<FWL_EVENTFLAG> nFlag) {
   DCHECK(pAnnot);
 
   // OnKeyDown() is implemented only for link annotations for now. As
@@ -201,7 +201,7 @@
 
 bool CPDFSDK_BAAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
                                      FWL_VKEYCODE nKeyCode,
-                                     FWL_EventFlagMask nFlag) {
+                                     Mask<FWL_EVENTFLAG> nFlag) {
   return false;
 }
 
@@ -228,7 +228,7 @@
 }
 
 bool CPDFSDK_BAAnnotHandler::OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        FWL_EventFlagMask nFlag) {
+                                        Mask<FWL_EVENTFLAG> nFlag) {
   if (!IsFocusableAnnot(pAnnot->Get()->GetAnnotSubtype()))
     return false;
 
@@ -238,7 +238,7 @@
 }
 
 bool CPDFSDK_BAAnnotHandler::OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                         FWL_EventFlagMask nFlag) {
+                                         Mask<FWL_EVENTFLAG> nFlag) {
   if (!IsFocusableAnnot(pAnnot->Get()->GetAnnotSubtype()))
     return false;
 
diff --git a/fpdfsdk/cpdfsdk_baannothandler.h b/fpdfsdk/cpdfsdk_baannothandler.h
index ad2b986..1c306c1 100644
--- a/fpdfsdk/cpdfsdk_baannothandler.h
+++ b/fpdfsdk/cpdfsdk_baannothandler.h
@@ -54,56 +54,56 @@
 
   void OnMouseEnter(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    FWL_EventFlagMask nFlag) override;
+                    Mask<FWL_EVENTFLAG> nFlag) override;
   void OnMouseExit(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlag) override;
+                   Mask<FWL_EVENTFLAG> nFlag) override;
   bool OnLButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     FWL_EventFlagMask nFlags,
+                     Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point) override;
   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
   bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                       FWL_EventFlagMask nFlags,
+                       Mask<FWL_EVENTFLAG> nFlags,
                        const CFX_PointF& point) override;
   bool OnMouseMove(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
   bool OnMouseWheel(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    FWL_EventFlagMask nFlags,
+                    Mask<FWL_EVENTFLAG> nFlags,
                     const CFX_PointF& point,
                     const CFX_Vector& delta) override;
   bool OnRButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     FWL_EventFlagMask nFlags,
+                     Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point) override;
   bool OnRButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
   bool OnRButtonDblClk(CPDFSDK_PageView* pPageView,
                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                       FWL_EventFlagMask nFlags,
+                       Mask<FWL_EVENTFLAG> nFlags,
                        const CFX_PointF& point) override;
   bool OnChar(CPDFSDK_Annot* pAnnot,
               uint32_t nChar,
-              FWL_EventFlagMask nFlags) override;
+              Mask<FWL_EVENTFLAG> nFlags) override;
   bool OnKeyDown(CPDFSDK_Annot* pAnnot,
                  FWL_VKEYCODE nKeyCode,
-                 FWL_EventFlagMask nFlag) override;
+                 Mask<FWL_EVENTFLAG> nFlag) override;
   bool OnKeyUp(CPDFSDK_Annot* pAnnot,
                FWL_VKEYCODE nKeyCode,
-               FWL_EventFlagMask nFlag) override;
+               Mask<FWL_EVENTFLAG> nFlag) override;
   bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                  FWL_EventFlagMask nFlag) override;
+                  Mask<FWL_EVENTFLAG> nFlag) override;
   bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlag) override;
+                   Mask<FWL_EVENTFLAG> nFlag) override;
   bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                         int index,
                         bool selected) override;
diff --git a/fpdfsdk/cpdfsdk_baannothandler_embeddertest.cpp b/fpdfsdk/cpdfsdk_baannothandler_embeddertest.cpp
index f402e3c..feb2ebb 100644
--- a/fpdfsdk/cpdfsdk_baannothandler_embeddertest.cpp
+++ b/fpdfsdk/cpdfsdk_baannothandler_embeddertest.cpp
@@ -85,8 +85,8 @@
   EXPECT_EQ(pAnnot->GetAnnotSubtype(), CPDF_Annot::Subtype::LINK);
 
   ObservedPtr<CPDFSDK_Annot> pLinkAnnot(pAnnot);
-  EXPECT_TRUE(GetBAAnnotHandler()->OnSetFocus(&pLinkAnnot, 0));
-  EXPECT_TRUE(GetBAAnnotHandler()->OnKillFocus(&pLinkAnnot, 0));
+  EXPECT_TRUE(GetBAAnnotHandler()->OnSetFocus(&pLinkAnnot, {}));
+  EXPECT_TRUE(GetBAAnnotHandler()->OnKillFocus(&pLinkAnnot, {}));
 
   // Get highlight annot.
   pAnnot = GetNthFocusableAnnot(4);
@@ -94,6 +94,6 @@
   EXPECT_EQ(pAnnot->GetAnnotSubtype(), CPDF_Annot::Subtype::HIGHLIGHT);
 
   ObservedPtr<CPDFSDK_Annot> pHighlightAnnot(pAnnot);
-  EXPECT_TRUE(GetBAAnnotHandler()->OnSetFocus(&pHighlightAnnot, 0));
-  EXPECT_TRUE(GetBAAnnotHandler()->OnKillFocus(&pHighlightAnnot, 0));
+  EXPECT_TRUE(GetBAAnnotHandler()->OnSetFocus(&pHighlightAnnot, {}));
+  EXPECT_TRUE(GetBAAnnotHandler()->OnKillFocus(&pHighlightAnnot, {}));
 }
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index c91dff3..6e6c70b 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -403,13 +403,13 @@
 }
 
 void CPDFSDK_FormFillEnvironment::DoURIAction(const ByteString& bsURI,
-                                              uint32_t modifiers) {
+                                              Mask<FWL_EVENTFLAG> modifiers) {
   if (!m_pInfo)
     return;
 
   if (m_pInfo->version >= 2 && m_pInfo->FFI_DoURIActionWithKeyboardModifier) {
     m_pInfo->FFI_DoURIActionWithKeyboardModifier(m_pInfo, bsURI.c_str(),
-                                                 modifiers);
+                                                 modifiers.UncheckedValue());
     return;
   }
 
@@ -587,7 +587,7 @@
 void CPDFSDK_FormFillEnvironment::ClearAllFocusedAnnots() {
   for (auto& it : m_PageMap) {
     if (it.second->IsValidSDKAnnot(GetFocusAnnot()))
-      KillFocusAnnot(0);
+      KillFocusAnnot({});
   }
 }
 
@@ -672,7 +672,7 @@
   // be created. We then have two page views pointing to the same page and
   // bad things happen.
   if (pPageView->IsValidSDKAnnot(GetFocusAnnot()))
-    KillFocusAnnot(0);
+    KillFocusAnnot({});
 
   // Remove the page from the map to make sure we don't accidentally attempt
   // to use the |pPageView| while we're cleaning it up.
@@ -707,7 +707,7 @@
     return false;
   if (m_pFocusAnnot == *pAnnot)
     return true;
-  if (m_pFocusAnnot && !KillFocusAnnot(0))
+  if (m_pFocusAnnot && !KillFocusAnnot({}))
     return false;
   if (!pAnnot->HasObservable())
     return false;
@@ -728,7 +728,7 @@
   if (!pAnnot->HasObservable())
     return false;
 #endif  // PDF_ENABLE_XFA
-  if (!pAnnotHandler->Annot_OnSetFocus(pAnnot, 0))
+  if (!pAnnotHandler->Annot_OnSetFocus(pAnnot, {}))
     return false;
   if (m_pFocusAnnot)
     return false;
@@ -741,7 +741,7 @@
   return true;
 }
 
-bool CPDFSDK_FormFillEnvironment::KillFocusAnnot(FWL_EventFlagMask nFlag) {
+bool CPDFSDK_FormFillEnvironment::KillFocusAnnot(Mask<FWL_EVENTFLAG> nFlag) {
   if (!m_pFocusAnnot)
     return false;
 
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h
index df47005..e505fe1 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.h
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.h
@@ -15,6 +15,7 @@
 #include "core/fpdfapi/page/cpdf_page.h"
 #include "core/fpdfapi/parser/cpdf_document.h"
 #include "core/fxcrt/cfx_timer.h"
+#include "core/fxcrt/mask.h"
 #include "core/fxcrt/observed_ptr.h"
 #include "core/fxcrt/retain_ptr.h"
 #include "core/fxcrt/unowned_ptr.h"
@@ -75,7 +76,7 @@
 
   CPDFSDK_Annot* GetFocusAnnot() const { return m_pFocusAnnot.Get(); }
   bool SetFocusAnnot(ObservedPtr<CPDFSDK_Annot>* pAnnot);
-  bool KillFocusAnnot(FWL_EventFlagMask nFlag);
+  bool KillFocusAnnot(Mask<FWL_EVENTFLAG> nFlag);
   void ClearAllFocusedAnnots();
 
   int GetPageCount() const;
@@ -97,7 +98,7 @@
   void OnSetFieldInputFocus(FPDF_WIDESTRING focusText,
                             FPDF_DWORD nTextLen,
                             bool bFocus);
-  void DoURIAction(const ByteString& bsURI, uint32_t modifiers);
+  void DoURIAction(const ByteString& bsURI, Mask<FWL_EVENTFLAG> modifiers);
   void DoGoToAction(int nPageIndex,
                     int zoomMode,
                     float* fPosArray,
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp
index 7978559..5a115e9 100644
--- a/fpdfsdk/cpdfsdk_pageview.cpp
+++ b/fpdfsdk/cpdfsdk_pageview.cpp
@@ -148,7 +148,7 @@
 
   ObservedPtr<CPDFSDK_Annot> pObserved(pAnnot);
   if (GetFocusAnnot() == pAnnot)
-    m_pFormFillEnv->KillFocusAnnot(0);  // May invoke JS, invalidating pAnnot.
+    m_pFormFillEnv->KillFocusAnnot({});  // May invoke JS, invalidating pAnnot.
 
   if (pObserved) {
     CPDFSDK_AnnotHandlerMgr* pAnnotHandler =
@@ -275,7 +275,7 @@
   return false;
 }
 
-bool CPDFSDK_PageView::OnFocus(FWL_EventFlagMask nFlag,
+bool CPDFSDK_PageView::OnFocus(Mask<FWL_EVENTFLAG> nFlag,
                                const CFX_PointF& point) {
   ObservedPtr<CPDFSDK_Annot> pAnnot(GetFXWidgetAtPoint(point));
   if (!pAnnot) {
@@ -287,7 +287,7 @@
   return true;
 }
 
-bool CPDFSDK_PageView::OnLButtonDown(FWL_EventFlagMask nFlag,
+bool CPDFSDK_PageView::OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
                                      const CFX_PointF& point) {
   ObservedPtr<CPDFSDK_Annot> pAnnot(GetFXWidgetAtPoint(point));
   if (!pAnnot) {
@@ -307,7 +307,7 @@
   return true;
 }
 
-bool CPDFSDK_PageView::OnLButtonUp(FWL_EventFlagMask nFlag,
+bool CPDFSDK_PageView::OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,
                                    const CFX_PointF& point) {
   CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
       m_pFormFillEnv->GetAnnotHandlerMgr();
@@ -322,7 +322,7 @@
          pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFXAnnot, nFlag, point);
 }
 
-bool CPDFSDK_PageView::OnLButtonDblClk(FWL_EventFlagMask nFlag,
+bool CPDFSDK_PageView::OnLButtonDblClk(Mask<FWL_EVENTFLAG> nFlag,
                                        const CFX_PointF& point) {
   ObservedPtr<CPDFSDK_Annot> pAnnot(GetFXWidgetAtPoint(point));
   if (!pAnnot) {
@@ -342,7 +342,7 @@
   return true;
 }
 
-bool CPDFSDK_PageView::OnRButtonDown(FWL_EventFlagMask nFlag,
+bool CPDFSDK_PageView::OnRButtonDown(Mask<FWL_EVENTFLAG> nFlag,
                                      const CFX_PointF& point) {
   ObservedPtr<CPDFSDK_Annot> pAnnot(GetFXWidgetAtPoint(point));
   if (!pAnnot)
@@ -360,7 +360,7 @@
   return true;
 }
 
-bool CPDFSDK_PageView::OnRButtonUp(FWL_EventFlagMask nFlag,
+bool CPDFSDK_PageView::OnRButtonUp(Mask<FWL_EVENTFLAG> nFlag,
                                    const CFX_PointF& point) {
   ObservedPtr<CPDFSDK_Annot> pAnnot(GetFXWidgetAtPoint(point));
   if (!pAnnot)
@@ -378,7 +378,7 @@
   return true;
 }
 
-bool CPDFSDK_PageView::OnMouseMove(FWL_EventFlagMask nFlag,
+bool CPDFSDK_PageView::OnMouseMove(Mask<FWL_EVENTFLAG> nFlag,
                                    const CFX_PointF& point) {
   CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
       m_pFormFillEnv->GetAnnotHandlerMgr();
@@ -411,7 +411,7 @@
 
 void CPDFSDK_PageView::EnterWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr,
                                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                   FWL_EventFlagMask nFlag) {
+                                   Mask<FWL_EVENTFLAG> nFlag) {
   m_bOnWidget = true;
   m_pCaptureWidget.Reset(pAnnot->Get());
   pAnnotHandlerMgr->Annot_OnMouseEnter(this, pAnnot, nFlag);
@@ -419,7 +419,7 @@
 
 void CPDFSDK_PageView::ExitWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr,
                                   bool callExitCallback,
-                                  FWL_EventFlagMask nFlag) {
+                                  Mask<FWL_EVENTFLAG> nFlag) {
   m_bOnWidget = false;
   if (!m_pCaptureWidget)
     return;
@@ -436,7 +436,7 @@
   m_pCaptureWidget.Reset();
 }
 
-bool CPDFSDK_PageView::OnMouseWheel(FWL_EventFlagMask nFlag,
+bool CPDFSDK_PageView::OnMouseWheel(Mask<FWL_EVENTFLAG> nFlag,
                                     const CFX_PointF& point,
                                     const CFX_Vector& delta) {
   ObservedPtr<CPDFSDK_Annot> pAnnot(GetFXWidgetAtPoint(point));
@@ -472,7 +472,7 @@
   return false;
 }
 
-bool CPDFSDK_PageView::OnChar(uint32_t nChar, FWL_EventFlagMask nFlag) {
+bool CPDFSDK_PageView::OnChar(uint32_t nChar, Mask<FWL_EVENTFLAG> nFlag) {
   if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) {
     CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
         m_pFormFillEnv->GetAnnotHandlerMgr();
@@ -483,14 +483,15 @@
 }
 
 bool CPDFSDK_PageView::OnKeyDown(FWL_VKEYCODE nKeyCode,
-                                 FWL_EventFlagMask nFlag) {
+                                 Mask<FWL_EVENTFLAG> nFlag) {
   CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
       m_pFormFillEnv->GetAnnotHandlerMgr();
   return pAnnotHandlerMgr->Annot_OnKeyDown(this, GetFocusAnnot(), nKeyCode,
                                            nFlag);
 }
 
-bool CPDFSDK_PageView::OnKeyUp(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag) {
+bool CPDFSDK_PageView::OnKeyUp(FWL_VKEYCODE nKeyCode,
+                               Mask<FWL_EVENTFLAG> nFlag) {
   return false;
 }
 
@@ -507,8 +508,8 @@
   if (pContext && pContext->ContainsExtensionFullForm()) {
     CXFA_FFPageView* pageView = protector->GetXFAPageView();
     CXFA_FFWidget::IteratorIface* pWidgetHandler =
-        pageView->CreateGCedFormWidgetIterator(XFA_WidgetStatus_Visible |
-                                               XFA_WidgetStatus_Viewable);
+        pageView->CreateGCedFormWidgetIterator(Mask<XFA_WidgetStatus>{
+            XFA_WidgetStatus::kVisible, XFA_WidgetStatus::kViewable});
 
     while (CXFA_FFWidget* pXFAAnnot = pWidgetHandler->MoveToNext()) {
       std::unique_ptr<CPDFSDK_Annot> pNewAnnot =
diff --git a/fpdfsdk/cpdfsdk_pageview.h b/fpdfsdk/cpdfsdk_pageview.h
index 1d30a0b..0ec9e3e 100644
--- a/fpdfsdk/cpdfsdk_pageview.h
+++ b/fpdfsdk/cpdfsdk_pageview.h
@@ -13,6 +13,7 @@
 #include <vector>
 
 #include "core/fpdfapi/page/cpdf_page.h"
+#include "core/fxcrt/mask.h"
 #include "core/fxcrt/retain_ptr.h"
 #include "core/fxcrt/unowned_ptr.h"
 #include "fpdfsdk/cpdfsdk_annot.h"
@@ -66,17 +67,17 @@
   bool Undo();
   bool Redo();
 
-  bool OnFocus(FWL_EventFlagMask nFlag, const CFX_PointF& point);
-  bool OnLButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point);
-  bool OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point);
-  bool OnLButtonDblClk(FWL_EventFlagMask nFlag, const CFX_PointF& point);
-  bool OnRButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point);
-  bool OnRButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point);
-  bool OnChar(uint32_t nChar, FWL_EventFlagMask nFlag);
-  bool OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag);
-  bool OnKeyUp(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag);
-  bool OnMouseMove(FWL_EventFlagMask nFlag, const CFX_PointF& point);
-  bool OnMouseWheel(FWL_EventFlagMask nFlag,
+  bool OnFocus(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point);
+  bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point);
+  bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point);
+  bool OnLButtonDblClk(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point);
+  bool OnRButtonDown(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point);
+  bool OnRButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point);
+  bool OnChar(uint32_t nChar, Mask<FWL_EVENTFLAG> nFlag);
+  bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlag);
+  bool OnKeyUp(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlag);
+  bool OnMouseMove(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point);
+  bool OnMouseWheel(Mask<FWL_EVENTFLAG> nFlag,
                     const CFX_PointF& point,
                     const CFX_Vector& delta);
 
@@ -104,10 +105,10 @@
 
   void EnterWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlag);
+                   Mask<FWL_EVENTFLAG> nFlag);
   void ExitWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr,
                   bool callExitCallback,
-                  FWL_EventFlagMask nFlag);
+                  Mask<FWL_EVENTFLAG> nFlag);
 
   CFX_Matrix m_curMatrix;
   UnownedPtr<IPDF_Page> const m_page;
diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp
index 658a0e2..7886191 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_widgethandler.cpp
@@ -96,21 +96,21 @@
 
 void CPDFSDK_WidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                         FWL_EventFlagMask nFlag) {
+                                         Mask<FWL_EVENTFLAG> nFlag) {
   if (!(*pAnnot)->IsSignatureWidget())
     m_pInteractiveFormFiller->OnMouseEnter(pPageView, pAnnot, nFlag);
 }
 
 void CPDFSDK_WidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        FWL_EventFlagMask nFlag) {
+                                        Mask<FWL_EVENTFLAG> nFlag) {
   if (!(*pAnnot)->IsSignatureWidget())
     m_pInteractiveFormFiller->OnMouseExit(pPageView, pAnnot, nFlag);
 }
 
 bool CPDFSDK_WidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
                                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                          FWL_EventFlagMask nFlags,
+                                          Mask<FWL_EVENTFLAG> nFlags,
                                           const CFX_PointF& point) {
   return !(*pAnnot)->IsSignatureWidget() &&
          m_pInteractiveFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags,
@@ -119,7 +119,7 @@
 
 bool CPDFSDK_WidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        FWL_EventFlagMask nFlags,
+                                        Mask<FWL_EVENTFLAG> nFlags,
                                         const CFX_PointF& point) {
   return !(*pAnnot)->IsSignatureWidget() &&
          m_pInteractiveFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags,
@@ -128,7 +128,7 @@
 
 bool CPDFSDK_WidgetHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                            FWL_EventFlagMask nFlags,
+                                            Mask<FWL_EVENTFLAG> nFlags,
                                             const CFX_PointF& point) {
   return !(*pAnnot)->IsSignatureWidget() &&
          m_pInteractiveFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags,
@@ -137,7 +137,7 @@
 
 bool CPDFSDK_WidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        FWL_EventFlagMask nFlags,
+                                        Mask<FWL_EVENTFLAG> nFlags,
                                         const CFX_PointF& point) {
   return !(*pAnnot)->IsSignatureWidget() &&
          m_pInteractiveFormFiller->OnMouseMove(pPageView, pAnnot, nFlags,
@@ -146,7 +146,7 @@
 
 bool CPDFSDK_WidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                         FWL_EventFlagMask nFlags,
+                                         Mask<FWL_EVENTFLAG> nFlags,
                                          const CFX_PointF& point,
                                          const CFX_Vector& delta) {
   return !(*pAnnot)->IsSignatureWidget() &&
@@ -156,7 +156,7 @@
 
 bool CPDFSDK_WidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
                                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                          FWL_EventFlagMask nFlags,
+                                          Mask<FWL_EVENTFLAG> nFlags,
                                           const CFX_PointF& point) {
   return !(*pAnnot)->IsSignatureWidget() &&
          m_pInteractiveFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags,
@@ -165,7 +165,7 @@
 
 bool CPDFSDK_WidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        FWL_EventFlagMask nFlags,
+                                        Mask<FWL_EVENTFLAG> nFlags,
                                         const CFX_PointF& point) {
   return !(*pAnnot)->IsSignatureWidget() &&
          m_pInteractiveFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags,
@@ -174,28 +174,28 @@
 
 bool CPDFSDK_WidgetHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView,
                                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                            FWL_EventFlagMask nFlags,
+                                            Mask<FWL_EVENTFLAG> nFlags,
                                             const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_WidgetHandler::OnChar(CPDFSDK_Annot* pAnnot,
                                    uint32_t nChar,
-                                   FWL_EventFlagMask nFlags) {
+                                   Mask<FWL_EVENTFLAG> nFlags) {
   return !pAnnot->IsSignatureWidget() &&
          m_pInteractiveFormFiller->OnChar(pAnnot, nChar, nFlags);
 }
 
 bool CPDFSDK_WidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
                                       FWL_VKEYCODE nKeyCode,
-                                      FWL_EventFlagMask nFlag) {
+                                      Mask<FWL_EVENTFLAG> nFlag) {
   return !pAnnot->IsSignatureWidget() &&
          m_pInteractiveFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlag);
 }
 
 bool CPDFSDK_WidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
                                     FWL_VKEYCODE nKeyCode,
-                                    FWL_EventFlagMask nFlag) {
+                                    Mask<FWL_EVENTFLAG> nFlag) {
   return false;
 }
 
@@ -230,7 +230,7 @@
 }
 
 bool CPDFSDK_WidgetHandler::OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                       FWL_EventFlagMask nFlag) {
+                                       Mask<FWL_EVENTFLAG> nFlag) {
   if (!IsFocusableAnnot((*pAnnot)->GetPDFAnnot()->GetSubtype()))
     return false;
 
@@ -239,7 +239,7 @@
 }
 
 bool CPDFSDK_WidgetHandler::OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        FWL_EventFlagMask nFlag) {
+                                        Mask<FWL_EVENTFLAG> nFlag) {
   if (!IsFocusableAnnot((*pAnnot)->GetPDFAnnot()->GetSubtype()))
     return false;
 
diff --git a/fpdfsdk/cpdfsdk_widgethandler.h b/fpdfsdk/cpdfsdk_widgethandler.h
index 2b8d59a..ff8e636 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.h
+++ b/fpdfsdk/cpdfsdk_widgethandler.h
@@ -54,56 +54,56 @@
 
   void OnMouseEnter(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    FWL_EventFlagMask nFlag) override;
+                    Mask<FWL_EVENTFLAG> nFlag) override;
   void OnMouseExit(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlag) override;
+                   Mask<FWL_EVENTFLAG> nFlag) override;
   bool OnLButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     FWL_EventFlagMask nFlags,
+                     Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point) override;
   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
   bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                       FWL_EventFlagMask nFlags,
+                       Mask<FWL_EVENTFLAG> nFlags,
                        const CFX_PointF& point) override;
   bool OnMouseMove(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
   bool OnMouseWheel(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    FWL_EventFlagMask nFlags,
+                    Mask<FWL_EVENTFLAG> nFlags,
                     const CFX_PointF& point,
                     const CFX_Vector& delta) override;
   bool OnRButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     FWL_EventFlagMask nFlags,
+                     Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point) override;
   bool OnRButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
   bool OnRButtonDblClk(CPDFSDK_PageView* pPageView,
                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                       FWL_EventFlagMask nFlags,
+                       Mask<FWL_EVENTFLAG> nFlags,
                        const CFX_PointF& point) override;
   bool OnChar(CPDFSDK_Annot* pAnnot,
               uint32_t nChar,
-              FWL_EventFlagMask nFlags) override;
+              Mask<FWL_EVENTFLAG> nFlags) override;
   bool OnKeyDown(CPDFSDK_Annot* pAnnot,
                  FWL_VKEYCODE nKeyCode,
-                 FWL_EventFlagMask nFlag) override;
+                 Mask<FWL_EVENTFLAG> nFlag) override;
   bool OnKeyUp(CPDFSDK_Annot* pAnnot,
                FWL_VKEYCODE nKeyCode,
-               FWL_EventFlagMask nFlag) override;
+               Mask<FWL_EVENTFLAG> nFlag) override;
   bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                  FWL_EventFlagMask nFlag) override;
+                  Mask<FWL_EVENTFLAG> nFlag) override;
   bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlag) override;
+                   Mask<FWL_EVENTFLAG> nFlag) override;
   bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                         int index,
                         bool selected) override;
diff --git a/fpdfsdk/formfiller/cffl_button.cpp b/fpdfsdk/formfiller/cffl_button.cpp
index 7382b4b..f80bb1c 100644
--- a/fpdfsdk/formfiller/cffl_button.cpp
+++ b/fpdfsdk/formfiller/cffl_button.cpp
@@ -29,7 +29,7 @@
 
 bool CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView,
                                 CPDFSDK_Annot* pAnnot,
-                                FWL_EventFlagMask nFlags,
+                                Mask<FWL_EVENTFLAG> nFlags,
                                 const CFX_PointF& point) {
   if (!pAnnot->GetRect().Contains(point))
     return false;
@@ -42,7 +42,7 @@
 
 bool CFFL_Button::OnLButtonUp(CPDFSDK_PageView* pPageView,
                               CPDFSDK_Annot* pAnnot,
-                              FWL_EventFlagMask nFlags,
+                              Mask<FWL_EVENTFLAG> nFlags,
                               const CFX_PointF& point) {
   if (!pAnnot->GetRect().Contains(point))
     return false;
@@ -53,7 +53,7 @@
 }
 
 bool CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView,
-                              FWL_EventFlagMask nFlags,
+                              Mask<FWL_EVENTFLAG> nFlags,
                               const CFX_PointF& point) {
   return true;
 }
diff --git a/fpdfsdk/formfiller/cffl_button.h b/fpdfsdk/formfiller/cffl_button.h
index 2a9912d..f0e7b49 100644
--- a/fpdfsdk/formfiller/cffl_button.h
+++ b/fpdfsdk/formfiller/cffl_button.h
@@ -28,14 +28,14 @@
   void OnMouseExit(CPDFSDK_PageView* pPageView) override;
   bool OnLButtonDown(CPDFSDK_PageView* pPageView,
                      CPDFSDK_Annot* pAnnot,
-                     FWL_EventFlagMask nFlags,
+                     Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point) override;
   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                    CPDFSDK_Annot* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
   bool OnMouseMove(CPDFSDK_PageView* pPageView,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
   void OnDraw(CPDFSDK_PageView* pPageView,
               CPDFSDK_Annot* pAnnot,
diff --git a/fpdfsdk/formfiller/cffl_checkbox.cpp b/fpdfsdk/formfiller/cffl_checkbox.cpp
index 299fb94..5676abd 100644
--- a/fpdfsdk/formfiller/cffl_checkbox.cpp
+++ b/fpdfsdk/formfiller/cffl_checkbox.cpp
@@ -32,7 +32,8 @@
   return std::move(pWnd);
 }
 
-bool CFFL_CheckBox::OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlags) {
+bool CFFL_CheckBox::OnKeyDown(FWL_VKEYCODE nKeyCode,
+                              Mask<FWL_EVENTFLAG> nFlags) {
   switch (nKeyCode) {
     case FWL_VKEY_Return:
     case FWL_VKEY_Space:
@@ -43,7 +44,7 @@
 }
 bool CFFL_CheckBox::OnChar(CPDFSDK_Annot* pAnnot,
                            uint32_t nChar,
-                           FWL_EventFlagMask nFlags) {
+                           Mask<FWL_EVENTFLAG> nFlags) {
   switch (nChar) {
     case pdfium::ascii::kReturn:
     case pdfium::ascii::kSpace: {
@@ -79,7 +80,7 @@
 
 bool CFFL_CheckBox::OnLButtonUp(CPDFSDK_PageView* pPageView,
                                 CPDFSDK_Annot* pAnnot,
-                                FWL_EventFlagMask nFlags,
+                                Mask<FWL_EVENTFLAG> nFlags,
                                 const CFX_PointF& point) {
   CFFL_Button::OnLButtonUp(pPageView, pAnnot, nFlags, point);
 
diff --git a/fpdfsdk/formfiller/cffl_checkbox.h b/fpdfsdk/formfiller/cffl_checkbox.h
index 9a76880..e7bb1c6 100644
--- a/fpdfsdk/formfiller/cffl_checkbox.h
+++ b/fpdfsdk/formfiller/cffl_checkbox.h
@@ -23,13 +23,13 @@
       const CPWL_Wnd::CreateParams& cp,
       std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData)
       override;
-  bool OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlags) override;
+  bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlags) override;
   bool OnChar(CPDFSDK_Annot* pAnnot,
               uint32_t nChar,
-              FWL_EventFlagMask nFlags) override;
+              Mask<FWL_EVENTFLAG> nFlags) override;
   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                    CPDFSDK_Annot* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
   bool IsDataChanged(const CPDFSDK_PageView* pPageView) override;
   void SaveData(const CPDFSDK_PageView* pPageView) override;
diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp
index f1bff27..d61fa89 100644
--- a/fpdfsdk/formfiller/cffl_combobox.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -65,7 +65,7 @@
 
 bool CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot,
                            uint32_t nChar,
-                           FWL_EventFlagMask nFlags) {
+                           Mask<FWL_EVENTFLAG> nFlags) {
   return CFFL_TextObject::OnChar(pAnnot, nChar, nFlags);
 }
 
diff --git a/fpdfsdk/formfiller/cffl_combobox.h b/fpdfsdk/formfiller/cffl_combobox.h
index 364ff06..b08f162 100644
--- a/fpdfsdk/formfiller/cffl_combobox.h
+++ b/fpdfsdk/formfiller/cffl_combobox.h
@@ -35,7 +35,7 @@
       override;
   bool OnChar(CPDFSDK_Annot* pAnnot,
               uint32_t nChar,
-              FWL_EventFlagMask nFlags) override;
+              Mask<FWL_EVENTFLAG> nFlags) override;
   bool IsDataChanged(const CPDFSDK_PageView* pPageView) override;
   void SaveData(const CPDFSDK_PageView* pPageView) override;
   void GetActionData(const CPDFSDK_PageView* pPageView,
diff --git a/fpdfsdk/formfiller/cffl_formfield.cpp b/fpdfsdk/formfiller/cffl_formfield.cpp
index 586b43f..7718c4e 100644
--- a/fpdfsdk/formfiller/cffl_formfield.cpp
+++ b/fpdfsdk/formfiller/cffl_formfield.cpp
@@ -88,7 +88,7 @@
 
 bool CFFL_FormField::OnLButtonDown(CPDFSDK_PageView* pPageView,
                                    CPDFSDK_Annot* pAnnot,
-                                   FWL_EventFlagMask nFlags,
+                                   Mask<FWL_EVENTFLAG> nFlags,
                                    const CFX_PointF& point) {
   CPWL_Wnd* pWnd = CreateOrUpdatePWLWindow(pPageView);
   if (!pWnd)
@@ -104,7 +104,7 @@
 
 bool CFFL_FormField::OnLButtonUp(CPDFSDK_PageView* pPageView,
                                  CPDFSDK_Annot* pAnnot,
-                                 FWL_EventFlagMask nFlags,
+                                 Mask<FWL_EVENTFLAG> nFlags,
                                  const CFX_PointF& point) {
   CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
   if (!pWnd)
@@ -116,7 +116,7 @@
 }
 
 bool CFFL_FormField::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
-                                     FWL_EventFlagMask nFlags,
+                                     Mask<FWL_EVENTFLAG> nFlags,
                                      const CFX_PointF& point) {
   CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
   if (!pWnd)
@@ -127,7 +127,7 @@
 }
 
 bool CFFL_FormField::OnMouseMove(CPDFSDK_PageView* pPageView,
-                                 FWL_EventFlagMask nFlags,
+                                 Mask<FWL_EVENTFLAG> nFlags,
                                  const CFX_PointF& point) {
   CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
   if (!pWnd)
@@ -138,7 +138,7 @@
 }
 
 bool CFFL_FormField::OnMouseWheel(CPDFSDK_PageView* pPageView,
-                                  FWL_EventFlagMask nFlags,
+                                  Mask<FWL_EVENTFLAG> nFlags,
                                   const CFX_PointF& point,
                                   const CFX_Vector& delta) {
   if (!IsValid())
@@ -149,21 +149,21 @@
 }
 
 bool CFFL_FormField::OnRButtonDown(CPDFSDK_PageView* pPageView,
-                                   FWL_EventFlagMask nFlags,
+                                   Mask<FWL_EVENTFLAG> nFlags,
                                    const CFX_PointF& point) {
   CPWL_Wnd* pWnd = CreateOrUpdatePWLWindow(pPageView);
   return pWnd && pWnd->OnRButtonDown(nFlags, FFLtoPWL(point));
 }
 
 bool CFFL_FormField::OnRButtonUp(CPDFSDK_PageView* pPageView,
-                                 FWL_EventFlagMask nFlags,
+                                 Mask<FWL_EVENTFLAG> nFlags,
                                  const CFX_PointF& point) {
   CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
   return pWnd && pWnd->OnRButtonUp(nFlags, FFLtoPWL(point));
 }
 
 bool CFFL_FormField::OnKeyDown(FWL_VKEYCODE nKeyCode,
-                               FWL_EventFlagMask nFlags) {
+                               Mask<FWL_EVENTFLAG> nFlags) {
   if (!IsValid())
     return false;
 
@@ -173,7 +173,7 @@
 
 bool CFFL_FormField::OnChar(CPDFSDK_Annot* pAnnot,
                             uint32_t nChar,
-                            FWL_EventFlagMask nFlags) {
+                            Mask<FWL_EVENTFLAG> nFlags) {
   if (!IsValid())
     return false;
 
@@ -257,7 +257,7 @@
 }
 
 void CFFL_FormField::SetFocusForAnnot(CPDFSDK_Annot* pAnnot,
-                                      FWL_EventFlagMask nFlag) {
+                                      Mask<FWL_EVENTFLAG> nFlag) {
   CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
   IPDF_Page* pPage = pWidget->GetPage();
   CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetOrCreatePageView(pPage);
@@ -269,7 +269,7 @@
   InvalidateRect(GetViewBBox(pPageView));
 }
 
-void CFFL_FormField::KillFocusForAnnot(FWL_EventFlagMask nFlag) {
+void CFFL_FormField::KillFocusForAnnot(Mask<FWL_EVENTFLAG> nFlag) {
   if (!IsValid())
     return;
 
@@ -463,7 +463,7 @@
 }
 
 bool CFFL_FormField::CommitData(const CPDFSDK_PageView* pPageView,
-                                FWL_EventFlagMask nFlag) {
+                                Mask<FWL_EVENTFLAG> nFlag) {
   if (!IsDataChanged(pPageView))
     return true;
 
diff --git a/fpdfsdk/formfiller/cffl_formfield.h b/fpdfsdk/formfiller/cffl_formfield.h
index a7057f7..b7f03a8 100644
--- a/fpdfsdk/formfiller/cffl_formfield.h
+++ b/fpdfsdk/formfiller/cffl_formfield.h
@@ -11,6 +11,7 @@
 #include <memory>
 
 #include "core/fxcrt/cfx_timer.h"
+#include "core/fxcrt/mask.h"
 #include "core/fxcrt/unowned_ptr.h"
 #include "fpdfsdk/cpdfsdk_fieldaction.h"
 #include "fpdfsdk/cpdfsdk_widget.h"
@@ -43,33 +44,33 @@
 
   virtual bool OnLButtonDown(CPDFSDK_PageView* pPageView,
                              CPDFSDK_Annot* pAnnot,
-                             FWL_EventFlagMask nFlags,
+                             Mask<FWL_EVENTFLAG> nFlags,
                              const CFX_PointF& point);
   virtual bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                            CPDFSDK_Annot* pAnnot,
-                           FWL_EventFlagMask nFlags,
+                           Mask<FWL_EVENTFLAG> nFlags,
                            const CFX_PointF& point);
   virtual bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
-                               FWL_EventFlagMask nFlags,
+                               Mask<FWL_EVENTFLAG> nFlags,
                                const CFX_PointF& point);
   virtual bool OnMouseMove(CPDFSDK_PageView* pPageView,
-                           FWL_EventFlagMask nFlags,
+                           Mask<FWL_EVENTFLAG> nFlags,
                            const CFX_PointF& point);
   virtual bool OnMouseWheel(CPDFSDK_PageView* pPageView,
-                            FWL_EventFlagMask nFlags,
+                            Mask<FWL_EVENTFLAG> nFlags,
                             const CFX_PointF& point,
                             const CFX_Vector& delta);
   virtual bool OnRButtonDown(CPDFSDK_PageView* pPageView,
-                             FWL_EventFlagMask nFlags,
+                             Mask<FWL_EVENTFLAG> nFlags,
                              const CFX_PointF& point);
   virtual bool OnRButtonUp(CPDFSDK_PageView* pPageView,
-                           FWL_EventFlagMask nFlags,
+                           Mask<FWL_EVENTFLAG> nFlags,
                            const CFX_PointF& point);
 
-  virtual bool OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlags);
+  virtual bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlags);
   virtual bool OnChar(CPDFSDK_Annot* pAnnot,
                       uint32_t nChar,
-                      FWL_EventFlagMask nFlags);
+                      Mask<FWL_EVENTFLAG> nFlags);
   virtual bool SetIndexSelected(int index, bool selected);
   virtual bool IsIndexSelected(int index);
 
@@ -85,8 +86,8 @@
   bool Undo();
   bool Redo();
 
-  void SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FWL_EventFlagMask nFlag);
-  void KillFocusForAnnot(FWL_EventFlagMask nFlag);
+  void SetFocusForAnnot(CPDFSDK_Annot* pAnnot, Mask<FWL_EVENTFLAG> nFlag);
+  void KillFocusForAnnot(Mask<FWL_EVENTFLAG> nFlag);
 
   // CFX_Timer::CallbackIface:
   void OnTimerFired() override;
@@ -120,7 +121,7 @@
   CFX_FloatRect PWLtoFFL(const CFX_FloatRect& rect);
   CFX_PointF FFLtoPWL(const CFX_PointF& point);
   CFX_PointF PWLtoFFL(const CFX_PointF& point);
-  bool CommitData(const CPDFSDK_PageView* pPageView, FWL_EventFlagMask nFlag);
+  bool CommitData(const CPDFSDK_PageView* pPageView, Mask<FWL_EVENTFLAG> nFlag);
   CPWL_Wnd* ResetPWLWindowForValueAge(const CPDFSDK_PageView* pPageView,
                                       CPDFSDK_Widget* pWidget,
                                       uint32_t nValueAge);
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
index cd93e7b..75a080e 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
@@ -100,7 +100,7 @@
 void CFFL_InteractiveFormFiller::OnMouseEnter(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlag) {
+    Mask<FWL_EVENTFLAG> nFlag) {
   DCHECK_EQ((*pAnnot)->GetPDFAnnot()->GetSubtype(),
             CPDF_Annot::Subtype::WIDGET);
   if (!m_bNotifying) {
@@ -133,7 +133,7 @@
 
 void CFFL_InteractiveFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView,
                                              ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                             FWL_EventFlagMask nFlag) {
+                                             Mask<FWL_EVENTFLAG> nFlag) {
   DCHECK_EQ((*pAnnot)->GetPDFAnnot()->GetSubtype(),
             CPDF_Annot::Subtype::WIDGET);
   if (!m_bNotifying) {
@@ -167,7 +167,7 @@
 bool CFFL_InteractiveFormFiller::OnLButtonDown(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlags,
+    Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK_EQ((*pAnnot)->GetPDFAnnot()->GetSubtype(),
             CPDF_Annot::Subtype::WIDGET);
@@ -206,7 +206,7 @@
 
 bool CFFL_InteractiveFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView,
                                              ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                             FWL_EventFlagMask nFlags,
+                                             Mask<FWL_EVENTFLAG> nFlags,
                                              const CFX_PointF& point) {
   DCHECK_EQ((*pAnnot)->GetPDFAnnot()->GetSubtype(),
             CPDF_Annot::Subtype::WIDGET);
@@ -245,7 +245,7 @@
 
 bool CFFL_InteractiveFormFiller::OnButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                             const CPDFSDK_PageView* pPageView,
-                                            FWL_EventFlagMask nFlag) {
+                                            Mask<FWL_EVENTFLAG> nFlag) {
   if (m_bNotifying)
     return false;
 
@@ -299,7 +299,7 @@
 bool CFFL_InteractiveFormFiller::OnLButtonDblClk(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlags,
+    Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK_EQ((*pAnnot)->GetPDFAnnot()->GetSubtype(),
             CPDF_Annot::Subtype::WIDGET);
@@ -309,7 +309,7 @@
 
 bool CFFL_InteractiveFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView,
                                              ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                             FWL_EventFlagMask nFlags,
+                                             Mask<FWL_EVENTFLAG> nFlags,
                                              const CFX_PointF& point) {
   DCHECK_EQ((*pAnnot)->GetPDFAnnot()->GetSubtype(),
             CPDF_Annot::Subtype::WIDGET);
@@ -320,7 +320,7 @@
 bool CFFL_InteractiveFormFiller::OnMouseWheel(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlags,
+    Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point,
     const CFX_Vector& delta) {
   DCHECK_EQ((*pAnnot)->GetPDFAnnot()->GetSubtype(),
@@ -333,7 +333,7 @@
 bool CFFL_InteractiveFormFiller::OnRButtonDown(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    FWL_EventFlagMask nFlags,
+    Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK_EQ((*pAnnot)->GetPDFAnnot()->GetSubtype(),
             CPDF_Annot::Subtype::WIDGET);
@@ -343,7 +343,7 @@
 
 bool CFFL_InteractiveFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView,
                                              ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                             FWL_EventFlagMask nFlags,
+                                             Mask<FWL_EVENTFLAG> nFlags,
                                              const CFX_PointF& point) {
   DCHECK_EQ((*pAnnot)->GetPDFAnnot()->GetSubtype(),
             CPDF_Annot::Subtype::WIDGET);
@@ -353,7 +353,7 @@
 
 bool CFFL_InteractiveFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot,
                                            FWL_VKEYCODE nKeyCode,
-                                           FWL_EventFlagMask nFlags) {
+                                           Mask<FWL_EVENTFLAG> nFlags) {
   DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
 
   CFFL_FormField* pFormField = GetFormField(pAnnot);
@@ -362,7 +362,7 @@
 
 bool CFFL_InteractiveFormFiller::OnChar(CPDFSDK_Annot* pAnnot,
                                         uint32_t nChar,
-                                        FWL_EventFlagMask nFlags) {
+                                        Mask<FWL_EVENTFLAG> nFlags) {
   DCHECK_EQ(pAnnot->GetPDFAnnot()->GetSubtype(), CPDF_Annot::Subtype::WIDGET);
   if (nChar == pdfium::ascii::kTab)
     return true;
@@ -372,7 +372,7 @@
 }
 
 bool CFFL_InteractiveFormFiller::OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                            FWL_EventFlagMask nFlag) {
+                                            Mask<FWL_EVENTFLAG> nFlag) {
   if (!pAnnot->HasObservable())
     return false;
 
@@ -417,7 +417,7 @@
 }
 
 bool CFFL_InteractiveFormFiller::OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                             FWL_EventFlagMask nFlag) {
+                                             Mask<FWL_EVENTFLAG> nFlag) {
   if (!pAnnot->HasObservable())
     return false;
 
@@ -646,7 +646,7 @@
 bool CFFL_InteractiveFormFiller::OnKeyStrokeCommit(
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
     const CPDFSDK_PageView* pPageView,
-    FWL_EventFlagMask nFlag) {
+    Mask<FWL_EVENTFLAG> nFlag) {
   if (m_bNotifying)
     return true;
 
@@ -678,7 +678,7 @@
 
 bool CFFL_InteractiveFormFiller::OnValidate(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                             const CPDFSDK_PageView* pPageView,
-                                            FWL_EventFlagMask nFlag) {
+                                            Mask<FWL_EVENTFLAG> nFlag) {
   if (m_bNotifying)
     return true;
 
@@ -709,7 +709,7 @@
 
 void CFFL_InteractiveFormFiller::OnCalculate(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                              const CPDFSDK_PageView* pPageView,
-                                             FWL_EventFlagMask nFlag) {
+                                             Mask<FWL_EVENTFLAG> nFlag) {
   if (m_bNotifying)
     return;
 
@@ -724,7 +724,7 @@
 
 void CFFL_InteractiveFormFiller::OnFormat(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                           const CPDFSDK_PageView* pPageView,
-                                          FWL_EventFlagMask nFlag) {
+                                          Mask<FWL_EVENTFLAG> nFlag) {
   if (m_bNotifying)
     return;
 
@@ -748,7 +748,7 @@
 #ifdef PDF_ENABLE_XFA
 bool CFFL_InteractiveFormFiller::OnClick(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                          const CPDFSDK_PageView* pPageView,
-                                         FWL_EventFlagMask nFlag) {
+                                         Mask<FWL_EVENTFLAG> nFlag) {
   if (m_bNotifying)
     return false;
 
@@ -779,7 +779,7 @@
 
 bool CFFL_InteractiveFormFiller::OnFull(ObservedPtr<CPDFSDK_Widget>* pAnnot,
                                         const CPDFSDK_PageView* pPageView,
-                                        FWL_EventFlagMask nFlag) {
+                                        Mask<FWL_EVENTFLAG> nFlag) {
   if (m_bNotifying)
     return false;
 
@@ -810,7 +810,7 @@
 
 bool CFFL_InteractiveFormFiller::OnPreOpen(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                            const CPDFSDK_PageView* pPageView,
-                                           FWL_EventFlagMask nFlag) {
+                                           Mask<FWL_EVENTFLAG> nFlag) {
   if (m_bNotifying)
     return false;
 
@@ -841,7 +841,7 @@
 
 bool CFFL_InteractiveFormFiller::OnPostOpen(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                             const CPDFSDK_PageView* pPageView,
-                                            FWL_EventFlagMask nFlag) {
+                                            Mask<FWL_EVENTFLAG> nFlag) {
   if (m_bNotifying)
     return false;
 
@@ -885,7 +885,7 @@
     int nSelStart,
     int nSelEnd,
     bool bKeyDown,
-    FWL_EventFlagMask nFlag) {
+    Mask<FWL_EVENTFLAG> nFlag) {
   // Copy out of private data since the window owning it may not survive.
   auto* pPrivateData = static_cast<const CFFL_PrivateData*>(pAttached);
   const CPDFSDK_PageView* pPageView = pPrivateData->GetPageView();
@@ -962,7 +962,7 @@
 
 bool CFFL_InteractiveFormFiller::OnPopupPreOpen(
     const IPWL_SystemHandler::PerWindowData* pAttached,
-    FWL_EventFlagMask nFlag) {
+    Mask<FWL_EVENTFLAG> nFlag) {
 #ifdef PDF_ENABLE_XFA
   auto* pData = static_cast<const CFFL_PrivateData*>(pAttached);
   DCHECK(pData->GetWidget());
@@ -976,7 +976,7 @@
 
 bool CFFL_InteractiveFormFiller::OnPopupPostOpen(
     const IPWL_SystemHandler::PerWindowData* pAttached,
-    FWL_EventFlagMask nFlag) {
+    Mask<FWL_EVENTFLAG> nFlag) {
 #ifdef PDF_ENABLE_XFA
   auto* pData = static_cast<const CFFL_PrivateData*>(pAttached);
   DCHECK(pData->GetWidget());
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.h b/fpdfsdk/formfiller/cffl_interactiveformfiller.h
index ae9f7a6..9a282df 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.h
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.h
@@ -11,6 +11,7 @@
 #include <memory>
 #include <utility>
 
+#include "core/fxcrt/mask.h"
 #include "core/fxcrt/observed_ptr.h"
 #include "core/fxcrt/unowned_ptr.h"
 #include "fpdfsdk/cpdfsdk_annot.h"
@@ -42,47 +43,51 @@
 
   void OnMouseEnter(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    FWL_EventFlagMask nFlag);
+                    Mask<FWL_EVENTFLAG> nFlag);
   void OnMouseExit(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlag);
+                   Mask<FWL_EVENTFLAG> nFlag);
   bool OnLButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     FWL_EventFlagMask nFlags,
+                     Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point);
   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point);
   bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                       FWL_EventFlagMask nFlags,
+                       Mask<FWL_EVENTFLAG> nFlags,
                        const CFX_PointF& point);
   bool OnMouseMove(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point);
   bool OnMouseWheel(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    FWL_EventFlagMask nFlags,
+                    Mask<FWL_EVENTFLAG> nFlags,
                     const CFX_PointF& point,
                     const CFX_Vector& delta);
   bool OnRButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     FWL_EventFlagMask nFlags,
+                     Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point);
   bool OnRButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point);
 
   bool OnKeyDown(CPDFSDK_Annot* pAnnot,
                  FWL_VKEYCODE nKeyCode,
-                 FWL_EventFlagMask nFlags);
-  bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, FWL_EventFlagMask nFlags);
+                 Mask<FWL_EVENTFLAG> nFlags);
+  bool OnChar(CPDFSDK_Annot* pAnnot,
+              uint32_t nChar,
+              Mask<FWL_EVENTFLAG> nFlags);
 
-  bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, FWL_EventFlagMask nFlag);
-  bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, FWL_EventFlagMask nFlag);
+  bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
+                  Mask<FWL_EVENTFLAG> nFlag);
+  bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
+                   Mask<FWL_EVENTFLAG> nFlag);
 
   CFFL_FormField* GetFormFieldForTesting(CPDFSDK_Annot* pAnnot) {
     return GetFormField(pAnnot);
@@ -105,19 +110,19 @@
 
   bool OnKeyStrokeCommit(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                          const CPDFSDK_PageView* pPageView,
-                         FWL_EventFlagMask nFlag);
+                         Mask<FWL_EVENTFLAG> nFlag);
   bool OnValidate(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                   const CPDFSDK_PageView* pPageView,
-                  FWL_EventFlagMask nFlag);
+                  Mask<FWL_EVENTFLAG> nFlag);
   void OnCalculate(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                    const CPDFSDK_PageView* pPageView,
-                   FWL_EventFlagMask nFlag);
+                   Mask<FWL_EVENTFLAG> nFlag);
   void OnFormat(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                 const CPDFSDK_PageView* pPageView,
-                FWL_EventFlagMask nFlag);
+                Mask<FWL_EVENTFLAG> nFlag);
   bool OnButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                   const CPDFSDK_PageView* pPageView,
-                  FWL_EventFlagMask nFlag);
+                  Mask<FWL_EVENTFLAG> nFlag);
 
   bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                         int index,
@@ -142,26 +147,26 @@
       int nSelStart,
       int nSelEnd,
       bool bKeyDown,
-      FWL_EventFlagMask nFlag) override;
+      Mask<FWL_EVENTFLAG> nFlag) override;
   bool OnPopupPreOpen(const IPWL_SystemHandler::PerWindowData* pAttached,
-                      FWL_EventFlagMask nFlag) override;
+                      Mask<FWL_EVENTFLAG> nFlag) override;
   bool OnPopupPostOpen(const IPWL_SystemHandler::PerWindowData* pAttached,
-                       FWL_EventFlagMask nFlag) override;
+                       Mask<FWL_EVENTFLAG> nFlag) override;
 
 #ifdef PDF_ENABLE_XFA
   void SetFocusAnnotTab(CPDFSDK_Annot* pWidget, bool bSameField, bool bNext);
   bool OnClick(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                const CPDFSDK_PageView* pPageView,
-               FWL_EventFlagMask nFlag);
+               Mask<FWL_EVENTFLAG> nFlag);
   bool OnFull(ObservedPtr<CPDFSDK_Widget>* pAnnot,
               const CPDFSDK_PageView* pPageView,
-              FWL_EventFlagMask nFlag);
+              Mask<FWL_EVENTFLAG> nFlag);
   bool OnPreOpen(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                  const CPDFSDK_PageView* pPageView,
-                 FWL_EventFlagMask nFlag);
+                 Mask<FWL_EVENTFLAG> nFlag);
   bool OnPostOpen(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                   const CPDFSDK_PageView* pPageView,
-                  FWL_EventFlagMask nFlag);
+                  Mask<FWL_EVENTFLAG> nFlag);
 #endif  // PDF_ENABLE_XFA
 
   bool IsFillingAllowed(CPDFSDK_Widget* pWidget) const;
diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp
index cc3143e..3a69181 100644
--- a/fpdfsdk/formfiller/cffl_listbox.cpp
+++ b/fpdfsdk/formfiller/cffl_listbox.cpp
@@ -79,7 +79,7 @@
 
 bool CFFL_ListBox::OnChar(CPDFSDK_Annot* pAnnot,
                           uint32_t nChar,
-                          FWL_EventFlagMask nFlags) {
+                          Mask<FWL_EVENTFLAG> nFlags) {
   return CFFL_TextObject::OnChar(pAnnot, nChar, nFlags);
 }
 
diff --git a/fpdfsdk/formfiller/cffl_listbox.h b/fpdfsdk/formfiller/cffl_listbox.h
index ff0b511..5814c3b 100644
--- a/fpdfsdk/formfiller/cffl_listbox.h
+++ b/fpdfsdk/formfiller/cffl_listbox.h
@@ -28,7 +28,7 @@
       override;
   bool OnChar(CPDFSDK_Annot* pAnnot,
               uint32_t nChar,
-              FWL_EventFlagMask nFlags) override;
+              Mask<FWL_EVENTFLAG> nFlags) override;
   bool IsDataChanged(const CPDFSDK_PageView* pPageView) override;
   void SaveData(const CPDFSDK_PageView* pPageView) override;
   void GetActionData(const CPDFSDK_PageView* pPageView,
diff --git a/fpdfsdk/formfiller/cffl_radiobutton.cpp b/fpdfsdk/formfiller/cffl_radiobutton.cpp
index 4f73945..55f0ca4 100644
--- a/fpdfsdk/formfiller/cffl_radiobutton.cpp
+++ b/fpdfsdk/formfiller/cffl_radiobutton.cpp
@@ -33,7 +33,7 @@
 }
 
 bool CFFL_RadioButton::OnKeyDown(FWL_VKEYCODE nKeyCode,
-                                 FWL_EventFlagMask nFlags) {
+                                 Mask<FWL_EVENTFLAG> nFlags) {
   switch (nKeyCode) {
     case FWL_VKEY_Return:
     case FWL_VKEY_Space:
@@ -45,7 +45,7 @@
 
 bool CFFL_RadioButton::OnChar(CPDFSDK_Annot* pAnnot,
                               uint32_t nChar,
-                              FWL_EventFlagMask nFlags) {
+                              Mask<FWL_EVENTFLAG> nFlags) {
   switch (nChar) {
     case pdfium::ascii::kReturn:
     case pdfium::ascii::kSpace: {
@@ -72,7 +72,7 @@
 
 bool CFFL_RadioButton::OnLButtonUp(CPDFSDK_PageView* pPageView,
                                    CPDFSDK_Annot* pAnnot,
-                                   FWL_EventFlagMask nFlags,
+                                   Mask<FWL_EVENTFLAG> nFlags,
                                    const CFX_PointF& point) {
   CFFL_Button::OnLButtonUp(pPageView, pAnnot, nFlags, point);
 
diff --git a/fpdfsdk/formfiller/cffl_radiobutton.h b/fpdfsdk/formfiller/cffl_radiobutton.h
index ea75ebc..847113c 100644
--- a/fpdfsdk/formfiller/cffl_radiobutton.h
+++ b/fpdfsdk/formfiller/cffl_radiobutton.h
@@ -23,13 +23,13 @@
       const CPWL_Wnd::CreateParams& cp,
       std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData)
       override;
-  bool OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlags) override;
+  bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlags) override;
   bool OnChar(CPDFSDK_Annot* pAnnot,
               uint32_t nChar,
-              FWL_EventFlagMask nFlags) override;
+              Mask<FWL_EVENTFLAG> nFlags) override;
   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                    CPDFSDK_Annot* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
   bool IsDataChanged(const CPDFSDK_PageView* pPageView) override;
   void SaveData(const CPDFSDK_PageView* pPageView) override;
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index c175050..ac2f152 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -107,7 +107,7 @@
 
 bool CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot,
                             uint32_t nChar,
-                            FWL_EventFlagMask nFlags) {
+                            Mask<FWL_EVENTFLAG> nFlags) {
   switch (nChar) {
     case pdfium::ascii::kReturn: {
       if (m_pWidget->GetFieldFlags() & pdfium::form_flags::kTextMultiline)
diff --git a/fpdfsdk/formfiller/cffl_textfield.h b/fpdfsdk/formfiller/cffl_textfield.h
index b48ae1c..b0e11a8 100644
--- a/fpdfsdk/formfiller/cffl_textfield.h
+++ b/fpdfsdk/formfiller/cffl_textfield.h
@@ -33,7 +33,7 @@
       override;
   bool OnChar(CPDFSDK_Annot* pAnnot,
               uint32_t nChar,
-              FWL_EventFlagMask nFlags) override;
+              Mask<FWL_EVENTFLAG> nFlags) override;
   bool IsDataChanged(const CPDFSDK_PageView* pPageView) override;
   void SaveData(const CPDFSDK_PageView* pPageView) override;
   void GetActionData(const CPDFSDK_PageView* pPageView,
diff --git a/fpdfsdk/fpdf_formfill.cpp b/fpdfsdk/fpdf_formfill.cpp
index 71ea438..58c9d03 100644
--- a/fpdfsdk/fpdf_formfill.cpp
+++ b/fpdfsdk/fpdf_formfill.cpp
@@ -374,8 +374,9 @@
                                                      double page_y) {
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
   return pPageView &&
-         pPageView->OnMouseMove(static_cast<FWL_EventFlagMask>(modifier),
-                                CFX_PointF(page_x, page_y));
+         pPageView->OnMouseMove(
+             Mask<FWL_EVENTFLAG>::FromUnderlyingUnchecked(modifier),
+             CFX_PointF(page_x, page_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
@@ -390,9 +391,9 @@
 
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
   return pPageView &&
-         pPageView->OnMouseWheel(static_cast<FWL_EventFlagMask>(modifier),
-                                 CFXPointFFromFSPointF(*page_coord),
-                                 CFX_Vector(delta_x, delta_y));
+         pPageView->OnMouseWheel(
+             Mask<FWL_EVENTFLAG>::FromUnderlyingUnchecked(modifier),
+             CFXPointFFromFSPointF(*page_coord), CFX_Vector(delta_x, delta_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnFocus(FPDF_FORMHANDLE hHandle,
@@ -402,8 +403,9 @@
                                                  double page_y) {
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
   return pPageView &&
-         pPageView->OnFocus(static_cast<FWL_EventFlagMask>(modifier),
-                            CFX_PointF(page_x, page_y));
+         pPageView->OnFocus(
+             Mask<FWL_EVENTFLAG>::FromUnderlyingUnchecked(modifier),
+             CFX_PointF(page_x, page_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle,
@@ -417,8 +419,9 @@
 #endif  // PDF_ENABLE_CLICK_LOGGING
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
   return pPageView &&
-         pPageView->OnLButtonDown(static_cast<FWL_EventFlagMask>(modifier),
-                                  CFX_PointF(page_x, page_y));
+         pPageView->OnLButtonDown(
+             Mask<FWL_EVENTFLAG>::FromUnderlyingUnchecked(modifier),
+             CFX_PointF(page_x, page_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle,
@@ -432,8 +435,9 @@
 #endif  // PDF_ENABLE_CLICK_LOGGING
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
   return pPageView &&
-         pPageView->OnLButtonUp(static_cast<FWL_EventFlagMask>(modifier),
-                                CFX_PointF(page_x, page_y));
+         pPageView->OnLButtonUp(
+             Mask<FWL_EVENTFLAG>::FromUnderlyingUnchecked(modifier),
+             CFX_PointF(page_x, page_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
@@ -448,8 +452,9 @@
 #endif  // PDF_ENABLE_CLICK_LOGGING
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
   return pPageView &&
-         pPageView->OnLButtonDblClk(static_cast<FWL_EventFlagMask>(modifier),
-                                    CFX_PointF(page_x, page_y));
+         pPageView->OnLButtonDblClk(
+             Mask<FWL_EVENTFLAG>::FromUnderlyingUnchecked(modifier),
+             CFX_PointF(page_x, page_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle,
@@ -463,8 +468,9 @@
 #endif  // PDF_ENABLE_CLICK_LOGGING
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
   return pPageView &&
-         pPageView->OnRButtonDown(static_cast<FWL_EventFlagMask>(modifier),
-                                  CFX_PointF(page_x, page_y));
+         pPageView->OnRButtonDown(
+             Mask<FWL_EVENTFLAG>::FromUnderlyingUnchecked(modifier),
+             CFX_PointF(page_x, page_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle,
@@ -478,8 +484,9 @@
 #endif  // PDF_ENABLE_CLICK_LOGGING
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
   return pPageView &&
-         pPageView->OnRButtonUp(static_cast<FWL_EventFlagMask>(modifier),
-                                CFX_PointF(page_x, page_y));
+         pPageView->OnRButtonUp(
+             Mask<FWL_EVENTFLAG>::FromUnderlyingUnchecked(modifier),
+             CFX_PointF(page_x, page_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnKeyDown(FPDF_FORMHANDLE hHandle,
@@ -488,8 +495,9 @@
                                                    int modifier) {
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
   return pPageView &&
-         pPageView->OnKeyDown(static_cast<FWL_VKEYCODE>(nKeyCode),
-                              static_cast<FWL_EventFlagMask>(modifier));
+         pPageView->OnKeyDown(
+             static_cast<FWL_VKEYCODE>(nKeyCode),
+             Mask<FWL_EVENTFLAG>::FromUnderlyingUnchecked(modifier));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnKeyUp(FPDF_FORMHANDLE hHandle,
@@ -498,8 +506,9 @@
                                                  int modifier) {
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
   return pPageView &&
-         pPageView->OnKeyUp(static_cast<FWL_VKEYCODE>(nKeyCode),
-                            static_cast<FWL_EventFlagMask>(modifier));
+         pPageView->OnKeyUp(
+             static_cast<FWL_VKEYCODE>(nKeyCode),
+             Mask<FWL_EVENTFLAG>::FromUnderlyingUnchecked(modifier));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnChar(FPDF_FORMHANDLE hHandle,
@@ -508,7 +517,8 @@
                                                 int modifier) {
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
   return pPageView &&
-         pPageView->OnChar(nChar, static_cast<FWL_EventFlagMask>(modifier));
+         pPageView->OnChar(
+             nChar, Mask<FWL_EVENTFLAG>::FromUnderlyingUnchecked(modifier));
 }
 
 FPDF_EXPORT unsigned long FPDF_CALLCONV
@@ -591,7 +601,7 @@
       CPDFSDKFormFillEnvironmentFromFPDFFormHandle(hHandle);
   if (!pFormFillEnv)
     return false;
-  return pFormFillEnv->KillFocusAnnot(0);
+  return pFormFillEnv->KillFocusAnnot({});
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
index 7925838..076232a 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
@@ -24,9 +24,11 @@
 
 namespace {
 
-constexpr XFA_WidgetStatusMask kIteratorFilter = XFA_WidgetStatus_Visible |
-                                                 XFA_WidgetStatus_Viewable |
-                                                 XFA_WidgetStatus_Focused;
+constexpr Mask<XFA_WidgetStatus> kIteratorFilter = {
+    XFA_WidgetStatus::kVisible,
+    XFA_WidgetStatus::kViewable,
+    XFA_WidgetStatus::kFocused,
+};
 
 CXFA_FFWidget::IteratorIface* GCedWidgetIteratorForPage(
     CXFA_FFPageView* pFFPageView,
@@ -273,7 +275,7 @@
     return -1;
 
   CXFA_FFWidget::IteratorIface* pWidgetIterator =
-      pPageView->CreateGCedFormWidgetIterator(XFA_WidgetStatus_Viewable);
+      pPageView->CreateGCedFormWidgetIterator(XFA_WidgetStatus::kViewable);
 
   CXFA_FFWidget* pXFAAnnot;
   while ((pXFAAnnot = pWidgetIterator->MoveToNext()) != nullptr) {
@@ -299,8 +301,8 @@
 
   CXFA_FFPageView* xfaView = GetXFAPageView();
   CXFA_FFWidget::IteratorIface* pWidgetIterator =
-      xfaView->CreateGCedFormWidgetIterator(XFA_WidgetStatus_Visible |
-                                            XFA_WidgetStatus_Viewable);
+      xfaView->CreateGCedFormWidgetIterator(Mask<XFA_WidgetStatus>{
+          XFA_WidgetStatus::kVisible, XFA_WidgetStatus::kViewable});
 
   while (1) {
     CXFA_FFWidget* pWidget = pWidgetIterator->MoveToNext();
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
index 8181f5f..df9ee63 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
@@ -372,7 +372,7 @@
 
 void CPDFXFA_WidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                         FWL_EventFlagMask nFlag) {
+                                         Mask<FWL_EVENTFLAG> nFlag) {
   if (!pPageView)
     return;
 
@@ -386,7 +386,7 @@
 
 void CPDFXFA_WidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        FWL_EventFlagMask nFlag) {
+                                        Mask<FWL_EVENTFLAG> nFlag) {
   if (!pPageView)
     return;
 
@@ -400,7 +400,7 @@
 
 bool CPDFXFA_WidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
                                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                          FWL_EventFlagMask nFlags,
+                                          Mask<FWL_EVENTFLAG> nFlags,
                                           const CFX_PointF& point) {
   if (!pPageView)
     return false;
@@ -416,7 +416,7 @@
 
 bool CPDFXFA_WidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        FWL_EventFlagMask nFlags,
+                                        Mask<FWL_EVENTFLAG> nFlags,
                                         const CFX_PointF& point) {
   if (!pPageView)
     return false;
@@ -432,7 +432,7 @@
 
 bool CPDFXFA_WidgetHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                            FWL_EventFlagMask nFlags,
+                                            Mask<FWL_EVENTFLAG> nFlags,
                                             const CFX_PointF& point) {
   if (!pPageView)
     return false;
@@ -448,7 +448,7 @@
 
 bool CPDFXFA_WidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        FWL_EventFlagMask nFlags,
+                                        Mask<FWL_EVENTFLAG> nFlags,
                                         const CFX_PointF& point) {
   if (!pPageView)
     return false;
@@ -464,7 +464,7 @@
 
 bool CPDFXFA_WidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                         FWL_EventFlagMask nFlags,
+                                         Mask<FWL_EVENTFLAG> nFlags,
                                          const CFX_PointF& point,
                                          const CFX_Vector& delta) {
   if (!pPageView)
@@ -481,7 +481,7 @@
 
 bool CPDFXFA_WidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
                                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                          FWL_EventFlagMask nFlags,
+                                          Mask<FWL_EVENTFLAG> nFlags,
                                           const CFX_PointF& point) {
   if (!pPageView)
     return false;
@@ -497,7 +497,7 @@
 
 bool CPDFXFA_WidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        FWL_EventFlagMask nFlags,
+                                        Mask<FWL_EVENTFLAG> nFlags,
                                         const CFX_PointF& point) {
   if (!pPageView)
     return false;
@@ -513,7 +513,7 @@
 
 bool CPDFXFA_WidgetHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView,
                                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                            FWL_EventFlagMask nFlags,
+                                            Mask<FWL_EVENTFLAG> nFlags,
                                             const CFX_PointF& point) {
   if (!pPageView)
     return false;
@@ -529,7 +529,7 @@
 
 bool CPDFXFA_WidgetHandler::OnChar(CPDFSDK_Annot* pAnnot,
                                    uint32_t nChar,
-                                   FWL_EventFlagMask nFlags) {
+                                   Mask<FWL_EVENTFLAG> nFlags) {
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot);
   if (!pXFAWidget)
     return false;
@@ -541,7 +541,7 @@
 
 bool CPDFXFA_WidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
                                       FWL_VKEYCODE nKeyCode,
-                                      FWL_EventFlagMask nFlag) {
+                                      Mask<FWL_EVENTFLAG> nFlag) {
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot);
   if (!pXFAWidget)
     return false;
@@ -554,7 +554,7 @@
 
 bool CPDFXFA_WidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
                                     FWL_VKEYCODE nKeyCode,
-                                    FWL_EventFlagMask nFlag) {
+                                    Mask<FWL_EVENTFLAG> nFlag) {
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot);
   if (!pXFAWidget)
     return false;
@@ -566,12 +566,12 @@
 }
 
 bool CPDFXFA_WidgetHandler::OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                       FWL_EventFlagMask nFlag) {
+                                       Mask<FWL_EVENTFLAG> nFlag) {
   return true;
 }
 
 bool CPDFXFA_WidgetHandler::OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        FWL_EventFlagMask nFlag) {
+                                        Mask<FWL_EVENTFLAG> nFlag) {
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot->Get());
   if (!pXFAWidget)
     return true;
@@ -651,7 +651,7 @@
 }
 
 Mask<XFA_FWL_KeyFlag> CPDFXFA_WidgetHandler::GetKeyFlags(
-    FWL_EventFlagMask dwFlag) {
+    Mask<FWL_EVENTFLAG> dwFlag) {
   Mask<XFA_FWL_KeyFlag> dwFWLFlag;
 
   if (dwFlag & FWL_EVENTFLAG_ControlKey)
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
index 199ffc9..2794533 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
@@ -57,56 +57,56 @@
   void OnLoad(CPDFSDK_Annot* pAnnot) override;
   void OnMouseEnter(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    FWL_EventFlagMask nFlag) override;
+                    Mask<FWL_EVENTFLAG> nFlag) override;
   void OnMouseExit(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlag) override;
+                   Mask<FWL_EVENTFLAG> nFlag) override;
   bool OnLButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     FWL_EventFlagMask nFlags,
+                     Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point) override;
   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
   bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                       FWL_EventFlagMask nFlags,
+                       Mask<FWL_EVENTFLAG> nFlags,
                        const CFX_PointF& point) override;
   bool OnMouseMove(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
   bool OnMouseWheel(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    FWL_EventFlagMask nFlags,
+                    Mask<FWL_EVENTFLAG> nFlags,
                     const CFX_PointF& point,
                     const CFX_Vector& delta) override;
   bool OnRButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     FWL_EventFlagMask nFlags,
+                     Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point) override;
   bool OnRButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlags,
+                   Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
   bool OnRButtonDblClk(CPDFSDK_PageView* pPageView,
                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                       FWL_EventFlagMask nFlags,
+                       Mask<FWL_EVENTFLAG> nFlags,
                        const CFX_PointF& point) override;
   bool OnChar(CPDFSDK_Annot* pAnnot,
               uint32_t nChar,
-              FWL_EventFlagMask nFlags) override;
+              Mask<FWL_EVENTFLAG> nFlags) override;
   bool OnKeyDown(CPDFSDK_Annot* pAnnot,
                  FWL_VKEYCODE nKeyCode,
-                 FWL_EventFlagMask nFlag) override;
+                 Mask<FWL_EVENTFLAG> nFlag) override;
   bool OnKeyUp(CPDFSDK_Annot* pAnnot,
                FWL_VKEYCODE nKeyCode,
-               FWL_EventFlagMask nFlag) override;
+               Mask<FWL_EVENTFLAG> nFlag) override;
   bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                  FWL_EventFlagMask nFlag) override;
+                  Mask<FWL_EVENTFLAG> nFlag) override;
   bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   FWL_EventFlagMask nFlag) override;
+                   Mask<FWL_EVENTFLAG> nFlag) override;
   bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                         int index,
                         bool selected) override;
@@ -119,7 +119,7 @@
 
  private:
   CXFA_FFWidgetHandler* GetXFAFFWidgetHandler(CPDFSDK_Annot* pAnnot);
-  Mask<XFA_FWL_KeyFlag> GetKeyFlags(FWL_EventFlagMask dwFlag);
+  Mask<XFA_FWL_KeyFlag> GetKeyFlags(Mask<FWL_EVENTFLAG> dwFlag);
 
   UnownedPtr<CPDFSDK_FormFillEnvironment> m_pFormFillEnv;
 };
diff --git a/fpdfsdk/ipdfsdk_annothandler.h b/fpdfsdk/ipdfsdk_annothandler.h
index 1d7ca16..563b1b8 100644
--- a/fpdfsdk/ipdfsdk_annothandler.h
+++ b/fpdfsdk/ipdfsdk_annothandler.h
@@ -10,6 +10,7 @@
 #include <memory>
 
 #include "core/fxcrt/fx_coordinates.h"
+#include "core/fxcrt/mask.h"
 #include "fpdfsdk/cpdfsdk_annot.h"
 #include "fpdfsdk/pwl/cpwl_wnd.h"
 #include "public/fpdf_fwlevent.h"
@@ -53,56 +54,56 @@
   virtual void OnLoad(CPDFSDK_Annot* pAnnot) = 0;
   virtual void OnMouseEnter(CPDFSDK_PageView* pPageView,
                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                            FWL_EventFlagMask nFlag) = 0;
+                            Mask<FWL_EVENTFLAG> nFlag) = 0;
   virtual void OnMouseExit(CPDFSDK_PageView* pPageView,
                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                           FWL_EventFlagMask nFlag) = 0;
+                           Mask<FWL_EVENTFLAG> nFlag) = 0;
   virtual bool OnLButtonDown(CPDFSDK_PageView* pPageView,
                              ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                             FWL_EventFlagMask nFlags,
+                             Mask<FWL_EVENTFLAG> nFlags,
                              const CFX_PointF& point) = 0;
   virtual bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                           FWL_EventFlagMask nFlags,
+                           Mask<FWL_EVENTFLAG> nFlags,
                            const CFX_PointF& point) = 0;
   virtual bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                                ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                               FWL_EventFlagMask nFlags,
+                               Mask<FWL_EVENTFLAG> nFlags,
                                const CFX_PointF& point) = 0;
   virtual bool OnMouseMove(CPDFSDK_PageView* pPageView,
                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                           FWL_EventFlagMask nFlags,
+                           Mask<FWL_EVENTFLAG> nFlags,
                            const CFX_PointF& point) = 0;
   virtual bool OnMouseWheel(CPDFSDK_PageView* pPageView,
                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                            FWL_EventFlagMask nFlags,
+                            Mask<FWL_EVENTFLAG> nFlags,
                             const CFX_PointF& point,
                             const CFX_Vector& delta) = 0;
   virtual bool OnRButtonDown(CPDFSDK_PageView* pPageView,
                              ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                             FWL_EventFlagMask nFlags,
+                             Mask<FWL_EVENTFLAG> nFlags,
                              const CFX_PointF& point) = 0;
   virtual bool OnRButtonUp(CPDFSDK_PageView* pPageView,
                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                           FWL_EventFlagMask nFlags,
+                           Mask<FWL_EVENTFLAG> nFlags,
                            const CFX_PointF& point) = 0;
   virtual bool OnRButtonDblClk(CPDFSDK_PageView* pPageView,
                                ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                               FWL_EventFlagMask nFlags,
+                               Mask<FWL_EVENTFLAG> nFlags,
                                const CFX_PointF& point) = 0;
   virtual bool OnChar(CPDFSDK_Annot* pAnnot,
                       uint32_t nChar,
-                      FWL_EventFlagMask nFlags) = 0;
+                      Mask<FWL_EVENTFLAG> nFlags) = 0;
   virtual bool OnKeyDown(CPDFSDK_Annot* pAnnot,
                          FWL_VKEYCODE nKeyCode,
-                         FWL_EventFlagMask nFlag) = 0;
+                         Mask<FWL_EVENTFLAG> nFlag) = 0;
   virtual bool OnKeyUp(CPDFSDK_Annot* pAnnot,
                        FWL_VKEYCODE nKeyCode,
-                       FWL_EventFlagMask nFlag) = 0;
+                       Mask<FWL_EVENTFLAG> nFlag) = 0;
   virtual bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                          FWL_EventFlagMask nFlag) = 0;
+                          Mask<FWL_EVENTFLAG> nFlag) = 0;
   virtual bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                           FWL_EventFlagMask nFlag) = 0;
+                           Mask<FWL_EVENTFLAG> nFlag) = 0;
   virtual bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                 int index,
                                 bool selected) = 0;
diff --git a/fpdfsdk/pwl/cpwl_button.cpp b/fpdfsdk/pwl/cpwl_button.cpp
index 0657117..b95725c 100644
--- a/fpdfsdk/pwl/cpwl_button.cpp
+++ b/fpdfsdk/pwl/cpwl_button.cpp
@@ -17,7 +17,7 @@
 
 CPWL_Button::~CPWL_Button() = default;
 
-bool CPWL_Button::OnLButtonDown(FWL_EventFlagMask nFlag,
+bool CPWL_Button::OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
                                 const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonDown(nFlag, point);
   m_bMouseDown = true;
@@ -25,7 +25,7 @@
   return true;
 }
 
-bool CPWL_Button::OnLButtonUp(FWL_EventFlagMask nFlag,
+bool CPWL_Button::OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,
                               const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonUp(nFlag, point);
   ReleaseCapture();
diff --git a/fpdfsdk/pwl/cpwl_button.h b/fpdfsdk/pwl/cpwl_button.h
index c944576..fcf56c4 100644
--- a/fpdfsdk/pwl/cpwl_button.h
+++ b/fpdfsdk/pwl/cpwl_button.h
@@ -19,8 +19,9 @@
   ~CPWL_Button() override;
 
   // CPWL_Wnd
-  bool OnLButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
-  bool OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
+  bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
+                     const CFX_PointF& point) override;
+  bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
 
  protected:
   bool m_bMouseDown = false;
diff --git a/fpdfsdk/pwl/cpwl_cbbutton.cpp b/fpdfsdk/pwl/cpwl_cbbutton.cpp
index 321fd85..a4d94a7 100644
--- a/fpdfsdk/pwl/cpwl_cbbutton.cpp
+++ b/fpdfsdk/pwl/cpwl_cbbutton.cpp
@@ -58,7 +58,7 @@
                     CFX_FillRenderOptions::EvenOddOptions());
 }
 
-bool CPWL_CBButton::OnLButtonDown(FWL_EventFlagMask nFlag,
+bool CPWL_CBButton::OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
                                   const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonDown(nFlag, point);
 
@@ -70,7 +70,7 @@
   return true;
 }
 
-bool CPWL_CBButton::OnLButtonUp(FWL_EventFlagMask nFlag,
+bool CPWL_CBButton::OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,
                                 const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonUp(nFlag, point);
 
diff --git a/fpdfsdk/pwl/cpwl_cbbutton.h b/fpdfsdk/pwl/cpwl_cbbutton.h
index 58dd54f..7292c26 100644
--- a/fpdfsdk/pwl/cpwl_cbbutton.h
+++ b/fpdfsdk/pwl/cpwl_cbbutton.h
@@ -22,8 +22,9 @@
   // CPWL_Wnd:
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
                           const CFX_Matrix& mtUser2Device) override;
-  bool OnLButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
-  bool OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
+  bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
+                     const CFX_PointF& point) override;
+  bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
 };
 
 #endif  // FPDFSDK_PWL_CPWL_CBBUTTON_H_
diff --git a/fpdfsdk/pwl/cpwl_cblistbox.cpp b/fpdfsdk/pwl/cpwl_cblistbox.cpp
index cf5b4e8..28994ae 100644
--- a/fpdfsdk/pwl/cpwl_cblistbox.cpp
+++ b/fpdfsdk/pwl/cpwl_cblistbox.cpp
@@ -20,7 +20,7 @@
 
 CPWL_CBListBox::~CPWL_CBListBox() = default;
 
-bool CPWL_CBListBox::OnLButtonUp(FWL_EventFlagMask nFlag,
+bool CPWL_CBListBox::OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,
                                  const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonUp(nFlag, point);
 
@@ -53,7 +53,7 @@
 }
 
 bool CPWL_CBListBox::OnMovementKeyDown(FWL_VKEYCODE nKeyCode,
-                                       FWL_EventFlagMask nFlag) {
+                                       Mask<FWL_EVENTFLAG> nFlag) {
   switch (nKeyCode) {
     case FWL_VKEY_Up:
       m_pListCtrl->OnVK_UP(IsSHIFTKeyDown(nFlag), IsCTRLKeyDown(nFlag));
@@ -80,12 +80,12 @@
   return OnNotifySelectionChanged(true, nFlag);
 }
 
-bool CPWL_CBListBox::IsChar(uint16_t nChar, FWL_EventFlagMask nFlag) const {
+bool CPWL_CBListBox::IsChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) const {
   return m_pListCtrl->OnChar(nChar, IsSHIFTKeyDown(nFlag),
                              IsCTRLKeyDown(nFlag));
 }
 
-bool CPWL_CBListBox::OnCharNotify(uint16_t nChar, FWL_EventFlagMask nFlag) {
+bool CPWL_CBListBox::OnCharNotify(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) {
   if (auto* pComboBox = static_cast<CPWL_ComboBox*>(GetParentWindow()))
     pComboBox->SetSelectText();
 
diff --git a/fpdfsdk/pwl/cpwl_cblistbox.h b/fpdfsdk/pwl/cpwl_cblistbox.h
index 40510b3..1f6509a 100644
--- a/fpdfsdk/pwl/cpwl_cblistbox.h
+++ b/fpdfsdk/pwl/cpwl_cblistbox.h
@@ -21,12 +21,12 @@
   ~CPWL_CBListBox() override;
 
   // CPWL_ListBox
-  bool OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
+  bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
 
   bool IsMovementKey(FWL_VKEYCODE nKeyCode) const;
-  bool OnMovementKeyDown(FWL_VKEYCODE nKyeCode, FWL_EventFlagMask nFlag);
-  bool IsChar(uint16_t nChar, FWL_EventFlagMask nFlag) const;
-  bool OnCharNotify(uint16_t nChar, FWL_EventFlagMask nFlag);
+  bool OnMovementKeyDown(FWL_VKEYCODE nKyeCode, Mask<FWL_EVENTFLAG> nFlag);
+  bool IsChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) const;
+  bool OnCharNotify(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag);
 };
 
 #endif  // FPDFSDK_PWL_CPWL_CBLISTBOX_H_
diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp
index 32dc9e2..107decc 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box.cpp
@@ -302,7 +302,7 @@
     return true;
 
   ObservedPtr<CPWL_ComboBox> thisObserved(this);
-  if (m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), 0))
+  if (m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), {}))
     return !!thisObserved;
   if (!thisObserved)
     return false;
@@ -333,11 +333,12 @@
   if (!Move(rcWindow, true, true))
     return false;
 
-  m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), 0);
+  m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), {});
   return !!thisObserved;
 }
 
-bool CPWL_ComboBox::OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag) {
+bool CPWL_ComboBox::OnKeyDown(FWL_VKEYCODE nKeyCode,
+                              Mask<FWL_EVENTFLAG> nFlag) {
   if (!m_pList)
     return false;
   if (!m_pEdit)
@@ -386,7 +387,7 @@
   return false;
 }
 
-bool CPWL_ComboBox::OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) {
+bool CPWL_ComboBox::OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) {
   if (!m_pList)
     return false;
 
diff --git a/fpdfsdk/pwl/cpwl_combo_box.h b/fpdfsdk/pwl/cpwl_combo_box.h
index b34a3ed..f537129 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.h
+++ b/fpdfsdk/pwl/cpwl_combo_box.h
@@ -30,8 +30,8 @@
 
   // CPWL_Wnd:
   void OnDestroy() override;
-  bool OnKeyDown(FWL_VKEYCODE nChar, FWL_EventFlagMask nFlag) override;
-  bool OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) override;
+  bool OnKeyDown(FWL_VKEYCODE nChar, Mask<FWL_EVENTFLAG> nFlag) override;
+  bool OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) override;
   void NotifyLButtonDown(CPWL_Wnd* child, const CFX_PointF& pos) override;
   void NotifyLButtonUp(CPWL_Wnd* child, const CFX_PointF& pos) override;
   void CreateChildWnd(const CreateParams& cp) override;
diff --git a/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp b/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
index f591f74..d2b2221 100644
--- a/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
@@ -57,7 +57,7 @@
         m_pFormFillEnv->GetInteractiveFormFiller();
     {
       ObservedPtr<CPDFSDK_Annot> pObserved(pAnnotCombobox);
-      EXPECT_TRUE(pInteractiveFormFiller->OnSetFocus(&pObserved, 0));
+      EXPECT_TRUE(pInteractiveFormFiller->OnSetFocus(&pObserved, {}));
     }
 
     m_pFormFiller =
@@ -74,7 +74,7 @@
     // Type text starting with 'A' to as many chars as specified by |num_chars|.
     for (int i = 0; i < num_chars; ++i) {
       EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(),
-                                              i + 'A', 0));
+                                              i + 'A', {}));
     }
   }
 
@@ -117,7 +117,7 @@
   EXPECT_STREQ(L"Cherry", GetCPWLComboBox()->GetSelectedText().c_str());
 
   // Verify that combobox text cannot be edited.
-  EXPECT_FALSE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotNormal(), 'a', 0));
+  EXPECT_FALSE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotNormal(), 'a', {}));
 }
 
 TEST_F(CPWLComboBoxEditEmbedderTest, GetSelectedTextFragmentsNormal) {
@@ -164,11 +164,11 @@
 
   // Type into editable combobox text field and select new text.
   EXPECT_TRUE(
-      GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), 'a', 0));
+      GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), 'a', {}));
   EXPECT_TRUE(
-      GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), 'b', 0));
+      GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), 'b', {}));
   EXPECT_TRUE(
-      GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), 'c', 0));
+      GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), 'c', {}));
 
   EXPECT_TRUE(GetCPWLComboBox()->GetSelectedText().IsEmpty());
   GetCPWLComboBox()->SetEditSelection(0, 5);
@@ -274,7 +274,7 @@
   TypeTextIntoTextField(10);
 
   // Move cursor to beginning of user-editable combobox text field.
-  EXPECT_TRUE(GetCFFLFormFiller()->OnKeyDown(FWL_VKEY_Home, 0));
+  EXPECT_TRUE(GetCFFLFormFiller()->OnKeyDown(FWL_VKEY_Home, {}));
 
   GetCPWLComboBox()->ReplaceSelection(L"Hello");
   EXPECT_STREQ(L"HelloABCDEFGHIJ", GetCPWLComboBox()->GetText().c_str());
@@ -287,7 +287,7 @@
 
   // Move cursor to middle of user-editable combobox text field.
   for (int i = 0; i < 5; ++i) {
-    EXPECT_TRUE(GetCFFLFormFiller()->OnKeyDown(FWL_VKEY_Left, 0));
+    EXPECT_TRUE(GetCFFLFormFiller()->OnKeyDown(FWL_VKEY_Left, {}));
   }
 
   GetCPWLComboBox()->ReplaceSelection(L"Hello");
diff --git a/fpdfsdk/pwl/cpwl_edit.cpp b/fpdfsdk/pwl/cpwl_edit.cpp
index c507363..fcec231 100644
--- a/fpdfsdk/pwl/cpwl_edit.cpp
+++ b/fpdfsdk/pwl/cpwl_edit.cpp
@@ -334,7 +334,7 @@
   return pScroll && pScroll->IsVisible();
 }
 
-bool CPWL_Edit::OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag) {
+bool CPWL_Edit::OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlag) {
   if (m_bMouseDown)
     return true;
 
@@ -379,7 +379,7 @@
 
 // static
 bool CPWL_Edit::IsProceedtoOnChar(FWL_VKEYCODE nKeyCode,
-                                  FWL_EventFlagMask nFlag) {
+                                  Mask<FWL_EVENTFLAG> nFlag) {
   bool bCtrl = IsPlatformShortcutKey(nFlag);
   bool bAlt = IsALTKeyDown(nFlag);
   if (bCtrl && !bAlt) {
@@ -407,7 +407,7 @@
   }
 }
 
-bool CPWL_Edit::OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) {
+bool CPWL_Edit::OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) {
   if (m_bMouseDown)
     return true;
 
@@ -463,7 +463,7 @@
   return OnCharInternal(nChar, nFlag);
 }
 
-bool CPWL_Edit::OnMouseWheel(FWL_EventFlagMask nFlag,
+bool CPWL_Edit::OnMouseWheel(Mask<FWL_EVENTFLAG> nFlag,
                              const CFX_PointF& point,
                              const CFX_Vector& delta) {
   if (!HasFlag(PES_MULTILINE))
@@ -554,7 +554,7 @@
 }
 
 bool CPWL_Edit::OnKeyDownInternal(FWL_VKEYCODE nKeyCode,
-                                  FWL_EventFlagMask nFlag) {
+                                  Mask<FWL_EVENTFLAG> nFlag) {
   if (m_bMouseDown)
     return true;
 
@@ -622,7 +622,7 @@
   return bRet;
 }
 
-bool CPWL_Edit::OnCharInternal(uint16_t nChar, FWL_EventFlagMask nFlag) {
+bool CPWL_Edit::OnCharInternal(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) {
   if (m_bMouseDown)
     return true;
 
@@ -694,7 +694,7 @@
   return true;
 }
 
-bool CPWL_Edit::OnLButtonDown(FWL_EventFlagMask nFlag,
+bool CPWL_Edit::OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
                               const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonDown(nFlag, point);
   if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) {
@@ -709,7 +709,8 @@
   return true;
 }
 
-bool CPWL_Edit::OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) {
+bool CPWL_Edit::OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,
+                            const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonUp(nFlag, point);
   if (m_bMouseDown) {
     // can receive keybord message
@@ -722,7 +723,7 @@
   return true;
 }
 
-bool CPWL_Edit::OnLButtonDblClk(FWL_EventFlagMask nFlag,
+bool CPWL_Edit::OnLButtonDblClk(Mask<FWL_EVENTFLAG> nFlag,
                                 const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonDblClk(nFlag, point);
   if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point))
@@ -731,7 +732,8 @@
   return true;
 }
 
-bool CPWL_Edit::OnRButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) {
+bool CPWL_Edit::OnRButtonUp(Mask<FWL_EVENTFLAG> nFlag,
+                            const CFX_PointF& point) {
   if (m_bMouseDown)
     return false;
 
@@ -743,7 +745,8 @@
   return false;
 }
 
-bool CPWL_Edit::OnMouseMove(FWL_EventFlagMask nFlag, const CFX_PointF& point) {
+bool CPWL_Edit::OnMouseMove(Mask<FWL_EVENTFLAG> nFlag,
+                            const CFX_PointF& point) {
   CPWL_Wnd::OnMouseMove(nFlag, point);
 
   if (m_bMouseDown)
diff --git a/fpdfsdk/pwl/cpwl_edit.h b/fpdfsdk/pwl/cpwl_edit.h
index e06dd06..7d0af0a 100644
--- a/fpdfsdk/pwl/cpwl_edit.h
+++ b/fpdfsdk/pwl/cpwl_edit.h
@@ -37,22 +37,23 @@
   CFX_FloatRect GetClientRect() const override;
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
                           const CFX_Matrix& mtUser2Device) override;
-  bool OnMouseWheel(FWL_EventFlagMask nFlag,
+  bool OnMouseWheel(Mask<FWL_EVENTFLAG> nFlag,
                     const CFX_PointF& point,
                     const CFX_Vector& delta) override;
-  bool OnKeyDown(FWL_VKEYCODE nChar, FWL_EventFlagMask nFlag) override;
-  bool OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) override;
+  bool OnKeyDown(FWL_VKEYCODE nChar, Mask<FWL_EVENTFLAG> nFlag) override;
+  bool OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) override;
   CFX_FloatRect GetFocusRect() const override;
   void OnSetFocus() override;
   void OnKillFocus() override;
   void OnCreated() override;
   void OnDestroy() override;
-  bool OnLButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
-  bool OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
-  bool OnLButtonDblClk(FWL_EventFlagMask nFlag,
+  bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
+                     const CFX_PointF& point) override;
+  bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
+  bool OnLButtonDblClk(Mask<FWL_EVENTFLAG> nFlag,
                        const CFX_PointF& point) override;
-  bool OnRButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
-  bool OnMouseMove(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
+  bool OnRButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
+  bool OnMouseMove(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
   void SetScrollInfo(const PWL_SCROLL_INFO& info) override;
   void SetScrollPosition(float pos) override;
   void ScrollWindowVertically(float pos) override;
@@ -108,10 +109,11 @@
   // In case of implementation swallow the OnKeyDown event. If the event is
   // swallowed, implementation may do other unexpected things, which is not the
   // control means to do.
-  static bool IsProceedtoOnChar(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag);
+  static bool IsProceedtoOnChar(FWL_VKEYCODE nKeyCode,
+                                Mask<FWL_EVENTFLAG> nFlag);
 
-  bool OnKeyDownInternal(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag);
-  bool OnCharInternal(uint16_t nChar, FWL_EventFlagMask nFlag);
+  bool OnKeyDownInternal(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlag);
+  bool OnCharInternal(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag);
 
   void CopyText();
   void PasteText();
diff --git a/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp b/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp
index 69762a5..f1f1051 100644
--- a/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp
@@ -63,7 +63,7 @@
         m_pFormFillEnv->GetInteractiveFormFiller();
     {
       ObservedPtr<CPDFSDK_Annot> pObserved(pAnnotTextField);
-      EXPECT_TRUE(pInteractiveFormFiller->OnSetFocus(&pObserved, 0));
+      EXPECT_TRUE(pInteractiveFormFiller->OnSetFocus(&pObserved, {}));
     }
 
     m_pFormFiller =
@@ -79,7 +79,7 @@
   void TypeTextIntoTextField(int num_chars) {
     // Type text starting with 'A' to as many chars as specified by |num_chars|.
     for (int i = 0; i < num_chars; ++i) {
-      EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), i + 'A', 0));
+      EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), i + 'A', {}));
     }
   }
 
@@ -101,9 +101,9 @@
 TEST_F(CPWLEditEmbedderTest, TypeText) {
   FormFillerAndWindowSetup(GetCPDFSDKAnnot());
   EXPECT_TRUE(GetCPWLEdit()->GetText().IsEmpty());
-  EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), 'a', 0));
-  EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), 'b', 0));
-  EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), 'c', 0));
+  EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), 'a', {}));
+  EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), 'b', {}));
+  EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), 'c', {}));
 
   EXPECT_STREQ(L"abc", GetCPWLEdit()->GetText().c_str());
 }
@@ -117,9 +117,9 @@
   GetCPWLEdit()->SetSelection(0, 3);
   EXPECT_TRUE(GetCPWLEdit()->GetSelectedText().IsEmpty());
 
-  EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), 'a', 0));
-  EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), 'b', 0));
-  EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), 'c', 0));
+  EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), 'a', {}));
+  EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), 'b', {}));
+  EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), 'c', {}));
   GetCPWLEdit()->SetSelection(0, 2);
 
   EXPECT_STREQ(L"ab", GetCPWLEdit()->GetSelectedText().c_str());
@@ -223,7 +223,7 @@
   TypeTextIntoTextField(10);
 
   // Move cursor to beginning of text field.
-  EXPECT_TRUE(GetCFFLFormFiller()->OnKeyDown(FWL_VKEY_Home, 0));
+  EXPECT_TRUE(GetCFFLFormFiller()->OnKeyDown(FWL_VKEY_Home, {}));
 
   GetCPWLEdit()->ReplaceSelection(L"Hello");
   EXPECT_STREQ(L"HelloABCDEFGHIJ", GetCPWLEdit()->GetText().c_str());
@@ -235,7 +235,7 @@
 
   // Move cursor to middle of text field.
   for (int i = 0; i < 5; ++i) {
-    EXPECT_TRUE(GetCFFLFormFiller()->OnKeyDown(FWL_VKEY_Left, 0));
+    EXPECT_TRUE(GetCFFLFormFiller()->OnKeyDown(FWL_VKEY_Left, {}));
   }
 
   GetCPWLEdit()->ReplaceSelection(L"Hello");
@@ -324,7 +324,7 @@
   FormFillerAndWindowSetup(GetCPDFSDKAnnotCharLimit());
   // Move cursor to middle of text field.
   for (int i = 0; i < 5; ++i) {
-    EXPECT_TRUE(GetCFFLFormFiller()->OnKeyDown(FWL_VKEY_Right, 0));
+    EXPECT_TRUE(GetCFFLFormFiller()->OnKeyDown(FWL_VKEY_Right, {}));
   }
 
   GetCPWLEdit()->ReplaceSelection(L"Hippopotamus");
@@ -334,7 +334,7 @@
 TEST_F(CPWLEditEmbedderTest, InsertTextInPopulatedCharLimitTextFieldRight) {
   FormFillerAndWindowSetup(GetCPDFSDKAnnotCharLimit());
   // Move cursor to end of text field.
-  EXPECT_TRUE(GetCFFLFormFiller()->OnKeyDown(FWL_VKEY_End, 0));
+  EXPECT_TRUE(GetCFFLFormFiller()->OnKeyDown(FWL_VKEY_End, {}));
 
   GetCPWLEdit()->ReplaceSelection(L"Hippopotamus");
   EXPECT_STREQ(L"ElephantHi", GetCPWLEdit()->GetText().c_str());
diff --git a/fpdfsdk/pwl/cpwl_list_box.cpp b/fpdfsdk/pwl/cpwl_list_box.cpp
index d91fddc..7747bb8 100644
--- a/fpdfsdk/pwl/cpwl_list_box.cpp
+++ b/fpdfsdk/pwl/cpwl_list_box.cpp
@@ -86,7 +86,7 @@
   }
 }
 
-bool CPWL_ListBox::OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag) {
+bool CPWL_ListBox::OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlag) {
   CPWL_Wnd::OnKeyDown(nKeyCode, nFlag);
 
   switch (nKeyCode) {
@@ -127,7 +127,7 @@
   return true;
 }
 
-bool CPWL_ListBox::OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) {
+bool CPWL_ListBox::OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) {
   CPWL_Wnd::OnChar(nChar, nFlag);
 
   if (!m_pListCtrl->OnChar(nChar, IsSHIFTKeyDown(nFlag), IsCTRLKeyDown(nFlag)))
@@ -137,7 +137,7 @@
   return true;
 }
 
-bool CPWL_ListBox::OnLButtonDown(FWL_EventFlagMask nFlag,
+bool CPWL_ListBox::OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
                                  const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonDown(nFlag, point);
 
@@ -153,7 +153,7 @@
   return true;
 }
 
-bool CPWL_ListBox::OnLButtonUp(FWL_EventFlagMask nFlag,
+bool CPWL_ListBox::OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,
                                const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonUp(nFlag, point);
 
@@ -169,7 +169,7 @@
   m_bHoverSel = bHoverSel;
 }
 
-bool CPWL_ListBox::OnMouseMove(FWL_EventFlagMask nFlag,
+bool CPWL_ListBox::OnMouseMove(Mask<FWL_EVENTFLAG> nFlag,
                                const CFX_PointF& point) {
   CPWL_Wnd::OnMouseMove(nFlag, point);
 
@@ -205,7 +205,7 @@
 }
 
 bool CPWL_ListBox::OnNotifySelectionChanged(bool bKeyDown,
-                                            FWL_EventFlagMask nFlag) {
+                                            Mask<FWL_EVENTFLAG> nFlag) {
   if (!m_pFillerNotify)
     return false;
 
@@ -365,7 +365,7 @@
   return GetWindowRect().GetDeflated(width, width);
 }
 
-bool CPWL_ListBox::OnMouseWheel(FWL_EventFlagMask nFlag,
+bool CPWL_ListBox::OnMouseWheel(Mask<FWL_EVENTFLAG> nFlag,
                                 const CFX_PointF& point,
                                 const CFX_Vector& delta) {
   if (delta.y < 0)
diff --git a/fpdfsdk/pwl/cpwl_list_box.h b/fpdfsdk/pwl/cpwl_list_box.h
index d7d300a..d56329f 100644
--- a/fpdfsdk/pwl/cpwl_list_box.h
+++ b/fpdfsdk/pwl/cpwl_list_box.h
@@ -27,12 +27,13 @@
   void OnDestroy() override;
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
                           const CFX_Matrix& mtUser2Device) override;
-  bool OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag) override;
-  bool OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) override;
-  bool OnLButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
-  bool OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
-  bool OnMouseMove(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
-  bool OnMouseWheel(FWL_EventFlagMask nFlag,
+  bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlag) override;
+  bool OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) override;
+  bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
+                     const CFX_PointF& point) override;
+  bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
+  bool OnMouseMove(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
+  bool OnMouseWheel(Mask<FWL_EVENTFLAG> nFlag,
                     const CFX_PointF& point,
                     const CFX_Vector& delta) override;
   WideString GetText() override;
@@ -54,7 +55,7 @@
   void OnSetScrollPosY(float fy) override;
   void OnInvalidateRect(const CFX_FloatRect& pRect) override;
 
-  bool OnNotifySelectionChanged(bool bKeyDown, FWL_EventFlagMask nFlag);
+  bool OnNotifySelectionChanged(bool bKeyDown, Mask<FWL_EVENTFLAG> nFlag);
 
   void AddString(const WideString& str);
   void SetTopVisibleIndex(int32_t nItemIndex);
diff --git a/fpdfsdk/pwl/cpwl_sbbutton.cpp b/fpdfsdk/pwl/cpwl_sbbutton.cpp
index 5b32791..6af47a3 100644
--- a/fpdfsdk/pwl/cpwl_sbbutton.cpp
+++ b/fpdfsdk/pwl/cpwl_sbbutton.cpp
@@ -113,7 +113,7 @@
   }
 }
 
-bool CPWL_SBButton::OnLButtonDown(FWL_EventFlagMask nFlag,
+bool CPWL_SBButton::OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
                                   const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonDown(nFlag, point);
 
@@ -126,7 +126,7 @@
   return true;
 }
 
-bool CPWL_SBButton::OnLButtonUp(FWL_EventFlagMask nFlag,
+bool CPWL_SBButton::OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,
                                 const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonUp(nFlag, point);
 
@@ -139,7 +139,7 @@
   return true;
 }
 
-bool CPWL_SBButton::OnMouseMove(FWL_EventFlagMask nFlag,
+bool CPWL_SBButton::OnMouseMove(Mask<FWL_EVENTFLAG> nFlag,
                                 const CFX_PointF& point) {
   CPWL_Wnd::OnMouseMove(nFlag, point);
 
diff --git a/fpdfsdk/pwl/cpwl_sbbutton.h b/fpdfsdk/pwl/cpwl_sbbutton.h
index fdcd887..9a21aee 100644
--- a/fpdfsdk/pwl/cpwl_sbbutton.h
+++ b/fpdfsdk/pwl/cpwl_sbbutton.h
@@ -25,9 +25,10 @@
   // CPWL_Wnd
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
                           const CFX_Matrix& mtUser2Device) override;
-  bool OnLButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
-  bool OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
-  bool OnMouseMove(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
+  bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
+                     const CFX_PointF& point) override;
+  bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
+  bool OnMouseMove(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
 
  private:
   const Type m_eSBButtonType;
diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.cpp b/fpdfsdk/pwl/cpwl_scroll_bar.cpp
index f145294..0279ca7 100644
--- a/fpdfsdk/pwl/cpwl_scroll_bar.cpp
+++ b/fpdfsdk/pwl/cpwl_scroll_bar.cpp
@@ -184,7 +184,7 @@
   }
 }
 
-bool CPWL_ScrollBar::OnLButtonDown(FWL_EventFlagMask nFlag,
+bool CPWL_ScrollBar::OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
                                    const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonDown(nFlag, point);
 
@@ -227,7 +227,7 @@
   return true;
 }
 
-bool CPWL_ScrollBar::OnLButtonUp(FWL_EventFlagMask nFlag,
+bool CPWL_ScrollBar::OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,
                                  const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonUp(nFlag, point);
 
diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.h b/fpdfsdk/pwl/cpwl_scroll_bar.h
index bb5472b..f6f49c7 100644
--- a/fpdfsdk/pwl/cpwl_scroll_bar.h
+++ b/fpdfsdk/pwl/cpwl_scroll_bar.h
@@ -104,8 +104,9 @@
   bool RePosChildWnd() override;
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
                           const CFX_Matrix& mtUser2Device) override;
-  bool OnLButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
-  bool OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
+  bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
+                     const CFX_PointF& point) override;
+  bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
   void SetScrollInfo(const PWL_SCROLL_INFO& info) override;
   void SetScrollPosition(float pos) override;
   void NotifyLButtonDown(CPWL_Wnd* child, const CFX_PointF& pos) override;
diff --git a/fpdfsdk/pwl/cpwl_special_button.cpp b/fpdfsdk/pwl/cpwl_special_button.cpp
index fa9ad06..730d815 100644
--- a/fpdfsdk/pwl/cpwl_special_button.cpp
+++ b/fpdfsdk/pwl/cpwl_special_button.cpp
@@ -30,7 +30,7 @@
 
 CPWL_CheckBox::~CPWL_CheckBox() = default;
 
-bool CPWL_CheckBox::OnLButtonUp(FWL_EventFlagMask nFlag,
+bool CPWL_CheckBox::OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,
                                 const CFX_PointF& point) {
   if (IsReadOnly())
     return false;
@@ -39,7 +39,7 @@
   return true;
 }
 
-bool CPWL_CheckBox::OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) {
+bool CPWL_CheckBox::OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) {
   if (IsReadOnly())
     return false;
 
@@ -54,7 +54,7 @@
 
 CPWL_RadioButton::~CPWL_RadioButton() = default;
 
-bool CPWL_RadioButton::OnLButtonUp(FWL_EventFlagMask nFlag,
+bool CPWL_RadioButton::OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,
                                    const CFX_PointF& point) {
   if (IsReadOnly())
     return false;
@@ -63,7 +63,7 @@
   return true;
 }
 
-bool CPWL_RadioButton::OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) {
+bool CPWL_RadioButton::OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) {
   if (IsReadOnly())
     return false;
 
diff --git a/fpdfsdk/pwl/cpwl_special_button.h b/fpdfsdk/pwl/cpwl_special_button.h
index 48fa5a5..f933cb6 100644
--- a/fpdfsdk/pwl/cpwl_special_button.h
+++ b/fpdfsdk/pwl/cpwl_special_button.h
@@ -30,8 +30,8 @@
   ~CPWL_CheckBox() override;
 
   // CPWL_Button:
-  bool OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
-  bool OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) override;
+  bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
+  bool OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) override;
 
   bool IsChecked() const { return m_bChecked; }
   void SetCheck(bool bCheck) { m_bChecked = bCheck; }
@@ -48,8 +48,8 @@
   ~CPWL_RadioButton() override;
 
   // CPWL_Button
-  bool OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
-  bool OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) override;
+  bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
+  bool OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) override;
 
   bool IsChecked() const { return m_bChecked; }
   void SetCheck(bool bCheck) { m_bChecked = bCheck; }
diff --git a/fpdfsdk/pwl/cpwl_special_button_embeddertest.cpp b/fpdfsdk/pwl/cpwl_special_button_embeddertest.cpp
index a5271fc..3bde235 100644
--- a/fpdfsdk/pwl/cpwl_special_button_embeddertest.cpp
+++ b/fpdfsdk/pwl/cpwl_special_button_embeddertest.cpp
@@ -68,7 +68,7 @@
         formfill_env_->GetInteractiveFormFiller();
     {
       ObservedPtr<CPDFSDK_Annot> observed(annot);
-      EXPECT_TRUE(interactive_formfiller->OnSetFocus(&observed, 0));
+      EXPECT_TRUE(interactive_formfiller->OnSetFocus(&observed, {}));
     }
 
     form_filler_ = interactive_formfiller->GetFormFieldForTesting(annot);
@@ -110,7 +110,7 @@
   CPWL_CheckBox* check_box = static_cast<CPWL_CheckBox*>(GetWindow());
   EXPECT_TRUE(check_box->IsChecked());
   EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
-      GetCPDFSDKAnnotReadOnlyCheckBox(), '\r', 0));
+      GetCPDFSDKAnnotReadOnlyCheckBox(), '\r', {}));
   EXPECT_TRUE(check_box->IsChecked());
 }
 
@@ -118,11 +118,11 @@
   FormFillerAndWindowSetup(GetCPDFSDKAnnotCheckBox());
   CPWL_CheckBox* check_box = static_cast<CPWL_CheckBox*>(GetWindow());
   EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
-      GetCPDFSDKAnnotCheckBox(), '\r', 0));
+      GetCPDFSDKAnnotCheckBox(), '\r', {}));
   EXPECT_TRUE(check_box->IsChecked());
 
   EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
-      GetCPDFSDKAnnotCheckBox(), '\r', 0));
+      GetCPDFSDKAnnotCheckBox(), '\r', {}));
   EXPECT_FALSE(check_box->IsChecked());
 }
 
@@ -131,7 +131,7 @@
   CPWL_RadioButton* radio_button = static_cast<CPWL_RadioButton*>(GetWindow());
   EXPECT_FALSE(radio_button->IsChecked());
   EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
-      GetCPDFSDKAnnotReadOnlyRadioButton(), '\r', 0));
+      GetCPDFSDKAnnotReadOnlyRadioButton(), '\r', {}));
   EXPECT_FALSE(radio_button->IsChecked());
 }
 
@@ -139,6 +139,6 @@
   FormFillerAndWindowSetup(GetCPDFSDKAnnotRadioButton());
   CPWL_RadioButton* radio_button = static_cast<CPWL_RadioButton*>(GetWindow());
   EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
-      GetCPDFSDKAnnotRadioButton(), '\r', 0));
+      GetCPDFSDKAnnotRadioButton(), '\r', {}));
   EXPECT_TRUE(radio_button->IsChecked());
 }
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp
index cc45a37..705a405 100644
--- a/fpdfsdk/pwl/cpwl_wnd.cpp
+++ b/fpdfsdk/pwl/cpwl_wnd.cpp
@@ -110,27 +110,27 @@
 };
 
 // static
-bool CPWL_Wnd::IsSHIFTKeyDown(FWL_EventFlagMask nFlag) {
+bool CPWL_Wnd::IsSHIFTKeyDown(Mask<FWL_EVENTFLAG> nFlag) {
   return !!(nFlag & FWL_EVENTFLAG_ShiftKey);
 }
 
 // static
-bool CPWL_Wnd::IsCTRLKeyDown(FWL_EventFlagMask nFlag) {
+bool CPWL_Wnd::IsCTRLKeyDown(Mask<FWL_EVENTFLAG> nFlag) {
   return !!(nFlag & FWL_EVENTFLAG_ControlKey);
 }
 
 // static
-bool CPWL_Wnd::IsALTKeyDown(FWL_EventFlagMask nFlag) {
+bool CPWL_Wnd::IsALTKeyDown(Mask<FWL_EVENTFLAG> nFlag) {
   return !!(nFlag & FWL_EVENTFLAG_AltKey);
 }
 
 // static
-bool CPWL_Wnd::IsMETAKeyDown(FWL_EventFlagMask nFlag) {
+bool CPWL_Wnd::IsMETAKeyDown(Mask<FWL_EVENTFLAG> nFlag) {
   return !!(nFlag & FWL_EVENTFLAG_MetaKey);
 }
 
 // static
-bool CPWL_Wnd::IsPlatformShortcutKey(FWL_EventFlagMask nFlag) {
+bool CPWL_Wnd::IsPlatformShortcutKey(Mask<FWL_EVENTFLAG> nFlag) {
 #if defined(OS_APPLE)
   return IsMETAKeyDown(nFlag);
 #else
@@ -287,7 +287,7 @@
   return !!thisObserved;
 }
 
-bool CPWL_Wnd::OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag) {
+bool CPWL_Wnd::OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlag) {
   if (!IsValid() || !IsVisible())
     return false;
   if (!IsWndCaptureKeyboard(this))
@@ -299,7 +299,7 @@
   return false;
 }
 
-bool CPWL_Wnd::OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) {
+bool CPWL_Wnd::OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) {
   if (!IsValid() || !IsVisible())
     return false;
   if (!IsWndCaptureKeyboard(this))
@@ -312,7 +312,7 @@
 }
 
 #define PWL_IMPLEMENT_MOUSE_METHOD(mouse_method_name)         \
-  bool CPWL_Wnd::mouse_method_name(FWL_EventFlagMask nFlag,   \
+  bool CPWL_Wnd::mouse_method_name(Mask<FWL_EVENTFLAG> nFlag, \
                                    const CFX_PointF& point) { \
     if (!IsValid() || !IsVisible())                           \
       return false;                                           \
@@ -342,11 +342,12 @@
 #undef PWL_IMPLEMENT_MOUSE_METHOD
 
 // Unlike their FWL counterparts, PWL windows don't handle right clicks.
-bool CPWL_Wnd::OnRButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point) {
+bool CPWL_Wnd::OnRButtonDown(Mask<FWL_EVENTFLAG> nFlag,
+                             const CFX_PointF& point) {
   return false;
 }
 
-bool CPWL_Wnd::OnRButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) {
+bool CPWL_Wnd::OnRButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) {
   return false;
 }
 
@@ -380,7 +381,7 @@
   return false;
 }
 
-bool CPWL_Wnd::OnMouseWheel(FWL_EventFlagMask nFlag,
+bool CPWL_Wnd::OnMouseWheel(Mask<FWL_EVENTFLAG> nFlag,
                             const CFX_PointF& point,
                             const CFX_Vector& delta) {
   if (!IsValid() || !IsVisible())
diff --git a/fpdfsdk/pwl/cpwl_wnd.h b/fpdfsdk/pwl/cpwl_wnd.h
index 579fa42..7e73414 100644
--- a/fpdfsdk/pwl/cpwl_wnd.h
+++ b/fpdfsdk/pwl/cpwl_wnd.h
@@ -8,10 +8,10 @@
 #define FPDFSDK_PWL_CPWL_WND_H_
 
 #include <memory>
-#include <type_traits>
 #include <vector>
 
 #include "core/fxcrt/cfx_timer.h"
+#include "core/fxcrt/mask.h"
 #include "core/fxcrt/observed_ptr.h"
 #include "core/fxcrt/unowned_ptr.h"
 #include "core/fxcrt/widestring.h"
@@ -26,8 +26,6 @@
 class IPVT_FontMap;
 struct PWL_SCROLL_INFO;
 
-using FWL_EventFlagMask = std::underlying_type<FWL_EVENTFLAG>::type;
-
 // window styles
 #define PWS_BORDER 0x40000000L
 #define PWS_BACKGROUND 0x20000000L
@@ -128,13 +126,13 @@
         IPWL_SystemHandler::CursorStyle::kArrow;
   };
 
-  static bool IsSHIFTKeyDown(FWL_EventFlagMask nFlag);
-  static bool IsCTRLKeyDown(FWL_EventFlagMask nFlag);
-  static bool IsALTKeyDown(FWL_EventFlagMask nFlag);
-  static bool IsMETAKeyDown(FWL_EventFlagMask nFlag);
+  static bool IsSHIFTKeyDown(Mask<FWL_EVENTFLAG> nFlag);
+  static bool IsCTRLKeyDown(Mask<FWL_EVENTFLAG> nFlag);
+  static bool IsALTKeyDown(Mask<FWL_EVENTFLAG> nFlag);
+  static bool IsMETAKeyDown(Mask<FWL_EVENTFLAG> nFlag);
 
   // Selects between IsCTRLKeyDown() and IsMETAKeyDown() depending on platform.
-  static bool IsPlatformShortcutKey(FWL_EventFlagMask nFlag);
+  static bool IsPlatformShortcutKey(Mask<FWL_EVENTFLAG> nFlag);
 
   CPWL_Wnd(const CreateParams& cp,
            std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData);
@@ -143,16 +141,18 @@
   // Returns |true| iff this instance is still allocated.
   virtual bool InvalidateRect(const CFX_FloatRect* pRect);
 
-  virtual bool OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag);
-  virtual bool OnChar(uint16_t nChar, FWL_EventFlagMask nFlag);
-  virtual bool OnLButtonDblClk(FWL_EventFlagMask nFlag,
+  virtual bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlag);
+  virtual bool OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag);
+  virtual bool OnLButtonDblClk(Mask<FWL_EVENTFLAG> nFlag,
                                const CFX_PointF& point);
-  virtual bool OnLButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point);
-  virtual bool OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point);
-  virtual bool OnRButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point);
-  virtual bool OnRButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point);
-  virtual bool OnMouseMove(FWL_EventFlagMask nFlag, const CFX_PointF& point);
-  virtual bool OnMouseWheel(FWL_EventFlagMask nFlag,
+  virtual bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
+                             const CFX_PointF& point);
+  virtual bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point);
+  virtual bool OnRButtonDown(Mask<FWL_EVENTFLAG> nFlag,
+                             const CFX_PointF& point);
+  virtual bool OnRButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point);
+  virtual bool OnMouseMove(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point);
+  virtual bool OnMouseWheel(Mask<FWL_EVENTFLAG> nFlag,
                             const CFX_PointF& point,
                             const CFX_Vector& delta);
   virtual void SetScrollInfo(const PWL_SCROLL_INFO& info);
diff --git a/fpdfsdk/pwl/ipwl_fillernotify.h b/fpdfsdk/pwl/ipwl_fillernotify.h
index b208d41..7b54f5d 100644
--- a/fpdfsdk/pwl/ipwl_fillernotify.h
+++ b/fpdfsdk/pwl/ipwl_fillernotify.h
@@ -10,6 +10,7 @@
 #include <utility>
 
 #include "core/fxcrt/fx_string.h"
+#include "core/fxcrt/mask.h"
 #include "fpdfsdk/pwl/cpwl_wnd.h"
 #include "fpdfsdk/pwl/ipwl_systemhandler.h"
 
@@ -32,15 +33,15 @@
       int nSelStart,
       int nSelEnd,
       bool bKeyDown,
-      FWL_EventFlagMask nFlag) = 0;
+      Mask<FWL_EVENTFLAG> nFlag) = 0;
 
   virtual bool OnPopupPreOpen(
       const IPWL_SystemHandler::PerWindowData* pAttached,
-      FWL_EventFlagMask nFlag) = 0;
+      Mask<FWL_EVENTFLAG> nFlag) = 0;
 
   virtual bool OnPopupPostOpen(
       const IPWL_SystemHandler::PerWindowData* pAttached,
-      FWL_EventFlagMask nFlag) = 0;
+      Mask<FWL_EVENTFLAG> nFlag) = 0;
 };
 
 #endif  // FPDFSDK_PWL_IPWL_FILLERNOTIFY_H_
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp
index fed9fb6..4299e64 100644
--- a/fxjs/cjs_app.cpp
+++ b/fxjs/cjs_app.cpp
@@ -253,7 +253,7 @@
     swTitle = JSGetStringFromID(JSMessage::kAlert);
 
   pRuntime->BeginBlock();
-  pFormFillEnv->KillFocusAnnot(0);
+  pFormFillEnv->KillFocusAnnot({});
   v8::Local<v8::Value> ret = pRuntime->NewNumber(
       pFormFillEnv->JS_appAlert(swMsg, swTitle, iType, iIcon));
   pRuntime->EndBlock();
diff --git a/xfa/fxfa/cxfa_ffdatetimeedit.cpp b/xfa/fxfa/cxfa_ffdatetimeedit.cpp
index 5332a45..8e7ea30 100644
--- a/xfa/fxfa/cxfa_ffdatetimeedit.cpp
+++ b/xfa/fxfa/cxfa_ffdatetimeedit.cpp
@@ -176,7 +176,7 @@
 }
 
 bool CXFA_FFDateTimeEdit::IsDataChanged() {
-  if (GetLayoutItem()->TestStatusBits(XFA_WidgetStatus_TextEditValueChanged))
+  if (GetLayoutItem()->TestStatusBits(XFA_WidgetStatus::kTextEditValueChanged))
     return true;
 
   WideString wsText = GetPickerWidget()->GetEditText();
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index e68a1f7..052b750 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -299,8 +299,8 @@
 
   if (m_pFocusWidget) {
     CXFA_ContentLayoutItem* pItem = m_pFocusWidget->GetLayoutItem();
-    if (pItem->TestStatusBits(XFA_WidgetStatus_Visible) &&
-        !pItem->TestStatusBits(XFA_WidgetStatus_Focused)) {
+    if (pItem->TestStatusBits(XFA_WidgetStatus::kVisible) &&
+        !pItem->TestStatusBits(XFA_WidgetStatus::kFocused)) {
       if (!m_pFocusWidget->IsLoaded())
         m_pFocusWidget->LoadWidget();
       if (!m_pFocusWidget->OnSetFocus(m_pFocusWidget))
@@ -313,7 +313,8 @@
   }
 
   if (pNewFocus) {
-    if (pNewFocus->GetLayoutItem()->TestStatusBits(XFA_WidgetStatus_Visible)) {
+    if (pNewFocus->GetLayoutItem()->TestStatusBits(
+            XFA_WidgetStatus::kVisible)) {
       if (!pNewFocus->IsLoaded())
         pNewFocus->LoadWidget();
       if (!pNewFocus->OnSetFocus(m_pFocusWidget))
diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp
index 255239e..6f9ba26 100644
--- a/xfa/fxfa/cxfa_fffield.cpp
+++ b/xfa/fxfa/cxfa_fffield.cpp
@@ -517,7 +517,7 @@
 
   CFWL_MessageSetFocus msg(nullptr, GetNormalWidget());
   SendMessageToFWLWidget(&msg);
-  GetLayoutItem()->SetStatusBits(XFA_WidgetStatus_Focused);
+  GetLayoutItem()->SetStatusBits(XFA_WidgetStatus::kFocused);
   InvalidateRect();
 
   return true;
@@ -527,7 +527,7 @@
   if (GetNormalWidget()) {
     CFWL_MessageKillFocus msg(nullptr, GetNormalWidget());
     SendMessageToFWLWidget(&msg);
-    GetLayoutItem()->ClearStatusBits(XFA_WidgetStatus_Focused);
+    GetLayoutItem()->ClearStatusBits(XFA_WidgetStatus::kFocused);
     InvalidateRect();
   }
   return pNewWidget && CXFA_FFWidget::OnKillFocus(pNewWidget);
diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp
index 810d565..c96869b 100644
--- a/xfa/fxfa/cxfa_ffnotify.cpp
+++ b/xfa/fxfa/cxfa_ffnotify.cpp
@@ -470,7 +470,7 @@
 void CXFA_FFNotify::OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout,
                                       CXFA_LayoutItem* pSender,
                                       int32_t iPageIdx,
-                                      XFA_WidgetStatusMask dwStatus) {
+                                      Mask<XFA_WidgetStatus> dwStatus) {
   CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout);
   if (!pDocView)
     return;
@@ -480,19 +480,19 @@
     return;
 
   CXFA_FFPageView* pNewPageView = pDocView->GetPageView(iPageIdx);
-  constexpr XFA_WidgetStatusMask kRemove = XFA_WidgetStatus_Visible |
-                                           XFA_WidgetStatus_Viewable |
-                                           XFA_WidgetStatus_Printable;
+  constexpr Mask<XFA_WidgetStatus> kRemove{XFA_WidgetStatus::kVisible,
+                                           XFA_WidgetStatus::kViewable,
+                                           XFA_WidgetStatus::kPrintable};
   pWidget->ModifyStatus(dwStatus, kRemove);
   CXFA_FFPageView* pPrePageView = pWidget->GetPageView();
   if (pPrePageView != pNewPageView ||
-      (dwStatus & (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) ==
-          (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) {
+      dwStatus.TestAll(
+          {XFA_WidgetStatus::kVisible, XFA_WidgetStatus::kViewable})) {
     pWidget->SetPageView(pNewPageView);
     m_pDoc->WidgetPostAdd(pWidget);
   }
   if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End ||
-      !(dwStatus & XFA_WidgetStatus_Visible)) {
+      !(dwStatus & XFA_WidgetStatus::kVisible)) {
     return;
   }
   if (pWidget->IsLoaded()) {
diff --git a/xfa/fxfa/cxfa_ffnotify.h b/xfa/fxfa/cxfa_ffnotify.h
index c982fbc..e92016a 100644
--- a/xfa/fxfa/cxfa_ffnotify.h
+++ b/xfa/fxfa/cxfa_ffnotify.h
@@ -7,6 +7,7 @@
 #ifndef XFA_FXFA_CXFA_FFNOTIFY_H_
 #define XFA_FXFA_CXFA_FFNOTIFY_H_
 
+#include "core/fxcrt/mask.h"
 #include "fxjs/gc/heap.h"
 #include "v8/include/cppgc/garbage-collected.h"
 #include "v8/include/cppgc/member.h"
@@ -55,7 +56,7 @@
   void OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout,
                          CXFA_LayoutItem* pSender,
                          int32_t iPageIdx,
-                         XFA_WidgetStatusMask dwStatus);
+                         Mask<XFA_WidgetStatus> dwStatus);
   void OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout,
                             CXFA_LayoutItem* pSender);
   void StartFieldDrawLayout(CXFA_Node* pItem,
diff --git a/xfa/fxfa/cxfa_ffpageview.cpp b/xfa/fxfa/cxfa_ffpageview.cpp
index 7a49aaf..59a114f 100644
--- a/xfa/fxfa/cxfa_ffpageview.cpp
+++ b/xfa/fxfa/cxfa_ffpageview.cpp
@@ -68,24 +68,25 @@
 }
 
 bool PageWidgetFilter(CXFA_FFWidget* pWidget,
-                      XFA_WidgetStatusMask dwFilter,
+                      Mask<XFA_WidgetStatus> dwFilter,
                       bool bTraversal,
                       bool bIgnoreRelevant) {
   CXFA_Node* pNode = pWidget->GetNode();
 
-  if ((dwFilter & XFA_WidgetStatus_Focused) &&
+  if ((dwFilter & XFA_WidgetStatus::kFocused) &&
       (!pNode || pNode->GetElementType() != XFA_Element::Field)) {
     return false;
   }
 
   CXFA_ContentLayoutItem* pItem = pWidget->GetLayoutItem();
-  if (bTraversal && pItem->TestStatusBits(XFA_WidgetStatus_Disabled))
+  if (bTraversal && pItem->TestStatusBits(XFA_WidgetStatus::kDisabled))
     return false;
   if (bIgnoreRelevant)
-    return pItem->TestStatusBits(XFA_WidgetStatus_Visible);
+    return pItem->TestStatusBits(XFA_WidgetStatus::kVisible);
 
-  dwFilter &= (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable |
-               XFA_WidgetStatus_Printable);
+  dwFilter &= Mask<XFA_WidgetStatus>{XFA_WidgetStatus::kVisible,
+                                     XFA_WidgetStatus::kViewable,
+                                     XFA_WidgetStatus::kPrintable};
   return pItem->TestStatusBits(dwFilter);
 }
 
@@ -117,7 +118,7 @@
 
 bool EnsureWidgetLoadedIfVisible(CXFA_FFWidget* pWidget) {
   if (!pWidget->IsLoaded() &&
-      pWidget->GetLayoutItem()->TestStatusBits(XFA_WidgetStatus_Visible)) {
+      pWidget->GetLayoutItem()->TestStatusBits(XFA_WidgetStatus::kVisible)) {
     if (!pWidget->LoadWidget())
       return false;
   }
@@ -133,9 +134,10 @@
   return pWidget;
 }
 
-CXFA_FFWidget* FilteredLoadedWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem,
-                                                  XFA_WidgetStatusMask dwFilter,
-                                                  bool bIgnoreRelevant) {
+CXFA_FFWidget* FilteredLoadedWidgetFromLayoutItem(
+    CXFA_LayoutItem* pLayoutItem,
+    Mask<XFA_WidgetStatus> dwFilter,
+    bool bIgnoreRelevant) {
   CXFA_FFWidget* pWidget = CXFA_FFWidget::FromLayoutItem(pLayoutItem);
   if (!pWidget)
     return nullptr;
@@ -265,14 +267,14 @@
 }
 
 CXFA_FFWidget::IteratorIface* CXFA_FFPageView::CreateGCedFormWidgetIterator(
-    XFA_WidgetStatusMask dwWidgetFilter) {
+    Mask<XFA_WidgetStatus> dwWidgetFilter) {
   return cppgc::MakeGarbageCollected<CXFA_FFPageWidgetIterator>(
       GetDocView()->GetDoc()->GetHeap()->GetAllocationHandle(), this,
       dwWidgetFilter);
 }
 
 CXFA_FFWidget::IteratorIface* CXFA_FFPageView::CreateGCedTraverseWidgetIterator(
-    XFA_WidgetStatusMask dwWidgetFilter) {
+    Mask<XFA_WidgetStatus> dwWidgetFilter) {
   return cppgc::MakeGarbageCollected<CXFA_FFTabOrderPageWidgetIterator>(
       GetDocView()->GetDoc()->GetHeap()->GetAllocationHandle(), this,
       dwWidgetFilter);
@@ -280,7 +282,7 @@
 
 CXFA_FFPageWidgetIterator::CXFA_FFPageWidgetIterator(
     CXFA_FFPageView* pPageView,
-    XFA_WidgetStatusMask dwFilter)
+    Mask<XFA_WidgetStatus> dwFilter)
     : m_sIterator(pPageView->GetLayoutItem()),
       m_dwFilter(dwFilter),
       m_bIgnoreRelevant(IsDocVersionBelow205(GetDocForPageView(pPageView))) {}
@@ -337,7 +339,7 @@
 
 CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator(
     CXFA_FFPageView* pPageView,
-    XFA_WidgetStatusMask dwFilter)
+    Mask<XFA_WidgetStatus> dwFilter)
     : m_pPageViewLayout(pPageView->GetLayoutItem()),
       m_dwFilter(dwFilter),
       m_bIgnoreRelevant(IsDocVersionBelow205(GetDocForPageView(pPageView))) {
diff --git a/xfa/fxfa/cxfa_ffpageview.h b/xfa/fxfa/cxfa_ffpageview.h
index af93ed7..54ea822 100644
--- a/xfa/fxfa/cxfa_ffpageview.h
+++ b/xfa/fxfa/cxfa_ffpageview.h
@@ -10,6 +10,7 @@
 #include <vector>
 
 #include "core/fxcrt/fx_string.h"
+#include "core/fxcrt/mask.h"
 #include "fxjs/gc/heap.h"
 #include "v8/include/cppgc/garbage-collected.h"
 #include "v8/include/cppgc/member.h"
@@ -38,9 +39,9 @@
 
   // These always return a non-null iterator from the gc heap.
   CXFA_FFWidget::IteratorIface* CreateGCedFormWidgetIterator(
-      XFA_WidgetStatusMask dwWidgetFilter);
+      Mask<XFA_WidgetStatus> dwWidgetFilter);
   CXFA_FFWidget::IteratorIface* CreateGCedTraverseWidgetIterator(
-      XFA_WidgetStatusMask dwWidgetFilter);
+      Mask<XFA_WidgetStatus> dwWidgetFilter);
 
  private:
   CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea);
@@ -69,10 +70,10 @@
 
  private:
   CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView,
-                            XFA_WidgetStatusMask dwFilter);
+                            Mask<XFA_WidgetStatus> dwFilter);
 
   CXFA_LayoutItemIterator m_sIterator;
-  const XFA_WidgetStatusMask m_dwFilter;
+  const Mask<XFA_WidgetStatus> m_dwFilter;
   const bool m_bIgnoreRelevant;
 };
 
@@ -95,7 +96,7 @@
 
  private:
   CXFA_FFTabOrderPageWidgetIterator(CXFA_FFPageView* pPageView,
-                                    XFA_WidgetStatusMask dwFilter);
+                                    Mask<XFA_WidgetStatus> dwFilter);
 
   CXFA_FFWidget* GetTraverseWidget(CXFA_FFWidget* pWidget);
   CXFA_FFWidget* FindWidgetByName(const WideString& wsWidgetName,
@@ -105,7 +106,7 @@
 
   cppgc::Member<CXFA_ViewLayoutItem> const m_pPageViewLayout;
   std::vector<cppgc::Member<CXFA_ContentLayoutItem>> m_TabOrderWidgetArray;
-  const XFA_WidgetStatusMask m_dwFilter;
+  const Mask<XFA_WidgetStatus> m_dwFilter;
   int32_t m_iCurWidget = -1;
   const bool m_bIgnoreRelevant;
 };
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp
index 9eea6fe..9a83b6f 100644
--- a/xfa/fxfa/cxfa_fftextedit.cpp
+++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -135,7 +135,7 @@
 bool CXFA_FFTextEdit::OnLButtonDown(Mask<XFA_FWL_KeyFlag> dwFlags,
                                     const CFX_PointF& point) {
   if (!IsFocused()) {
-    GetLayoutItem()->SetStatusBits(XFA_WidgetStatus_Focused);
+    GetLayoutItem()->SetStatusBits(XFA_WidgetStatus::kFocused);
     UpdateFWLData();
     InvalidateRect();
   }
@@ -150,7 +150,7 @@
 bool CXFA_FFTextEdit::OnRButtonDown(Mask<XFA_FWL_KeyFlag> dwFlags,
                                     const CFX_PointF& point) {
   if (!IsFocused()) {
-    GetLayoutItem()->SetStatusBits(XFA_WidgetStatus_Focused);
+    GetLayoutItem()->SetStatusBits(XFA_WidgetStatus::kFocused);
     UpdateFWLData();
     InvalidateRect();
   }
@@ -172,9 +172,9 @@
 }
 
 bool CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) {
-  GetLayoutItem()->ClearStatusBits(XFA_WidgetStatus_TextEditValueChanged);
+  GetLayoutItem()->ClearStatusBits(XFA_WidgetStatus::kTextEditValueChanged);
   if (!IsFocused()) {
-    GetLayoutItem()->SetStatusBits(XFA_WidgetStatus_Focused);
+    GetLayoutItem()->SetStatusBits(XFA_WidgetStatus::kFocused);
     UpdateFWLData();
     InvalidateRect();
   }
@@ -190,7 +190,7 @@
   CFWL_MessageKillFocus msg(nullptr, GetNormalWidget());
   SendMessageToFWLWidget(&msg);
 
-  GetLayoutItem()->ClearStatusBits(XFA_WidgetStatus_Focused);
+  GetLayoutItem()->ClearStatusBits(XFA_WidgetStatus::kFocused);
   SetEditScrollOffset();
   ProcessCommittedData();
   UpdateFWLData();
@@ -199,7 +199,7 @@
   if (!CXFA_FFWidget::OnKillFocus(pNewWidget))
     return false;
 
-  GetLayoutItem()->ClearStatusBits(XFA_WidgetStatus_TextEditValueChanged);
+  GetLayoutItem()->ClearStatusBits(XFA_WidgetStatus::kTextEditValueChanged);
   return true;
 }
 
@@ -229,7 +229,8 @@
 }
 
 bool CXFA_FFTextEdit::IsDataChanged() {
-  return GetLayoutItem()->TestStatusBits(XFA_WidgetStatus_TextEditValueChanged);
+  return GetLayoutItem()->TestStatusBits(
+      XFA_WidgetStatus::kTextEditValueChanged);
 }
 
 uint32_t CXFA_FFTextEdit::GetAlignment() {
@@ -316,7 +317,7 @@
 
 void CXFA_FFTextEdit::OnTextWillChange(CFWL_Widget* pWidget,
                                        CFWL_EventTextWillChange* event) {
-  GetLayoutItem()->SetStatusBits(XFA_WidgetStatus_TextEditValueChanged);
+  GetLayoutItem()->SetStatusBits(XFA_WidgetStatus::kTextEditValueChanged);
 
   CXFA_EventParam eParam;
   eParam.m_eType = XFA_EVENT_Change;
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 1c1584d..6cb200b 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -249,13 +249,13 @@
 }
 
 const CFX_RectF& CXFA_FFWidget::GetWidgetRect() const {
-  if (!GetLayoutItem()->TestStatusBits(XFA_WidgetStatus_RectCached))
+  if (!GetLayoutItem()->TestStatusBits(XFA_WidgetStatus::kRectCached))
     RecacheWidgetRect();
   return m_WidgetRect;
 }
 
 const CFX_RectF& CXFA_FFWidget::RecacheWidgetRect() const {
-  GetLayoutItem()->SetStatusBits(XFA_WidgetStatus_RectCached);
+  GetLayoutItem()->SetStatusBits(XFA_WidgetStatus::kRectCached);
   m_WidgetRect = GetLayoutItem()->GetAbsoluteRect();
   return m_WidgetRect;
 }
@@ -284,8 +284,8 @@
   return rtWidget;
 }
 
-void CXFA_FFWidget::ModifyStatus(XFA_WidgetStatusMask dwAdded,
-                                 XFA_WidgetStatusMask dwRemoved) {
+void CXFA_FFWidget::ModifyStatus(Mask<XFA_WidgetStatus> dwAdded,
+                                 Mask<XFA_WidgetStatus> dwRemoved) {
   GetLayoutItem()->ClearStatusBits(dwRemoved);
   GetLayoutItem()->SetStatusBits(dwAdded);
 }
@@ -438,7 +438,7 @@
     if (!pParent->OnSetFocus(pOldWidget))
       return false;
   }
-  GetLayoutItem()->SetStatusBits(XFA_WidgetStatus_Focused);
+  GetLayoutItem()->SetStatusBits(XFA_WidgetStatus::kFocused);
 
   CXFA_EventParam eParam;
   eParam.m_eType = XFA_EVENT_Enter;
@@ -448,7 +448,7 @@
 }
 
 bool CXFA_FFWidget::OnKillFocus(CXFA_FFWidget* pNewWidget) {
-  GetLayoutItem()->ClearStatusBits(XFA_WidgetStatus_Focused);
+  GetLayoutItem()->ClearStatusBits(XFA_WidgetStatus::kFocused);
   EventKillFocus();
   if (!pNewWidget)
     return true;
@@ -652,13 +652,13 @@
 }
 
 bool CXFA_FFWidget::HasVisibleStatus() const {
-  return GetLayoutItem()->TestStatusBits(XFA_WidgetStatus_Visible);
+  return GetLayoutItem()->TestStatusBits(XFA_WidgetStatus::kVisible);
 }
 
 void CXFA_FFWidget::EventKillFocus() {
   CXFA_ContentLayoutItem* pItem = GetLayoutItem();
-  if (pItem->TestStatusBits(XFA_WidgetStatus_Access)) {
-    pItem->ClearStatusBits(XFA_WidgetStatus_Access);
+  if (pItem->TestStatusBits(XFA_WidgetStatus::kAccess)) {
+    pItem->ClearStatusBits(XFA_WidgetStatus::kAccess);
     return;
   }
   CXFA_EventParam eParam;
@@ -668,13 +668,13 @@
 }
 
 bool CXFA_FFWidget::IsButtonDown() {
-  return GetLayoutItem()->TestStatusBits(XFA_WidgetStatus_ButtonDown);
+  return GetLayoutItem()->TestStatusBits(XFA_WidgetStatus::kButtonDown);
 }
 
 void CXFA_FFWidget::SetButtonDown(bool bSet) {
   CXFA_ContentLayoutItem* pItem = GetLayoutItem();
   if (bSet)
-    pItem->SetStatusBits(XFA_WidgetStatus_ButtonDown);
+    pItem->SetStatusBits(XFA_WidgetStatus::kButtonDown);
   else
-    pItem->ClearStatusBits(XFA_WidgetStatus_ButtonDown);
+    pItem->ClearStatusBits(XFA_WidgetStatus::kButtonDown);
 }
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index 1fb8ca2..bddabe5 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -11,6 +11,7 @@
 
 #include "core/fpdfdoc/cpdf_formfield.h"
 #include "core/fxcodec/fx_codec_def.h"
+#include "core/fxcrt/mask.h"
 #include "core/fxcrt/retain_ptr.h"
 #include "core/fxge/cfx_graphstatedata.h"
 #include "fxjs/gc/heap.h"
@@ -171,8 +172,8 @@
   CXFA_FFWidget* GetNextFFWidget() const;
   const CFX_RectF& GetWidgetRect() const;
   const CFX_RectF& RecacheWidgetRect() const;
-  void ModifyStatus(XFA_WidgetStatusMask dwAdded,
-                    XFA_WidgetStatusMask dwRemoved);
+  void ModifyStatus(Mask<XFA_WidgetStatus> dwAdded,
+                    Mask<XFA_WidgetStatus> dwRemoved);
 
   CXFA_FFDoc* GetDoc();
   CXFA_FFApp* GetApp();
@@ -180,7 +181,7 @@
   CFWL_App* GetFWLApp() const;
   void InvalidateRect();
   bool IsFocused() const {
-    return GetLayoutItem()->TestStatusBits(XFA_WidgetStatus_Focused);
+    return GetLayoutItem()->TestStatusBits(XFA_WidgetStatus::kFocused);
   }
   CFX_PointF Rotate2Normal(const CFX_PointF& point);
   bool IsLayoutRectEmpty();
diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp
index 5cd4efd..a0cbe2c 100644
--- a/xfa/fxfa/cxfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp
@@ -186,7 +186,7 @@
 
 FWL_WidgetHit CXFA_FFWidgetHandler::HitTest(CXFA_FFWidget* pWidget,
                                             const CFX_PointF& point) {
-  if (!pWidget->GetLayoutItem()->TestStatusBits(XFA_WidgetStatus_Visible))
+  if (!pWidget->GetLayoutItem()->TestStatusBits(XFA_WidgetStatus::kVisible))
     return FWL_WidgetHit::Unknown;
   return pWidget->HitTest(pWidget->Rotate2Normal(point));
 }
diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h
index 688bdce..863c139 100644
--- a/xfa/fxfa/fxfa.h
+++ b/xfa/fxfa/fxfa.h
@@ -7,8 +7,6 @@
 #ifndef XFA_FXFA_FXFA_H_
 #define XFA_FXFA_FXFA_H_
 
-#include <type_traits>
-
 // Note, values must match fpdf_formfill.h JSPLATFORM_ALERT_BUTTON_* flags.
 enum class AlertButton {
   kDefault = 0,
@@ -60,18 +58,17 @@
   kDisabled = 2,
 };
 
-enum XFA_WidgetStatus : uint16_t {
-  XFA_WidgetStatus_None = 0,
-  XFA_WidgetStatus_Access = 1 << 0,
-  XFA_WidgetStatus_ButtonDown = 1 << 1,
-  XFA_WidgetStatus_Disabled = 1 << 2,
-  XFA_WidgetStatus_Focused = 1 << 3,
-  XFA_WidgetStatus_Printable = 1 << 4,
-  XFA_WidgetStatus_RectCached = 1 << 5,
-  XFA_WidgetStatus_TextEditValueChanged = 1 << 6,
-  XFA_WidgetStatus_Viewable = 1 << 7,
-  XFA_WidgetStatus_Visible = 1 << 8
+enum class XFA_WidgetStatus : uint16_t {
+  kNone = 0,
+  kAccess = 1 << 0,
+  kButtonDown = 1 << 1,
+  kDisabled = 1 << 2,
+  kFocused = 1 << 3,
+  kPrintable = 1 << 4,
+  kRectCached = 1 << 5,
+  kTextEditValueChanged = 1 << 6,
+  kViewable = 1 << 7,
+  kVisible = 1 << 8
 };
-using XFA_WidgetStatusMask = std::underlying_type<XFA_WidgetStatus>::type;
 
 #endif  // XFA_FXFA_FXFA_H_
diff --git a/xfa/fxfa/layout/cxfa_contentlayoutitem.h b/xfa/fxfa/layout/cxfa_contentlayoutitem.h
index a3dd50d..c8462d2 100644
--- a/xfa/fxfa/layout/cxfa_contentlayoutitem.h
+++ b/xfa/fxfa/layout/cxfa_contentlayoutitem.h
@@ -8,6 +8,7 @@
 #define XFA_FXFA_LAYOUT_CXFA_CONTENTLAYOUTITEM_H_
 
 #include "core/fxcrt/fx_coordinates.h"
+#include "core/fxcrt/mask.h"
 #include "v8/include/cppgc/persistent.h"
 #include "xfa/fxfa/fxfa.h"
 #include "xfa/fxfa/layout/cxfa_layoutitem.h"
@@ -33,12 +34,12 @@
   CFX_RectF GetAbsoluteRect() const;
   size_t GetIndex() const;
 
-  void SetStatusBits(XFA_WidgetStatusMask val) { m_dwStatus |= val; }
-  void ClearStatusBits(XFA_WidgetStatusMask val) { m_dwStatus &= ~val; }
+  void SetStatusBits(Mask<XFA_WidgetStatus> val) { m_dwStatus |= val; }
+  void ClearStatusBits(Mask<XFA_WidgetStatus> val) { m_dwStatus &= ~val; }
 
   // TRUE if all (not any) bits set in |val| are set in |m_dwStatus|.
-  bool TestStatusBits(XFA_WidgetStatusMask val) const {
-    return (m_dwStatus & val) == val;
+  bool TestStatusBits(Mask<XFA_WidgetStatus> val) const {
+    return m_dwStatus.TestAll(val);
   }
 
   CFX_PointF m_sPos;
@@ -48,7 +49,7 @@
   CXFA_ContentLayoutItem(CXFA_Node* pNode, CXFA_FFWidget* pFFWidget);
   void RemoveSelf();
 
-  mutable XFA_WidgetStatusMask m_dwStatus = 0;
+  mutable Mask<XFA_WidgetStatus> m_dwStatus;
   cppgc::Member<CXFA_ContentLayoutItem> m_pPrev;
   cppgc::Member<CXFA_ContentLayoutItem> m_pNext;
   cppgc::Member<CXFA_FFWidget> const m_pFFWidget;
diff --git a/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp b/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
index 4ceba71..86f36fc 100644
--- a/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
+++ b/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
@@ -105,25 +105,25 @@
 using PageSetIterator =
     CXFA_NodeIteratorTemplate<CXFA_ViewLayoutItem, TraverseStrategy_PageSet>;
 
-XFA_WidgetStatusMask GetRelevant(CXFA_Node* pFormItem,
-                                 XFA_WidgetStatusMask dwParentRelvant) {
-  XFA_WidgetStatusMask dwRelevant =
-      XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable;
+Mask<XFA_WidgetStatus> GetRelevant(CXFA_Node* pFormItem,
+                                   Mask<XFA_WidgetStatus> dwParentRelvant) {
+  Mask<XFA_WidgetStatus> dwRelevant = {XFA_WidgetStatus::kViewable,
+                                       XFA_WidgetStatus::kPrintable};
   WideString wsRelevant =
       pFormItem->JSObject()->GetCData(XFA_Attribute::Relevant);
   if (!wsRelevant.IsEmpty()) {
     if (wsRelevant.EqualsASCII("+print") || wsRelevant.EqualsASCII("print"))
-      dwRelevant &= ~XFA_WidgetStatus_Viewable;
+      dwRelevant.Clear(XFA_WidgetStatus::kViewable);
     else if (wsRelevant.EqualsASCII("-print"))
-      dwRelevant &= ~XFA_WidgetStatus_Printable;
+      dwRelevant.Clear(XFA_WidgetStatus::kPrintable);
   }
-  if (!(dwParentRelvant & XFA_WidgetStatus_Viewable) &&
-      (dwRelevant != XFA_WidgetStatus_Viewable)) {
-    dwRelevant &= ~XFA_WidgetStatus_Viewable;
+  if (!(dwParentRelvant & XFA_WidgetStatus::kViewable) &&
+      (dwRelevant != XFA_WidgetStatus::kViewable)) {
+    dwRelevant.Clear(XFA_WidgetStatus::kViewable);
   }
-  if (!(dwParentRelvant & XFA_WidgetStatus_Printable) &&
-      (dwRelevant != XFA_WidgetStatus_Printable)) {
-    dwRelevant &= ~XFA_WidgetStatus_Printable;
+  if (!(dwParentRelvant & XFA_WidgetStatus::kPrintable) &&
+      (dwRelevant != XFA_WidgetStatus::kPrintable)) {
+    dwRelevant.Clear(XFA_WidgetStatus::kPrintable);
   }
   return dwRelevant;
 }
@@ -131,12 +131,12 @@
 void SyncContainer(CXFA_FFNotify* pNotify,
                    CXFA_LayoutProcessor* pDocLayout,
                    CXFA_LayoutItem* pViewItem,
-                   XFA_WidgetStatusMask dwRelevant,
+                   Mask<XFA_WidgetStatus> dwRelevant,
                    bool bVisible,
                    int32_t nPageIndex) {
   bool bVisibleItem = false;
-  XFA_WidgetStatusMask dwStatus = 0;
-  XFA_WidgetStatusMask dwRelevantContainer = 0;
+  Mask<XFA_WidgetStatus> dwStatus;
+  Mask<XFA_WidgetStatus> dwRelevantContainer;
   if (bVisible) {
     XFA_AttributeValue eAttributeValue =
         pViewItem->GetFormNode()
@@ -147,8 +147,9 @@
       bVisibleItem = true;
 
     dwRelevantContainer = GetRelevant(pViewItem->GetFormNode(), dwRelevant);
-    dwStatus =
-        (bVisibleItem ? XFA_WidgetStatus_Visible : 0) | dwRelevantContainer;
+    dwStatus = dwRelevantContainer;
+    if (bVisibleItem)
+      dwStatus |= XFA_WidgetStatus::kVisible;
   }
   pNotify->OnLayoutItemAdded(pDocLayout, pViewItem, nPageIndex, dwStatus);
   for (CXFA_LayoutItem* pChild = pViewItem->GetFirstChild(); pChild;
@@ -1885,8 +1886,8 @@
         continue;
 
       nPageIdx++;
-      XFA_WidgetStatusMask dwRelevant =
-          XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable;
+      Mask<XFA_WidgetStatus> dwRelevant = {XFA_WidgetStatus::kViewable,
+                                           XFA_WidgetStatus::kPrintable};
       CXFA_LayoutItemIterator iterator(pViewItem);
       CXFA_LayoutItem* pChildLayoutItem = iterator.GetCurrent();
       while (pChildLayoutItem) {
@@ -1903,7 +1904,7 @@
                 ->TryEnum(XFA_Attribute::Presence, true)
                 .value_or(XFA_AttributeValue::Visible);
         bool bVisible = presence == XFA_AttributeValue::Visible;
-        XFA_WidgetStatusMask dwRelevantChild =
+        Mask<XFA_WidgetStatus> dwRelevantChild =
             GetRelevant(pContentItem->GetFormNode(), dwRelevant);
         SyncContainer(pNotify, m_pLayoutProcessor, pContentItem,
                       dwRelevantChild, bVisible, nPageIdx);