summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fde/cfde_txtedtbuf.cpp9
-rw-r--r--xfa/fde/cfde_txtedtbuf.h4
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp19
-rw-r--r--xfa/fde/cfde_txtedtengine.h6
-rw-r--r--xfa/fde/cfde_txtedtpage.cpp25
-rw-r--r--xfa/fde/cfde_txtedtpage.h9
-rw-r--r--xfa/fde/css/fde_cssstyleselector.cpp81
-rw-r--r--xfa/fde/css/fde_cssstyleselector.h20
-rw-r--r--xfa/fde/css/fde_cssstylesheet.cpp23
-rw-r--r--xfa/fde/css/fde_cssstylesheet.h3
-rw-r--r--xfa/fde/fde_gedevice.cpp2
-rw-r--r--xfa/fde/fde_gedevice.h3
-rw-r--r--xfa/fde/fde_render.cpp21
-rw-r--r--xfa/fde/fde_render.h4
-rw-r--r--xfa/fde/tto/fde_textout.cpp134
-rw-r--r--xfa/fde/tto/fde_textout.h16
-rw-r--r--xfa/fgas/crt/fgas_memory.cpp23
-rw-r--r--xfa/fgas/crt/fgas_memory.h8
-rw-r--r--xfa/fxfa/app/xfa_textlayout.cpp10
19 files changed, 222 insertions, 198 deletions
diff --git a/xfa/fde/cfde_txtedtbuf.cpp b/xfa/fde/cfde_txtedtbuf.cpp
index 7af5a1892b..58f1822661 100644
--- a/xfa/fde/cfde_txtedtbuf.cpp
+++ b/xfa/fde/cfde_txtedtbuf.cpp
@@ -16,17 +16,12 @@ const int kDefaultChunkCount = 2;
} // namespace
CFDE_TxtEdtBuf::CFDE_TxtEdtBuf()
- : m_nChunkSize(kDefaultChunkSize),
- m_nTotal(0),
- m_bChanged(FALSE),
- m_pAllocator(nullptr) {
- ASSERT(m_nChunkSize);
+ : m_nChunkSize(kDefaultChunkSize), m_nTotal(0), m_bChanged(FALSE) {
ResetChunkBuffer(kDefaultChunkCount, m_nChunkSize);
}
CFDE_TxtEdtBuf::~CFDE_TxtEdtBuf() {
Clear(TRUE);
- delete m_pAllocator;
m_Chunks.RemoveAll();
}
@@ -271,8 +266,6 @@ void CFDE_TxtEdtBuf::ResetChunkBuffer(int32_t nDefChunkCount,
int32_t nChunkSize) {
ASSERT(nChunkSize);
ASSERT(nDefChunkCount);
- delete m_pAllocator;
- m_pAllocator = nullptr;
m_Chunks.RemoveAll();
m_nChunkSize = nChunkSize;
int32_t nChunkLength =
diff --git a/xfa/fde/cfde_txtedtbuf.h b/xfa/fde/cfde_txtedtbuf.h
index e871ed9aed..baf67cef00 100644
--- a/xfa/fde/cfde_txtedtbuf.h
+++ b/xfa/fde/cfde_txtedtbuf.h
@@ -7,6 +7,8 @@
#ifndef XFA_FDE_CFDE_TXTEDTBUF_H_
#define XFA_FDE_CFDE_TXTEDTBUF_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_basic.h"
#include "core/fxcrt/include/fx_system.h"
@@ -55,7 +57,7 @@ class CFDE_TxtEdtBuf {
int32_t m_nTotal;
FX_BOOL m_bChanged;
CFX_ArrayTemplate<FDE_CHUNKHEADER*> m_Chunks;
- IFX_MemoryAllocator* m_pAllocator;
+ std::unique_ptr<IFX_MemoryAllocator> m_pAllocator;
};
#endif // XFA_FDE_CFDE_TXTEDTBUF_H_
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index 8c950f5ab3..e7da157178 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -50,7 +50,7 @@ FDE_TXTEDT_TEXTCHANGE_INFO::FDE_TXTEDT_TEXTCHANGE_INFO() {}
FDE_TXTEDT_TEXTCHANGE_INFO::~FDE_TXTEDT_TEXTCHANGE_INFO() {}
CFDE_TxtEdtEngine::CFDE_TxtEdtEngine()
- : m_pTextBreak(nullptr),
+ : m_pTxtBuf(new CFDE_TxtEdtBuf()),
m_nPageLineCount(20),
m_nLineCount(0),
m_nAnchorPos(-1),
@@ -67,13 +67,10 @@ CFDE_TxtEdtEngine::CFDE_TxtEdtEngine()
m_bAutoLineEnd(TRUE),
m_wLineEnd(kUnicodeParagraphSeparator) {
FXSYS_memset(&m_rtCaret, 0, sizeof(CFX_RectF));
- m_pTxtBuf = new CFDE_TxtEdtBuf();
m_bAutoLineEnd = (m_Param.nLineEnd == FDE_TXTEDIT_LINEEND_Auto);
}
CFDE_TxtEdtEngine::~CFDE_TxtEdtEngine() {
- delete m_pTxtBuf;
- delete m_pTextBreak;
RemoveAllParags();
RemoveAllPages();
m_Param.pEventSink = nullptr;
@@ -82,7 +79,7 @@ CFDE_TxtEdtEngine::~CFDE_TxtEdtEngine() {
void CFDE_TxtEdtEngine::SetEditParams(const FDE_TXTEDTPARAMS& params) {
if (!m_pTextBreak)
- m_pTextBreak = new CFX_TxtBreak(FX_TXTBREAKPOLICY_None);
+ m_pTextBreak.reset(new CFX_TxtBreak(FX_TXTBREAKPOLICY_None));
FXSYS_memcpy(&m_Param, &params, sizeof(FDE_TXTEDTPARAMS));
m_wLineEnd = params.wLineBreakChar;
@@ -727,7 +724,7 @@ FX_BOOL CFDE_TxtEdtEngine::Optimize(IFX_Pause* pPause) {
}
CFDE_TxtEdtBuf* CFDE_TxtEdtEngine::GetTextBuf() const {
- return m_pTxtBuf;
+ return m_pTxtBuf.get();
}
int32_t CFDE_TxtEdtEngine::GetTextBufLength() const {
@@ -735,7 +732,7 @@ int32_t CFDE_TxtEdtEngine::GetTextBufLength() const {
}
CFX_TxtBreak* CFDE_TxtEdtEngine::GetTextBreak() const {
- return m_pTextBreak;
+ return m_pTextBreak.get();
}
int32_t CFDE_TxtEdtEngine::GetLineCount() const {
@@ -755,10 +752,9 @@ CFDE_TxtEdtParag* CFDE_TxtEdtEngine::GetParag(int32_t nParagIndex) const {
}
IFX_CharIter* CFDE_TxtEdtEngine::CreateCharIter() {
- if (!m_pTxtBuf) {
+ if (!m_pTxtBuf)
return nullptr;
- }
- return new CFDE_TxtEdtBufIter(static_cast<CFDE_TxtEdtBuf*>(m_pTxtBuf));
+ return new CFDE_TxtEdtBufIter(m_pTxtBuf.get());
}
int32_t CFDE_TxtEdtEngine::Line2Parag(int32_t nStartParag,
@@ -986,8 +982,7 @@ void CFDE_TxtEdtEngine::RebuildParagraphs() {
FX_WCHAR wChar = L' ';
int32_t nParagStart = 0;
int32_t nIndex = 0;
- std::unique_ptr<IFX_CharIter> pIter(
- new CFDE_TxtEdtBufIter(static_cast<CFDE_TxtEdtBuf*>(m_pTxtBuf)));
+ std::unique_ptr<IFX_CharIter> pIter(new CFDE_TxtEdtBufIter(m_pTxtBuf.get()));
pIter->SetAt(0);
do {
wChar = pIter->GetChar();
diff --git a/xfa/fde/cfde_txtedtengine.h b/xfa/fde/cfde_txtedtengine.h
index 4bafce6864..974913936f 100644
--- a/xfa/fde/cfde_txtedtengine.h
+++ b/xfa/fde/cfde_txtedtengine.h
@@ -7,6 +7,8 @@
#ifndef XFA_FDE_CFDE_TXTEDTENGINE_H_
#define XFA_FDE_CFDE_TXTEDTENGINE_H_
+#include <memory>
+
#include "xfa/fde/ifde_txtedtengine.h"
class CFDE_TxtEdtBuf;
@@ -150,8 +152,8 @@ class CFDE_TxtEdtEngine {
FX_BOOL IsSelect();
void DeleteSelect();
- CFDE_TxtEdtBuf* m_pTxtBuf;
- CFX_TxtBreak* m_pTextBreak;
+ std::unique_ptr<CFDE_TxtEdtBuf> m_pTxtBuf;
+ std::unique_ptr<CFX_TxtBreak> m_pTextBreak;
FDE_TXTEDTPARAMS m_Param;
CFX_ArrayTemplate<IFDE_TxtEdtPage*> m_PagePtrArray;
CFX_ArrayTemplate<CFDE_TxtEdtParag*> m_ParagPtrArray;
diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp
index a31997fc65..21420998d4 100644
--- a/xfa/fde/cfde_txtedtpage.cpp
+++ b/xfa/fde/cfde_txtedtpage.cpp
@@ -29,7 +29,7 @@ IFDE_TxtEdtPage* IFDE_TxtEdtPage::Create(CFDE_TxtEdtEngine* pEngine,
}
CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex)
- : m_pTextSet(nullptr),
+ : m_pEditEngine(pEngine),
m_PieceMassArr(100),
m_pBgnParag(nullptr),
m_pEndParag(nullptr),
@@ -37,19 +37,15 @@ CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex)
m_nPageStart(-1),
m_nCharCount(0),
m_nPageIndex(nPageIndex),
- m_bLoaded(FALSE),
- m_pCharWidth(nullptr) {
+ m_bLoaded(FALSE) {
FXSYS_memset(&m_rtPage, 0, sizeof(CFX_RectF));
FXSYS_memset(&m_rtPageMargin, 0, sizeof(CFX_RectF));
FXSYS_memset(&m_rtPageContents, 0, sizeof(CFX_RectF));
FXSYS_memset(&m_rtPageCanvas, 0, sizeof(CFX_RectF));
- m_pEditEngine = static_cast<CFDE_TxtEdtEngine*>(pEngine);
}
CFDE_TxtEdtPage::~CFDE_TxtEdtPage() {
m_PieceMassArr.RemoveAll(TRUE);
- delete m_pTextSet;
- delete[] m_pCharWidth;
}
CFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const {
@@ -308,14 +304,13 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox,
(bVertial && bLineReserve) ? (-pParams->fLineSpace) : pParams->fLineSpace;
FX_FLOAT fLinePos = fLineStart;
if (!m_pTextSet)
- m_pTextSet = new CFDE_TxtEdtTextSet(this);
+ m_pTextSet.reset(new CFDE_TxtEdtTextSet(this));
m_PieceMassArr.RemoveAll(TRUE);
uint32_t dwBreakStatus = FX_TXTBREAK_None;
int32_t nPieceStart = 0;
- delete[] m_pCharWidth;
- m_pCharWidth = new int32_t[nPageEnd - nPageStart + 1];
+ m_CharWidths.resize(nPageEnd - nPageStart + 1, 0);
pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak);
pBreak->ClearBreakPieces();
m_nPageStart = nPageStart;
@@ -394,7 +389,7 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox,
m_PieceMassArr.Add(TxtEdtPiece);
for (int32_t k = 0; k < TxtEdtPiece.nCount; k++) {
CFX_Char* ptc = pPiece->GetCharPtr(k);
- m_pCharWidth[TxtEdtPiece.nStart + k] = ptc->m_iCharWidth;
+ m_CharWidths[TxtEdtPiece.nStart + k] = ptc->m_iCharWidth;
}
}
fLinePos += fLineStep;
@@ -448,10 +443,8 @@ void CFDE_TxtEdtPage::UnloadPage(const CFX_RectF* pClipBox) {
return;
m_PieceMassArr.RemoveAll(FALSE);
- delete m_pTextSet;
- m_pTextSet = nullptr;
- delete[] m_pCharWidth;
- m_pCharWidth = nullptr;
+ m_pTextSet.reset();
+ m_CharWidths.clear();
if (m_pBgnParag) {
m_pBgnParag->UnloadParag();
m_pBgnParag = nullptr;
@@ -480,7 +473,7 @@ FDE_TEXTEDITPIECE* CFDE_TxtEdtPage::GetNext(FX_POSITION& pos,
return nullptr;
}
int32_t nPos = (int32_t)(uintptr_t)pos;
- pVisualSet = m_pTextSet;
+ pVisualSet = m_pTextSet.get();
if (nPos + 1 > m_PieceMassArr.GetSize()) {
pos = nullptr;
} else {
@@ -502,7 +495,7 @@ FX_WCHAR CFDE_TxtEdtPage::GetChar(const FDE_TEXTEDITPIECE* pIdentity,
int32_t CFDE_TxtEdtPage::GetWidth(const FDE_TEXTEDITPIECE* pIdentity,
int32_t index) const {
- int32_t nWidth = m_pCharWidth[pIdentity->nStart + index];
+ int32_t nWidth = m_CharWidths[pIdentity->nStart + index];
return nWidth;
}
diff --git a/xfa/fde/cfde_txtedtpage.h b/xfa/fde/cfde_txtedtpage.h
index 9adaee1fdc..777f82929e 100644
--- a/xfa/fde/cfde_txtedtpage.h
+++ b/xfa/fde/cfde_txtedtpage.h
@@ -7,6 +7,9 @@
#ifndef XFA_FDE_CFDE_TXTEDTPAGE_H_
#define XFA_FDE_CFDE_TXTEDTPAGE_H_
+#include <memory>
+#include <vector>
+
#include "xfa/fde/ifde_txtedtpage.h"
#include "xfa/fde/ifx_chariter.h"
@@ -60,8 +63,8 @@ class CFDE_TxtEdtPage : public IFDE_TxtEdtPage {
FX_FLOAT fTolerance) const;
std::unique_ptr<IFX_CharIter> m_pIter;
- CFDE_TxtEdtTextSet* m_pTextSet;
- CFDE_TxtEdtEngine* m_pEditEngine;
+ std::unique_ptr<CFDE_TxtEdtTextSet> m_pTextSet;
+ CFDE_TxtEdtEngine* const m_pEditEngine;
CFX_MassArrayTemplate<FDE_TEXTEDITPIECE> m_PieceMassArr;
CFDE_TxtEdtParag* m_pBgnParag;
CFDE_TxtEdtParag* m_pEndParag;
@@ -74,7 +77,7 @@ class CFDE_TxtEdtPage : public IFDE_TxtEdtPage {
CFX_RectF m_rtPageMargin;
CFX_RectF m_rtPageContents;
CFX_RectF m_rtPageCanvas;
- int32_t* m_pCharWidth;
+ std::vector<int32_t> m_CharWidths;
};
#endif // XFA_FDE_CFDE_TXTEDTPAGE_H_
diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp
index 6a1a0b0c56..b68ace8dce 100644
--- a/xfa/fde/css/fde_cssstyleselector.cpp
+++ b/xfa/fde/css/fde_cssstyleselector.cpp
@@ -27,6 +27,7 @@ int32_t CFDE_CSSCounterStyle::FindIndex(const FX_WCHAR* pszIdentifier) {
}
return -1;
}
+
void CFDE_CSSCounterStyle::DoUpdateIndex(IFDE_CSSValueList* pList) {
if (!pList)
return;
@@ -105,13 +106,8 @@ FDE_CSSRuleData::FDE_CSSRuleData(CFDE_CSSSelector* pSel,
}
}
-CFDE_CSSStyleSelector::CFDE_CSSStyleSelector()
- : m_pFontMgr(nullptr),
- m_fDefFontSize(12.0f),
- m_pRuleDataStore(nullptr),
- m_pInlineStyleStore(nullptr),
- m_pFixedStyleStore(nullptr),
- m_pAccelerator(nullptr) {
+CFDE_CSSStyleSelector::CFDE_CSSStyleSelector(IFGAS_FontMgr* pFontMgr)
+ : m_pFontMgr(pFontMgr), m_fDefFontSize(12.0f) {
m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_High] = FDE_CSSSTYLESHEETGROUP_Author;
m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Mid] = FDE_CSSSTYLESHEETGROUP_User;
m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Low] =
@@ -120,14 +116,8 @@ CFDE_CSSStyleSelector::CFDE_CSSStyleSelector()
CFDE_CSSStyleSelector::~CFDE_CSSStyleSelector() {
Reset();
- delete m_pInlineStyleStore;
- delete m_pFixedStyleStore;
- delete m_pAccelerator;
}
-void CFDE_CSSStyleSelector::SetFontMgr(IFGAS_FontMgr* pFontMgr) {
- m_pFontMgr = pFontMgr;
-}
void CFDE_CSSStyleSelector::SetDefFontSize(FX_FLOAT fFontSize) {
ASSERT(fFontSize > 0);
m_fDefFontSize = fFontSize;
@@ -135,9 +125,9 @@ void CFDE_CSSStyleSelector::SetDefFontSize(FX_FLOAT fFontSize) {
CFDE_CSSAccelerator* CFDE_CSSStyleSelector::InitAccelerator() {
if (!m_pAccelerator)
- m_pAccelerator = new CFDE_CSSAccelerator;
+ m_pAccelerator.reset(new CFDE_CSSAccelerator);
m_pAccelerator->Clear();
- return m_pAccelerator;
+ return m_pAccelerator.get();
}
IFDE_CSSComputedStyle* CFDE_CSSStyleSelector::CreateComputedStyle(
@@ -146,8 +136,8 @@ IFDE_CSSComputedStyle* CFDE_CSSStyleSelector::CreateComputedStyle(
m_pFixedStyleStore = IFX_MemoryAllocator::Create(
FX_ALLOCTYPE_Fixed, 16, sizeof(CFDE_CSSComputedStyle));
}
- CFDE_CSSComputedStyle* pStyle = FXTARGET_NewWith(m_pFixedStyleStore)
- CFDE_CSSComputedStyle(m_pFixedStyleStore);
+ CFDE_CSSComputedStyle* pStyle = FXTARGET_NewWith(m_pFixedStyleStore.get())
+ CFDE_CSSComputedStyle(m_pFixedStyleStore.get());
if (pParentStyle) {
pStyle->m_InheritedData =
static_cast<CFDE_CSSComputedStyle*>(pParentStyle)->m_InheritedData;
@@ -157,6 +147,7 @@ IFDE_CSSComputedStyle* CFDE_CSSStyleSelector::CreateComputedStyle(
pStyle->m_NonInheritedData.Reset();
return pStyle;
}
+
FX_BOOL CFDE_CSSStyleSelector::SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType,
IFDE_CSSStyleSheet* pSheet) {
ASSERT(eType < FDE_CSSSTYLESHEETGROUP_MAX);
@@ -166,6 +157,7 @@ FX_BOOL CFDE_CSSStyleSelector::SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType,
dest.Add(pSheet);
return TRUE;
}
+
FX_BOOL CFDE_CSSStyleSelector::SetStyleSheets(
FDE_CSSSTYLESHEETGROUP eType,
const CFDE_CSSStyleSheetArray* pArray) {
@@ -177,27 +169,30 @@ FX_BOOL CFDE_CSSStyleSelector::SetStyleSheets(
dest.RemoveAt(0, dest.GetSize());
return TRUE;
}
+
void CFDE_CSSStyleSelector::SetStylePriority(
FDE_CSSSTYLESHEETGROUP eType,
FDE_CSSSTYLESHEETPRIORITY ePriority) {
m_ePriorities[ePriority] = eType;
}
+
void CFDE_CSSStyleSelector::UpdateStyleIndex(uint32_t dwMediaList) {
Reset();
m_pRuleDataStore = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 1024, 0);
for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) {
CFDE_CSSRuleCollection& rules = m_RuleCollection[iGroup];
- rules.m_pStaticStore = m_pRuleDataStore;
+ rules.m_pStaticStore = m_pRuleDataStore.get();
rules.AddRulesFrom(m_SheetGroups[iGroup], dwMediaList, m_pFontMgr);
}
}
+
void CFDE_CSSStyleSelector::Reset() {
for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) {
m_RuleCollection[iGroup].Clear();
}
- delete m_pRuleDataStore;
- m_pRuleDataStore = nullptr;
+ m_pRuleDataStore.reset();
}
+
int32_t CFDE_CSSStyleSelector::MatchDeclarations(
CXFA_CSSTagProvider* pTag,
CFDE_CSSDeclarationArray& matchedDecls,
@@ -325,16 +320,18 @@ void CFDE_CSSStyleSelector::ComputeStyle(
uint32_t dwAttriHash = FX_HashCode_GetW(wsAttri.AsStringC(), true);
if (dwAttriHash == s_dwStyleHash) {
if (!pDecl)
- pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration;
+ pDecl =
+ FXTARGET_NewWith(m_pInlineStyleStore.get()) CFDE_CSSDeclaration;
AppendInlineStyle(pDecl, wsValue.c_str(), wsValue.GetLength());
} else if (dwAttriHash == s_dwAlignHash) {
if (!pDecl)
- pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration;
+ pDecl =
+ FXTARGET_NewWith(m_pInlineStyleStore.get()) CFDE_CSSDeclaration;
FDE_CSSPROPERTYARGS args;
args.pStringCache = nullptr;
- args.pStaticStore = m_pInlineStyleStore;
+ args.pStaticStore = m_pInlineStyleStore.get();
args.pProperty = FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY_TextAlign);
pDecl->AddProperty(&args, wsValue.c_str(), wsValue.GetLength());
}
@@ -431,6 +428,7 @@ void CFDE_CSSStyleSelector::ApplyDeclarations(
}
}
}
+
void CFDE_CSSStyleSelector::AppendInlineStyle(CFDE_CSSDeclaration* pDecl,
const FX_WCHAR* psz,
int32_t iLen) {
@@ -443,7 +441,7 @@ void CFDE_CSSStyleSelector::AppendInlineStyle(CFDE_CSSDeclaration* pDecl,
const FX_WCHAR* psz2;
FDE_CSSPROPERTYARGS args;
args.pStringCache = nullptr;
- args.pStaticStore = m_pInlineStyleStore;
+ args.pStaticStore = m_pInlineStyleStore.get();
args.pProperty = nullptr;
CFX_WideString wsName;
while (1) {
@@ -1016,6 +1014,7 @@ void CFDE_CSSStyleSelector::ApplyProperty(
ASSERT(FALSE);
}
}
+
FX_FLOAT CFDE_CSSStyleSelector::ApplyNumber(FDE_CSSPRIMITIVETYPE eUnit,
FX_FLOAT fValue,
FX_FLOAT fPercentBase) {
@@ -1042,6 +1041,7 @@ FX_FLOAT CFDE_CSSStyleSelector::ApplyNumber(FDE_CSSPRIMITIVETYPE eUnit,
return fValue;
}
}
+
FDE_CSSRUBYSPAN CFDE_CSSStyleSelector::ToRubySpan(FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
case FDE_CSSPROPERTYVALUE_None:
@@ -1049,6 +1049,7 @@ FDE_CSSRUBYSPAN CFDE_CSSStyleSelector::ToRubySpan(FDE_CSSPROPERTYVALUE eValue) {
return FDE_CSSRUBYSPAN_None;
}
}
+
FDE_CSSRUBYPOSITION CFDE_CSSStyleSelector::ToRubyPosition(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1064,6 +1065,7 @@ FDE_CSSRUBYPOSITION CFDE_CSSStyleSelector::ToRubyPosition(
return FDE_CSSRUBYPOSITION_Before;
}
}
+
FDE_CSSRUBYOVERHANG CFDE_CSSStyleSelector::ToRubyOverhang(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1078,6 +1080,7 @@ FDE_CSSRUBYOVERHANG CFDE_CSSStyleSelector::ToRubyOverhang(
return FDE_CSSRUBYOVERHANG_None;
}
}
+
FDE_CSSRUBYALIGN CFDE_CSSStyleSelector::ToRubyAlign(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1103,6 +1106,7 @@ FDE_CSSRUBYALIGN CFDE_CSSStyleSelector::ToRubyAlign(
return FDE_CSSRUBYALIGN_Auto;
}
}
+
FX_BOOL CFDE_CSSStyleSelector::ToTextEmphasisMark(
FDE_CSSPROPERTYVALUE eValue,
FDE_CSSTEXTEMPHASISMARK& eMark) {
@@ -1129,6 +1133,7 @@ FX_BOOL CFDE_CSSStyleSelector::ToTextEmphasisMark(
return FALSE;
}
}
+
FX_BOOL CFDE_CSSStyleSelector::ToTextEmphasisFill(
FDE_CSSPROPERTYVALUE eValue,
FDE_CSSTEXTEMPHASISFILL& eFill) {
@@ -1143,6 +1148,7 @@ FX_BOOL CFDE_CSSStyleSelector::ToTextEmphasisFill(
return FALSE;
}
}
+
FDE_CSSBKGATTACHMENT CFDE_CSSStyleSelector::ToBKGAttachment(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1154,6 +1160,7 @@ FDE_CSSBKGATTACHMENT CFDE_CSSStyleSelector::ToBKGAttachment(
return FDE_CSSBKGATTACHMENT_Fixed;
}
}
+
FDE_CSSCAPTIONSIDE CFDE_CSSStyleSelector::ToCaptionSide(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1173,6 +1180,7 @@ FDE_CSSCAPTIONSIDE CFDE_CSSStyleSelector::ToCaptionSide(
return FDE_CSSCAPTIONSIDE_Top;
}
}
+
FDE_CSSPOSITION CFDE_CSSStyleSelector::ToPosition(FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
case FDE_CSSPROPERTYVALUE_Static:
@@ -1187,6 +1195,7 @@ FDE_CSSPOSITION CFDE_CSSStyleSelector::ToPosition(FDE_CSSPROPERTYVALUE eValue) {
return FDE_CSSPOSITION_Static;
}
}
+
FDE_CSSCURSOR CFDE_CSSStyleSelector::ToCursor(FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
case FDE_CSSPROPERTYVALUE_Auto:
@@ -1215,6 +1224,7 @@ FDE_CSSCURSOR CFDE_CSSStyleSelector::ToCursor(FDE_CSSPROPERTYVALUE eValue) {
return FDE_CSSCURSOR_Auto;
}
}
+
FDE_CSSBKGREPEAT CFDE_CSSStyleSelector::ToBKGRepeat(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1230,6 +1240,7 @@ FDE_CSSBKGREPEAT CFDE_CSSStyleSelector::ToBKGRepeat(
return FDE_CSSBKGREPEAT_Repeat;
}
}
+
FDE_CSSTEXTCOMBINE CFDE_CSSStyleSelector::ToTextCombine(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1240,6 +1251,7 @@ FDE_CSSTEXTCOMBINE CFDE_CSSStyleSelector::ToTextCombine(
return FDE_CSSTEXTCOMBINE_None;
}
}
+
FDE_CSSLINEBREAK CFDE_CSSStyleSelector::ToLineBreak(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1255,6 +1267,7 @@ FDE_CSSLINEBREAK CFDE_CSSStyleSelector::ToLineBreak(
return FDE_CSSLINEBREAK_Auto;
}
}
+
FDE_CSSOVERFLOW CFDE_CSSStyleSelector::ToOverflow(FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
case FDE_CSSPROPERTYVALUE_Visible:
@@ -1273,6 +1286,7 @@ FDE_CSSOVERFLOW CFDE_CSSStyleSelector::ToOverflow(FDE_CSSPROPERTYVALUE eValue) {
return FDE_CSSOVERFLOW_Visible;
}
}
+
FDE_CSSWRITINGMODE CFDE_CSSStyleSelector::ToWritingMode(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1286,6 +1300,7 @@ FDE_CSSWRITINGMODE CFDE_CSSStyleSelector::ToWritingMode(
return FDE_CSSWRITINGMODE_HorizontalTb;
}
}
+
FDE_CSSWORDBREAK CFDE_CSSStyleSelector::ToWordBreak(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1301,6 +1316,7 @@ FDE_CSSWORDBREAK CFDE_CSSStyleSelector::ToWordBreak(
return FDE_CSSWORDBREAK_Normal;
}
}
+
FDE_CSSFLOAT CFDE_CSSStyleSelector::ToFloat(FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
case FDE_CSSPROPERTYVALUE_Left:
@@ -1313,6 +1329,7 @@ FDE_CSSFLOAT CFDE_CSSStyleSelector::ToFloat(FDE_CSSPROPERTYVALUE eValue) {
return FDE_CSSFLOAT_None;
}
}
+
FDE_CSSCLEAR CFDE_CSSStyleSelector::ToClear(FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
case FDE_CSSPROPERTYVALUE_None:
@@ -1327,6 +1344,7 @@ FDE_CSSCLEAR CFDE_CSSStyleSelector::ToClear(FDE_CSSPROPERTYVALUE eValue) {
return FDE_CSSCLEAR_None;
}
}
+
FDE_CSSPAGEBREAK CFDE_CSSStyleSelector::ToPageBreak(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1344,6 +1362,7 @@ FDE_CSSPAGEBREAK CFDE_CSSStyleSelector::ToPageBreak(
return FDE_CSSPAGEBREAK_Auto;
}
}
+
FDE_CSSDISPLAY CFDE_CSSStyleSelector::ToDisplay(FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
case FDE_CSSPROPERTYVALUE_Inline:
@@ -1392,6 +1411,7 @@ FDE_CSSDISPLAY CFDE_CSSStyleSelector::ToDisplay(FDE_CSSPROPERTYVALUE eValue) {
return FDE_CSSDISPLAY_Inline;
}
}
+
FDE_CSSTEXTALIGN CFDE_CSSStyleSelector::ToTextAlign(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1407,6 +1427,7 @@ FDE_CSSTEXTALIGN CFDE_CSSStyleSelector::ToTextAlign(
return FDE_CSSTEXTALIGN_Left;
}
}
+
uint16_t CFDE_CSSStyleSelector::ToFontWeight(FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
case FDE_CSSPROPERTYVALUE_Normal:
@@ -1421,6 +1442,7 @@ uint16_t CFDE_CSSStyleSelector::ToFontWeight(FDE_CSSPROPERTYVALUE eValue) {
return 400;
}
}
+
FDE_CSSFONTSTYLE CFDE_CSSStyleSelector::ToFontStyle(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1431,6 +1453,7 @@ FDE_CSSFONTSTYLE CFDE_CSSStyleSelector::ToFontStyle(
return FDE_CSSFONTSTYLE_Normal;
}
}
+
FDE_CSSBORDERSTYLE CFDE_CSSStyleSelector::ToBorderStyle(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1458,6 +1481,7 @@ FDE_CSSBORDERSTYLE CFDE_CSSStyleSelector::ToBorderStyle(
return FDE_CSSBORDERSTYLE_None;
}
}
+
FX_BOOL CFDE_CSSStyleSelector::SetLengthWithPercent(
FDE_CSSLENGTH& width,
FDE_CSSPRIMITIVETYPE eType,
@@ -1494,6 +1518,7 @@ FX_BOOL CFDE_CSSStyleSelector::SetLengthWithPercent(
}
return FALSE;
}
+
FX_FLOAT CFDE_CSSStyleSelector::ToFontSize(FDE_CSSPROPERTYVALUE eValue,
FX_FLOAT fCurFontSize) {
switch (eValue) {
@@ -1519,6 +1544,7 @@ FX_FLOAT CFDE_CSSStyleSelector::ToFontSize(FDE_CSSPROPERTYVALUE eValue,
return fCurFontSize;
}
}
+
FDE_CSSVERTICALALIGN CFDE_CSSStyleSelector::ToVerticalAlign(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1542,6 +1568,7 @@ FDE_CSSVERTICALALIGN CFDE_CSSStyleSelector::ToVerticalAlign(
return FDE_CSSVERTICALALIGN_Baseline;
}
}
+
FDE_CSSLISTSTYLETYPE CFDE_CSSStyleSelector::ToListStyleType(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1591,12 +1618,14 @@ FDE_CSSLISTSTYLETYPE CFDE_CSSStyleSelector::ToListStyleType(
return FDE_CSSLISTSTYLETYPE_Disc;
}
}
+
FDE_CSSLISTSTYLEPOSITION CFDE_CSSStyleSelector::ToListStylePosition(
FDE_CSSPROPERTYVALUE eValue) {
return eValue == FDE_CSSPROPERTYVALUE_Inside
? FDE_CSSLISTSTYLEPOSITION_Inside
: FDE_CSSLISTSTYLEPOSITION_Outside;
}
+
FDE_CSSVISIBILITY CFDE_CSSStyleSelector::ToVisibility(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1610,6 +1639,7 @@ FDE_CSSVISIBILITY CFDE_CSSStyleSelector::ToVisibility(
return FDE_CSSVISIBILITY_Visible;
}
}
+
FDE_CSSWHITESPACE CFDE_CSSStyleSelector::ToWhiteSpace(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1627,6 +1657,7 @@ FDE_CSSWHITESPACE CFDE_CSSStyleSelector::ToWhiteSpace(
return FDE_CSSWHITESPACE_Normal;
}
}
+
uint32_t CFDE_CSSStyleSelector::ToTextDecoration(IFDE_CSSValueList* pValue) {
uint32_t dwDecoration = 0;
for (int32_t i = pValue->CountValues() - 1; i >= 0; --i) {
@@ -1656,6 +1687,7 @@ uint32_t CFDE_CSSStyleSelector::ToTextDecoration(IFDE_CSSValueList* pValue) {
}
return dwDecoration;
}
+
FDE_CSSTEXTTRANSFORM CFDE_CSSStyleSelector::ToTextTransform(
FDE_CSSPROPERTYVALUE eValue) {
switch (eValue) {
@@ -1671,6 +1703,7 @@ FDE_CSSTEXTTRANSFORM CFDE_CSSStyleSelector::ToTextTransform(
return FDE_CSSTEXTTRANSFORM_None;
}
}
+
FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant(
FDE_CSSPROPERTYVALUE eValue) {
return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps
diff --git a/xfa/fde/css/fde_cssstyleselector.h b/xfa/fde/css/fde_cssstyleselector.h
index 042e989242..469712fb5d 100644
--- a/xfa/fde/css/fde_cssstyleselector.h
+++ b/xfa/fde/css/fde_cssstyleselector.h
@@ -7,6 +7,7 @@
#ifndef XFA_FDE_CSS_FDE_CSSSTYLESELECTOR_H_
#define XFA_FDE_CSS_FDE_CSSSTYLESELECTOR_H_
+#include <memory>
#include <vector>
#include "core/fxcrt/include/fx_ext.h"
@@ -26,8 +27,8 @@ class FDE_CSSRuleData : public CFX_Target {
CFDE_CSSDeclaration* pDecl,
uint32_t dwPos);
- CFDE_CSSSelector* pSelector;
- CFDE_CSSDeclaration* pDeclaration;
+ CFDE_CSSSelector* const pSelector;
+ CFDE_CSSDeclaration* const pDeclaration;
uint32_t dwPriority;
FDE_CSSRuleData* pNext;
};
@@ -88,10 +89,9 @@ class CFDE_CSSRuleCollection : public CFX_Target {
class CFDE_CSSStyleSelector : public CFX_Target {
public:
- CFDE_CSSStyleSelector();
+ explicit CFDE_CSSStyleSelector(IFGAS_FontMgr* pFontMgr);
~CFDE_CSSStyleSelector() override;
- void SetFontMgr(IFGAS_FontMgr* pFontMgr);
void SetDefFontSize(FX_FLOAT fFontSize);
FX_BOOL SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType,
@@ -174,15 +174,15 @@ class CFDE_CSSStyleSelector : public CFX_Target {
FDE_CSSRUBYPOSITION ToRubyPosition(FDE_CSSPROPERTYVALUE eValue);
FDE_CSSRUBYSPAN ToRubySpan(FDE_CSSPROPERTYVALUE eValue);
- IFGAS_FontMgr* m_pFontMgr;
+ IFGAS_FontMgr* const m_pFontMgr;
FX_FLOAT m_fDefFontSize;
- IFX_MemoryAllocator* m_pRuleDataStore;
+ std::unique_ptr<IFX_MemoryAllocator> m_pRuleDataStore;
CFDE_CSSStyleSheetArray m_SheetGroups[FDE_CSSSTYLESHEETGROUP_MAX];
CFDE_CSSRuleCollection m_RuleCollection[FDE_CSSSTYLESHEETGROUP_MAX];
FDE_CSSSTYLESHEETGROUP m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_MAX];
- IFX_MemoryAllocator* m_pInlineStyleStore;
- IFX_MemoryAllocator* m_pFixedStyleStore;
- CFDE_CSSAccelerator* m_pAccelerator;
+ std::unique_ptr<IFX_MemoryAllocator> m_pInlineStyleStore;
+ std::unique_ptr<IFX_MemoryAllocator> m_pFixedStyleStore;
+ std::unique_ptr<CFDE_CSSAccelerator> m_pAccelerator;
std::vector<FDE_CSSRuleData*> m_MatchedRules;
};
@@ -413,7 +413,7 @@ class CFDE_CSSComputedStyle : public IFDE_CSSComputedStyle,
const CFX_WideString& wsValue);
uint32_t m_dwRefCount;
- IFX_MemoryAllocator* m_pAllocator;
+ IFX_MemoryAllocator* const m_pAllocator;
CFDE_CSSInheritedData m_InheritedData;
CFDE_CSSNonInheritedData m_NonInheritedData;
CFX_WideStringArray m_CustomProperties;
diff --git a/xfa/fde/css/fde_cssstylesheet.cpp b/xfa/fde/css/fde_cssstylesheet.cpp
index 99beab8cf6..bc94cc2f70 100644
--- a/xfa/fde/css/fde_cssstylesheet.cpp
+++ b/xfa/fde/css/fde_cssstylesheet.cpp
@@ -78,7 +78,6 @@ CFDE_CSSStyleSheet::CFDE_CSSStyleSheet(uint32_t dwMediaList)
: m_wCodePage(FX_CODEPAGE_UTF8),
m_wRefCount(1),
m_dwMediaList(dwMediaList),
- m_pAllocator(nullptr),
m_RuleArray(100) {
ASSERT(m_dwMediaList > 0);
}
@@ -108,8 +107,7 @@ void CFDE_CSSStyleSheet::Reset() {
m_RuleArray.RemoveAll(FALSE);
m_Selectors.RemoveAll();
m_StringCache.clear();
- delete m_pAllocator;
- m_pAllocator = nullptr;
+ m_pAllocator.reset();
}
uint32_t CFDE_CSSStyleSheet::Retain() {
@@ -228,8 +226,8 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule(
break;
case FDE_CSSSYNTAXSTATUS_DeclOpen:
if ((dwMediaList & m_dwMediaList) > 0 && !pMediaRule) {
- pMediaRule =
- FXTARGET_NewWith(m_pAllocator) CFDE_CSSMediaRule(dwMediaList);
+ pMediaRule = FXTARGET_NewWith(m_pAllocator.get())
+ CFDE_CSSMediaRule(dwMediaList);
m_RuleArray.Add(pMediaRule);
}
break;
@@ -248,7 +246,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule(
const FX_WCHAR* pszValue = nullptr;
int32_t iValueLen = 0;
FDE_CSSPROPERTYARGS propertyArgs;
- propertyArgs.pStaticStore = m_pAllocator;
+ propertyArgs.pStaticStore = m_pAllocator.get();
propertyArgs.pStringCache = &m_StringCache;
propertyArgs.pProperty = nullptr;
CFX_WideString wsName;
@@ -256,8 +254,8 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule(
switch (pSyntax->DoSyntaxParse()) {
case FDE_CSSSYNTAXSTATUS_Selector: {
pszValue = pSyntax->GetCurrentString(iValueLen);
- CFDE_CSSSelector* pSelector =
- CFDE_CSSSelector::FromString(m_pAllocator, pszValue, iValueLen);
+ CFDE_CSSSelector* pSelector = CFDE_CSSSelector::FromString(
+ m_pAllocator.get(), pszValue, iValueLen);
if (pSelector)
m_Selectors.Add(pSelector);
} break;
@@ -286,8 +284,8 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule(
break;
case FDE_CSSSYNTAXSTATUS_DeclOpen:
if (!pStyleRule && m_Selectors.GetSize() > 0) {
- pStyleRule = FXTARGET_NewWith(m_pAllocator) CFDE_CSSStyleRule;
- pStyleRule->SetSelector(m_pAllocator, m_Selectors);
+ pStyleRule = FXTARGET_NewWith(m_pAllocator.get()) CFDE_CSSStyleRule;
+ pStyleRule->SetSelector(m_pAllocator.get(), m_Selectors);
ruleArray.Add(pStyleRule);
} else {
SkipRuleSet(pSyntax);
@@ -312,7 +310,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule(
const FX_WCHAR* pszValue = nullptr;
int32_t iValueLen = 0;
FDE_CSSPROPERTYARGS propertyArgs;
- propertyArgs.pStaticStore = m_pAllocator;
+ propertyArgs.pStaticStore = m_pAllocator.get();
propertyArgs.pStringCache = &m_StringCache;
propertyArgs.pProperty = nullptr;
for (;;) {
@@ -333,7 +331,8 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule(
break;
case FDE_CSSSYNTAXSTATUS_DeclOpen:
if (!pFontFaceRule) {
- pFontFaceRule = FXTARGET_NewWith(m_pAllocator) CFDE_CSSFontFaceRule;
+ pFontFaceRule =
+ FXTARGET_NewWith(m_pAllocator.get()) CFDE_CSSFontFaceRule;
ruleArray.Add(pFontFaceRule);
}
break;
diff --git a/xfa/fde/css/fde_cssstylesheet.h b/xfa/fde/css/fde_cssstylesheet.h
index d4781f8a8d..b013e2d2bd 100644
--- a/xfa/fde/css/fde_cssstylesheet.h
+++ b/xfa/fde/css/fde_cssstylesheet.h
@@ -7,6 +7,7 @@
#ifndef XFA_FDE_CSS_FDE_CSSSTYLESHEET_H_
#define XFA_FDE_CSS_FDE_CSSSTYLESHEET_H_
+#include <memory>
#include <unordered_map>
#include "core/fxcrt/include/fx_ext.h"
@@ -133,7 +134,7 @@ class CFDE_CSSStyleSheet : public IFDE_CSSStyleSheet, public CFX_Target {
uint16_t m_wCodePage;
uint16_t m_wRefCount;
uint32_t m_dwMediaList;
- IFX_MemoryAllocator* m_pAllocator;
+ std::unique_ptr<IFX_MemoryAllocator> m_pAllocator;
CFX_MassArrayTemplate<IFDE_CSSRule*> m_RuleArray;
CFX_WideString m_szUrl;
CFX_ArrayTemplate<CFDE_CSSSelector*> m_Selectors;
diff --git a/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp
index 56f845c35b..3612966e75 100644
--- a/xfa/fde/fde_gedevice.cpp
+++ b/xfa/fde/fde_gedevice.cpp
@@ -17,7 +17,6 @@ CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice,
FX_BOOL bOwnerDevice)
: m_pDevice(pDevice),
m_bOwnerDevice(bOwnerDevice),
- m_pCharPos(nullptr),
m_iCharCount(0) {
ASSERT(pDevice);
@@ -27,7 +26,6 @@ CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice,
}
CFDE_RenderDevice::~CFDE_RenderDevice() {
- FX_Free(m_pCharPos);
if (m_bOwnerDevice)
delete m_pDevice;
}
diff --git a/xfa/fde/fde_gedevice.h b/xfa/fde/fde_gedevice.h
index 2d2a901904..bb06cf6b53 100644
--- a/xfa/fde/fde_gedevice.h
+++ b/xfa/fde/fde_gedevice.h
@@ -116,10 +116,9 @@ class CFDE_RenderDevice : public CFX_Target {
FX_FLOAT fPenWidth,
CFX_GraphStateData& graphState);
- CFX_RenderDevice* m_pDevice;
+ CFX_RenderDevice* const m_pDevice;
CFX_RectF m_rtClip;
FX_BOOL m_bOwnerDevice;
- FXTEXT_CHARPOS* m_pCharPos;
int32_t m_iCharCount;
};
diff --git a/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp
index e2c395eeb5..f3189b0877 100644
--- a/xfa/fde/fde_render.cpp
+++ b/xfa/fde/fde_render.cpp
@@ -16,9 +16,7 @@
CFDE_RenderContext::CFDE_RenderContext()
: m_eStatus(FDE_RENDERSTATUS_Reset),
m_pRenderDevice(nullptr),
- m_Transform(),
- m_pCharPos(nullptr),
- m_iCharPosCount(0) {
+ m_Transform() {
m_Transform.SetIdentity();
}
@@ -101,9 +99,7 @@ void CFDE_RenderContext::StopRender() {
m_Transform.SetIdentity();
m_pIterator.reset();
m_pBrush.reset();
- FX_Free(m_pCharPos);
- m_pCharPos = nullptr;
- m_iCharPosCount = 0;
+ m_CharPos.clear();
}
void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet,
@@ -122,19 +118,14 @@ void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet,
if (!m_pBrush)
m_pBrush.reset(new CFDE_Brush);
- if (!m_pCharPos)
- m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iCount);
- else if (m_iCharPosCount < iCount)
- m_pCharPos = FX_Realloc(FXTEXT_CHARPOS, m_pCharPos, iCount);
+ if (m_CharPos.size() < static_cast<size_t>(iCount))
+ m_CharPos.resize(iCount, FXTEXT_CHARPOS());
- if (m_iCharPosCount < iCount)
- m_iCharPosCount = iCount;
-
- iCount = pTextSet->GetDisplayPos(pText, m_pCharPos, FALSE);
+ iCount = pTextSet->GetDisplayPos(pText, m_CharPos.data(), FALSE);
FX_FLOAT fFontSize = pTextSet->GetFontSize();
FX_ARGB dwColor = pTextSet->GetFontColor();
m_pBrush->SetColor(dwColor);
- m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_pCharPos, iCount,
+ m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_CharPos.data(), iCount,
fFontSize, &m_Transform);
}
diff --git a/xfa/fde/fde_render.h b/xfa/fde/fde_render.h
index 523aaee7c7..b91bbfe554 100644
--- a/xfa/fde/fde_render.h
+++ b/xfa/fde/fde_render.h
@@ -8,6 +8,7 @@
#define XFA_FDE_FDE_RENDER_H_
#include <memory>
+#include <vector>
#include "core/fxcrt/include/fx_coordinates.h"
#include "xfa/fde/fde_gedevice.h"
@@ -40,8 +41,7 @@ class CFDE_RenderContext : public CFX_Target {
FDE_RENDERSTATUS m_eStatus;
CFDE_RenderDevice* m_pRenderDevice;
CFX_Matrix m_Transform;
- FXTEXT_CHARPOS* m_pCharPos;
- int32_t m_iCharPosCount;
+ std::vector<FXTEXT_CHARPOS> m_CharPos;
std::unique_ptr<CFDE_Brush> m_pBrush;
std::unique_ptr<CFDE_VisualSetIterator> m_pIterator;
};
diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp
index a29a420216..c83afc1ad6 100644
--- a/xfa/fde/tto/fde_textout.cpp
+++ b/xfa/fde/tto/fde_textout.cpp
@@ -18,17 +18,14 @@
#include "xfa/fgas/layout/fgas_textbreak.h"
CFDE_TextOut::CFDE_TextOut()
- : m_pFont(nullptr),
+ : m_pTxtBreak(new CFX_TxtBreak(FX_TXTBREAKPOLICY_None)),
+ m_pFont(nullptr),
m_fFontSize(12.0f),
m_fLineSpace(m_fFontSize),
m_fLinePos(0.0f),
m_fTolerance(0.0f),
m_iAlignment(0),
m_iTxtBkAlignment(0),
- m_pCharWidths(nullptr),
- m_iChars(0),
- m_pEllCharWidths(nullptr),
- m_iEllChars(0),
m_wParagraphBkChar(L'\n'),
m_TxtColor(0xFF000000),
m_dwStyles(0),
@@ -38,34 +35,32 @@ CFDE_TextOut::CFDE_TextOut()
m_ttoLines(5),
m_iCurLine(0),
m_iCurPiece(0),
- m_iTotalLines(0),
- m_pCharPos(nullptr),
- m_iCharPosSize(0) {
- m_pTxtBreak = new CFX_TxtBreak(FX_TXTBREAKPOLICY_None);
+ m_iTotalLines(0) {
m_Matrix.SetIdentity();
m_rtClip.Reset();
m_rtLogicClip.Reset();
}
+
CFDE_TextOut::~CFDE_TextOut() {
- delete m_pTxtBreak;
- FX_Free(m_pCharWidths);
- FX_Free(m_pEllCharWidths);
- FX_Free(m_pCharPos);
m_ttoLines.RemoveAll(FALSE);
}
+
void CFDE_TextOut::SetFont(CFGAS_GEFont* pFont) {
ASSERT(pFont);
m_pFont = pFont;
m_pTxtBreak->SetFont(pFont);
}
+
void CFDE_TextOut::SetFontSize(FX_FLOAT fFontSize) {
ASSERT(fFontSize > 0);
m_fFontSize = fFontSize;
m_pTxtBreak->SetFontSize(fFontSize);
}
+
void CFDE_TextOut::SetTextColor(FX_ARGB color) {
m_TxtColor = color;
}
+
void CFDE_TextOut::SetStyles(uint32_t dwStyles) {
m_dwStyles = dwStyles;
m_dwTxtBkStyles = 0;
@@ -90,18 +85,22 @@ void CFDE_TextOut::SetStyles(uint32_t dwStyles) {
}
m_pTxtBreak->SetLayoutStyles(m_dwTxtBkStyles);
}
+
void CFDE_TextOut::SetTabWidth(FX_FLOAT fTabWidth) {
ASSERT(fTabWidth > 1.0f);
m_pTxtBreak->SetTabWidth(fTabWidth, FALSE);
}
+
void CFDE_TextOut::SetEllipsisString(const CFX_WideString& wsEllipsis) {
m_bElliChanged = TRUE;
m_wsEllipsis = wsEllipsis;
}
+
void CFDE_TextOut::SetParagraphBreakChar(FX_WCHAR wch) {
m_wParagraphBkChar = wch;
m_pTxtBreak->SetParagraphBreakChar(wch);
}
+
void CFDE_TextOut::SetAlignment(int32_t iAlignment) {
m_iAlignment = iAlignment;
switch (m_iAlignment) {
@@ -121,6 +120,7 @@ void CFDE_TextOut::SetAlignment(int32_t iAlignment) {
}
m_pTxtBreak->SetAlignment(m_iTxtBkAlignment);
}
+
void CFDE_TextOut::SetLineSpace(FX_FLOAT fLineSpace) {
ASSERT(fLineSpace > 1.0f);
m_fLineSpace = fLineSpace;
@@ -144,22 +144,28 @@ void CFDE_TextOut::SetClipRect(const CFX_Rect& rtClip) {
m_rtClip.Set((FX_FLOAT)rtClip.left, (FX_FLOAT)rtClip.top,
(FX_FLOAT)rtClip.Width(), (FX_FLOAT)rtClip.Height());
}
+
void CFDE_TextOut::SetClipRect(const CFX_RectF& rtClip) {
m_rtClip = rtClip;
}
+
void CFDE_TextOut::SetLogicClipRect(const CFX_RectF& rtClip) {
m_rtLogicClip = rtClip;
}
+
void CFDE_TextOut::SetMatrix(const CFX_Matrix& matrix) {
m_Matrix = matrix;
}
+
void CFDE_TextOut::SetLineBreakTolerance(FX_FLOAT fTolerance) {
m_fTolerance = fTolerance;
m_pTxtBreak->SetLineBreakTolerance(m_fTolerance);
}
+
int32_t CFDE_TextOut::GetTotalLines() {
return m_iTotalLines;
}
+
void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_Size& size) {
@@ -169,6 +175,7 @@ void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
size.x = (int32_t)rtText.Width();
size.y = (int32_t)rtText.Height();
}
+
void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_SizeF& size) {
@@ -178,6 +185,7 @@ void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
size.x = rtText.Width();
size.y = rtText.Height();
}
+
void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_Rect& rect) {
@@ -188,6 +196,7 @@ void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
rect.Set((int32_t)rtText.left, (int32_t)rtText.top, (int32_t)rtText.Width(),
(int32_t)rtText.Height());
}
+
void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_RectF& rect) {
@@ -202,6 +211,7 @@ void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
m_Matrix.TransformRect(rect);
}
}
+
void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_SizeF& size) {
@@ -211,6 +221,7 @@ void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr,
size.x = rtText.Width();
size.y = rtText.Height();
}
+
void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_RectF& rect) {
@@ -221,6 +232,7 @@ void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr,
CalcTextSize(pwsStr, iLength, rect);
}
}
+
void CFDE_TextOut::CalcTextSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_RectF& rect) {
@@ -283,6 +295,7 @@ void CFDE_TextOut::CalcTextSize(const FX_WCHAR* pwsStr,
}
}
}
+
void CFDE_TextOut::SetLineWidth(CFX_RectF& rect) {
if ((m_dwStyles & FDE_TTOSTYLE_SingleLine) == 0) {
FX_FLOAT fLineWidth = 0.0f;
@@ -300,6 +313,7 @@ void CFDE_TextOut::SetLineWidth(CFX_RectF& rect) {
m_pTxtBreak->SetLineWidth(fLineWidth);
}
}
+
FX_BOOL CFDE_TextOut::RetrieveLineWidth(uint32_t dwBreakStatus,
FX_FLOAT& fStartPos,
FX_FLOAT& fWidth,
@@ -330,6 +344,7 @@ FX_BOOL CFDE_TextOut::RetrieveLineWidth(uint32_t dwBreakStatus,
m_iTotalLines++;
return TRUE;
}
+
void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
int32_t iLength,
int32_t x,
@@ -339,6 +354,7 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
m_fFontSize * 1000.0f);
DrawText(pwsStr, iLength, rtText);
}
+
void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
int32_t iLength,
FX_FLOAT x,
@@ -347,6 +363,7 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
rtText.Set(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f);
DrawText(pwsStr, iLength, rtText);
}
+
void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
int32_t iLength,
const CFX_Rect& rect) {
@@ -355,6 +372,7 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
(FX_FLOAT)rect.height);
DrawText(pwsStr, iLength, rtText);
}
+
void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
int32_t iLength,
const CFX_RectF& rect) {
@@ -365,6 +383,7 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
rm.TransformRect(rtText);
DrawText(pwsStr, iLength, rtText, m_rtClip);
}
+
void CFDE_TextOut::DrawLogicText(const FX_WCHAR* pwsStr,
int32_t iLength,
FX_FLOAT x,
@@ -373,6 +392,7 @@ void CFDE_TextOut::DrawLogicText(const FX_WCHAR* pwsStr,
rtText.Set(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f);
DrawLogicText(pwsStr, iLength, rtText);
}
+
void CFDE_TextOut::DrawLogicText(const FX_WCHAR* pwsStr,
int32_t iLength,
const CFX_RectF& rect) {
@@ -382,6 +402,7 @@ void CFDE_TextOut::DrawLogicText(const FX_WCHAR* pwsStr,
m_Matrix.TransformRect(rtClip);
DrawText(pwsStr, iLength, rect, rtClip);
}
+
void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
int32_t iLength,
const CFX_RectF& rect,
@@ -408,39 +429,26 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
DoAlignment(rect);
OnDraw(rtClip);
}
+
void CFDE_TextOut::ExpandBuffer(int32_t iSize, int32_t iType) {
+ ASSERT(iSize >= 0);
+ size_t size = iSize;
switch (iType) {
case 0:
- if (!m_pCharWidths) {
- m_pCharWidths = FX_Alloc(int32_t, iSize);
- m_iChars = iSize;
- } else if (m_iChars < iSize) {
- m_pCharWidths = FX_Realloc(int32_t, m_pCharWidths, iSize);
- m_iChars = iSize;
- }
- FXSYS_memset(m_pCharWidths, 0, iSize * sizeof(int32_t));
+ if (m_CharWidths.size() < size)
+ m_CharWidths.resize(size, 0);
break;
case 1:
- if (!m_pEllCharWidths) {
- m_pEllCharWidths = FX_Alloc(int32_t, iSize);
- m_iEllChars = iSize;
- } else if (m_iEllChars < iSize) {
- m_pEllCharWidths = FX_Realloc(int32_t, m_pEllCharWidths, iSize);
- m_iEllChars = iSize;
- }
- FXSYS_memset(m_pEllCharWidths, 0, iSize * sizeof(int32_t));
+ if (m_EllCharWidths.size() < size)
+ m_EllCharWidths.resize(size, 0);
break;
case 2:
- if (!m_pCharPos) {
- m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iSize);
- m_iCharPosSize = iSize;
- } else if (m_iCharPosSize < iSize) {
- m_pCharPos = FX_Realloc(FXTEXT_CHARPOS, m_pCharPos, iSize);
- m_iCharPosSize = iSize;
- }
+ if (m_CharPos.size() < size)
+ m_CharPos.resize(size, FXTEXT_CHARPOS());
break;
}
}
+
void CFDE_TextOut::LoadEllipsis() {
if (!m_bElliChanged) {
return;
@@ -453,41 +461,36 @@ void CFDE_TextOut::LoadEllipsis() {
}
ExpandBuffer(iLength, 1);
const FX_WCHAR* pStr = m_wsEllipsis.c_str();
- int32_t* pCharWidths = m_pEllCharWidths;
uint32_t dwBreakStatus;
FX_WCHAR wch;
while (iLength-- > 0) {
wch = *pStr++;
dwBreakStatus = m_pTxtBreak->AppendChar(wch);
- if (dwBreakStatus > FX_TXTBREAK_PieceBreak) {
- RetrieveEllPieces(pCharWidths);
- }
+ if (dwBreakStatus > FX_TXTBREAK_PieceBreak)
+ RetrieveEllPieces(&m_EllCharWidths);
}
dwBreakStatus = m_pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak);
- if (dwBreakStatus > FX_TXTBREAK_PieceBreak) {
- RetrieveEllPieces(pCharWidths);
- }
+ if (dwBreakStatus > FX_TXTBREAK_PieceBreak)
+ RetrieveEllPieces(&m_EllCharWidths);
m_pTxtBreak->Reset();
}
-void CFDE_TextOut::RetrieveEllPieces(int32_t*& pCharWidths) {
+
+void CFDE_TextOut::RetrieveEllPieces(std::vector<int32_t>* pCharWidths) {
int32_t iCount = m_pTxtBreak->CountBreakPieces();
- CFX_Char* pTC;
+ int32_t iCharIndex = 0;
for (int32_t i = 0; i < iCount; i++) {
const CFX_TxtPiece* pPiece = m_pTxtBreak->GetBreakPiece(i);
int32_t iPieceChars = pPiece->GetLength();
for (int32_t j = 0; j < iPieceChars; j++) {
- pTC = pPiece->GetCharPtr(j);
- if (pTC->m_iCharWidth <= 0) {
- *pCharWidths = 0;
- } else {
- *pCharWidths = pTC->m_iCharWidth;
- }
- m_iEllipsisWidth += *pCharWidths;
- pCharWidths++;
+ CFX_Char* pTC = pPiece->GetCharPtr(j);
+ (*pCharWidths)[iCharIndex] = std::max(pTC->m_iCharWidth, 0);
+ m_iEllipsisWidth += (*pCharWidths)[iCharIndex];
+ iCharIndex++;
}
}
m_pTxtBreak->ClearBreakPieces();
}
+
void CFDE_TextOut::LoadText(const FX_WCHAR* pwsStr,
int32_t iLength,
const CFX_RectF& rect) {
@@ -551,6 +554,7 @@ void CFDE_TextOut::LoadText(const FX_WCHAR* pwsStr,
m_pTxtBreak->Reset();
m_wsText.ReleaseBuffer(iLength);
}
+
FX_BOOL CFDE_TextOut::RetriecePieces(uint32_t dwBreakStatus,
int32_t& iStartChar,
int32_t& iPieceWidths,
@@ -585,7 +589,7 @@ FX_BOOL CFDE_TextOut::RetriecePieces(uint32_t dwBreakStatus,
}
}
iWidth += iCurCharWidth;
- m_pCharWidths[iChar++] = iCurCharWidth;
+ m_CharWidths[iChar++] = iCurCharWidth;
}
if (j == 0 && !bReload) {
CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(m_iCurLine);
@@ -621,6 +625,7 @@ FX_BOOL CFDE_TextOut::RetriecePieces(uint32_t dwBreakStatus,
dwBreakStatus == FX_TXTBREAK_ParagraphBreak;
return bRet;
}
+
void CFDE_TextOut::AppendPiece(const FDE_TTOPIECE& ttoPiece,
FX_BOOL bNeedReload,
FX_BOOL bEnd) {
@@ -644,6 +649,7 @@ void CFDE_TextOut::AppendPiece(const FDE_TTOPIECE& ttoPiece,
m_iCurPiece = 0;
}
}
+
void CFDE_TextOut::ReplaceWidthEllipsis() {
LoadEllipsis();
int32_t iLength = m_wsEllipsis.GetLength();
@@ -670,14 +676,14 @@ void CFDE_TextOut::ReplaceWidthEllipsis() {
break;
}
int32_t index = pPiece->iStartChar + j;
- iCharWidth += m_pCharWidths[index];
+ iCharWidth += m_CharWidths[index];
iCharCount++;
if (iCharCount <= iLength) {
m_wsText.SetAt(index, m_wsEllipsis.GetAt(iEllipsisCharIndex));
- m_pCharWidths[index] = m_pEllCharWidths[iEllipsisCharIndex];
+ m_CharWidths[index] = m_EllCharWidths[iEllipsisCharIndex];
} else if (iCharWidth <= m_iEllipsisWidth) {
m_wsText.SetAt(index, 0);
- m_pCharWidths[index] = 0;
+ m_CharWidths[index] = 0;
}
iEllipsisCharIndex--;
}
@@ -687,6 +693,7 @@ void CFDE_TextOut::ReplaceWidthEllipsis() {
}
}
}
+
void CFDE_TextOut::Reload(const CFX_RectF& rect) {
int32_t iCount = m_ttoLines.GetSize();
for (int32_t i = 0; i < iCount; i++) {
@@ -699,6 +706,7 @@ void CFDE_TextOut::Reload(const CFX_RectF& rect) {
ReloadLinePiece(pLine, rect);
}
}
+
void CFDE_TextOut::ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect) {
const FX_WCHAR* pwsStr = m_wsText.c_str();
FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout);
@@ -730,6 +738,7 @@ void CFDE_TextOut::ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect) {
}
m_pTxtBreak->Reset();
}
+
void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) {
FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout);
FX_FLOAT fLineStopS = bVertical ? rect.right() : rect.bottom();
@@ -763,6 +772,7 @@ void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) {
}
}
}
+
void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) {
if (!m_pRenderDevice)
return;
@@ -788,7 +798,7 @@ void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) {
int32_t iCount = GetDisplayPos(pPiece);
if (iCount > 0) {
- m_pRenderDevice->DrawString(pBrush, m_pFont, m_pCharPos, iCount,
+ m_pRenderDevice->DrawString(pBrush, m_pFont, m_CharPos.data(), iCount,
m_fFontSize, &m_Matrix);
}
DrawLine(pPiece, pPen);
@@ -802,7 +812,7 @@ void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) {
int32_t CFDE_TextOut::GetDisplayPos(FDE_TTOPIECE* pPiece) {
FX_TXTRUN tr = ToTextRun(pPiece);
ExpandBuffer(tr.iLength, 2);
- return m_pTxtBreak->GetDisplayPos(&tr, m_pCharPos);
+ return m_pTxtBreak->GetDisplayPos(&tr, m_CharPos.data());
}
int32_t CFDE_TextOut::GetCharRects(const FDE_TTOPIECE* pPiece) {
@@ -814,7 +824,7 @@ int32_t CFDE_TextOut::GetCharRects(const FDE_TTOPIECE* pPiece) {
FX_TXTRUN CFDE_TextOut::ToTextRun(const FDE_TTOPIECE* pPiece) {
FX_TXTRUN tr;
tr.wsStr = m_wsText + pPiece->iStartChar;
- tr.pWidths = m_pCharWidths + pPiece->iStartChar;
+ tr.pWidths = &m_CharWidths[pPiece->iStartChar];
tr.iLength = pPiece->iChars;
tr.pFont = m_pFont;
tr.fFontSize = m_fFontSize;
@@ -922,18 +932,22 @@ int32_t CFDE_TTOLine::AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece) {
}
return index;
}
+
int32_t CFDE_TTOLine::GetSize() const {
return m_iPieceCount;
}
+
FDE_TTOPIECE* CFDE_TTOLine::GetPtrAt(int32_t index) {
if (index >= m_iPieceCount) {
return nullptr;
}
return m_pieces.GetPtrAt(index);
}
+
void CFDE_TTOLine::RemoveLast(int32_t iCount) {
m_pieces.RemoveLast(iCount);
}
+
void CFDE_TTOLine::RemoveAll(FX_BOOL bLeaveMemory) {
m_pieces.RemoveAll(bLeaveMemory);
}
diff --git a/xfa/fde/tto/fde_textout.h b/xfa/fde/tto/fde_textout.h
index 14ca5e19bb..8d2c0fe8a0 100644
--- a/xfa/fde/tto/fde_textout.h
+++ b/xfa/fde/tto/fde_textout.h
@@ -8,6 +8,7 @@
#define XFA_FDE_TTO_FDE_TEXTOUT_H_
#include <memory>
+#include <vector>
#include "core/fxge/include/fx_dib.h"
#include "core/fxge/include/fx_ge.h"
@@ -131,7 +132,7 @@ class CFDE_TextOut : public CFX_Target {
void LoadText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect);
void LoadEllipsis();
void ExpandBuffer(int32_t iSize, int32_t iType);
- void RetrieveEllPieces(int32_t*& pCharWidths);
+ void RetrieveEllPieces(std::vector<int32_t>* pCharWidths);
void Reload(const CFX_RectF& rect);
void ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect);
@@ -152,18 +153,16 @@ class CFDE_TextOut : public CFX_Target {
FX_TXTRUN ToTextRun(const FDE_TTOPIECE* pPiece);
void DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen*& pPen);
- CFX_TxtBreak* m_pTxtBreak;
- CFGAS_GEFont* m_pFont;
+ std::unique_ptr<CFX_TxtBreak> m_pTxtBreak;
+ CFGAS_GEFont* m_pFont; // not owned.
FX_FLOAT m_fFontSize;
FX_FLOAT m_fLineSpace;
FX_FLOAT m_fLinePos;
FX_FLOAT m_fTolerance;
int32_t m_iAlignment;
int32_t m_iTxtBkAlignment;
- int32_t* m_pCharWidths;
- int32_t m_iChars;
- int32_t* m_pEllCharWidths;
- int32_t m_iEllChars;
+ std::vector<int32_t> m_CharWidths;
+ std::vector<int32_t> m_EllCharWidths;
FX_WCHAR m_wParagraphBkChar;
FX_ARGB m_TxtColor;
uint32_t m_dwStyles;
@@ -179,8 +178,7 @@ class CFDE_TextOut : public CFX_Target {
int32_t m_iCurLine;
int32_t m_iCurPiece;
int32_t m_iTotalLines;
- FXTEXT_CHARPOS* m_pCharPos;
- int32_t m_iCharPosSize;
+ std::vector<FXTEXT_CHARPOS> m_CharPos;
std::unique_ptr<CFDE_RenderDevice> m_pRenderDevice;
CFX_Int32Array m_hotKeys;
CFX_RectFArray m_rectArray;
diff --git a/xfa/fgas/crt/fgas_memory.cpp b/xfa/fgas/crt/fgas_memory.cpp
index d218f42aa4..e587f5a5b0 100644
--- a/xfa/fgas/crt/fgas_memory.cpp
+++ b/xfa/fgas/crt/fgas_memory.cpp
@@ -27,10 +27,11 @@ class CFX_DefStore : public IFX_MemoryAllocator, public CFX_Target {
} // namespace
-IFX_MemoryAllocator* IFX_MemoryAllocator::Create(FX_ALLOCTYPE eType,
- size_t chunkSize,
- size_t blockSize) {
- return new CFX_DefStore();
+std::unique_ptr<IFX_MemoryAllocator> IFX_MemoryAllocator::Create(
+ FX_ALLOCTYPE eType,
+ size_t chunkSize,
+ size_t blockSize) {
+ return std::unique_ptr<IFX_MemoryAllocator>(new CFX_DefStore());
}
#else // MEMORY_TOOL_REPLACES_ALLOCATOR
@@ -88,17 +89,19 @@ class CFX_FixedStore : public IFX_MemoryAllocator, public CFX_Target {
#define FX_4BYTEALIGN(size) (((size) + 3) & ~3)
-IFX_MemoryAllocator* IFX_MemoryAllocator::Create(FX_ALLOCTYPE eType,
- size_t chunkSize,
- size_t blockSize) {
+std::unique_ptr<IFX_MemoryAllocator> IFX_MemoryAllocator::Create(
+ FX_ALLOCTYPE eType,
+ size_t chunkSize,
+ size_t blockSize) {
switch (eType) {
case FX_ALLOCTYPE_Static:
- return new CFX_StaticStore(chunkSize);
+ return std::unique_ptr<IFX_MemoryAllocator>(
+ new CFX_StaticStore(chunkSize));
case FX_ALLOCTYPE_Fixed:
- return new CFX_FixedStore(blockSize, chunkSize);
+ return std::unique_ptr<IFX_MemoryAllocator>(new CFX_FixedStore(blockSize, chunkSize);
default:
ASSERT(0);
- return nullptr;
+ return std::unique_ptr<IFX_MemoryAllocator>();
}
}
diff --git a/xfa/fgas/crt/fgas_memory.h b/xfa/fgas/crt/fgas_memory.h
index a83933c7a5..1034c417d7 100644
--- a/xfa/fgas/crt/fgas_memory.h
+++ b/xfa/fgas/crt/fgas_memory.h
@@ -7,6 +7,8 @@
#ifndef XFA_FGAS_CRT_FGAS_MEMORY_H_
#define XFA_FGAS_CRT_FGAS_MEMORY_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_memory.h"
#include "core/fxcrt/include/fx_system.h"
@@ -21,9 +23,9 @@ class IFX_MemoryAllocator {
virtual void* Alloc(size_t size) = 0;
virtual void Free(void* pBlock) = 0;
- static IFX_MemoryAllocator* Create(FX_ALLOCTYPE eType,
- size_t chunkSize,
- size_t blockSize);
+ static std::unique_ptr<IFX_MemoryAllocator> Create(FX_ALLOCTYPE eType,
+ size_t chunkSize,
+ size_t blockSize);
};
class CFX_Target {
diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp
index 88645b7cdd..6ac5c057c0 100644
--- a/xfa/fxfa/app/xfa_textlayout.cpp
+++ b/xfa/fxfa/app/xfa_textlayout.cpp
@@ -96,8 +96,7 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
CXFA_FFDoc* pDoc = pTextProvider->GetDocNode();
IFGAS_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr();
ASSERT(pFontMgr);
- m_pSelector.reset(new CFDE_CSSStyleSelector);
- m_pSelector->SetFontMgr(pFontMgr);
+ m_pSelector.reset(new CFDE_CSSStyleSelector(pFontMgr));
FX_FLOAT fFontSize = 10;
CXFA_Font font = pTextProvider->GetFontNode();
if (font) {
@@ -252,8 +251,8 @@ void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer,
if (!pXMLContainer || !pTextProvider || m_pAllocator) {
return;
}
- m_pAllocator.reset(IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, 32,
- sizeof(CXFA_CSSTagProvider)));
+ m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, 32,
+ sizeof(CXFA_CSSTagProvider));
InitCSSData(pTextProvider);
IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider);
ParseRichText(pXMLContainer, pRootStyle);
@@ -1294,8 +1293,7 @@ FX_BOOL CXFA_TextLayout::Loader(const CFX_SizeF& szText,
FX_FLOAT& fLinePos,
FX_BOOL bSavePieces) {
if (!m_pAllocator) {
- m_pAllocator.reset(
- IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 256, 0));
+ m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 256, 0);
}
GetTextDataNode();
if (!m_pTextDataNode)