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

Side by Side Diff: xfa/fwl/core/cfwl_widgetmgr.cpp

Issue 2095653002: Remove NULL in xfa/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 5 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 | « xfa/fwl/core/cfwl_widgetmgr.h ('k') | xfa/fwl/core/fwl_appimp.cpp » ('j') | 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 "xfa/fwl/core/cfwl_widgetmgr.h" 7 #include "xfa/fwl/core/cfwl_widgetmgr.h"
8 8
9 #include "xfa/fwl/core/cfwl_message.h" 9 #include "xfa/fwl/core/cfwl_message.h"
10 #include "xfa/fwl/core/fwl_appimp.h" 10 #include "xfa/fwl/core/fwl_appimp.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 if (pChild->pPrevious) { 133 if (pChild->pPrevious) {
134 pChild->pPrevious->pNext = pChild->pNext; 134 pChild->pPrevious->pNext = pChild->pNext;
135 } 135 }
136 if (pChild->pNext) { 136 if (pChild->pNext) {
137 pChild->pNext->pPrevious = pChild->pPrevious; 137 pChild->pNext->pPrevious = pChild->pPrevious;
138 } 138 }
139 if (pItem->pParent->pChild == pItem) { 139 if (pItem->pParent->pChild == pItem) {
140 pItem->pParent->pChild = pItem->pNext; 140 pItem->pParent->pChild = pItem->pNext;
141 } 141 }
142 pItem->pNext = NULL; 142 pItem->pNext = nullptr;
143 pItem->pPrevious = NULL; 143 pItem->pPrevious = nullptr;
144 break; 144 break;
145 } 145 }
146 if (!pChild->pNext) { 146 if (!pChild->pNext) {
147 break; 147 break;
148 } 148 }
149 pChild = pChild->pNext; 149 pChild = pChild->pNext;
150 ++i; 150 ++i;
151 } 151 }
152 pChild = pItem->pParent->pChild; 152 pChild = pItem->pParent->pChild;
153 if (pChild) { 153 if (pChild) {
154 if (nIndex < 0) { 154 if (nIndex < 0) {
155 while (pChild->pNext) { 155 while (pChild->pNext) {
156 pChild = pChild->pNext; 156 pChild = pChild->pNext;
157 } 157 }
158 pChild->pNext = pItem; 158 pChild->pNext = pItem;
159 pItem->pPrevious = pChild; 159 pItem->pPrevious = pChild;
160 pItem->pNext = NULL; 160 pItem->pNext = nullptr;
161 return TRUE; 161 return TRUE;
162 } 162 }
163 i = 0; 163 i = 0;
164 while (i < nIndex && pChild->pNext) { 164 while (i < nIndex && pChild->pNext) {
165 pChild = pChild->pNext; 165 pChild = pChild->pNext;
166 ++i; 166 ++i;
167 } 167 }
168 if (!pChild->pNext) { 168 if (!pChild->pNext) {
169 pChild->pNext = pItem; 169 pChild->pNext = pItem;
170 pItem->pPrevious = pChild; 170 pItem->pPrevious = pChild;
171 pItem->pNext = NULL; 171 pItem->pNext = nullptr;
172 return TRUE; 172 return TRUE;
173 } 173 }
174 if (pChild->pPrevious) { 174 if (pChild->pPrevious) {
175 pItem->pPrevious = pChild->pPrevious; 175 pItem->pPrevious = pChild->pPrevious;
176 pChild->pPrevious->pNext = pItem; 176 pChild->pPrevious->pNext = pItem;
177 } 177 }
178 pChild->pPrevious = pItem; 178 pChild->pPrevious = pItem;
179 pItem->pNext = pChild; 179 pItem->pNext = pChild;
180 if (pItem->pParent->pChild == pChild) { 180 if (pItem->pParent->pChild == pChild) {
181 pItem->pParent->pChild = pItem; 181 pItem->pParent->pChild = pItem;
182 } 182 }
183 } else { 183 } else {
184 pItem->pParent->pChild = pItem; 184 pItem->pParent->pChild = pItem;
185 pItem->pPrevious = NULL; 185 pItem->pPrevious = nullptr;
186 pItem->pNext = NULL; 186 pItem->pNext = nullptr;
187 } 187 }
188 return TRUE; 188 return TRUE;
189 } 189 }
190 FWL_Error CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, 190 FWL_Error CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget,
191 const CFX_RectF* pRect) { 191 const CFX_RectF* pRect) {
192 if (!m_pAdapter) 192 if (!m_pAdapter)
193 return FWL_Error::Indefinite; 193 return FWL_Error::Indefinite;
194 IFWL_Widget* pNative = pWidget; 194 IFWL_Widget* pNative = pWidget;
195 CFX_RectF rect(*pRect); 195 CFX_RectF rect(*pRect);
196 if (IsFormDisabled()) { 196 if (IsFormDisabled()) {
197 IFWL_Widget* pOuter = pWidget->GetOuter(); 197 IFWL_Widget* pOuter = pWidget->GetOuter();
198 while (pOuter) { 198 while (pOuter) {
199 CFX_RectF rtTemp; 199 CFX_RectF rtTemp;
200 pNative->GetWidgetRect(rtTemp); 200 pNative->GetWidgetRect(rtTemp);
201 rect.left += rtTemp.left; 201 rect.left += rtTemp.left;
202 rect.top += rtTemp.top; 202 rect.top += rtTemp.top;
203 pNative = pOuter; 203 pNative = pOuter;
204 pOuter = pOuter->GetOuter(); 204 pOuter = pOuter->GetOuter();
205 } 205 }
206 } else if (!IsAbleNative(pWidget)) { 206 } else if (!IsAbleNative(pWidget)) {
207 pNative = GetSystemFormWidget(pWidget); 207 pNative = GetSystemFormWidget(pWidget);
208 if (!pNative) 208 if (!pNative)
209 return FWL_Error::Indefinite; 209 return FWL_Error::Indefinite;
210 pWidget->TransformTo(pNative, rect.left, rect.top); 210 pWidget->TransformTo(pNative, rect.left, rect.top);
211 } 211 }
212 AddRedrawCounts(pNative); 212 AddRedrawCounts(pNative);
213 return m_pAdapter->RepaintWidget(pNative, &rect); 213 return m_pAdapter->RepaintWidget(pNative, &rect);
214 } 214 }
215 void CFWL_WidgetMgr::AddWidget(IFWL_Widget* pWidget) { 215 void CFWL_WidgetMgr::AddWidget(IFWL_Widget* pWidget) {
216 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(NULL); 216 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(nullptr);
217 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); 217 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
218 if (!pItem) { 218 if (!pItem) {
219 pItem = new CFWL_WidgetMgrItem(pWidget); 219 pItem = new CFWL_WidgetMgrItem(pWidget);
220 m_mapWidgetItem[pWidget].reset(pItem); 220 m_mapWidgetItem[pWidget].reset(pItem);
221 } 221 }
222 if (pItem->pParent && pItem->pParent != pParentItem) { 222 if (pItem->pParent && pItem->pParent != pParentItem) {
223 if (pItem->pPrevious) { 223 if (pItem->pPrevious) {
224 pItem->pPrevious->pNext = pItem->pNext; 224 pItem->pPrevious->pNext = pItem->pNext;
225 } 225 }
226 if (pItem->pNext) { 226 if (pItem->pNext) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 if (pItem->pParent && pItem->pParent != pParentItem) { 307 if (pItem->pParent && pItem->pParent != pParentItem) {
308 if (pItem->pPrevious) { 308 if (pItem->pPrevious) {
309 pItem->pPrevious->pNext = pItem->pNext; 309 pItem->pPrevious->pNext = pItem->pNext;
310 } 310 }
311 if (pItem->pNext) { 311 if (pItem->pNext) {
312 pItem->pNext->pPrevious = pItem->pPrevious; 312 pItem->pNext->pPrevious = pItem->pPrevious;
313 } 313 }
314 if (pItem->pParent->pChild == pItem) { 314 if (pItem->pParent->pChild == pItem) {
315 pItem->pParent->pChild = pItem->pNext; 315 pItem->pParent->pChild = pItem->pNext;
316 } 316 }
317 pItem->pNext = NULL; 317 pItem->pNext = nullptr;
318 pItem->pPrevious = NULL; 318 pItem->pPrevious = nullptr;
319 } 319 }
320 pItem->pParent = pParentItem; 320 pItem->pParent = pParentItem;
321 SetWidgetIndex(pChild, -1); 321 SetWidgetIndex(pChild, -1);
322 } 322 }
323 323
324 FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) { 324 FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) {
325 IFWL_Widget* pTemp = pChild; 325 IFWL_Widget* pTemp = pChild;
326 do { 326 do {
327 if (pTemp == pParent) 327 if (pTemp == pParent)
328 return TRUE; 328 return TRUE;
(...skipping 21 matching lines...) Expand all
350 pItem->bOutsideChanged = !m_rtScreen.Contains(rect); 350 pItem->bOutsideChanged = !m_rtScreen.Contains(rect);
351 #endif 351 #endif
352 } 352 }
353 return FWL_Error::Succeeded; 353 return FWL_Error::Succeeded;
354 } 354 }
355 355
356 IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, 356 IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent,
357 FX_FLOAT x, 357 FX_FLOAT x,
358 FX_FLOAT y) { 358 FX_FLOAT y) {
359 if (!parent) 359 if (!parent)
360 return NULL; 360 return nullptr;
361 FX_FLOAT x1; 361 FX_FLOAT x1;
362 FX_FLOAT y1; 362 FX_FLOAT y1;
363 IFWL_Widget* child = GetLastChildWidget(parent); 363 IFWL_Widget* child = GetLastChildWidget(parent);
364 while (child) { 364 while (child) {
365 if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) { 365 if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) {
366 x1 = x; 366 x1 = x;
367 y1 = y; 367 y1 = y;
368 CFX_Matrix matrixOnParent; 368 CFX_Matrix matrixOnParent;
369 child->GetMatrix(matrixOnParent); 369 child->GetMatrix(matrixOnParent);
370 CFX_Matrix m; 370 CFX_Matrix m;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 void CFWL_WidgetMgr::GetSameGroupRadioButton( 446 void CFWL_WidgetMgr::GetSameGroupRadioButton(
447 IFWL_Widget* pRadioButton, 447 IFWL_Widget* pRadioButton,
448 CFX_ArrayTemplate<IFWL_Widget*>& group) { 448 CFX_ArrayTemplate<IFWL_Widget*>& group) {
449 IFWL_Widget* pFirst = GetFirstSiblingWidget(pRadioButton); 449 IFWL_Widget* pFirst = GetFirstSiblingWidget(pRadioButton);
450 if (!pFirst) { 450 if (!pFirst) {
451 pFirst = pRadioButton; 451 pFirst = pRadioButton;
452 } 452 }
453 int32_t iGroup = CountRadioButtonGroup(pFirst); 453 int32_t iGroup = CountRadioButtonGroup(pFirst);
454 if (iGroup < 2) { 454 if (iGroup < 2) {
455 IFWL_Widget* pNext = pFirst; 455 IFWL_Widget* pNext = pFirst;
456 while ((pNext = GetSiblingRadioButton(pNext, TRUE)) != NULL) { 456 while ((pNext = GetSiblingRadioButton(pNext, TRUE)) != nullptr) {
457 group.Add(pNext); 457 group.Add(pNext);
458 } 458 }
459 return; 459 return;
460 } 460 }
461 IFWL_Widget* pNext = GetRadioButtonGroupHeader(pRadioButton); 461 IFWL_Widget* pNext = GetRadioButtonGroupHeader(pRadioButton);
462 do { 462 do {
463 group.Add(pNext); 463 group.Add(pNext);
464 pNext = GetSiblingRadioButton(pNext, TRUE); 464 pNext = GetSiblingRadioButton(pNext, TRUE);
465 if (!pNext) 465 if (!pNext)
466 pNext = GetSiblingRadioButton(pFirst, TRUE); 466 pNext = GetSiblingRadioButton(pFirst, TRUE);
(...skipping 10 matching lines...) Expand all
477 if ((child->GetClassID() == FWL_Type::PushButton) && 477 if ((child->GetClassID() == FWL_Type::PushButton) &&
478 (child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { 478 (child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) {
479 return child; 479 return child;
480 } 480 }
481 IFWL_Widget* find = GetDefaultButton(child); 481 IFWL_Widget* find = GetDefaultButton(child);
482 if (find) { 482 if (find) {
483 return find; 483 return find;
484 } 484 }
485 child = CFWL_WidgetMgr::GetInstance()->GetNextSiblingWidget(child); 485 child = CFWL_WidgetMgr::GetInstance()->GetNextSiblingWidget(child);
486 } 486 }
487 return NULL; 487 return nullptr;
488 } 488 }
489 void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) { 489 void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) {
490 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); 490 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
491 (pItem->iRedrawCounter)++; 491 (pItem->iRedrawCounter)++;
492 } 492 }
493 void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) { 493 void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) {
494 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); 494 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
495 pItem->iRedrawCounter = 0; 495 pItem->iRedrawCounter = 0;
496 } 496 }
497 CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem( 497 CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem(
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 pWidget->GetWidgetRect(clipCopy); 614 pWidget->GetWidgetRect(clipCopy);
615 clipCopy.left = clipCopy.top = 0; 615 clipCopy.left = clipCopy.top = 0;
616 if (bUseOffscreenDirect(pWidget)) { 616 if (bUseOffscreenDirect(pWidget)) {
617 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); 617 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix);
618 return; 618 return;
619 } 619 }
620 CFX_RectF clipBounds; 620 CFX_RectF clipBounds;
621 621
622 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ || \ 622 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ || \
623 _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_ 623 _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_
624 IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); 624 IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(nullptr);
625 pDelegate->OnDrawWidget(pTemp, pMatrix); 625 pDelegate->OnDrawWidget(pTemp, pMatrix);
626 pGraphics->GetClipRect(clipBounds); 626 pGraphics->GetClipRect(clipBounds);
627 clipCopy = clipBounds; 627 clipCopy = clipBounds;
628 #elif _FX_OS_ == _FX_MACOSX_ 628 #elif _FX_OS_ == _FX_MACOSX_
629 if (m_pWidgetMgr->IsFormDisabled()) { 629 if (m_pWidgetMgr->IsFormDisabled()) {
630 IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); 630 IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(nullptr);
631 pDelegate->OnDrawWidget(pTemp, pMatrix); 631 pDelegate->OnDrawWidget(pTemp, pMatrix);
632 pGraphics->GetClipRect(clipBounds); 632 pGraphics->GetClipRect(clipBounds);
633 clipCopy = clipBounds; 633 clipCopy = clipBounds;
634 } else { 634 } else {
635 clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d); 635 clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d);
636 const_cast<CFX_Matrix*>(pMatrix)->SetIdentity(); // FIXME: const cast. 636 const_cast<CFX_Matrix*>(pMatrix)->SetIdentity(); // FIXME: const cast.
637 IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); 637 IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(nullptr);
638 pDelegate->OnDrawWidget(pTemp, pMatrix); 638 pDelegate->OnDrawWidget(pTemp, pMatrix);
639 } 639 }
640 #endif // _FX_OS_ == _FX_MACOSX_ 640 #endif // _FX_OS_ == _FX_MACOSX_
641 641
642 if (!m_pWidgetMgr->IsFormDisabled()) { 642 if (!m_pWidgetMgr->IsFormDisabled()) {
643 CFX_RectF rtClient; 643 CFX_RectF rtClient;
644 pWidget->GetClientRect(rtClient); 644 pWidget->GetClientRect(rtClient);
645 clipBounds.Intersect(rtClient); 645 clipBounds.Intersect(rtClient);
646 } 646 }
647 if (!clipBounds.IsEmpty()) 647 if (!clipBounds.IsEmpty())
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 if (!bFormDisable) { 681 if (!bFormDisable) {
682 widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top); 682 widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top);
683 clipBounds.Intersect(rtClip); 683 clipBounds.Intersect(rtClip);
684 if (clipBounds.IsEmpty()) 684 if (clipBounds.IsEmpty())
685 continue; 685 continue;
686 686
687 pGraphics->SaveGraphState(); 687 pGraphics->SaveGraphState();
688 pGraphics->SetClipRect(clipBounds); 688 pGraphics->SetClipRect(clipBounds);
689 } 689 }
690 widgetMatrix.Translate(rtWidget.left, rtWidget.top, TRUE); 690 widgetMatrix.Translate(rtWidget.left, rtWidget.top, TRUE);
691 IFWL_WidgetDelegate* pDelegate = child->SetDelegate(NULL); 691 IFWL_WidgetDelegate* pDelegate = child->SetDelegate(nullptr);
692 if (pDelegate) { 692 if (pDelegate) {
693 if (m_pWidgetMgr->IsFormDisabled() || 693 if (m_pWidgetMgr->IsFormDisabled() ||
694 IsNeedRepaint(child, &widgetMatrix, rtClip)) { 694 IsNeedRepaint(child, &widgetMatrix, rtClip)) {
695 pDelegate->OnDrawWidget(pGraphics, &widgetMatrix); 695 pDelegate->OnDrawWidget(pGraphics, &widgetMatrix);
696 } 696 }
697 } 697 }
698 if (!bFormDisable) 698 if (!bFormDisable)
699 pGraphics->RestoreGraphState(); 699 pGraphics->RestoreGraphState();
700 700
701 DrawChild(child, clipBounds, pGraphics, 701 DrawChild(child, clipBounds, pGraphics,
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 pWidget(widget), 871 pWidget(widget),
872 iRedrawCounter(0) 872 iRedrawCounter(0)
873 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) 873 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
874 , 874 ,
875 bOutsideChanged(FALSE) 875 bOutsideChanged(FALSE)
876 #endif 876 #endif
877 { 877 {
878 } 878 }
879 879
880 CFWL_WidgetMgrItem::~CFWL_WidgetMgrItem() {} 880 CFWL_WidgetMgrItem::~CFWL_WidgetMgrItem() {}
OLDNEW
« no previous file with comments | « xfa/fwl/core/cfwl_widgetmgr.h ('k') | xfa/fwl/core/fwl_appimp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698