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/fde/tto/fde_textout.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'xfa/fde') diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp index fe4e019eb7..7895b785f3 100644 --- a/xfa/fde/tto/fde_textout.cpp +++ b/xfa/fde/tto/fde_textout.cpp @@ -142,7 +142,7 @@ class CFDE_TextOut : public IFDE_TextOut, public CFX_Target { int32_t GetDisplayPos(FDE_LPTTOPIECE pPiece); int32_t GetCharRects(FDE_LPTTOPIECE pPiece); - void ToTextRun(const FDE_LPTTOPIECE pPiece, FX_TXTRUN& tr); + FX_TXTRUN ToTextRun(const FDE_LPTTOPIECE pPiece); void DrawLine(const FDE_LPTTOPIECE pPiece, CFDE_Pen*& pPen); CFX_TxtBreak* m_pTxtBreak; @@ -975,32 +975,33 @@ void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { delete pBrush; delete pPen; } + int32_t CFDE_TextOut::GetDisplayPos(FDE_LPTTOPIECE pPiece) { - FX_TXTRUN tr; - ToTextRun(pPiece, tr); + FX_TXTRUN tr = ToTextRun(pPiece); ExpandBuffer(tr.iLength, 2); return m_pTxtBreak->GetDisplayPos(&tr, m_pCharPos); } + int32_t CFDE_TextOut::GetCharRects(FDE_LPTTOPIECE pPiece) { - FX_TXTRUN tr; - ToTextRun(pPiece, tr); + FX_TXTRUN tr = ToTextRun(pPiece); m_rectArray.RemoveAll(); return m_pTxtBreak->GetCharRects(&tr, m_rectArray); } -void CFDE_TextOut::ToTextRun(const FDE_LPTTOPIECE pPiece, FX_TXTRUN& tr) { - tr.pAccess = NULL; - tr.pIdentity = NULL; - tr.pStr = (m_wsText + pPiece->iStartChar).c_str(); + +FX_TXTRUN CFDE_TextOut::ToTextRun(const FDE_LPTTOPIECE pPiece) { + FX_TXTRUN tr; + tr.wsStr = m_wsText + pPiece->iStartChar; tr.pWidths = m_pCharWidths + pPiece->iStartChar; tr.iLength = pPiece->iChars; tr.pFont = m_pFont; tr.fFontSize = m_fFontSize; tr.dwStyles = m_dwTxtBkStyles; - tr.iCharRotation = 0; tr.dwCharStyles = pPiece->dwCharStyles; tr.wLineBreakChar = m_wParagraphBkChar; tr.pRect = &pPiece->rtPiece; + return tr; } + void CFDE_TextOut::DrawLine(const FDE_LPTTOPIECE pPiece, CFDE_Pen*& pPen) { FX_BOOL bUnderLine = !!(m_dwStyles & FDE_TTOSTYLE_Underline); FX_BOOL bStrikeOut = !!(m_dwStyles & FDE_TTOSTYLE_Strikeout); -- cgit v1.2.3