Introduce FWL_EventFlagMask type.

Define this type in cpwl_wnd.h. Use it to clarify the meaning of
many former uint32_t args. Update the public API again to explain
where these values are found.

-- tidy some boolean functions.

Change-Id: I4e5df29b6d205f092aaea1fca3e30205ffb5b35e
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/83953
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.cpp b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
index 1299c49..b4b68f6 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,
-    uint32_t nFlags,
+    FWL_EventFlagMask 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,
-    uint32_t nFlags,
+    FWL_EventFlagMask 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,
-    uint32_t nFlags,
+    FWL_EventFlagMask 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,
-    uint32_t nFlags,
+    FWL_EventFlagMask 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,
-    uint32_t nFlags,
+    FWL_EventFlagMask 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,
-    uint32_t nFlags,
+    FWL_EventFlagMask 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,
-    uint32_t nFlags,
+    FWL_EventFlagMask 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,
-    uint32_t nFlag) {
+    FWL_EventFlagMask 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,
-    uint32_t nFlag) {
+    FWL_EventFlagMask nFlag) {
   DCHECK(pAnnot->HasObservable());
   GetAnnotHandler(pAnnot->Get())->OnMouseExit(pPageView, pAnnot, nFlag);
 }
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot,
                                            uint32_t nChar,
-                                           uint32_t nFlags) {
+                                           FWL_EventFlagMask nFlags) {
   return GetAnnotHandler(pAnnot)->OnChar(pAnnot, nChar, nFlags);
 }
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_PageView* pPageView,
                                               CPDFSDK_Annot* pAnnot,
                                               FWL_VKEYCODE nKeyCode,
-                                              int nFlag) {
+                                              FWL_EventFlagMask 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,
-    uint32_t nFlag) {
+    FWL_EventFlagMask nFlag) {
   DCHECK(pAnnot->HasObservable());
   return GetAnnotHandler(pAnnot->Get())->OnSetFocus(pAnnot, nFlag);
 }
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    uint32_t nFlag) {
+    FWL_EventFlagMask nFlag) {
   DCHECK(pAnnot->HasObservable());
   return GetAnnotHandler(pAnnot->Get())->OnKillFocus(pAnnot, nFlag);
 }
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.h b/fpdfsdk/cpdfsdk_annothandlermgr.h
index f43a2b9..f6463ac 100644
--- a/fpdfsdk/cpdfsdk_annothandlermgr.h
+++ b/fpdfsdk/cpdfsdk_annothandlermgr.h
@@ -12,6 +12,7 @@
 #include "core/fpdfdoc/cpdf_annot.h"
 #include "core/fxcrt/fx_coordinates.h"
 #include "fpdfsdk/cpdfsdk_annot.h"
+#include "fpdfsdk/pwl/cpwl_wnd.h"
 #include "public/fpdf_fwlevent.h"
 
 class CFX_Matrix;
@@ -65,46 +66,50 @@
 
   void Annot_OnMouseEnter(CPDFSDK_PageView* pPageView,
                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                          uint32_t nFlags);
+                          FWL_EventFlagMask nFlags);
   void Annot_OnMouseExit(CPDFSDK_PageView* pPageView,
                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                         uint32_t nFlags);
+                         FWL_EventFlagMask nFlags);
   bool Annot_OnLButtonDown(CPDFSDK_PageView* pPageView,
                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                           uint32_t nFlags,
+                           FWL_EventFlagMask nFlags,
                            const CFX_PointF& point);
   bool Annot_OnLButtonUp(CPDFSDK_PageView* pPageView,
                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                         uint32_t nFlags,
+                         FWL_EventFlagMask nFlags,
                          const CFX_PointF& point);
   bool Annot_OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                              ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                             uint32_t nFlags,
+                             FWL_EventFlagMask nFlags,
                              const CFX_PointF& point);
   bool Annot_OnMouseMove(CPDFSDK_PageView* pPageView,
                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                         uint32_t nFlags,
+                         FWL_EventFlagMask nFlags,
                          const CFX_PointF& point);
   bool Annot_OnMouseWheel(CPDFSDK_PageView* pPageView,
                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                          uint32_t nFlags,
+                          FWL_EventFlagMask nFlags,
                           const CFX_PointF& point,
                           const CFX_Vector& delta);
   bool Annot_OnRButtonDown(CPDFSDK_PageView* pPageView,
                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                           uint32_t nFlags,
+                           FWL_EventFlagMask nFlags,
                            const CFX_PointF& point);
   bool Annot_OnRButtonUp(CPDFSDK_PageView* pPageView,
                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                         uint32_t nFlags,
+                         FWL_EventFlagMask nFlags,
                          const CFX_PointF& point);
-  bool Annot_OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags);
+  bool Annot_OnChar(CPDFSDK_Annot* pAnnot,
+                    uint32_t nChar,
+                    FWL_EventFlagMask nFlags);
   bool Annot_OnKeyDown(CPDFSDK_PageView* pPageView,
                        CPDFSDK_Annot* pAnnot,
                        FWL_VKEYCODE nKeyCode,
-                       int nFlag);
-  bool Annot_OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag);
-  bool Annot_OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag);
+                       FWL_EventFlagMask nFlag);
+  bool Annot_OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
+                        FWL_EventFlagMask nFlag);
+  bool Annot_OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
+                         FWL_EventFlagMask 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 5ade8d9..4e19780 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,
-                                          uint32_t nFlag) {
+                                          FWL_EventFlagMask 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,
-                                         uint32_t nFlag) {
+                                         FWL_EventFlagMask 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,
-                                           uint32_t nFlags,
+                                           FWL_EventFlagMask nFlags,
                                            const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                         uint32_t nFlags,
+                                         FWL_EventFlagMask nFlags,
                                          const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                                              ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                             uint32_t nFlags,
+                                             FWL_EventFlagMask nFlags,
                                              const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                         uint32_t nFlags,
+                                         FWL_EventFlagMask nFlags,
                                          const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
                                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                          uint32_t nFlags,
+                                          FWL_EventFlagMask 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,
-                                           uint32_t nFlags,
+                                           FWL_EventFlagMask nFlags,
                                            const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                         uint32_t nFlags,
+                                         FWL_EventFlagMask nFlags,
                                          const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView,
                                              ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                             uint32_t nFlags,
+                                             FWL_EventFlagMask nFlags,
                                              const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot,
                                     uint32_t nChar,
-                                    uint32_t nFlags) {
+                                    FWL_EventFlagMask nFlags) {
   return false;
 }
 
 bool CPDFSDK_BAAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
                                        FWL_VKEYCODE nKeyCode,
-                                       int nFlag) {
+                                       FWL_EventFlagMask 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,
-                                     int nFlag) {
+                                     FWL_EventFlagMask nFlag) {
   return false;
 }
 
@@ -228,7 +228,7 @@
 }
 
 bool CPDFSDK_BAAnnotHandler::OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        uint32_t nFlag) {
+                                        FWL_EventFlagMask nFlag) {
   if (!IsFocusableAnnot(pAnnot->Get()->GetAnnotSubtype()))
     return false;
 
@@ -238,7 +238,7 @@
 }
 
 bool CPDFSDK_BAAnnotHandler::OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                         uint32_t nFlag) {
+                                         FWL_EventFlagMask nFlag) {
   if (!IsFocusableAnnot(pAnnot->Get()->GetAnnotSubtype()))
     return false;
 
diff --git a/fpdfsdk/cpdfsdk_baannothandler.h b/fpdfsdk/cpdfsdk_baannothandler.h
index f5b632a..ad2b986 100644
--- a/fpdfsdk/cpdfsdk_baannothandler.h
+++ b/fpdfsdk/cpdfsdk_baannothandler.h
@@ -54,52 +54,56 @@
 
   void OnMouseEnter(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    uint32_t nFlag) override;
+                    FWL_EventFlagMask nFlag) override;
   void OnMouseExit(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlag) override;
+                   FWL_EventFlagMask nFlag) override;
   bool OnLButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     uint32_t nFlags,
+                     FWL_EventFlagMask nFlags,
                      const CFX_PointF& point) override;
   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask nFlags,
                    const CFX_PointF& point) override;
   bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                       uint32_t nFlags,
+                       FWL_EventFlagMask nFlags,
                        const CFX_PointF& point) override;
   bool OnMouseMove(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask nFlags,
                    const CFX_PointF& point) override;
   bool OnMouseWheel(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    uint32_t nFlags,
+                    FWL_EventFlagMask nFlags,
                     const CFX_PointF& point,
                     const CFX_Vector& delta) override;
   bool OnRButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     uint32_t nFlags,
+                     FWL_EventFlagMask nFlags,
                      const CFX_PointF& point) override;
   bool OnRButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask nFlags,
                    const CFX_PointF& point) override;
   bool OnRButtonDblClk(CPDFSDK_PageView* pPageView,
                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                       uint32_t nFlags,
+                       FWL_EventFlagMask nFlags,
                        const CFX_PointF& point) override;
-  bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override;
+  bool OnChar(CPDFSDK_Annot* pAnnot,
+              uint32_t nChar,
+              FWL_EventFlagMask nFlags) override;
   bool OnKeyDown(CPDFSDK_Annot* pAnnot,
                  FWL_VKEYCODE nKeyCode,
-                 int nFlag) override;
+                 FWL_EventFlagMask nFlag) override;
   bool OnKeyUp(CPDFSDK_Annot* pAnnot,
                FWL_VKEYCODE nKeyCode,
-               int nFlag) override;
-  bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag) override;
-  bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag) override;
+               FWL_EventFlagMask nFlag) override;
+  bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
+                  FWL_EventFlagMask nFlag) override;
+  bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
+                   FWL_EventFlagMask nFlag) override;
   bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                         int index,
                         bool selected) override;
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index 572e1fa..c91dff3 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -741,7 +741,7 @@
   return true;
 }
 
-bool CPDFSDK_FormFillEnvironment::KillFocusAnnot(uint32_t nFlag) {
+bool CPDFSDK_FormFillEnvironment::KillFocusAnnot(FWL_EventFlagMask nFlag) {
   if (!m_pFocusAnnot)
     return false;
 
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h
index bedbc37..df47005 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.h
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.h
@@ -19,6 +19,7 @@
 #include "core/fxcrt/retain_ptr.h"
 #include "core/fxcrt/unowned_ptr.h"
 #include "fpdfsdk/cpdfsdk_annot.h"
+#include "fpdfsdk/pwl/cpwl_wnd.h"
 #include "fpdfsdk/pwl/ipwl_systemhandler.h"
 #include "public/fpdf_formfill.h"
 
@@ -74,7 +75,7 @@
 
   CPDFSDK_Annot* GetFocusAnnot() const { return m_pFocusAnnot.Get(); }
   bool SetFocusAnnot(ObservedPtr<CPDFSDK_Annot>* pAnnot);
-  bool KillFocusAnnot(uint32_t nFlag);
+  bool KillFocusAnnot(FWL_EventFlagMask nFlag);
   void ClearAllFocusedAnnots();
 
   int GetPageCount() const;
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp
index a2648da..7978559 100644
--- a/fpdfsdk/cpdfsdk_pageview.cpp
+++ b/fpdfsdk/cpdfsdk_pageview.cpp
@@ -275,7 +275,8 @@
   return false;
 }
 
-bool CPDFSDK_PageView::OnFocus(uint32_t nFlag, const CFX_PointF& point) {
+bool CPDFSDK_PageView::OnFocus(FWL_EventFlagMask nFlag,
+                               const CFX_PointF& point) {
   ObservedPtr<CPDFSDK_Annot> pAnnot(GetFXWidgetAtPoint(point));
   if (!pAnnot) {
     m_pFormFillEnv->KillFocusAnnot(nFlag);
@@ -286,7 +287,8 @@
   return true;
 }
 
-bool CPDFSDK_PageView::OnLButtonDown(uint32_t nFlag, const CFX_PointF& point) {
+bool CPDFSDK_PageView::OnLButtonDown(FWL_EventFlagMask nFlag,
+                                     const CFX_PointF& point) {
   ObservedPtr<CPDFSDK_Annot> pAnnot(GetFXWidgetAtPoint(point));
   if (!pAnnot) {
     m_pFormFillEnv->KillFocusAnnot(nFlag);
@@ -305,7 +307,8 @@
   return true;
 }
 
-bool CPDFSDK_PageView::OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) {
+bool CPDFSDK_PageView::OnLButtonUp(FWL_EventFlagMask nFlag,
+                                   const CFX_PointF& point) {
   CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
       m_pFormFillEnv->GetAnnotHandlerMgr();
   ObservedPtr<CPDFSDK_Annot> pFXAnnot(GetFXWidgetAtPoint(point));
@@ -319,7 +322,7 @@
          pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFXAnnot, nFlag, point);
 }
 
-bool CPDFSDK_PageView::OnLButtonDblClk(uint32_t nFlag,
+bool CPDFSDK_PageView::OnLButtonDblClk(FWL_EventFlagMask nFlag,
                                        const CFX_PointF& point) {
   ObservedPtr<CPDFSDK_Annot> pAnnot(GetFXWidgetAtPoint(point));
   if (!pAnnot) {
@@ -339,7 +342,8 @@
   return true;
 }
 
-bool CPDFSDK_PageView::OnRButtonDown(uint32_t nFlag, const CFX_PointF& point) {
+bool CPDFSDK_PageView::OnRButtonDown(FWL_EventFlagMask nFlag,
+                                     const CFX_PointF& point) {
   ObservedPtr<CPDFSDK_Annot> pAnnot(GetFXWidgetAtPoint(point));
   if (!pAnnot)
     return false;
@@ -356,7 +360,8 @@
   return true;
 }
 
-bool CPDFSDK_PageView::OnRButtonUp(uint32_t nFlag, const CFX_PointF& point) {
+bool CPDFSDK_PageView::OnRButtonUp(FWL_EventFlagMask nFlag,
+                                   const CFX_PointF& point) {
   ObservedPtr<CPDFSDK_Annot> pAnnot(GetFXWidgetAtPoint(point));
   if (!pAnnot)
     return false;
@@ -373,7 +378,8 @@
   return true;
 }
 
-bool CPDFSDK_PageView::OnMouseMove(int nFlag, const CFX_PointF& point) {
+bool CPDFSDK_PageView::OnMouseMove(FWL_EventFlagMask nFlag,
+                                   const CFX_PointF& point) {
   CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
       m_pFormFillEnv->GetAnnotHandlerMgr();
 
@@ -405,7 +411,7 @@
 
 void CPDFSDK_PageView::EnterWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr,
                                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                   uint32_t nFlag) {
+                                   FWL_EventFlagMask nFlag) {
   m_bOnWidget = true;
   m_pCaptureWidget.Reset(pAnnot->Get());
   pAnnotHandlerMgr->Annot_OnMouseEnter(this, pAnnot, nFlag);
@@ -413,7 +419,7 @@
 
 void CPDFSDK_PageView::ExitWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr,
                                   bool callExitCallback,
-                                  uint32_t nFlag) {
+                                  FWL_EventFlagMask nFlag) {
   m_bOnWidget = false;
   if (!m_pCaptureWidget)
     return;
@@ -430,7 +436,7 @@
   m_pCaptureWidget.Reset();
 }
 
-bool CPDFSDK_PageView::OnMouseWheel(int nFlag,
+bool CPDFSDK_PageView::OnMouseWheel(FWL_EventFlagMask nFlag,
                                     const CFX_PointF& point,
                                     const CFX_Vector& delta) {
   ObservedPtr<CPDFSDK_Annot> pAnnot(GetFXWidgetAtPoint(point));
@@ -466,7 +472,7 @@
   return false;
 }
 
-bool CPDFSDK_PageView::OnChar(uint32_t nChar, uint32_t nFlag) {
+bool CPDFSDK_PageView::OnChar(uint32_t nChar, FWL_EventFlagMask nFlag) {
   if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) {
     CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
         m_pFormFillEnv->GetAnnotHandlerMgr();
@@ -476,14 +482,15 @@
   return false;
 }
 
-bool CPDFSDK_PageView::OnKeyDown(FWL_VKEYCODE nKeyCode, int nFlag) {
+bool CPDFSDK_PageView::OnKeyDown(FWL_VKEYCODE nKeyCode,
+                                 FWL_EventFlagMask nFlag) {
   CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
       m_pFormFillEnv->GetAnnotHandlerMgr();
   return pAnnotHandlerMgr->Annot_OnKeyDown(this, GetFocusAnnot(), nKeyCode,
                                            nFlag);
 }
 
-bool CPDFSDK_PageView::OnKeyUp(FWL_VKEYCODE nKeyCode, int nFlag) {
+bool CPDFSDK_PageView::OnKeyUp(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag) {
   return false;
 }
 
diff --git a/fpdfsdk/cpdfsdk_pageview.h b/fpdfsdk/cpdfsdk_pageview.h
index 2219779..1d30a0b 100644
--- a/fpdfsdk/cpdfsdk_pageview.h
+++ b/fpdfsdk/cpdfsdk_pageview.h
@@ -66,17 +66,17 @@
   bool Undo();
   bool Redo();
 
-  bool OnFocus(uint32_t nFlag, const CFX_PointF& point);
-  bool OnLButtonDown(uint32_t nFlag, const CFX_PointF& point);
-  bool OnLButtonUp(uint32_t nFlag, const CFX_PointF& point);
-  bool OnLButtonDblClk(uint32_t nFlag, const CFX_PointF& point);
-  bool OnRButtonDown(uint32_t nFlag, const CFX_PointF& point);
-  bool OnRButtonUp(uint32_t nFlag, const CFX_PointF& point);
-  bool OnChar(uint32_t nChar, uint32_t nFlag);
-  bool OnKeyDown(FWL_VKEYCODE nKeyCode, int nFlag);
-  bool OnKeyUp(FWL_VKEYCODE nKeyCode, int nFlag);
-  bool OnMouseMove(int nFlag, const CFX_PointF& point);
-  bool OnMouseWheel(int nFlag,
+  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,
                     const CFX_PointF& point,
                     const CFX_Vector& delta);
 
@@ -104,10 +104,10 @@
 
   void EnterWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlag);
+                   FWL_EventFlagMask nFlag);
   void ExitWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr,
                   bool callExitCallback,
-                  uint32_t nFlag);
+                  FWL_EventFlagMask nFlag);
 
   CFX_Matrix m_curMatrix;
   UnownedPtr<IPDF_Page> const m_page;
diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp
index 2de83f0..658a0e2 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,
-                                         uint32_t nFlag) {
+                                         FWL_EventFlagMask nFlag) {
   if (!(*pAnnot)->IsSignatureWidget())
     m_pInteractiveFormFiller->OnMouseEnter(pPageView, pAnnot, nFlag);
 }
 
 void CPDFSDK_WidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        uint32_t nFlag) {
+                                        FWL_EventFlagMask nFlag) {
   if (!(*pAnnot)->IsSignatureWidget())
     m_pInteractiveFormFiller->OnMouseExit(pPageView, pAnnot, nFlag);
 }
 
 bool CPDFSDK_WidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
                                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                          uint32_t nFlags,
+                                          FWL_EventFlagMask 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,
-                                        uint32_t nFlags,
+                                        FWL_EventFlagMask 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,
-                                            uint32_t nFlags,
+                                            FWL_EventFlagMask 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,
-                                        uint32_t nFlags,
+                                        FWL_EventFlagMask 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,
-                                         uint32_t nFlags,
+                                         FWL_EventFlagMask 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,
-                                          uint32_t nFlags,
+                                          FWL_EventFlagMask 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,
-                                        uint32_t nFlags,
+                                        FWL_EventFlagMask 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,
-                                            uint32_t nFlags,
+                                            FWL_EventFlagMask nFlags,
                                             const CFX_PointF& point) {
   return false;
 }
 
 bool CPDFSDK_WidgetHandler::OnChar(CPDFSDK_Annot* pAnnot,
                                    uint32_t nChar,
-                                   uint32_t nFlags) {
+                                   FWL_EventFlagMask nFlags) {
   return !pAnnot->IsSignatureWidget() &&
          m_pInteractiveFormFiller->OnChar(pAnnot, nChar, nFlags);
 }
 
 bool CPDFSDK_WidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
                                       FWL_VKEYCODE nKeyCode,
-                                      int nFlag) {
+                                      FWL_EventFlagMask nFlag) {
   return !pAnnot->IsSignatureWidget() &&
          m_pInteractiveFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlag);
 }
 
 bool CPDFSDK_WidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
                                     FWL_VKEYCODE nKeyCode,
-                                    int nFlag) {
+                                    FWL_EventFlagMask nFlag) {
   return false;
 }
 
@@ -230,7 +230,7 @@
 }
 
 bool CPDFSDK_WidgetHandler::OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                       uint32_t nFlag) {
+                                       FWL_EventFlagMask nFlag) {
   if (!IsFocusableAnnot((*pAnnot)->GetPDFAnnot()->GetSubtype()))
     return false;
 
@@ -239,7 +239,7 @@
 }
 
 bool CPDFSDK_WidgetHandler::OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        uint32_t nFlag) {
+                                        FWL_EventFlagMask nFlag) {
   if (!IsFocusableAnnot((*pAnnot)->GetPDFAnnot()->GetSubtype()))
     return false;
 
diff --git a/fpdfsdk/cpdfsdk_widgethandler.h b/fpdfsdk/cpdfsdk_widgethandler.h
index 366d093..2b8d59a 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.h
+++ b/fpdfsdk/cpdfsdk_widgethandler.h
@@ -54,52 +54,56 @@
 
   void OnMouseEnter(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    uint32_t nFlag) override;
+                    FWL_EventFlagMask nFlag) override;
   void OnMouseExit(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlag) override;
+                   FWL_EventFlagMask nFlag) override;
   bool OnLButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     uint32_t nFlags,
+                     FWL_EventFlagMask nFlags,
                      const CFX_PointF& point) override;
   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask nFlags,
                    const CFX_PointF& point) override;
   bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                       uint32_t nFlags,
+                       FWL_EventFlagMask nFlags,
                        const CFX_PointF& point) override;
   bool OnMouseMove(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask nFlags,
                    const CFX_PointF& point) override;
   bool OnMouseWheel(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    uint32_t nFlags,
+                    FWL_EventFlagMask nFlags,
                     const CFX_PointF& point,
                     const CFX_Vector& delta) override;
   bool OnRButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     uint32_t nFlags,
+                     FWL_EventFlagMask nFlags,
                      const CFX_PointF& point) override;
   bool OnRButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask nFlags,
                    const CFX_PointF& point) override;
   bool OnRButtonDblClk(CPDFSDK_PageView* pPageView,
                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                       uint32_t nFlags,
+                       FWL_EventFlagMask nFlags,
                        const CFX_PointF& point) override;
-  bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override;
+  bool OnChar(CPDFSDK_Annot* pAnnot,
+              uint32_t nChar,
+              FWL_EventFlagMask nFlags) override;
   bool OnKeyDown(CPDFSDK_Annot* pAnnot,
                  FWL_VKEYCODE nKeyCode,
-                 int nFlag) override;
+                 FWL_EventFlagMask nFlag) override;
   bool OnKeyUp(CPDFSDK_Annot* pAnnot,
                FWL_VKEYCODE nKeyCode,
-               int nFlag) override;
-  bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag) override;
-  bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag) override;
+               FWL_EventFlagMask nFlag) override;
+  bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
+                  FWL_EventFlagMask nFlag) override;
+  bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
+                   FWL_EventFlagMask 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 c02d9d6..7382b4b 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,
-                                uint32_t nFlags,
+                                FWL_EventFlagMask 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,
-                              uint32_t nFlags,
+                              FWL_EventFlagMask nFlags,
                               const CFX_PointF& point) {
   if (!pAnnot->GetRect().Contains(point))
     return false;
@@ -53,7 +53,7 @@
 }
 
 bool CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView,
-                              uint32_t nFlags,
+                              FWL_EventFlagMask nFlags,
                               const CFX_PointF& point) {
   return true;
 }
diff --git a/fpdfsdk/formfiller/cffl_button.h b/fpdfsdk/formfiller/cffl_button.h
index aed4b41..2a9912d 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,
-                     uint32_t nFlags,
+                     FWL_EventFlagMask nFlags,
                      const CFX_PointF& point) override;
   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                    CPDFSDK_Annot* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask nFlags,
                    const CFX_PointF& point) override;
   bool OnMouseMove(CPDFSDK_PageView* pPageView,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask 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 96398f9..299fb94 100644
--- a/fpdfsdk/formfiller/cffl_checkbox.cpp
+++ b/fpdfsdk/formfiller/cffl_checkbox.cpp
@@ -32,7 +32,7 @@
   return std::move(pWnd);
 }
 
-bool CFFL_CheckBox::OnKeyDown(FWL_VKEYCODE nKeyCode, uint32_t nFlags) {
+bool CFFL_CheckBox::OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlags) {
   switch (nKeyCode) {
     case FWL_VKEY_Return:
     case FWL_VKEY_Space:
@@ -43,7 +43,7 @@
 }
 bool CFFL_CheckBox::OnChar(CPDFSDK_Annot* pAnnot,
                            uint32_t nChar,
-                           uint32_t nFlags) {
+                           FWL_EventFlagMask nFlags) {
   switch (nChar) {
     case pdfium::ascii::kReturn:
     case pdfium::ascii::kSpace: {
@@ -79,7 +79,7 @@
 
 bool CFFL_CheckBox::OnLButtonUp(CPDFSDK_PageView* pPageView,
                                 CPDFSDK_Annot* pAnnot,
-                                uint32_t nFlags,
+                                FWL_EventFlagMask 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 7685cdb..9a76880 100644
--- a/fpdfsdk/formfiller/cffl_checkbox.h
+++ b/fpdfsdk/formfiller/cffl_checkbox.h
@@ -23,11 +23,13 @@
       const CPWL_Wnd::CreateParams& cp,
       std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData)
       override;
-  bool OnKeyDown(FWL_VKEYCODE nKeyCode, uint32_t nFlags) override;
-  bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override;
+  bool OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlags) override;
+  bool OnChar(CPDFSDK_Annot* pAnnot,
+              uint32_t nChar,
+              FWL_EventFlagMask nFlags) override;
   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                    CPDFSDK_Annot* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask 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 412f1a1..f1bff27 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,
-                           uint32_t nFlags) {
+                           FWL_EventFlagMask nFlags) {
   return CFFL_TextObject::OnChar(pAnnot, nChar, nFlags);
 }
 
diff --git a/fpdfsdk/formfiller/cffl_combobox.h b/fpdfsdk/formfiller/cffl_combobox.h
index 5ef3ff6..364ff06 100644
--- a/fpdfsdk/formfiller/cffl_combobox.h
+++ b/fpdfsdk/formfiller/cffl_combobox.h
@@ -33,7 +33,9 @@
       const CPWL_Wnd::CreateParams& cp,
       std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData)
       override;
-  bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override;
+  bool OnChar(CPDFSDK_Annot* pAnnot,
+              uint32_t nChar,
+              FWL_EventFlagMask 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 44c3388..586b43f 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,
-                                   uint32_t nFlags,
+                                   FWL_EventFlagMask 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,
-                                 uint32_t nFlags,
+                                 FWL_EventFlagMask nFlags,
                                  const CFX_PointF& point) {
   CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
   if (!pWnd)
@@ -116,7 +116,7 @@
 }
 
 bool CFFL_FormField::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
-                                     uint32_t nFlags,
+                                     FWL_EventFlagMask nFlags,
                                      const CFX_PointF& point) {
   CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
   if (!pWnd)
@@ -127,7 +127,7 @@
 }
 
 bool CFFL_FormField::OnMouseMove(CPDFSDK_PageView* pPageView,
-                                 uint32_t nFlags,
+                                 FWL_EventFlagMask nFlags,
                                  const CFX_PointF& point) {
   CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
   if (!pWnd)
@@ -138,7 +138,7 @@
 }
 
 bool CFFL_FormField::OnMouseWheel(CPDFSDK_PageView* pPageView,
-                                  uint32_t nFlags,
+                                  FWL_EventFlagMask nFlags,
                                   const CFX_PointF& point,
                                   const CFX_Vector& delta) {
   if (!IsValid())
@@ -149,20 +149,21 @@
 }
 
 bool CFFL_FormField::OnRButtonDown(CPDFSDK_PageView* pPageView,
-                                   uint32_t nFlags,
+                                   FWL_EventFlagMask nFlags,
                                    const CFX_PointF& point) {
   CPWL_Wnd* pWnd = CreateOrUpdatePWLWindow(pPageView);
   return pWnd && pWnd->OnRButtonDown(nFlags, FFLtoPWL(point));
 }
 
 bool CFFL_FormField::OnRButtonUp(CPDFSDK_PageView* pPageView,
-                                 uint32_t nFlags,
+                                 FWL_EventFlagMask nFlags,
                                  const CFX_PointF& point) {
   CPWL_Wnd* pWnd = GetPWLWindow(pPageView);
   return pWnd && pWnd->OnRButtonUp(nFlags, FFLtoPWL(point));
 }
 
-bool CFFL_FormField::OnKeyDown(FWL_VKEYCODE nKeyCode, uint32_t nFlags) {
+bool CFFL_FormField::OnKeyDown(FWL_VKEYCODE nKeyCode,
+                               FWL_EventFlagMask nFlags) {
   if (!IsValid())
     return false;
 
@@ -172,7 +173,7 @@
 
 bool CFFL_FormField::OnChar(CPDFSDK_Annot* pAnnot,
                             uint32_t nChar,
-                            uint32_t nFlags) {
+                            FWL_EventFlagMask nFlags) {
   if (!IsValid())
     return false;
 
@@ -255,7 +256,8 @@
   return pWnd && pWnd->Redo();
 }
 
-void CFFL_FormField::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) {
+void CFFL_FormField::SetFocusForAnnot(CPDFSDK_Annot* pAnnot,
+                                      FWL_EventFlagMask nFlag) {
   CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
   IPDF_Page* pPage = pWidget->GetPage();
   CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetOrCreatePageView(pPage);
@@ -267,7 +269,7 @@
   InvalidateRect(GetViewBBox(pPageView));
 }
 
-void CFFL_FormField::KillFocusForAnnot(uint32_t nFlag) {
+void CFFL_FormField::KillFocusForAnnot(FWL_EventFlagMask nFlag) {
   if (!IsValid())
     return;
 
@@ -461,7 +463,7 @@
 }
 
 bool CFFL_FormField::CommitData(const CPDFSDK_PageView* pPageView,
-                                uint32_t nFlag) {
+                                FWL_EventFlagMask nFlag) {
   if (!IsDataChanged(pPageView))
     return true;
 
diff --git a/fpdfsdk/formfiller/cffl_formfield.h b/fpdfsdk/formfiller/cffl_formfield.h
index cd6e0f2..a7057f7 100644
--- a/fpdfsdk/formfiller/cffl_formfield.h
+++ b/fpdfsdk/formfiller/cffl_formfield.h
@@ -43,31 +43,33 @@
 
   virtual bool OnLButtonDown(CPDFSDK_PageView* pPageView,
                              CPDFSDK_Annot* pAnnot,
-                             uint32_t nFlags,
+                             FWL_EventFlagMask nFlags,
                              const CFX_PointF& point);
   virtual bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                            CPDFSDK_Annot* pAnnot,
-                           uint32_t nFlags,
+                           FWL_EventFlagMask nFlags,
                            const CFX_PointF& point);
   virtual bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
-                               uint32_t nFlags,
+                               FWL_EventFlagMask nFlags,
                                const CFX_PointF& point);
   virtual bool OnMouseMove(CPDFSDK_PageView* pPageView,
-                           uint32_t nFlags,
+                           FWL_EventFlagMask nFlags,
                            const CFX_PointF& point);
   virtual bool OnMouseWheel(CPDFSDK_PageView* pPageView,
-                            uint32_t nFlags,
+                            FWL_EventFlagMask nFlags,
                             const CFX_PointF& point,
                             const CFX_Vector& delta);
   virtual bool OnRButtonDown(CPDFSDK_PageView* pPageView,
-                             uint32_t nFlags,
+                             FWL_EventFlagMask nFlags,
                              const CFX_PointF& point);
   virtual bool OnRButtonUp(CPDFSDK_PageView* pPageView,
-                           uint32_t nFlags,
+                           FWL_EventFlagMask nFlags,
                            const CFX_PointF& point);
 
-  virtual bool OnKeyDown(FWL_VKEYCODE nKeyCode, uint32_t nFlags);
-  virtual bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags);
+  virtual bool OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlags);
+  virtual bool OnChar(CPDFSDK_Annot* pAnnot,
+                      uint32_t nChar,
+                      FWL_EventFlagMask nFlags);
   virtual bool SetIndexSelected(int index, bool selected);
   virtual bool IsIndexSelected(int index);
 
@@ -83,8 +85,8 @@
   bool Undo();
   bool Redo();
 
-  void SetFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag);
-  void KillFocusForAnnot(uint32_t nFlag);
+  void SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FWL_EventFlagMask nFlag);
+  void KillFocusForAnnot(FWL_EventFlagMask nFlag);
 
   // CFX_Timer::CallbackIface:
   void OnTimerFired() override;
@@ -118,7 +120,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, uint32_t nFlag);
+  bool CommitData(const CPDFSDK_PageView* pPageView, FWL_EventFlagMask 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 711c16e..cd93e7b 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,
-    uint32_t nFlag) {
+    FWL_EventFlagMask 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,
-                                             uint32_t nFlag) {
+                                             FWL_EventFlagMask 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,
-    uint32_t nFlags,
+    FWL_EventFlagMask 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,
-                                             uint32_t nFlags,
+                                             FWL_EventFlagMask 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,
-                                            uint32_t nFlag) {
+                                            FWL_EventFlagMask nFlag) {
   if (m_bNotifying)
     return false;
 
@@ -299,7 +299,7 @@
 bool CFFL_InteractiveFormFiller::OnLButtonDblClk(
     CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-    uint32_t nFlags,
+    FWL_EventFlagMask 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,
-                                             uint32_t nFlags,
+                                             FWL_EventFlagMask 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,
-    uint32_t nFlags,
+    FWL_EventFlagMask 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,
-    uint32_t nFlags,
+    FWL_EventFlagMask 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,
-                                             uint32_t nFlags,
+                                             FWL_EventFlagMask 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,
-                                           uint32_t nFlags) {
+                                           FWL_EventFlagMask 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,
-                                        uint32_t nFlags) {
+                                        FWL_EventFlagMask 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,
-                                            uint32_t nFlag) {
+                                            FWL_EventFlagMask nFlag) {
   if (!pAnnot->HasObservable())
     return false;
 
@@ -417,7 +417,7 @@
 }
 
 bool CFFL_InteractiveFormFiller::OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                             uint32_t nFlag) {
+                                             FWL_EventFlagMask nFlag) {
   if (!pAnnot->HasObservable())
     return false;
 
@@ -646,7 +646,7 @@
 bool CFFL_InteractiveFormFiller::OnKeyStrokeCommit(
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
     const CPDFSDK_PageView* pPageView,
-    uint32_t nFlag) {
+    FWL_EventFlagMask nFlag) {
   if (m_bNotifying)
     return true;
 
@@ -678,7 +678,7 @@
 
 bool CFFL_InteractiveFormFiller::OnValidate(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                             const CPDFSDK_PageView* pPageView,
-                                            uint32_t nFlag) {
+                                            FWL_EventFlagMask nFlag) {
   if (m_bNotifying)
     return true;
 
@@ -709,7 +709,7 @@
 
 void CFFL_InteractiveFormFiller::OnCalculate(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                              const CPDFSDK_PageView* pPageView,
-                                             uint32_t nFlag) {
+                                             FWL_EventFlagMask nFlag) {
   if (m_bNotifying)
     return;
 
@@ -724,7 +724,7 @@
 
 void CFFL_InteractiveFormFiller::OnFormat(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                           const CPDFSDK_PageView* pPageView,
-                                          uint32_t nFlag) {
+                                          FWL_EventFlagMask 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,
-                                         uint32_t nFlag) {
+                                         FWL_EventFlagMask nFlag) {
   if (m_bNotifying)
     return false;
 
@@ -779,7 +779,7 @@
 
 bool CFFL_InteractiveFormFiller::OnFull(ObservedPtr<CPDFSDK_Widget>* pAnnot,
                                         const CPDFSDK_PageView* pPageView,
-                                        uint32_t nFlag) {
+                                        FWL_EventFlagMask nFlag) {
   if (m_bNotifying)
     return false;
 
@@ -810,7 +810,7 @@
 
 bool CFFL_InteractiveFormFiller::OnPreOpen(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                            const CPDFSDK_PageView* pPageView,
-                                           uint32_t nFlag) {
+                                           FWL_EventFlagMask nFlag) {
   if (m_bNotifying)
     return false;
 
@@ -841,7 +841,7 @@
 
 bool CFFL_InteractiveFormFiller::OnPostOpen(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                             const CPDFSDK_PageView* pPageView,
-                                            uint32_t nFlag) {
+                                            FWL_EventFlagMask nFlag) {
   if (m_bNotifying)
     return false;
 
@@ -885,7 +885,7 @@
     int nSelStart,
     int nSelEnd,
     bool bKeyDown,
-    uint32_t nFlag) {
+    FWL_EventFlagMask 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,
-    uint32_t nFlag) {
+    FWL_EventFlagMask 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,
-    uint32_t nFlag) {
+    FWL_EventFlagMask 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 8934d87..ae9f7a6 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.h
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.h
@@ -42,45 +42,47 @@
 
   void OnMouseEnter(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    uint32_t nFlag);
+                    FWL_EventFlagMask nFlag);
   void OnMouseExit(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlag);
+                   FWL_EventFlagMask nFlag);
   bool OnLButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     uint32_t nFlags,
+                     FWL_EventFlagMask nFlags,
                      const CFX_PointF& point);
   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask nFlags,
                    const CFX_PointF& point);
   bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                       uint32_t nFlags,
+                       FWL_EventFlagMask nFlags,
                        const CFX_PointF& point);
   bool OnMouseMove(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask nFlags,
                    const CFX_PointF& point);
   bool OnMouseWheel(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    uint32_t nFlags,
+                    FWL_EventFlagMask nFlags,
                     const CFX_PointF& point,
                     const CFX_Vector& delta);
   bool OnRButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     uint32_t nFlags,
+                     FWL_EventFlagMask nFlags,
                      const CFX_PointF& point);
   bool OnRButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask nFlags,
                    const CFX_PointF& point);
 
-  bool OnKeyDown(CPDFSDK_Annot* pAnnot, FWL_VKEYCODE nKeyCode, uint32_t nFlags);
-  bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags);
+  bool OnKeyDown(CPDFSDK_Annot* pAnnot,
+                 FWL_VKEYCODE nKeyCode,
+                 FWL_EventFlagMask nFlags);
+  bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, FWL_EventFlagMask nFlags);
 
-  bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag);
-  bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag);
+  bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, FWL_EventFlagMask nFlag);
+  bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, FWL_EventFlagMask nFlag);
 
   CFFL_FormField* GetFormFieldForTesting(CPDFSDK_Annot* pAnnot) {
     return GetFormField(pAnnot);
@@ -103,19 +105,19 @@
 
   bool OnKeyStrokeCommit(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                          const CPDFSDK_PageView* pPageView,
-                         uint32_t nFlag);
+                         FWL_EventFlagMask nFlag);
   bool OnValidate(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                   const CPDFSDK_PageView* pPageView,
-                  uint32_t nFlag);
+                  FWL_EventFlagMask nFlag);
   void OnCalculate(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                    const CPDFSDK_PageView* pPageView,
-                   uint32_t nFlag);
+                   FWL_EventFlagMask nFlag);
   void OnFormat(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                 const CPDFSDK_PageView* pPageView,
-                uint32_t nFlag);
+                FWL_EventFlagMask nFlag);
   bool OnButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                   const CPDFSDK_PageView* pPageView,
-                  uint32_t nFlag);
+                  FWL_EventFlagMask nFlag);
 
   bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                         int index,
@@ -140,26 +142,26 @@
       int nSelStart,
       int nSelEnd,
       bool bKeyDown,
-      uint32_t nFlag) override;
+      FWL_EventFlagMask nFlag) override;
   bool OnPopupPreOpen(const IPWL_SystemHandler::PerWindowData* pAttached,
-                      uint32_t nFlag) override;
+                      FWL_EventFlagMask nFlag) override;
   bool OnPopupPostOpen(const IPWL_SystemHandler::PerWindowData* pAttached,
-                       uint32_t nFlag) override;
+                       FWL_EventFlagMask 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,
-               uint32_t nFlag);
+               FWL_EventFlagMask nFlag);
   bool OnFull(ObservedPtr<CPDFSDK_Widget>* pAnnot,
               const CPDFSDK_PageView* pPageView,
-              uint32_t nFlag);
+              FWL_EventFlagMask nFlag);
   bool OnPreOpen(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                  const CPDFSDK_PageView* pPageView,
-                 uint32_t nFlag);
+                 FWL_EventFlagMask nFlag);
   bool OnPostOpen(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                   const CPDFSDK_PageView* pPageView,
-                  uint32_t nFlag);
+                  FWL_EventFlagMask 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 578c255..cc3143e 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,
-                          uint32_t nFlags) {
+                          FWL_EventFlagMask nFlags) {
   return CFFL_TextObject::OnChar(pAnnot, nChar, nFlags);
 }
 
diff --git a/fpdfsdk/formfiller/cffl_listbox.h b/fpdfsdk/formfiller/cffl_listbox.h
index 2dbba24..ff0b511 100644
--- a/fpdfsdk/formfiller/cffl_listbox.h
+++ b/fpdfsdk/formfiller/cffl_listbox.h
@@ -26,7 +26,9 @@
       const CPWL_Wnd::CreateParams& cp,
       std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData)
       override;
-  bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override;
+  bool OnChar(CPDFSDK_Annot* pAnnot,
+              uint32_t nChar,
+              FWL_EventFlagMask 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 d31d7d2..4f73945 100644
--- a/fpdfsdk/formfiller/cffl_radiobutton.cpp
+++ b/fpdfsdk/formfiller/cffl_radiobutton.cpp
@@ -32,7 +32,8 @@
   return std::move(pWnd);
 }
 
-bool CFFL_RadioButton::OnKeyDown(FWL_VKEYCODE nKeyCode, uint32_t nFlags) {
+bool CFFL_RadioButton::OnKeyDown(FWL_VKEYCODE nKeyCode,
+                                 FWL_EventFlagMask nFlags) {
   switch (nKeyCode) {
     case FWL_VKEY_Return:
     case FWL_VKEY_Space:
@@ -44,7 +45,7 @@
 
 bool CFFL_RadioButton::OnChar(CPDFSDK_Annot* pAnnot,
                               uint32_t nChar,
-                              uint32_t nFlags) {
+                              FWL_EventFlagMask nFlags) {
   switch (nChar) {
     case pdfium::ascii::kReturn:
     case pdfium::ascii::kSpace: {
@@ -71,7 +72,7 @@
 
 bool CFFL_RadioButton::OnLButtonUp(CPDFSDK_PageView* pPageView,
                                    CPDFSDK_Annot* pAnnot,
-                                   uint32_t nFlags,
+                                   FWL_EventFlagMask 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 ae5e86d..ea75ebc 100644
--- a/fpdfsdk/formfiller/cffl_radiobutton.h
+++ b/fpdfsdk/formfiller/cffl_radiobutton.h
@@ -23,11 +23,13 @@
       const CPWL_Wnd::CreateParams& cp,
       std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData)
       override;
-  bool OnKeyDown(FWL_VKEYCODE nKeyCode, uint32_t nFlags) override;
-  bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override;
+  bool OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlags) override;
+  bool OnChar(CPDFSDK_Annot* pAnnot,
+              uint32_t nChar,
+              FWL_EventFlagMask nFlags) override;
   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                    CPDFSDK_Annot* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask 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 ba6a8d8..c175050 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,
-                            uint32_t nFlags) {
+                            FWL_EventFlagMask 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 5d845be..b48ae1c 100644
--- a/fpdfsdk/formfiller/cffl_textfield.h
+++ b/fpdfsdk/formfiller/cffl_textfield.h
@@ -31,7 +31,9 @@
       const CPWL_Wnd::CreateParams& cp,
       std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData)
       override;
-  bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override;
+  bool OnChar(CPDFSDK_Annot* pAnnot,
+              uint32_t nChar,
+              FWL_EventFlagMask 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 5871721..71ea438 100644
--- a/fpdfsdk/fpdf_formfill.cpp
+++ b/fpdfsdk/fpdf_formfill.cpp
@@ -373,9 +373,9 @@
                                                      double page_x,
                                                      double page_y) {
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
-  if (!pPageView)
-    return false;
-  return pPageView->OnMouseMove(modifier, CFX_PointF(page_x, page_y));
+  return pPageView &&
+         pPageView->OnMouseMove(static_cast<FWL_EventFlagMask>(modifier),
+                                CFX_PointF(page_x, page_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
@@ -385,10 +385,13 @@
                   const FS_POINTF* page_coord,
                   int delta_x,
                   int delta_y) {
-  CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
-  if (!pPageView || !page_coord)
+  if (!page_coord)
     return false;
-  return pPageView->OnMouseWheel(modifier, CFXPointFFromFSPointF(*page_coord),
+
+  CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
+  return pPageView &&
+         pPageView->OnMouseWheel(static_cast<FWL_EventFlagMask>(modifier),
+                                 CFXPointFFromFSPointF(*page_coord),
                                  CFX_Vector(delta_x, delta_y));
 }
 
@@ -398,9 +401,9 @@
                                                  double page_x,
                                                  double page_y) {
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
-  if (!pPageView)
-    return false;
-  return pPageView->OnFocus(modifier, CFX_PointF(page_x, page_y));
+  return pPageView &&
+         pPageView->OnFocus(static_cast<FWL_EventFlagMask>(modifier),
+                            CFX_PointF(page_x, page_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle,
@@ -408,14 +411,14 @@
                                                        int modifier,
                                                        double page_x,
                                                        double page_y) {
-  CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
-  if (!pPageView)
-    return false;
 #ifdef PDF_ENABLE_CLICK_LOGGING
   fprintf(stderr, "mousedown,left,%d,%d\n", static_cast<int>(round(page_x)),
           static_cast<int>(round(page_y)));
 #endif  // PDF_ENABLE_CLICK_LOGGING
-  return pPageView->OnLButtonDown(modifier, CFX_PointF(page_x, page_y));
+  CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
+  return pPageView &&
+         pPageView->OnLButtonDown(static_cast<FWL_EventFlagMask>(modifier),
+                                  CFX_PointF(page_x, page_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle,
@@ -423,14 +426,14 @@
                                                      int modifier,
                                                      double page_x,
                                                      double page_y) {
-  CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
-  if (!pPageView)
-    return false;
 #ifdef PDF_ENABLE_CLICK_LOGGING
   fprintf(stderr, "mouseup,left,%d,%d\n", static_cast<int>(round(page_x)),
           static_cast<int>(round(page_y)));
 #endif  // PDF_ENABLE_CLICK_LOGGING
-  return pPageView->OnLButtonUp(modifier, CFX_PointF(page_x, page_y));
+  CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
+  return pPageView &&
+         pPageView->OnLButtonUp(static_cast<FWL_EventFlagMask>(modifier),
+                                CFX_PointF(page_x, page_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
@@ -439,14 +442,14 @@
                           int modifier,
                           double page_x,
                           double page_y) {
-  CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
-  if (!pPageView)
-    return false;
 #ifdef PDF_ENABLE_CLICK_LOGGING
   fprintf(stderr, "mousedown,doubleleft,%d,%d\n",
           static_cast<int>(round(page_x)), static_cast<int>(round(page_y)));
 #endif  // PDF_ENABLE_CLICK_LOGGING
-  return pPageView->OnLButtonDblClk(modifier, CFX_PointF(page_x, page_y));
+  CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
+  return pPageView &&
+         pPageView->OnLButtonDblClk(static_cast<FWL_EventFlagMask>(modifier),
+                                    CFX_PointF(page_x, page_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle,
@@ -454,14 +457,14 @@
                                                        int modifier,
                                                        double page_x,
                                                        double page_y) {
-  CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
-  if (!pPageView)
-    return false;
 #ifdef PDF_ENABLE_CLICK_LOGGING
   fprintf(stderr, "mousedown,right,%d,%d\n", static_cast<int>(round(page_x)),
           static_cast<int>(round(page_y)));
 #endif  // PDF_ENABLE_CLICK_LOGGING
-  return pPageView->OnRButtonDown(modifier, CFX_PointF(page_x, page_y));
+  CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
+  return pPageView &&
+         pPageView->OnRButtonDown(static_cast<FWL_EventFlagMask>(modifier),
+                                  CFX_PointF(page_x, page_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle,
@@ -469,14 +472,14 @@
                                                      int modifier,
                                                      double page_x,
                                                      double page_y) {
-  CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
-  if (!pPageView)
-    return false;
 #ifdef PDF_ENABLE_CLICK_LOGGING
   fprintf(stderr, "mouseup,right,%d,%d\n", static_cast<int>(round(page_x)),
           static_cast<int>(round(page_y)));
 #endif  // PDF_ENABLE_CLICK_LOGGING
-  return pPageView->OnRButtonUp(modifier, CFX_PointF(page_x, page_y));
+  CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
+  return pPageView &&
+         pPageView->OnRButtonUp(static_cast<FWL_EventFlagMask>(modifier),
+                                CFX_PointF(page_x, page_y));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnKeyDown(FPDF_FORMHANDLE hHandle,
@@ -484,9 +487,9 @@
                                                    int nKeyCode,
                                                    int modifier) {
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
-  if (!pPageView)
-    return false;
-  return pPageView->OnKeyDown(static_cast<FWL_VKEYCODE>(nKeyCode), modifier);
+  return pPageView &&
+         pPageView->OnKeyDown(static_cast<FWL_VKEYCODE>(nKeyCode),
+                              static_cast<FWL_EventFlagMask>(modifier));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnKeyUp(FPDF_FORMHANDLE hHandle,
@@ -494,9 +497,9 @@
                                                  int nKeyCode,
                                                  int modifier) {
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
-  if (!pPageView)
-    return false;
-  return pPageView->OnKeyUp(static_cast<FWL_VKEYCODE>(nKeyCode), modifier);
+  return pPageView &&
+         pPageView->OnKeyUp(static_cast<FWL_VKEYCODE>(nKeyCode),
+                            static_cast<FWL_EventFlagMask>(modifier));
 }
 
 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnChar(FPDF_FORMHANDLE hHandle,
@@ -504,9 +507,8 @@
                                                 int nChar,
                                                 int modifier) {
   CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
-  if (!pPageView)
-    return false;
-  return pPageView->OnChar(nChar, modifier);
+  return pPageView &&
+         pPageView->OnChar(nChar, static_cast<FWL_EventFlagMask>(modifier));
 }
 
 FPDF_EXPORT unsigned long FPDF_CALLCONV
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
index b7bfc3d..27ef26a 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,
-                                         uint32_t nFlag) {
+                                         FWL_EventFlagMask nFlag) {
   if (!pPageView)
     return;
 
@@ -386,7 +386,7 @@
 
 void CPDFXFA_WidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        uint32_t nFlag) {
+                                        FWL_EventFlagMask nFlag) {
   if (!pPageView)
     return;
 
@@ -400,7 +400,7 @@
 
 bool CPDFXFA_WidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
                                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                          uint32_t nFlags,
+                                          FWL_EventFlagMask nFlags,
                                           const CFX_PointF& point) {
   if (!pPageView)
     return false;
@@ -411,12 +411,12 @@
 
   CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(pXFAWidget);
   return pWidgetHandler->OnLButtonDown(pXFAWidget->GetXFAFFWidget(),
-                                       GetFWLFlags(nFlags), point);
+                                       GetKeyFlags(nFlags), point);
 }
 
 bool CPDFXFA_WidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        uint32_t nFlags,
+                                        FWL_EventFlagMask nFlags,
                                         const CFX_PointF& point) {
   if (!pPageView)
     return false;
@@ -427,12 +427,12 @@
 
   CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(pXFAWidget);
   return pWidgetHandler->OnLButtonUp(pXFAWidget->GetXFAFFWidget(),
-                                     GetFWLFlags(nFlags), point);
+                                     GetKeyFlags(nFlags), point);
 }
 
 bool CPDFXFA_WidgetHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                            uint32_t nFlags,
+                                            FWL_EventFlagMask nFlags,
                                             const CFX_PointF& point) {
   if (!pPageView)
     return false;
@@ -443,12 +443,12 @@
 
   CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(pXFAWidget);
   return pWidgetHandler->OnLButtonDblClk(pXFAWidget->GetXFAFFWidget(),
-                                         GetFWLFlags(nFlags), point);
+                                         GetKeyFlags(nFlags), point);
 }
 
 bool CPDFXFA_WidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        uint32_t nFlags,
+                                        FWL_EventFlagMask nFlags,
                                         const CFX_PointF& point) {
   if (!pPageView)
     return false;
@@ -459,12 +459,12 @@
 
   CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(pXFAWidget);
   return pWidgetHandler->OnMouseMove(pXFAWidget->GetXFAFFWidget(),
-                                     GetFWLFlags(nFlags), point);
+                                     GetKeyFlags(nFlags), point);
 }
 
 bool CPDFXFA_WidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                         uint32_t nFlags,
+                                         FWL_EventFlagMask nFlags,
                                          const CFX_PointF& point,
                                          const CFX_Vector& delta) {
   if (!pPageView)
@@ -476,12 +476,12 @@
 
   CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(pXFAWidget);
   return pWidgetHandler->OnMouseWheel(pXFAWidget->GetXFAFFWidget(),
-                                      GetFWLFlags(nFlags), point, delta);
+                                      GetKeyFlags(nFlags), point, delta);
 }
 
 bool CPDFXFA_WidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
                                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                          uint32_t nFlags,
+                                          FWL_EventFlagMask nFlags,
                                           const CFX_PointF& point) {
   if (!pPageView)
     return false;
@@ -492,12 +492,12 @@
 
   CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(pXFAWidget);
   return pWidgetHandler->OnRButtonDown(pXFAWidget->GetXFAFFWidget(),
-                                       GetFWLFlags(nFlags), point);
+                                       GetKeyFlags(nFlags), point);
 }
 
 bool CPDFXFA_WidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        uint32_t nFlags,
+                                        FWL_EventFlagMask nFlags,
                                         const CFX_PointF& point) {
   if (!pPageView)
     return false;
@@ -508,12 +508,12 @@
 
   CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(pXFAWidget);
   return pWidgetHandler->OnRButtonUp(pXFAWidget->GetXFAFFWidget(),
-                                     GetFWLFlags(nFlags), point);
+                                     GetKeyFlags(nFlags), point);
 }
 
 bool CPDFXFA_WidgetHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView,
                                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                            uint32_t nFlags,
+                                            FWL_EventFlagMask nFlags,
                                             const CFX_PointF& point) {
   if (!pPageView)
     return false;
@@ -524,24 +524,24 @@
 
   CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(pXFAWidget);
   return pWidgetHandler->OnRButtonDblClk(pXFAWidget->GetXFAFFWidget(),
-                                         GetFWLFlags(nFlags), point);
+                                         GetKeyFlags(nFlags), point);
 }
 
 bool CPDFXFA_WidgetHandler::OnChar(CPDFSDK_Annot* pAnnot,
                                    uint32_t nChar,
-                                   uint32_t nFlags) {
+                                   FWL_EventFlagMask nFlags) {
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot);
   if (!pXFAWidget)
     return false;
 
   CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(pXFAWidget);
   return pWidgetHandler->OnChar(pXFAWidget->GetXFAFFWidget(), nChar,
-                                GetFWLFlags(nFlags));
+                                GetKeyFlags(nFlags));
 }
 
 bool CPDFXFA_WidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
                                       FWL_VKEYCODE nKeyCode,
-                                      int nFlag) {
+                                      FWL_EventFlagMask nFlag) {
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot);
   if (!pXFAWidget)
     return false;
@@ -549,12 +549,12 @@
   CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(pXFAWidget);
   return pWidgetHandler->OnKeyDown(pXFAWidget->GetXFAFFWidget(),
                                    static_cast<XFA_FWL_VKEYCODE>(nKeyCode),
-                                   GetFWLFlags(nFlag));
+                                   GetKeyFlags(nFlag));
 }
 
 bool CPDFXFA_WidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
                                     FWL_VKEYCODE nKeyCode,
-                                    int nFlag) {
+                                    FWL_EventFlagMask nFlag) {
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot);
   if (!pXFAWidget)
     return false;
@@ -562,16 +562,16 @@
   CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler(pXFAWidget);
   return pWidgetHandler->OnKeyUp(pXFAWidget->GetXFAFFWidget(),
                                  static_cast<XFA_FWL_VKEYCODE>(nKeyCode),
-                                 GetFWLFlags(nFlag));
+                                 GetKeyFlags(nFlag));
 }
 
 bool CPDFXFA_WidgetHandler::OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                       uint32_t nFlag) {
+                                       FWL_EventFlagMask nFlag) {
   return true;
 }
 
 bool CPDFXFA_WidgetHandler::OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                                        uint32_t nFlag) {
+                                        FWL_EventFlagMask nFlag) {
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot->Get());
   if (!pXFAWidget)
     return true;
@@ -650,7 +650,7 @@
   return pDocView->GetWidgetHandler();
 }
 
-FWL_KeyFlagMask CPDFXFA_WidgetHandler::GetFWLFlags(uint32_t dwFlag) {
+FWL_KeyFlagMask CPDFXFA_WidgetHandler::GetKeyFlags(FWL_EventFlagMask dwFlag) {
   FWL_KeyFlagMask dwFWLFlag = 0;
 
   if (dwFlag & FWL_EVENTFLAG_ControlKey)
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
index cd0ed25..1693a71 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
@@ -57,52 +57,56 @@
   void OnLoad(CPDFSDK_Annot* pAnnot) override;
   void OnMouseEnter(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    uint32_t nFlag) override;
+                    FWL_EventFlagMask nFlag) override;
   void OnMouseExit(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlag) override;
+                   FWL_EventFlagMask nFlag) override;
   bool OnLButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     uint32_t nFlags,
+                     FWL_EventFlagMask nFlags,
                      const CFX_PointF& point) override;
   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask nFlags,
                    const CFX_PointF& point) override;
   bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                       uint32_t nFlags,
+                       FWL_EventFlagMask nFlags,
                        const CFX_PointF& point) override;
   bool OnMouseMove(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask nFlags,
                    const CFX_PointF& point) override;
   bool OnMouseWheel(CPDFSDK_PageView* pPageView,
                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                    uint32_t nFlags,
+                    FWL_EventFlagMask nFlags,
                     const CFX_PointF& point,
                     const CFX_Vector& delta) override;
   bool OnRButtonDown(CPDFSDK_PageView* pPageView,
                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                     uint32_t nFlags,
+                     FWL_EventFlagMask nFlags,
                      const CFX_PointF& point) override;
   bool OnRButtonUp(CPDFSDK_PageView* pPageView,
                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                   uint32_t nFlags,
+                   FWL_EventFlagMask nFlags,
                    const CFX_PointF& point) override;
   bool OnRButtonDblClk(CPDFSDK_PageView* pPageView,
                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                       uint32_t nFlags,
+                       FWL_EventFlagMask nFlags,
                        const CFX_PointF& point) override;
-  bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override;
+  bool OnChar(CPDFSDK_Annot* pAnnot,
+              uint32_t nChar,
+              FWL_EventFlagMask nFlags) override;
   bool OnKeyDown(CPDFSDK_Annot* pAnnot,
                  FWL_VKEYCODE nKeyCode,
-                 int nFlag) override;
+                 FWL_EventFlagMask nFlag) override;
   bool OnKeyUp(CPDFSDK_Annot* pAnnot,
                FWL_VKEYCODE nKeyCode,
-               int nFlag) override;
-  bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag) override;
-  bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag) override;
+               FWL_EventFlagMask nFlag) override;
+  bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
+                  FWL_EventFlagMask nFlag) override;
+  bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
+                   FWL_EventFlagMask nFlag) override;
   bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                         int index,
                         bool selected) override;
@@ -115,7 +119,7 @@
 
  private:
   CXFA_FFWidgetHandler* GetXFAFFWidgetHandler(CPDFSDK_Annot* pAnnot);
-  FWL_KeyFlagMask GetFWLFlags(uint32_t dwFlag);
+  FWL_KeyFlagMask GetKeyFlags(FWL_EventFlagMask dwFlag);
 
   UnownedPtr<CPDFSDK_FormFillEnvironment> m_pFormFillEnv;
 };
diff --git a/fpdfsdk/ipdfsdk_annothandler.h b/fpdfsdk/ipdfsdk_annothandler.h
index cd0c7c5..1d7ca16 100644
--- a/fpdfsdk/ipdfsdk_annothandler.h
+++ b/fpdfsdk/ipdfsdk_annothandler.h
@@ -11,6 +11,7 @@
 
 #include "core/fxcrt/fx_coordinates.h"
 #include "fpdfsdk/cpdfsdk_annot.h"
+#include "fpdfsdk/pwl/cpwl_wnd.h"
 #include "public/fpdf_fwlevent.h"
 
 class CFX_Matrix;
@@ -52,56 +53,56 @@
   virtual void OnLoad(CPDFSDK_Annot* pAnnot) = 0;
   virtual void OnMouseEnter(CPDFSDK_PageView* pPageView,
                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                            uint32_t nFlag) = 0;
+                            FWL_EventFlagMask nFlag) = 0;
   virtual void OnMouseExit(CPDFSDK_PageView* pPageView,
                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                           uint32_t nFlag) = 0;
+                           FWL_EventFlagMask nFlag) = 0;
   virtual bool OnLButtonDown(CPDFSDK_PageView* pPageView,
                              ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                             uint32_t nFlags,
+                             FWL_EventFlagMask nFlags,
                              const CFX_PointF& point) = 0;
   virtual bool OnLButtonUp(CPDFSDK_PageView* pPageView,
                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                           uint32_t nFlags,
+                           FWL_EventFlagMask nFlags,
                            const CFX_PointF& point) = 0;
   virtual bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
                                ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                               uint32_t nFlags,
+                               FWL_EventFlagMask nFlags,
                                const CFX_PointF& point) = 0;
   virtual bool OnMouseMove(CPDFSDK_PageView* pPageView,
                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                           uint32_t nFlags,
+                           FWL_EventFlagMask nFlags,
                            const CFX_PointF& point) = 0;
   virtual bool OnMouseWheel(CPDFSDK_PageView* pPageView,
                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                            uint32_t nFlags,
+                            FWL_EventFlagMask nFlags,
                             const CFX_PointF& point,
                             const CFX_Vector& delta) = 0;
   virtual bool OnRButtonDown(CPDFSDK_PageView* pPageView,
                              ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                             uint32_t nFlags,
+                             FWL_EventFlagMask nFlags,
                              const CFX_PointF& point) = 0;
   virtual bool OnRButtonUp(CPDFSDK_PageView* pPageView,
                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                           uint32_t nFlags,
+                           FWL_EventFlagMask nFlags,
                            const CFX_PointF& point) = 0;
   virtual bool OnRButtonDblClk(CPDFSDK_PageView* pPageView,
                                ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                               uint32_t nFlags,
+                               FWL_EventFlagMask nFlags,
                                const CFX_PointF& point) = 0;
   virtual bool OnChar(CPDFSDK_Annot* pAnnot,
                       uint32_t nChar,
-                      uint32_t nFlags) = 0;
+                      FWL_EventFlagMask nFlags) = 0;
   virtual bool OnKeyDown(CPDFSDK_Annot* pAnnot,
                          FWL_VKEYCODE nKeyCode,
-                         int nFlag) = 0;
+                         FWL_EventFlagMask nFlag) = 0;
   virtual bool OnKeyUp(CPDFSDK_Annot* pAnnot,
                        FWL_VKEYCODE nKeyCode,
-                       int nFlag) = 0;
+                       FWL_EventFlagMask nFlag) = 0;
   virtual bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                          uint32_t nFlag) = 0;
+                          FWL_EventFlagMask nFlag) = 0;
   virtual bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
-                           uint32_t nFlag) = 0;
+                           FWL_EventFlagMask 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 7b978bb..0657117 100644
--- a/fpdfsdk/pwl/cpwl_button.cpp
+++ b/fpdfsdk/pwl/cpwl_button.cpp
@@ -17,14 +17,16 @@
 
 CPWL_Button::~CPWL_Button() = default;
 
-bool CPWL_Button::OnLButtonDown(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_Button::OnLButtonDown(FWL_EventFlagMask nFlag,
+                                const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonDown(nFlag, point);
   m_bMouseDown = true;
   SetCapture();
   return true;
 }
 
-bool CPWL_Button::OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_Button::OnLButtonUp(FWL_EventFlagMask nFlag,
+                              const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonUp(nFlag, point);
   ReleaseCapture();
   m_bMouseDown = false;
diff --git a/fpdfsdk/pwl/cpwl_button.h b/fpdfsdk/pwl/cpwl_button.h
index 89187a1..c944576 100644
--- a/fpdfsdk/pwl/cpwl_button.h
+++ b/fpdfsdk/pwl/cpwl_button.h
@@ -19,8 +19,8 @@
   ~CPWL_Button() override;
 
   // CPWL_Wnd
-  bool OnLButtonDown(uint32_t nFlag, const CFX_PointF& point) override;
-  bool OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) override;
+  bool OnLButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
+  bool OnLButtonUp(FWL_EventFlagMask 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 bd72664..321fd85 100644
--- a/fpdfsdk/pwl/cpwl_cbbutton.cpp
+++ b/fpdfsdk/pwl/cpwl_cbbutton.cpp
@@ -58,7 +58,8 @@
                     CFX_FillRenderOptions::EvenOddOptions());
 }
 
-bool CPWL_CBButton::OnLButtonDown(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_CBButton::OnLButtonDown(FWL_EventFlagMask nFlag,
+                                  const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonDown(nFlag, point);
 
   SetCapture();
@@ -69,7 +70,8 @@
   return true;
 }
 
-bool CPWL_CBButton::OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_CBButton::OnLButtonUp(FWL_EventFlagMask nFlag,
+                                const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonUp(nFlag, point);
 
   ReleaseCapture();
diff --git a/fpdfsdk/pwl/cpwl_cbbutton.h b/fpdfsdk/pwl/cpwl_cbbutton.h
index ce36d7d..58dd54f 100644
--- a/fpdfsdk/pwl/cpwl_cbbutton.h
+++ b/fpdfsdk/pwl/cpwl_cbbutton.h
@@ -22,8 +22,8 @@
   // CPWL_Wnd:
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
                           const CFX_Matrix& mtUser2Device) override;
-  bool OnLButtonDown(uint32_t nFlag, const CFX_PointF& point) override;
-  bool OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) override;
+  bool OnLButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
+  bool OnLButtonUp(FWL_EventFlagMask 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 f49f36d..cf5b4e8 100644
--- a/fpdfsdk/pwl/cpwl_cblistbox.cpp
+++ b/fpdfsdk/pwl/cpwl_cblistbox.cpp
@@ -20,7 +20,8 @@
 
 CPWL_CBListBox::~CPWL_CBListBox() = default;
 
-bool CPWL_CBListBox::OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_CBListBox::OnLButtonUp(FWL_EventFlagMask nFlag,
+                                 const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonUp(nFlag, point);
 
   if (!m_bMouseDown)
@@ -51,7 +52,8 @@
   }
 }
 
-bool CPWL_CBListBox::OnMovementKeyDown(FWL_VKEYCODE nKeyCode, uint32_t nFlag) {
+bool CPWL_CBListBox::OnMovementKeyDown(FWL_VKEYCODE nKeyCode,
+                                       FWL_EventFlagMask nFlag) {
   switch (nKeyCode) {
     case FWL_VKEY_Up:
       m_pListCtrl->OnVK_UP(IsSHIFTKeyDown(nFlag), IsCTRLKeyDown(nFlag));
@@ -78,12 +80,12 @@
   return OnNotifySelectionChanged(true, nFlag);
 }
 
-bool CPWL_CBListBox::IsChar(uint16_t nChar, uint32_t nFlag) const {
+bool CPWL_CBListBox::IsChar(uint16_t nChar, FWL_EventFlagMask nFlag) const {
   return m_pListCtrl->OnChar(nChar, IsSHIFTKeyDown(nFlag),
                              IsCTRLKeyDown(nFlag));
 }
 
-bool CPWL_CBListBox::OnCharNotify(uint16_t nChar, uint32_t nFlag) {
+bool CPWL_CBListBox::OnCharNotify(uint16_t nChar, FWL_EventFlagMask 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 c38074d..40510b3 100644
--- a/fpdfsdk/pwl/cpwl_cblistbox.h
+++ b/fpdfsdk/pwl/cpwl_cblistbox.h
@@ -21,12 +21,12 @@
   ~CPWL_CBListBox() override;
 
   // CPWL_ListBox
-  bool OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) override;
+  bool OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
 
   bool IsMovementKey(FWL_VKEYCODE nKeyCode) const;
-  bool OnMovementKeyDown(FWL_VKEYCODE nKyeCode, uint32_t nFlag);
-  bool IsChar(uint16_t nChar, uint32_t nFlag) const;
-  bool OnCharNotify(uint16_t nChar, uint32_t nFlag);
+  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);
 };
 
 #endif  // FPDFSDK_PWL_CPWL_CBLISTBOX_H_
diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp
index 0376409..32dc9e2 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box.cpp
@@ -337,7 +337,7 @@
   return !!thisObserved;
 }
 
-bool CPWL_ComboBox::OnKeyDown(FWL_VKEYCODE nKeyCode, uint32_t nFlag) {
+bool CPWL_ComboBox::OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag) {
   if (!m_pList)
     return false;
   if (!m_pEdit)
@@ -386,7 +386,7 @@
   return false;
 }
 
-bool CPWL_ComboBox::OnChar(uint16_t nChar, uint32_t nFlag) {
+bool CPWL_ComboBox::OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) {
   if (!m_pList)
     return false;
 
diff --git a/fpdfsdk/pwl/cpwl_combo_box.h b/fpdfsdk/pwl/cpwl_combo_box.h
index 125b25f..b34a3ed 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, uint32_t nFlag) override;
-  bool OnChar(uint16_t nChar, uint32_t nFlag) override;
+  bool OnKeyDown(FWL_VKEYCODE nChar, FWL_EventFlagMask nFlag) override;
+  bool OnChar(uint16_t nChar, FWL_EventFlagMask 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_edit.cpp b/fpdfsdk/pwl/cpwl_edit.cpp
index 4cf30cd..c507363 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, uint32_t nFlag) {
+bool CPWL_Edit::OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag) {
   if (m_bMouseDown)
     return true;
 
@@ -378,7 +378,8 @@
 }
 
 // static
-bool CPWL_Edit::IsProceedtoOnChar(FWL_VKEYCODE nKeyCode, uint32_t nFlag) {
+bool CPWL_Edit::IsProceedtoOnChar(FWL_VKEYCODE nKeyCode,
+                                  FWL_EventFlagMask nFlag) {
   bool bCtrl = IsPlatformShortcutKey(nFlag);
   bool bAlt = IsALTKeyDown(nFlag);
   if (bCtrl && !bAlt) {
@@ -406,7 +407,7 @@
   }
 }
 
-bool CPWL_Edit::OnChar(uint16_t nChar, uint32_t nFlag) {
+bool CPWL_Edit::OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) {
   if (m_bMouseDown)
     return true;
 
@@ -462,7 +463,7 @@
   return OnCharInternal(nChar, nFlag);
 }
 
-bool CPWL_Edit::OnMouseWheel(uint32_t nFlag,
+bool CPWL_Edit::OnMouseWheel(FWL_EventFlagMask nFlag,
                              const CFX_PointF& point,
                              const CFX_Vector& delta) {
   if (!HasFlag(PES_MULTILINE))
@@ -552,7 +553,8 @@
   return m_pEditImpl->GetFontSize();
 }
 
-bool CPWL_Edit::OnKeyDownInternal(FWL_VKEYCODE nKeyCode, uint32_t nFlag) {
+bool CPWL_Edit::OnKeyDownInternal(FWL_VKEYCODE nKeyCode,
+                                  FWL_EventFlagMask nFlag) {
   if (m_bMouseDown)
     return true;
 
@@ -620,7 +622,7 @@
   return bRet;
 }
 
-bool CPWL_Edit::OnCharInternal(uint16_t nChar, uint32_t nFlag) {
+bool CPWL_Edit::OnCharInternal(uint16_t nChar, FWL_EventFlagMask nFlag) {
   if (m_bMouseDown)
     return true;
 
@@ -692,7 +694,8 @@
   return true;
 }
 
-bool CPWL_Edit::OnLButtonDown(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_Edit::OnLButtonDown(FWL_EventFlagMask nFlag,
+                              const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonDown(nFlag, point);
   if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) {
     if (m_bMouseDown && !InvalidateRect(nullptr))
@@ -706,7 +709,7 @@
   return true;
 }
 
-bool CPWL_Edit::OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_Edit::OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonUp(nFlag, point);
   if (m_bMouseDown) {
     // can receive keybord message
@@ -719,7 +722,8 @@
   return true;
 }
 
-bool CPWL_Edit::OnLButtonDblClk(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_Edit::OnLButtonDblClk(FWL_EventFlagMask nFlag,
+                                const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonDblClk(nFlag, point);
   if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point))
     m_pEditImpl->SelectAll();
@@ -727,7 +731,7 @@
   return true;
 }
 
-bool CPWL_Edit::OnRButtonUp(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_Edit::OnRButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) {
   if (m_bMouseDown)
     return false;
 
@@ -739,7 +743,7 @@
   return false;
 }
 
-bool CPWL_Edit::OnMouseMove(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_Edit::OnMouseMove(FWL_EventFlagMask 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 68e6cd0..e06dd06 100644
--- a/fpdfsdk/pwl/cpwl_edit.h
+++ b/fpdfsdk/pwl/cpwl_edit.h
@@ -37,21 +37,22 @@
   CFX_FloatRect GetClientRect() const override;
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
                           const CFX_Matrix& mtUser2Device) override;
-  bool OnMouseWheel(uint32_t nFlag,
+  bool OnMouseWheel(FWL_EventFlagMask nFlag,
                     const CFX_PointF& point,
                     const CFX_Vector& delta) override;
-  bool OnKeyDown(FWL_VKEYCODE nChar, uint32_t nFlag) override;
-  bool OnChar(uint16_t nChar, uint32_t nFlag) override;
+  bool OnKeyDown(FWL_VKEYCODE nChar, FWL_EventFlagMask nFlag) override;
+  bool OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) override;
   CFX_FloatRect GetFocusRect() const override;
   void OnSetFocus() override;
   void OnKillFocus() override;
   void OnCreated() override;
   void OnDestroy() override;
-  bool OnLButtonDown(uint32_t nFlag, const CFX_PointF& point) override;
-  bool OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) override;
-  bool OnLButtonDblClk(uint32_t nFlag, const CFX_PointF& point) override;
-  bool OnRButtonUp(uint32_t nFlag, const CFX_PointF& point) override;
-  bool OnMouseMove(uint32_t nFlag, const CFX_PointF& point) 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,
+                       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;
   void SetScrollInfo(const PWL_SCROLL_INFO& info) override;
   void SetScrollPosition(float pos) override;
   void ScrollWindowVertically(float pos) override;
@@ -107,10 +108,10 @@
   // 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, uint32_t nFlag);
+  static bool IsProceedtoOnChar(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag);
 
-  bool OnKeyDownInternal(FWL_VKEYCODE nKeyCode, uint32_t nFlag);
-  bool OnCharInternal(uint16_t nChar, uint32_t nFlag);
+  bool OnKeyDownInternal(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag);
+  bool OnCharInternal(uint16_t nChar, FWL_EventFlagMask nFlag);
 
   void CopyText();
   void PasteText();
diff --git a/fpdfsdk/pwl/cpwl_list_box.cpp b/fpdfsdk/pwl/cpwl_list_box.cpp
index c4b16a8..d91fddc 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, uint32_t nFlag) {
+bool CPWL_ListBox::OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag) {
   CPWL_Wnd::OnKeyDown(nKeyCode, nFlag);
 
   switch (nKeyCode) {
@@ -127,7 +127,7 @@
   return true;
 }
 
-bool CPWL_ListBox::OnChar(uint16_t nChar, uint32_t nFlag) {
+bool CPWL_ListBox::OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) {
   CPWL_Wnd::OnChar(nChar, nFlag);
 
   if (!m_pListCtrl->OnChar(nChar, IsSHIFTKeyDown(nFlag), IsCTRLKeyDown(nFlag)))
@@ -137,7 +137,8 @@
   return true;
 }
 
-bool CPWL_ListBox::OnLButtonDown(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_ListBox::OnLButtonDown(FWL_EventFlagMask nFlag,
+                                 const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonDown(nFlag, point);
 
   if (ClientHitTest(point)) {
@@ -152,7 +153,8 @@
   return true;
 }
 
-bool CPWL_ListBox::OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_ListBox::OnLButtonUp(FWL_EventFlagMask nFlag,
+                               const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonUp(nFlag, point);
 
   if (m_bMouseDown) {
@@ -167,7 +169,8 @@
   m_bHoverSel = bHoverSel;
 }
 
-bool CPWL_ListBox::OnMouseMove(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_ListBox::OnMouseMove(FWL_EventFlagMask nFlag,
+                               const CFX_PointF& point) {
   CPWL_Wnd::OnMouseMove(nFlag, point);
 
   if (m_bHoverSel && !IsCaptureMouse() && ClientHitTest(point))
@@ -201,7 +204,8 @@
   return true;
 }
 
-bool CPWL_ListBox::OnNotifySelectionChanged(bool bKeyDown, uint32_t nFlag) {
+bool CPWL_ListBox::OnNotifySelectionChanged(bool bKeyDown,
+                                            FWL_EventFlagMask nFlag) {
   if (!m_pFillerNotify)
     return false;
 
@@ -361,7 +365,7 @@
   return GetWindowRect().GetDeflated(width, width);
 }
 
-bool CPWL_ListBox::OnMouseWheel(uint32_t nFlag,
+bool CPWL_ListBox::OnMouseWheel(FWL_EventFlagMask 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 412bcf1..d7d300a 100644
--- a/fpdfsdk/pwl/cpwl_list_box.h
+++ b/fpdfsdk/pwl/cpwl_list_box.h
@@ -27,12 +27,12 @@
   void OnDestroy() override;
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
                           const CFX_Matrix& mtUser2Device) override;
-  bool OnKeyDown(FWL_VKEYCODE nKeyCode, uint32_t nFlag) override;
-  bool OnChar(uint16_t nChar, uint32_t nFlag) override;
-  bool OnLButtonDown(uint32_t nFlag, const CFX_PointF& point) override;
-  bool OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) override;
-  bool OnMouseMove(uint32_t nFlag, const CFX_PointF& point) override;
-  bool OnMouseWheel(uint32_t nFlag,
+  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,
                     const CFX_PointF& point,
                     const CFX_Vector& delta) override;
   WideString GetText() override;
@@ -54,7 +54,7 @@
   void OnSetScrollPosY(float fy) override;
   void OnInvalidateRect(const CFX_FloatRect& pRect) override;
 
-  bool OnNotifySelectionChanged(bool bKeyDown, uint32_t nFlag);
+  bool OnNotifySelectionChanged(bool bKeyDown, FWL_EventFlagMask 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 a75ac99..5b32791 100644
--- a/fpdfsdk/pwl/cpwl_sbbutton.cpp
+++ b/fpdfsdk/pwl/cpwl_sbbutton.cpp
@@ -113,7 +113,8 @@
   }
 }
 
-bool CPWL_SBButton::OnLButtonDown(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_SBButton::OnLButtonDown(FWL_EventFlagMask nFlag,
+                                  const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonDown(nFlag, point);
 
   if (CPWL_Wnd* pParent = GetParentWindow())
@@ -125,7 +126,8 @@
   return true;
 }
 
-bool CPWL_SBButton::OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_SBButton::OnLButtonUp(FWL_EventFlagMask nFlag,
+                                const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonUp(nFlag, point);
 
   if (CPWL_Wnd* pParent = GetParentWindow())
@@ -137,7 +139,8 @@
   return true;
 }
 
-bool CPWL_SBButton::OnMouseMove(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_SBButton::OnMouseMove(FWL_EventFlagMask nFlag,
+                                const CFX_PointF& point) {
   CPWL_Wnd::OnMouseMove(nFlag, point);
 
   if (CPWL_Wnd* pParent = GetParentWindow())
diff --git a/fpdfsdk/pwl/cpwl_sbbutton.h b/fpdfsdk/pwl/cpwl_sbbutton.h
index e97e28a..fdcd887 100644
--- a/fpdfsdk/pwl/cpwl_sbbutton.h
+++ b/fpdfsdk/pwl/cpwl_sbbutton.h
@@ -25,9 +25,9 @@
   // CPWL_Wnd
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
                           const CFX_Matrix& mtUser2Device) override;
-  bool OnLButtonDown(uint32_t nFlag, const CFX_PointF& point) override;
-  bool OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) override;
-  bool OnMouseMove(uint32_t nFlag, const CFX_PointF& point) 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;
 
  private:
   const Type m_eSBButtonType;
diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.cpp b/fpdfsdk/pwl/cpwl_scroll_bar.cpp
index 6f18180..f145294 100644
--- a/fpdfsdk/pwl/cpwl_scroll_bar.cpp
+++ b/fpdfsdk/pwl/cpwl_scroll_bar.cpp
@@ -184,7 +184,8 @@
   }
 }
 
-bool CPWL_ScrollBar::OnLButtonDown(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_ScrollBar::OnLButtonDown(FWL_EventFlagMask nFlag,
+                                   const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonDown(nFlag, point);
 
   if (HasFlag(PWS_AUTOTRANSPARENT)) {
@@ -226,7 +227,8 @@
   return true;
 }
 
-bool CPWL_ScrollBar::OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_ScrollBar::OnLButtonUp(FWL_EventFlagMask nFlag,
+                                 const CFX_PointF& point) {
   CPWL_Wnd::OnLButtonUp(nFlag, point);
 
   if (HasFlag(PWS_AUTOTRANSPARENT)) {
diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.h b/fpdfsdk/pwl/cpwl_scroll_bar.h
index 4e6df62..bb5472b 100644
--- a/fpdfsdk/pwl/cpwl_scroll_bar.h
+++ b/fpdfsdk/pwl/cpwl_scroll_bar.h
@@ -104,8 +104,8 @@
   bool RePosChildWnd() override;
   void DrawThisAppearance(CFX_RenderDevice* pDevice,
                           const CFX_Matrix& mtUser2Device) override;
-  bool OnLButtonDown(uint32_t nFlag, const CFX_PointF& point) override;
-  bool OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) override;
+  bool OnLButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
+  bool OnLButtonUp(FWL_EventFlagMask 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 215df40..fa9ad06 100644
--- a/fpdfsdk/pwl/cpwl_special_button.cpp
+++ b/fpdfsdk/pwl/cpwl_special_button.cpp
@@ -30,7 +30,8 @@
 
 CPWL_CheckBox::~CPWL_CheckBox() = default;
 
-bool CPWL_CheckBox::OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_CheckBox::OnLButtonUp(FWL_EventFlagMask nFlag,
+                                const CFX_PointF& point) {
   if (IsReadOnly())
     return false;
 
@@ -38,7 +39,7 @@
   return true;
 }
 
-bool CPWL_CheckBox::OnChar(uint16_t nChar, uint32_t nFlag) {
+bool CPWL_CheckBox::OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) {
   if (IsReadOnly())
     return false;
 
@@ -53,7 +54,8 @@
 
 CPWL_RadioButton::~CPWL_RadioButton() = default;
 
-bool CPWL_RadioButton::OnLButtonUp(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_RadioButton::OnLButtonUp(FWL_EventFlagMask nFlag,
+                                   const CFX_PointF& point) {
   if (IsReadOnly())
     return false;
 
@@ -61,7 +63,7 @@
   return true;
 }
 
-bool CPWL_RadioButton::OnChar(uint16_t nChar, uint32_t nFlag) {
+bool CPWL_RadioButton::OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) {
   if (IsReadOnly())
     return false;
 
diff --git a/fpdfsdk/pwl/cpwl_special_button.h b/fpdfsdk/pwl/cpwl_special_button.h
index ac3db7e..48fa5a5 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(uint32_t nFlag, const CFX_PointF& point) override;
-  bool OnChar(uint16_t nChar, uint32_t nFlag) override;
+  bool OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
+  bool OnChar(uint16_t nChar, FWL_EventFlagMask 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(uint32_t nFlag, const CFX_PointF& point) override;
-  bool OnChar(uint16_t nChar, uint32_t nFlag) override;
+  bool OnLButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) override;
+  bool OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) override;
 
   bool IsChecked() const { return m_bChecked; }
   void SetCheck(bool bCheck) { m_bChecked = bCheck; }
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp
index 0dd94e3..cc45a37 100644
--- a/fpdfsdk/pwl/cpwl_wnd.cpp
+++ b/fpdfsdk/pwl/cpwl_wnd.cpp
@@ -110,27 +110,27 @@
 };
 
 // static
-bool CPWL_Wnd::IsSHIFTKeyDown(uint32_t nFlag) {
+bool CPWL_Wnd::IsSHIFTKeyDown(FWL_EventFlagMask nFlag) {
   return !!(nFlag & FWL_EVENTFLAG_ShiftKey);
 }
 
 // static
-bool CPWL_Wnd::IsCTRLKeyDown(uint32_t nFlag) {
+bool CPWL_Wnd::IsCTRLKeyDown(FWL_EventFlagMask nFlag) {
   return !!(nFlag & FWL_EVENTFLAG_ControlKey);
 }
 
 // static
-bool CPWL_Wnd::IsALTKeyDown(uint32_t nFlag) {
+bool CPWL_Wnd::IsALTKeyDown(FWL_EventFlagMask nFlag) {
   return !!(nFlag & FWL_EVENTFLAG_AltKey);
 }
 
 // static
-bool CPWL_Wnd::IsMETAKeyDown(uint32_t nFlag) {
+bool CPWL_Wnd::IsMETAKeyDown(FWL_EventFlagMask nFlag) {
   return !!(nFlag & FWL_EVENTFLAG_MetaKey);
 }
 
 // static
-bool CPWL_Wnd::IsPlatformShortcutKey(uint32_t nFlag) {
+bool CPWL_Wnd::IsPlatformShortcutKey(FWL_EventFlagMask nFlag) {
 #if defined(OS_APPLE)
   return IsMETAKeyDown(nFlag);
 #else
@@ -287,7 +287,7 @@
   return !!thisObserved;
 }
 
-bool CPWL_Wnd::OnKeyDown(FWL_VKEYCODE nKeyCode, uint32_t nFlag) {
+bool CPWL_Wnd::OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag) {
   if (!IsValid() || !IsVisible())
     return false;
   if (!IsWndCaptureKeyboard(this))
@@ -299,7 +299,7 @@
   return false;
 }
 
-bool CPWL_Wnd::OnChar(uint16_t nChar, uint32_t nFlag) {
+bool CPWL_Wnd::OnChar(uint16_t nChar, FWL_EventFlagMask nFlag) {
   if (!IsValid() || !IsVisible())
     return false;
   if (!IsWndCaptureKeyboard(this))
@@ -311,27 +311,28 @@
   return false;
 }
 
-#define PWL_IMPLEMENT_MOUSE_METHOD(mouse_method_name)                         \
-  bool CPWL_Wnd::mouse_method_name(uint32_t nFlag, const CFX_PointF& point) { \
-    if (!IsValid() || !IsVisible())                                           \
-      return false;                                                           \
-    if (IsWndCaptureMouse(this)) {                                            \
-      for (const auto& pChild : m_Children) {                                 \
-        if (IsWndCaptureMouse(pChild.get())) {                                \
-          return pChild->mouse_method_name(nFlag, point);                     \
-        }                                                                     \
-      }                                                                       \
-      SetCursor();                                                            \
-      return false;                                                           \
-    }                                                                         \
-    for (const auto& pChild : m_Children) {                                   \
-      if (pChild->WndHitTest(point)) {                                        \
-        return pChild->mouse_method_name(nFlag, point);                       \
-      }                                                                       \
-    }                                                                         \
-    if (WndHitTest(point))                                                    \
-      SetCursor();                                                            \
-    return false;                                                             \
+#define PWL_IMPLEMENT_MOUSE_METHOD(mouse_method_name)         \
+  bool CPWL_Wnd::mouse_method_name(FWL_EventFlagMask nFlag,   \
+                                   const CFX_PointF& point) { \
+    if (!IsValid() || !IsVisible())                           \
+      return false;                                           \
+    if (IsWndCaptureMouse(this)) {                            \
+      for (const auto& pChild : m_Children) {                 \
+        if (IsWndCaptureMouse(pChild.get())) {                \
+          return pChild->mouse_method_name(nFlag, point);     \
+        }                                                     \
+      }                                                       \
+      SetCursor();                                            \
+      return false;                                           \
+    }                                                         \
+    for (const auto& pChild : m_Children) {                   \
+      if (pChild->WndHitTest(point)) {                        \
+        return pChild->mouse_method_name(nFlag, point);       \
+      }                                                       \
+    }                                                         \
+    if (WndHitTest(point))                                    \
+      SetCursor();                                            \
+    return false;                                             \
   }
 
 PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDblClk)
@@ -341,11 +342,11 @@
 #undef PWL_IMPLEMENT_MOUSE_METHOD
 
 // Unlike their FWL counterparts, PWL windows don't handle right clicks.
-bool CPWL_Wnd::OnRButtonDown(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_Wnd::OnRButtonDown(FWL_EventFlagMask nFlag, const CFX_PointF& point) {
   return false;
 }
 
-bool CPWL_Wnd::OnRButtonUp(uint32_t nFlag, const CFX_PointF& point) {
+bool CPWL_Wnd::OnRButtonUp(FWL_EventFlagMask nFlag, const CFX_PointF& point) {
   return false;
 }
 
@@ -379,7 +380,7 @@
   return false;
 }
 
-bool CPWL_Wnd::OnMouseWheel(uint32_t nFlag,
+bool CPWL_Wnd::OnMouseWheel(FWL_EventFlagMask 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 f1d6e78..579fa42 100644
--- a/fpdfsdk/pwl/cpwl_wnd.h
+++ b/fpdfsdk/pwl/cpwl_wnd.h
@@ -8,6 +8,7 @@
 #define FPDFSDK_PWL_CPWL_WND_H_
 
 #include <memory>
+#include <type_traits>
 #include <vector>
 
 #include "core/fxcrt/cfx_timer.h"
@@ -25,6 +26,8 @@
 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
@@ -125,13 +128,13 @@
         IPWL_SystemHandler::CursorStyle::kArrow;
   };
 
-  static bool IsSHIFTKeyDown(uint32_t nFlag);
-  static bool IsCTRLKeyDown(uint32_t nFlag);
-  static bool IsALTKeyDown(uint32_t nFlag);
-  static bool IsMETAKeyDown(uint32_t nFlag);
+  static bool IsSHIFTKeyDown(FWL_EventFlagMask nFlag);
+  static bool IsCTRLKeyDown(FWL_EventFlagMask nFlag);
+  static bool IsALTKeyDown(FWL_EventFlagMask nFlag);
+  static bool IsMETAKeyDown(FWL_EventFlagMask nFlag);
 
   // Selects between IsCTRLKeyDown() and IsMETAKeyDown() depending on platform.
-  static bool IsPlatformShortcutKey(uint32_t nFlag);
+  static bool IsPlatformShortcutKey(FWL_EventFlagMask nFlag);
 
   CPWL_Wnd(const CreateParams& cp,
            std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData);
@@ -140,15 +143,16 @@
   // Returns |true| iff this instance is still allocated.
   virtual bool InvalidateRect(const CFX_FloatRect* pRect);
 
-  virtual bool OnKeyDown(FWL_VKEYCODE nKeyCode, uint32_t nFlag);
-  virtual bool OnChar(uint16_t nChar, uint32_t nFlag);
-  virtual bool OnLButtonDblClk(uint32_t nFlag, const CFX_PointF& point);
-  virtual bool OnLButtonDown(uint32_t nFlag, const CFX_PointF& point);
-  virtual bool OnLButtonUp(uint32_t nFlag, const CFX_PointF& point);
-  virtual bool OnRButtonDown(uint32_t nFlag, const CFX_PointF& point);
-  virtual bool OnRButtonUp(uint32_t nFlag, const CFX_PointF& point);
-  virtual bool OnMouseMove(uint32_t nFlag, const CFX_PointF& point);
-  virtual bool OnMouseWheel(uint32_t nFlag,
+  virtual bool OnKeyDown(FWL_VKEYCODE nKeyCode, FWL_EventFlagMask nFlag);
+  virtual bool OnChar(uint16_t nChar, FWL_EventFlagMask nFlag);
+  virtual bool OnLButtonDblClk(FWL_EventFlagMask 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,
                             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 5447a60..b208d41 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 "fpdfsdk/pwl/cpwl_wnd.h"
 #include "fpdfsdk/pwl/ipwl_systemhandler.h"
 
 class IPWL_FillerNotify {
@@ -31,15 +32,15 @@
       int nSelStart,
       int nSelEnd,
       bool bKeyDown,
-      uint32_t nFlag) = 0;
+      FWL_EventFlagMask nFlag) = 0;
 
   virtual bool OnPopupPreOpen(
       const IPWL_SystemHandler::PerWindowData* pAttached,
-      uint32_t nFlag) = 0;
+      FWL_EventFlagMask nFlag) = 0;
 
   virtual bool OnPopupPostOpen(
       const IPWL_SystemHandler::PerWindowData* pAttached,
-      uint32_t nFlag) = 0;
+      FWL_EventFlagMask nFlag) = 0;
 };
 
 #endif  // FPDFSDK_PWL_IPWL_FILLERNOTIFY_H_
diff --git a/public/fpdf_formfill.h b/public/fpdf_formfill.h
index 8e0cc56..ee70ed9 100644
--- a/public/fpdf_formfill.h
+++ b/public/fpdf_formfill.h
@@ -1457,8 +1457,8 @@
  *       page        -   Handle to the page, as returned by FPDF_LoadPage().
  *       nKeyCode    -   The virtual-key code of the given key (see
  *                       fpdf_fwlevent.h for virtual key codes).
- *       modifier    -   Contains the scan code, key-transition code,
- *                       previous key state, and context code.
+ *       modifier    -   Mask of key flags (see fpdf_fwlevent.h for key
+ *                       flag values).
  * Return Value:
  *       True indicates success; otherwise false.
  */
@@ -1476,8 +1476,8 @@
  *       page        -   Handle to the page, as returned by FPDF_LoadPage().
  *       nKeyCode    -   The virtual-key code of the given key (see
  *                       fpdf_fwlevent.h for virtual key codes).
- *       modifier    -   Contains the scan code, key-transition code,
- *                       previous key state, and context code.
+ *       modifier    -   Mask of key flags (see fpdf_fwlevent.h for key
+ *                       flag values).
  * Return Value:
  *       True indicates success; otherwise false.
  */
@@ -1491,12 +1491,12 @@
  *       Call this member function when a keystroke translates to a
  *       nonsystem character.
  * Parameters:
- *        hHandle    -   Handle to the form fill module, as returned by
+ *       hHandle     -   Handle to the form fill module, as returned by
  *                       FPDFDOC_InitFormFillEnvironment().
- *        page       -   Handle to the page, as returned by FPDF_LoadPage().
- *        nChar      -   The character code value itself.
- *        modifier   -   Contains the scan code, key-transition code,
- *                       previous key state, and context code.
+ *       page        -   Handle to the page, as returned by FPDF_LoadPage().
+ *       nChar       -   The character code value itself.
+ *       modifier    -   Mask of key flags (see fpdf_fwlevent.h for key
+ *                       flag values).
  * Return Value:
  *       True indicates success; otherwise false.
  */