summaryrefslogtreecommitdiff
path: root/xfa/fde
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2017-01-05 12:57:00 -0800
committerCommit bot <commit-bot@chromium.org>2017-01-05 12:57:00 -0800
commite647799f6a2f7f747c9f55d9f0ce08dcdfbd53f4 (patch)
tree282c502bd9f807f385d0cbcc1692bb475c8a4df1 /xfa/fde
parent6bb3b894488fd6f38c096b708980a9f08286ac5c (diff)
downloadpdfium-e647799f6a2f7f747c9f55d9f0ce08dcdfbd53f4.tar.xz
Properly ref-count CFGAS_GEFont with CFX_RetainPtr.
We worry about cyclical references, but no leaks found. Review-Url: https://codereview.chromium.org/2609423003
Diffstat (limited to 'xfa/fde')
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp3
-rw-r--r--xfa/fde/cfde_txtedttextset.cpp7
-rw-r--r--xfa/fde/cfde_txtedttextset.h2
-rw-r--r--xfa/fde/fde_gedevice.cpp6
-rw-r--r--xfa/fde/fde_gedevice.h8
-rw-r--r--xfa/fde/fde_render.cpp2
-rw-r--r--xfa/fde/fde_visualset.h3
-rw-r--r--xfa/fde/ifde_txtedtengine.h3
-rw-r--r--xfa/fde/tto/fde_textout.cpp2
-rw-r--r--xfa/fde/tto/fde_textout.h4
10 files changed, 22 insertions, 18 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index 1d357e928f..342913d820 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -34,7 +34,6 @@ FDE_TXTEDTPARAMS::FDE_TXTEDTPARAMS()
dwLayoutStyles(0),
dwAlignment(0),
dwMode(0),
- pFont(nullptr),
fFontSize(10.0f),
dwFontColor(0xff000000),
fLineSpace(10.0f),
@@ -48,6 +47,8 @@ FDE_TXTEDTPARAMS::FDE_TXTEDTPARAMS()
fCharSpace(0),
pEventSink(nullptr) {}
+FDE_TXTEDTPARAMS::~FDE_TXTEDTPARAMS() {}
+
FDE_TXTEDT_TEXTCHANGE_INFO::FDE_TXTEDT_TEXTCHANGE_INFO() {}
FDE_TXTEDT_TEXTCHANGE_INFO::~FDE_TXTEDT_TEXTCHANGE_INFO() {}
diff --git a/xfa/fde/cfde_txtedttextset.cpp b/xfa/fde/cfde_txtedttextset.cpp
index 33da0c5a8f..4149a6df20 100644
--- a/xfa/fde/cfde_txtedttextset.cpp
+++ b/xfa/fde/cfde_txtedttextset.cpp
@@ -8,6 +8,7 @@
#include "xfa/fde/cfde_txtedtengine.h"
#include "xfa/fde/cfde_txtedtpage.h"
+#include "xfa/fgas/font/cfgas_gefont.h"
CFDE_TxtEdtTextSet::CFDE_TxtEdtTextSet(CFDE_TxtEdtPage* pPage)
: m_pPage(pPage) {}
@@ -25,14 +26,14 @@ void CFDE_TxtEdtTextSet::GetRect(FDE_TEXTEDITPIECE* pPiece, CFX_RectF& rt) {
int32_t CFDE_TxtEdtTextSet::GetString(FDE_TEXTEDITPIECE* pPiece,
CFX_WideString& wsText) {
FX_WCHAR* pBuffer = wsText.GetBuffer(pPiece->nCount);
- for (int32_t i = 0; i < pPiece->nCount; i++) {
+ for (int32_t i = 0; i < pPiece->nCount; i++)
pBuffer[i] = m_pPage->GetChar(pPiece, i);
- }
+
wsText.ReleaseBuffer(pPiece->nCount);
return pPiece->nCount;
}
-CFGAS_GEFont* CFDE_TxtEdtTextSet::GetFont() {
+CFX_RetainPtr<CFGAS_GEFont> CFDE_TxtEdtTextSet::GetFont() {
return m_pPage->GetEngine()->GetEditParams()->pFont;
}
diff --git a/xfa/fde/cfde_txtedttextset.h b/xfa/fde/cfde_txtedttextset.h
index 14979dcf14..6c6266642b 100644
--- a/xfa/fde/cfde_txtedttextset.h
+++ b/xfa/fde/cfde_txtedttextset.h
@@ -22,7 +22,7 @@ class CFDE_TxtEdtTextSet : public IFDE_TextSet {
// IFDE_TextSet
int32_t GetString(FDE_TEXTEDITPIECE* pPiece, CFX_WideString& wsText) override;
- CFGAS_GEFont* GetFont() override;
+ CFX_RetainPtr<CFGAS_GEFont> GetFont() override;
FX_FLOAT GetFontSize() override;
FX_ARGB GetFontColor() override;
int32_t GetDisplayPos(FDE_TEXTEDITPIECE* pPiece,
diff --git a/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp
index bf34135f3e..081f00a036 100644
--- a/xfa/fde/fde_gedevice.cpp
+++ b/xfa/fde/fde_gedevice.cpp
@@ -105,7 +105,7 @@ bool CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib,
return !!handle;
}
bool CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush,
- CFGAS_GEFont* pFont,
+ const CFX_RetainPtr<CFGAS_GEFont>& pFont,
const FXTEXT_CHARPOS* pCharPos,
int32_t iCount,
FX_FLOAT fFontSize,
@@ -126,8 +126,8 @@ bool CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush,
}
}
FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos;
- CFGAS_GEFont* pCurFont = nullptr;
- CFGAS_GEFont* pSTFont = nullptr;
+ CFX_RetainPtr<CFGAS_GEFont> pCurFont;
+ CFX_RetainPtr<CFGAS_GEFont> pSTFont;
FXTEXT_CHARPOS* pCurCP = nullptr;
int32_t iCurCount = 0;
diff --git a/xfa/fde/fde_gedevice.h b/xfa/fde/fde_gedevice.h
index cb8e3fa42a..35efab2b2d 100644
--- a/xfa/fde/fde_gedevice.h
+++ b/xfa/fde/fde_gedevice.h
@@ -9,11 +9,11 @@
#include "core/fxge/cfx_renderdevice.h"
#include "xfa/fgas/crt/fgas_memory.h"
+#include "xfa/fgas/font/cfgas_gefont.h"
class CFDE_Brush;
class CFDE_Path;
class CFDE_Pen;
-class CFGAS_GEFont;
class CFX_GraphStateData;
class CFDE_RenderDevice : public CFX_Target {
@@ -39,7 +39,7 @@ class CFDE_RenderDevice : public CFX_Target {
const CFX_Matrix* pImgMatrix = nullptr,
const CFX_Matrix* pDevMatrix = nullptr);
bool DrawString(CFDE_Brush* pBrush,
- CFGAS_GEFont* pFont,
+ const CFX_RetainPtr<CFGAS_GEFont>& pFont,
const FXTEXT_CHARPOS* pCharPos,
int32_t iCount,
FX_FLOAT fFontSize,
@@ -100,13 +100,13 @@ class CFDE_RenderDevice : public CFX_Target {
const CFX_Matrix* pMatrix = nullptr);
bool DrawSolidString(CFDE_Brush* pBrush,
- CFGAS_GEFont* pFont,
+ const CFX_RetainPtr<CFGAS_GEFont>& pFont,
const FXTEXT_CHARPOS* pCharPos,
int32_t iCount,
FX_FLOAT fFontSize,
const CFX_Matrix* pMatrix);
bool DrawStringPath(CFDE_Brush* pBrush,
- CFGAS_GEFont* pFont,
+ const CFX_RetainPtr<CFGAS_GEFont>& pFont,
const FXTEXT_CHARPOS* pCharPos,
int32_t iCount,
FX_FLOAT fFontSize,
diff --git a/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp
index 9528219b45..1cdea421e1 100644
--- a/xfa/fde/fde_render.cpp
+++ b/xfa/fde/fde_render.cpp
@@ -108,7 +108,7 @@ void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet,
ASSERT(m_pRenderDevice);
ASSERT(pTextSet && pText);
- CFGAS_GEFont* pFont = pTextSet->GetFont();
+ CFX_RetainPtr<CFGAS_GEFont> pFont = pTextSet->GetFont();
if (!pFont)
return;
diff --git a/xfa/fde/fde_visualset.h b/xfa/fde/fde_visualset.h
index 481f4a5cbb..77aa6c7253 100644
--- a/xfa/fde/fde_visualset.h
+++ b/xfa/fde/fde_visualset.h
@@ -7,6 +7,7 @@
#ifndef XFA_FDE_FDE_VISUALSET_H_
#define XFA_FDE_FDE_VISUALSET_H_
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxge/fx_dib.h"
@@ -48,7 +49,7 @@ class IFDE_TextSet : public IFDE_VisualSet {
public:
virtual int32_t GetString(FDE_TEXTEDITPIECE* hText,
CFX_WideString& wsText) = 0;
- virtual CFGAS_GEFont* GetFont() = 0;
+ virtual CFX_RetainPtr<CFGAS_GEFont> GetFont() = 0;
virtual FX_FLOAT GetFontSize() = 0;
virtual FX_ARGB GetFontColor() = 0;
virtual int32_t GetDisplayPos(FDE_TEXTEDITPIECE* hText,
diff --git a/xfa/fde/ifde_txtedtengine.h b/xfa/fde/ifde_txtedtengine.h
index 12f0cd88bf..6940a8c7d6 100644
--- a/xfa/fde/ifde_txtedtengine.h
+++ b/xfa/fde/ifde_txtedtengine.h
@@ -72,6 +72,7 @@ enum FDE_TXTEDIT_LINEEND {
struct FDE_TXTEDTPARAMS {
FDE_TXTEDTPARAMS();
+ ~FDE_TXTEDTPARAMS();
FX_FLOAT fPlateWidth;
FX_FLOAT fPlateHeight;
@@ -79,7 +80,7 @@ struct FDE_TXTEDTPARAMS {
uint32_t dwLayoutStyles;
uint32_t dwAlignment;
uint32_t dwMode;
- CFGAS_GEFont* pFont;
+ CFX_RetainPtr<CFGAS_GEFont> pFont;
FX_FLOAT fFontSize;
FX_ARGB dwFontColor;
FX_FLOAT fLineSpace;
diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp
index cf541a289c..1081526148 100644
--- a/xfa/fde/tto/fde_textout.cpp
+++ b/xfa/fde/tto/fde_textout.cpp
@@ -46,7 +46,7 @@ CFDE_TextOut::~CFDE_TextOut() {
m_ttoLines.RemoveAll(false);
}
-void CFDE_TextOut::SetFont(CFGAS_GEFont* pFont) {
+void CFDE_TextOut::SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont) {
ASSERT(pFont);
m_pFont = pFont;
m_pTxtBreak->SetFont(pFont);
diff --git a/xfa/fde/tto/fde_textout.h b/xfa/fde/tto/fde_textout.h
index 684a6411fa..f9eeb82ddc 100644
--- a/xfa/fde/tto/fde_textout.h
+++ b/xfa/fde/tto/fde_textout.h
@@ -79,7 +79,7 @@ class CFDE_TextOut : public CFX_Target {
CFDE_TextOut();
~CFDE_TextOut() override;
- void SetFont(CFGAS_GEFont* pFont);
+ void SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont);
void SetFontSize(FX_FLOAT fFontSize);
void SetTextColor(FX_ARGB color);
void SetStyles(uint32_t dwStyles);
@@ -153,7 +153,7 @@ class CFDE_TextOut : public CFX_Target {
void DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen*& pPen);
std::unique_ptr<CFX_TxtBreak> m_pTxtBreak;
- CFGAS_GEFont* m_pFont; // not owned.
+ CFX_RetainPtr<CFGAS_GEFont> m_pFont;
FX_FLOAT m_fFontSize;
FX_FLOAT m_fLineSpace;
FX_FLOAT m_fLinePos;