From d403329fa818ffd650221cee366c837f867e3df6 Mon Sep 17 00:00:00 2001 From: tsepez Date: Tue, 19 Apr 2016 12:03:15 -0700 Subject: Store WideString, not raw pointer, in FX_TXTRUN Storing raw pointers in structs is a questionable idea, given that we've got string classes to auto-manage lifetimes of the underlying storage. Also, return FX_TXTRUN while we're at it, since we count on RVO removing copies nowadays. BUG=pdfium:480 Review URL: https://codereview.chromium.org/1900743004 --- xfa/fgas/layout/fgas_textbreak.cpp | 4 ++-- xfa/fgas/layout/fgas_textbreak.h | 34 ++++++++++++++++------------------ 2 files changed, 18 insertions(+), 20 deletions(-) (limited to 'xfa/fgas') diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp index 0face90abd..f8cfcd0066 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -1174,7 +1174,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, } IFX_TxtAccess* pAccess = pTxtRun->pAccess; void* pIdentity = pTxtRun->pIdentity; - const FX_WCHAR* pStr = pTxtRun->pStr; + const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); int32_t* pWidths = pTxtRun->pWidths; int32_t iLength = pTxtRun->iLength - 1; IFX_Font* pFont = pTxtRun->pFont; @@ -1554,7 +1554,7 @@ int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, } IFX_TxtAccess* pAccess = pTxtRun->pAccess; void* pIdentity = pTxtRun->pIdentity; - const FX_WCHAR* pStr = pTxtRun->pStr; + const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); int32_t* pWidths = pTxtRun->pWidths; int32_t iLength = pTxtRun->iLength; CFX_RectF rect(*pTxtRun->pRect); diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h index b83f2604c8..af6d52163f 100644 --- a/xfa/fgas/layout/fgas_textbreak.h +++ b/xfa/fgas/layout/fgas_textbreak.h @@ -79,27 +79,25 @@ class IFX_TxtAccess { }; struct FX_TXTRUN { - FX_TXTRUN() { - pAccess = NULL; - pIdentity = NULL; - pStr = NULL; - pWidths = NULL; - iLength = 0; - pFont = NULL; - fFontSize = 12; - dwStyles = 0; - iHorizontalScale = 100; - iVerticalScale = 100; - iCharRotation = 0; - dwCharStyles = 0; - pRect = NULL; - wLineBreakChar = L'\n'; - bSkipSpace = TRUE; - } + FX_TXTRUN() + : pAccess(nullptr), + pIdentity(nullptr), + pWidths(nullptr), + iLength(0), + pFont(nullptr), + fFontSize(12), + dwStyles(0), + iHorizontalScale(100), + iVerticalScale(100), + iCharRotation(0), + dwCharStyles(0), + pRect(nullptr), + wLineBreakChar(L'\n'), + bSkipSpace(TRUE) {} IFX_TxtAccess* pAccess; void* pIdentity; - const FX_WCHAR* pStr; + CFX_WideString wsStr; int32_t* pWidths; int32_t iLength; IFX_Font* pFont; -- cgit v1.2.3