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

Side by Side Diff: xfa/fwl/basewidget/fwl_editimp.cpp

Issue 2207093005: Use smart pointers for class owned pointers (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: small fix Created 4 years, 4 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
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/basewidget/fwl_editimp.h" 7 #include "xfa/fwl/basewidget/fwl_editimp.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 return static_cast<CFWL_EditImp*>(GetImpl()) 196 return static_cast<CFWL_EditImp*>(GetImpl())
197 ->ReplaceSpellCheckWord(pointf, bsReplace); 197 ->ReplaceSpellCheckWord(pointf, bsReplace);
198 } 198 }
199 199
200 CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties& properties, 200 CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties& properties,
201 IFWL_Widget* pOuter) 201 IFWL_Widget* pOuter)
202 : CFWL_WidgetImp(properties, pOuter), 202 : CFWL_WidgetImp(properties, pOuter),
203 m_fVAlignOffset(0.0f), 203 m_fVAlignOffset(0.0f),
204 m_fScrollOffsetX(0.0f), 204 m_fScrollOffsetX(0.0f),
205 m_fScrollOffsetY(0.0f), 205 m_fScrollOffsetY(0.0f),
206 m_pEdtEngine(nullptr),
207 m_bLButtonDown(FALSE), 206 m_bLButtonDown(FALSE),
208 m_nSelStart(0), 207 m_nSelStart(0),
209 m_nLimit(-1), 208 m_nLimit(-1),
210 m_fSpaceAbove(0), 209 m_fSpaceAbove(0),
211 m_fSpaceBelow(0), 210 m_fSpaceBelow(0),
212 m_fFontSize(0), 211 m_fFontSize(0),
213 m_bSetRange(FALSE), 212 m_bSetRange(FALSE),
214 m_iMin(-1), 213 m_iMin(-1),
215 m_iMax(0xFFFFFFF), 214 m_iMax(0xFFFFFFF),
216 m_backColor(0), 215 m_backColor(0),
217 m_updateBackColor(FALSE), 216 m_updateBackColor(FALSE),
218 m_iCurRecord(-1), 217 m_iCurRecord(-1),
219 m_iMaxRecord(128) { 218 m_iMaxRecord(128) {
220 m_rtClient.Reset(); 219 m_rtClient.Reset();
221 m_rtEngine.Reset(); 220 m_rtEngine.Reset();
222 m_rtStatic.Reset(); 221 m_rtStatic.Reset();
223 } 222 }
224 223
225 CFWL_EditImp::~CFWL_EditImp() { 224 CFWL_EditImp::~CFWL_EditImp() {
226 delete m_pEdtEngine;
227 ClearRecord(); 225 ClearRecord();
228 } 226 }
229 227
230 FWL_Error CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const { 228 FWL_Error CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const {
231 wsClass = FWL_CLASS_Edit; 229 wsClass = FWL_CLASS_Edit;
232 return FWL_Error::Succeeded; 230 return FWL_Error::Succeeded;
233 } 231 }
234 232
235 FWL_Type CFWL_EditImp::GetClassID() const { 233 FWL_Type CFWL_EditImp::GetClassID() const {
236 return FWL_Type::Edit; 234 return FWL_Type::Edit;
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 CFWL_EvtEdtTextChanged event; 889 CFWL_EvtEdtTextChanged event;
892 event.m_pSrcTarget = m_pInterface; 890 event.m_pSrcTarget = m_pInterface;
893 event.nChangeType = ChangeInfo.nChangeType; 891 event.nChangeType = ChangeInfo.nChangeType;
894 event.wsInsert = ChangeInfo.wsInsert; 892 event.wsInsert = ChangeInfo.wsInsert;
895 event.wsDelete = ChangeInfo.wsDelete; 893 event.wsDelete = ChangeInfo.wsDelete;
896 event.wsPrevText = ChangeInfo.wsPrevText; 894 event.wsPrevText = ChangeInfo.wsPrevText;
897 DispatchEvent(&event); 895 DispatchEvent(&event);
898 LayoutScrollBar(); 896 LayoutScrollBar();
899 Repaint(&rtTemp); 897 Repaint(&rtTemp);
900 } 898 }
899
901 void CFWL_EditImp::On_SelChanged(CFDE_TxtEdtEngine* pEdit) { 900 void CFWL_EditImp::On_SelChanged(CFDE_TxtEdtEngine* pEdit) {
902 CFX_RectF rtTemp; 901 CFX_RectF rtTemp;
903 GetClientRect(rtTemp); 902 GetClientRect(rtTemp);
904 Repaint(&rtTemp); 903 Repaint(&rtTemp);
905 } 904 }
905
906 FX_BOOL CFWL_EditImp::On_PageLoad(CFDE_TxtEdtEngine* pEdit, 906 FX_BOOL CFWL_EditImp::On_PageLoad(CFDE_TxtEdtEngine* pEdit,
907 int32_t nPageIndex, 907 int32_t nPageIndex,
908 int32_t nPurpose) { 908 int32_t nPurpose) {
909 CFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine; 909 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex);
910 IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex);
911 if (!pPage) 910 if (!pPage)
912 return FALSE; 911 return FALSE;
913 pPage->LoadPage(nullptr, nullptr); 912 pPage->LoadPage(nullptr, nullptr);
914 return TRUE; 913 return TRUE;
915 } 914 }
915
916 FX_BOOL CFWL_EditImp::On_PageUnload(CFDE_TxtEdtEngine* pEdit, 916 FX_BOOL CFWL_EditImp::On_PageUnload(CFDE_TxtEdtEngine* pEdit,
917 int32_t nPageIndex, 917 int32_t nPageIndex,
918 int32_t nPurpose) { 918 int32_t nPurpose) {
919 CFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine; 919 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex);
920 IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex);
921 if (!pPage) 920 if (!pPage)
922 return FALSE; 921 return FALSE;
923 pPage->UnloadPage(nullptr); 922 pPage->UnloadPage(nullptr);
924 return TRUE; 923 return TRUE;
925 } 924 }
926 925
927 void CFWL_EditImp::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, 926 void CFWL_EditImp::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit,
928 IFDE_TxtEdtDoRecord* pRecord) { 927 IFDE_TxtEdtDoRecord* pRecord) {
929 AddDoRecord(pRecord); 928 AddDoRecord(pRecord);
930 } 929 }
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; 1622 prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible;
1624 prop.m_pParent = m_pInterface; 1623 prop.m_pParent = m_pInterface;
1625 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 1624 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
1626 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface); 1625 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface);
1627 pScrollBar->Initialize(); 1626 pScrollBar->Initialize();
1628 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); 1627 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar);
1629 } 1628 }
1630 1629
1631 void CFWL_EditImp::InitEngine() { 1630 void CFWL_EditImp::InitEngine() {
1632 if (!m_pEdtEngine) 1631 if (!m_pEdtEngine)
1633 m_pEdtEngine = new CFDE_TxtEdtEngine; 1632 m_pEdtEngine.reset(new CFDE_TxtEdtEngine);
1634 } 1633 }
1635 1634
1636 FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, 1635 FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget,
1637 FX_BOOL bVisible, 1636 FX_BOOL bVisible,
1638 const CFX_RectF* pRtAnchor) { 1637 const CFX_RectF* pRtAnchor) {
1639 CXFA_FFWidget* pXFAWidget = 1638 CXFA_FFWidget* pXFAWidget =
1640 static_cast<CXFA_FFWidget*>(pWidget->GetLayoutItem()); 1639 static_cast<CXFA_FFWidget*>(pWidget->GetLayoutItem());
1641 if (!pXFAWidget) 1640 if (!pXFAWidget)
1642 return FALSE; 1641 return FALSE;
1643 1642
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
2186 } 2185 }
2187 CFX_RectF rect; 2186 CFX_RectF rect;
2188 m_pOwner->GetWidgetRect(rect); 2187 m_pOwner->GetWidgetRect(rect);
2189 CFX_RectF rtInvalidate; 2188 CFX_RectF rtInvalidate;
2190 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); 2189 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2);
2191 m_pOwner->Repaint(&rtInvalidate); 2190 m_pOwner->Repaint(&rtInvalidate);
2192 } 2191 }
2193 return TRUE; 2192 return TRUE;
2194 } 2193 }
2195 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} 2194 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698