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

Side by Side Diff: xfa/fwl/theme/cfwl_widgettp.cpp

Issue 2571913002: Avoid the ptr.reset(new XXX()) anti-pattern (Closed)
Patch Set: rebase Created 4 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 | « xfa/fwl/theme/cfwl_checkboxtp.cpp ('k') | xfa/fxbarcode/BC_TwoDimWriter.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/theme/cfwl_widgettp.h" 7 #include "xfa/fwl/theme/cfwl_widgettp.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
11 11
12 #include "third_party/base/ptr_util.h"
12 #include "xfa/fde/tto/fde_textout.h" 13 #include "xfa/fde/tto/fde_textout.h"
13 #include "xfa/fgas/font/cfgas_fontmgr.h" 14 #include "xfa/fgas/font/cfgas_fontmgr.h"
14 #include "xfa/fgas/font/cfgas_gefont.h" 15 #include "xfa/fgas/font/cfgas_gefont.h"
15 #include "xfa/fwl/cfwl_themebackground.h" 16 #include "xfa/fwl/cfwl_themebackground.h"
16 #include "xfa/fwl/cfwl_themepart.h" 17 #include "xfa/fwl/cfwl_themepart.h"
17 #include "xfa/fwl/cfwl_themetext.h" 18 #include "xfa/fwl/cfwl_themetext.h"
18 #include "xfa/fwl/cfwl_widget.h" 19 #include "xfa/fwl/cfwl_widget.h"
19 #include "xfa/fwl/cfwl_widgetmgr.h" 20 #include "xfa/fwl/cfwl_widgetmgr.h"
20 #include "xfa/fwl/ifwl_themeprovider.h" 21 #include "xfa/fwl/ifwl_themeprovider.h"
21 #include "xfa/fwl/theme/cfwl_arrowdata.h" 22 #include "xfa/fwl/theme/cfwl_arrowdata.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 167 }
167 168
168 CFWL_WidgetTP::CFWL_WidgetTP() : m_dwRefCount(1), m_pFDEFont(nullptr) {} 169 CFWL_WidgetTP::CFWL_WidgetTP() : m_dwRefCount(1), m_pFDEFont(nullptr) {}
169 170
170 void CFWL_WidgetTP::InitTTO() { 171 void CFWL_WidgetTP::InitTTO() {
171 if (m_pTextOut) 172 if (m_pTextOut)
172 return; 173 return;
173 174
174 m_pFDEFont = 175 m_pFDEFont =
175 CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0); 176 CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0);
176 m_pTextOut.reset(new CFDE_TextOut); 177 m_pTextOut = pdfium::MakeUnique<CFDE_TextOut>();
177 m_pTextOut->SetFont(m_pFDEFont); 178 m_pTextOut->SetFont(m_pFDEFont);
178 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); 179 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize);
179 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); 180 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor);
180 m_pTextOut->SetEllipsisString(L"..."); 181 m_pTextOut->SetEllipsisString(L"...");
181 } 182 }
182 183
183 void CFWL_WidgetTP::FinalizeTTO() { 184 void CFWL_WidgetTP::FinalizeTTO() {
184 m_pTextOut.reset(); 185 m_pTextOut.reset();
185 } 186 }
186 187
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 bool CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily, 635 bool CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily,
635 uint32_t dwFontStyles, 636 uint32_t dwFontStyles,
636 uint16_t dwCodePage) { 637 uint16_t dwCodePage) {
637 m_wsFamily = wsFontFamily; 638 m_wsFamily = wsFontFamily;
638 m_dwStyles = dwFontStyles; 639 m_dwStyles = dwFontStyles;
639 m_dwCodePage = dwCodePage; 640 m_dwCodePage = dwCodePage;
640 if (!m_pFontMgr) { 641 if (!m_pFontMgr) {
641 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 642 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
642 m_pFontMgr = CFGAS_FontMgr::Create(FX_GetDefFontEnumerator()); 643 m_pFontMgr = CFGAS_FontMgr::Create(FX_GetDefFontEnumerator());
643 #else 644 #else
644 m_pFontSource.reset(new CFX_FontSourceEnum_File); 645 m_pFontSource = pdfium::MakeUnique<CFX_FontSourceEnum_File>();
645 m_pFontMgr = CFGAS_FontMgr::Create(m_pFontSource.get()); 646 m_pFontMgr = CFGAS_FontMgr::Create(m_pFontSource.get());
646 #endif 647 #endif
647 } 648 }
648 m_pFont.reset(CFGAS_GEFont::LoadFont(wsFontFamily.c_str(), dwFontStyles, 649 m_pFont.reset(CFGAS_GEFont::LoadFont(wsFontFamily.c_str(), dwFontStyles,
649 dwCodePage, m_pFontMgr.get())); 650 dwCodePage, m_pFontMgr.get()));
650 return !!m_pFont; 651 return !!m_pFont;
651 } 652 }
652 653
653 CFWL_FontManager* CFWL_FontManager::s_FontManager = nullptr; 654 CFWL_FontManager* CFWL_FontManager::s_FontManager = nullptr;
654 CFWL_FontManager* CFWL_FontManager::GetInstance() { 655 CFWL_FontManager* CFWL_FontManager::GetInstance() {
(...skipping 22 matching lines...) Expand all
677 if (!pFontData->LoadFont(wsFontFamily, dwFontStyles, wCodePage)) 678 if (!pFontData->LoadFont(wsFontFamily, dwFontStyles, wCodePage))
678 return nullptr; 679 return nullptr;
679 m_FontsArray.push_back(std::move(pFontData)); 680 m_FontsArray.push_back(std::move(pFontData));
680 return m_FontsArray.back()->GetFont(); 681 return m_FontsArray.back()->GetFont();
681 } 682 }
682 683
683 void FWLTHEME_Release() { 684 void FWLTHEME_Release() {
684 CFWL_ArrowData::DestroyInstance(); 685 CFWL_ArrowData::DestroyInstance();
685 CFWL_FontManager::DestroyInstance(); 686 CFWL_FontManager::DestroyInstance();
686 } 687 }
OLDNEW
« no previous file with comments | « xfa/fwl/theme/cfwl_checkboxtp.cpp ('k') | xfa/fxbarcode/BC_TwoDimWriter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698