Use CFWL_Widget::Is*() helpers

Avoid any particular flag representation.

Change-Id: Iec99bac5a3f971998d3d24094b8bde5e46436190
Reviewed-on: https://pdfium-review.googlesource.com/c/45971
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fwl/cfwl_combobox.h b/xfa/fwl/cfwl_combobox.h
index f247d93..c136ab5 100644
--- a/xfa/fwl/cfwl_combobox.h
+++ b/xfa/fwl/cfwl_combobox.h
@@ -116,9 +116,7 @@
 
   void InitComboList();
   void InitComboEdit();
-  bool IsDropListVisible() const {
-    return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible);
-  }
+  bool IsDropListVisible() const { return m_pListBox->IsVisible(); }
   void OnLButtonDown(CFWL_MessageMouse* pMsg);
   void OnFocusChanged(CFWL_Message* pMsg, bool bSet);
   void OnKey(CFWL_MessageKey* pMsg);
diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp
index 68dc171..9666f36 100644
--- a/xfa/fwl/cfwl_datetimepicker.cpp
+++ b/xfa/fwl/cfwl_datetimepicker.cpp
@@ -268,7 +268,7 @@
 }
 
 bool CFWL_DateTimePicker::IsMonthCalendarVisible() const {
-  return (m_pMonthCal && !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible));
+  return m_pMonthCal && m_pMonthCal->IsVisible();
 }
 
 void CFWL_DateTimePicker::ResetEditAlignment() {
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index 07d3b07..070257d 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -664,12 +664,8 @@
 }
 
 CFWL_ScrollBar* CFWL_Edit::UpdateScroll() {
-  bool bShowHorz =
-      m_pHorzScrollBar &&
-      ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0);
-  bool bShowVert =
-      m_pVertScrollBar &&
-      ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0);
+  bool bShowHorz = m_pHorzScrollBar && m_pHorzScrollBar->IsVisible();
+  bool bShowVert = m_pVertScrollBar && m_pVertScrollBar->IsVisible();
   if (!bShowHorz && !bShowVert)
     return nullptr;
 
diff --git a/xfa/fwl/cfwl_listbox.cpp b/xfa/fwl/cfwl_listbox.cpp
index e50aa05..e652ef9 100644
--- a/xfa/fwl/cfwl_listbox.cpp
+++ b/xfa/fwl/cfwl_listbox.cpp
@@ -648,8 +648,9 @@
 bool CFWL_ListBox::IsShowScrollBar(bool bVert) {
   CFWL_ScrollBar* pScrollbar =
       bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get();
-  if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible))
+  if (!pScrollbar || !pScrollbar->IsVisible())
     return false;
+
   return !(m_pProperties->m_dwStyleExes &
            FWL_STYLEEXT_LTB_ShowScrollBarFocus) ||
          (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused);
diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp
index ac41977..43489e7 100644
--- a/xfa/fwl/cfwl_widget.cpp
+++ b/xfa/fwl/cfwl_widget.cpp
@@ -132,7 +132,7 @@
 
 void CFWL_Widget::SetStates(uint32_t dwStates) {
   m_pProperties->m_dwStates |= dwStates;
-  if (!(dwStates & FWL_WGTSTATE_Invisible))
+  if (IsVisible())
     return;
 
   CFWL_NoteDriver* noteDriver =
@@ -213,7 +213,7 @@
 }
 
 bool CFWL_Widget::IsVisible() const {
-  return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0;
+  return !(m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible);
 }
 
 bool CFWL_Widget::IsOverLapper() const {
@@ -258,9 +258,8 @@
 
   const CFWL_Widget* pUp = this;
   do {
-    pUp = (pUp->GetStyles() & FWL_WGTSTYLE_Popup)
-              ? m_pWidgetMgr->GetOwnerWidget(pUp)
-              : m_pWidgetMgr->GetParentWidget(pUp);
+    pUp = pUp->IsPopup() ? m_pWidgetMgr->GetOwnerWidget(pUp)
+                         : m_pWidgetMgr->GetParentWidget(pUp);
     if (pUp) {
       IFWL_ThemeProvider* pRet = pUp->GetThemeProvider();
       if (pRet)
diff --git a/xfa/fwl/cfwl_widget.h b/xfa/fwl/cfwl_widget.h
index a021f4a..785c5fa9 100644
--- a/xfa/fwl/cfwl_widget.h
+++ b/xfa/fwl/cfwl_widget.h
@@ -78,6 +78,11 @@
 
   void SetParent(CFWL_Widget* pParent);
 
+  bool IsVisible() const;
+  bool IsOverLapper() const;
+  bool IsPopup() const;
+  bool IsChild() const;
+
   CFWL_Widget* GetOwner() { return m_pWidgetMgr->GetOwnerWidget(this); }
   CFWL_Widget* GetOuter() const { return m_pOuter; }
 
@@ -155,11 +160,6 @@
  private:
   CFWL_Widget* GetParent() const { return m_pWidgetMgr->GetParentWidget(this); }
   CFX_SizeF GetOffsetFromParent(CFWL_Widget* pParent);
-
-  bool IsVisible() const;
-  bool IsOverLapper() const;
-  bool IsPopup() const;
-  bool IsChild() const;
   CFWL_Widget* GetRootOuter();
   void DrawBackground(CXFA_Graphics* pGraphics,
                       CFWL_Part iPartBk,
diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp
index 8310564..9630a81 100644
--- a/xfa/fwl/cfwl_widgetmgr.cpp
+++ b/xfa/fwl/cfwl_widgetmgr.cpp
@@ -231,12 +231,10 @@
   if (!parent)
     return nullptr;
 
-  CFX_PointF pos;
   CFWL_Widget* child = GetLastChildWidget(parent);
   while (child) {
-    if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) {
-      pos = parent->GetMatrix().GetInverse().Transform(point);
-
+    if (child->IsVisible()) {
+      CFX_PointF pos = parent->GetMatrix().GetInverse().Transform(point);
       CFX_RectF bounds = child->GetWidgetRect();
       if (bounds.Contains(pos)) {
         pos -= bounds.TopLeft();
@@ -337,10 +335,7 @@
   if (!pWidget || !pWidget->IsForm())
     return false;
 
-  uint32_t dwStyles = pWidget->GetStyles();
-  return ((dwStyles & FWL_WGTSTYLE_WindowTypeMask) ==
-          FWL_WGTSTYLE_OverLapper) ||
-         (dwStyles & FWL_WGTSTYLE_Popup);
+  return pWidget->IsOverLapper() || pWidget->IsPopup();
 }
 
 void CFWL_WidgetMgr::GetAdapterPopupPos(CFWL_Widget* pWidget,
@@ -409,7 +404,7 @@
   while (pNextChild) {
     CFWL_Widget* child = pNextChild;
     pNextChild = GetNextSiblingWidget(child);
-    if (child->GetStates() & FWL_WGTSTATE_Invisible)
+    if (!child->IsVisible())
       continue;
 
     CFX_RectF rtWidget = child->GetWidgetRect();