Clean up some type usage in CFWL_Message hierarchy

-- Move FWL_KeyFlag definition to cfwl_message.h
-- Then use FWL_KeyFlagMask in another message subclass.
-- Rename enum class CFWL_MessageKey::Type to not shadow
   superclass enum class CFWL_Message::Type.

Change-Id: Ie4571b46d13c528d90d4cc14ee720d548a5f07cf
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/83830
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fwl/cfwl_checkbox.cpp b/xfa/fwl/cfwl_checkbox.cpp
index f482165..d048ab9 100644
--- a/xfa/fwl/cfwl_checkbox.cpp
+++ b/xfa/fwl/cfwl_checkbox.cpp
@@ -211,7 +211,7 @@
     }
     case CFWL_Message::Type::kKey: {
       CFWL_MessageKey* pKey = static_cast<CFWL_MessageKey*>(pMessage);
-      if (pKey->m_dwCmd == CFWL_MessageKey::Type::kKeyDown)
+      if (pKey->m_dwCmd == CFWL_MessageKey::KeyCommand::kKeyDown)
         OnKeyDown(pKey);
       break;
     }
diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp
index 809cb11..8154d75 100644
--- a/xfa/fwl/cfwl_combobox.cpp
+++ b/xfa/fwl/cfwl_combobox.cpp
@@ -406,10 +406,10 @@
     case CFWL_Message::Type::kKey: {
       backDefault = false;
       CFWL_MessageKey* pKey = static_cast<CFWL_MessageKey*>(pMessage);
-      if (pKey->m_dwCmd == CFWL_MessageKey::Type::kKeyUp)
+      if (pKey->m_dwCmd == CFWL_MessageKey::KeyCommand::kKeyUp)
         break;
       if (IsDropListVisible() &&
-          pKey->m_dwCmd == CFWL_MessageKey::Type::kKeyDown) {
+          pKey->m_dwCmd == CFWL_MessageKey::KeyCommand::kKeyDown) {
         bool bListKey = pKey->m_dwKeyCode == XFA_FWL_VKEY_Up ||
                         pKey->m_dwKeyCode == XFA_FWL_VKEY_Down ||
                         pKey->m_dwKeyCode == XFA_FWL_VKEY_Return ||
diff --git a/xfa/fwl/cfwl_combolist.cpp b/xfa/fwl/cfwl_combolist.cpp
index 355cb01..98dfc01 100644
--- a/xfa/fwl/cfwl_combolist.cpp
+++ b/xfa/fwl/cfwl_combolist.cpp
@@ -178,7 +178,7 @@
 bool CFWL_ComboList::OnDropListKey(CFWL_MessageKey* pKey) {
   CFWL_ComboBox* pOuter = static_cast<CFWL_ComboBox*>(GetOuter());
   bool bPropagate = false;
-  if (pKey->m_dwCmd == CFWL_MessageKey::Type::kKeyDown) {
+  if (pKey->m_dwCmd == CFWL_MessageKey::KeyCommand::kKeyDown) {
     uint32_t dwKeyCode = pKey->m_dwKeyCode;
     switch (dwKeyCode) {
       case XFA_FWL_VKEY_Return:
@@ -197,7 +197,7 @@
         break;
       }
     }
-  } else if (pKey->m_dwCmd == CFWL_MessageKey::Type::kChar) {
+  } else if (pKey->m_dwCmd == CFWL_MessageKey::KeyCommand::kChar) {
     bPropagate = true;
   }
   if (bPropagate) {
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index fb8cd8c..e157cb3 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -817,9 +817,9 @@
     }
     case CFWL_Message::Type::kKey: {
       CFWL_MessageKey* pKey = static_cast<CFWL_MessageKey*>(pMessage);
-      if (pKey->m_dwCmd == CFWL_MessageKey::Type::kKeyDown)
+      if (pKey->m_dwCmd == CFWL_MessageKey::KeyCommand::kKeyDown)
         OnKeyDown(pKey);
-      else if (pKey->m_dwCmd == CFWL_MessageKey::Type::kChar)
+      else if (pKey->m_dwCmd == CFWL_MessageKey::KeyCommand::kChar)
         OnChar(pKey);
       break;
     }
diff --git a/xfa/fwl/cfwl_listbox.cpp b/xfa/fwl/cfwl_listbox.cpp
index 374a8e5..f07a409 100644
--- a/xfa/fwl/cfwl_listbox.cpp
+++ b/xfa/fwl/cfwl_listbox.cpp
@@ -622,7 +622,7 @@
       break;
     case CFWL_Message::Type::kKey: {
       CFWL_MessageKey* pMsg = static_cast<CFWL_MessageKey*>(pMessage);
-      if (pMsg->m_dwCmd == CFWL_MessageKey::Type::kKeyDown)
+      if (pMsg->m_dwCmd == CFWL_MessageKey::KeyCommand::kKeyDown)
         OnKeyDown(pMsg);
       break;
     }
diff --git a/xfa/fwl/cfwl_message.h b/xfa/fwl/cfwl_message.h
index 7a6e565..0e4c65d 100644
--- a/xfa/fwl/cfwl_message.h
+++ b/xfa/fwl/cfwl_message.h
@@ -7,11 +7,24 @@
 #ifndef XFA_FWL_CFWL_MESSAGE_H_
 #define XFA_FWL_CFWL_MESSAGE_H_
 
+#include <type_traits>
+
 #include "core/fxcrt/unowned_ptr.h"
 #include "v8/include/cppgc/macros.h"
 
 class CFWL_Widget;
 
+enum FWL_KeyFlag : uint8_t {
+  FWL_KEYFLAG_Ctrl = 1 << 0,
+  FWL_KEYFLAG_Alt = 1 << 1,
+  FWL_KEYFLAG_Shift = 1 << 2,
+  FWL_KEYFLAG_Command = 1 << 3,
+  FWL_KEYFLAG_LButton = 1 << 4,
+  FWL_KEYFLAG_RButton = 1 << 5,
+  FWL_KEYFLAG_MButton = 1 << 6
+};
+using FWL_KeyFlagMask = std::underlying_type<FWL_KeyFlag>::type;
+
 class CFWL_Message {
   CPPGC_STACK_ALLOCATED();  // Allow Raw/Unowned pointers.
 
diff --git a/xfa/fwl/cfwl_messagekey.cpp b/xfa/fwl/cfwl_messagekey.cpp
index 3a18dc0..b9aaf4a 100644
--- a/xfa/fwl/cfwl_messagekey.cpp
+++ b/xfa/fwl/cfwl_messagekey.cpp
@@ -7,8 +7,8 @@
 #include "xfa/fwl/cfwl_messagekey.h"
 
 CFWL_MessageKey::CFWL_MessageKey(CFWL_Widget* pDstTarget,
-                                 Type cmd,
-                                 uint32_t flags,
+                                 KeyCommand cmd,
+                                 FWL_KeyFlagMask flags,
                                  uint32_t keycode)
     : CFWL_Message(CFWL_Message::Type::kKey, nullptr, pDstTarget),
       m_dwCmd(cmd),
diff --git a/xfa/fwl/cfwl_messagekey.h b/xfa/fwl/cfwl_messagekey.h
index 77317ed..85ea85d 100644
--- a/xfa/fwl/cfwl_messagekey.h
+++ b/xfa/fwl/cfwl_messagekey.h
@@ -11,16 +11,16 @@
 
 class CFWL_MessageKey final : public CFWL_Message {
  public:
-  enum class Type { kKeyDown, kKeyUp, kChar };
+  enum class KeyCommand : uint8_t { kKeyDown, kKeyUp, kChar };
 
   CFWL_MessageKey(CFWL_Widget* pDstTarget,
-                  Type cmd,
-                  uint32_t flags,
+                  KeyCommand subtype,
+                  FWL_KeyFlagMask flags,
                   uint32_t keycode);
   ~CFWL_MessageKey() override;
 
-  const Type m_dwCmd;
-  const uint32_t m_dwFlags;
+  const KeyCommand m_dwCmd;
+  const FWL_KeyFlagMask m_dwFlags;
   const uint32_t m_dwKeyCode;
 };
 
diff --git a/xfa/fwl/cfwl_messagemouse.h b/xfa/fwl/cfwl_messagemouse.h
index d7758cc..89fa511 100644
--- a/xfa/fwl/cfwl_messagemouse.h
+++ b/xfa/fwl/cfwl_messagemouse.h
@@ -7,8 +7,6 @@
 #ifndef XFA_FWL_CFWL_MESSAGEMOUSE_H_
 #define XFA_FWL_CFWL_MESSAGEMOUSE_H_
 
-#include <type_traits>
-
 #include "core/fxcrt/fx_coordinates.h"
 #include "xfa/fwl/cfwl_message.h"
 
@@ -25,17 +23,6 @@
   Hover
 };
 
-enum FWL_KeyFlag : uint8_t {
-  FWL_KEYFLAG_Ctrl = 1 << 0,
-  FWL_KEYFLAG_Alt = 1 << 1,
-  FWL_KEYFLAG_Shift = 1 << 2,
-  FWL_KEYFLAG_Command = 1 << 3,
-  FWL_KEYFLAG_LButton = 1 << 4,
-  FWL_KEYFLAG_RButton = 1 << 5,
-  FWL_KEYFLAG_MButton = 1 << 6
-};
-using FWL_KeyFlagMask = std::underlying_type<FWL_KeyFlag>::type;
-
 class CFWL_MessageMouse final : public CFWL_Message {
  public:
   CFWL_MessageMouse(CFWL_Widget* pDstTarget, FWL_MouseCommand cmd);
diff --git a/xfa/fwl/cfwl_notedriver.cpp b/xfa/fwl/cfwl_notedriver.cpp
index af83ff2..c61ecd4 100644
--- a/xfa/fwl/cfwl_notedriver.cpp
+++ b/xfa/fwl/cfwl_notedriver.cpp
@@ -156,7 +156,7 @@
 bool CFWL_NoteDriver::DoKey(CFWL_Message* pMessage, CFWL_Widget* pMessageForm) {
   CFWL_MessageKey* pMsg = static_cast<CFWL_MessageKey*>(pMessage);
 #if !defined(OS_APPLE)
-  if (pMsg->m_dwCmd == CFWL_MessageKey::Type::kKeyDown &&
+  if (pMsg->m_dwCmd == CFWL_MessageKey::KeyCommand::kKeyDown &&
       pMsg->m_dwKeyCode == XFA_FWL_VKEY_Tab) {
     return true;
   }
@@ -167,7 +167,7 @@
     return true;
   }
 
-  if (pMsg->m_dwCmd == CFWL_MessageKey::Type::kKeyDown &&
+  if (pMsg->m_dwCmd == CFWL_MessageKey::KeyCommand::kKeyDown &&
       pMsg->m_dwKeyCode == XFA_FWL_VKEY_Return) {
     CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetFWLApp()->GetWidgetMgr();
     CFWL_Widget* pDefButton = pWidgetMgr->GetDefaultButton(pMessageForm);
diff --git a/xfa/fwl/cfwl_pushbutton.cpp b/xfa/fwl/cfwl_pushbutton.cpp
index aad52b2..62080e7 100644
--- a/xfa/fwl/cfwl_pushbutton.cpp
+++ b/xfa/fwl/cfwl_pushbutton.cpp
@@ -111,7 +111,7 @@
     }
     case CFWL_Message::Type::kKey: {
       CFWL_MessageKey* pKey = static_cast<CFWL_MessageKey*>(pMessage);
-      if (pKey->m_dwCmd == CFWL_MessageKey::Type::kKeyDown)
+      if (pKey->m_dwCmd == CFWL_MessageKey::KeyCommand::kKeyDown)
         OnKeyDown(pKey);
       break;
     }
diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp
index 53d7356..df2ef7d 100644
--- a/xfa/fxfa/cxfa_fffield.cpp
+++ b/xfa/fxfa/cxfa_fffield.cpp
@@ -517,7 +517,7 @@
   if (!GetNormalWidget() || !GetDoc()->GetXFADoc()->IsInteractive())
     return false;
 
-  CFWL_MessageKey msg(GetNormalWidget(), CFWL_MessageKey::Type::kKeyDown,
+  CFWL_MessageKey msg(GetNormalWidget(), CFWL_MessageKey::KeyCommand::kKeyDown,
                       dwFlags, dwKeyCode);
   SendMessageToFWLWidget(&msg);
   return true;
@@ -527,8 +527,8 @@
   if (!GetNormalWidget() || !GetDoc()->GetXFADoc()->IsInteractive())
     return false;
 
-  CFWL_MessageKey msg(GetNormalWidget(), CFWL_MessageKey::Type::kKeyUp, dwFlags,
-                      dwKeyCode);
+  CFWL_MessageKey msg(GetNormalWidget(), CFWL_MessageKey::KeyCommand::kKeyUp,
+                      dwFlags, dwKeyCode);
   SendMessageToFWLWidget(&msg);
   return true;
 }
@@ -543,8 +543,8 @@
   if (!m_pNode->IsOpenAccess())
     return false;
 
-  CFWL_MessageKey msg(GetNormalWidget(), CFWL_MessageKey::Type::kChar, dwFlags,
-                      dwChar);
+  CFWL_MessageKey msg(GetNormalWidget(), CFWL_MessageKey::KeyCommand::kChar,
+                      dwFlags, dwChar);
   SendMessageToFWLWidget(&msg);
   return true;
 }