From 931a6b9c253f161f8016064eee601cd238ed246f Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 3 Jul 2018 17:18:35 +0000 Subject: Use UnownedPtr<> in cfwl_scrollbar.h and cfwl_themebackground.h Change-Id: Ib65197a9cd9de173de8e77db168dcfbb43669022 Reviewed-on: https://pdfium-review.googlesource.com/36911 Commit-Queue: dsinclair Reviewed-by: dsinclair --- xfa/fwl/cfwl_scrollbar.h | 3 ++- xfa/fwl/cfwl_themebackground.h | 10 +++++----- xfa/fwl/theme/cfwl_barcodetp.cpp | 11 +++++------ xfa/fwl/theme/cfwl_carettp.cpp | 6 +++--- xfa/fwl/theme/cfwl_checkboxtp.cpp | 4 ++-- xfa/fwl/theme/cfwl_comboboxtp.cpp | 5 +++-- xfa/fwl/theme/cfwl_datetimepickertp.cpp | 11 +++++------ xfa/fwl/theme/cfwl_edittp.cpp | 13 ++++++++----- xfa/fwl/theme/cfwl_listboxtp.cpp | 11 ++++++----- xfa/fwl/theme/cfwl_monthcalendartp.cpp | 7 ++++--- xfa/fwl/theme/cfwl_pictureboxtp.cpp | 6 +++--- xfa/fwl/theme/cfwl_pushbuttontp.cpp | 5 +++-- xfa/fwl/theme/cfwl_scrollbartp.cpp | 2 +- 13 files changed, 50 insertions(+), 44 deletions(-) diff --git a/xfa/fwl/cfwl_scrollbar.h b/xfa/fwl/cfwl_scrollbar.h index b2523a6e15..de394ed96d 100644 --- a/xfa/fwl/cfwl_scrollbar.h +++ b/xfa/fwl/cfwl_scrollbar.h @@ -10,6 +10,7 @@ #include #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/unowned_ptr.h" #include "xfa/fwl/cfwl_eventscroll.h" #include "xfa/fwl/cfwl_timer.h" #include "xfa/fwl/cfwl_widget.h" @@ -109,7 +110,7 @@ class CFWL_ScrollBar : public CFWL_Widget { void DoMouseLeave(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); void DoMouseHover(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); - CFWL_TimerInfo* m_pTimerInfo; + UnownedPtr m_pTimerInfo; float m_fRangeMin; float m_fRangeMax; float m_fPageSize; diff --git a/xfa/fwl/cfwl_themebackground.h b/xfa/fwl/cfwl_themebackground.h index 85435aa524..37103ae01a 100644 --- a/xfa/fwl/cfwl_themebackground.h +++ b/xfa/fwl/cfwl_themebackground.h @@ -7,6 +7,7 @@ #ifndef XFA_FWL_CFWL_THEMEBACKGROUND_H_ #define XFA_FWL_CFWL_THEMEBACKGROUND_H_ +#include "core/fxcrt/unowned_ptr.h" #include "xfa/fwl/cfwl_themepart.h" class CXFA_Graphics; @@ -17,13 +18,12 @@ class CFWL_ThemeBackground : public CFWL_ThemePart { CFWL_ThemeBackground(); ~CFWL_ThemeBackground(); - CXFA_Graphics* m_pGraphics; - CXFA_GEPath* m_pPath; + UnownedPtr m_pGraphics; + UnownedPtr m_pPath; }; -inline CFWL_ThemeBackground::CFWL_ThemeBackground() - : m_pGraphics(nullptr), m_pPath(nullptr) {} +inline CFWL_ThemeBackground::CFWL_ThemeBackground() = default; -inline CFWL_ThemeBackground::~CFWL_ThemeBackground() {} +inline CFWL_ThemeBackground::~CFWL_ThemeBackground() = default; #endif // XFA_FWL_CFWL_THEMEBACKGROUND_H_ diff --git a/xfa/fwl/theme/cfwl_barcodetp.cpp b/xfa/fwl/theme/cfwl_barcodetp.cpp index cafdf17933..52e0c9fa5b 100644 --- a/xfa/fwl/theme/cfwl_barcodetp.cpp +++ b/xfa/fwl/theme/cfwl_barcodetp.cpp @@ -19,15 +19,14 @@ void CFWL_BarcodeTP::DrawBackground(CFWL_ThemeBackground* pParams) { return; switch (pParams->m_iPart) { - case CFWL_Part::Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + case CFWL_Part::Border: + DrawBorder(pParams->m_pGraphics.Get(), &pParams->m_rtPart, + &pParams->m_matrix); break; - } - case CFWL_Part::Background: { - FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, + case CFWL_Part::Background: + FillBackground(pParams->m_pGraphics.Get(), &pParams->m_rtPart, &pParams->m_matrix); break; - } default: break; } diff --git a/xfa/fwl/theme/cfwl_carettp.cpp b/xfa/fwl/theme/cfwl_carettp.cpp index 973531958a..186d658041 100644 --- a/xfa/fwl/theme/cfwl_carettp.cpp +++ b/xfa/fwl/theme/cfwl_carettp.cpp @@ -24,9 +24,9 @@ void CFWL_CaretTP::DrawBackground(CFWL_ThemeBackground* pParams) { if (!(pParams->m_dwStates & CFWL_PartState_HightLight)) return; - DrawCaretBK(pParams->m_pGraphics, pParams->m_dwStates, - &(pParams->m_rtPart), (CXFA_GEColor*)pParams->m_pData, - &(pParams->m_matrix)); + DrawCaretBK( + pParams->m_pGraphics.Get(), pParams->m_dwStates, &pParams->m_rtPart, + static_cast(pParams->m_pData), &pParams->m_matrix); break; } default: diff --git a/xfa/fwl/theme/cfwl_checkboxtp.cpp b/xfa/fwl/theme/cfwl_checkboxtp.cpp index a4e474b4f1..f54f93f351 100644 --- a/xfa/fwl/theme/cfwl_checkboxtp.cpp +++ b/xfa/fwl/theme/cfwl_checkboxtp.cpp @@ -270,8 +270,8 @@ void CFWL_CheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { if ((pParams->m_dwStates & CFWL_PartState_Checked) || (pParams->m_dwStates & CFWL_PartState_Neutral)) { - DrawCheckSign(pParams->m_pWidget, pParams->m_pGraphics, pParams->m_rtPart, - pParams->m_dwStates, &pParams->m_matrix); + DrawCheckSign(pParams->m_pWidget, pParams->m_pGraphics.Get(), + pParams->m_rtPart, pParams->m_dwStates, &pParams->m_matrix); } } diff --git a/xfa/fwl/theme/cfwl_comboboxtp.cpp b/xfa/fwl/theme/cfwl_comboboxtp.cpp index 76953423e6..8c35e56713 100644 --- a/xfa/fwl/theme/cfwl_comboboxtp.cpp +++ b/xfa/fwl/theme/cfwl_comboboxtp.cpp @@ -23,7 +23,8 @@ void CFWL_ComboBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { switch (pParams->m_iPart) { case CFWL_Part::Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + DrawBorder(pParams->m_pGraphics.Get(), &pParams->m_rtPart, + &pParams->m_matrix); break; } case CFWL_Part::Background: { @@ -95,6 +96,6 @@ void CFWL_ComboBoxTP::DrawDropDownButton(CFWL_ThemeBackground* pParams, default: break; } - DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, + DrawArrowBtn(pParams->m_pGraphics.Get(), &pParams->m_rtPart, FWLTHEME_DIRECTION_Down, eState, &pParams->m_matrix); } diff --git a/xfa/fwl/theme/cfwl_datetimepickertp.cpp b/xfa/fwl/theme/cfwl_datetimepickertp.cpp index 8902ef9351..d13d4c7548 100644 --- a/xfa/fwl/theme/cfwl_datetimepickertp.cpp +++ b/xfa/fwl/theme/cfwl_datetimepickertp.cpp @@ -18,14 +18,13 @@ void CFWL_DateTimePickerTP::DrawBackground(CFWL_ThemeBackground* pParams) { return; switch (pParams->m_iPart) { - case CFWL_Part::Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + case CFWL_Part::Border: + DrawBorder(pParams->m_pGraphics.Get(), &pParams->m_rtPart, + &pParams->m_matrix); break; - } - case CFWL_Part::DropDownButton: { + case CFWL_Part::DropDownButton: DrawDropDownButton(pParams, &pParams->m_matrix); break; - } default: break; } @@ -56,7 +55,7 @@ void CFWL_DateTimePickerTP::DrawDropDownButton(CFWL_ThemeBackground* pParams, default: break; } - DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, + DrawArrowBtn(pParams->m_pGraphics.Get(), &pParams->m_rtPart, FWLTHEME_DIRECTION_Down, eState, pMatrix); } diff --git a/xfa/fwl/theme/cfwl_edittp.cpp b/xfa/fwl/theme/cfwl_edittp.cpp index 700d78131f..eb1f24e14e 100644 --- a/xfa/fwl/theme/cfwl_edittp.cpp +++ b/xfa/fwl/theme/cfwl_edittp.cpp @@ -37,21 +37,23 @@ void CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) { } pParams->m_pGraphics->SetStrokeColor(CXFA_GEColor(cr)); pParams->m_pGraphics->SetLineWidth(fWidth); - pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix); + pParams->m_pGraphics->StrokePath(pParams->m_pPath.Get(), + &pParams->m_matrix); return; } switch (pParams->m_iPart) { case CFWL_Part::Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + DrawBorder(pParams->m_pGraphics.Get(), &pParams->m_rtPart, + &pParams->m_matrix); break; } case CFWL_Part::Background: { if (pParams->m_pPath) { - CXFA_Graphics* pGraphics = pParams->m_pGraphics; + CXFA_Graphics* pGraphics = pParams->m_pGraphics.Get(); pGraphics->SaveGraphState(); pGraphics->SetFillColor(CXFA_GEColor(FWLTHEME_COLOR_BKSelected)); - pGraphics->FillPath(pParams->m_pPath, FXFILL_WINDING, + pGraphics->FillPath(pParams->m_pPath.Get(), FXFILL_WINDING, &pParams->m_matrix); pGraphics->RestoreGraphState(); } else { @@ -78,7 +80,8 @@ void CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) { case CFWL_Part::CombTextLine: { pParams->m_pGraphics->SetStrokeColor(CXFA_GEColor(0xFF000000)); pParams->m_pGraphics->SetLineWidth(1.0f); - pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix); + pParams->m_pGraphics->StrokePath(pParams->m_pPath.Get(), + &pParams->m_matrix); break; } default: diff --git a/xfa/fwl/theme/cfwl_listboxtp.cpp b/xfa/fwl/theme/cfwl_listboxtp.cpp index 6c495b4c81..9b8cd0dc7a 100644 --- a/xfa/fwl/theme/cfwl_listboxtp.cpp +++ b/xfa/fwl/theme/cfwl_listboxtp.cpp @@ -22,21 +22,22 @@ void CFWL_ListBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { switch (pParams->m_iPart) { case CFWL_Part::Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + DrawBorder(pParams->m_pGraphics.Get(), &pParams->m_rtPart, + &pParams->m_matrix); break; } case CFWL_Part::Background: { - FillSolidRect(pParams->m_pGraphics, ArgbEncode(255, 255, 255, 255), + FillSolidRect(pParams->m_pGraphics.Get(), ArgbEncode(255, 255, 255, 255), &pParams->m_rtPart, &pParams->m_matrix); if (pParams->m_pData) { - FillSolidRect(pParams->m_pGraphics, FWLTHEME_COLOR_Background, + FillSolidRect(pParams->m_pGraphics.Get(), FWLTHEME_COLOR_Background, static_cast(pParams->m_pData), &pParams->m_matrix); } break; } case CFWL_Part::ListItem: { - DrawListBoxItem(pParams->m_pGraphics, pParams->m_dwStates, + DrawListBoxItem(pParams->m_pGraphics.Get(), pParams->m_dwStates, &pParams->m_rtPart, pParams->m_pData, &pParams->m_matrix); break; } @@ -47,7 +48,7 @@ void CFWL_ListBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { } else if (pParams->m_dwStates == CFWL_PartState_Normal) { color = 0xFF0000FF; } - FillSolidRect(pParams->m_pGraphics, color, &pParams->m_rtPart, + FillSolidRect(pParams->m_pGraphics.Get(), color, &pParams->m_rtPart, &pParams->m_matrix); break; } diff --git a/xfa/fwl/theme/cfwl_monthcalendartp.cpp b/xfa/fwl/theme/cfwl_monthcalendartp.cpp index 6bb3f186b7..c17451d1ae 100644 --- a/xfa/fwl/theme/cfwl_monthcalendartp.cpp +++ b/xfa/fwl/theme/cfwl_monthcalendartp.cpp @@ -37,7 +37,8 @@ void CFWL_MonthCalendarTP::DrawBackground(CFWL_ThemeBackground* pParams) { switch (pParams->m_iPart) { case CFWL_Part::Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + DrawBorder(pParams->m_pGraphics.Get(), &pParams->m_rtPart, + &pParams->m_matrix); break; } case CFWL_Part::Background: { @@ -50,13 +51,13 @@ void CFWL_MonthCalendarTP::DrawBackground(CFWL_ThemeBackground* pParams) { } case CFWL_Part::LBtn: { FWLTHEME_STATE eState = GetState(pParams->m_dwStates); - DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, + DrawArrowBtn(pParams->m_pGraphics.Get(), &pParams->m_rtPart, FWLTHEME_DIRECTION_Left, eState, &pParams->m_matrix); break; } case CFWL_Part::RBtn: { FWLTHEME_STATE eState = GetState(pParams->m_dwStates); - DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, + DrawArrowBtn(pParams->m_pGraphics.Get(), &pParams->m_rtPart, FWLTHEME_DIRECTION_Right, eState, &pParams->m_matrix); break; } diff --git a/xfa/fwl/theme/cfwl_pictureboxtp.cpp b/xfa/fwl/theme/cfwl_pictureboxtp.cpp index 27abbe27e3..6a30113cf7 100644 --- a/xfa/fwl/theme/cfwl_pictureboxtp.cpp +++ b/xfa/fwl/theme/cfwl_pictureboxtp.cpp @@ -19,10 +19,10 @@ void CFWL_PictureBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { return; switch (pParams->m_iPart) { - case CFWL_Part::Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + case CFWL_Part::Border: + DrawBorder(pParams->m_pGraphics.Get(), &pParams->m_rtPart, + &pParams->m_matrix); break; - } default: break; } diff --git a/xfa/fwl/theme/cfwl_pushbuttontp.cpp b/xfa/fwl/theme/cfwl_pushbuttontp.cpp index c3eef0f11f..dbd6800ba2 100644 --- a/xfa/fwl/theme/cfwl_pushbuttontp.cpp +++ b/xfa/fwl/theme/cfwl_pushbuttontp.cpp @@ -24,7 +24,8 @@ CFWL_PushButtonTP::~CFWL_PushButtonTP() {} void CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) { switch (pParams->m_iPart) { case CFWL_Part::Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + DrawBorder(pParams->m_pGraphics.Get(), &pParams->m_rtPart, + &pParams->m_matrix); break; } case CFWL_Part::Background: { @@ -51,7 +52,7 @@ void CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) { CXFA_GEPath fillPath; fillPath.AddSubpath(&strokePath); - CXFA_Graphics* pGraphics = pParams->m_pGraphics; + CXFA_Graphics* pGraphics = pParams->m_pGraphics.Get(); pGraphics->SaveGraphState(); CFX_RectF rtInner(rect); diff --git a/xfa/fwl/theme/cfwl_scrollbartp.cpp b/xfa/fwl/theme/cfwl_scrollbartp.cpp index 1e9ade8c76..0f383e64b0 100644 --- a/xfa/fwl/theme/cfwl_scrollbartp.cpp +++ b/xfa/fwl/theme/cfwl_scrollbartp.cpp @@ -38,7 +38,7 @@ void CFWL_ScrollBarTP::DrawBackground(CFWL_ThemeBackground* pParams) { else if (pParams->m_dwStates & CFWL_PartState_Disabled) eState = FWLTHEME_STATE_Disable; - CXFA_Graphics* pGraphics = pParams->m_pGraphics; + CXFA_Graphics* pGraphics = pParams->m_pGraphics.Get(); CFX_RectF* pRect = &pParams->m_rtPart; bool bVert = !!pWidget->GetStylesEx(); switch (pParams->m_iPart) { -- cgit v1.2.3