summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-11 10:26:05 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-11 10:26:05 -0700
commitf74ad998d2e8d2636fb25e94823946a3b151e34e (patch)
tree0b18e0a29fdc4bf1cce66ea437d8a4841b3daf4a
parent2c3a16a7698ba15476173e849f82c97ea3da9939 (diff)
downloadpdfium-f74ad998d2e8d2636fb25e94823946a3b151e34e.tar.xz
Replace some calls to Release() with direct delete, part 1.
Searching for the anti-pattern: void Release() { delete this; } We must be explicit on the ownership model. Add unique_ptrs as a result. Review-Url: https://codereview.chromium.org/1960673003
-rw-r--r--core/fxcodec/codec/fx_codec_flate.cpp1
-rw-r--r--core/fxcodec/codec/fx_codec_jpeg.cpp1
-rw-r--r--xfa/fde/cfde_path.h2
-rw-r--r--xfa/fde/css/fde_cssstyleselector.cpp63
-rw-r--r--xfa/fde/css/fde_cssstyleselector.h4
-rw-r--r--xfa/fde/css/fde_cssstylesheet.cpp21
-rw-r--r--xfa/fde/css/fde_csssyntax.h3
-rw-r--r--xfa/fde/fde_gedevice.h4
-rw-r--r--xfa/fde/fde_iterator.h4
-rw-r--r--xfa/fde/fde_render.cpp20
-rw-r--r--xfa/fde/fde_render.h9
-rw-r--r--xfa/fde/tto/fde_textout.cpp44
-rw-r--r--xfa/fde/tto/fde_textout.h7
-rw-r--r--xfa/fee/fde_txtedtengine.cpp4
-rw-r--r--xfa/fwl/basewidget/fwl_editimp.cpp14
-rw-r--r--xfa/fwl/theme/cfwl_widgettp.cpp31
-rw-r--r--xfa/fwl/theme/cfwl_widgettp.h2
-rw-r--r--xfa/fxfa/app/xfa_ffwidgetacc.cpp75
-rw-r--r--xfa/fxfa/app/xfa_fwltheme.cpp12
-rw-r--r--xfa/fxfa/app/xfa_fwltheme.h4
-rw-r--r--xfa/fxfa/app/xfa_textlayout.cpp51
-rw-r--r--xfa/fxfa/app/xfa_textlayout.h5
22 files changed, 171 insertions, 210 deletions
diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp
index d1b4a5f985..c23de277fb 100644
--- a/core/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/fxcodec/codec/fx_codec_flate.cpp
@@ -750,7 +750,6 @@ class CCodec_FlateScanlineDecoder : public CCodec_ScanlineDecoder {
int Colors,
int BitsPerComponent,
int Columns);
- void Destroy() { delete this; }
// CCodec_ScanlineDecoder
FX_BOOL v_Rewind() override;
diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp
index ebe6106945..c41dde943f 100644
--- a/core/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/fxcodec/codec/fx_codec_jpeg.cpp
@@ -318,7 +318,6 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder {
int height,
int nComps,
FX_BOOL ColorTransform);
- void Destroy() { delete this; }
// CCodec_ScanlineDecoder
FX_BOOL v_Rewind() override;
diff --git a/xfa/fde/cfde_path.h b/xfa/fde/cfde_path.h
index c4b66f063e..c9f213d350 100644
--- a/xfa/fde/cfde_path.h
+++ b/xfa/fde/cfde_path.h
@@ -12,8 +12,6 @@
class CFDE_Path : public CFX_Target {
public:
- void Release() { delete this; }
-
FX_BOOL StartFigure();
FX_BOOL CloseFigure();
diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp
index 27b251a783..05f036b1f3 100644
--- a/xfa/fde/css/fde_cssstyleselector.cpp
+++ b/xfa/fde/css/fde_cssstyleselector.cpp
@@ -7,6 +7,7 @@
#include "xfa/fde/css/fde_cssstyleselector.h"
#include <algorithm>
+#include <memory>
#include "xfa/fde/css/fde_csscache.h"
#include "xfa/fde/css/fde_cssdeclaration.h"
@@ -538,44 +539,42 @@ void CFDE_CSSStyleSelector::AppendInlineStyle(CFDE_CSSDeclaration* pDecl,
const FX_WCHAR* psz,
int32_t iLen) {
ASSERT(pDecl && psz && iLen > 0);
+ std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser);
+ if (!pSyntax->Init(psz, iLen, 32, TRUE))
+ return;
- CFDE_CSSSyntaxParser* pSyntax = new CFDE_CSSSyntaxParser;
- if (pSyntax->Init(psz, iLen, 32, TRUE)) {
- int32_t iLen;
- const FX_WCHAR* psz;
- FDE_CSSPROPERTYARGS args;
- args.pStringCache = NULL;
- args.pStaticStore = m_pInlineStyleStore;
- args.pProperty = NULL;
- CFX_WideString wsName;
- for (;;) {
- FDE_CSSSYNTAXSTATUS eStatus = pSyntax->DoSyntaxParse();
- if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyName) {
- psz = pSyntax->GetCurrentString(iLen);
- args.pProperty = FDE_GetCSSPropertyByName(CFX_WideStringC(psz, iLen));
- if (args.pProperty == NULL) {
- wsName = CFX_WideStringC(psz, iLen);
- }
- } else if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyValue) {
- if (args.pProperty != NULL) {
- psz = pSyntax->GetCurrentString(iLen);
- if (iLen > 0) {
- pDecl->AddProperty(&args, psz, iLen);
- }
- } else if (iLen > 0) {
- psz = pSyntax->GetCurrentString(iLen);
- if (iLen > 0) {
- pDecl->AddProperty(&args, wsName.c_str(), wsName.GetLength(), psz,
- iLen);
- }
+ int32_t iLen2;
+ const FX_WCHAR* psz2;
+ FDE_CSSPROPERTYARGS args;
+ args.pStringCache = nullptr;
+ args.pStaticStore = m_pInlineStyleStore;
+ args.pProperty = nullptr;
+ CFX_WideString wsName;
+ while (1) {
+ FDE_CSSSYNTAXSTATUS eStatus = pSyntax->DoSyntaxParse();
+ if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyName) {
+ psz2 = pSyntax->GetCurrentString(iLen2);
+ args.pProperty = FDE_GetCSSPropertyByName(CFX_WideStringC(psz2, iLen2));
+ if (!args.pProperty)
+ wsName = CFX_WideStringC(psz2, iLen2);
+ } else if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyValue) {
+ if (args.pProperty) {
+ psz2 = pSyntax->GetCurrentString(iLen2);
+ if (iLen2 > 0)
+ pDecl->AddProperty(&args, psz2, iLen2);
+ } else if (iLen2 > 0) {
+ psz2 = pSyntax->GetCurrentString(iLen2);
+ if (iLen2 > 0) {
+ pDecl->AddProperty(&args, wsName.c_str(), wsName.GetLength(), psz2,
+ iLen2);
}
- } else {
- break;
}
+ } else {
+ break;
}
}
- pSyntax->Release();
}
+
#define FDE_CSSNONINHERITS (pComputedStyle->m_NonInheritedData)
#define FDE_CSSINHERITS (pComputedStyle->m_InheritedData)
#define FDE_CSSFONTSIZE (FDE_CSSINHERITS.m_fFontSize)
diff --git a/xfa/fde/css/fde_cssstyleselector.h b/xfa/fde/css/fde_cssstyleselector.h
index 790149c596..cb54aaed7f 100644
--- a/xfa/fde/css/fde_cssstyleselector.h
+++ b/xfa/fde/css/fde_cssstyleselector.h
@@ -93,9 +93,7 @@ class CFDE_CSSRuleCollection : public CFX_Target {
class CFDE_CSSStyleSelector : public CFX_Target {
public:
CFDE_CSSStyleSelector();
- ~CFDE_CSSStyleSelector();
-
- void Release() { delete this; }
+ ~CFDE_CSSStyleSelector() override;
void SetFontMgr(IFX_FontMgr* pFontMgr);
void SetDefFontSize(FX_FLOAT fFontSize);
diff --git a/xfa/fde/css/fde_cssstylesheet.cpp b/xfa/fde/css/fde_cssstylesheet.cpp
index af6872bbaa..b07031c354 100644
--- a/xfa/fde/css/fde_cssstylesheet.cpp
+++ b/xfa/fde/css/fde_cssstylesheet.cpp
@@ -6,6 +6,8 @@
#include "xfa/fde/css/fde_cssstylesheet.h"
+#include <memory>
+
#include "xfa/fde/css/fde_cssdatatable.h"
#include "xfa/fde/css/fde_csssyntax.h"
#include "xfa/fgas/crt/fgas_codepage.h"
@@ -120,32 +122,33 @@ int32_t CFDE_CSSStyleSheet::CountRules() const {
IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) {
return m_RuleArray.GetAt(index);
}
+
FX_BOOL CFDE_CSSStyleSheet::LoadFromStream(const CFX_WideString& szUrl,
IFX_Stream* pStream,
uint16_t wCodePage) {
- CFDE_CSSSyntaxParser* pSyntax = new CFDE_CSSSyntaxParser;
- if (pStream->GetCodePage() != wCodePage) {
+ std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser);
+ if (pStream->GetCodePage() != wCodePage)
pStream->SetCodePage(wCodePage);
- }
- FX_BOOL bRet = pSyntax->Init(pStream, 4096) && LoadFromSyntax(pSyntax);
- pSyntax->Release();
+
+ FX_BOOL bRet = pSyntax->Init(pStream, 4096) && LoadFromSyntax(pSyntax.get());
m_wCodePage = wCodePage;
m_szUrl = szUrl;
return bRet;
}
+
FX_BOOL CFDE_CSSStyleSheet::LoadFromBuffer(const CFX_WideString& szUrl,
const FX_WCHAR* pBuffer,
int32_t iBufSize,
uint16_t wCodePage) {
ASSERT(pBuffer && iBufSize > 0);
-
- CFDE_CSSSyntaxParser* pSyntax = new CFDE_CSSSyntaxParser;
- FX_BOOL bRet = pSyntax->Init(pBuffer, iBufSize) && LoadFromSyntax(pSyntax);
- pSyntax->Release();
+ std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser);
+ FX_BOOL bRet =
+ pSyntax->Init(pBuffer, iBufSize) && LoadFromSyntax(pSyntax.get());
m_wCodePage = wCodePage;
m_szUrl = szUrl;
return bRet;
}
+
FX_BOOL CFDE_CSSStyleSheet::LoadFromSyntax(CFDE_CSSSyntaxParser* pSyntax) {
Reset();
m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 1024, 0);
diff --git a/xfa/fde/css/fde_csssyntax.h b/xfa/fde/css/fde_csssyntax.h
index d14f81ea7a..a4e9249055 100644
--- a/xfa/fde/css/fde_csssyntax.h
+++ b/xfa/fde/css/fde_csssyntax.h
@@ -77,9 +77,8 @@ enum FDE_CSSSYNTAXMODE {
class CFDE_CSSSyntaxParser : public CFX_Target {
public:
CFDE_CSSSyntaxParser();
- ~CFDE_CSSSyntaxParser();
+ ~CFDE_CSSSyntaxParser() override;
- void Release() { delete this; }
FX_BOOL Init(IFX_Stream* pStream,
int32_t iCSSPlaneSize,
int32_t iTextDataSize = 32,
diff --git a/xfa/fde/fde_gedevice.h b/xfa/fde/fde_gedevice.h
index 3d14a0f8af..f69e4d106c 100644
--- a/xfa/fde/fde_gedevice.h
+++ b/xfa/fde/fde_gedevice.h
@@ -21,9 +21,7 @@ class IFX_Font;
class CFDE_RenderDevice : public CFX_Target {
public:
CFDE_RenderDevice(CFX_RenderDevice* pDevice, FX_BOOL bOwnerDevice);
- ~CFDE_RenderDevice();
-
- void Release() { delete this; }
+ ~CFDE_RenderDevice() override;
int32_t GetWidth() const;
int32_t GetHeight() const;
diff --git a/xfa/fde/fde_iterator.h b/xfa/fde/fde_iterator.h
index 4d089254ea..4f3fdf3f29 100644
--- a/xfa/fde/fde_iterator.h
+++ b/xfa/fde/fde_iterator.h
@@ -20,9 +20,7 @@ struct FDE_CANVASITEM {
class CFDE_VisualSetIterator : public CFX_Target {
public:
CFDE_VisualSetIterator();
- ~CFDE_VisualSetIterator();
-
- void Release() { delete this; }
+ ~CFDE_VisualSetIterator() override;
FX_BOOL AttachCanvas(IFDE_CanvasSet* pCanvas);
FX_BOOL FilterObjects(uint32_t dwObjects = 0xFFFFFFFF);
diff --git a/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp
index 7c989a0c6b..074a851e9f 100644
--- a/xfa/fde/fde_render.cpp
+++ b/xfa/fde/fde_render.cpp
@@ -16,11 +16,9 @@
CFDE_RenderContext::CFDE_RenderContext()
: m_eStatus(FDE_RENDERSTATUS_Reset),
m_pRenderDevice(nullptr),
- m_pBrush(nullptr),
m_Transform(),
m_pCharPos(nullptr),
- m_iCharPosCount(0),
- m_pIterator(nullptr) {
+ m_iCharPosCount(0) {
m_Transform.SetIdentity();
}
@@ -42,7 +40,7 @@ FX_BOOL CFDE_RenderContext::StartRender(CFDE_RenderDevice* pRenderDevice,
m_pRenderDevice = pRenderDevice;
m_Transform = tmDoc2Device;
if (!m_pIterator)
- m_pIterator = new CFDE_VisualSetIterator;
+ m_pIterator.reset(new CFDE_VisualSetIterator);
return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects();
}
@@ -101,12 +99,8 @@ void CFDE_RenderContext::StopRender() {
m_eStatus = FDE_RENDERSTATUS_Reset;
m_pRenderDevice = nullptr;
m_Transform.SetIdentity();
- if (m_pIterator) {
- m_pIterator->Release();
- m_pIterator = nullptr;
- }
- delete m_pBrush;
- m_pBrush = nullptr;
+ m_pIterator.reset();
+ m_pBrush.reset();
FX_Free(m_pCharPos);
m_pCharPos = nullptr;
m_iCharPosCount = 0;
@@ -126,7 +120,7 @@ void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet,
return;
if (!m_pBrush)
- m_pBrush = new CFDE_Brush;
+ m_pBrush.reset(new CFDE_Brush);
if (!m_pCharPos)
m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iCount);
@@ -142,8 +136,8 @@ void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet,
m_pBrush->SetColor(dwColor);
FDE_HDEVICESTATE hState;
FX_BOOL bClip = ApplyClip(pTextSet, hText, hState);
- m_pRenderDevice->DrawString(m_pBrush, pFont, m_pCharPos, iCount, fFontSize,
- &m_Transform);
+ m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_pCharPos, iCount,
+ fFontSize, &m_Transform);
if (bClip)
RestoreClip(hState);
}
diff --git a/xfa/fde/fde_render.h b/xfa/fde/fde_render.h
index c28b4abd16..1a80bce926 100644
--- a/xfa/fde/fde_render.h
+++ b/xfa/fde/fde_render.h
@@ -7,6 +7,8 @@
#ifndef XFA_FDE_FDE_RENDER_H_
#define XFA_FDE_FDE_RENDER_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_coordinates.h"
#include "xfa/fde/fde_gedevice.h"
#include "xfa/fde/fde_iterator.h"
@@ -24,9 +26,8 @@ enum FDE_RENDERSTATUS {
class CFDE_RenderContext : public CFX_Target {
public:
CFDE_RenderContext();
- ~CFDE_RenderContext();
+ ~CFDE_RenderContext() override;
- void Release() { delete this; }
FX_BOOL StartRender(CFDE_RenderDevice* pRenderDevice,
IFDE_CanvasSet* pCanvasSet,
const CFX_Matrix& tmDoc2Device);
@@ -42,11 +43,11 @@ class CFDE_RenderContext : public CFX_Target {
protected:
FDE_RENDERSTATUS m_eStatus;
CFDE_RenderDevice* m_pRenderDevice;
- CFDE_Brush* m_pBrush;
CFX_Matrix m_Transform;
FXTEXT_CHARPOS* m_pCharPos;
int32_t m_iCharPosCount;
- CFDE_VisualSetIterator* m_pIterator;
+ std::unique_ptr<CFDE_Brush> m_pBrush;
+ std::unique_ptr<CFDE_VisualSetIterator> m_pIterator;
};
#endif // XFA_FDE_FDE_RENDER_H_
diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp
index fc97d99125..ca108de92c 100644
--- a/xfa/fde/tto/fde_textout.cpp
+++ b/xfa/fde/tto/fde_textout.cpp
@@ -40,8 +40,7 @@ CFDE_TextOut::CFDE_TextOut()
m_iCurPiece(0),
m_iTotalLines(0),
m_pCharPos(NULL),
- m_iCharPosSize(0),
- m_pRenderDevice(NULL) {
+ m_iCharPosSize(0) {
m_pTxtBreak = new CFX_TxtBreak(FX_TXTBREAKPOLICY_None);
m_Matrix.SetIdentity();
m_rtClip.Reset();
@@ -53,9 +52,6 @@ CFDE_TextOut::~CFDE_TextOut() {
}
FX_Free(m_pCharWidths);
FX_Free(m_pEllCharWidths);
- if (m_pRenderDevice) {
- m_pRenderDevice->Release();
- }
FX_Free(m_pCharPos);
m_ttoLines.RemoveAll();
}
@@ -134,21 +130,15 @@ void CFDE_TextOut::SetLineSpace(FX_FLOAT fLineSpace) {
void CFDE_TextOut::SetDIBitmap(CFX_DIBitmap* pDIB) {
ASSERT(pDIB);
- if (m_pRenderDevice)
- m_pRenderDevice->Release();
-
+ m_pRenderDevice.reset();
CFX_FxgeDevice* device = new CFX_FxgeDevice;
device->Attach(pDIB, 0, FALSE);
- m_pRenderDevice = new CFDE_RenderDevice(device, FALSE);
+ m_pRenderDevice.reset(new CFDE_RenderDevice(device, FALSE));
}
void CFDE_TextOut::SetRenderDevice(CFX_RenderDevice* pDevice) {
ASSERT(pDevice);
-
- if (m_pRenderDevice)
- m_pRenderDevice->Release();
-
- m_pRenderDevice = new CFDE_RenderDevice(pDevice, FALSE);
+ m_pRenderDevice.reset(new CFDE_RenderDevice(pDevice, FALSE));
}
void CFDE_TextOut::SetClipRect(const CFX_Rect& rtClip) {
@@ -780,13 +770,13 @@ void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) {
}
}
void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) {
- if (m_pRenderDevice == NULL) {
+ if (!m_pRenderDevice)
return;
- }
+
int32_t iLines = m_ttoLines.GetSize();
- if (iLines < 1) {
+ if (iLines < 1)
return;
- }
+
CFDE_Brush* pBrush = new CFDE_Brush;
pBrush->SetColor(m_TxtColor);
CFDE_Pen* pPen = NULL;
@@ -846,14 +836,14 @@ void CFDE_TextOut::DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen*& pPen) {
FX_BOOL bStrikeOut = !!(m_dwStyles & FDE_TTOSTYLE_Strikeout);
FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey);
FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout);
- if (!bUnderLine && !bStrikeOut && !bHotKey) {
+ if (!bUnderLine && !bStrikeOut && !bHotKey)
return;
- }
- if (pPen == NULL) {
+
+ if (!pPen) {
pPen = new CFDE_Pen;
pPen->SetColor(m_TxtColor);
}
- CFDE_Path* pPath = new CFDE_Path;
+ std::unique_ptr<CFDE_Path> pPath(new CFDE_Path);
int32_t iLineCount = 0;
CFX_RectF rtText = pPiece->rtPiece;
CFX_PointF pt1, pt2;
@@ -913,19 +903,21 @@ void CFDE_TextOut::DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen*& pPen) {
}
}
}
- if (iLineCount > 0) {
- m_pRenderDevice->DrawPath(pPen, 1, pPath, &m_Matrix);
- }
- pPath->Release();
+ if (iLineCount > 0)
+ m_pRenderDevice->DrawPath(pPen, 1, pPath.get(), &m_Matrix);
}
+
CFDE_TTOLine::CFDE_TTOLine()
: m_bNewReload(FALSE), m_pieces(5), m_iPieceCount(0) {}
+
CFDE_TTOLine::CFDE_TTOLine(const CFDE_TTOLine& ttoLine) : m_pieces(5) {
m_bNewReload = ttoLine.m_bNewReload;
m_iPieceCount = ttoLine.m_iPieceCount;
m_pieces.Copy(ttoLine.m_pieces);
}
+
CFDE_TTOLine::~CFDE_TTOLine() {}
+
int32_t CFDE_TTOLine::AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece) {
if (index >= m_iPieceCount) {
index = m_pieces.Add(ttoPiece) + 1;
diff --git a/xfa/fde/tto/fde_textout.h b/xfa/fde/tto/fde_textout.h
index e3e87a780a..91f03e8d9b 100644
--- a/xfa/fde/tto/fde_textout.h
+++ b/xfa/fde/tto/fde_textout.h
@@ -7,6 +7,8 @@
#ifndef XFA_FDE_TTO_FDE_TEXTOUT_H_
#define XFA_FDE_TTO_FDE_TEXTOUT_H_
+#include <memory>
+
#include "core/fxge/include/fx_dib.h"
#include "core/fxge/include/fx_ge.h"
#include "xfa/fde/fde_object.h"
@@ -72,9 +74,8 @@ typedef CFX_ObjectMassArrayTemplate<CFDE_TTOLine> CFDE_TTOLineArray;
class CFDE_TextOut : public CFX_Target {
public:
CFDE_TextOut();
- ~CFDE_TextOut();
+ ~CFDE_TextOut() override;
- void Release() { delete this; }
void SetFont(IFX_Font* pFont);
void SetFontSize(FX_FLOAT fFontSize);
void SetTextColor(FX_ARGB color);
@@ -179,7 +180,7 @@ class CFDE_TextOut : public CFX_Target {
int32_t m_iTotalLines;
FXTEXT_CHARPOS* m_pCharPos;
int32_t m_iCharPosSize;
- CFDE_RenderDevice* m_pRenderDevice;
+ std::unique_ptr<CFDE_RenderDevice> m_pRenderDevice;
CFX_Int32Array m_hotKeys;
CFX_RectFArray m_rectArray;
};
diff --git a/xfa/fee/fde_txtedtengine.cpp b/xfa/fee/fde_txtedtengine.cpp
index 812817fbfa..dfbf02e881 100644
--- a/xfa/fee/fde_txtedtengine.cpp
+++ b/xfa/fee/fde_txtedtengine.cpp
@@ -7,6 +7,7 @@
#include "xfa/fee/fde_txtedtengine.h"
#include <algorithm>
+#include <memory>
#include "xfa/fde/tto/fde_textout.h"
#include "xfa/fee/fde_txtedtparag.h"
@@ -1488,7 +1489,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveEnd() {
}
FX_BOOL CFDE_TxtEdtEngine::IsFitArea(CFX_WideString& wsText) {
- CFDE_TextOut* pTextOut = new CFDE_TextOut;
+ std::unique_ptr<CFDE_TextOut> pTextOut(new CFDE_TextOut);
pTextOut->SetLineSpace(m_Param.fLineSpace);
pTextOut->SetFont(m_Param.pFont);
pTextOut->SetFontSize(m_Param.fFontSize);
@@ -1507,7 +1508,6 @@ FX_BOOL CFDE_TxtEdtEngine::IsFitArea(CFX_WideString& wsText) {
pTextOut->SetStyles(dwStyle);
wsText += L"\n";
pTextOut->CalcLogicSize(wsText.c_str(), wsText.GetLength(), rcText);
- pTextOut->Release();
wsText.Delete(wsText.GetLength() - 1);
if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz) &&
(rcText.width > m_Param.fPlateWidth)) {
diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp
index e47fb1b739..9f80336efa 100644
--- a/xfa/fwl/basewidget/fwl_editimp.cpp
+++ b/xfa/fwl/basewidget/fwl_editimp.cpp
@@ -7,6 +7,7 @@
#include "xfa/fwl/basewidget/fwl_editimp.h"
#include <algorithm>
+#include <memory>
#include <vector>
#include "xfa/fde/fde_gedevice.h"
@@ -1082,13 +1083,13 @@ void CFWL_EditImp::DrawContent(CFX_Graphics* pGraphics,
CFX_RenderDevice* pRenderDev = pGraphics->GetRenderDevice();
if (!pRenderDev)
return;
- CFDE_RenderDevice* pRenderDevice = new CFDE_RenderDevice(pRenderDev, FALSE);
- CFDE_RenderContext* pRenderContext = new CFDE_RenderContext;
+
+ std::unique_ptr<CFDE_RenderDevice> pRenderDevice(
+ new CFDE_RenderDevice(pRenderDev, FALSE));
+ std::unique_ptr<CFDE_RenderContext> pRenderContext(new CFDE_RenderContext);
pRenderDevice->SetClipRect(rtClip);
- pRenderContext->StartRender(pRenderDevice, pPage, mt);
- pRenderContext->DoRender(NULL);
- pRenderContext->Release();
- pRenderDevice->Release();
+ pRenderContext->StartRender(pRenderDevice.get(), pPage, mt);
+ pRenderContext->DoRender(nullptr);
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) {
pGraphics->RestoreGraphState();
CFX_Path path;
@@ -1110,6 +1111,7 @@ void CFWL_EditImp::DrawContent(CFX_Graphics* pGraphics,
}
pGraphics->RestoreGraphState();
}
+
void CFWL_EditImp::UpdateEditEngine() {
UpdateEditParams();
UpdateEditLayout();
diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp
index fb1132beef..764c86e314 100644
--- a/xfa/fwl/theme/cfwl_widgettp.cpp
+++ b/xfa/fwl/theme/cfwl_widgettp.cpp
@@ -83,9 +83,9 @@ FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) {
return TRUE;
}
FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) {
- if (!m_pTextOut) {
+ if (!m_pTextOut)
InitTTO();
- }
+
int32_t iLen = pParams->m_wsText.GetLength();
if (iLen <= 0)
return FALSE;
@@ -183,9 +183,8 @@ FWL_Error CFWL_WidgetTP::Initialize() {
return FWL_Error::Succeeded;
}
FWL_Error CFWL_WidgetTP::Finalize() {
- if (!m_pTextOut) {
+ if (!m_pTextOut)
FinalizeTTO();
- }
return FWL_Error::Succeeded;
}
CFWL_WidgetTP::~CFWL_WidgetTP() {}
@@ -193,9 +192,9 @@ FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget,
const FX_WCHAR* strFont,
FX_FLOAT fFontSize,
FX_ARGB rgbFont) {
- if (!m_pTextOut) {
+ if (!m_pTextOut)
return FWL_Error::Succeeded;
- }
+
m_pFDEFont = CFWL_FontManager::GetInstance()->FindFont(strFont, 0, 0);
m_pTextOut->SetFont(m_pFDEFont);
m_pTextOut->SetFontSize(fFontSize);
@@ -206,9 +205,9 @@ FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget,
IFX_Font* pFont,
FX_FLOAT fFontSize,
FX_ARGB rgbFont) {
- if (!m_pTextOut) {
+ if (!m_pTextOut)
return FWL_Error::Succeeded;
- }
+
m_pTextOut->SetFont(pFont);
m_pTextOut->SetFontSize(fFontSize);
m_pTextOut->SetTextColor(rgbFont);
@@ -217,26 +216,26 @@ FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget,
IFX_Font* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) {
return m_pFDEFont;
}
+
CFWL_WidgetTP::CFWL_WidgetTP()
- : m_dwRefCount(1), m_pTextOut(NULL), m_pFDEFont(NULL), m_dwThemeID(0) {}
+ : m_dwRefCount(1), m_pFDEFont(nullptr), m_dwThemeID(0) {}
+
FWL_Error CFWL_WidgetTP::InitTTO() {
- if (m_pTextOut) {
+ if (m_pTextOut)
return FWL_Error::Succeeded;
- }
+
m_pFDEFont =
CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0);
- m_pTextOut = new CFDE_TextOut;
+ m_pTextOut.reset(new CFDE_TextOut);
m_pTextOut->SetFont(m_pFDEFont);
m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize);
m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor);
m_pTextOut->SetEllipsisString(L"...");
return FWL_Error::Succeeded;
}
+
FWL_Error CFWL_WidgetTP::FinalizeTTO() {
- if (m_pTextOut) {
- m_pTextOut->Release();
- m_pTextOut = NULL;
- }
+ m_pTextOut.reset();
return FWL_Error::Succeeded;
}
diff --git a/xfa/fwl/theme/cfwl_widgettp.h b/xfa/fwl/theme/cfwl_widgettp.h
index edb793def9..b66e19344e 100644
--- a/xfa/fwl/theme/cfwl_widgettp.h
+++ b/xfa/fwl/theme/cfwl_widgettp.h
@@ -220,7 +220,7 @@ class CFWL_WidgetTP {
FWLTHEME_STATE eState,
CFX_Matrix* pMatrix = NULL);
uint32_t m_dwRefCount;
- CFDE_TextOut* m_pTextOut;
+ std::unique_ptr<CFDE_TextOut> m_pTextOut;
IFX_Font* m_pFDEFont;
FX_FLOAT m_fValue;
uint32_t m_dwValue;
diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
index ad8cabad3a..fd3757ace5 100644
--- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/app/xfa_ffwidgetacc.h"
#include <algorithm>
+#include <memory>
#include "xfa/fde/tto/fde_textout.h"
#include "xfa/fde/xml/fde_xml_imp.h"
@@ -101,50 +102,30 @@ class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData {
int32_t m_iImageXDpi;
int32_t m_iImageYDpi;
};
+
class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData {
public:
- CXFA_FieldLayoutData()
- : m_pCapTextLayout(NULL),
- m_pCapTextProvider(NULL),
- m_pTextOut(NULL),
- m_pFieldSplitArray(NULL) {}
- ~CXFA_FieldLayoutData() {
- if (m_pCapTextLayout) {
- delete m_pCapTextLayout;
- }
- m_pCapTextLayout = NULL;
- if (m_pCapTextProvider) {
- delete m_pCapTextProvider;
- }
- m_pCapTextProvider = NULL;
- if (m_pTextOut) {
- m_pTextOut->Release();
- }
- m_pTextOut = NULL;
- if (m_pFieldSplitArray) {
- m_pFieldSplitArray->RemoveAll();
- delete m_pFieldSplitArray;
- m_pFieldSplitArray = NULL;
- }
- }
+ CXFA_FieldLayoutData() {}
+ ~CXFA_FieldLayoutData() {}
+
FX_BOOL LoadCaption(CXFA_WidgetAcc* pAcc) {
- if (m_pCapTextLayout) {
+ if (m_pCapTextLayout)
return TRUE;
- }
CXFA_Caption caption = pAcc->GetCaption();
- if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) {
- m_pCapTextProvider =
- new CXFA_TextProvider(pAcc, XFA_TEXTPROVIDERTYPE_Caption);
- m_pCapTextLayout = new CXFA_TextLayout(m_pCapTextProvider);
- return TRUE;
- }
- return FALSE;
+ if (!caption || caption.GetPresence() == XFA_ATTRIBUTEENUM_Hidden)
+ return FALSE;
+ m_pCapTextProvider.reset(
+ new CXFA_TextProvider(pAcc, XFA_TEXTPROVIDERTYPE_Caption));
+ m_pCapTextLayout.reset(new CXFA_TextLayout(m_pCapTextProvider.get()));
+ return TRUE;
}
- CXFA_TextLayout* m_pCapTextLayout;
- CXFA_TextProvider* m_pCapTextProvider;
- CFDE_TextOut* m_pTextOut;
- CFX_FloatArray* m_pFieldSplitArray;
+
+ std::unique_ptr<CXFA_TextLayout> m_pCapTextLayout;
+ std::unique_ptr<CXFA_TextProvider> m_pCapTextProvider;
+ std::unique_ptr<CFDE_TextOut> m_pTextOut;
+ std::unique_ptr<CFX_FloatArray> m_pFieldSplitArray;
};
+
class CXFA_TextEditData : public CXFA_FieldLayoutData {
public:
};
@@ -763,7 +744,7 @@ void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) {
iCapPlacement == XFA_ATTRIBUTEENUM_Bottom;
const bool bReserveExit = fCapReserve > 0.01;
CXFA_TextLayout* pCapTextLayout =
- ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pCapTextLayout;
+ static_cast<CXFA_FieldLayoutData*>(m_pLayoutData)->m_pCapTextLayout.get();
if (pCapTextLayout) {
if (!bVert && eUIType != XFA_ELEMENT_Button) {
szCap.x = fCapReserve;
@@ -886,8 +867,8 @@ void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) {
CXFA_FieldLayoutData* layoutData =
static_cast<CXFA_FieldLayoutData*>(m_pLayoutData);
if (!layoutData->m_pTextOut) {
- layoutData->m_pTextOut = new CFDE_TextOut;
- CFDE_TextOut* pTextOut = layoutData->m_pTextOut;
+ layoutData->m_pTextOut.reset(new CFDE_TextOut);
+ CFDE_TextOut* pTextOut = layoutData->m_pTextOut.get();
pTextOut->SetFont(GetFDEFont());
pTextOut->SetFontSize(fFontSize);
pTextOut->SetLineBreakTolerance(fFontSize * 0.2f);
@@ -1264,12 +1245,13 @@ FX_BOOL CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex,
iLinesCount =
((CXFA_FieldLayoutData*)m_pLayoutData)->m_pTextOut->GetTotalLines();
}
- if (!((CXFA_FieldLayoutData*)m_pLayoutData)->m_pFieldSplitArray) {
- ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pFieldSplitArray =
- new CFX_FloatArray;
+ if (!static_cast<CXFA_FieldLayoutData*>(m_pLayoutData)->m_pFieldSplitArray) {
+ static_cast<CXFA_FieldLayoutData*>(m_pLayoutData)
+ ->m_pFieldSplitArray.reset(new CFX_FloatArray);
}
CFX_FloatArray* pFieldArray =
- ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pFieldSplitArray;
+ static_cast<CXFA_FieldLayoutData*>(m_pLayoutData)
+ ->m_pFieldSplitArray.get();
int32_t iFieldSplitCount = pFieldArray->GetSize();
for (int32_t i = 0; i < iBlockIndex * 3; i += 3) {
iLinesCount -= (int32_t)pFieldArray->GetAt(i + 1);
@@ -1486,8 +1468,9 @@ FX_BOOL CXFA_WidgetAcc::LoadCaption() {
}
CXFA_TextLayout* CXFA_WidgetAcc::GetCaptionTextLayout() {
return m_pLayoutData
- ? ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pCapTextLayout
- : NULL;
+ ? static_cast<CXFA_FieldLayoutData*>(m_pLayoutData)
+ ->m_pCapTextLayout.get()
+ : nullptr;
}
CXFA_TextLayout* CXFA_WidgetAcc::GetTextLayout() {
return m_pLayoutData ? ((CXFA_TextLayoutData*)m_pLayoutData)->m_pTextLayout
diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp
index fac873cac9..df09fb504a 100644
--- a/xfa/fxfa/app/xfa_fwltheme.cpp
+++ b/xfa/fxfa/app/xfa_fwltheme.cpp
@@ -44,7 +44,6 @@ CXFA_FFWidget* XFA_ThemeGetOuterWidget(IFWL_Widget* pWidget) {
return NULL;
}
CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp) : m_pApp(pApp) {
- m_pTextOut = NULL;
m_dwCapacity = 0;
m_fCapacity = 0;
m_pCalendarFont = NULL;
@@ -77,7 +76,7 @@ CXFA_FWLTheme::~CXFA_FWLTheme() {
delete m_pBarcodeTP;
}
FWL_Error CXFA_FWLTheme::Initialize() {
- m_pTextOut = new CFDE_TextOut;
+ m_pTextOut.reset(new CFDE_TextOut);
for (size_t i = 0; !m_pCalendarFont && i < FX_ArraySize(g_FWLTheme_CalFonts);
++i) {
m_pCalendarFont = IFX_Font::LoadFont(g_FWLTheme_CalFonts[i], 0, 0,
@@ -98,13 +97,10 @@ FWL_Error CXFA_FWLTheme::Initialize() {
return FWL_Error::Succeeded;
}
FWL_Error CXFA_FWLTheme::Finalize() {
- if (m_pTextOut) {
- m_pTextOut->Release();
- m_pTextOut = NULL;
- }
+ m_pTextOut.reset();
if (m_pCalendarFont) {
m_pCalendarFont->Release();
- m_pCalendarFont = NULL;
+ m_pCalendarFont = nullptr;
}
FWLTHEME_Release();
return FWL_Error::Succeeded;
@@ -386,8 +382,6 @@ FX_BOOL CXFA_FWLTheme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) {
m_pTextOut->SetTextColor(pAcc->GetTextColor());
if (!pParams)
return FALSE;
- if (!m_pTextOut)
- return FALSE;
m_pTextOut->SetAlignment(pParams->m_iTTOAlign);
m_pTextOut->SetStyles(pParams->m_dwTTOStyles);
m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(),
diff --git a/xfa/fxfa/app/xfa_fwltheme.h b/xfa/fxfa/app/xfa_fwltheme.h
index 7d58b43c9b..319df8dfa5 100644
--- a/xfa/fxfa/app/xfa_fwltheme.h
+++ b/xfa/fxfa/app/xfa_fwltheme.h
@@ -7,6 +7,8 @@
#ifndef XFA_FXFA_APP_XFA_FWLTHEME_H_
#define XFA_FXFA_APP_XFA_FWLTHEME_H_
+#include <memory>
+
#include "xfa/fwl/core/ifwl_themeprovider.h"
#include "xfa/fwl/theme/cfwl_barcodetp.h"
#include "xfa/fwl/theme/cfwl_carettp.h"
@@ -77,7 +79,7 @@ class CXFA_FWLTheme : public IFWL_ThemeProvider {
CFWL_PushButtonTP* m_pPushButtonTP;
CFWL_CaretTP* m_pCaretTP;
CFWL_BarcodeTP* m_pBarcodeTP;
- CFDE_TextOut* m_pTextOut;
+ std::unique_ptr<CFDE_TextOut> m_pTextOut;
FX_FLOAT m_fCapacity;
uint32_t m_dwCapacity;
IFX_Font* m_pCalendarFont;
diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp
index 01b16a93a2..1f34b45670 100644
--- a/xfa/fxfa/app/xfa_textlayout.cpp
+++ b/xfa/fxfa/app/xfa_textlayout.cpp
@@ -32,11 +32,13 @@ void CXFA_TextParseContext::SetDecls(const CFDE_CSSDeclaration** ppDeclArray,
FXSYS_memcpy(m_ppMatchedDecls, ppDeclArray,
iDeclCount * sizeof(CFDE_CSSDeclaration*));
}
+
+CXFA_TextParser::CXFA_TextParser() : m_pAllocator(NULL), m_pUASheet(NULL) {}
+
CXFA_TextParser::~CXFA_TextParser() {
if (m_pUASheet)
m_pUASheet->Release();
- if (m_pSelector)
- m_pSelector->Release();
+
delete m_pAllocator;
FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition();
while (ps) {
@@ -62,14 +64,14 @@ void CXFA_TextParser::Reset() {
m_pAllocator = nullptr;
}
void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
- if (pTextProvider == NULL) {
+ if (!pTextProvider)
return;
- }
- if (m_pSelector == NULL) {
+
+ if (!m_pSelector) {
CXFA_FFDoc* pDoc = pTextProvider->GetDocNode();
IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr();
ASSERT(pFontMgr);
- m_pSelector = new CFDE_CSSStyleSelector;
+ m_pSelector.reset(new CFDE_CSSStyleSelector);
m_pSelector->SetFontMgr(pFontMgr);
FX_FLOAT fFontSize = 10;
CXFA_Font font = pTextProvider->GetFontNode();
@@ -78,7 +80,7 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
}
m_pSelector->SetDefFontSize(fFontSize);
}
- if (m_pUASheet == NULL) {
+ if (!m_pUASheet) {
m_pUASheet = LoadDefaultSheetStyle();
m_pSelector->SetStyleSheet(FDE_CSSSTYLESHEETGROUP_UserAgent, m_pUASheet);
m_pSelector->UpdateStyleIndex(FDE_CSSMEDIATYPE_ALL);
@@ -1183,13 +1185,13 @@ FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice,
if (!pFxDevice)
return FALSE;
- CFDE_RenderDevice* pDevice = new CFDE_RenderDevice(pFxDevice, FALSE);
+ std::unique_ptr<CFDE_RenderDevice> pDevice(
+ new CFDE_RenderDevice(pFxDevice, FALSE));
FDE_HDEVICESTATE state = pDevice->SaveState();
pDevice->SetClipRect(rtClip);
- CFDE_Brush* pSolidBrush = new CFDE_Brush;
- CFDE_Pen* pPen = new CFDE_Pen;
- ASSERT(pDevice);
+ std::unique_ptr<CFDE_Brush> pSolidBrush(new CFDE_Brush);
+ std::unique_ptr<CFDE_Pen> pPen(new CFDE_Pen);
if (m_pieceLines.GetSize() == 0) {
int32_t iBlockCount = CountBlocks();
for (int32_t i = 0; i < iBlockCount; i++) {
@@ -1226,17 +1228,16 @@ FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice,
iCharCount = iChars;
}
FXSYS_memset(pCharPos, 0, iCharCount * sizeof(FXTEXT_CHARPOS));
- RenderString(pDevice, pSolidBrush, pPieceLine, j, pCharPos, tmDoc2Device);
+ RenderString(pDevice.get(), pSolidBrush.get(), pPieceLine, j, pCharPos,
+ tmDoc2Device);
}
for (j = 0; j < iPieces; j++) {
- RenderPath(pDevice, pPen, pPieceLine, j, pCharPos, tmDoc2Device);
+ RenderPath(pDevice.get(), pPen.get(), pPieceLine, j, pCharPos,
+ tmDoc2Device);
}
}
pDevice->RestoreState(state);
FX_Free(pCharPos);
- delete pSolidBrush;
- delete pPen;
- pDevice->Release();
return iPieceLines;
}
void CXFA_TextLayout::UpdateAlign(FX_FLOAT fHeight, FX_FLOAT fBottom) {
@@ -1817,6 +1818,7 @@ void CXFA_TextLayout::RenderString(CFDE_RenderDevice* pDevice,
}
pPieceLine->m_charCounts.Add(iCount);
}
+
void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice,
CFDE_Pen* pPen,
CXFA_PieceLine* pPieceLine,
@@ -1830,7 +1832,7 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice,
return;
}
pPen->SetColor(pPiece->dwColor);
- CFDE_Path* pPath = new CFDE_Path;
+ std::unique_ptr<CFDE_Path> pPath(new CFDE_Path);
int32_t iChars = GetDisplayPos(pPiece, pCharPos);
if (iChars > 0) {
CFX_PointF pt1, pt2;
@@ -1870,7 +1872,7 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice,
} else {
if (bNoLineThrough &&
(bNoUnderline || pPiece->iPeriod != XFA_ATTRIBUTEENUM_All)) {
- goto XFA_RenderPathRet;
+ return;
}
int32_t iCharsTmp = 0;
int32_t iPiecePrev = iPiece, iPieceNext = iPiece;
@@ -1882,7 +1884,7 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice,
}
}
if (iCharsTmp == 0) {
- goto XFA_RenderPathRet;
+ return;
}
iCharsTmp = 0;
int32_t iPieces = pPieceLine->m_textPieces.GetSize();
@@ -1894,20 +1896,20 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice,
}
}
if (iCharsTmp == 0) {
- goto XFA_RenderPathRet;
+ return;
}
FX_FLOAT fOrgX = 0.0f, fEndX = 0.0f;
pPiece = pPieceLine->m_textPieces.GetAt(iPiecePrev);
iChars = GetDisplayPos(pPiece, pCharPos);
if (iChars < 1) {
- goto XFA_RenderPathRet;
+ return;
}
fOrgX = pCharPos[iChars - 1].m_OriginX +
pCharPos[iChars - 1].m_FontCharWidth * pPiece->fFontSize / 1000.0f;
pPiece = pPieceLine->m_textPieces.GetAt(iPieceNext);
iChars = GetDisplayPos(pPiece, pCharPos);
if (iChars < 1) {
- goto XFA_RenderPathRet;
+ return;
}
fEndX = pCharPos[0].m_OriginX;
CFX_PointF pt1, pt2;
@@ -1926,10 +1928,9 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice,
fEndY += 2.0f;
}
}
- pDevice->DrawPath(pPen, 1, pPath, &tmDoc2Device);
-XFA_RenderPathRet:
- pPath->Release();
+ pDevice->DrawPath(pPen, 1, pPath.get(), &tmDoc2Device);
}
+
int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece,
FXTEXT_CHARPOS* pCharPos,
FX_BOOL bCharCode) {
diff --git a/xfa/fxfa/app/xfa_textlayout.h b/xfa/fxfa/app/xfa_textlayout.h
index 17450ddeab..4d03aee302 100644
--- a/xfa/fxfa/app/xfa_textlayout.h
+++ b/xfa/fxfa/app/xfa_textlayout.h
@@ -8,6 +8,7 @@
#define XFA_FXFA_APP_XFA_TEXTLAYOUT_H_
#include <map>
+#include <memory>
#include "xfa/fde/css/fde_css.h"
#include "xfa/fde/fde_gedevice.h"
@@ -79,7 +80,7 @@ class CXFA_TextParseContext : public CFX_Target {
class CXFA_TextParser {
public:
- CXFA_TextParser() : m_pAllocator(NULL), m_pSelector(NULL), m_pUASheet(NULL) {}
+ CXFA_TextParser();
virtual ~CXFA_TextParser();
void Reset();
void DoParse(CFDE_XMLNode* pXMLContainer, CXFA_TextProvider* pTextProvider);
@@ -131,7 +132,7 @@ class CXFA_TextParser {
IFDE_CSSStyleSheet* LoadDefaultSheetStyle();
IFDE_CSSComputedStyle* CreateStyle(IFDE_CSSComputedStyle* pParentStyle);
IFX_MemoryAllocator* m_pAllocator;
- CFDE_CSSStyleSelector* m_pSelector;
+ std::unique_ptr<CFDE_CSSStyleSelector> m_pSelector;
IFDE_CSSStyleSheet* m_pUASheet;
CFX_MapPtrTemplate<CFDE_XMLNode*, CXFA_TextParseContext*>
m_mapXMLNodeToParseContext;