Pass CFWL_Widget properties by const-ref. Then just copy the few words of data directly into the CFWL_Widget. Callers can now just use a stack-allocated copy and avoid a lot of heap allocation in the process. - Nest CFWL_WidgetProperties as CFWL_Widget::Properties. - Tidy a couple of boolean expressions. Change-Id: Idd388ea82883394805ed9f2b1ca067cbc7a1ee09 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/72810 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fwl/BUILD.gn b/xfa/fwl/BUILD.gn index a3778b2..bdb2e4a 100644 --- a/xfa/fwl/BUILD.gn +++ b/xfa/fwl/BUILD.gn
@@ -77,8 +77,6 @@ "cfwl_widget.h", "cfwl_widgetmgr.cpp", "cfwl_widgetmgr.h", - "cfwl_widgetproperties.cpp", - "cfwl_widgetproperties.h", "fwl_widgetdef.h", "fwl_widgethit.h", "ifwl_themeprovider.cpp",
diff --git a/xfa/fwl/cfwl_barcode.cpp b/xfa/fwl/cfwl_barcode.cpp index d77c18a..08233c2 100644 --- a/xfa/fwl/cfwl_barcode.cpp +++ b/xfa/fwl/cfwl_barcode.cpp
@@ -16,7 +16,7 @@ #include "xfa/fwl/theme/cfwl_utils.h" CFWL_Barcode::CFWL_Barcode(const CFWL_App* app) - : CFWL_Edit(app, std::make_unique<CFWL_WidgetProperties>(), nullptr) {} + : CFWL_Edit(app, Properties(), nullptr) {} CFWL_Barcode::~CFWL_Barcode() = default; @@ -37,7 +37,7 @@ if (!pGraphics) return; - if ((GetProperties()->m_dwStates & FWL_WGTSTATE_Focused) == 0) { + if ((m_Properties.m_dwStates & FWL_WGTSTATE_Focused) == 0) { GenerateBarcodeImageCache(); if (!m_pBarcodeEngine || m_eStatus != Status::kEncodeSuccess) return;
diff --git a/xfa/fwl/cfwl_caret.cpp b/xfa/fwl/cfwl_caret.cpp index a612cc3..f538329 100644 --- a/xfa/fwl/cfwl_caret.cpp +++ b/xfa/fwl/cfwl_caret.cpp
@@ -11,7 +11,7 @@ #include "xfa/fwl/cfwl_app.h" #include "xfa/fwl/cfwl_notedriver.h" #include "xfa/fwl/cfwl_themebackground.h" -#include "xfa/fwl/cfwl_widgetproperties.h" +#include "xfa/fwl/fwl_widgetdef.h" #include "xfa/fwl/ifwl_themeprovider.h" namespace { @@ -23,9 +23,9 @@ } // namespace CFWL_Caret::CFWL_Caret(const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, + const Properties& properties, CFWL_Widget* pOuter) - : CFWL_Widget(app, std::move(properties), pOuter) { + : CFWL_Widget(app, properties, pOuter) { SetStates(kStateHighlight); } @@ -60,7 +60,7 @@ void CFWL_Caret::DrawCaretBK(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) { - if (!(GetProperties()->m_dwStates & kStateHighlight)) + if (!(m_Properties.m_dwStates & kStateHighlight)) return; CFWL_ThemeBackground param;
diff --git a/xfa/fwl/cfwl_caret.h b/xfa/fwl/cfwl_caret.h index 834ea1b..f01eba8 100644 --- a/xfa/fwl/cfwl_caret.h +++ b/xfa/fwl/cfwl_caret.h
@@ -13,13 +13,10 @@ #include "xfa/fwl/cfwl_widget.h" #include "xfa/fxgraphics/cxfa_gecolor.h" -class CFWL_WidgetProperties; -class CFWL_Widget; - class CFWL_Caret final : public CFWL_Widget, public CFX_Timer::CallbackIface { public: CFWL_Caret(const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, + const Properties& properties, CFWL_Widget* pOuter); ~CFWL_Caret() override;
diff --git a/xfa/fwl/cfwl_checkbox.cpp b/xfa/fwl/cfwl_checkbox.cpp index a614f84..6bd420d 100644 --- a/xfa/fwl/cfwl_checkbox.cpp +++ b/xfa/fwl/cfwl_checkbox.cpp
@@ -7,7 +7,6 @@ #include "xfa/fwl/cfwl_checkbox.h" #include <algorithm> -#include <memory> #include <utility> #include "xfa/fde/cfde_textout.h" @@ -29,7 +28,7 @@ } // namespace CFWL_CheckBox::CFWL_CheckBox(const CFWL_App* app) - : CFWL_Widget(app, std::make_unique<CFWL_WidgetProperties>(), nullptr) { + : CFWL_Widget(app, Properties(), nullptr) { m_TTOStyles.single_line_ = true; } @@ -67,7 +66,7 @@ param.m_pGraphics = pGraphics; param.m_matrix.Concat(matrix); param.m_PartRect = m_ClientRect; - if (GetProperties()->m_dwStates & FWL_WGTSTATE_Focused) + if (m_Properties.m_dwStates & FWL_WGTSTATE_Focused) param.m_pRtData = &m_FocusRect; IFWL_ThemeProvider* pTheme = GetThemeProvider(); @@ -91,14 +90,14 @@ } void CFWL_CheckBox::SetCheckState(int32_t iCheck) { - GetProperties()->m_dwStates &= ~FWL_STATE_CKB_CheckMask; + m_Properties.m_dwStates &= ~FWL_STATE_CKB_CheckMask; switch (iCheck) { case 1: - GetProperties()->m_dwStates |= FWL_STATE_CKB_Checked; + m_Properties.m_dwStates |= FWL_STATE_CKB_Checked; break; case 2: - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) - GetProperties()->m_dwStates |= FWL_STATE_CKB_Neutral; + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_CKB_3State) + m_Properties.m_dwStates |= FWL_STATE_CKB_Neutral; break; default: break; @@ -128,22 +127,22 @@ uint32_t CFWL_CheckBox::GetPartStates() const { int32_t dwStates = CFWL_PartState_Normal; - if ((GetProperties()->m_dwStates & FWL_STATE_CKB_CheckMask) == + if ((m_Properties.m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Neutral) { dwStates = CFWL_PartState_Neutral; - } else if ((GetProperties()->m_dwStates & FWL_STATE_CKB_CheckMask) == + } else if ((m_Properties.m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Checked) { dwStates = CFWL_PartState_Checked; } - if (GetProperties()->m_dwStates & FWL_WGTSTATE_Disabled) + if (m_Properties.m_dwStates & FWL_WGTSTATE_Disabled) dwStates |= CFWL_PartState_Disabled; - else if (GetProperties()->m_dwStates & FWL_STATE_CKB_Hovered) + else if (m_Properties.m_dwStates & FWL_STATE_CKB_Hovered) dwStates |= CFWL_PartState_Hovered; - else if (GetProperties()->m_dwStates & FWL_STATE_CKB_Pressed) + else if (m_Properties.m_dwStates & FWL_STATE_CKB_Pressed) dwStates |= CFWL_PartState_Pressed; else dwStates |= CFWL_PartState_Normal; - if (GetProperties()->m_dwStates & FWL_WGTSTATE_Focused) + if (m_Properties.m_dwStates & FWL_WGTSTATE_Focused) dwStates |= CFWL_PartState_Focused; return dwStates; } @@ -155,31 +154,31 @@ } void CFWL_CheckBox::NextStates() { - uint32_t dwFirststate = GetProperties()->m_dwStates; - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) { - if ((GetProperties()->m_dwStates & FWL_STATE_CKB_CheckMask) == + uint32_t dwFirststate = m_Properties.m_dwStates; + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) { + if ((m_Properties.m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Unchecked) { - GetProperties()->m_dwStates |= FWL_STATE_CKB_Checked; + m_Properties.m_dwStates |= FWL_STATE_CKB_Checked; } } else { - if ((GetProperties()->m_dwStates & FWL_STATE_CKB_CheckMask) == + if ((m_Properties.m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Neutral) { - GetProperties()->m_dwStates &= ~FWL_STATE_CKB_CheckMask; - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) - GetProperties()->m_dwStates |= FWL_STATE_CKB_Checked; - } else if ((GetProperties()->m_dwStates & FWL_STATE_CKB_CheckMask) == + m_Properties.m_dwStates &= ~FWL_STATE_CKB_CheckMask; + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_CKB_3State) + m_Properties.m_dwStates |= FWL_STATE_CKB_Checked; + } else if ((m_Properties.m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Checked) { - GetProperties()->m_dwStates &= ~FWL_STATE_CKB_CheckMask; + m_Properties.m_dwStates &= ~FWL_STATE_CKB_CheckMask; } else { - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) - GetProperties()->m_dwStates |= FWL_STATE_CKB_Neutral; + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_CKB_3State) + m_Properties.m_dwStates |= FWL_STATE_CKB_Neutral; else - GetProperties()->m_dwStates |= FWL_STATE_CKB_Checked; + m_Properties.m_dwStates |= FWL_STATE_CKB_Checked; } } RepaintRect(m_ClientRect); - if (dwFirststate == GetProperties()->m_dwStates) + if (dwFirststate == m_Properties.m_dwStates) return; CFWL_Event wmCheckBoxState(CFWL_Event::Type::CheckStateChanged, this); @@ -235,20 +234,20 @@ void CFWL_CheckBox::OnFocusChanged(bool bSet) { if (bSet) - GetProperties()->m_dwStates |= FWL_WGTSTATE_Focused; + m_Properties.m_dwStates |= FWL_WGTSTATE_Focused; else - GetProperties()->m_dwStates &= ~FWL_WGTSTATE_Focused; + m_Properties.m_dwStates &= ~FWL_WGTSTATE_Focused; RepaintRect(m_ClientRect); } void CFWL_CheckBox::OnLButtonDown() { - if (GetProperties()->m_dwStates & FWL_WGTSTATE_Disabled) + if (m_Properties.m_dwStates & FWL_WGTSTATE_Disabled) return; m_bBtnDown = true; - GetProperties()->m_dwStates &= ~FWL_STATE_CKB_Hovered; - GetProperties()->m_dwStates |= FWL_STATE_CKB_Pressed; + m_Properties.m_dwStates &= ~FWL_STATE_CKB_Hovered; + m_Properties.m_dwStates |= FWL_STATE_CKB_Pressed; RepaintRect(m_ClientRect); } @@ -260,41 +259,41 @@ if (!m_ClientRect.Contains(pMsg->m_pos)) return; - GetProperties()->m_dwStates |= FWL_STATE_CKB_Hovered; - GetProperties()->m_dwStates &= ~FWL_STATE_CKB_Pressed; + m_Properties.m_dwStates |= FWL_STATE_CKB_Hovered; + m_Properties.m_dwStates &= ~FWL_STATE_CKB_Pressed; NextStates(); } void CFWL_CheckBox::OnMouseMove(CFWL_MessageMouse* pMsg) { - if (GetProperties()->m_dwStates & FWL_WGTSTATE_Disabled) + if (m_Properties.m_dwStates & FWL_WGTSTATE_Disabled) return; bool bRepaint = false; if (m_bBtnDown) { if (m_ClientRect.Contains(pMsg->m_pos)) { - if ((GetProperties()->m_dwStates & FWL_STATE_CKB_Pressed) == 0) { + if ((m_Properties.m_dwStates & FWL_STATE_CKB_Pressed) == 0) { bRepaint = true; - GetProperties()->m_dwStates |= FWL_STATE_CKB_Pressed; + m_Properties.m_dwStates |= FWL_STATE_CKB_Pressed; } - if ((GetProperties()->m_dwStates & FWL_STATE_CKB_Hovered)) { + if ((m_Properties.m_dwStates & FWL_STATE_CKB_Hovered)) { bRepaint = true; - GetProperties()->m_dwStates &= ~FWL_STATE_CKB_Hovered; + m_Properties.m_dwStates &= ~FWL_STATE_CKB_Hovered; } } else { - if (GetProperties()->m_dwStates & FWL_STATE_CKB_Pressed) { + if (m_Properties.m_dwStates & FWL_STATE_CKB_Pressed) { bRepaint = true; - GetProperties()->m_dwStates &= ~FWL_STATE_CKB_Pressed; + m_Properties.m_dwStates &= ~FWL_STATE_CKB_Pressed; } - if ((GetProperties()->m_dwStates & FWL_STATE_CKB_Hovered) == 0) { + if ((m_Properties.m_dwStates & FWL_STATE_CKB_Hovered) == 0) { bRepaint = true; - GetProperties()->m_dwStates |= FWL_STATE_CKB_Hovered; + m_Properties.m_dwStates |= FWL_STATE_CKB_Hovered; } } } else { if (m_ClientRect.Contains(pMsg->m_pos)) { - if ((GetProperties()->m_dwStates & FWL_STATE_CKB_Hovered) == 0) { + if ((m_Properties.m_dwStates & FWL_STATE_CKB_Hovered) == 0) { bRepaint = true; - GetProperties()->m_dwStates |= FWL_STATE_CKB_Hovered; + m_Properties.m_dwStates |= FWL_STATE_CKB_Hovered; } } } @@ -304,9 +303,9 @@ void CFWL_CheckBox::OnMouseLeave() { if (m_bBtnDown) - GetProperties()->m_dwStates |= FWL_STATE_CKB_Hovered; + m_Properties.m_dwStates |= FWL_STATE_CKB_Hovered; else - GetProperties()->m_dwStates &= ~FWL_STATE_CKB_Hovered; + m_Properties.m_dwStates &= ~FWL_STATE_CKB_Hovered; RepaintRect(m_BoxRect); }
diff --git a/xfa/fwl/cfwl_checkbox.h b/xfa/fwl/cfwl_checkbox.h index 04ae7ef..ae301f3 100644 --- a/xfa/fwl/cfwl_checkbox.h +++ b/xfa/fwl/cfwl_checkbox.h
@@ -9,7 +9,6 @@ #include "xfa/fwl/cfwl_event.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fwl/cfwl_widgetproperties.h" #define FWL_STYLEEXT_CKB_3State (1L << 6) #define FWL_STYLEEXT_CKB_RadioButton (1L << 7) @@ -28,8 +27,6 @@ #define FWL_STATE_CKB_CheckMask (3L << (FWL_WGTSTATE_MAX + 2)) class CFWL_MessageMouse; -class CFWL_WidgetProperties; -class CFWL_Widget; class CFWL_CheckBox final : public CFWL_Widget { public:
diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp index 23bdcde..50f912e 100644 --- a/xfa/fwl/cfwl_combobox.cpp +++ b/xfa/fwl/cfwl_combobox.cpp
@@ -29,7 +29,7 @@ #include "xfa/fwl/ifwl_themeprovider.h" CFWL_ComboBox::CFWL_ComboBox(const CFWL_App* app) - : CFWL_Widget(app, std::make_unique<CFWL_WidgetProperties>(), nullptr) { + : CFWL_Widget(app, Properties(), nullptr) { InitComboList(); InitComboEdit(); } @@ -61,7 +61,7 @@ bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown); dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown; - GetProperties()->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown; + m_Properties.m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown; if (bAddDropDown) m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly); @@ -302,7 +302,7 @@ return; uint32_t dwAdd = 0; - switch (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_CMB_EditHAlignMask) { + switch (m_Properties.m_dwStyleExes & FWL_STYLEEXT_CMB_EditHAlignMask) { case FWL_STYLEEXT_CMB_EditHCenter: { dwAdd |= FWL_STYLEEXT_EDT_HCenter; break; @@ -312,7 +312,7 @@ break; } } - switch (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_CMB_EditVAlignMask) { + switch (m_Properties.m_dwStyleExes & FWL_STYLEEXT_CMB_EditVAlignMask) { case FWL_STYLEEXT_CMB_EditVCenter: { dwAdd |= FWL_STYLEEXT_EDT_VCenter; break; @@ -326,7 +326,7 @@ break; } } - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_CMB_EditJustified) + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_CMB_EditJustified) dwAdd |= FWL_STYLEEXT_EDT_Justified; m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask | @@ -339,7 +339,7 @@ return; uint32_t dwAdd = 0; - switch (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemAlignMask) { + switch (m_Properties.m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemAlignMask) { case FWL_STYLEEXT_CMB_ListItemCenterAlign: { dwAdd |= FWL_STYLEEXT_LTB_CenterAlign; break; @@ -377,19 +377,17 @@ if (m_pListBox) return; - auto prop = std::make_unique<CFWL_WidgetProperties>(); - prop->m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; - prop->m_dwStates = FWL_WGTSTATE_Invisible; - m_pListBox = - std::make_unique<CFWL_ComboList>(GetOwnerApp(), std::move(prop), this); + Properties prop; + prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; + prop.m_dwStates = FWL_WGTSTATE_Invisible; + m_pListBox = std::make_unique<CFWL_ComboList>(GetOwnerApp(), prop, this); } void CFWL_ComboBox::InitComboEdit() { if (m_pEdit) return; - m_pEdit = std::make_unique<CFWL_ComboEdit>( - GetOwnerApp(), std::make_unique<CFWL_WidgetProperties>(), this); + m_pEdit = std::make_unique<CFWL_ComboEdit>(GetOwnerApp(), Properties(), this); } void CFWL_ComboBox::OnProcessMessage(CFWL_Message* pMessage) { @@ -492,13 +490,13 @@ void CFWL_ComboBox::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { if (bSet) { - GetProperties()->m_dwStates |= FWL_WGTSTATE_Focused; + m_Properties.m_dwStates |= FWL_WGTSTATE_Focused; if ((m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) { CFWL_MessageSetFocus msg(nullptr, m_pEdit.get()); m_pEdit->GetDelegate()->OnProcessMessage(&msg); } } else { - GetProperties()->m_dwStates &= ~FWL_WGTSTATE_Focused; + m_Properties.m_dwStates &= ~FWL_WGTSTATE_Focused; ShowDropList(false); CFWL_MessageKillFocus msg(m_pEdit.get()); m_pEdit->GetDelegate()->OnProcessMessage(&msg);
diff --git a/xfa/fwl/cfwl_combobox.h b/xfa/fwl/cfwl_combobox.h index 719c825..3c7b7ae 100644 --- a/xfa/fwl/cfwl_combobox.h +++ b/xfa/fwl/cfwl_combobox.h
@@ -12,12 +12,11 @@ #include "xfa/fwl/cfwl_comboedit.h" #include "xfa/fwl/cfwl_combolist.h" #include "xfa/fwl/cfwl_listbox.h" +#include "xfa/fwl/cfwl_widget.h" #include "xfa/fxgraphics/cxfa_graphics.h" -class CFWL_WidgetProperties; class CFWL_ComboBox; class CFWL_ListBox; -class CFWL_Widget; #define FWL_STYLEEXT_CMB_DropDown (1L << 0) #define FWL_STYLEEXT_CMB_Sort (1L << 1) @@ -96,7 +95,7 @@ private: bool IsDropDownStyle() const { - return !!(GetProperties()->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown); + return !!(m_Properties.m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown); } void MatchEditText(); void SyncEditText(int32_t iListItem);
diff --git a/xfa/fwl/cfwl_comboedit.cpp b/xfa/fwl/cfwl_comboedit.cpp index 0b5beac..cad3231 100644 --- a/xfa/fwl/cfwl_comboedit.cpp +++ b/xfa/fwl/cfwl_comboedit.cpp
@@ -6,18 +6,16 @@ #include "xfa/fwl/cfwl_comboedit.h" -#include <memory> #include <utility> #include "xfa/fde/cfde_texteditengine.h" #include "xfa/fwl/cfwl_combobox.h" #include "xfa/fwl/cfwl_messagemouse.h" -CFWL_ComboEdit::CFWL_ComboEdit( - const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, - CFWL_Widget* pOuter) - : CFWL_Edit(app, std::move(properties), pOuter) {} +CFWL_ComboEdit::CFWL_ComboEdit(const CFWL_App* app, + const Properties& properties, + CFWL_Widget* pOuter) + : CFWL_Edit(app, properties, pOuter) {} CFWL_ComboEdit::~CFWL_ComboEdit() = default; @@ -33,11 +31,11 @@ void CFWL_ComboEdit::FlagFocus(bool bSet) { if (bSet) { - GetProperties()->m_dwStates |= FWL_WGTSTATE_Focused; + m_Properties.m_dwStates |= FWL_WGTSTATE_Focused; return; } - GetProperties()->m_dwStates &= ~FWL_WGTSTATE_Focused; + m_Properties.m_dwStates &= ~FWL_WGTSTATE_Focused; HideCaret(nullptr); } @@ -45,19 +43,19 @@ bool backDefault = true; switch (pMessage->GetType()) { case CFWL_Message::Type::kSetFocus: { - GetProperties()->m_dwStates |= FWL_WGTSTATE_Focused; + m_Properties.m_dwStates |= FWL_WGTSTATE_Focused; backDefault = false; break; } case CFWL_Message::Type::kKillFocus: { - GetProperties()->m_dwStates &= ~FWL_WGTSTATE_Focused; + m_Properties.m_dwStates &= ~FWL_WGTSTATE_Focused; backDefault = false; break; } case CFWL_Message::Type::kMouse: { CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); if ((pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown) && - ((GetProperties()->m_dwStates & FWL_WGTSTATE_Focused) == 0)) { + ((m_Properties.m_dwStates & FWL_WGTSTATE_Focused) == 0)) { SetSelected(); } break;
diff --git a/xfa/fwl/cfwl_comboedit.h b/xfa/fwl/cfwl_comboedit.h index 68e6caa..b6fd11a 100644 --- a/xfa/fwl/cfwl_comboedit.h +++ b/xfa/fwl/cfwl_comboedit.h
@@ -7,22 +7,17 @@ #ifndef XFA_FWL_CFWL_COMBOEDIT_H_ #define XFA_FWL_CFWL_COMBOEDIT_H_ -#include <memory> - #include "xfa/fwl/cfwl_edit.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fwl/cfwl_widgetproperties.h" - -class CFWL_ComboBox; class CFWL_ComboEdit final : public CFWL_Edit { public: CFWL_ComboEdit(const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, + const Properties& properties, CFWL_Widget* pOuter); ~CFWL_ComboEdit() override; - // CFWL_Edit. + // CFWL_Edit: void OnProcessMessage(CFWL_Message* pMessage) override; void ClearSelected();
diff --git a/xfa/fwl/cfwl_combolist.cpp b/xfa/fwl/cfwl_combolist.cpp index c6fb591..709c24a 100644 --- a/xfa/fwl/cfwl_combolist.cpp +++ b/xfa/fwl/cfwl_combolist.cpp
@@ -6,7 +6,6 @@ #include "xfa/fwl/cfwl_combolist.h" -#include <memory> #include <utility> #include "xfa/fwl/cfwl_combobox.h" @@ -17,11 +16,10 @@ #include "xfa/fwl/cfwl_messagemouse.h" #include "xfa/fwl/fwl_widgetdef.h" -CFWL_ComboList::CFWL_ComboList( - const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, - CFWL_Widget* pOuter) - : CFWL_ListBox(app, std::move(properties), pOuter) { +CFWL_ComboList::CFWL_ComboList(const CFWL_App* app, + const Properties& properties, + CFWL_Widget* pOuter) + : CFWL_ListBox(app, properties, pOuter) { ASSERT(pOuter); }
diff --git a/xfa/fwl/cfwl_combolist.h b/xfa/fwl/cfwl_combolist.h index c275c72..cb7f086 100644 --- a/xfa/fwl/cfwl_combolist.h +++ b/xfa/fwl/cfwl_combolist.h
@@ -7,16 +7,13 @@ #ifndef XFA_FWL_CFWL_COMBOLIST_H_ #define XFA_FWL_CFWL_COMBOLIST_H_ -#include <memory> - #include "xfa/fwl/cfwl_listbox.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fwl/cfwl_widgetproperties.h" class CFWL_ComboList final : public CFWL_ListBox { public: CFWL_ComboList(const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, + const Properties& properties, CFWL_Widget* pOuter); // CFWL_ListBox.
diff --git a/xfa/fwl/cfwl_datetimeedit.cpp b/xfa/fwl/cfwl_datetimeedit.cpp index e93d3af..bb6c12e 100644 --- a/xfa/fwl/cfwl_datetimeedit.cpp +++ b/xfa/fwl/cfwl_datetimeedit.cpp
@@ -6,18 +6,16 @@ #include "xfa/fwl/cfwl_datetimeedit.h" -#include <memory> #include <utility> #include "xfa/fwl/cfwl_datetimepicker.h" #include "xfa/fwl/cfwl_messagemouse.h" #include "xfa/fwl/cfwl_widgetmgr.h" -CFWL_DateTimeEdit::CFWL_DateTimeEdit( - const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, - CFWL_Widget* pOuter) - : CFWL_Edit(app, std::move(properties), pOuter) {} +CFWL_DateTimeEdit::CFWL_DateTimeEdit(const CFWL_App* app, + const Properties& properties, + CFWL_Widget* pOuter) + : CFWL_Edit(app, properties, pOuter) {} CFWL_DateTimeEdit::~CFWL_DateTimeEdit() = default; @@ -30,8 +28,8 @@ CFWL_MessageMouse* pMouse = static_cast<CFWL_MessageMouse*>(pMessage); if (pMouse->m_dwCmd == FWL_MouseCommand::LeftButtonDown || pMouse->m_dwCmd == FWL_MouseCommand::RightButtonDown) { - if ((GetProperties()->m_dwStates & FWL_WGTSTATE_Focused) == 0) - GetProperties()->m_dwStates |= FWL_WGTSTATE_Focused; + if ((m_Properties.m_dwStates & FWL_WGTSTATE_Focused) == 0) + m_Properties.m_dwStates |= FWL_WGTSTATE_Focused; CFWL_DateTimePicker* pDateTime = static_cast<CFWL_DateTimePicker*>(GetOuter());
diff --git a/xfa/fwl/cfwl_datetimeedit.h b/xfa/fwl/cfwl_datetimeedit.h index e617ff4..36e9af3 100644 --- a/xfa/fwl/cfwl_datetimeedit.h +++ b/xfa/fwl/cfwl_datetimeedit.h
@@ -7,20 +7,17 @@ #ifndef XFA_FWL_CFWL_DATETIMEEDIT_H_ #define XFA_FWL_CFWL_DATETIMEEDIT_H_ -#include <memory> - #include "xfa/fwl/cfwl_edit.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fwl/cfwl_widgetproperties.h" class CFWL_DateTimeEdit final : public CFWL_Edit { public: CFWL_DateTimeEdit(const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, + const Properties& properties, CFWL_Widget* pOuter); ~CFWL_DateTimeEdit() override; - // CFWL_Edit. + // CFWL_Edit: void OnProcessMessage(CFWL_Message* pMessage) override; };
diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp index 4a0addb..270ed3f 100644 --- a/xfa/fwl/cfwl_datetimepicker.cpp +++ b/xfa/fwl/cfwl_datetimepicker.cpp
@@ -24,20 +24,20 @@ } // namespace CFWL_DateTimePicker::CFWL_DateTimePicker(const CFWL_App* app) - : CFWL_Widget(app, std::make_unique<CFWL_WidgetProperties>(), nullptr) { - GetProperties()->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; + : CFWL_Widget(app, Properties(), nullptr) { + m_Properties.m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; - auto monthProp = std::make_unique<CFWL_WidgetProperties>(); - monthProp->m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border; - monthProp->m_dwStates = FWL_WGTSTATE_Invisible; - m_pMonthCal = std::make_unique<CFWL_MonthCalendar>( - GetOwnerApp(), std::move(monthProp), this); + Properties monthProp; + monthProp.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border; + monthProp.m_dwStates = FWL_WGTSTATE_Invisible; + m_pMonthCal = + std::make_unique<CFWL_MonthCalendar>(GetOwnerApp(), monthProp, this); m_pMonthCal->SetWidgetRect( CFX_RectF(0, 0, m_pMonthCal->GetAutosizedWidgetRect().Size())); - m_pEdit = std::make_unique<CFWL_DateTimeEdit>( - GetOwnerApp(), std::make_unique<CFWL_WidgetProperties>(), this); + m_pEdit = + std::make_unique<CFWL_DateTimeEdit>(GetOwnerApp(), Properties(), this); RegisterEventTarget(m_pMonthCal.get()); RegisterEventTarget(m_pEdit.get()); @@ -190,7 +190,7 @@ WideString CFWL_DateTimePicker::FormatDateString(int32_t iYear, int32_t iMonth, int32_t iDay) { - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_DTP_ShortDateFormat) + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_DTP_ShortDateFormat) return WideString::Format(L"%d-%d-%d", iYear, iMonth, iDay); return WideString::Format(L"%d Year %d Month %d Day", iYear, iMonth, iDay); @@ -240,7 +240,7 @@ return; uint32_t dwAdd = 0; - switch (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_DTP_EditHAlignMask) { + switch (m_Properties.m_dwStyleExes & FWL_STYLEEXT_DTP_EditHAlignMask) { case FWL_STYLEEXT_DTP_EditHCenter: { dwAdd |= FWL_STYLEEXT_EDT_HCenter; break; @@ -254,7 +254,7 @@ break; } } - switch (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_DTP_EditVAlignMask) { + switch (m_Properties.m_dwStyleExes & FWL_STYLEEXT_DTP_EditVAlignMask) { case FWL_STYLEEXT_DTP_EditVCenter: { dwAdd |= FWL_STYLEEXT_EDT_VCenter; break; @@ -268,7 +268,7 @@ break; } } - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_DTP_EditJustified) + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_DTP_EditJustified) dwAdd |= FWL_STYLEEXT_EDT_Justified; m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask | @@ -300,7 +300,7 @@ } bool CFWL_DateTimePicker::NeedsToShowButton() const { - return GetProperties()->m_dwStates & FWL_WGTSTATE_Focused || + return m_Properties.m_dwStates & FWL_WGTSTATE_Focused || m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused || m_pEdit->GetStates() & FWL_WGTSTATE_Focused; } @@ -359,7 +359,7 @@ CFX_RectF rtInvalidate(m_BtnRect); if (bSet) { - GetProperties()->m_dwStates |= FWL_WGTSTATE_Focused; + m_Properties.m_dwStates |= FWL_WGTSTATE_Focused; if (m_pEdit && !(m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)) { m_BtnRect = CFX_RectF(m_WidgetRect.width, 0, m_fBtn, m_WidgetRect.height - 1); @@ -368,7 +368,7 @@ pMsg->SetDstTarget(m_pEdit.get()); m_pEdit->GetDelegate()->OnProcessMessage(pMsg); } else { - GetProperties()->m_dwStates &= ~FWL_WGTSTATE_Focused; + m_Properties.m_dwStates &= ~FWL_WGTSTATE_Focused; m_BtnRect = CFX_RectF(); if (IsMonthCalendarVisible()) ShowMonthCalendar(false);
diff --git a/xfa/fwl/cfwl_datetimepicker.h b/xfa/fwl/cfwl_datetimepicker.h index 4b84d83..701f586 100644 --- a/xfa/fwl/cfwl_datetimepicker.h +++ b/xfa/fwl/cfwl_datetimepicker.h
@@ -14,7 +14,6 @@ #include "xfa/fwl/cfwl_event.h" #include "xfa/fwl/cfwl_monthcalendar.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fwl/cfwl_widgetproperties.h" #define FWL_STYLEEXT_DTP_ShortDateFormat (1L << 1) #define FWL_STYLEEXT_DTP_EditHAlignMask (3L << 4)
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index 2492e4d..44224f2 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp
@@ -45,16 +45,16 @@ } // namespace CFWL_Edit::CFWL_Edit(const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, + const Properties& properties, CFWL_Widget* pOuter) - : CFWL_Widget(app, std::move(properties), pOuter), + : CFWL_Widget(app, properties, pOuter), m_pEditEngine(std::make_unique<CFDE_TextEditEngine>()) { m_pEditEngine->SetDelegate(this); } CFWL_Edit::~CFWL_Edit() { m_pEditEngine->SetDelegate(nullptr); - if (GetProperties()->m_dwStates & FWL_WGTSTATE_Focused) + if (m_Properties.m_dwStates & FWL_WGTSTATE_Focused) HideCaret(nullptr); } @@ -64,7 +64,7 @@ CFX_RectF CFWL_Edit::GetWidgetRect() { CFX_RectF rect = m_WidgetRect; - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { float scrollbarWidth = GetThemeProvider()->GetScrollBarWidth(); if (IsShowScrollBar(true)) { rect.width += scrollbarWidth; @@ -83,7 +83,7 @@ if (m_pEditEngine->GetLength() > 0) { CFX_SizeF size = CalcTextSize( m_pEditEngine->GetText(), - !!(GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine)); + !!(m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine)); rect = CFX_RectF(0, 0, size); } InflateWidgetRect(rect); @@ -91,8 +91,8 @@ } void CFWL_Edit::SetStates(uint32_t dwStates) { - if ((GetProperties()->m_dwStates & FWL_WGTSTATE_Invisible) || - (GetProperties()->m_dwStates & FWL_WGTSTATE_Disabled)) { + if ((m_Properties.m_dwStates & FWL_WGTSTATE_Invisible) || + (m_Properties.m_dwStates & FWL_WGTSTATE_Disabled)) { HideCaret(nullptr); } CFWL_Widget::SetStates(dwStates); @@ -113,7 +113,7 @@ } FWL_WidgetHit CFWL_Edit::HitTest(const CFX_PointF& point) { - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { if (IsShowScrollBar(true)) { if (m_pVertScrollBar->GetWidgetRect().Contains(point)) return FWL_WidgetHit::VScrollBar; @@ -248,14 +248,14 @@ void CFWL_Edit::OnCaretChanged() { if (m_EngineRect.IsEmpty()) return; - if ((GetProperties()->m_dwStates & FWL_WGTSTATE_Focused) == 0) + if ((m_Properties.m_dwStates & FWL_WGTSTATE_Focused) == 0) return; bool bRepaintContent = UpdateOffset(); UpdateCaret(); CFX_RectF rtInvalid; bool bRepaintScroll = false; - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { CFWL_ScrollBar* pScroll = UpdateScroll(); if (pScroll) { rtInvalid = pScroll->GetWidgetRect(); @@ -286,7 +286,7 @@ } void CFWL_Edit::OnTextChanged() { - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask) + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask) UpdateVAlignment(); LayoutScrollBar(); @@ -315,10 +315,10 @@ param.m_pWidget = this; param.m_iPart = CFWL_Part::Background; param.m_bStaticBackground = false; - param.m_dwStates = GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly + param.m_dwStates = m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly ? CFWL_PartState_ReadOnly : CFWL_PartState_Normal; - uint32_t dwStates = (GetProperties()->m_dwStates & FWL_WGTSTATE_Disabled); + uint32_t dwStates = (m_Properties.m_dwStates & FWL_WGTSTATE_Disabled); if (dwStates) param.m_dwStates = CFWL_PartState_Disabled; param.m_pGraphics = pGraphics; @@ -343,7 +343,7 @@ void CFWL_Edit::DrawContent(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) { pGraphics->SaveGraphState(); - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) pGraphics->SaveGraphState(); CFX_RectF rtClip = m_EngineRect; @@ -356,7 +356,7 @@ mt.Concat(*pMatrix); } - bool bShowSel = !!(GetProperties()->m_dwStates & FWL_WGTSTATE_Focused); + bool bShowSel = !!(m_Properties.m_dwStates & FWL_WGTSTATE_Focused); if (bShowSel && m_pEditEngine->HasSelection()) { size_t sel_start; size_t count; @@ -384,7 +384,7 @@ CFX_RenderDevice* pRenderDev = pGraphics->GetRenderDevice(); RenderText(pRenderDev, rtClip, mt); - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { pGraphics->RestoreGraphState(); CXFA_GEPath path; @@ -450,15 +450,15 @@ void CFWL_Edit::UpdateEditParams() { m_pEditEngine->SetAvailableWidth(m_EngineRect.width); m_pEditEngine->SetCombText( - !!(GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText)); + !!(m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_CombText)); m_pEditEngine->EnableValidation( - !!(GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_Validate)); + !!(m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_Validate)); m_pEditEngine->EnablePasswordMode( - !!(GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_Password)); + !!(m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_Password)); uint32_t alignment = 0; - switch (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignMask) { + switch (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignMask) { case FWL_STYLEEXT_EDT_HNear: { alignment |= CFX_TxtLineAlignment_Left; break; @@ -474,7 +474,7 @@ default: break; } - switch (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignModeMask) { + switch (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignModeMask) { case FWL_STYLEEXT_EDT_Justified: { alignment |= CFX_TxtLineAlignment_Justified; break; @@ -485,13 +485,13 @@ m_pEditEngine->SetAlignment(alignment); bool auto_hscroll = - !!(GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoHScroll); - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { + !!(m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_AutoHScroll); + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { m_pEditEngine->EnableMultiLine(true); m_pEditEngine->EnableLineWrap(!auto_hscroll); m_pEditEngine->LimitVerticalScroll( - (GetProperties()->m_dwStyles & FWL_WGTSTYLE_VScroll) == 0 && - (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoVScroll) == 0); + (m_Properties.m_dwStyles & FWL_WGTSTYLE_VScroll) == 0 && + (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_AutoVScroll) == 0); } else { m_pEditEngine->EnableMultiLine(false); m_pEditEngine->EnableLineWrap(false); @@ -584,14 +584,14 @@ float fOffsetY = 0.0f; CFX_RectF contents_bounds = m_pEditEngine->GetContentsBoundingBox(); - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_VCenter) { + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_VCenter) { fOffsetY = (m_EngineRect.height - contents_bounds.height) / 2.0f; if (fOffsetY < (fSpaceAbove + fSpaceBelow) / 2.0f && fSpaceAbove < fSpaceBelow) { return; } fOffsetY += (fSpaceAbove - fSpaceBelow) / 2.0f; - } else if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_VFar) { + } else if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_VFar) { fOffsetY = (m_EngineRect.height - contents_bounds.height); fOffsetY -= fSpaceBelow; } else { @@ -613,7 +613,7 @@ rtCaret.width = right - rtCaret.left; } - if (GetProperties()->m_dwStates & FWL_WGTSTATE_Focused && !rtCaret.IsEmpty()) + if (m_Properties.m_dwStates & FWL_WGTSTATE_Focused && !rtCaret.IsEmpty()) ShowCaret(&rtCaret); else HideCaret(&rtCaret); @@ -691,12 +691,12 @@ if (!bVert) return false; bool bShow = - (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) - ? (GetProperties()->m_dwStates & FWL_WGTSTATE_Focused) == + (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) + ? (m_Properties.m_dwStates & FWL_WGTSTATE_Focused) == FWL_WGTSTATE_Focused : true; - return bShow && (GetProperties()->m_dwStyles & FWL_WGTSTYLE_VScroll) && - (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) && + return bShow && (m_Properties.m_dwStyles & FWL_WGTSTYLE_VScroll) && + (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) && IsContentHeightOverflow(); } @@ -730,7 +730,7 @@ InitVerticalScrollBar(); CFX_RectF rtVertScr; - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { rtVertScr = CFX_RectF(m_ClientRect.right() + kEditMargin, m_ClientRect.top, fWidth, m_ClientRect.height); } else { @@ -752,7 +752,7 @@ InitHorizontalScrollBar(); CFX_RectF rtHoriScr; - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { rtHoriScr = CFX_RectF(m_ClientRect.left, m_ClientRect.bottom() + kEditMargin, m_ClientRect.width, fWidth); @@ -772,8 +772,7 @@ } void CFWL_Edit::LayoutScrollBar() { - if ((GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) == - 0) { + if ((m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) == 0) { return; } @@ -785,7 +784,7 @@ if (!m_pVertScrollBar) { InitVerticalScrollBar(); CFX_RectF rtVertScr; - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { rtVertScr = CFX_RectF(m_ClientRect.right() + kEditMargin, m_ClientRect.top, fWidth, m_ClientRect.height); } else { @@ -806,7 +805,7 @@ if (!m_pHorzScrollBar) { InitHorizontalScrollBar(); CFX_RectF rtHoriScr; - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { rtHoriScr = CFX_RectF(m_ClientRect.left, m_ClientRect.bottom() + kEditMargin, m_ClientRect.width, fWidth); @@ -836,22 +835,22 @@ if (m_pVertScrollBar) return; - auto prop = std::make_unique<CFWL_WidgetProperties>(); - prop->m_dwStyleExes = FWL_STYLEEXT_SCB_Vert; - prop->m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; + Properties prop; + prop.m_dwStyleExes = FWL_STYLEEXT_SCB_Vert; + prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; m_pVertScrollBar = - std::make_unique<CFWL_ScrollBar>(GetOwnerApp(), std::move(prop), this); + std::make_unique<CFWL_ScrollBar>(GetOwnerApp(), prop, this); } void CFWL_Edit::InitHorizontalScrollBar() { if (m_pHorzScrollBar) return; - auto prop = std::make_unique<CFWL_WidgetProperties>(); - prop->m_dwStyleExes = FWL_STYLEEXT_SCB_Horz; - prop->m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; + Properties prop; + prop.m_dwStyleExes = FWL_STYLEEXT_SCB_Horz; + prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; m_pHorzScrollBar = - std::make_unique<CFWL_ScrollBar>(GetOwnerApp(), std::move(prop), this); + std::make_unique<CFWL_ScrollBar>(GetOwnerApp(), prop, this); } void CFWL_Edit::ShowCaret(CFX_RectF* pRect) { @@ -921,9 +920,8 @@ if (m_pCaret) return; - m_pCaret = std::make_unique<CFWL_Caret>( - GetOwnerApp(), std::make_unique<CFWL_WidgetProperties>(), this); - m_pCaret->SetStates(GetProperties()->m_dwStates); + m_pCaret = std::make_unique<CFWL_Caret>(GetOwnerApp(), Properties(), this); + m_pCaret->SetStates(m_Properties.m_dwStates); UpdateCursorRect(); } @@ -1029,13 +1027,13 @@ void CFWL_Edit::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { bool bRepaint = false; if (bSet) { - GetProperties()->m_dwStates |= FWL_WGTSTATE_Focused; + m_Properties.m_dwStates |= FWL_WGTSTATE_Focused; UpdateVAlignment(); UpdateOffset(); UpdateCaret(); - } else if (GetProperties()->m_dwStates & FWL_WGTSTATE_Focused) { - GetProperties()->m_dwStates &= ~FWL_WGTSTATE_Focused; + } else if (m_Properties.m_dwStates & FWL_WGTSTATE_Focused) { + m_Properties.m_dwStates &= ~FWL_WGTSTATE_Focused; HideCaret(nullptr); if (HasSelection()) { @@ -1053,7 +1051,7 @@ } void CFWL_Edit::OnLButtonDown(CFWL_MessageMouse* pMsg) { - if (GetProperties()->m_dwStates & FWL_WGTSTATE_Disabled) + if (m_Properties.m_dwStates & FWL_WGTSTATE_Disabled) return; m_bLButtonDown = true; @@ -1162,8 +1160,8 @@ : m_pEditEngine->GetIndexAtEndOfLine(m_CursorPosition)); break; case XFA_FWL_VKEY_Delete: { - if ((GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || - (GetProperties()->m_dwStates & FWL_WGTSTATE_Disabled)) { + if ((m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || + (m_Properties.m_dwStates & FWL_WGTSTATE_Disabled)) { break; } @@ -1187,8 +1185,8 @@ } void CFWL_Edit::OnChar(CFWL_MessageKey* pMsg) { - if ((GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || - (GetProperties()->m_dwStates & FWL_WGTSTATE_Disabled)) { + if ((m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || + (m_Properties.m_dwStates & FWL_WGTSTATE_Disabled)) { return; } @@ -1210,7 +1208,7 @@ SetCursorPosition(m_CursorPosition + 1); break; case L'\r': - if (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_EDT_WantReturn) { + if (m_Properties.m_dwStyleExes & FWL_STYLEEXT_EDT_WantReturn) { m_pEditEngine->Insert(m_CursorPosition, L"\n"); SetCursorPosition(m_CursorPosition + 1); }
diff --git a/xfa/fwl/cfwl_edit.h b/xfa/fwl/cfwl_edit.h index d77413b..5e451ae 100644 --- a/xfa/fwl/cfwl_edit.h +++ b/xfa/fwl/cfwl_edit.h
@@ -40,13 +40,12 @@ class CFWL_Edit; class CFWL_MessageMouse; -class CFWL_WidgetProperties; class CFWL_Caret; class CFWL_Edit : public CFWL_Widget, public CFDE_TextEditEngine::Delegate { public: CFWL_Edit(const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, + const Properties& properties, CFWL_Widget* pOuter); ~CFWL_Edit() override;
diff --git a/xfa/fwl/cfwl_listbox.cpp b/xfa/fwl/cfwl_listbox.cpp index f4ac843..f4de0b6 100644 --- a/xfa/fwl/cfwl_listbox.cpp +++ b/xfa/fwl/cfwl_listbox.cpp
@@ -29,9 +29,9 @@ } // namespace CFWL_ListBox::CFWL_ListBox(const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, + const Properties& properties, CFWL_Widget* pOuter) - : CFWL_Widget(app, std::move(properties), pOuter) {} + : CFWL_Widget(app, properties, pOuter) {} CFWL_ListBox::~CFWL_ListBox() = default; @@ -43,7 +43,7 @@ if (IsLocked()) return; - switch (GetProperties()->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) { + switch (m_Properties.m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) { case FWL_STYLEEXT_LTB_LeftAlign: m_iTTOAligns = FDE_TextAlignment::kCenterLeft; break; @@ -92,7 +92,7 @@ rtClip.width -= m_fScorllBarWidth; pGraphics->SetClipRect(matrix.TransformRect(rtClip)); - if ((GetProperties()->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) + if ((m_Properties.m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) DrawBkground(pGraphics, &matrix); DrawItems(pGraphics, &matrix); @@ -215,7 +215,7 @@ } bool CFWL_ListBox::IsMultiSelection() const { - return GetProperties()->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; + return m_Properties.m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; } bool CFWL_ListBox::IsItemSelected(CFWL_ListItem* pItem) { @@ -385,12 +385,12 @@ const CFX_Matrix* pMatrix) { uint32_t dwItemStyles = pItem ? pItem->GetStates() : 0; uint32_t dwPartStates = CFWL_PartState_Normal; - if (GetProperties()->m_dwStates & FWL_WGTSTATE_Disabled) + if (m_Properties.m_dwStates & FWL_WGTSTATE_Disabled) dwPartStates = CFWL_PartState_Disabled; else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) dwPartStates = CFWL_PartState_Selected; - if (GetProperties()->m_dwStates & FWL_WGTSTATE_Focused && + if (m_Properties.m_dwStates & FWL_WGTSTATE_Focused && dwItemStyles & FWL_ITEMSTATE_LTB_Focused) { dwPartStates |= CFWL_PartState_Focused; } @@ -471,7 +471,7 @@ float iHeight = m_ClientRect.height; bool bShowVertScr = false; bool bShowHorzScr = false; - if (!bShowVertScr && (GetProperties()->m_dwStyles & FWL_WGTSTYLE_VScroll)) + if (!bShowVertScr && (m_Properties.m_dwStyles & FWL_WGTSTYLE_VScroll)) bShowVertScr = (fs.height > iHeight); CFX_SizeF szRange; @@ -497,9 +497,9 @@ pdfium::clamp(m_pVertScrollBar->GetPos(), 0.0f, szRange.height); m_pVertScrollBar->SetPos(fPos); m_pVertScrollBar->SetTrackPos(fPos); - if ((GetProperties()->m_dwStyleExes & - FWL_STYLEEXT_LTB_ShowScrollBarFocus) == 0 || - (GetProperties()->m_dwStates & FWL_WGTSTATE_Focused)) { + if ((m_Properties.m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == + 0 || + (m_Properties.m_dwStates & FWL_WGTSTATE_Focused)) { m_pVertScrollBar->RemoveStates(FWL_WGTSTATE_Invisible); } m_pVertScrollBar->Update(); @@ -529,9 +529,9 @@ pdfium::clamp(m_pHorzScrollBar->GetPos(), 0.0f, szRange.height); m_pHorzScrollBar->SetPos(fPos); m_pHorzScrollBar->SetTrackPos(fPos); - if ((GetProperties()->m_dwStyleExes & - FWL_STYLEEXT_LTB_ShowScrollBarFocus) == 0 || - (GetProperties()->m_dwStates & FWL_WGTSTATE_Focused)) { + if ((m_Properties.m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == + 0 || + (m_Properties.m_dwStates & FWL_WGTSTATE_Focused)) { m_pHorzScrollBar->RemoveStates(FWL_WGTSTATE_Invisible); } m_pHorzScrollBar->Update(); @@ -589,22 +589,22 @@ if (m_pVertScrollBar) return; - auto prop = std::make_unique<CFWL_WidgetProperties>(); - prop->m_dwStyleExes = FWL_STYLEEXT_SCB_Vert; - prop->m_dwStates = FWL_WGTSTATE_Invisible; + Properties prop; + prop.m_dwStyleExes = FWL_STYLEEXT_SCB_Vert; + prop.m_dwStates = FWL_WGTSTATE_Invisible; m_pVertScrollBar = - std::make_unique<CFWL_ScrollBar>(GetOwnerApp(), std::move(prop), this); + std::make_unique<CFWL_ScrollBar>(GetOwnerApp(), prop, this); } void CFWL_ListBox::InitHorizontalScrollBar() { if (m_pHorzScrollBar) return; - auto prop = std::make_unique<CFWL_WidgetProperties>(); - prop->m_dwStyleExes = FWL_STYLEEXT_SCB_Horz; - prop->m_dwStates = FWL_WGTSTATE_Invisible; + Properties prop; + prop.m_dwStyleExes = FWL_STYLEEXT_SCB_Horz; + prop.m_dwStates = FWL_WGTSTATE_Invisible; m_pHorzScrollBar = - std::make_unique<CFWL_ScrollBar>(GetOwnerApp(), std::move(prop), this); + std::make_unique<CFWL_ScrollBar>(GetOwnerApp(), prop, this); } bool CFWL_ListBox::IsShowScrollBar(bool bVert) { @@ -613,9 +613,8 @@ if (!pScrollbar || !pScrollbar->IsVisible()) return false; - return !(GetProperties()->m_dwStyleExes & - FWL_STYLEEXT_LTB_ShowScrollBarFocus) || - (GetProperties()->m_dwStates & FWL_WGTSTATE_Focused); + return !(m_Properties.m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) || + (m_Properties.m_dwStates & FWL_WGTSTATE_Focused); } void CFWL_ListBox::OnProcessMessage(CFWL_Message* pMessage) { @@ -696,9 +695,9 @@ } } if (bSet) - GetProperties()->m_dwStates |= (FWL_WGTSTATE_Focused); + m_Properties.m_dwStates |= (FWL_WGTSTATE_Focused); else - GetProperties()->m_dwStates &= ~(FWL_WGTSTATE_Focused); + m_Properties.m_dwStates &= ~(FWL_WGTSTATE_Focused); RepaintRect(m_ClientRect); }
diff --git a/xfa/fwl/cfwl_listbox.h b/xfa/fwl/cfwl_listbox.h index c45e0a5..685d910 100644 --- a/xfa/fwl/cfwl_listbox.h +++ b/xfa/fwl/cfwl_listbox.h
@@ -15,7 +15,6 @@ #include "xfa/fwl/cfwl_listbox.h" #include "xfa/fwl/cfwl_listitem.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fwl/cfwl_widgetproperties.h" #define FWL_STYLEEXT_LTB_MultiSelection (1L << 0) #define FWL_STYLEEXT_LTB_LeftAlign (0L << 4) @@ -33,9 +32,9 @@ class CFWL_ListBox : public CFWL_Widget { public: - explicit CFWL_ListBox(const CFWL_App* pApp, - std::unique_ptr<CFWL_WidgetProperties> properties, - CFWL_Widget* pOuter); + CFWL_ListBox(const CFWL_App* pApp, + const Properties& properties, + CFWL_Widget* pOuter); ~CFWL_ListBox() override; // CFWL_Widget
diff --git a/xfa/fwl/cfwl_monthcalendar.cpp b/xfa/fwl/cfwl_monthcalendar.cpp index 49f9f74..5af4080 100644 --- a/xfa/fwl/cfwl_monthcalendar.cpp +++ b/xfa/fwl/cfwl_monthcalendar.cpp
@@ -85,11 +85,10 @@ } // namespace -CFWL_MonthCalendar::CFWL_MonthCalendar( - const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, - CFWL_Widget* pOuter) - : CFWL_Widget(app, std::move(properties), pOuter) {} +CFWL_MonthCalendar::CFWL_MonthCalendar(const CFWL_App* app, + const Properties& properties, + CFWL_Widget* pOuter) + : CFWL_Widget(app, properties, pOuter) {} CFWL_MonthCalendar::~CFWL_MonthCalendar() = default;
diff --git a/xfa/fwl/cfwl_monthcalendar.h b/xfa/fwl/cfwl_monthcalendar.h index f57b443..6488a02 100644 --- a/xfa/fwl/cfwl_monthcalendar.h +++ b/xfa/fwl/cfwl_monthcalendar.h
@@ -13,7 +13,6 @@ #include "core/fxcrt/cfx_datetime.h" #include "xfa/fwl/cfwl_event.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fwl/cfwl_widgetproperties.h" #define FWL_ITEMSTATE_MCD_Flag (1L << 0) #define FWL_ITEMSTATE_MCD_Selected (1L << 1) @@ -23,7 +22,7 @@ class CFWL_MonthCalendar final : public CFWL_Widget { public: CFWL_MonthCalendar(const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, + const Properties& properties, CFWL_Widget* pOuter); ~CFWL_MonthCalendar() override;
diff --git a/xfa/fwl/cfwl_picturebox.cpp b/xfa/fwl/cfwl_picturebox.cpp index c1254a1..fafa67e 100644 --- a/xfa/fwl/cfwl_picturebox.cpp +++ b/xfa/fwl/cfwl_picturebox.cpp
@@ -6,10 +6,8 @@ #include "xfa/fwl/cfwl_picturebox.h" -#include <memory> - CFWL_PictureBox::CFWL_PictureBox(const CFWL_App* app) - : CFWL_Widget(app, std::make_unique<CFWL_WidgetProperties>(), nullptr) {} + : CFWL_Widget(app, CFWL_Widget::Properties(), nullptr) {} CFWL_PictureBox::~CFWL_PictureBox() = default;
diff --git a/xfa/fwl/cfwl_picturebox.h b/xfa/fwl/cfwl_picturebox.h index e7e0a05..967af73 100644 --- a/xfa/fwl/cfwl_picturebox.h +++ b/xfa/fwl/cfwl_picturebox.h
@@ -8,7 +8,6 @@ #define XFA_FWL_CFWL_PICTUREBOX_H_ #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fwl/cfwl_widgetproperties.h" class CFX_DIBitmap; class CFWL_Widget;
diff --git a/xfa/fwl/cfwl_pushbutton.cpp b/xfa/fwl/cfwl_pushbutton.cpp index 9e7d470..d0764d8 100644 --- a/xfa/fwl/cfwl_pushbutton.cpp +++ b/xfa/fwl/cfwl_pushbutton.cpp
@@ -6,7 +6,6 @@ #include "xfa/fwl/cfwl_pushbutton.h" -#include <memory> #include <utility> #include "xfa/fde/cfde_textout.h" @@ -21,7 +20,7 @@ #include "xfa/fwl/ifwl_themeprovider.h" CFWL_PushButton::CFWL_PushButton(const CFWL_App* app) - : CFWL_Widget(app, std::make_unique<CFWL_WidgetProperties>(), nullptr) {} + : CFWL_Widget(app, Properties(), nullptr) {} CFWL_PushButton::~CFWL_PushButton() = default; @@ -31,7 +30,7 @@ void CFWL_PushButton::SetStates(uint32_t dwStates) { if (dwStates & FWL_WGTSTATE_Disabled) { - GetProperties()->m_dwStates = FWL_WGTSTATE_Disabled; + m_Properties.m_dwStates = FWL_WGTSTATE_Disabled; return; } CFWL_Widget::SetStates(dwStates); @@ -66,20 +65,20 @@ if (pMatrix) param.m_matrix.Concat(*pMatrix); param.m_PartRect = m_ClientRect; - if (GetProperties()->m_dwStates & FWL_WGTSTATE_Focused) + if (m_Properties.m_dwStates & FWL_WGTSTATE_Focused) param.m_pRtData = &m_CaptionRect; GetThemeProvider()->DrawBackground(param); } uint32_t CFWL_PushButton::GetPartStates() { uint32_t dwStates = CFWL_PartState_Normal; - if (GetProperties()->m_dwStates & FWL_WGTSTATE_Focused) + if (m_Properties.m_dwStates & FWL_WGTSTATE_Focused) dwStates |= CFWL_PartState_Focused; - if (GetProperties()->m_dwStates & FWL_WGTSTATE_Disabled) + if (m_Properties.m_dwStates & FWL_WGTSTATE_Disabled) dwStates = CFWL_PartState_Disabled; - else if (GetProperties()->m_dwStates & FWL_STATE_PSB_Pressed) + else if (m_Properties.m_dwStates & FWL_STATE_PSB_Pressed) dwStates |= CFWL_PartState_Pressed; - else if (GetProperties()->m_dwStates & FWL_STATE_PSB_Hovered) + else if (m_Properties.m_dwStates & FWL_STATE_PSB_Hovered) dwStates |= CFWL_PartState_Hovered; return dwStates; } @@ -136,28 +135,28 @@ void CFWL_PushButton::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { if (bSet) - GetProperties()->m_dwStates |= FWL_WGTSTATE_Focused; + m_Properties.m_dwStates |= FWL_WGTSTATE_Focused; else - GetProperties()->m_dwStates &= ~FWL_WGTSTATE_Focused; + m_Properties.m_dwStates &= ~FWL_WGTSTATE_Focused; RepaintRect(m_ClientRect); } void CFWL_PushButton::OnLButtonDown(CFWL_MessageMouse* pMsg) { m_bBtnDown = true; - GetProperties()->m_dwStates |= FWL_STATE_PSB_Hovered; - GetProperties()->m_dwStates |= FWL_STATE_PSB_Pressed; + m_Properties.m_dwStates |= FWL_STATE_PSB_Hovered; + m_Properties.m_dwStates |= FWL_STATE_PSB_Pressed; RepaintRect(m_ClientRect); } void CFWL_PushButton::OnLButtonUp(CFWL_MessageMouse* pMsg) { m_bBtnDown = false; if (m_ClientRect.Contains(pMsg->m_pos)) { - GetProperties()->m_dwStates &= ~FWL_STATE_PSB_Pressed; - GetProperties()->m_dwStates |= FWL_STATE_PSB_Hovered; + m_Properties.m_dwStates &= ~FWL_STATE_PSB_Pressed; + m_Properties.m_dwStates |= FWL_STATE_PSB_Hovered; } else { - GetProperties()->m_dwStates &= ~FWL_STATE_PSB_Hovered; - GetProperties()->m_dwStates &= ~FWL_STATE_PSB_Pressed; + m_Properties.m_dwStates &= ~FWL_STATE_PSB_Hovered; + m_Properties.m_dwStates &= ~FWL_STATE_PSB_Pressed; } if (m_ClientRect.Contains(pMsg->m_pos)) { CFWL_Event wmClick(CFWL_Event::Type::Click, this); @@ -170,29 +169,29 @@ bool bRepaint = false; if (m_bBtnDown) { if (m_ClientRect.Contains(pMsg->m_pos)) { - if ((GetProperties()->m_dwStates & FWL_STATE_PSB_Pressed) == 0) { - GetProperties()->m_dwStates |= FWL_STATE_PSB_Pressed; + if ((m_Properties.m_dwStates & FWL_STATE_PSB_Pressed) == 0) { + m_Properties.m_dwStates |= FWL_STATE_PSB_Pressed; bRepaint = true; } - if (GetProperties()->m_dwStates & FWL_STATE_PSB_Hovered) { - GetProperties()->m_dwStates &= ~FWL_STATE_PSB_Hovered; + if (m_Properties.m_dwStates & FWL_STATE_PSB_Hovered) { + m_Properties.m_dwStates &= ~FWL_STATE_PSB_Hovered; bRepaint = true; } } else { - if (GetProperties()->m_dwStates & FWL_STATE_PSB_Pressed) { - GetProperties()->m_dwStates &= ~FWL_STATE_PSB_Pressed; + if (m_Properties.m_dwStates & FWL_STATE_PSB_Pressed) { + m_Properties.m_dwStates &= ~FWL_STATE_PSB_Pressed; bRepaint = true; } - if ((GetProperties()->m_dwStates & FWL_STATE_PSB_Hovered) == 0) { - GetProperties()->m_dwStates |= FWL_STATE_PSB_Hovered; + if ((m_Properties.m_dwStates & FWL_STATE_PSB_Hovered) == 0) { + m_Properties.m_dwStates |= FWL_STATE_PSB_Hovered; bRepaint = true; } } } else { if (!m_ClientRect.Contains(pMsg->m_pos)) return; - if ((GetProperties()->m_dwStates & FWL_STATE_PSB_Hovered) == 0) { - GetProperties()->m_dwStates |= FWL_STATE_PSB_Hovered; + if ((m_Properties.m_dwStates & FWL_STATE_PSB_Hovered) == 0) { + m_Properties.m_dwStates |= FWL_STATE_PSB_Hovered; bRepaint = true; } } @@ -202,8 +201,8 @@ void CFWL_PushButton::OnMouseLeave(CFWL_MessageMouse* pMsg) { m_bBtnDown = false; - GetProperties()->m_dwStates &= ~FWL_STATE_PSB_Hovered; - GetProperties()->m_dwStates &= ~FWL_STATE_PSB_Pressed; + m_Properties.m_dwStates &= ~FWL_STATE_PSB_Hovered; + m_Properties.m_dwStates &= ~FWL_STATE_PSB_Pressed; RepaintRect(m_ClientRect); }
diff --git a/xfa/fwl/cfwl_pushbutton.h b/xfa/fwl/cfwl_pushbutton.h index 67403a6..7f83a74 100644 --- a/xfa/fwl/cfwl_pushbutton.h +++ b/xfa/fwl/cfwl_pushbutton.h
@@ -8,7 +8,6 @@ #define XFA_FWL_CFWL_PUSHBUTTON_H_ #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fwl/cfwl_widgetproperties.h" #define FWL_STATE_PSB_Hovered (1 << FWL_WGTSTATE_MAX) #define FWL_STATE_PSB_Pressed (1 << (FWL_WGTSTATE_MAX + 1))
diff --git a/xfa/fwl/cfwl_scrollbar.cpp b/xfa/fwl/cfwl_scrollbar.cpp index 000c10d..1a7bbde 100644 --- a/xfa/fwl/cfwl_scrollbar.cpp +++ b/xfa/fwl/cfwl_scrollbar.cpp
@@ -27,11 +27,10 @@ } // namespace -CFWL_ScrollBar::CFWL_ScrollBar( - const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, - CFWL_Widget* pOuter) - : CFWL_Widget(app, std::move(properties), pOuter) {} +CFWL_ScrollBar::CFWL_ScrollBar(const CFWL_App* app, + const Properties& properties, + CFWL_Widget* pOuter) + : CFWL_Widget(app, properties, pOuter) {} CFWL_ScrollBar::~CFWL_ScrollBar() = default; @@ -80,7 +79,7 @@ CFWL_ThemeBackground param; param.m_pWidget = this; param.m_iPart = bLower ? CFWL_Part::LowerTrack : CFWL_Part::UpperTrack; - param.m_dwStates = (GetProperties()->m_dwStates & FWL_WGTSTATE_Disabled) + param.m_dwStates = (m_Properties.m_dwStates & FWL_WGTSTATE_Disabled) ? CFWL_PartState_Disabled : (bLower ? m_iMinTrackState : m_iMaxTrackState); param.m_pGraphics = pGraphics; @@ -95,7 +94,7 @@ CFWL_ThemeBackground param; param.m_pWidget = this; param.m_iPart = bMinBtn ? CFWL_Part::ForeArrow : CFWL_Part::BackArrow; - param.m_dwStates = (GetProperties()->m_dwStates & FWL_WGTSTATE_Disabled) + param.m_dwStates = (m_Properties.m_dwStates & FWL_WGTSTATE_Disabled) ? CFWL_PartState_Disabled : (bMinBtn ? m_iMinButtonState : m_iMaxButtonState); param.m_pGraphics = pGraphics; @@ -110,7 +109,7 @@ CFWL_ThemeBackground param; param.m_pWidget = this; param.m_iPart = CFWL_Part::Thumb; - param.m_dwStates = (GetProperties()->m_dwStates & FWL_WGTSTATE_Disabled) + param.m_dwStates = (m_Properties.m_dwStates & FWL_WGTSTATE_Disabled) ? CFWL_PartState_Disabled : m_iThumbButtonState; param.m_pGraphics = pGraphics;
diff --git a/xfa/fwl/cfwl_scrollbar.h b/xfa/fwl/cfwl_scrollbar.h index 83899b0..da29b3d 100644 --- a/xfa/fwl/cfwl_scrollbar.h +++ b/xfa/fwl/cfwl_scrollbar.h
@@ -14,9 +14,6 @@ #include "core/fxcrt/unowned_ptr.h" #include "xfa/fwl/cfwl_eventscroll.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fwl/cfwl_widgetproperties.h" - -class CFWL_Widget; #define FWL_STYLEEXT_SCB_Horz (0L << 0) #define FWL_STYLEEXT_SCB_Vert (1L << 0) @@ -25,7 +22,7 @@ public CFX_Timer::CallbackIface { public: CFWL_ScrollBar(const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, + const Properties& properties, CFWL_Widget* pOuter); ~CFWL_ScrollBar() override; @@ -60,7 +57,7 @@ private: bool IsVertical() const { - return !!(GetProperties()->m_dwStyleExes & FWL_STYLEEXT_SCB_Vert); + return !!(m_Properties.m_dwStyleExes & FWL_STYLEEXT_SCB_Vert); } void DrawTrack(CXFA_Graphics* pGraphics, bool bLower,
diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp index aeb819f..9708768 100644 --- a/xfa/fwl/cfwl_widget.cpp +++ b/xfa/fwl/cfwl_widget.cpp
@@ -33,14 +33,12 @@ #define FWL_WGT_CalcMultiLineDefWidth 120.0f CFWL_Widget::CFWL_Widget(const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, + const Properties& properties, CFWL_Widget* pOuter) - : m_pOwnerApp(app), + : m_Properties(properties), + m_pOwnerApp(app), m_pWidgetMgr(app->GetWidgetMgr()), - m_pProperties(std::move(properties)), m_pOuter(pOuter) { - ASSERT(m_pWidgetMgr); - ASSERT(m_pProperties); m_pWidgetMgr->InsertWidget(m_pOuter, this); } @@ -80,21 +78,14 @@ void CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved) { - m_pProperties->m_dwStyles = - (m_pProperties->m_dwStyles & ~dwStylesRemoved) | dwStylesAdded; -} - -uint32_t CFWL_Widget::GetStylesEx() const { - return m_pProperties->m_dwStyleExes; -} -uint32_t CFWL_Widget::GetStates() const { - return m_pProperties->m_dwStates; + m_Properties.m_dwStyles &= ~dwStylesRemoved; + m_Properties.m_dwStyles |= dwStylesAdded; } void CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved) { - m_pProperties->m_dwStyleExes = - (m_pProperties->m_dwStyleExes & ~dwStylesExRemoved) | dwStylesExAdded; + m_Properties.m_dwStyleExes &= ~dwStylesExRemoved; + m_Properties.m_dwStyleExes |= dwStylesExAdded; } static void NotifyHideChildWidget(CFWL_WidgetMgr* widgetMgr, @@ -109,7 +100,7 @@ } void CFWL_Widget::SetStates(uint32_t dwStates) { - m_pProperties->m_dwStates |= dwStates; + m_Properties.m_dwStates |= dwStates; if (IsVisible()) return; @@ -123,11 +114,10 @@ NotifyHideChildWidget(widgetMgr, child, noteDriver); child = widgetMgr->GetNextSiblingWidget(child); } - return; } void CFWL_Widget::RemoveStates(uint32_t dwStates) { - m_pProperties->m_dwStates &= ~dwStates; + m_Properties.m_dwStates &= ~dwStates; } FWL_WidgetHit CFWL_Widget::HitTest(const CFX_PointF& point) { @@ -172,28 +162,28 @@ } bool CFWL_Widget::IsEnabled() const { - return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0; + return (m_Properties.m_dwStates & FWL_WGTSTATE_Disabled) == 0; } bool CFWL_Widget::HasBorder() const { - return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border); + return !!(m_Properties.m_dwStyles & FWL_WGTSTYLE_Border); } bool CFWL_Widget::IsVisible() const { - return !(m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible); + return !(m_Properties.m_dwStates & FWL_WGTSTATE_Invisible); } bool CFWL_Widget::IsOverLapper() const { - return (m_pProperties->m_dwStyles & FWL_WGTSTYLE_WindowTypeMask) == + return (m_Properties.m_dwStyles & FWL_WGTSTYLE_WindowTypeMask) == FWL_WGTSTYLE_OverLapper; } bool CFWL_Widget::IsPopup() const { - return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Popup); + return !!(m_Properties.m_dwStyles & FWL_WGTSTYLE_Popup); } bool CFWL_Widget::IsChild() const { - return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Child); + return !!(m_Properties.m_dwStyles & FWL_WGTSTYLE_Child); } CFWL_Widget* CFWL_Widget::GetOutmost() const { @@ -357,6 +347,12 @@ void CFWL_Widget::OnDrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) {} +CFWL_Widget::Properties::Properties() = default; + +CFWL_Widget::Properties::Properties(const Properties& that) = default; + +CFWL_Widget::Properties::~Properties() = default; + CFWL_Widget::ScopedUpdateLock::ScopedUpdateLock(CFWL_Widget* widget) : widget_(widget) { widget_->LockUpdate();
diff --git a/xfa/fwl/cfwl_widget.h b/xfa/fwl/cfwl_widget.h index c475aa9..9fe3a53 100644 --- a/xfa/fwl/cfwl_widget.h +++ b/xfa/fwl/cfwl_widget.h
@@ -7,8 +7,6 @@ #ifndef XFA_FWL_CFWL_WIDGET_H_ #define XFA_FWL_CFWL_WIDGET_H_ -#include <memory> - #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_system.h" #include "core/fxcrt/observed_ptr.h" @@ -16,7 +14,7 @@ #include "xfa/fde/cfde_data.h" #include "xfa/fwl/cfwl_themepart.h" #include "xfa/fwl/cfwl_widgetmgr.h" -#include "xfa/fwl/cfwl_widgetproperties.h" +#include "xfa/fwl/fwl_widgetdef.h" #include "xfa/fwl/fwl_widgethit.h" #include "xfa/fwl/ifwl_widgetdelegate.h" @@ -59,6 +57,17 @@ virtual void GetBorderColorAndThickness(FX_ARGB* cr, float* fWidth) = 0; }; + class Properties { + public: + Properties(); + Properties(const Properties& that); + ~Properties(); + + uint32_t m_dwStyles = FWL_WGTSTYLE_Child; + uint32_t m_dwStyleExes = 0; + uint32_t m_dwStates = 0; + }; + class ScopedUpdateLock { public: explicit ScopedUpdateLock(CFWL_Widget* widget); @@ -103,8 +112,8 @@ CFWL_Widget* GetOutmost() const; void ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved); - uint32_t GetStylesEx() const; - uint32_t GetStates() const; + uint32_t GetStylesEx() const { return m_Properties.m_dwStyleExes; } + uint32_t GetStates() const { return m_Properties.m_dwStates; } CFX_PointF TransformTo(CFWL_Widget* pWidget, const CFX_PointF& point); CFX_Matrix GetMatrix() const; @@ -127,7 +136,7 @@ protected: CFWL_Widget(const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, + const Properties& properties, CFWL_Widget* pOuter); bool IsEnabled() const; @@ -137,10 +146,6 @@ float GetCXBorderSize() const; float GetCYBorderSize() const; CFX_RectF GetRelativeRect() const; - CFWL_WidgetProperties* GetProperties() { return m_pProperties.get(); } - const CFWL_WidgetProperties* GetProperties() const { - return m_pProperties.get(); - } CFX_SizeF CalcTextSize(const WideString& wsText, bool bMultiLine); void CalcTextRect(const WideString& wsText, @@ -155,6 +160,7 @@ CFWL_Part iPartBorder, const CFX_Matrix& pMatrix); + Properties m_Properties; CFX_RectF m_WidgetRect; private: @@ -176,7 +182,6 @@ uint64_t m_nEventKey = 0; UnownedPtr<const CFWL_App> const m_pOwnerApp; UnownedPtr<CFWL_WidgetMgr> const m_pWidgetMgr; - std::unique_ptr<CFWL_WidgetProperties> m_pProperties; CFWL_Widget* const m_pOuter; AdapterIface* m_pAdapterIface = nullptr; UnownedPtr<IFWL_WidgetDelegate> m_pDelegate;
diff --git a/xfa/fwl/cfwl_widgetproperties.cpp b/xfa/fwl/cfwl_widgetproperties.cpp deleted file mode 100644 index f592d7b..0000000 --- a/xfa/fwl/cfwl_widgetproperties.cpp +++ /dev/null
@@ -1,14 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fwl/cfwl_widgetproperties.h" - -CFWL_WidgetProperties::CFWL_WidgetProperties() = default; - -CFWL_WidgetProperties::CFWL_WidgetProperties( - const CFWL_WidgetProperties& that) = default; - -CFWL_WidgetProperties::~CFWL_WidgetProperties() = default;
diff --git a/xfa/fwl/cfwl_widgetproperties.h b/xfa/fwl/cfwl_widgetproperties.h deleted file mode 100644 index 8d3c8ec..0000000 --- a/xfa/fwl/cfwl_widgetproperties.h +++ /dev/null
@@ -1,24 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FWL_CFWL_WIDGETPROPERTIES_H_ -#define XFA_FWL_CFWL_WIDGETPROPERTIES_H_ - -#include "core/fxcrt/fx_system.h" -#include "xfa/fwl/fwl_widgetdef.h" - -class CFWL_WidgetProperties { - public: - CFWL_WidgetProperties(); - CFWL_WidgetProperties(const CFWL_WidgetProperties& that); - ~CFWL_WidgetProperties(); - - uint32_t m_dwStyles = FWL_WGTSTYLE_Child; - uint32_t m_dwStyleExes = 0; - uint32_t m_dwStates = 0; -}; - -#endif // XFA_FWL_CFWL_WIDGETPROPERTIES_H_
diff --git a/xfa/fxfa/cxfa_fflistbox.cpp b/xfa/fxfa/cxfa_fflistbox.cpp index 76a28c6..655311a 100644 --- a/xfa/fxfa/cxfa_fflistbox.cpp +++ b/xfa/fxfa/cxfa_fflistbox.cpp
@@ -44,7 +44,7 @@ RetainPtr<CXFA_ContentLayoutItem> retain_layout(m_pLayoutItem.Get()); auto pNew = std::make_unique<CFWL_ListBox>( - GetFWLApp(), std::make_unique<CFWL_WidgetProperties>(), nullptr); + GetFWLApp(), CFWL_Widget::Properties(), nullptr); CFWL_ListBox* pListBox = pNew.get(); pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground, 0xFFFFFFFF);
diff --git a/xfa/fxfa/cxfa_ffnumericedit.cpp b/xfa/fxfa/cxfa_ffnumericedit.cpp index dae089c..da60a3a 100644 --- a/xfa/fxfa/cxfa_ffnumericedit.cpp +++ b/xfa/fxfa/cxfa_ffnumericedit.cpp
@@ -29,7 +29,7 @@ RetainPtr<CXFA_ContentLayoutItem> retain_layout(m_pLayoutItem.Get()); auto pNewEdit = std::make_unique<CFWL_Edit>( - GetFWLApp(), std::make_unique<CFWL_WidgetProperties>(), nullptr); + GetFWLApp(), CFWL_Widget::Properties(), nullptr); CFWL_Edit* pWidget = pNewEdit.get(); SetNormalWidget(std::move(pNewEdit)); pWidget->SetAdapterIface(this);
diff --git a/xfa/fxfa/cxfa_ffpasswordedit.cpp b/xfa/fxfa/cxfa_ffpasswordedit.cpp index b0ece33..7d222b7 100644 --- a/xfa/fxfa/cxfa_ffpasswordedit.cpp +++ b/xfa/fxfa/cxfa_ffpasswordedit.cpp
@@ -28,7 +28,7 @@ RetainPtr<CXFA_ContentLayoutItem> retain_layout(m_pLayoutItem.Get()); auto pNewEdit = std::make_unique<CFWL_Edit>( - GetFWLApp(), std::make_unique<CFWL_WidgetProperties>(), nullptr); + GetFWLApp(), CFWL_Widget::Properties(), nullptr); CFWL_Edit* pWidget = pNewEdit.get(); SetNormalWidget(std::move(pNewEdit)); pWidget->SetAdapterIface(this);
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp index c2833b8..b8579c2 100644 --- a/xfa/fxfa/cxfa_fftextedit.cpp +++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -49,7 +49,7 @@ RetainPtr<CXFA_ContentLayoutItem> retain_layout(m_pLayoutItem.Get()); auto pNewWidget = std::make_unique<CFWL_Edit>( - GetFWLApp(), std::make_unique<CFWL_WidgetProperties>(), nullptr); + GetFWLApp(), CFWL_Widget::Properties(), nullptr); CFWL_Edit* pFWLEdit = pNewWidget.get(); SetNormalWidget(std::move(pNewWidget)); pFWLEdit->SetAdapterIface(this);