diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-10-26 22:08:43 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-26 22:08:43 +0000 |
commit | 9590dee526c514d87dc1f47569d1136ffcf539ad (patch) | |
tree | eaea0d3d96ee9248b1cb0dc34fc2950192b7f9ef /fpdfsdk | |
parent | e027c9765c1aa5ea2a4293fc6ea29a96e3fc2c73 (diff) | |
download | pdfium-9590dee526c514d87dc1f47569d1136ffcf539ad.tar.xz |
Pass unique_ptr to CPWL_Wnd::AddChild().
But stop short of updating the underlying data structures.
Change-Id: I7d8edc74f71725005b81359484d30caddbe958d7
Reviewed-on: https://pdfium-review.googlesource.com/c/44693
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/pwl/cpwl_combo_box.cpp | 24 | ||||
-rw-r--r-- | fpdfsdk/pwl/cpwl_edit_ctrl.cpp | 9 | ||||
-rw-r--r-- | fpdfsdk/pwl/cpwl_scroll_bar.cpp | 18 | ||||
-rw-r--r-- | fpdfsdk/pwl/cpwl_wnd.cpp | 10 | ||||
-rw-r--r-- | fpdfsdk/pwl/cpwl_wnd.h | 2 |
5 files changed, 37 insertions, 26 deletions
diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp index 70893ca437..887b0225e5 100644 --- a/fpdfsdk/pwl/cpwl_combo_box.cpp +++ b/fpdfsdk/pwl/cpwl_combo_box.cpp @@ -272,10 +272,6 @@ void CPWL_ComboBox::CreateEdit(const CreateParams& cp) { if (m_pEdit) return; - m_pEdit = new CPWL_Edit(CloneAttachedData()); - m_pEdit->AttachFFLData(m_pFormFiller.Get()); - AddChild(m_pEdit.Get()); - CreateParams ecp = cp; ecp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PES_CENTER | PES_AUTOSCROLL | PES_UNDO; @@ -289,6 +285,11 @@ void CPWL_ComboBox::CreateEdit(const CreateParams& cp) { ecp.rcRectWnd = CFX_FloatRect(); ecp.dwBorderWidth = 0; ecp.nBorderStyle = BorderStyle::SOLID; + + auto pEdit = pdfium::MakeUnique<CPWL_Edit>(CloneAttachedData()); + m_pEdit = pEdit.get(); + m_pEdit->AttachFFLData(m_pFormFiller.Get()); + AddChild(std::move(pEdit)); m_pEdit->Realize(ecp); } @@ -296,9 +297,6 @@ void CPWL_ComboBox::CreateButton(const CreateParams& cp) { if (m_pButton) return; - m_pButton = new CPWL_CBButton(CloneAttachedData()); - AddChild(m_pButton.Get()); - CreateParams bcp = cp; bcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGROUND; bcp.sBackgroundColor = CFX_Color(CFX_Color::kRGB, 220.0f / 255.0f, @@ -307,6 +305,10 @@ void CPWL_ComboBox::CreateButton(const CreateParams& cp) { bcp.dwBorderWidth = 2; bcp.nBorderStyle = BorderStyle::BEVELED; bcp.eCursorType = FXCT_ARROW; + + auto pButton = pdfium::MakeUnique<CPWL_CBButton>(CloneAttachedData()); + m_pButton = pButton.get(); + AddChild(std::move(pButton)); m_pButton->Realize(bcp); } @@ -314,10 +316,6 @@ void CPWL_ComboBox::CreateListBox(const CreateParams& cp) { if (m_pList) return; - m_pList = new CPWL_CBListBox(CloneAttachedData()); - m_pList->AttachFFLData(m_pFormFiller.Get()); - AddChild(m_pList.Get()); - CreateParams lcp = cp; lcp.dwFlags = PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PLBS_HOVERSEL | PWS_VSCROLL; @@ -335,6 +333,10 @@ void CPWL_ComboBox::CreateListBox(const CreateParams& cp) { if (cp.sBackgroundColor.nColorType == CFX_Color::kTransparent) lcp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR; + auto pList = pdfium::MakeUnique<CPWL_CBListBox>(CloneAttachedData()); + m_pList = pList.get(); + m_pList->AttachFFLData(m_pFormFiller.Get()); + AddChild(std::move(pList)); m_pList->Realize(lcp); } diff --git a/fpdfsdk/pwl/cpwl_edit_ctrl.cpp b/fpdfsdk/pwl/cpwl_edit_ctrl.cpp index 8bf13a73d0..44918be30e 100644 --- a/fpdfsdk/pwl/cpwl_edit_ctrl.cpp +++ b/fpdfsdk/pwl/cpwl_edit_ctrl.cpp @@ -88,15 +88,16 @@ void CPWL_EditCtrl::CreateEditCaret(const CreateParams& cp) { if (m_pEditCaret) return; - m_pEditCaret = new CPWL_Caret(CloneAttachedData()); - m_pEditCaret->SetInvalidRect(GetClientRect()); - AddChild(m_pEditCaret); - CreateParams ecp = cp; ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP; ecp.dwBorderWidth = 0; ecp.nBorderStyle = BorderStyle::SOLID; ecp.rcRectWnd = CFX_FloatRect(); + + auto pCaret = pdfium::MakeUnique<CPWL_Caret>(CloneAttachedData()); + m_pEditCaret = pCaret.get(); + m_pEditCaret->SetInvalidRect(GetClientRect()); + AddChild(std::move(pCaret)); m_pEditCaret->Realize(ecp); } diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.cpp b/fpdfsdk/pwl/cpwl_scroll_bar.cpp index 34154aaa98..fb2060a149 100644 --- a/fpdfsdk/pwl/cpwl_scroll_bar.cpp +++ b/fpdfsdk/pwl/cpwl_scroll_bar.cpp @@ -541,22 +541,28 @@ void CPWL_ScrollBar::CreateButtons(const CreateParams& cp) { PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PWS_NOREFRESHCLIP; if (!m_pMinButton) { - m_pMinButton = new CPWL_SBButton(CloneAttachedData(), m_sbType, PSBT_MIN); - AddChild(m_pMinButton.Get()); + auto pButton = pdfium::MakeUnique<CPWL_SBButton>(CloneAttachedData(), + m_sbType, PSBT_MIN); + m_pMinButton = pButton.get(); + AddChild(std::move(pButton)); m_pMinButton->Realize(scp); } if (!m_pMaxButton) { - m_pMaxButton = new CPWL_SBButton(CloneAttachedData(), m_sbType, PSBT_MAX); - AddChild(m_pMaxButton.Get()); + auto pButton = pdfium::MakeUnique<CPWL_SBButton>(CloneAttachedData(), + m_sbType, PSBT_MAX); + m_pMaxButton = pButton.get(); + AddChild(std::move(pButton)); m_pMaxButton->Realize(scp); } if (!m_pPosButton) { - m_pPosButton = new CPWL_SBButton(CloneAttachedData(), m_sbType, PSBT_POS); + auto pButton = pdfium::MakeUnique<CPWL_SBButton>(CloneAttachedData(), + m_sbType, PSBT_POS); + m_pPosButton = pButton.get(); ObservedPtr thisObserved(this); if (m_pPosButton->SetVisible(false) && thisObserved) { - AddChild(m_pPosButton.Get()); + AddChild(std::move(pButton)); m_pPosButton->Realize(scp); } } diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp index 66e5cfa0b6..5522a53972 100644 --- a/fpdfsdk/pwl/cpwl_wnd.cpp +++ b/fpdfsdk/pwl/cpwl_wnd.cpp @@ -377,10 +377,10 @@ bool CPWL_Wnd::OnMouseWheel(short zDelta, return false; } -void CPWL_Wnd::AddChild(CPWL_Wnd* pWnd) { +void CPWL_Wnd::AddChild(std::unique_ptr<CPWL_Wnd> pWnd) { ASSERT(!pWnd->m_pParent); pWnd->m_pParent = this; - m_Children.push_back(pWnd); + m_Children.push_back(pWnd.release()); } void CPWL_Wnd::RemoveChild(CPWL_Wnd* pWnd) { @@ -499,8 +499,10 @@ void CPWL_Wnd::CreateVScrollBar(const CreateParams& cp) { scp.eCursorType = FXCT_ARROW; scp.nTransparency = PWL_SCROLLBAR_TRANSPARENCY; - m_pVScrollBar = new CPWL_ScrollBar(CloneAttachedData(), SBT_VSCROLL); - AddChild(m_pVScrollBar.Get()); + auto pBar = + pdfium::MakeUnique<CPWL_ScrollBar>(CloneAttachedData(), SBT_VSCROLL); + m_pVScrollBar = pBar.get(); + AddChild(std::move(pBar)); m_pVScrollBar->Realize(scp); } diff --git a/fpdfsdk/pwl/cpwl_wnd.h b/fpdfsdk/pwl/cpwl_wnd.h index 3a4c9a5914..7f6bfec813 100644 --- a/fpdfsdk/pwl/cpwl_wnd.h +++ b/fpdfsdk/pwl/cpwl_wnd.h @@ -176,7 +176,7 @@ class CPWL_Wnd : public CPWL_TimerHandler, public Observable<CPWL_Wnd> { virtual CFX_FloatRect GetFocusRect() const; virtual CFX_FloatRect GetClientRect() const; - void AddChild(CPWL_Wnd* pWnd); + void AddChild(std::unique_ptr<CPWL_Wnd> pWnd); void RemoveChild(CPWL_Wnd* pWnd); void Realize(const CreateParams& cp); void Destroy(); |