summaryrefslogtreecommitdiff
path: root/xfa/fwl
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fwl')
-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
3 files changed, 24 insertions, 23 deletions
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;