Continue formatting fwl/core

Review-Url: https://codereview.chromium.org/2506083002
diff --git a/xfa/fwl/core/cfwl_combobox.cpp b/xfa/fwl/core/cfwl_combobox.cpp
index fcdbec9..569ad6d 100644
--- a/xfa/fwl/core/cfwl_combobox.cpp
+++ b/xfa/fwl/core/cfwl_combobox.cpp
@@ -127,16 +127,19 @@
   return GetWidget() ? ToComboBox(GetWidget())->EditPaste(wsPaste) : false;
 }
 
-bool CFWL_ComboBox::EditSelectAll() {
-  return GetWidget() ? ToComboBox(GetWidget())->EditSelectAll() : false;
+void CFWL_ComboBox::EditSelectAll() {
+  if (GetWidget())
+    ToComboBox(GetWidget())->EditSelectAll();
 }
 
-bool CFWL_ComboBox::EditDelete() {
-  return GetWidget() ? ToComboBox(GetWidget())->EditDelete() : false;
+void CFWL_ComboBox::EditDelete() {
+  if (GetWidget())
+    ToComboBox(GetWidget())->EditDelete();
 }
 
-bool CFWL_ComboBox::EditDeSelect() {
-  return GetWidget() ? ToComboBox(GetWidget())->EditDeSelect() : false;
+void CFWL_ComboBox::EditDeSelect() {
+  if (GetWidget())
+    ToComboBox(GetWidget())->EditDeSelect();
 }
 
 void CFWL_ComboBox::GetBBox(CFX_RectF& rect) {
diff --git a/xfa/fwl/core/cfwl_combobox.h b/xfa/fwl/core/cfwl_combobox.h
index 5b4f821..2e904af 100644
--- a/xfa/fwl/core/cfwl_combobox.h
+++ b/xfa/fwl/core/cfwl_combobox.h
@@ -85,9 +85,9 @@
   bool EditCopy(CFX_WideString& wsCopy);
   bool EditCut(CFX_WideString& wsCut);
   bool EditPaste(const CFX_WideString& wsPaste);
-  bool EditSelectAll();
-  bool EditDelete();
-  bool EditDeSelect();
+  void EditSelectAll();
+  void EditDelete();
+  void EditDeSelect();
 
   void GetBBox(CFX_RectF& rect);
   void EditModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved);
diff --git a/xfa/fwl/core/ifwl_combobox.cpp b/xfa/fwl/core/ifwl_combobox.cpp
index 6299632..c26a9fc 100644
--- a/xfa/fwl/core/ifwl_combobox.cpp
+++ b/xfa/fwl/core/ifwl_combobox.cpp
@@ -16,8 +16,6 @@
 #include "xfa/fwl/core/cfwl_widgetmgr.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
 #include "xfa/fwl/core/ifwl_app.h"
-#include "xfa/fwl/core/ifwl_comboboxproxy.h"
-#include "xfa/fwl/core/ifwl_comboedit.h"
 #include "xfa/fwl/core/ifwl_formproxy.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
 
@@ -65,27 +63,28 @@
 }
 
 void IFWL_ComboBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
-  if (bAutoSize) {
-    rect.Reset();
-    bool bIsDropDown = IsDropDownStyle();
-    if (bIsDropDown && m_pEdit) {
-      m_pEdit->GetWidgetRect(rect, true);
-    } else {
-      rect.width = 100;
-      rect.height = 16;
-    }
-    if (!m_pProperties->m_pThemeProvider) {
-      ResetTheme();
-    }
-    FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
-        GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
-    if (!pFWidth)
-      return;
-    rect.Inflate(0, 0, *pFWidth, 0);
-    IFWL_Widget::GetWidgetRect(rect, true);
-  } else {
+  if (!bAutoSize) {
     rect = m_pProperties->m_rtWidget;
+    return;
   }
+
+  rect.Reset();
+  if (IsDropDownStyle() && m_pEdit) {
+    m_pEdit->GetWidgetRect(rect, true);
+  } else {
+    rect.width = 100;
+    rect.height = 16;
+  }
+  if (!m_pProperties->m_pThemeProvider)
+    ResetTheme();
+
+  FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
+      GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
+  if (!pFWidth)
+    return;
+
+  rect.Inflate(0, 0, *pFWidth, 0);
+  IFWL_Widget::GetWidgetRect(rect, true);
 }
 
 void IFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded,
@@ -94,11 +93,12 @@
     DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
     return;
   }
+
   bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
   bool bRemoveDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
   if (bAddDropDown && !m_pEdit) {
-    m_pEdit.reset(new IFWL_ComboEdit(
-        m_pOwnerApp, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr));
+    m_pEdit = pdfium::MakeUnique<IFWL_ComboEdit>(
+        m_pOwnerApp, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr);
     m_pEdit->SetOuter(this);
     m_pEdit->SetParent(this);
   } else if (bRemoveDropDown && m_pEdit) {
@@ -112,17 +112,15 @@
     DisForm_Update();
     return;
   }
-  if (IsLocked()) {
+  if (IsLocked())
     return;
-  }
+
   ResetTheme();
-  bool bDropDown = IsDropDownStyle();
-  if (bDropDown && m_pEdit) {
+  if (IsDropDownStyle() && m_pEdit)
     ResetEditAlignment();
-  }
-  if (!m_pProperties->m_pThemeProvider) {
+  if (!m_pProperties->m_pThemeProvider)
     m_pProperties->m_pThemeProvider = GetAvailableTheme();
-  }
+
   Layout();
   CFWL_ThemePart part;
   part.m_pWidget = this;
@@ -132,9 +130,8 @@
 }
 
 FWL_WidgetHit IFWL_ComboBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
-  if (m_pWidgetMgr->IsFormDisabled()) {
+  if (m_pWidgetMgr->IsFormDisabled())
     return DisForm_HitTest(fx, fy);
-  }
   return IFWL_Widget::HitTest(fx, fy);
 }
 
@@ -144,38 +141,39 @@
     DisForm_DrawWidget(pGraphics, pMatrix);
     return;
   }
+
   if (!pGraphics)
     return;
   if (!m_pProperties->m_pThemeProvider)
     return;
+
   IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
-  bool bIsDropDown = IsDropDownStyle();
-  if (HasBorder()) {
+  if (HasBorder())
     DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
-  }
-  if (HasEdge()) {
+  if (HasEdge())
     DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
-  }
-  if (!bIsDropDown) {
+
+  if (!IsDropDownStyle()) {
     CFX_RectF rtTextBk(m_rtClient);
     rtTextBk.width -= m_rtBtn.width;
+
     CFWL_ThemeBackground param;
     param.m_pWidget = this;
     param.m_iPart = CFWL_Part::Background;
     param.m_pGraphics = pGraphics;
-    if (pMatrix) {
+    if (pMatrix)
       param.m_matrix.Concat(*pMatrix);
-    }
     param.m_rtPart = rtTextBk;
+
     if (m_iCurSel >= 0) {
       IFWL_ListBoxDP* pData =
           static_cast<IFWL_ListBoxDP*>(m_pListBox->GetDataProvider());
       void* p = pData->GetItemData(m_pListBox.get(),
                                    pData->GetItem(m_pListBox.get(), m_iCurSel));
-      if (p) {
+      if (p)
         param.m_pData = p;
-      }
     }
+
     if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
       param.m_dwStates = CFWL_PartState_Disabled;
     } else if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) &&
@@ -185,14 +183,17 @@
       param.m_dwStates = CFWL_PartState_Normal;
     }
     pTheme->DrawBackground(&param);
+
     if (m_iCurSel >= 0) {
       if (!m_pListBox)
         return;
+
       CFX_WideString wsText;
       IFWL_ComboBoxDP* pData =
           static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
       CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
       m_pListBox->GetItemText(hItem, wsText);
+
       CFWL_ThemeText theme_text;
       theme_text.m_pWidget = this;
       theme_text.m_iPart = CFWL_Part::Caption;
@@ -209,23 +210,23 @@
       pTheme->DrawText(&theme_text);
     }
   }
-  {
-    CFWL_ThemeBackground param;
-    param.m_pWidget = this;
-    param.m_iPart = CFWL_Part::DropDownButton;
-    param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
-                           ? CFWL_PartState_Disabled
-                           : m_iBtnState;
-    param.m_pGraphics = pGraphics;
-    param.m_matrix.Concat(*pMatrix);
-    param.m_rtPart = m_rtBtn;
-    pTheme->DrawBackground(&param);
-  }
+
+  CFWL_ThemeBackground param;
+  param.m_pWidget = this;
+  param.m_iPart = CFWL_Part::DropDownButton;
+  param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
+                         ? CFWL_PartState_Disabled
+                         : m_iBtnState;
+  param.m_pGraphics = pGraphics;
+  param.m_matrix.Concat(*pMatrix);
+  param.m_rtPart = m_rtBtn;
+  pTheme->DrawBackground(&param);
 }
 
 void IFWL_ComboBox::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
   if (!pThemeProvider)
     return;
+
   m_pProperties->m_pThemeProvider = pThemeProvider;
   if (m_pListBox)
     m_pListBox->SetThemeProvider(pThemeProvider);
@@ -233,15 +234,10 @@
     m_pEdit->SetThemeProvider(pThemeProvider);
 }
 
-int32_t IFWL_ComboBox::GetCurSel() const {
-  return m_iCurSel;
-}
-
 void IFWL_ComboBox::SetCurSel(int32_t iSel) {
   int32_t iCount = m_pListBox->CountItems();
   bool bClearSel = iSel < 0 || iSel >= iCount;
-  bool bDropDown = IsDropDownStyle();
-  if (bDropDown && m_pEdit) {
+  if (IsDropDownStyle() && m_pEdit) {
     if (bClearSel) {
       m_pEdit->SetText(CFX_WideString());
     } else {
@@ -258,8 +254,7 @@
 }
 
 void IFWL_ComboBox::SetStates(uint32_t dwStates, bool bSet) {
-  bool bIsDropDown = IsDropDownStyle();
-  if (bIsDropDown && m_pEdit)
+  if (IsDropDownStyle() && m_pEdit)
     m_pEdit->SetStates(dwStates, bSet);
   if (m_pListBox)
     m_pListBox->SetStates(dwStates, bSet);
@@ -269,6 +264,7 @@
 void IFWL_ComboBox::SetEditText(const CFX_WideString& wsText) {
   if (!m_pEdit)
     return;
+
   m_pEdit->SetText(wsText);
   m_pEdit->Update();
 }
@@ -293,76 +289,20 @@
   ShowDropList(bActivate);
 }
 
-bool IFWL_ComboBox::EditCanUndo() {
-  return m_pEdit->CanUndo();
-}
-
-bool IFWL_ComboBox::EditCanRedo() {
-  return m_pEdit->CanRedo();
-}
-
-bool IFWL_ComboBox::EditUndo() {
-  return m_pEdit->Undo();
-}
-
-bool IFWL_ComboBox::EditRedo() {
-  return m_pEdit->Redo();
-}
-
-bool IFWL_ComboBox::EditCanCopy() {
-  return m_pEdit->CountSelRanges() > 0;
-}
-
-bool IFWL_ComboBox::EditCanCut() {
-  if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) {
-    return false;
-  }
-  return m_pEdit->CountSelRanges() > 0;
-}
-
-bool IFWL_ComboBox::EditCanSelectAll() {
-  return m_pEdit->GetTextLength() > 0;
-}
-
-bool IFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) {
-  return m_pEdit->Copy(wsCopy);
-}
-
-bool IFWL_ComboBox::EditCut(CFX_WideString& wsCut) {
-  return m_pEdit->Cut(wsCut);
-}
-
-bool IFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) {
-  return m_pEdit->Paste(wsPaste);
-}
-
-bool IFWL_ComboBox::EditSelectAll() {
-  m_pEdit->AddSelRange(0);
-  return true;
-}
-
-bool IFWL_ComboBox::EditDelete() {
-  m_pEdit->ClearText();
-  return true;
-}
-
-bool IFWL_ComboBox::EditDeSelect() {
-  m_pEdit->ClearSelections();
-  return true;
-}
-
-void IFWL_ComboBox::GetBBox(CFX_RectF& rect) {
+void IFWL_ComboBox::GetBBox(CFX_RectF& rect) const {
   if (m_pWidgetMgr->IsFormDisabled()) {
     DisForm_GetBBox(rect);
     return;
   }
+
   rect = m_pProperties->m_rtWidget;
-  if (m_pListBox && IsDropListVisible()) {
-    CFX_RectF rtList;
-    m_pListBox->GetWidgetRect(rtList);
-    rtList.Offset(rect.left, rect.top);
-    rect.Union(rtList);
-  }
+  if (!m_pListBox || !IsDropListVisible())
+    return;
+
+  CFX_RectF rtList;
+  m_pListBox->GetWidgetRect(rtList);
+  rtList.Offset(rect.left, rect.top);
+  rect.Union(rtList);
 }
 
 void IFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded,
@@ -383,9 +323,8 @@
   param.m_iPart = CFWL_Part::StretchHandler;
   param.m_dwStates = CFWL_PartState_Normal;
   param.m_pWidget = this;
-  if (pMatrix) {
+  if (pMatrix)
     param.m_matrix.Concat(*pMatrix);
-  }
   param.m_rtPart = m_rtHandler;
   m_pProperties->m_pThemeProvider->DrawBackground(&param);
 }
@@ -393,78 +332,75 @@
 void IFWL_ComboBox::ShowDropList(bool bActivate) {
   if (m_pWidgetMgr->IsFormDisabled())
     return DisForm_ShowDropList(bActivate);
-
-  bool bDropList = IsDropListVisible();
-  if (bDropList == bActivate)
+  if (IsDropListVisible() == bActivate)
     return;
   if (!m_pComboBoxProxy)
     InitProxyForm();
 
   m_pComboBoxProxy->Reset();
-  if (bActivate) {
-    m_pListBox->ChangeSelected(m_iCurSel);
-    ResetListItemAlignment();
-    uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes &
-                          (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw);
-    m_pListBox->ModifyStylesEx(dwStyleAdd, 0);
-    m_pListBox->GetWidgetRect(m_rtList, true);
-    FX_FLOAT fHeight = GetListHeight();
-    if (fHeight > 0) {
-      if (m_rtList.height > GetListHeight()) {
-        m_rtList.height = GetListHeight();
-        m_pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll, 0);
-      }
-    }
-    CFX_RectF rtAnchor;
-    rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width,
-                 m_pProperties->m_rtWidget.height);
-    FX_FLOAT fMinHeight = 0;
-    if (m_rtList.width < m_rtClient.width) {
-      m_rtList.width = m_rtClient.width;
-    }
-    m_rtProxy = m_rtList;
-    if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) {
-      m_rtProxy.height += m_fComboFormHandler;
-    }
-    GetPopupPos(fMinHeight, m_rtProxy.height, rtAnchor, m_rtProxy);
-    if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) {
-      FX_FLOAT fx = 0;
-      FX_FLOAT fy = m_rtClient.top + m_rtClient.height / 2;
-      TransformTo(nullptr, fx, fy);
-      m_bUpFormHandler = fy > m_rtProxy.top;
-      if (m_bUpFormHandler) {
-        m_rtHandler.Set(0, 0, m_rtList.width, m_fComboFormHandler);
-        m_rtList.top = m_fComboFormHandler;
-      } else {
-        m_rtHandler.Set(0, m_rtList.height, m_rtList.width,
-                        m_fComboFormHandler);
-      }
-    }
-    m_pComboBoxProxy->SetWidgetRect(m_rtProxy);
-    m_pComboBoxProxy->Update();
-    m_pListBox->SetWidgetRect(m_rtList);
-    m_pListBox->Update();
-    CFWL_EvtCmbPreDropDown ev;
-    ev.m_pSrcTarget = this;
-    DispatchEvent(&ev);
-    m_fItemHeight = m_pListBox->GetItemHeight();
-    m_pListBox->SetFocus(true);
-    m_pComboBoxProxy->DoModal();
-    m_pListBox->SetFocus(false);
-  } else {
+  if (!bActivate) {
     m_pComboBoxProxy->EndDoModal();
+
     CFWL_EvtCmbCloseUp ev;
     ev.m_pSrcTarget = this;
     DispatchEvent(&ev);
+
     m_bLButtonDown = false;
     m_pListBox->SetNotifyOwner(true);
     SetFocus(true);
+    return;
   }
-}
 
-bool IFWL_ComboBox::IsDropListVisible() {
-  return m_pComboBoxProxy &&
-         !(m_pComboBoxProxy->GetStates() & FWL_WGTSTATE_Invisible);
+  m_pListBox->ChangeSelected(m_iCurSel);
+  ResetListItemAlignment();
+
+  uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes &
+                        (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw);
+  m_pListBox->ModifyStylesEx(dwStyleAdd, 0);
+  m_pListBox->GetWidgetRect(m_rtList, true);
+  FX_FLOAT fHeight = GetListHeight();
+  if (fHeight > 0 && m_rtList.height > GetListHeight()) {
+    m_rtList.height = GetListHeight();
+    m_pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll, 0);
+  }
+
+  CFX_RectF rtAnchor;
+  rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width,
+               m_pProperties->m_rtWidget.height);
+
+  m_rtList.width = std::max(m_rtList.width, m_rtClient.width);
+  m_rtProxy = m_rtList;
+  if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag)
+    m_rtProxy.height += m_fComboFormHandler;
+
+  FX_FLOAT fMinHeight = 0;
+  GetPopupPos(fMinHeight, m_rtProxy.height, rtAnchor, m_rtProxy);
+  if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) {
+    FX_FLOAT fx = 0;
+    FX_FLOAT fy = m_rtClient.top + m_rtClient.height / 2;
+    TransformTo(nullptr, fx, fy);
+
+    m_bUpFormHandler = fy > m_rtProxy.top;
+    if (m_bUpFormHandler) {
+      m_rtHandler.Set(0, 0, m_rtList.width, m_fComboFormHandler);
+      m_rtList.top = m_fComboFormHandler;
+    } else {
+      m_rtHandler.Set(0, m_rtList.height, m_rtList.width, m_fComboFormHandler);
+    }
+  }
+  m_pComboBoxProxy->SetWidgetRect(m_rtProxy);
+  m_pComboBoxProxy->Update();
+  m_pListBox->SetWidgetRect(m_rtList);
+  m_pListBox->Update();
+
+  CFWL_EvtCmbPreDropDown ev;
+  ev.m_pSrcTarget = this;
+  DispatchEvent(&ev);
+
+  m_fItemHeight = m_pListBox->GetItemHeight();
+  m_pListBox->SetFocus(true);
+  m_pComboBoxProxy->DoModal();
+  m_pListBox->SetFocus(false);
 }
 
 void IFWL_ComboBox::MatchEditText() {
@@ -473,9 +409,8 @@
   int32_t iMatch = m_pListBox->MatchItem(wsText);
   if (iMatch != m_iCurSel) {
     m_pListBox->ChangeSelected(iMatch);
-    if (iMatch >= 0) {
+    if (iMatch >= 0)
       SyncEditText(iMatch);
-    }
   } else if (iMatch >= 0) {
     m_pEdit->SetSelected();
   }
@@ -494,35 +429,37 @@
 }
 
 void IFWL_ComboBox::Layout() {
-  if (m_pWidgetMgr->IsFormDisabled()) {
+  if (m_pWidgetMgr->IsFormDisabled())
     return DisForm_Layout();
-  }
+
   GetClientRect(m_rtClient);
   FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
       GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
   if (!pFWidth)
     return;
+
   FX_FLOAT fBtn = *pFWidth;
   m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn,
               m_rtClient.height);
-  bool bIsDropDown = IsDropDownStyle();
-  if (bIsDropDown && m_pEdit) {
-    CFX_RectF rtEdit;
-    rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn,
-               m_rtClient.height);
-    m_pEdit->SetWidgetRect(rtEdit);
-    if (m_iCurSel >= 0) {
-      CFX_WideString wsText;
-      IFWL_ComboBoxDP* pData =
-          static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
-      CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
-      m_pListBox->GetItemText(hItem, wsText);
-      m_pEdit->LockUpdate();
-      m_pEdit->SetText(wsText);
-      m_pEdit->UnlockUpdate();
-    }
-    m_pEdit->Update();
+  if (!IsDropDownStyle() || !m_pEdit)
+    return;
+
+  CFX_RectF rtEdit;
+  rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn,
+             m_rtClient.height);
+  m_pEdit->SetWidgetRect(rtEdit);
+
+  if (m_iCurSel >= 0) {
+    CFX_WideString wsText;
+    IFWL_ComboBoxDP* pData =
+        static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
+    CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
+    m_pListBox->GetItemText(hItem, wsText);
+    m_pEdit->LockUpdate();
+    m_pEdit->SetText(wsText);
+    m_pEdit->UnlockUpdate();
   }
+  m_pEdit->Update();
 }
 
 void IFWL_ComboBox::ResetTheme() {
@@ -540,9 +477,9 @@
 void IFWL_ComboBox::ResetEditAlignment() {
   if (!m_pEdit)
     return;
-  uint32_t dwStylExes = m_pProperties->m_dwStyleExes;
+
   uint32_t dwAdd = 0;
-  switch (dwStylExes & FWL_STYLEEXT_CMB_EditHAlignMask) {
+  switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_EditHAlignMask) {
     case FWL_STYLEEXT_CMB_EditHCenter: {
       dwAdd |= FWL_STYLEEXT_EDT_HCenter;
       break;
@@ -553,7 +490,7 @@
     }
     default: { dwAdd |= FWL_STYLEEXT_EDT_HNear; }
   }
-  switch (dwStylExes & FWL_STYLEEXT_CMB_EditVAlignMask) {
+  switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_EditVAlignMask) {
     case FWL_STYLEEXT_CMB_EditVCenter: {
       dwAdd |= FWL_STYLEEXT_EDT_VCenter;
       break;
@@ -562,14 +499,16 @@
       dwAdd |= FWL_STYLEEXT_EDT_VFar;
       break;
     }
-    default: { dwAdd |= FWL_STYLEEXT_EDT_VNear; }
+    default: {
+      dwAdd |= FWL_STYLEEXT_EDT_VNear;
+      break;
+    }
   }
-  if (dwStylExes & FWL_STYLEEXT_CMB_EditJustified) {
+  if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_EditJustified)
     dwAdd |= FWL_STYLEEXT_EDT_Justified;
-  }
-  if (dwStylExes & FWL_STYLEEXT_CMB_EditDistributed) {
+  if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_EditDistributed)
     dwAdd |= FWL_STYLEEXT_EDT_Distributed;
-  }
+
   m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask |
                                      FWL_STYLEEXT_EDT_HAlignModeMask |
                                      FWL_STYLEEXT_EDT_VAlignMask);
@@ -578,16 +517,21 @@
 void IFWL_ComboBox::ResetListItemAlignment() {
   if (!m_pListBox)
     return;
-  uint32_t dwStylExes = m_pProperties->m_dwStyleExes;
+
   uint32_t dwAdd = 0;
-  switch (dwStylExes & FWL_STYLEEXT_CMB_ListItemAlignMask) {
+  switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemAlignMask) {
     case FWL_STYLEEXT_CMB_ListItemCenterAlign: {
       dwAdd |= FWL_STYLEEXT_LTB_CenterAlign;
+      break;
     }
     case FWL_STYLEEXT_CMB_ListItemRightAlign: {
       dwAdd |= FWL_STYLEEXT_LTB_RightAlign;
+      break;
     }
-    default: { dwAdd |= FWL_STYLEEXT_LTB_LeftAlign; }
+    default: {
+      dwAdd |= FWL_STYLEEXT_LTB_LeftAlign;
+      break;
+    }
   }
   m_pListBox->ModifyStylesEx(dwAdd, FWL_STYLEEXT_CMB_ListItemAlignMask);
 }
@@ -596,28 +540,30 @@
   IFWL_ComboBoxDP* pDatas =
       static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
   m_iCurSel = pDatas->GetItemIndex(this, m_pListBox->GetSelItem(0));
-  bool bDropDown = IsDropDownStyle();
-  if (bDropDown) {
-    IFWL_ComboBoxDP* pData =
-        static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
-    CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
-    if (hItem) {
-      CFX_WideString wsText;
-      pData->GetItemText(this, hItem, wsText);
-      if (m_pEdit) {
-        m_pEdit->SetText(wsText);
-        m_pEdit->Update();
-        m_pEdit->SetSelected();
-      }
-      CFWL_EvtCmbSelChanged ev;
-      ev.bLButtonUp = bLButtonUp;
-      ev.m_pSrcTarget = this;
-      ev.iArraySels.Add(m_iCurSel);
-      DispatchEvent(&ev);
-    }
-  } else {
+  if (!IsDropDownStyle()) {
     Repaint(&m_rtClient);
+    return;
   }
+
+  IFWL_ComboBoxDP* pData =
+      static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
+  CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
+  if (!hItem)
+    return;
+
+  CFX_WideString wsText;
+  pData->GetItemText(this, hItem, wsText);
+  if (m_pEdit) {
+    m_pEdit->SetText(wsText);
+    m_pEdit->Update();
+    m_pEdit->SetSelected();
+  }
+
+  CFWL_EvtCmbSelChanged ev;
+  ev.bLButtonUp = bLButtonUp;
+  ev.m_pSrcTarget = this;
+  ev.iArraySels.Add(m_iCurSel);
+  DispatchEvent(&ev);
 }
 
 void IFWL_ComboBox::InitProxyForm() {
@@ -631,6 +577,8 @@
   prop->m_dwStyles = FWL_WGTSTYLE_Popup;
   prop->m_dwStates = FWL_WGTSTATE_Invisible;
 
+  // TODO(dsinclair): Does this leak? I don't see a delete, but I'm not sure
+  // if the SetParent call is going to transfer ownership.
   m_pComboBoxProxy = new IFWL_ComboBoxProxy(this, m_pOwnerApp, std::move(prop),
                                             m_pListBox.get());
   m_pListBox->SetParent(m_pComboBoxProxy);
@@ -646,7 +594,9 @@
   prop->m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
   prop->m_dwStates = FWL_WGTSTATE_Invisible;
   prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
-  m_pListBox.reset(new IFWL_ComboList(m_pOwnerApp, std::move(prop), this));
+
+  m_pListBox =
+      pdfium::MakeUnique<IFWL_ComboList>(m_pOwnerApp, std::move(prop), this);
 }
 
 void IFWL_ComboBox::DisForm_InitComboEdit() {
@@ -656,32 +606,35 @@
   auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>();
   prop->m_pParent = this;
   prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
-  m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, std::move(prop), this));
+
+  m_pEdit =
+      pdfium::MakeUnique<IFWL_ComboEdit>(m_pOwnerApp, std::move(prop), this);
   m_pEdit->SetOuter(this);
 }
 
 void IFWL_ComboBox::DisForm_ShowDropList(bool bActivate) {
-  bool bDropList = DisForm_IsDropListVisible();
-  if (bDropList == bActivate) {
+  if (DisForm_IsDropListVisible() == bActivate)
     return;
-  }
+
   if (bActivate) {
     CFWL_EvtCmbPreDropDown preEvent;
     preEvent.m_pSrcTarget = this;
     DispatchEvent(&preEvent);
+
     IFWL_ComboList* pComboList = m_pListBox.get();
     int32_t iItems = pComboList->CountItems();
-    if (iItems < 1) {
+    if (iItems < 1)
       return;
-    }
+
     ResetListItemAlignment();
     pComboList->ChangeSelected(m_iCurSel);
+
     FX_FLOAT fItemHeight = pComboList->CalcItemHeight();
     FX_FLOAT fBorder = GetBorderSize();
     FX_FLOAT fPopupMin = 0.0f;
-    if (iItems > 3) {
+    if (iItems > 3)
       fPopupMin = fItemHeight * 3 + fBorder * 2;
-    }
+
     FX_FLOAT fPopupMax = fItemHeight * iItems + fBorder * 2;
     CFX_RectF rtList;
     rtList.left = m_rtClient.left;
@@ -689,17 +642,20 @@
     rtList.top = 0;
     rtList.height = 0;
     GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, rtList);
+
     m_pListBox->SetWidgetRect(rtList);
     m_pListBox->Update();
   } else {
     SetFocus(true);
   }
+
   m_pListBox->SetStates(FWL_WGTSTATE_Invisible, !bActivate);
   if (bActivate) {
     CFWL_EvtCmbPostDropDown postEvent;
     postEvent.m_pSrcTarget = this;
     DispatchEvent(&postEvent);
   }
+
   CFX_RectF rect;
   m_pListBox->GetWidgetRect(rect);
   rect.Inflate(2, 2);
@@ -713,23 +669,22 @@
 
   bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
   bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
+
   dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown;
   m_pProperties->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown;
-  if (bAddDropDown) {
+
+  if (bAddDropDown)
     m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly);
-  } else if (bDelDropDown) {
+  else if (bDelDropDown)
     m_pEdit->ModifyStylesEx(FWL_STYLEEXT_EDT_ReadOnly, 0);
-  }
   IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
 }
 
 void IFWL_ComboBox::DisForm_Update() {
-  if (m_iLock) {
+  if (m_iLock)
     return;
-  }
-  if (m_pEdit) {
+  if (m_pEdit)
     ResetEditAlignment();
-  }
   ResetTheme();
   Layout();
 }
@@ -755,10 +710,9 @@
   IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
   CFX_Matrix mtOrg;
   mtOrg.Set(1, 0, 0, 1, 0, 0);
-  if (pMatrix) {
+  if (pMatrix)
     mtOrg = *pMatrix;
-  }
-  bool bListShowed = m_pListBox && DisForm_IsDropListVisible();
+
   pGraphics->SaveGraphState();
   pGraphics->ConcatMatrix(&mtOrg);
   if (!m_rtBtn.IsEmpty(0.1f)) {
@@ -771,6 +725,7 @@
     pTheme->DrawBackground(&param);
   }
   pGraphics->RestoreGraphState();
+
   if (m_pEdit) {
     CFX_RectF rtEdit;
     m_pEdit->GetWidgetRect(rtEdit);
@@ -779,7 +734,7 @@
     mt.Concat(mtOrg);
     m_pEdit->DrawWidget(pGraphics, &mt);
   }
-  if (bListShowed) {
+  if (m_pListBox && DisForm_IsDropListVisible()) {
     CFX_RectF rtList;
     m_pListBox->GetWidgetRect(rtList);
     CFX_Matrix mt;
@@ -789,14 +744,15 @@
   }
 }
 
-void IFWL_ComboBox::DisForm_GetBBox(CFX_RectF& rect) {
+void IFWL_ComboBox::DisForm_GetBBox(CFX_RectF& rect) const {
   rect = m_pProperties->m_rtWidget;
-  if (m_pListBox && DisForm_IsDropListVisible()) {
-    CFX_RectF rtList;
-    m_pListBox->GetWidgetRect(rtList);
-    rtList.Offset(rect.left, rect.top);
-    rect.Union(rtList);
-  }
+  if (!m_pListBox || !DisForm_IsDropListVisible())
+    return;
+
+  CFX_RectF rtList;
+  m_pListBox->GetWidgetRect(rtList);
+  rtList.Offset(rect.left, rect.top);
+  rect.Union(rtList);
 }
 
 void IFWL_ComboBox::DisForm_Layout() {
@@ -806,36 +762,40 @@
       GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
   if (!pFWidth)
     return;
+
   FX_FLOAT borderWidth = 1;
   FX_FLOAT fBtn = *pFWidth;
   if (!(GetStylesEx() & FWL_STYLEEXT_CMB_ReadOnly)) {
     m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top + borderWidth,
                 fBtn - borderWidth, m_rtClient.height - 2 * borderWidth);
   }
+
   CFX_RectF* pUIMargin =
       static_cast<CFX_RectF*>(GetThemeCapacity(CFWL_WidgetCapacity::UIMargin));
   if (pUIMargin) {
     m_rtContent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
                         pUIMargin->height);
   }
-  bool bIsDropDown = IsDropDownStyle();
-  if (bIsDropDown && m_pEdit) {
-    CFX_RectF rtEdit;
-    rtEdit.Set(m_rtContent.left, m_rtContent.top, m_rtContent.width - fBtn,
-               m_rtContent.height);
-    m_pEdit->SetWidgetRect(rtEdit);
-    if (m_iCurSel >= 0) {
-      CFX_WideString wsText;
-      IFWL_ComboBoxDP* pData =
-          static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
-      CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
-      m_pListBox->GetItemText(hItem, wsText);
-      m_pEdit->LockUpdate();
-      m_pEdit->SetText(wsText);
-      m_pEdit->UnlockUpdate();
-    }
-    m_pEdit->Update();
+
+  if (!IsDropDownStyle() || !m_pEdit)
+    return;
+
+  CFX_RectF rtEdit;
+  rtEdit.Set(m_rtContent.left, m_rtContent.top, m_rtContent.width - fBtn,
+             m_rtContent.height);
+  m_pEdit->SetWidgetRect(rtEdit);
+
+  if (m_iCurSel >= 0) {
+    CFX_WideString wsText;
+    IFWL_ComboBoxDP* pData =
+        static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
+    CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
+    m_pListBox->GetItemText(hItem, wsText);
+    m_pEdit->LockUpdate();
+    m_pEdit->SetText(wsText);
+    m_pEdit->UnlockUpdate();
   }
+  m_pEdit->Update();
 }
 
 void IFWL_ComboBox::OnProcessMessage(CFWL_Message* pMessage) {
@@ -919,47 +879,46 @@
 }
 
 void IFWL_ComboBox::OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
-  IFWL_Widget* pDstTarget = pMsg->m_pDstTarget;
-  IFWL_Widget* pSrcTarget = pMsg->m_pSrcTarget;
-  bool bDropDown = IsDropDownStyle();
   if (bSet) {
     m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
-    if (bDropDown && pSrcTarget != m_pListBox.get()) {
+    if (IsDropDownStyle() && pMsg->m_pSrcTarget != m_pListBox.get()) {
       if (!m_pEdit)
         return;
       m_pEdit->SetSelected();
-    } else {
-      Repaint(&m_rtClient);
+      return;
     }
-  } else {
-    m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
-    if (bDropDown && pDstTarget != m_pListBox.get()) {
-      if (!m_pEdit)
-        return;
-      m_pEdit->FlagFocus(false);
-      m_pEdit->ClearSelected();
-    } else {
-      Repaint(&m_rtClient);
-    }
+
+    Repaint(&m_rtClient);
+    return;
   }
+
+  m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+  if (!IsDropDownStyle() || pMsg->m_pDstTarget == m_pListBox.get()) {
+    Repaint(&m_rtClient);
+    return;
+  }
+  if (!m_pEdit)
+    return;
+
+  m_pEdit->FlagFocus(false);
+  m_pEdit->ClearSelected();
 }
 
 void IFWL_ComboBox::OnLButtonDown(CFWL_MsgMouse* pMsg) {
   if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
     return;
 
-  bool bDropDown = IsDropDownStyle();
-  CFX_RectF& rtBtn = bDropDown ? m_rtBtn : m_rtClient;
-  bool bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy);
-  if (!bClickBtn)
+  CFX_RectF& rtBtn = IsDropDownStyle() ? m_rtBtn : m_rtClient;
+  if (!rtBtn.Contains(pMsg->m_fx, pMsg->m_fy))
     return;
 
-  if (bDropDown && m_pEdit)
+  if (IsDropDownStyle() && m_pEdit)
     MatchEditText();
 
   m_bLButtonDown = true;
   m_iBtnState = CFWL_PartState_Pressed;
   Repaint(&m_rtClient);
+
   ShowDropList(true);
   m_iBtnState = CFWL_PartState_Normal;
   Repaint(&m_rtClient);
@@ -1052,8 +1011,7 @@
     return;
   }
 
-  bool bDropDown = IsDropDownStyle();
-  if (bDropDown)
+  if (IsDropDownStyle())
     m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
 }
 
diff --git a/xfa/fwl/core/ifwl_combobox.h b/xfa/fwl/core/ifwl_combobox.h
index 8332a79..065d947 100644
--- a/xfa/fwl/core/ifwl_combobox.h
+++ b/xfa/fwl/core/ifwl_combobox.h
@@ -7,6 +7,8 @@
 #ifndef XFA_FWL_CORE_IFWL_COMBOBOX_H_
 #define XFA_FWL_CORE_IFWL_COMBOBOX_H_
 
+#include "xfa/fwl/core/ifwl_comboboxproxy.h"
+#include "xfa/fwl/core/ifwl_comboedit.h"
 #include "xfa/fwl/core/ifwl_combolist.h"
 #include "xfa/fwl/core/ifwl_form.h"
 #include "xfa/fwl/core/ifwl_listbox.h"
@@ -15,7 +17,6 @@
 class CFWL_WidgetProperties;
 class IFWL_ComboBox;
 class IFWL_ComboBoxProxy;
-class IFWL_ComboEdit;
 class IFWL_FormProxy;
 class IFWL_ListBox;
 class IFWL_Widget;
@@ -99,7 +100,7 @@
   void OnDrawWidget(CFX_Graphics* pGraphics,
                     const CFX_Matrix* pMatrix) override;
 
-  int32_t GetCurSel() const;
+  int32_t GetCurSel() const { return m_iCurSel; }
   void SetCurSel(int32_t iSel);
 
   void SetEditText(const CFX_WideString& wsText);
@@ -109,26 +110,34 @@
 
   void OpenDropDownList(bool bActivate);
 
-  bool EditCanUndo();
-  bool EditCanRedo();
-  bool EditUndo();
-  bool EditRedo();
-  bool EditCanCopy();
-  bool EditCanCut();
-  bool EditCanSelectAll();
-  bool EditCopy(CFX_WideString& wsCopy);
-  bool EditCut(CFX_WideString& wsCut);
-  bool EditPaste(const CFX_WideString& wsPaste);
-  bool EditSelectAll();
-  bool EditDelete();
-  bool EditDeSelect();
+  bool EditCanUndo() const { return m_pEdit->CanUndo(); }
+  bool EditCanRedo() const { return m_pEdit->CanRedo(); }
+  bool EditUndo() { return m_pEdit->Undo(); }
+  bool EditRedo() { return m_pEdit->Redo(); }
+  bool EditCanCopy() const { return m_pEdit->CountSelRanges() > 0; }
+  bool EditCanCut() const {
+    if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)
+      return false;
+    return EditCanCopy();
+  }
+  bool EditCanSelectAll() const { return m_pEdit->GetTextLength() > 0; }
+  bool EditCopy(CFX_WideString& wsCopy) const { return m_pEdit->Copy(wsCopy); }
+  bool EditCut(CFX_WideString& wsCut) { return m_pEdit->Cut(wsCut); }
+  bool EditPaste(const CFX_WideString& wsPaste) {
+    return m_pEdit->Paste(wsPaste);
+  }
+  void EditSelectAll() { m_pEdit->AddSelRange(0); }
+  void EditDelete() { m_pEdit->ClearText(); }
+  void EditDeSelect() { m_pEdit->ClearSelections(); }
 
-  void GetBBox(CFX_RectF& rect);
+  void GetBBox(CFX_RectF& rect) const;
   void EditModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved);
 
   void DrawStretchHandler(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix);
-  bool IsDropListVisible();
-
+  bool IsDropListVisible() const {
+    return m_pComboBoxProxy &&
+           !(m_pComboBoxProxy->GetStates() & FWL_WGTSTATE_Invisible);
+  }
   void ShowDropList(bool bActivate);
 
   IFWL_ComboEdit* GetComboEdit() const { return m_pEdit.get(); }
@@ -160,7 +169,7 @@
   FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy);
   void DisForm_DrawWidget(CFX_Graphics* pGraphics,
                           const CFX_Matrix* pMatrix = nullptr);
-  void DisForm_GetBBox(CFX_RectF& rect);
+  void DisForm_GetBBox(CFX_RectF& rect) const;
   void DisForm_Layout();
   void OnFocusChanged(CFWL_Message* pMsg, bool bSet = true);
   void OnLButtonDown(CFWL_MsgMouse* pMsg);
@@ -182,7 +191,7 @@
   CFX_RectF m_rtHandler;
   std::unique_ptr<IFWL_ComboEdit> m_pEdit;
   std::unique_ptr<IFWL_ComboList> m_pListBox;
-  IFWL_ComboBoxProxy* m_pComboBoxProxy;
+  IFWL_ComboBoxProxy* m_pComboBoxProxy;  // Can this be a unique_ptr?
   bool m_bLButtonDown;
   bool m_bUpFormHandler;
   int32_t m_iCurSel;
diff --git a/xfa/fwl/core/ifwl_comboboxproxy.cpp b/xfa/fwl/core/ifwl_comboboxproxy.cpp
index 2ca65d7..4bc1e29 100644
--- a/xfa/fwl/core/ifwl_comboboxproxy.cpp
+++ b/xfa/fwl/core/ifwl_comboboxproxy.cpp
@@ -87,23 +87,23 @@
   CFWL_NoteDriver* pDriver =
       static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
   pDriver->SetGrab(this, false);
-  if (m_bLButtonUpSelf) {
-    CFX_RectF rect;
-    GetWidgetRect(rect);
-    rect.left = rect.top = 0;
-    if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) &&
-        m_pComboBox->IsDropListVisible()) {
-      m_pComboBox->ShowDropList(false);
-    }
-  } else {
+  if (!m_bLButtonUpSelf) {
     m_bLButtonUpSelf = true;
+    return;
+  }
+
+  CFX_RectF rect;
+  GetWidgetRect(rect);
+  rect.left = rect.top = 0;
+  if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) &&
+      m_pComboBox->IsDropListVisible()) {
+    m_pComboBox->ShowDropList(false);
   }
 }
 
 void IFWL_ComboBoxProxy::OnFocusChanged(CFWL_MsgKillFocus* pMsg, bool bSet) {
   if (bSet)
     return;
-
   if (!pMsg->m_pSetFocus)
     m_pComboBox->ShowDropList(false);
 }
diff --git a/xfa/fwl/core/ifwl_comboedit.cpp b/xfa/fwl/core/ifwl_comboedit.cpp
index 0896ba7..73ca146 100644
--- a/xfa/fwl/core/ifwl_comboedit.cpp
+++ b/xfa/fwl/core/ifwl_comboedit.cpp
@@ -31,10 +31,11 @@
 void IFWL_ComboEdit::FlagFocus(bool bSet) {
   if (bSet) {
     m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
-  } else {
-    m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
-    ShowCaret(false);
+    return;
   }
+
+  m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+  ShowCaret(false);
 }
 
 void IFWL_ComboEdit::OnProcessMessage(CFWL_Message* pMessage) {
diff --git a/xfa/fwl/core/ifwl_combolist.cpp b/xfa/fwl/core/ifwl_combolist.cpp
index d021088..13847ee 100644
--- a/xfa/fwl/core/ifwl_combolist.cpp
+++ b/xfa/fwl/core/ifwl_combolist.cpp
@@ -19,11 +19,11 @@
 }
 
 int32_t IFWL_ComboList::MatchItem(const CFX_WideString& wsMatch) {
-  if (wsMatch.IsEmpty()) {
+  if (wsMatch.IsEmpty())
     return -1;
-  }
   if (!m_pProperties->m_pDataProvider)
     return -1;
+
   IFWL_ListBoxDP* pData =
       static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
   int32_t iCount = pData->CountItems(this);
@@ -32,9 +32,8 @@
     CFX_WideString wsText;
     pData->GetItemText(this, hItem, wsText);
     FX_STRSIZE pos = wsText.Find(wsMatch.c_str());
-    if (!pos) {
+    if (!pos)
       return i;
-    }
   }
   return -1;
 }
@@ -42,6 +41,7 @@
 void IFWL_ComboList::ChangeSelected(int32_t iSel) {
   if (!m_pProperties->m_pDataProvider)
     return;
+
   IFWL_ListBoxDP* pData =
       static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
   CFWL_ListItem* hItem = pData->GetItem(this, iSel);
@@ -49,9 +49,9 @@
   rtInvalidate.Reset();
   CFWL_ListItem* hOld = GetSelItem(0);
   int32_t iOld = pData->GetItemIndex(this, hOld);
-  if (iOld == iSel) {
+  if (iOld == iSel)
     return;
-  } else if (iOld > -1) {
+  if (iOld > -1) {
     GetItemRect(iOld, rtInvalidate);
     SetSelItem(hOld, false);
   }
@@ -62,9 +62,8 @@
     CFWL_ListItem* hSel = pData->GetItem(this, iSel);
     SetSelItem(hSel, true);
   }
-  if (!rtInvalidate.IsEmpty()) {
+  if (!rtInvalidate.IsEmpty())
     Repaint(&rtInvalidate);
-  }
 }
 
 int32_t IFWL_ComboList::CountItems() {
@@ -88,10 +87,6 @@
   pOwner->TransformTo(m_pOuter, fx, fy);
 }
 
-void IFWL_ComboList::SetFocus(bool bSet) {
-  IFWL_Widget::SetFocus(bSet);
-}
-
 void IFWL_ComboList::OnProcessMessage(CFWL_Message* pMessage) {
   if (!pMessage)
     return;
@@ -152,72 +147,71 @@
   }
 }
 
-int32_t IFWL_ComboList::OnDropListMouseMove(CFWL_MsgMouse* pMsg) {
+void IFWL_ComboList::OnDropListMouseMove(CFWL_MsgMouse* pMsg) {
   if (GetRTClient().Contains(pMsg->m_fx, pMsg->m_fy)) {
-    if (m_bNotifyOwner) {
+    if (m_bNotifyOwner)
       m_bNotifyOwner = false;
-    }
+
     IFWL_ScrollBar* vertSB = GetVertScrollBar();
     if (IsShowScrollBar(true) && vertSB) {
       CFX_RectF rect;
       vertSB->GetWidgetRect(rect);
-      if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
-        return 1;
-      }
+      if (rect.Contains(pMsg->m_fx, pMsg->m_fy))
+        return;
     }
+
     CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
-    if (hItem) {
-      if (!m_pProperties->m_pDataProvider)
-        return 0;
-      IFWL_ListBoxDP* pData =
-          static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
-      int32_t iSel = pData->GetItemIndex(this, hItem);
-      CFWL_EvtCmbHoverChanged event;
-      event.m_pSrcTarget = m_pOuter;
-      event.m_iCurHover = iSel;
-      DispatchEvent(&event);
-      ChangeSelected(iSel);
-    }
+    if (!hItem)
+      return;
+    if (!m_pProperties->m_pDataProvider)
+      return;
+
+    IFWL_ListBoxDP* pData =
+        static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
+    int32_t iSel = pData->GetItemIndex(this, hItem);
+    CFWL_EvtCmbHoverChanged event;
+    event.m_pSrcTarget = m_pOuter;
+    event.m_iCurHover = iSel;
+    DispatchEvent(&event);
+    ChangeSelected(iSel);
   } else if (m_bNotifyOwner) {
     ClientToOuter(pMsg->m_fx, pMsg->m_fy);
     IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
     pOuter->GetDelegate()->OnProcessMessage(pMsg);
   }
-  return 1;
 }
 
-int32_t IFWL_ComboList::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) {
+void IFWL_ComboList::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) {
   if (GetRTClient().Contains(pMsg->m_fx, pMsg->m_fy))
-    return 0;
+    return;
 
   IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
   pOuter->ShowDropList(false);
-  return 1;
 }
 
-int32_t IFWL_ComboList::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) {
+void IFWL_ComboList::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) {
   IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
   if (m_bNotifyOwner) {
     ClientToOuter(pMsg->m_fx, pMsg->m_fy);
     pOuter->GetDelegate()->OnProcessMessage(pMsg);
-  } else {
-    IFWL_ScrollBar* vertSB = GetVertScrollBar();
-    if (IsShowScrollBar(true) && vertSB) {
-      CFX_RectF rect;
-      vertSB->GetWidgetRect(rect);
-      if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
-        return 1;
-      }
-    }
-    pOuter->ShowDropList(false);
-    CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
-    if (hItem)
-      pOuter->ProcessSelChanged(true);
+    return;
   }
-  return 1;
+
+  IFWL_ScrollBar* vertSB = GetVertScrollBar();
+  if (IsShowScrollBar(true) && vertSB) {
+    CFX_RectF rect;
+    vertSB->GetWidgetRect(rect);
+    if (rect.Contains(pMsg->m_fx, pMsg->m_fy))
+      return;
+  }
+  pOuter->ShowDropList(false);
+
+  CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
+  if (hItem)
+    pOuter->ProcessSelChanged(true);
 }
 
-int32_t IFWL_ComboList::OnDropListKey(CFWL_MsgKey* pKey) {
+bool IFWL_ComboList::OnDropListKey(CFWL_MsgKey* pKey) {
   IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
   bool bPropagate = false;
   if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) {
@@ -226,15 +220,18 @@
       case FWL_VKEY_Return:
       case FWL_VKEY_Escape: {
         pOuter->ShowDropList(false);
-        return 1;
+        return true;
       }
       case FWL_VKEY_Up:
       case FWL_VKEY_Down: {
         OnDropListKeyDown(pKey);
         pOuter->ProcessSelChanged(false);
-        return 1;
+        return true;
       }
-      default: { bPropagate = true; }
+      default: {
+        bPropagate = true;
+        break;
+      }
     }
   } else if (pKey->m_dwCmd == FWL_KeyCommand::Char) {
     bPropagate = true;
@@ -242,9 +239,9 @@
   if (bPropagate) {
     pKey->m_pDstTarget = m_pOuter;
     pOuter->GetDelegate()->OnProcessMessage(pKey);
-    return 1;
+    return true;
   }
-  return 0;
+  return false;
 }
 
 void IFWL_ComboList::OnDropListKeyDown(CFWL_MsgKey* pKey) {
@@ -260,9 +257,9 @@
       CFWL_ListItem* hItem =
           pData->GetItem(this, pOuter->GetCurrentSelection());
       hItem = GetItem(hItem, dwKeyCode);
-      if (!hItem) {
+      if (!hItem)
         break;
-      }
+
       SetSelection(hItem, hItem, true);
       ScrollToVisible(hItem);
       CFX_RectF rtInvalidate;
diff --git a/xfa/fwl/core/ifwl_combolist.h b/xfa/fwl/core/ifwl_combolist.h
index 64ffbba..ff479cb 100644
--- a/xfa/fwl/core/ifwl_combolist.h
+++ b/xfa/fwl/core/ifwl_combolist.h
@@ -25,17 +25,16 @@
   void ChangeSelected(int32_t iSel);
   int32_t CountItems();
 
-  void SetFocus(bool bSet);
   void SetNotifyOwner(bool notify) { m_bNotifyOwner = notify; }
 
  private:
   void GetItemRect(int32_t nIndex, CFX_RectF& rtItem);
   void ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy);
   void OnDropListFocusChanged(CFWL_Message* pMsg, bool bSet);
-  int32_t OnDropListMouseMove(CFWL_MsgMouse* pMsg);
-  int32_t OnDropListLButtonDown(CFWL_MsgMouse* pMsg);
-  int32_t OnDropListLButtonUp(CFWL_MsgMouse* pMsg);
-  int32_t OnDropListKey(CFWL_MsgKey* pKey);
+  void OnDropListMouseMove(CFWL_MsgMouse* pMsg);
+  void OnDropListLButtonDown(CFWL_MsgMouse* pMsg);
+  void OnDropListLButtonUp(CFWL_MsgMouse* pMsg);
+  bool OnDropListKey(CFWL_MsgKey* pKey);
   void OnDropListKeyDown(CFWL_MsgKey* pKey);
 
   bool m_bNotifyOwner;
diff --git a/xfa/fwl/core/ifwl_datetimeedit.cpp b/xfa/fwl/core/ifwl_datetimeedit.cpp
index c2aa6e3..f612f50 100644
--- a/xfa/fwl/core/ifwl_datetimeedit.cpp
+++ b/xfa/fwl/core/ifwl_datetimeedit.cpp
@@ -32,24 +32,26 @@
 
 void IFWL_DateTimeEdit::DisForm_OnProcessMessage(CFWL_Message* pMessage) {
   CFWL_MessageType dwHashCode = pMessage->GetClassID();
-  if (m_pWidgetMgr->IsFormDisabled()) {
-    if (dwHashCode == CFWL_MessageType::Mouse) {
-      CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage);
-      if (pMouse->m_dwCmd == FWL_MouseCommand::LeftButtonDown ||
-          pMouse->m_dwCmd == FWL_MouseCommand::RightButtonDown) {
-        if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
-          m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+  if (!m_pWidgetMgr->IsFormDisabled() ||
+      dwHashCode != CFWL_MessageType::Mouse) {
+    IFWL_Edit::OnProcessMessage(pMessage);
+    return;
+  }
 
-        IFWL_DateTimePicker* pDateTime =
-            static_cast<IFWL_DateTimePicker*>(m_pOuter);
-        if (pDateTime->IsMonthCalendarVisible()) {
-          CFX_RectF rtInvalidate;
-          pDateTime->GetWidgetRect(rtInvalidate);
-          pDateTime->ShowMonthCalendar(false);
-          rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top);
-          pDateTime->Repaint(&rtInvalidate);
-        }
-      }
+  CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage);
+  if (pMouse->m_dwCmd == FWL_MouseCommand::LeftButtonDown ||
+      pMouse->m_dwCmd == FWL_MouseCommand::RightButtonDown) {
+    if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
+      m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+
+    IFWL_DateTimePicker* pDateTime =
+        static_cast<IFWL_DateTimePicker*>(m_pOuter);
+    if (pDateTime->IsMonthCalendarVisible()) {
+      CFX_RectF rtInvalidate;
+      pDateTime->GetWidgetRect(rtInvalidate);
+      pDateTime->ShowMonthCalendar(false);
+      rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top);
+      pDateTime->Repaint(&rtInvalidate);
     }
   }
   IFWL_Edit::OnProcessMessage(pMessage);
diff --git a/xfa/fwl/core/ifwl_datetimepicker.cpp b/xfa/fwl/core/ifwl_datetimepicker.cpp
index 3ecaf68..71ff7ef 100644
--- a/xfa/fwl/core/ifwl_datetimepicker.cpp
+++ b/xfa/fwl/core/ifwl_datetimepicker.cpp
@@ -11,7 +11,6 @@
 #include "xfa/fwl/core/cfwl_themebackground.h"
 #include "xfa/fwl/core/cfwl_widgetmgr.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/ifwl_datetimeedit.h"
 #include "xfa/fwl/core/ifwl_formproxy.h"
 #include "xfa/fwl/core/ifwl_spinbutton.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
@@ -74,12 +73,13 @@
     DisForm_GetWidgetRect(rect, bAutoSize);
     return;
   }
-  if (bAutoSize) {
-    rect.Set(0, 0, kDateTimePickerWidth, kDateTimePickerHeight);
-    IFWL_Widget::GetWidgetRect(rect, true);
-  } else {
+  if (!bAutoSize) {
     rect = m_pProperties->m_rtWidget;
+    return;
   }
+
+  rect.Set(0, 0, kDateTimePickerWidth, kDateTimePickerHeight);
+  IFWL_Widget::GetWidgetRect(rect, true);
 }
 
 void IFWL_DateTimePicker::Update() {
@@ -87,35 +87,36 @@
     DisForm_Update();
     return;
   }
-  if (m_iLock) {
+  if (m_iLock)
     return;
-  }
-  if (!m_pProperties->m_pThemeProvider) {
+  if (!m_pProperties->m_pThemeProvider)
     m_pProperties->m_pThemeProvider = GetAvailableTheme();
-  }
+
   m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider);
   GetClientRect(m_rtClient);
   FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
       GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
   if (!pFWidth)
     return;
+
   FX_FLOAT fBtn = *pFWidth;
   m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn - 1,
               m_rtClient.height - 1);
+
   CFX_RectF rtEdit;
   rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn,
              m_rtClient.height);
   m_pEdit->SetWidgetRect(rtEdit);
   ResetEditAlignment();
   m_pEdit->Update();
-  if (!(m_pMonthCal->GetThemeProvider())) {
+  if (!(m_pMonthCal->GetThemeProvider()))
     m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
-  }
   if (m_pProperties->m_pDataProvider) {
     IFWL_DateTimePickerDP* pData =
         static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider);
     pData->GetToday(this, m_iCurYear, m_iCurMonth, m_iCurDay);
   }
+
   CFX_RectF rtMonthCal;
   m_pMonthCal->GetWidgetRect(rtMonthCal, true);
   CFX_RectF rtPopUp;
@@ -126,14 +127,6 @@
   return;
 }
 
-int32_t IFWL_DateTimePicker::CountSelRanges() {
-  return m_pEdit->CountSelRanges();
-}
-
-int32_t IFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) {
-  return m_pEdit->GetSelRange(nIndex, nStart);
-}
-
 FWL_WidgetHit IFWL_DateTimePicker::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
   if (m_pWidgetMgr->IsFormDisabled())
     return DisForm_HitTest(fx, fy);
@@ -154,16 +147,14 @@
     return;
   if (!m_pProperties->m_pThemeProvider)
     return;
+
   IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
-  if (HasBorder()) {
+  if (HasBorder())
     DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
-  }
-  if (HasEdge()) {
+  if (HasEdge())
     DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
-  }
-  if (!m_rtBtn.IsEmpty()) {
+  if (!m_rtBtn.IsEmpty())
     DrawDropDownButton(pGraphics, pTheme, pMatrix);
-  }
   if (m_pWidgetMgr->IsFormDisabled()) {
     DisForm_DrawWidget(pGraphics, pMatrix);
     return;
@@ -217,11 +208,12 @@
     m_pEdit->GetText(wsText, nStart, nCount);
 }
 
-void IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) {
+void IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) const {
   if (m_pWidgetMgr->IsFormDisabled()) {
     DisForm_GetBBox(rect);
     return;
   }
+
   rect = m_pProperties->m_rtWidget;
   if (IsMonthCalendarVisible()) {
     CFX_RectF rtMonth;
@@ -232,10 +224,6 @@
   }
 }
 
-void IFWL_DateTimePicker::SetEditLimit(int32_t nLimit) {
-  m_pEdit->SetLimit(nLimit);
-}
-
 void IFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded,
                                              uint32_t dwStylesExRemoved) {
   m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
@@ -257,7 +245,6 @@
   param.m_rtPart = m_rtBtn;
   if (pMatrix)
     param.m_matrix.Concat(*pMatrix);
-
   pTheme->DrawBackground(&param);
 }
 
@@ -271,43 +258,41 @@
   } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_LongDateFormat) ==
              FWL_STYLEEXT_DTP_LongDateFormat) {
     wsText.Format(L"%d Year %d Month %d Day", iYear, iMonth, iDay);
-  } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat) ==
-             FWL_STYLEEXT_DTP_TimeFormat) {
   }
 }
 
 void IFWL_DateTimePicker::ShowMonthCalendar(bool bActivate) {
-  if (m_pWidgetMgr->IsFormDisabled()) {
+  if (m_pWidgetMgr->IsFormDisabled())
     return DisForm_ShowMonthCalendar(bActivate);
-  }
-  if (IsMonthCalendarVisible() == bActivate) {
+  if (IsMonthCalendarVisible() == bActivate)
+    return;
+  if (!m_pForm)
+    InitProxyForm();
+
+  if (!bActivate) {
+    m_pForm->EndDoModal();
     return;
   }
-  if (!m_pForm) {
-    InitProxyForm();
-  }
-  if (bActivate) {
-    CFX_RectF rtMonth;
-    m_pMonthCal->GetWidgetRect(rtMonth);
-    CFX_RectF rtAnchor;
-    rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width,
-                 m_pProperties->m_rtWidget.height);
-    GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth);
-    m_pForm->SetWidgetRect(rtMonth);
-    rtMonth.left = rtMonth.top = 0;
-    m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate);
-    m_pMonthCal->SetWidgetRect(rtMonth);
-    m_pMonthCal->Update();
-    m_pForm->DoModal();
-  } else {
-    m_pForm->EndDoModal();
-  }
+
+  CFX_RectF rtMonth;
+  m_pMonthCal->GetWidgetRect(rtMonth);
+
+  CFX_RectF rtAnchor;
+  rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width,
+               m_pProperties->m_rtWidget.height);
+  GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth);
+  m_pForm->SetWidgetRect(rtMonth);
+
+  rtMonth.left = rtMonth.top = 0;
+  m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate);
+  m_pMonthCal->SetWidgetRect(rtMonth);
+  m_pMonthCal->Update();
+  m_pForm->DoModal();
 }
 
-bool IFWL_DateTimePicker::IsMonthCalendarVisible() {
-  if (m_pWidgetMgr->IsFormDisabled()) {
+bool IFWL_DateTimePicker::IsMonthCalendarVisible() const {
+  if (m_pWidgetMgr->IsFormDisabled())
     return DisForm_IsMonthCalendarVisible();
-  }
   if (!m_pForm)
     return false;
   return !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible);
@@ -316,9 +301,9 @@
 void IFWL_DateTimePicker::ResetEditAlignment() {
   if (!m_pEdit)
     return;
-  uint32_t dwStylExes = m_pProperties->m_dwStyleExes;
+
   uint32_t dwAdd = 0;
-  switch (dwStylExes & FWL_STYLEEXT_DTP_EditHAlignMask) {
+  switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_EditHAlignMask) {
     case FWL_STYLEEXT_DTP_EditHCenter: {
       dwAdd |= FWL_STYLEEXT_EDT_HCenter;
       break;
@@ -327,9 +312,12 @@
       dwAdd |= FWL_STYLEEXT_EDT_HFar;
       break;
     }
-    default: { dwAdd |= FWL_STYLEEXT_EDT_HNear; }
+    default: {
+      dwAdd |= FWL_STYLEEXT_EDT_HNear;
+      break;
+    }
   }
-  switch (dwStylExes & FWL_STYLEEXT_DTP_EditVAlignMask) {
+  switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_EditVAlignMask) {
     case FWL_STYLEEXT_DTP_EditVCenter: {
       dwAdd |= FWL_STYLEEXT_EDT_VCenter;
       break;
@@ -338,14 +326,16 @@
       dwAdd |= FWL_STYLEEXT_EDT_VFar;
       break;
     }
-    default: { dwAdd |= FWL_STYLEEXT_EDT_VNear; }
+    default: {
+      dwAdd |= FWL_STYLEEXT_EDT_VNear;
+      break;
+    }
   }
-  if (dwStylExes & FWL_STYLEEXT_DTP_EditJustified) {
+  if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_EditJustified)
     dwAdd |= FWL_STYLEEXT_EDT_Justified;
-  }
-  if (dwStylExes & FWL_STYLEEXT_DTP_EditDistributed) {
+  if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_EditDistributed)
     dwAdd |= FWL_STYLEEXT_EDT_Distributed;
-  }
+
   m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask |
                                      FWL_STYLEEXT_EDT_HAlignModeMask |
                                      FWL_STYLEEXT_EDT_VAlignMask);
@@ -357,11 +347,13 @@
   m_iYear = iYear;
   m_iMonth = iMonth;
   m_iDay = iDay;
+
   CFX_WideString wsText;
   FormatDateString(m_iYear, m_iMonth, m_iDay, wsText);
   m_pEdit->SetText(wsText);
   m_pEdit->Update();
   Repaint(&m_rtClient);
+
   CFWL_Event_DtpSelectChanged ev;
   ev.m_pSrcTarget = this;
   ev.iYear = m_iYear;
@@ -381,22 +373,21 @@
   prop->m_dwStates = FWL_WGTSTATE_Invisible;
   prop->m_pOwner = this;
 
-  m_pForm.reset(
-      new IFWL_FormProxy(m_pOwnerApp, std::move(prop), m_pMonthCal.get()));
+  m_pForm = pdfium::MakeUnique<IFWL_FormProxy>(m_pOwnerApp, std::move(prop),
+                                               m_pMonthCal.get());
   m_pMonthCal->SetParent(m_pForm.get());
 }
 
-bool IFWL_DateTimePicker::DisForm_IsMonthCalendarVisible() {
+bool IFWL_DateTimePicker::DisForm_IsMonthCalendarVisible() const {
   if (!m_pMonthCal)
     return false;
   return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible);
 }
 
 void IFWL_DateTimePicker::DisForm_ShowMonthCalendar(bool bActivate) {
-  bool bShowed = IsMonthCalendarVisible();
-  if (bShowed == bActivate) {
+  if (IsMonthCalendarVisible() == bActivate)
     return;
-  }
+
   if (bActivate) {
     CFX_RectF rtMonthCal;
     m_pMonthCal->GetWidgetRect(rtMonthCal, true);
@@ -408,18 +399,19 @@
     rtMonthCal.top = rtAnchor.Height();
     GetPopupPos(fPopupMin, fPopupMax, rtAnchor, rtMonthCal);
     m_pMonthCal->SetWidgetRect(rtMonthCal);
-    if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0) {
+    if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0)
       m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay);
-    }
     m_pMonthCal->Update();
   }
   m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate);
+
   if (bActivate) {
     CFWL_MsgSetFocus msg;
     msg.m_pDstTarget = m_pMonthCal.get();
     msg.m_pSrcTarget = m_pEdit.get();
     m_pEdit->GetDelegate()->OnProcessMessage(&msg);
   }
+
   CFX_RectF rtInvalidate, rtCal;
   rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width,
                    m_pProperties->m_rtWidget.height);
@@ -429,7 +421,8 @@
   Repaint(&rtInvalidate);
 }
 
-FWL_WidgetHit IFWL_DateTimePicker::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+FWL_WidgetHit IFWL_DateTimePicker::DisForm_HitTest(FX_FLOAT fx,
+                                                   FX_FLOAT fy) const {
   CFX_RectF rect;
   rect.Set(0, 0, m_pProperties->m_rtWidget.width,
            m_pProperties->m_rtWidget.height);
@@ -447,11 +440,10 @@
   return FWL_WidgetHit::Unknown;
 }
 
-bool IFWL_DateTimePicker::DisForm_IsNeedShowButton() {
-  bool bFocus = m_pProperties->m_dwStates & FWL_WGTSTATE_Focused ||
-                m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused ||
-                m_pEdit->GetStates() & FWL_WGTSTATE_Focused;
-  return bFocus;
+bool IFWL_DateTimePicker::DisForm_IsNeedShowButton() const {
+  return m_pProperties->m_dwStates & FWL_WGTSTATE_Focused ||
+         m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused ||
+         m_pEdit->GetStates() & FWL_WGTSTATE_Focused;
 }
 
 void IFWL_DateTimePicker::DisForm_Update() {
@@ -465,14 +457,15 @@
   m_pEdit->SetWidgetRect(m_rtClient);
   ResetEditAlignment();
   m_pEdit->Update();
+
   if (!m_pMonthCal->GetThemeProvider())
     m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
-
   if (m_pProperties->m_pDataProvider) {
     IFWL_DateTimePickerDP* pData =
         static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider);
     pData->GetToday(this, m_iCurYear, m_iCurMonth, m_iCurDay);
   }
+
   FX_FLOAT* pWidth = static_cast<FX_FLOAT*>(
       GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
   if (!pWidth)
@@ -481,6 +474,7 @@
   m_fBtn = *pWidth;
   CFX_RectF rtMonthCal;
   m_pMonthCal->GetWidgetRect(rtMonthCal, true);
+
   CFX_RectF rtPopUp;
   rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight,
               rtMonthCal.width, rtMonthCal.height);
@@ -491,23 +485,21 @@
 void IFWL_DateTimePicker::DisForm_GetWidgetRect(CFX_RectF& rect,
                                                 bool bAutoSize) {
   rect = m_pProperties->m_rtWidget;
-  if (DisForm_IsNeedShowButton()) {
+  if (DisForm_IsNeedShowButton())
     rect.width += m_fBtn;
-  }
 }
 
-void IFWL_DateTimePicker::DisForm_GetBBox(CFX_RectF& rect) {
+void IFWL_DateTimePicker::DisForm_GetBBox(CFX_RectF& rect) const {
   rect = m_pProperties->m_rtWidget;
-  if (DisForm_IsNeedShowButton()) {
+  if (DisForm_IsNeedShowButton())
     rect.width += m_fBtn;
-  }
-  if (IsMonthCalendarVisible()) {
-    CFX_RectF rtMonth;
-    m_pMonthCal->GetWidgetRect(rtMonth);
-    rtMonth.Offset(m_pProperties->m_rtWidget.left,
-                   m_pProperties->m_rtWidget.top);
-    rect.Union(rtMonth);
-  }
+  if (!IsMonthCalendarVisible())
+    return;
+
+  CFX_RectF rtMonth;
+  m_pMonthCal->GetWidgetRect(rtMonth);
+  rtMonth.Offset(m_pProperties->m_rtWidget.left, m_pProperties->m_rtWidget.top);
+  rect.Union(rtMonth);
 }
 
 void IFWL_DateTimePicker::DisForm_DrawWidget(CFX_Graphics* pGraphics,
@@ -517,24 +509,23 @@
   if (m_pEdit) {
     CFX_RectF rtEdit;
     m_pEdit->GetWidgetRect(rtEdit);
+
     CFX_Matrix mt;
     mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top);
-    if (pMatrix) {
+    if (pMatrix)
       mt.Concat(*pMatrix);
-    }
     m_pEdit->DrawWidget(pGraphics, &mt);
   }
-  if (IsMonthCalendarVisible()) {
-    CFX_RectF rtMonth;
-    m_pMonthCal->GetWidgetRect(rtMonth);
-    CFX_Matrix mt;
-    mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top);
-    if (pMatrix) {
-      mt.Concat(*pMatrix);
-    }
-    m_pMonthCal->DrawWidget(pGraphics, &mt);
-  }
-  return;
+  if (!IsMonthCalendarVisible())
+    return;
+
+  CFX_RectF rtMonth;
+  m_pMonthCal->GetWidgetRect(rtMonth);
+  CFX_Matrix mt;
+  mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top);
+  if (pMatrix)
+    mt.Concat(*pMatrix);
+  m_pMonthCal->DrawWidget(pGraphics, &mt);
 }
 
 void IFWL_DateTimePicker::OnProcessMessage(CFWL_Message* pMessage) {
@@ -611,21 +602,23 @@
     return;
   if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
     SetFocus(true);
-  if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
-    if (IsMonthCalendarVisible()) {
-      ShowMonthCalendar(false);
-      CFWL_Event_DtpCloseUp ev;
-      DispatchEvent(&ev);
-    } else {
-      if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat)) {
-        ShowMonthCalendar(true);
-        CFWL_Event_DtpDropDown ev;
-        DispatchEvent(&ev);
-      }
-      m_bLBtnDown = true;
-      Repaint(&m_rtClient);
-    }
+  if (!m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy))
+    return;
+
+  if (IsMonthCalendarVisible()) {
+    ShowMonthCalendar(false);
+    CFWL_Event_DtpCloseUp ev;
+    DispatchEvent(&ev);
+    return;
   }
+
+  if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat)) {
+    ShowMonthCalendar(true);
+    CFWL_Event_DtpDropDown ev;
+    DispatchEvent(&ev);
+  }
+  m_bLBtnDown = true;
+  Repaint(&m_rtClient);
 }
 
 void IFWL_DateTimePicker::OnLButtonUp(CFWL_MsgMouse* pMsg) {
@@ -643,7 +636,6 @@
 void IFWL_DateTimePicker::OnMouseMove(CFWL_MsgMouse* pMsg) {
   if (!m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy))
     m_iBtnState = CFWL_PartState_Normal;
-
   Repaint(&m_rtBtn);
 }
 
diff --git a/xfa/fwl/core/ifwl_datetimepicker.h b/xfa/fwl/core/ifwl_datetimepicker.h
index 5a40a05..b23fe88 100644
--- a/xfa/fwl/core/ifwl_datetimepicker.h
+++ b/xfa/fwl/core/ifwl_datetimepicker.h
@@ -10,6 +10,7 @@
 #include "xfa/fwl/core/cfwl_event.h"
 #include "xfa/fwl/core/cfwl_widgetproperties.h"
 #include "xfa/fwl/core/ifwl_dataprovider.h"
+#include "xfa/fwl/core/ifwl_datetimeedit.h"
 #include "xfa/fwl/core/ifwl_monthcalendar.h"
 #include "xfa/fwl/core/ifwl_widget.h"
 
@@ -90,14 +91,16 @@
                    int32_t nStart = 0,
                    int32_t nCount = -1) const;
 
-  int32_t CountSelRanges();
-  int32_t GetSelRange(int32_t nIndex, int32_t& nStart);
+  int32_t CountSelRanges() const { return m_pEdit->CountSelRanges(); }
+  int32_t GetSelRange(int32_t nIndex, int32_t& nStart) const {
+    return m_pEdit->GetSelRange(nIndex, nStart);
+  }
 
-  void GetBBox(CFX_RectF& rect);
-  void SetEditLimit(int32_t nLimit);
+  void GetBBox(CFX_RectF& rect) const;
+  void SetEditLimit(int32_t nLimit) { m_pEdit->SetLimit(nLimit); }
   void ModifyEditStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved);
 
-  bool IsMonthCalendarVisible();
+  bool IsMonthCalendarVisible() const;
   void ShowMonthCalendar(bool bActivate);
   void ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay);
 
@@ -114,13 +117,13 @@
   void ResetEditAlignment();
   void InitProxyForm();
 
-  bool DisForm_IsMonthCalendarVisible();
+  bool DisForm_IsMonthCalendarVisible() const;
   void DisForm_ShowMonthCalendar(bool bActivate);
-  FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy);
-  bool DisForm_IsNeedShowButton();
+  FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) const;
+  bool DisForm_IsNeedShowButton() const;
   void DisForm_Update();
   void DisForm_GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false);
-  void DisForm_GetBBox(CFX_RectF& rect);
+  void DisForm_GetBBox(CFX_RectF& rect) const;
   void DisForm_DrawWidget(CFX_Graphics* pGraphics,
                           const CFX_Matrix* pMatrix = nullptr);
   void DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet);
diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp
index 93e270d..e516ffd 100644
--- a/xfa/fxfa/app/xfa_ffchoicelist.cpp
+++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp
@@ -439,14 +439,14 @@
   return m_pDataAcc->IsChoiceListAllowTextEntry() &&
          ((CFWL_ComboBox*)m_pNormalWidget)->EditPaste(wsPaste);
 }
-bool CXFA_FFComboBox::SelectAll() {
-  return ((CFWL_ComboBox*)m_pNormalWidget)->EditSelectAll();
+void CXFA_FFComboBox::SelectAll() {
+  ((CFWL_ComboBox*)m_pNormalWidget)->EditSelectAll();
 }
-bool CXFA_FFComboBox::Delete() {
-  return ((CFWL_ComboBox*)m_pNormalWidget)->EditDelete();
+void CXFA_FFComboBox::Delete() {
+  ((CFWL_ComboBox*)m_pNormalWidget)->EditDelete();
 }
-bool CXFA_FFComboBox::DeSelect() {
-  return ((CFWL_ComboBox*)m_pNormalWidget)->EditDeSelect();
+void CXFA_FFComboBox::DeSelect() {
+  ((CFWL_ComboBox*)m_pNormalWidget)->EditDeSelect();
 }
 void CXFA_FFComboBox::SetItemState(int32_t nIndex, bool bSelected) {
   if (bSelected) {
diff --git a/xfa/fxfa/app/xfa_ffchoicelist.h b/xfa/fxfa/app/xfa_ffchoicelist.h
index 9ce6ccc..720807f 100644
--- a/xfa/fxfa/app/xfa_ffchoicelist.h
+++ b/xfa/fxfa/app/xfa_ffchoicelist.h
@@ -63,9 +63,9 @@
   bool Copy(CFX_WideString& wsCopy) override;
   bool Cut(CFX_WideString& wsCut) override;
   bool Paste(const CFX_WideString& wsPaste) override;
-  bool SelectAll() override;
-  bool Delete() override;
-  bool DeSelect() override;
+  void SelectAll() override;
+  void Delete() override;
+  void DeSelect() override;
 
   // IFWL_WidgetDelegate
   void OnProcessMessage(CFWL_Message* pMessage) override;
diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp
index 89b3053..07ba16c 100644
--- a/xfa/fxfa/app/xfa_ffwidget.cpp
+++ b/xfa/fxfa/app/xfa_ffwidget.cpp
@@ -304,15 +304,13 @@
 bool CXFA_FFWidget::Paste(const CFX_WideString& wsPaste) {
   return false;
 }
-bool CXFA_FFWidget::SelectAll() {
-  return false;
-}
-bool CXFA_FFWidget::Delete() {
-  return false;
-}
-bool CXFA_FFWidget::DeSelect() {
-  return false;
-}
+
+void CXFA_FFWidget::SelectAll() {}
+
+void CXFA_FFWidget::Delete() {}
+
+void CXFA_FFWidget::DeSelect() {}
+
 bool CXFA_FFWidget::GetSuggestWords(CFX_PointF pointf,
                                     std::vector<CFX_ByteString>& sSuggest) {
   return false;
diff --git a/xfa/fxfa/xfa_ffwidget.h b/xfa/fxfa/xfa_ffwidget.h
index a2aaee2..3c2af16 100644
--- a/xfa/fxfa/xfa_ffwidget.h
+++ b/xfa/fxfa/xfa_ffwidget.h
@@ -92,9 +92,9 @@
   virtual bool Copy(CFX_WideString& wsCopy);
   virtual bool Cut(CFX_WideString& wsCut);
   virtual bool Paste(const CFX_WideString& wsPaste);
-  virtual bool SelectAll();
-  virtual bool Delete();
-  virtual bool DeSelect();
+  virtual void SelectAll();
+  virtual void Delete();
+  virtual void DeSelect();
   virtual bool GetSuggestWords(CFX_PointF pointf,
                                std::vector<CFX_ByteString>& sSuggest);
   virtual bool ReplaceSpellCheckWord(CFX_PointF pointf,