diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-03-02 12:21:15 -0800 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-02 21:01:30 +0000 |
commit | c803cbcad51355ffa38dce0851a51dfdcf279645 (patch) | |
tree | 82fa82015ec801285231cf507ed97bdea5fc7e08 /xfa/fde | |
parent | c3f74e91b2f019c3035395f5605cb98409502385 (diff) | |
download | pdfium-c803cbcad51355ffa38dce0851a51dfdcf279645.tar.xz |
Use std::deque for CFX_MassArrayTemplate<FDE_TEXTEDITPIECE>
Change-Id: I1080eefb4e47d7bc86fb3384fd7479a1fd49b203
Reviewed-on: https://pdfium-review.googlesource.com/2898
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fde')
-rw-r--r-- | xfa/fde/cfde_txtedtpage.cpp | 107 | ||||
-rw-r--r-- | xfa/fde/cfde_txtedtpage.h | 5 | ||||
-rw-r--r-- | xfa/fde/cfde_txtedttextset.cpp | 40 | ||||
-rw-r--r-- | xfa/fde/cfde_txtedttextset.h | 9 | ||||
-rw-r--r-- | xfa/fde/fde_render.cpp | 9 | ||||
-rw-r--r-- | xfa/fde/fde_visualset.h | 12 | ||||
-rw-r--r-- | xfa/fde/tto/fde_textout.cpp | 4 |
7 files changed, 79 insertions, 107 deletions
diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp index 56e1a04a55..8b58b2b443 100644 --- a/xfa/fde/cfde_txtedtpage.cpp +++ b/xfa/fde/cfde_txtedtpage.cpp @@ -31,7 +31,6 @@ IFDE_TxtEdtPage* IFDE_TxtEdtPage::Create(CFDE_TxtEdtEngine* pEngine, CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex) : m_pEditEngine(pEngine), - m_PieceMassArr(100), m_pBgnParag(nullptr), m_pEndParag(nullptr), m_nRefCount(0), @@ -41,9 +40,7 @@ CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex) m_bLoaded(false) { } -CFDE_TxtEdtPage::~CFDE_TxtEdtPage() { - m_PieceMassArr.RemoveAll(true); -} +CFDE_TxtEdtPage::~CFDE_TxtEdtPage() {} CFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const { return m_pEditEngine; @@ -53,25 +50,23 @@ FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() { return FDE_VISUALOBJ_Text; } -void CFDE_TxtEdtPage::GetRect(FDE_TEXTEDITPIECE* hVisualObj, CFX_RectF& rt) {} +CFX_RectF CFDE_TxtEdtPage::GetRect(const FDE_TEXTEDITPIECE& hVisualObj) { + return CFX_RectF(); +} int32_t CFDE_TxtEdtPage::GetCharRect(int32_t nIndex, CFX_RectF& rect, bool bBBox) const { ASSERT(m_nRefCount > 0); ASSERT(nIndex >= 0 && nIndex < m_nCharCount); - if (m_nRefCount < 1) { + if (m_nRefCount < 1) return 0; - } - int32_t nCount = m_PieceMassArr.GetSize(); - for (int32_t i = 0; i < nCount; i++) { - const FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(i); - if (nIndex >= pPiece->nStart && - nIndex < (pPiece->nStart + pPiece->nCount)) { - std::vector<CFX_RectF> rectArr; - m_pTextSet->GetCharRects(pPiece, &rectArr, bBBox); - rect = rectArr[nIndex - pPiece->nStart]; - return pPiece->nBidiLevel; + + for (const auto& piece : m_Pieces) { + if (nIndex >= piece.nStart && nIndex < piece.nStart + piece.nCount) { + std::vector<CFX_RectF> rectArr = m_pTextSet->GetCharRects(&piece, bBBox); + rect = rectArr[nIndex - piece.nStart]; + return piece.nBidiLevel; } } ASSERT(0); @@ -81,14 +76,14 @@ int32_t CFDE_TxtEdtPage::GetCharRect(int32_t nIndex, int32_t CFDE_TxtEdtPage::GetCharIndex(const CFX_PointF& fPoint, bool& bBefore) { CFX_PointF ptF = fPoint; NormalizePt2Rect(ptF, m_rtPageContents, kTolerance); - int32_t nCount = m_PieceMassArr.GetSize(); + int32_t nCount = pdfium::CollectionSize<int32_t>(m_Pieces); CFX_RectF rtLine; int32_t nBgn = 0; int32_t nEnd = 0; bool bInLine = false; int32_t i = 0; for (i = 0; i < nCount; i++) { - const FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(i); + const FDE_TEXTEDITPIECE* pPiece = &m_Pieces[i]; if (!bInLine && (pPiece->rtPiece.top <= ptF.y && pPiece->rtPiece.bottom() > ptF.y)) { nBgn = nEnd = i; @@ -107,11 +102,10 @@ int32_t CFDE_TxtEdtPage::GetCharIndex(const CFX_PointF& fPoint, bool& bBefore) { int32_t nCaret = 0; FDE_TEXTEDITPIECE* pPiece = nullptr; for (i = nBgn; i <= nEnd; i++) { - pPiece = m_PieceMassArr.GetPtrAt(i); + pPiece = &m_Pieces[i]; nCaret = m_nPageStart + pPiece->nStart; if (pPiece->rtPiece.Contains(ptF)) { - std::vector<CFX_RectF> rectArr; - m_pTextSet->GetCharRects(pPiece, &rectArr, false); + std::vector<CFX_RectF> rectArr = m_pTextSet->GetCharRects(pPiece, false); int32_t nRtCount = pdfium::CollectionSize<int32_t>(rectArr); for (int32_t j = 0; j < nRtCount; j++) { if (rectArr[j].Contains(ptF)) { @@ -158,17 +152,12 @@ int32_t CFDE_TxtEdtPage::GetDisplayPos(const CFX_RectF& rtClip, CFX_RectF* pBBox) const { pCharPos = FX_Alloc(FXTEXT_CHARPOS, m_nCharCount); int32_t nCharPosCount = 0; - FDE_TEXTEDITPIECE* pPiece = nullptr; - int32_t nVisualObjCount = m_PieceMassArr.GetSize(); FXTEXT_CHARPOS* pos = pCharPos; - CFX_RectF rtObj; - for (int32_t i = 0; i < nVisualObjCount; i++) { - pPiece = m_PieceMassArr.GetPtrAt(i); - m_pTextSet->GetRect(pPiece, rtObj); - if (!rtClip.IntersectWith(rtObj)) { + for (const auto& piece : m_Pieces) { + if (!rtClip.IntersectWith(m_pTextSet->GetRect(piece))) continue; - } - int32_t nCount = m_pTextSet->GetDisplayPos(pPiece, pos, false); + + int32_t nCount = m_pTextSet->GetDisplayPos(piece, pos, false); nCharPosCount += nCount; pos += nCount; } @@ -185,22 +174,19 @@ void CFDE_TxtEdtPage::CalcRangeRectArray( int32_t nStart, int32_t nCount, std::vector<CFX_RectF>* pRectFArr) const { - int32_t nPieceCount = m_PieceMassArr.GetSize(); int32_t nEnd = nStart + nCount - 1; bool bInRange = false; - for (int32_t i = 0; i < nPieceCount; i++) { - FDE_TEXTEDITPIECE* piece = m_PieceMassArr.GetPtrAt(i); + for (const auto& piece : m_Pieces) { if (!bInRange) { - if (nStart >= piece->nStart && nStart < (piece->nStart + piece->nCount)) { - int32_t nRangeEnd = piece->nCount - 1; + if (nStart >= piece.nStart && nStart < piece.nStart + piece.nCount) { + int32_t nRangeEnd = piece.nCount - 1; bool bEnd = false; - if (nEnd >= piece->nStart && nEnd < (piece->nStart + piece->nCount)) { - nRangeEnd = nEnd - piece->nStart; + if (nEnd >= piece.nStart && nEnd < piece.nStart + piece.nCount) { + nRangeEnd = nEnd - piece.nStart; bEnd = true; } - std::vector<CFX_RectF> rcArr; - m_pTextSet->GetCharRects(piece, &rcArr, false); - CFX_RectF rectPiece = rcArr[nStart - piece->nStart]; + std::vector<CFX_RectF> rcArr = m_pTextSet->GetCharRects(&piece, false); + CFX_RectF rectPiece = rcArr[nStart - piece.nStart]; rectPiece.Union(rcArr[nRangeEnd]); pRectFArr->push_back(rectPiece); if (bEnd) @@ -209,15 +195,14 @@ void CFDE_TxtEdtPage::CalcRangeRectArray( bInRange = true; } } else { - if (nEnd >= piece->nStart && nEnd < (piece->nStart + piece->nCount)) { - std::vector<CFX_RectF> rcArr; - m_pTextSet->GetCharRects(piece, &rcArr, false); + if (nEnd >= piece.nStart && nEnd < piece.nStart + piece.nCount) { + std::vector<CFX_RectF> rcArr = m_pTextSet->GetCharRects(&piece, false); CFX_RectF rectPiece = rcArr[0]; - rectPiece.Union(rcArr[nEnd - piece->nStart]); + rectPiece.Union(rcArr[nEnd - piece.nStart]); pRectFArr->push_back(rectPiece); return; } - pRectFArr->push_back(piece->rtPiece); + pRectFArr->push_back(piece.rtPiece); } } } @@ -288,7 +273,7 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, if (!m_pTextSet) m_pTextSet = pdfium::MakeUnique<CFDE_TxtEdtTextSet>(this); - m_PieceMassArr.RemoveAll(true); + m_Pieces.clear(); uint32_t dwBreakStatus = FX_TXTBREAK_None; int32_t nPieceStart = 0; @@ -362,7 +347,7 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, m_rtPageContents.Union(TxtEdtPiece.rtPiece); } nPieceStart += TxtEdtPiece.nCount; - m_PieceMassArr.Add(TxtEdtPiece); + m_Pieces.push_back(TxtEdtPiece); for (int32_t k = 0; k < TxtEdtPiece.nCount; k++) { CFX_Char* ptc = pPiece->GetCharPtr(k); m_CharWidths[TxtEdtPiece.nStart + k] = ptc->m_iCharWidth; @@ -393,19 +378,15 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, } } FX_FLOAT fOffset = m_rtPageContents.left - fDelta; - int32_t nCount = m_PieceMassArr.GetSize(); - for (int32_t i = 0; i < nCount; i++) { - FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(i); - pPiece->rtPiece.Offset(-fOffset, 0.0f); - } + for (auto& piece : m_Pieces) + piece.rtPiece.Offset(-fOffset, 0.0f); + m_rtPageContents.Offset(-fOffset, 0.0f); } if (m_pEditEngine->GetEditParams()->dwLayoutStyles & FDE_TEXTEDITLAYOUT_LastLineHeight) { m_rtPageContents.height -= pParams->fLineSpace - pParams->fFontSize; - int32_t nCount = m_PieceMassArr.GetSize(); - FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(nCount - 1); - pPiece->rtPiece.height = pParams->fFontSize; + m_Pieces.back().rtPiece.height = pParams->fFontSize; } m_nRefCount = 1; m_bLoaded = true; @@ -418,7 +399,7 @@ void CFDE_TxtEdtPage::UnloadPage(const CFX_RectF* pClipBox) { if (m_nRefCount != 0) return; - m_PieceMassArr.RemoveAll(false); + m_Pieces.clear(); m_pTextSet.reset(); m_CharWidths.clear(); if (m_pBgnParag) { @@ -437,7 +418,7 @@ const CFX_RectF& CFDE_TxtEdtPage::GetContentsBox() { } FX_POSITION CFDE_TxtEdtPage::GetFirstPosition() { - if (m_PieceMassArr.GetSize() < 1) + if (m_Pieces.empty()) return nullptr; return (FX_POSITION)1; } @@ -450,20 +431,20 @@ FDE_TEXTEDITPIECE* CFDE_TxtEdtPage::GetNext(FX_POSITION& pos, } int32_t nPos = (int32_t)(uintptr_t)pos; pVisualSet = m_pTextSet.get(); - if (nPos + 1 > m_PieceMassArr.GetSize()) { + if (nPos + 1 > pdfium::CollectionSize<int32_t>(m_Pieces)) pos = nullptr; - } else { + else pos = (FX_POSITION)(uintptr_t)(nPos + 1); - } - return m_PieceMassArr.GetPtrAt(nPos - 1); + + return &m_Pieces[nPos - 1]; } FX_WCHAR CFDE_TxtEdtPage::GetChar(const FDE_TEXTEDITPIECE* pIdentity, int32_t index) const { int32_t nIndex = m_nPageStart + pIdentity->nStart + index; - if (nIndex != m_pIter->GetAt()) { + if (nIndex != m_pIter->GetAt()) m_pIter->SetAt(nIndex); - } + FX_WCHAR wChar = m_pIter->GetChar(); m_pIter->Next(); return wChar; diff --git a/xfa/fde/cfde_txtedtpage.h b/xfa/fde/cfde_txtedtpage.h index 57ade45bbc..63ec7e7cf3 100644 --- a/xfa/fde/cfde_txtedtpage.h +++ b/xfa/fde/cfde_txtedtpage.h @@ -7,6 +7,7 @@ #ifndef XFA_FDE_CFDE_TXTEDTPAGE_H_ #define XFA_FDE_CFDE_TXTEDTPAGE_H_ +#include <deque> #include <memory> #include <vector> @@ -44,7 +45,7 @@ class CFDE_TxtEdtPage : public IFDE_TxtEdtPage { // IFDE_VisualSet: FDE_VISUALOBJTYPE GetType() override; - void GetRect(FDE_TEXTEDITPIECE* pPiece, CFX_RectF& rt) override; + CFX_RectF GetRect(const FDE_TEXTEDITPIECE& pPiece) override; // IFDE_CanvasSet: FX_POSITION GetFirstPosition() override; @@ -65,7 +66,7 @@ class CFDE_TxtEdtPage : public IFDE_TxtEdtPage { std::unique_ptr<IFX_CharIter> m_pIter; std::unique_ptr<CFDE_TxtEdtTextSet> m_pTextSet; CFDE_TxtEdtEngine* const m_pEditEngine; - CFX_MassArrayTemplate<FDE_TEXTEDITPIECE> m_PieceMassArr; + std::deque<FDE_TEXTEDITPIECE> m_Pieces; CFDE_TxtEdtParag* m_pBgnParag; CFDE_TxtEdtParag* m_pEndParag; int32_t m_nRefCount; diff --git a/xfa/fde/cfde_txtedttextset.cpp b/xfa/fde/cfde_txtedttextset.cpp index a885ad4508..8d32f75ff3 100644 --- a/xfa/fde/cfde_txtedttextset.cpp +++ b/xfa/fde/cfde_txtedttextset.cpp @@ -19,8 +19,8 @@ FDE_VISUALOBJTYPE CFDE_TxtEdtTextSet::GetType() { return FDE_VISUALOBJ_Text; } -void CFDE_TxtEdtTextSet::GetRect(FDE_TEXTEDITPIECE* pPiece, CFX_RectF& rt) { - rt = pPiece->rtPiece; +CFX_RectF CFDE_TxtEdtTextSet::GetRect(const FDE_TEXTEDITPIECE& pPiece) { + return pPiece.rtPiece; } int32_t CFDE_TxtEdtTextSet::GetString(FDE_TEXTEDITPIECE* pPiece, @@ -45,14 +45,11 @@ FX_ARGB CFDE_TxtEdtTextSet::GetFontColor() { return m_pPage->GetEngine()->GetEditParams()->dwFontColor; } -int32_t CFDE_TxtEdtTextSet::GetDisplayPos(FDE_TEXTEDITPIECE* pPiece, +int32_t CFDE_TxtEdtTextSet::GetDisplayPos(const FDE_TEXTEDITPIECE& piece, FXTEXT_CHARPOS* pCharPos, bool bCharCode, CFX_WideString* pWSForms) { - if (!pPiece) - return 0; - - int32_t nLength = pPiece->nCount; + int32_t nLength = piece.nCount; if (nLength < 1) return 0; @@ -63,42 +60,37 @@ int32_t CFDE_TxtEdtTextSet::GetDisplayPos(FDE_TEXTEDITPIECE* pPiece, uint32_t dwLayoutStyle = pBreak->GetLayoutStyles(); FX_TXTRUN tr; tr.pAccess = m_pPage; - tr.pIdentity = pPiece; + tr.pIdentity = &piece; tr.iLength = nLength; tr.pFont = pTextParams->pFont; tr.fFontSize = pTextParams->fFontSize; tr.dwStyles = dwLayoutStyle; tr.iCharRotation = pTextParams->nCharRotation; - tr.dwCharStyles = pPiece->dwCharStyles; - tr.pRect = &(pPiece->rtPiece); + tr.dwCharStyles = piece.dwCharStyles; + tr.pRect = &piece.rtPiece; tr.wLineBreakChar = pTextParams->wLineBreakChar; return pBreak->GetDisplayPos(&tr, pCharPos, bCharCode, pWSForms); } -int32_t CFDE_TxtEdtTextSet::GetCharRects(const FDE_TEXTEDITPIECE* pPiece, - std::vector<CFX_RectF>* rtArray, - bool bBBox) { - if (!pPiece) - return 0; - - CFDE_TxtEdtEngine* pEngine = - static_cast<CFDE_TxtEdtEngine*>(m_pPage->GetEngine()); - int32_t nLength = pPiece->nCount; - if (nLength < 1) - return 0; +std::vector<CFX_RectF> CFDE_TxtEdtTextSet::GetCharRects( + const FDE_TEXTEDITPIECE* pPiece, + bool bBBox) { + if (!pPiece || pPiece->nCount < 1) + return std::vector<CFX_RectF>(); + auto pEngine = static_cast<CFDE_TxtEdtEngine*>(m_pPage->GetEngine()); const FDE_TXTEDTPARAMS* pTextParams = pEngine->GetEditParams(); uint32_t dwLayoutStyle = pEngine->GetTextBreak()->GetLayoutStyles(); FX_TXTRUN tr; tr.pAccess = m_pPage; tr.pIdentity = pPiece; - tr.iLength = nLength; + tr.iLength = pPiece->nCount; tr.pFont = pTextParams->pFont; tr.fFontSize = pTextParams->fFontSize; tr.dwStyles = dwLayoutStyle; tr.iCharRotation = pTextParams->nCharRotation; tr.dwCharStyles = pPiece->dwCharStyles; - tr.pRect = &(pPiece->rtPiece); + tr.pRect = &pPiece->rtPiece; tr.wLineBreakChar = pTextParams->wLineBreakChar; - return pEngine->GetTextBreak()->GetCharRects(&tr, rtArray, bBBox); + return pEngine->GetTextBreak()->GetCharRects(&tr, bBBox); } diff --git a/xfa/fde/cfde_txtedttextset.h b/xfa/fde/cfde_txtedttextset.h index 561419affe..8ab6578793 100644 --- a/xfa/fde/cfde_txtedttextset.h +++ b/xfa/fde/cfde_txtedttextset.h @@ -20,20 +20,19 @@ class CFDE_TxtEdtTextSet : public IFDE_TextSet { // IFDE_VisualSet FDE_VISUALOBJTYPE GetType() override; - void GetRect(FDE_TEXTEDITPIECE* hVisualObj, CFX_RectF& rt) override; + CFX_RectF GetRect(const FDE_TEXTEDITPIECE& hVisualObj) override; // IFDE_TextSet int32_t GetString(FDE_TEXTEDITPIECE* pPiece, CFX_WideString& wsText) override; CFX_RetainPtr<CFGAS_GEFont> GetFont() override; FX_FLOAT GetFontSize() override; FX_ARGB GetFontColor() override; - int32_t GetDisplayPos(FDE_TEXTEDITPIECE* pPiece, + int32_t GetDisplayPos(const FDE_TEXTEDITPIECE& pPiece, FXTEXT_CHARPOS* pCharPos, bool bCharCode = false, CFX_WideString* pWSForms = nullptr) override; - int32_t GetCharRects(const FDE_TEXTEDITPIECE* pPiece, - std::vector<CFX_RectF>* rtArray, - bool bBBox) override; + std::vector<CFX_RectF> GetCharRects(const FDE_TEXTEDITPIECE* pPiece, + bool bBBox) override; private: CFDE_TxtEdtPage* const m_pPage; diff --git a/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp index c0fb926c36..b6a8f7edd0 100644 --- a/xfa/fde/fde_render.cpp +++ b/xfa/fde/fde_render.cpp @@ -61,7 +61,6 @@ FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) { rm.TransformRect(rtDocClip); IFDE_VisualSet* pVisualSet; FDE_TEXTEDITPIECE* pPiece; - CFX_RectF rtObj; int32_t iCount = 0; while (true) { pPiece = m_pIterator->GetNext(pVisualSet); @@ -69,9 +68,7 @@ FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) { eStatus = FDE_RENDERSTATUS_Done; break; } - rtObj.Empty(); - pVisualSet->GetRect(pPiece, rtObj); - if (!rtDocClip.IntersectWith(rtObj)) + if (!rtDocClip.IntersectWith(pVisualSet->GetRect(*pPiece))) continue; switch (pVisualSet->GetType()) { @@ -111,7 +108,7 @@ void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet, if (!pFont) return; - int32_t iCount = pTextSet->GetDisplayPos(pText, nullptr, false); + int32_t iCount = pTextSet->GetDisplayPos(*pText, nullptr, false); if (iCount < 1) return; @@ -121,7 +118,7 @@ void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet, if (m_CharPos.size() < static_cast<size_t>(iCount)) m_CharPos.resize(iCount, FXTEXT_CHARPOS()); - iCount = pTextSet->GetDisplayPos(pText, m_CharPos.data(), false); + iCount = pTextSet->GetDisplayPos(*pText, m_CharPos.data(), false); FX_FLOAT fFontSize = pTextSet->GetFontSize(); FX_ARGB dwColor = pTextSet->GetFontColor(); m_pBrush->SetColor(dwColor); diff --git a/xfa/fde/fde_visualset.h b/xfa/fde/fde_visualset.h index 3260caee79..5cf02cde9c 100644 --- a/xfa/fde/fde_visualset.h +++ b/xfa/fde/fde_visualset.h @@ -26,6 +26,7 @@ enum FDE_VISUALOBJTYPE { struct FDE_TEXTEDITPIECE { FDE_TEXTEDITPIECE(); + FDE_TEXTEDITPIECE(const FDE_TEXTEDITPIECE& that); ~FDE_TEXTEDITPIECE(); int32_t nStart; @@ -35,13 +36,15 @@ struct FDE_TEXTEDITPIECE { uint32_t dwCharStyles; }; inline FDE_TEXTEDITPIECE::FDE_TEXTEDITPIECE() = default; +inline FDE_TEXTEDITPIECE::FDE_TEXTEDITPIECE(const FDE_TEXTEDITPIECE& that) = + default; inline FDE_TEXTEDITPIECE::~FDE_TEXTEDITPIECE() = default; class IFDE_VisualSet { public: virtual ~IFDE_VisualSet() {} virtual FDE_VISUALOBJTYPE GetType() = 0; - virtual void GetRect(FDE_TEXTEDITPIECE* hVisualObj, CFX_RectF& rt) = 0; + virtual CFX_RectF GetRect(const FDE_TEXTEDITPIECE& hVisualObj) = 0; }; class IFDE_CanvasSet : public IFDE_VisualSet { @@ -58,13 +61,12 @@ class IFDE_TextSet : public IFDE_VisualSet { virtual CFX_RetainPtr<CFGAS_GEFont> GetFont() = 0; virtual FX_FLOAT GetFontSize() = 0; virtual FX_ARGB GetFontColor() = 0; - virtual int32_t GetDisplayPos(FDE_TEXTEDITPIECE* hText, + virtual int32_t GetDisplayPos(const FDE_TEXTEDITPIECE& hText, FXTEXT_CHARPOS* pCharPos, bool bCharCode = false, CFX_WideString* pWSForms = nullptr) = 0; - virtual int32_t GetCharRects(const FDE_TEXTEDITPIECE* hText, - std::vector<CFX_RectF>* rtArray, - bool bbox) = 0; + virtual std::vector<CFX_RectF> GetCharRects(const FDE_TEXTEDITPIECE* hText, + bool bbox) = 0; }; #endif // XFA_FDE_FDE_VISUALSET_H_ diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp index 7e9ff08ffd..421876b48d 100644 --- a/xfa/fde/tto/fde_textout.cpp +++ b/xfa/fde/tto/fde_textout.cpp @@ -745,8 +745,8 @@ int32_t CFDE_TextOut::GetDisplayPos(FDE_TTOPIECE* pPiece) { int32_t CFDE_TextOut::GetCharRects(const FDE_TTOPIECE* pPiece) { FX_TXTRUN tr = ToTextRun(pPiece); - m_rectArray.clear(); - return m_pTxtBreak->GetCharRects(&tr, &m_rectArray); + m_rectArray = m_pTxtBreak->GetCharRects(&tr); + return pdfium::CollectionSize<int32_t>(m_rectArray); } FX_TXTRUN CFDE_TextOut::ToTextRun(const FDE_TTOPIECE* pPiece) { |