Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(630)

Side by Side Diff: fpdfsdk/pdfwindow/PWL_Wnd.cpp

Issue 2031653003: Get rid of NULLs in fpdfsdk/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@nullptr_core
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/pdfwindow/PWL_Wnd.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h" 9 #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h"
10 #include "fpdfsdk/pdfwindow/PWL_Utils.h" 10 #include "fpdfsdk/pdfwindow/PWL_Utils.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 void CPWL_Timer::TimerProc(int32_t idEvent) { 48 void CPWL_Timer::TimerProc(int32_t idEvent) {
49 auto it = GetPWLTimeMap().find(idEvent); 49 auto it = GetPWLTimeMap().find(idEvent);
50 if (it == GetPWLTimeMap().end()) 50 if (it == GetPWLTimeMap().end())
51 return; 51 return;
52 52
53 CPWL_Timer* pTimer = it->second; 53 CPWL_Timer* pTimer = it->second;
54 if (pTimer->m_pAttached) 54 if (pTimer->m_pAttached)
55 pTimer->m_pAttached->TimerProc(); 55 pTimer->m_pAttached->TimerProc();
56 } 56 }
57 57
58 CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL) {} 58 CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(nullptr) {}
59 59
60 CPWL_TimerHandler::~CPWL_TimerHandler() { 60 CPWL_TimerHandler::~CPWL_TimerHandler() {
61 delete m_pTimer; 61 delete m_pTimer;
62 } 62 }
63 63
64 void CPWL_TimerHandler::BeginTimer(int32_t nElapse) { 64 void CPWL_TimerHandler::BeginTimer(int32_t nElapse) {
65 if (!m_pTimer) 65 if (!m_pTimer)
66 m_pTimer = new CPWL_Timer(this, GetSystemHandler()); 66 m_pTimer = new CPWL_Timer(this, GetSystemHandler());
67 67
68 if (m_pTimer) 68 if (m_pTimer)
(...skipping 14 matching lines...) Expand all
83 explicit CPWL_MsgControl(CPWL_Wnd* pWnd) { 83 explicit CPWL_MsgControl(CPWL_Wnd* pWnd) {
84 m_pCreatedWnd = pWnd; 84 m_pCreatedWnd = pWnd;
85 Default(); 85 Default();
86 } 86 }
87 87
88 ~CPWL_MsgControl() { Default(); } 88 ~CPWL_MsgControl() { Default(); }
89 89
90 void Default() { 90 void Default() {
91 m_aMousePath.RemoveAll(); 91 m_aMousePath.RemoveAll();
92 m_aKeyboardPath.RemoveAll(); 92 m_aKeyboardPath.RemoveAll();
93 m_pMainMouseWnd = NULL; 93 m_pMainMouseWnd = nullptr;
94 m_pMainKeyboardWnd = NULL; 94 m_pMainKeyboardWnd = nullptr;
95 } 95 }
96 96
97 FX_BOOL IsWndCreated(const CPWL_Wnd* pWnd) const { 97 FX_BOOL IsWndCreated(const CPWL_Wnd* pWnd) const {
98 return m_pCreatedWnd == pWnd; 98 return m_pCreatedWnd == pWnd;
99 } 99 }
100 100
101 FX_BOOL IsMainCaptureMouse(const CPWL_Wnd* pWnd) const { 101 FX_BOOL IsMainCaptureMouse(const CPWL_Wnd* pWnd) const {
102 return pWnd == m_pMainMouseWnd; 102 return pWnd == m_pMainMouseWnd;
103 } 103 }
104 104
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 pWnd->OnSetFocus(); 143 pWnd->OnSetFocus();
144 } 144 }
145 } 145 }
146 146
147 void KillFocus() { 147 void KillFocus() {
148 if (m_aKeyboardPath.GetSize() > 0) 148 if (m_aKeyboardPath.GetSize() > 0)
149 if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0)) 149 if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0))
150 pWnd->OnKillFocus(); 150 pWnd->OnKillFocus();
151 151
152 m_pMainKeyboardWnd = NULL; 152 m_pMainKeyboardWnd = nullptr;
153 m_aKeyboardPath.RemoveAll(); 153 m_aKeyboardPath.RemoveAll();
154 } 154 }
155 155
156 void SetCapture(CPWL_Wnd* pWnd) { 156 void SetCapture(CPWL_Wnd* pWnd) {
157 m_aMousePath.RemoveAll(); 157 m_aMousePath.RemoveAll();
158 158
159 if (pWnd) { 159 if (pWnd) {
160 m_pMainMouseWnd = pWnd; 160 m_pMainMouseWnd = pWnd;
161 161
162 CPWL_Wnd* pParent = pWnd; 162 CPWL_Wnd* pParent = pWnd;
163 while (pParent) { 163 while (pParent) {
164 m_aMousePath.Add(pParent); 164 m_aMousePath.Add(pParent);
165 pParent = pParent->GetParentWindow(); 165 pParent = pParent->GetParentWindow();
166 } 166 }
167 } 167 }
168 } 168 }
169 169
170 void ReleaseCapture() { 170 void ReleaseCapture() {
171 m_pMainMouseWnd = NULL; 171 m_pMainMouseWnd = nullptr;
172 m_aMousePath.RemoveAll(); 172 m_aMousePath.RemoveAll();
173 } 173 }
174 174
175 private: 175 private:
176 CFX_ArrayTemplate<CPWL_Wnd*> m_aMousePath; 176 CFX_ArrayTemplate<CPWL_Wnd*> m_aMousePath;
177 CFX_ArrayTemplate<CPWL_Wnd*> m_aKeyboardPath; 177 CFX_ArrayTemplate<CPWL_Wnd*> m_aKeyboardPath;
178 CPWL_Wnd* m_pCreatedWnd; 178 CPWL_Wnd* m_pCreatedWnd;
179 CPWL_Wnd* m_pMainMouseWnd; 179 CPWL_Wnd* m_pMainMouseWnd;
180 CPWL_Wnd* m_pMainKeyboardWnd; 180 CPWL_Wnd* m_pMainKeyboardWnd;
181 }; 181 };
182 182
183 CPWL_Wnd::CPWL_Wnd() 183 CPWL_Wnd::CPWL_Wnd()
184 : m_pVScrollBar(NULL), 184 : m_pVScrollBar(nullptr),
185 m_rcWindow(), 185 m_rcWindow(),
186 m_rcClip(), 186 m_rcClip(),
187 m_bCreated(FALSE), 187 m_bCreated(FALSE),
188 m_bVisible(FALSE), 188 m_bVisible(FALSE),
189 m_bNotifying(FALSE), 189 m_bNotifying(FALSE),
190 m_bEnabled(TRUE) {} 190 m_bEnabled(TRUE) {}
191 191
192 CPWL_Wnd::~CPWL_Wnd() { 192 CPWL_Wnd::~CPWL_Wnd() {
193 ASSERT(m_bCreated == FALSE); 193 ASSERT(m_bCreated == FALSE);
194 } 194 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 void CPWL_Wnd::Destroy() { 248 void CPWL_Wnd::Destroy() {
249 KillFocus(); 249 KillFocus();
250 250
251 OnDestroy(); 251 OnDestroy();
252 252
253 if (m_bCreated) { 253 if (m_bCreated) {
254 for (int32_t i = m_aChildren.GetSize() - 1; i >= 0; i--) { 254 for (int32_t i = m_aChildren.GetSize() - 1; i >= 0; i--) {
255 if (CPWL_Wnd* pChild = m_aChildren[i]) { 255 if (CPWL_Wnd* pChild = m_aChildren[i]) {
256 pChild->Destroy(); 256 pChild->Destroy();
257 delete pChild; 257 delete pChild;
258 pChild = NULL; 258 pChild = nullptr;
259 } 259 }
260 } 260 }
261 261
262 if (m_sPrivateParam.pParentWnd) 262 if (m_sPrivateParam.pParentWnd)
263 m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD); 263 m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD);
264 m_bCreated = FALSE; 264 m_bCreated = FALSE;
265 } 265 }
266 266
267 DestroyMsgControl(); 267 DestroyMsgControl();
268 268
269 FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM)); 269 FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM));
270 m_aChildren.RemoveAll(); 270 m_aChildren.RemoveAll();
271 m_pVScrollBar = NULL; 271 m_pVScrollBar = nullptr;
272 } 272 }
273 273
274 void CPWL_Wnd::Move(const CFX_FloatRect& rcNew, 274 void CPWL_Wnd::Move(const CFX_FloatRect& rcNew,
275 FX_BOOL bReset, 275 FX_BOOL bReset,
276 FX_BOOL bRefresh) { 276 FX_BOOL bRefresh) {
277 if (IsValid()) { 277 if (IsValid()) {
278 CFX_FloatRect rcOld = GetWindowRect(); 278 CFX_FloatRect rcOld = GetWindowRect();
279 279
280 m_rcWindow = rcNew; 280 m_rcWindow = rcNew;
281 m_rcWindow.Normalize(); 281 m_rcWindow.Normalize();
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 } 617 }
618 618
619 void* CPWL_Wnd::GetAttachedData() const { 619 void* CPWL_Wnd::GetAttachedData() const {
620 return m_sPrivateParam.pAttachedData; 620 return m_sPrivateParam.pAttachedData;
621 } 621 }
622 622
623 CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const { 623 CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const {
624 if (HasFlag(PWS_VSCROLL)) 624 if (HasFlag(PWS_VSCROLL))
625 return m_pVScrollBar; 625 return m_pVScrollBar;
626 626
627 return NULL; 627 return nullptr;
628 } 628 }
629 629
630 void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM& cp) { 630 void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM& cp) {
631 CreateVScrollBar(cp); 631 CreateVScrollBar(cp);
632 } 632 }
633 633
634 void CPWL_Wnd::CreateVScrollBar(const PWL_CREATEPARAM& cp) { 634 void CPWL_Wnd::CreateVScrollBar(const PWL_CREATEPARAM& cp) {
635 if (!m_pVScrollBar && HasFlag(PWS_VSCROLL)) { 635 if (!m_pVScrollBar && HasFlag(PWS_VSCROLL)) {
636 PWL_CREATEPARAM scp = cp; 636 PWL_CREATEPARAM scp = cp;
637 637
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 951
952 void CPWL_Wnd::SetChildMatrix(const CFX_Matrix& mt) { 952 void CPWL_Wnd::SetChildMatrix(const CFX_Matrix& mt) {
953 m_sPrivateParam.mtChild = mt; 953 m_sPrivateParam.mtChild = mt;
954 } 954 }
955 955
956 const CPWL_Wnd* CPWL_Wnd::GetFocused() const { 956 const CPWL_Wnd* CPWL_Wnd::GetFocused() const {
957 if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) { 957 if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) {
958 return pMsgCtrl->m_pMainKeyboardWnd; 958 return pMsgCtrl->m_pMainKeyboardWnd;
959 } 959 }
960 960
961 return NULL; 961 return nullptr;
962 } 962 }
963 963
964 void CPWL_Wnd::EnableWindow(FX_BOOL bEnable) { 964 void CPWL_Wnd::EnableWindow(FX_BOOL bEnable) {
965 if (m_bEnabled != bEnable) { 965 if (m_bEnabled != bEnable) {
966 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { 966 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
967 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { 967 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
968 pChild->EnableWindow(bEnable); 968 pChild->EnableWindow(bEnable);
969 } 969 }
970 } 970 }
971 971
(...skipping 30 matching lines...) Expand all
1002 return FALSE; 1002 return FALSE;
1003 } 1003 }
1004 1004
1005 FX_BOOL CPWL_Wnd::IsALTpressed(uint32_t nFlag) const { 1005 FX_BOOL CPWL_Wnd::IsALTpressed(uint32_t nFlag) const {
1006 if (CFX_SystemHandler* pSystemHandler = GetSystemHandler()) { 1006 if (CFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
1007 return pSystemHandler->IsALTKeyDown(nFlag); 1007 return pSystemHandler->IsALTKeyDown(nFlag);
1008 } 1008 }
1009 1009
1010 return FALSE; 1010 return FALSE;
1011 } 1011 }
OLDNEW
« no previous file with comments | « fpdfsdk/pdfwindow/PWL_Wnd.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698