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

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_Note.cpp

Issue 1512763013: Get rid of most instance of 'foo != NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 5 years 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/src/pdfwindow/PWL_ListBox.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_ScrollBar.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 "fpdfsdk/include/pdfwindow/PDFWindow.h" 7 #include "fpdfsdk/include/pdfwindow/PDFWindow.h"
8 #include "fpdfsdk/include/pdfwindow/PWL_Button.h" 8 #include "fpdfsdk/include/pdfwindow/PWL_Button.h"
9 #include "fpdfsdk/include/pdfwindow/PWL_Caret.h" 9 #include "fpdfsdk/include/pdfwindow/PWL_Caret.h"
10 #include "fpdfsdk/include/pdfwindow/PWL_Edit.h" 10 #include "fpdfsdk/include/pdfwindow/PWL_Edit.h"
(...skipping 29 matching lines...) Expand all
40 40
41 void CPWL_Note_Options::SetTextColor(const CPWL_Color& color) { 41 void CPWL_Note_Options::SetTextColor(const CPWL_Color& color) {
42 CPWL_Wnd::SetTextColor(color); 42 CPWL_Wnd::SetTextColor(color);
43 43
44 if (m_pText) 44 if (m_pText)
45 m_pText->SetTextColor(color); 45 m_pText->SetTextColor(color);
46 } 46 }
47 47
48 void CPWL_Note_Options::RePosChildWnd() { 48 void CPWL_Note_Options::RePosChildWnd() {
49 if (IsValid()) { 49 if (IsValid()) {
50 ASSERT(m_pText != NULL);
51
52 CPDF_Rect rcClient = GetClientRect(); 50 CPDF_Rect rcClient = GetClientRect();
53 51
54 if (rcClient.Width() > 15.0f) { 52 if (rcClient.Width() > 15.0f) {
55 rcClient.right -= 15.0f; 53 rcClient.right -= 15.0f;
56 m_pText->Move(rcClient, TRUE, FALSE); 54 m_pText->Move(rcClient, TRUE, FALSE);
57 m_pText->SetVisible(TRUE); 55 m_pText->SetVisible(TRUE);
58 } else { 56 } else {
59 m_pText->Move(CPDF_Rect(0, 0, 0, 0), TRUE, FALSE); 57 m_pText->Move(CPDF_Rect(0, 0, 0, 0), TRUE, FALSE);
60 m_pText->SetVisible(FALSE); 58 m_pText->SetVisible(FALSE);
61 } 59 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO); 94 path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO);
97 path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); 95 path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO);
98 96
99 pDevice->DrawPath( 97 pDevice->DrawPath(
100 &path, pUser2Device, NULL, 98 &path, pUser2Device, NULL,
101 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), 0, 99 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), 0,
102 FXFILL_ALTERNATE); 100 FXFILL_ALTERNATE);
103 } 101 }
104 102
105 CPDF_Rect CPWL_Note_Options::GetContentRect() const { 103 CPDF_Rect CPWL_Note_Options::GetContentRect() const {
106 ASSERT(m_pText != NULL);
107
108 CPDF_Rect rcText = m_pText->GetContentRect(); 104 CPDF_Rect rcText = m_pText->GetContentRect();
109 rcText.right += 15.0f; 105 rcText.right += 15.0f;
110 return rcText; 106 return rcText;
111 } 107 }
112 108
113 /* ------------------------------- CPWL_Note_Edit ------------------------------ 109 /* ------------------------------- CPWL_Note_Edit ------------------------------
114 */ 110 */
115 111
116 CPWL_Note_Edit::CPWL_Note_Edit() 112 CPWL_Note_Edit::CPWL_Note_Edit()
117 : m_bEnableNotify(TRUE), 113 : m_bEnableNotify(TRUE),
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 CPWL_Color(COLORTYPE_RGB, 240 / 255.0f, 240 / 255.0f, 240 / 255.0f); 650 CPWL_Color(COLORTYPE_RGB, 240 / 255.0f, 240 / 255.0f, 240 / 255.0f);
655 ccp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BACKGROUND; 651 ccp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BACKGROUND;
656 m_pContents->Create(ccp); 652 m_pContents->Create(ccp);
657 m_pContents->SetItemSpace(POPUP_ITEM_SPACE); 653 m_pContents->SetItemSpace(POPUP_ITEM_SPACE);
658 m_pContents->SetTopSpace(POPUP_ITEM_SPACE); 654 m_pContents->SetTopSpace(POPUP_ITEM_SPACE);
659 m_pContents->SetBottomSpace(POPUP_ITEM_SPACE); 655 m_pContents->SetBottomSpace(POPUP_ITEM_SPACE);
660 } 656 }
661 657
662 void CPWL_NoteItem::RePosChildWnd() { 658 void CPWL_NoteItem::RePosChildWnd() {
663 if (IsValid()) { 659 if (IsValid()) {
664 ASSERT(m_pSubject != NULL);
665 ASSERT(m_pDateTime != NULL);
666 ASSERT(m_pContents != NULL);
667
668 CPDF_Rect rcClient = GetClientRect(); 660 CPDF_Rect rcClient = GetClientRect();
669 661
670 CPDF_Rect rcSubject = rcClient; 662 CPDF_Rect rcSubject = rcClient;
671 rcSubject.left += POPUP_ITEM_TEXT_INDENT; 663 rcSubject.left += POPUP_ITEM_TEXT_INDENT;
672 rcSubject.top = rcClient.top; 664 rcSubject.top = rcClient.top;
673 rcSubject.right = 665 rcSubject.right =
674 PWL_MIN(rcSubject.left + m_pSubject->GetContentRect().Width() + 1.0f, 666 PWL_MIN(rcSubject.left + m_pSubject->GetContentRect().Width() + 1.0f,
675 rcClient.right); 667 rcClient.right);
676 rcSubject.bottom = rcSubject.top - m_pSubject->GetContentRect().Height(); 668 rcSubject.bottom = rcSubject.top - m_pSubject->GetContentRect().Height();
677 rcSubject.Normalize(); 669 rcSubject.Normalize();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 if (nItemIndex < 0) { 744 if (nItemIndex < 0) {
753 if (CPWL_Wnd* pParent = GetParentWindow()) { 745 if (CPWL_Wnd* pParent = GetParentWindow()) {
754 ASSERT(pParent->GetClassName() == "CPWL_Note_Contents"); 746 ASSERT(pParent->GetClassName() == "CPWL_Note_Contents");
755 747
756 CPWL_Note_Contents* pContents = (CPWL_Note_Contents*)pParent; 748 CPWL_Note_Contents* pContents = (CPWL_Note_Contents*)pParent;
757 nItemIndex = pContents->GetItemIndex(this); 749 nItemIndex = pContents->GetItemIndex(this);
758 } 750 }
759 } 751 }
760 752
761 const CPWL_Note* pNote = GetNote(); 753 const CPWL_Note* pNote = GetNote();
762 ASSERT(pNote != NULL);
763
764 CFX_WideString sSubject; 754 CFX_WideString sSubject;
765 sSubject.Format(pNote->GetReplyString().c_str(), nItemIndex); 755 sSubject.Format(pNote->GetReplyString().c_str(), nItemIndex);
766 756
767 if (!m_sAuthor.IsEmpty()) { 757 if (!m_sAuthor.IsEmpty()) {
768 sSubject += L" - "; 758 sSubject += L" - ";
769 sSubject += m_sAuthor; 759 sSubject += m_sAuthor;
770 } 760 }
771 SetSubjectName(sSubject); 761 SetSubjectName(sSubject);
772 RePosChildWnd(); 762 RePosChildWnd();
773 } 763 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 return NULL; 908 return NULL;
919 } 909 }
920 910
921 FX_FLOAT CPWL_NoteItem::GetItemHeight(FX_FLOAT fLimitWidth) { 911 FX_FLOAT CPWL_NoteItem::GetItemHeight(FX_FLOAT fLimitWidth) {
922 if (fLimitWidth > 0) { 912 if (fLimitWidth > 0) {
923 if (!m_bSizeChanged) 913 if (!m_bSizeChanged)
924 return m_fOldItemHeight; 914 return m_fOldItemHeight;
925 915
926 m_bSizeChanged = FALSE; 916 m_bSizeChanged = FALSE;
927 917
928 ASSERT(m_pSubject != NULL);
929 ASSERT(m_pDateTime != NULL);
930 ASSERT(m_pContents != NULL);
931
932 FX_FLOAT fRet = m_pDateTime->GetContentRect().Height(); 918 FX_FLOAT fRet = m_pDateTime->GetContentRect().Height();
933 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); 919 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
934 if (fLimitWidth > fBorderWidth * 2) 920 if (fLimitWidth > fBorderWidth * 2)
935 fRet += m_pContents->GetContentsHeight(fLimitWidth - fBorderWidth * 2); 921 fRet += m_pContents->GetContentsHeight(fLimitWidth - fBorderWidth * 2);
936 fRet += POPUP_ITEM_HEAD_BOTTOM + POPUP_ITEM_BOTTOMWIDTH + fBorderWidth * 2; 922 fRet += POPUP_ITEM_HEAD_BOTTOM + POPUP_ITEM_BOTTOMWIDTH + fBorderWidth * 2;
937 923
938 return m_fOldItemHeight = fRet; 924 return m_fOldItemHeight = fRet;
939 } 925 }
940 926
941 return 0; 927 return 0;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 RePosNoteChildren(); 1135 RePosNoteChildren();
1150 } 1136 }
1151 1137
1152 void CPWL_Note::RePosNoteChildren() { 1138 void CPWL_Note::RePosNoteChildren() {
1153 if (m_bResizing) 1139 if (m_bResizing)
1154 return; 1140 return;
1155 1141
1156 m_bResizing = TRUE; 1142 m_bResizing = TRUE;
1157 1143
1158 if (IsValid()) { 1144 if (IsValid()) {
1159 ASSERT(m_pSubject != NULL);
1160 ASSERT(m_pDateTime != NULL);
1161 ASSERT(m_pContents != NULL);
1162 ASSERT(m_pAuthor != NULL);
1163 ASSERT(m_pCloseBox != NULL);
1164 ASSERT(m_pIcon != NULL);
1165 ASSERT(m_pLBBox != NULL);
1166 ASSERT(m_pRBBox != NULL);
1167 ASSERT(m_pContentsBar != NULL);
1168 ASSERT(m_pOptions != NULL);
1169
1170 CPDF_Rect rcClient = GetClientRect(); 1145 CPDF_Rect rcClient = GetClientRect();
1171 1146
1172 CPDF_Rect rcIcon = rcClient; 1147 CPDF_Rect rcIcon = rcClient;
1173 rcIcon.top -= 2.0f; 1148 rcIcon.top -= 2.0f;
1174 rcIcon.right = rcIcon.left + 14.0f; 1149 rcIcon.right = rcIcon.left + 14.0f;
1175 rcIcon.bottom = rcIcon.top - 14.0f; 1150 rcIcon.bottom = rcIcon.top - 14.0f;
1176 rcIcon.Normalize(); 1151 rcIcon.Normalize();
1177 m_pIcon->Move(rcIcon, TRUE, FALSE); 1152 m_pIcon->Move(rcIcon, TRUE, FALSE);
1178 m_pIcon->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcIcon)); 1153 m_pIcon->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcIcon));
1179 1154
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 rcContentsBar.Normalize(); 1235 rcContentsBar.Normalize();
1261 m_pContentsBar->Move(rcContentsBar, TRUE, FALSE); 1236 m_pContentsBar->Move(rcContentsBar, TRUE, FALSE);
1262 1237
1263 m_rcCaption = rcClient; 1238 m_rcCaption = rcClient;
1264 m_rcCaption.bottom = rcContents.top; 1239 m_rcCaption.bottom = rcContents.top;
1265 } 1240 }
1266 1241
1267 m_bResizing = FALSE; 1242 m_bResizing = FALSE;
1268 } 1243 }
1269 1244
1245 // TODO(thestig): Make this return an enum.
1270 // 0-normal / 1-caption / 2-leftbottom corner / 3-rightbottom corner / 4-close / 1246 // 0-normal / 1-caption / 2-leftbottom corner / 3-rightbottom corner / 4-close /
1271 // 5-options 1247 // 5-options
1272 int32_t CPWL_Note::NoteHitTest(const CPDF_Point& point) const { 1248 int32_t CPWL_Note::NoteHitTest(const CPDF_Point& point) const {
1273 ASSERT(m_pSubject != NULL);
1274 ASSERT(m_pDateTime != NULL);
1275 ASSERT(m_pContents != NULL);
1276 ASSERT(m_pAuthor != NULL);
1277 ASSERT(m_pIcon != NULL);
1278 ASSERT(m_pContentsBar != NULL);
1279
1280 ASSERT(m_pCloseBox != NULL);
1281 ASSERT(m_pLBBox != NULL);
1282 ASSERT(m_pRBBox != NULL);
1283 ASSERT(m_pOptions != NULL);
1284
1285 GetClientRect(); 1249 GetClientRect();
1286 1250
1287 if (m_pSubject->WndHitTest(m_pSubject->ParentToChild(point))) 1251 if (m_pSubject->WndHitTest(m_pSubject->ParentToChild(point)))
1288 return 1; 1252 return 1;
1289 if (m_pDateTime->WndHitTest(m_pDateTime->ParentToChild(point))) 1253 if (m_pDateTime->WndHitTest(m_pDateTime->ParentToChild(point)))
1290 return 1; 1254 return 1;
1291 if (m_pAuthor->WndHitTest(m_pAuthor->ParentToChild(point))) 1255 if (m_pAuthor->WndHitTest(m_pAuthor->ParentToChild(point)))
1292 return 1; 1256 return 1;
1293 if (m_pIcon->WndHitTest(m_pIcon->ParentToChild(point))) 1257 if (m_pIcon->WndHitTest(m_pIcon->ParentToChild(point)))
1294 return 1; 1258 return 1;
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 m_pContents->EnableRead(bEnabled); 1570 m_pContents->EnableRead(bEnabled);
1607 } 1571 }
1608 1572
1609 CFX_WideString CPWL_Note::GetReplyString() const { 1573 CFX_WideString CPWL_Note::GetReplyString() const {
1610 return m_sReplyString; 1574 return m_sReplyString;
1611 } 1575 }
1612 1576
1613 void CPWL_Note::SetReplyString(const CFX_WideString& string) { 1577 void CPWL_Note::SetReplyString(const CFX_WideString& string) {
1614 m_sReplyString = string; 1578 m_sReplyString = string;
1615 } 1579 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_ListBox.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698