summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-10-26 19:42:40 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-26 19:42:40 +0000
commit7df950ac2ef484880fe3cbfb9961bed34fee191d (patch)
tree922958659a46f1344c61cf16a1f7b92b3541ac1d
parent385bf2e0481230b1f5e50a2627063383bd297451 (diff)
downloadpdfium-7df950ac2ef484880fe3cbfb9961bed34fee191d.tar.xz
Stop transfering ownership of |this| as CPWL_Wnd::Create() side-effect
Instead, make it an explicit method called on the parent outside of create. Rename Create() to Realize() to be sure to catch all usages, and add the new required call. Attachment to the parent now takes place a little earlier on in the life-cycle as a result but should be ok. Precursor to converting to smart pointers. Change-Id: I45c459fcd28b5d03c428ce5809d0432506cf4ec6 Reviewed-on: https://pdfium-review.googlesource.com/c/44690 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
-rw-r--r--fpdfsdk/formfiller/cffl_checkbox.cpp4
-rw-r--r--fpdfsdk/formfiller/cffl_combobox.cpp4
-rw-r--r--fpdfsdk/formfiller/cffl_listbox.cpp4
-rw-r--r--fpdfsdk/formfiller/cffl_pushbutton.cpp4
-rw-r--r--fpdfsdk/formfiller/cffl_radiobutton.cpp4
-rw-r--r--fpdfsdk/formfiller/cffl_textfield.cpp4
-rw-r--r--fpdfsdk/pwl/cpwl_appstream.cpp4
-rw-r--r--fpdfsdk/pwl/cpwl_combo_box.cpp9
-rw-r--r--fpdfsdk/pwl/cpwl_edit_ctrl.cpp3
-rw-r--r--fpdfsdk/pwl/cpwl_scroll_bar.cpp12
-rw-r--r--fpdfsdk/pwl/cpwl_wnd.cpp10
-rw-r--r--fpdfsdk/pwl/cpwl_wnd.h12
12 files changed, 45 insertions, 29 deletions
diff --git a/fpdfsdk/formfiller/cffl_checkbox.cpp b/fpdfsdk/formfiller/cffl_checkbox.cpp
index 3dbac1aa84..d9add785aa 100644
--- a/fpdfsdk/formfiller/cffl_checkbox.cpp
+++ b/fpdfsdk/formfiller/cffl_checkbox.cpp
@@ -25,7 +25,9 @@ std::unique_ptr<CPWL_Wnd> CFFL_CheckBox::NewPWLWindow(
const CPWL_Wnd::CreateParams& cp,
std::unique_ptr<CPWL_Wnd::PrivateData> pAttachedData) {
auto pWnd = pdfium::MakeUnique<CPWL_CheckBox>(std::move(pAttachedData));
- pWnd->Create(cp);
+ if (cp.pParentWnd)
+ cp.pParentWnd->AddChild(pWnd.get());
+ pWnd->Realize(cp);
pWnd->SetCheck(m_pWidget->IsChecked());
return std::move(pWnd);
}
diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp
index b068171250..7d2124c306 100644
--- a/fpdfsdk/formfiller/cffl_combobox.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -48,8 +48,10 @@ std::unique_ptr<CPWL_Wnd> CFFL_ComboBox::NewPWLWindow(
const CPWL_Wnd::CreateParams& cp,
std::unique_ptr<CPWL_Wnd::PrivateData> pAttachedData) {
auto pWnd = pdfium::MakeUnique<CPWL_ComboBox>(std::move(pAttachedData));
+ if (cp.pParentWnd)
+ cp.pParentWnd->AddChild(pWnd.get());
pWnd->AttachFFLData(this);
- pWnd->Create(cp);
+ pWnd->Realize(cp);
CFFL_InteractiveFormFiller* pFormFiller =
m_pFormFillEnv->GetInteractiveFormFiller();
diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp
index 4eb3a7105b..335073293f 100644
--- a/fpdfsdk/formfiller/cffl_listbox.cpp
+++ b/fpdfsdk/formfiller/cffl_listbox.cpp
@@ -43,8 +43,10 @@ std::unique_ptr<CPWL_Wnd> CFFL_ListBox::NewPWLWindow(
const CPWL_Wnd::CreateParams& cp,
std::unique_ptr<CPWL_Wnd::PrivateData> pAttachedData) {
auto pWnd = pdfium::MakeUnique<CPWL_ListBox>(std::move(pAttachedData));
+ if (cp.pParentWnd)
+ cp.pParentWnd->AddChild(pWnd.get());
pWnd->AttachFFLData(this);
- pWnd->Create(cp);
+ pWnd->Realize(cp);
pWnd->SetFillerNotify(m_pFormFillEnv->GetInteractiveFormFiller());
for (int32_t i = 0, sz = m_pWidget->CountOptions(); i < sz; i++)
diff --git a/fpdfsdk/formfiller/cffl_pushbutton.cpp b/fpdfsdk/formfiller/cffl_pushbutton.cpp
index 04db191572..4c9a1ed4cb 100644
--- a/fpdfsdk/formfiller/cffl_pushbutton.cpp
+++ b/fpdfsdk/formfiller/cffl_pushbutton.cpp
@@ -21,6 +21,8 @@ std::unique_ptr<CPWL_Wnd> CFFL_PushButton::NewPWLWindow(
const CPWL_Wnd::CreateParams& cp,
std::unique_ptr<CPWL_Wnd::PrivateData> pAttachedData) {
auto pWnd = pdfium::MakeUnique<CPWL_PushButton>(std::move(pAttachedData));
- pWnd->Create(cp);
+ if (cp.pParentWnd)
+ cp.pParentWnd->AddChild(pWnd.get());
+ pWnd->Realize(cp);
return std::move(pWnd);
}
diff --git a/fpdfsdk/formfiller/cffl_radiobutton.cpp b/fpdfsdk/formfiller/cffl_radiobutton.cpp
index c8103d4a62..f987d7613c 100644
--- a/fpdfsdk/formfiller/cffl_radiobutton.cpp
+++ b/fpdfsdk/formfiller/cffl_radiobutton.cpp
@@ -24,7 +24,9 @@ std::unique_ptr<CPWL_Wnd> CFFL_RadioButton::NewPWLWindow(
const CPWL_Wnd::CreateParams& cp,
std::unique_ptr<CPWL_Wnd::PrivateData> pAttachedData) {
auto pWnd = pdfium::MakeUnique<CPWL_RadioButton>(std::move(pAttachedData));
- pWnd->Create(cp);
+ if (cp.pParentWnd)
+ cp.pParentWnd->AddChild(pWnd.get());
+ pWnd->Realize(cp);
pWnd->SetCheck(m_pWidget->IsChecked());
return std::move(pWnd);
}
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index a54939666f..fbbc63763b 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -74,7 +74,9 @@ std::unique_ptr<CPWL_Wnd> CFFL_TextField::NewPWLWindow(
std::unique_ptr<CPWL_Wnd::PrivateData> pAttachedData) {
auto pWnd = pdfium::MakeUnique<CPWL_Edit>(std::move(pAttachedData));
pWnd->AttachFFLData(this);
- pWnd->Create(cp);
+ if (cp.pParentWnd)
+ cp.pParentWnd->AddChild(pWnd.get());
+ pWnd->Realize(cp);
pWnd->SetFillerNotify(m_pFormFillEnv->GetInteractiveFormFiller());
int32_t nMaxLen = m_pWidget->GetMaxLen();
diff --git a/fpdfsdk/pwl/cpwl_appstream.cpp b/fpdfsdk/pwl/cpwl_appstream.cpp
index ebd47befc0..02541aa3b6 100644
--- a/fpdfsdk/pwl/cpwl_appstream.cpp
+++ b/fpdfsdk/pwl/cpwl_appstream.cpp
@@ -684,9 +684,9 @@ ByteString GenerateIconAppStream(CPDF_IconFit& fit,
return ByteString();
CPWL_Icon icon(nullptr);
- CPWL_Wnd::CreateParams cp;
+ CPWL_Wnd::CreateParams cp; // No parent.
cp.dwFlags = PWS_VISIBLE;
- icon.Create(cp);
+ icon.Realize(cp);
icon.SetIconFit(&fit);
icon.SetPDFStream(pIconStream);
if (!icon.Move(rcIcon, false, false))
diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp
index bb5890b519..db1def0758 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box.cpp
@@ -274,6 +274,7 @@ void CPWL_ComboBox::CreateEdit(const CreateParams& cp) {
m_pEdit = new CPWL_Edit(CloneAttachedData());
m_pEdit->AttachFFLData(m_pFormFiller.Get());
+ AddChild(m_pEdit.Get());
CreateParams ecp = cp;
ecp.pParentWnd = this;
@@ -289,7 +290,7 @@ void CPWL_ComboBox::CreateEdit(const CreateParams& cp) {
ecp.rcRectWnd = CFX_FloatRect();
ecp.dwBorderWidth = 0;
ecp.nBorderStyle = BorderStyle::SOLID;
- m_pEdit->Create(ecp);
+ m_pEdit->Realize(ecp);
}
void CPWL_ComboBox::CreateButton(const CreateParams& cp) {
@@ -297,6 +298,7 @@ void CPWL_ComboBox::CreateButton(const CreateParams& cp) {
return;
m_pButton = new CPWL_CBButton(CloneAttachedData());
+ AddChild(m_pButton.Get());
CreateParams bcp = cp;
bcp.pParentWnd = this;
@@ -307,7 +309,7 @@ void CPWL_ComboBox::CreateButton(const CreateParams& cp) {
bcp.dwBorderWidth = 2;
bcp.nBorderStyle = BorderStyle::BEVELED;
bcp.eCursorType = FXCT_ARROW;
- m_pButton->Create(bcp);
+ m_pButton->Realize(bcp);
}
void CPWL_ComboBox::CreateListBox(const CreateParams& cp) {
@@ -316,6 +318,7 @@ void CPWL_ComboBox::CreateListBox(const CreateParams& cp) {
m_pList = new CPWL_CBListBox(CloneAttachedData());
m_pList->AttachFFLData(m_pFormFiller.Get());
+ AddChild(m_pList.Get());
CreateParams lcp = cp;
lcp.pParentWnd = this;
@@ -335,7 +338,7 @@ void CPWL_ComboBox::CreateListBox(const CreateParams& cp) {
if (cp.sBackgroundColor.nColorType == CFX_Color::kTransparent)
lcp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
- m_pList->Create(lcp);
+ m_pList->Realize(lcp);
}
bool CPWL_ComboBox::RePosChildWnd() {
diff --git a/fpdfsdk/pwl/cpwl_edit_ctrl.cpp b/fpdfsdk/pwl/cpwl_edit_ctrl.cpp
index d27c6cd604..ea48c45376 100644
--- a/fpdfsdk/pwl/cpwl_edit_ctrl.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_ctrl.cpp
@@ -90,6 +90,7 @@ void CPWL_EditCtrl::CreateEditCaret(const CreateParams& cp) {
m_pEditCaret = new CPWL_Caret(CloneAttachedData());
m_pEditCaret->SetInvalidRect(GetClientRect());
+ AddChild(m_pEditCaret);
CreateParams ecp = cp;
ecp.pParentWnd = this;
@@ -97,7 +98,7 @@ void CPWL_EditCtrl::CreateEditCaret(const CreateParams& cp) {
ecp.dwBorderWidth = 0;
ecp.nBorderStyle = BorderStyle::SOLID;
ecp.rcRectWnd = CFX_FloatRect();
- m_pEditCaret->Create(ecp);
+ m_pEditCaret->Realize(ecp);
}
void CPWL_EditCtrl::SetFontSize(float fFontSize) {
diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.cpp b/fpdfsdk/pwl/cpwl_scroll_bar.cpp
index 4051d7be51..3e52e0d81b 100644
--- a/fpdfsdk/pwl/cpwl_scroll_bar.cpp
+++ b/fpdfsdk/pwl/cpwl_scroll_bar.cpp
@@ -543,19 +543,23 @@ void CPWL_ScrollBar::CreateButtons(const CreateParams& cp) {
if (!m_pMinButton) {
m_pMinButton = new CPWL_SBButton(CloneAttachedData(), m_sbType, PSBT_MIN);
- m_pMinButton->Create(scp);
+ AddChild(m_pMinButton.Get());
+ m_pMinButton->Realize(scp);
}
if (!m_pMaxButton) {
m_pMaxButton = new CPWL_SBButton(CloneAttachedData(), m_sbType, PSBT_MAX);
- m_pMaxButton->Create(scp);
+ AddChild(m_pMaxButton.Get());
+ m_pMaxButton->Realize(scp);
}
if (!m_pPosButton) {
m_pPosButton = new CPWL_SBButton(CloneAttachedData(), m_sbType, PSBT_POS);
ObservedPtr thisObserved(this);
- if (m_pPosButton->SetVisible(false) && thisObserved)
- m_pPosButton->Create(scp);
+ if (m_pPosButton->SetVisible(false) && thisObserved) {
+ AddChild(m_pPosButton.Get());
+ m_pPosButton->Realize(scp);
+ }
}
}
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp
index 6767164073..d5d2102997 100644
--- a/fpdfsdk/pwl/cpwl_wnd.cpp
+++ b/fpdfsdk/pwl/cpwl_wnd.cpp
@@ -118,9 +118,8 @@ CPWL_Wnd::~CPWL_Wnd() {
ASSERT(!m_bCreated);
}
-void CPWL_Wnd::Create(const CreateParams& cp) {
- if (IsValid())
- return;
+void CPWL_Wnd::Realize(const CreateParams& cp) {
+ ASSERT(!m_bCreated);
m_CreationParams = cp;
OnCreate(&m_CreationParams);
@@ -132,8 +131,6 @@ void CPWL_Wnd::Create(const CreateParams& cp) {
m_rcClip.Normalize();
}
CreateMsgControl();
- if (m_CreationParams.pParentWnd)
- m_CreationParams.pParentWnd->AddChild(this);
CreateParams ccp = m_CreationParams;
ccp.dwFlags &= 0xFFFF0000L; // remove sub styles
@@ -501,7 +498,8 @@ void CPWL_Wnd::CreateVScrollBar(const CreateParams& cp) {
scp.nTransparency = PWL_SCROLLBAR_TRANSPARENCY;
m_pVScrollBar = new CPWL_ScrollBar(CloneAttachedData(), SBT_VSCROLL);
- m_pVScrollBar->Create(scp);
+ AddChild(m_pVScrollBar.Get());
+ m_pVScrollBar->Realize(scp);
}
void CPWL_Wnd::SetCapture() {
diff --git a/fpdfsdk/pwl/cpwl_wnd.h b/fpdfsdk/pwl/cpwl_wnd.h
index 921693f148..8d7eebc5e9 100644
--- a/fpdfsdk/pwl/cpwl_wnd.h
+++ b/fpdfsdk/pwl/cpwl_wnd.h
@@ -177,15 +177,16 @@ class CPWL_Wnd : public CPWL_TimerHandler, public Observable<CPWL_Wnd> {
virtual CFX_FloatRect GetFocusRect() const;
virtual CFX_FloatRect GetClientRect() const;
- void InvalidateFocusHandler(FocusHandlerIface* handler);
- void InvalidateProvider(ProviderIface* provider);
- void Create(const CreateParams& cp);
+ void AddChild(CPWL_Wnd* pWnd);
+ void RemoveChild(CPWL_Wnd* pWnd);
+ void Realize(const CreateParams& cp);
void Destroy();
bool Move(const CFX_FloatRect& rcNew, bool bReset, bool bRefresh);
+ void InvalidateFocusHandler(FocusHandlerIface* handler);
+ void InvalidateProvider(ProviderIface* provider);
void SetCapture();
void ReleaseCapture();
-
void DrawAppearance(CFX_RenderDevice* pDevice,
const CFX_Matrix& mtUser2Device);
@@ -296,9 +297,6 @@ class CPWL_Wnd : public CPWL_TimerHandler, public Observable<CPWL_Wnd> {
CFX_FloatRect PWLtoWnd(const CFX_FloatRect& rect) const;
- void AddChild(CPWL_Wnd* pWnd);
- void RemoveChild(CPWL_Wnd* pWnd);
-
void CreateScrollBar(const CreateParams& cp);
void CreateVScrollBar(const CreateParams& cp);