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
diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp
index fe4e019..7895b78 100644
--- a/xfa/fde/tto/fde_textout.cpp
+++ b/xfa/fde/tto/fde_textout.cpp
@@ -142,7 +142,7 @@
   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 @@
   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);
diff --git a/xfa/fee/fde_txtedtpage.cpp b/xfa/fee/fde_txtedtpage.cpp
index eaf2627..4aadb39 100644
--- a/xfa/fee/fde_txtedtpage.cpp
+++ b/xfa/fee/fde_txtedtpage.cpp
@@ -81,8 +81,6 @@
   FX_TXTRUN tr;
   tr.pAccess = m_pPage;
   tr.pIdentity = (void*)hText;
-  tr.pStr = NULL;
-  tr.pWidths = NULL;
   tr.iLength = nLength;
   tr.pFont = pTextParams->pFont;
   tr.fFontSize = pTextParams->fFontSize;
@@ -114,8 +112,6 @@
   FX_TXTRUN tr;
   tr.pAccess = m_pPage;
   tr.pIdentity = (void*)hText;
-  tr.pStr = NULL;
-  tr.pWidths = NULL;
   tr.iLength = nLength;
   tr.pFont = pTextParams->pFont;
   tr.fFontSize = pTextParams->fFontSize;
diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp
index 0face90..f8cfcd0 100644
--- a/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/xfa/fgas/layout/fgas_textbreak.cpp
@@ -1174,7 +1174,7 @@
   }
   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 @@
   }
   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 b83f260..af6d521 100644
--- a/xfa/fgas/layout/fgas_textbreak.h
+++ b/xfa/fgas/layout/fgas_textbreak.h
@@ -79,27 +79,25 @@
 };
 
 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;