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

Side by Side Diff: xfa/fxfa/app/xfa_fwltheme.cpp

Issue 1960673003: Replace some calls to Release() with direct delete, part 1. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Another unique_ptr. Created 4 years, 7 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/fxfa/app/xfa_fwltheme.h ('k') | xfa/fxfa/app/xfa_textlayout.h » ('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/fxfa/app/xfa_fwltheme.h" 7 #include "xfa/fxfa/app/xfa_fwltheme.h"
8 8
9 #include "xfa/fde/tto/fde_textout.h" 9 #include "xfa/fde/tto/fde_textout.h"
10 #include "xfa/fgas/crt/fgas_codepage.h" 10 #include "xfa/fgas/crt/fgas_codepage.h"
(...skipping 26 matching lines...) Expand all
37 IFWL_Widget* pOuter = pWidget; 37 IFWL_Widget* pOuter = pWidget;
38 while (pOuter->GetOuter()) { 38 while (pOuter->GetOuter()) {
39 pOuter = pOuter->GetOuter(); 39 pOuter = pOuter->GetOuter();
40 } 40 }
41 if (pOuter) { 41 if (pOuter) {
42 return (CXFA_FFWidget*)pOuter->GetPrivateData(pOuter); 42 return (CXFA_FFWidget*)pOuter->GetPrivateData(pOuter);
43 } 43 }
44 return NULL; 44 return NULL;
45 } 45 }
46 CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp) : m_pApp(pApp) { 46 CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp) : m_pApp(pApp) {
47 m_pTextOut = NULL;
48 m_dwCapacity = 0; 47 m_dwCapacity = 0;
49 m_fCapacity = 0; 48 m_fCapacity = 0;
50 m_pCalendarFont = NULL; 49 m_pCalendarFont = NULL;
51 m_Rect.Set(0, 0, 0, 0); 50 m_Rect.Set(0, 0, 0, 0);
52 m_pCheckBoxTP = new CXFA_FWLCheckBoxTP; 51 m_pCheckBoxTP = new CXFA_FWLCheckBoxTP;
53 m_pListBoxTP = new CFWL_ListBoxTP; 52 m_pListBoxTP = new CFWL_ListBoxTP;
54 m_pPictureBoxTP = new CFWL_PictureBoxTP; 53 m_pPictureBoxTP = new CFWL_PictureBoxTP;
55 m_pSrollBarTP = new CFWL_ScrollBarTP; 54 m_pSrollBarTP = new CFWL_ScrollBarTP;
56 m_pEditTP = new CXFA_FWLEditTP; 55 m_pEditTP = new CXFA_FWLEditTP;
57 m_pComboBoxTP = new CFWL_ComboBoxTP; 56 m_pComboBoxTP = new CFWL_ComboBoxTP;
(...skipping 12 matching lines...) Expand all
70 delete m_pSrollBarTP; 69 delete m_pSrollBarTP;
71 delete m_pEditTP; 70 delete m_pEditTP;
72 delete m_pComboBoxTP; 71 delete m_pComboBoxTP;
73 delete m_pMonthCalendarTP; 72 delete m_pMonthCalendarTP;
74 delete m_pDateTimePickerTP; 73 delete m_pDateTimePickerTP;
75 delete m_pPushButtonTP; 74 delete m_pPushButtonTP;
76 delete m_pCaretTP; 75 delete m_pCaretTP;
77 delete m_pBarcodeTP; 76 delete m_pBarcodeTP;
78 } 77 }
79 FWL_Error CXFA_FWLTheme::Initialize() { 78 FWL_Error CXFA_FWLTheme::Initialize() {
80 m_pTextOut = new CFDE_TextOut; 79 m_pTextOut.reset(new CFDE_TextOut);
81 for (size_t i = 0; !m_pCalendarFont && i < FX_ArraySize(g_FWLTheme_CalFonts); 80 for (size_t i = 0; !m_pCalendarFont && i < FX_ArraySize(g_FWLTheme_CalFonts);
82 ++i) { 81 ++i) {
83 m_pCalendarFont = IFX_Font::LoadFont(g_FWLTheme_CalFonts[i], 0, 0, 82 m_pCalendarFont = IFX_Font::LoadFont(g_FWLTheme_CalFonts[i], 0, 0,
84 m_pApp->GetFDEFontMgr()); 83 m_pApp->GetFDEFontMgr());
85 } 84 }
86 if (!m_pCalendarFont) { 85 if (!m_pCalendarFont) {
87 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 86 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
88 m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetDefFontByCodePage( 87 m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetDefFontByCodePage(
89 FX_CODEPAGE_MSWin_WesternEuropean, 0, NULL); 88 FX_CODEPAGE_MSWin_WesternEuropean, 0, NULL);
90 #else 89 #else
91 m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetFontByCodePage( 90 m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetFontByCodePage(
92 FX_CODEPAGE_MSWin_WesternEuropean, 0, NULL); 91 FX_CODEPAGE_MSWin_WesternEuropean, 0, NULL);
93 #endif 92 #endif
94 } 93 }
95 94
96 ASSERT(NULL != m_pCalendarFont); 95 ASSERT(NULL != m_pCalendarFont);
97 FWLTHEME_Init(); 96 FWLTHEME_Init();
98 return FWL_Error::Succeeded; 97 return FWL_Error::Succeeded;
99 } 98 }
100 FWL_Error CXFA_FWLTheme::Finalize() { 99 FWL_Error CXFA_FWLTheme::Finalize() {
101 if (m_pTextOut) { 100 m_pTextOut.reset();
102 m_pTextOut->Release();
103 m_pTextOut = NULL;
104 }
105 if (m_pCalendarFont) { 101 if (m_pCalendarFont) {
106 m_pCalendarFont->Release(); 102 m_pCalendarFont->Release();
107 m_pCalendarFont = NULL; 103 m_pCalendarFont = nullptr;
108 } 104 }
109 FWLTHEME_Release(); 105 FWLTHEME_Release();
110 return FWL_Error::Succeeded; 106 return FWL_Error::Succeeded;
111 } 107 }
112 108
113 bool CXFA_FWLTheme::IsValidWidget(IFWL_Widget* pWidget) { 109 bool CXFA_FWLTheme::IsValidWidget(IFWL_Widget* pWidget) {
114 return TRUE; 110 return TRUE;
115 } 111 }
116 112
117 uint32_t CXFA_FWLTheme::GetThemeID(IFWL_Widget* pWidget) { 113 uint32_t CXFA_FWLTheme::GetThemeID(IFWL_Widget* pWidget) {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); 375 CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget);
380 if (!pWidget) 376 if (!pWidget)
381 return FALSE; 377 return FALSE;
382 378
383 CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); 379 CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc();
384 m_pTextOut->SetFont(pAcc->GetFDEFont()); 380 m_pTextOut->SetFont(pAcc->GetFDEFont());
385 m_pTextOut->SetFontSize(pAcc->GetFontSize()); 381 m_pTextOut->SetFontSize(pAcc->GetFontSize());
386 m_pTextOut->SetTextColor(pAcc->GetTextColor()); 382 m_pTextOut->SetTextColor(pAcc->GetTextColor());
387 if (!pParams) 383 if (!pParams)
388 return FALSE; 384 return FALSE;
389 if (!m_pTextOut)
390 return FALSE;
391 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); 385 m_pTextOut->SetAlignment(pParams->m_iTTOAlign);
392 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); 386 m_pTextOut->SetStyles(pParams->m_dwTTOStyles);
393 m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), 387 m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(),
394 pParams->m_wsText.GetLength(), rect); 388 pParams->m_wsText.GetLength(), rect);
395 return TRUE; 389 return TRUE;
396 } 390 }
397 CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(IFWL_Widget* pWidget) { 391 CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(IFWL_Widget* pWidget) {
398 switch (pWidget->GetClassID()) { 392 switch (pWidget->GetClassID()) {
399 case FWL_Type::CheckBox: 393 case FWL_Type::CheckBox:
400 return m_pCheckBoxTP; 394 return m_pCheckBoxTP;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 } 480 }
487 } 481 }
488 CFX_Color crLine(cr); 482 CFX_Color crLine(cr);
489 pParams->m_pGraphics->SetStrokeColor(&crLine); 483 pParams->m_pGraphics->SetStrokeColor(&crLine);
490 pParams->m_pGraphics->SetLineWidth(fWidth); 484 pParams->m_pGraphics->SetLineWidth(fWidth);
491 pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix); 485 pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix);
492 return TRUE; 486 return TRUE;
493 } 487 }
494 return CFWL_EditTP::DrawBackground(pParams); 488 return CFWL_EditTP::DrawBackground(pParams);
495 } 489 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_fwltheme.h ('k') | xfa/fxfa/app/xfa_textlayout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698