diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-08-21 15:21:05 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-23 15:46:39 +0000 |
commit | 6b0287d245995d04a2a9a44213b22fce9ca8c237 (patch) | |
tree | 0c278f27eaca99adc72cfad210a879649a55753e | |
parent | 12db7515f17228798d1aa38fce0fee3e7d2d36b6 (diff) | |
download | pdfium-6b0287d245995d04a2a9a44213b22fce9ca8c237.tar.xz |
Move m_pTextBreak to be a member of CFDE_TxtEdtEngine
Previously text break was a unique_ptr inside the CFDE_TxtEdtEngine.
This CL converts it to be a member instead of a unique_ptr. We never
replace the pointer after it's created.
Change-Id: I89ab73e81c63c24abfacd38a1141db6473d77640
Reviewed-on: https://pdfium-review.googlesource.com/11530
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r-- | xfa/fde/cfde_txtedtengine.cpp | 32 | ||||
-rw-r--r-- | xfa/fde/cfde_txtedtengine.h | 6 |
2 files changed, 17 insertions, 21 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp index 469ec87cf7..be0270960d 100644 --- a/xfa/fde/cfde_txtedtengine.cpp +++ b/xfa/fde/cfde_txtedtengine.cpp @@ -15,7 +15,6 @@ #include "xfa/fde/cfde_txtedtbuf.h" #include "xfa/fde/cfde_txtedtpage.h" #include "xfa/fde/cfde_txtedtparag.h" -#include "xfa/fgas/layout/cfx_txtbreak.h" #include "xfa/fwl/cfwl_edit.h" namespace { @@ -145,9 +144,6 @@ CFDE_TxtEdtEngine::~CFDE_TxtEdtEngine() { } void CFDE_TxtEdtEngine::SetEditParams(const FDE_TXTEDTPARAMS& params) { - if (!m_pTextBreak) - m_pTextBreak = pdfium::MakeUnique<CFX_TxtBreak>(); - m_Param = params; m_bAutoLineEnd = true; UpdateTxtBreak(); @@ -807,7 +803,7 @@ void CFDE_TxtEdtEngine::UpdatePages() { } void CFDE_TxtEdtEngine::UpdateTxtBreak() { - uint32_t dwStyle = m_pTextBreak->GetLayoutStyles(); + uint32_t dwStyle = m_TextBreak.GetLayoutStyles(); if (m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines) dwStyle &= ~FX_LAYOUTSTYLE_SingleLine; else @@ -818,7 +814,7 @@ void CFDE_TxtEdtEngine::UpdateTxtBreak() { else dwStyle &= ~FX_LAYOUTSTYLE_CombText; - m_pTextBreak->SetLayoutStyles(dwStyle); + m_TextBreak.SetLayoutStyles(dwStyle); uint32_t dwAligment = 0; if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Justified) dwAligment |= CFX_TxtLineAlignment_Justified; @@ -828,12 +824,12 @@ void CFDE_TxtEdtEngine::UpdateTxtBreak() { else if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Right) dwAligment |= CFX_TxtLineAlignment_Right; - m_pTextBreak->SetAlignment(dwAligment); + m_TextBreak.SetAlignment(dwAligment); if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) - m_pTextBreak->SetLineWidth(m_Param.fPlateWidth); + m_TextBreak.SetLineWidth(m_Param.fPlateWidth); else - m_pTextBreak->SetLineWidth(kPageWidthMax); + m_TextBreak.SetLineWidth(kPageWidthMax); m_nPageLineCount = m_Param.nLineCount; if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText) { @@ -841,16 +837,16 @@ void CFDE_TxtEdtEngine::UpdateTxtBreak() { if (m_nLimit > 0) fCombWidth /= m_nLimit; - m_pTextBreak->SetCombWidth(fCombWidth); + m_TextBreak.SetCombWidth(fCombWidth); } - m_pTextBreak->SetFont(m_Param.pFont); - m_pTextBreak->SetFontSize(m_Param.fFontSize); - m_pTextBreak->SetTabWidth(m_Param.fTabWidth); - m_pTextBreak->SetDefaultChar(0xFEFF); - m_pTextBreak->SetParagraphBreakChar(L'\n'); - m_pTextBreak->SetLineBreakTolerance(m_Param.fFontSize * 0.2f); - m_pTextBreak->SetHorizontalScale(100); - m_pTextBreak->SetCharSpace(0); + m_TextBreak.SetFont(m_Param.pFont); + m_TextBreak.SetFontSize(m_Param.fFontSize); + m_TextBreak.SetTabWidth(m_Param.fTabWidth); + m_TextBreak.SetDefaultChar(0xFEFF); + m_TextBreak.SetParagraphBreakChar(L'\n'); + m_TextBreak.SetLineBreakTolerance(m_Param.fFontSize * 0.2f); + m_TextBreak.SetHorizontalScale(100); + m_TextBreak.SetCharSpace(0); } bool CFDE_TxtEdtEngine::ReplaceParagEnd(wchar_t*& lpText, diff --git a/xfa/fde/cfde_txtedtengine.h b/xfa/fde/cfde_txtedtengine.h index b708984ac4..547cd57eae 100644 --- a/xfa/fde/cfde_txtedtengine.h +++ b/xfa/fde/cfde_txtedtengine.h @@ -16,10 +16,10 @@ #include "xfa/fde/cfde_txtedtbuf.h" #include "xfa/fde/cfde_txtedtpage.h" #include "xfa/fde/cfde_txtedtparag.h" +#include "xfa/fgas/layout/cfx_txtbreak.h" class CFGAS_GEFont; class CFWL_Edit; -class CFX_TxtBreak; class IFDE_TxtEdtDoRecord; class IFX_CharIter; @@ -125,7 +125,7 @@ class CFDE_TxtEdtEngine { } CFDE_TxtEdtBuf* GetTextBuf() const { return m_pTxtBuf.get(); } - CFX_TxtBreak* GetTextBreak() const { return m_pTextBreak.get(); } + CFX_TxtBreak* GetTextBreak() { return &m_TextBreak; } int32_t GetLineCount() const { return m_nLineCount; } int32_t GetPageLineCount() const { return m_nPageLineCount; } @@ -205,7 +205,7 @@ class CFDE_TxtEdtEngine { void DeleteSelect(); std::unique_ptr<CFDE_TxtEdtBuf> m_pTxtBuf; - std::unique_ptr<CFX_TxtBreak> m_pTextBreak; + CFX_TxtBreak m_TextBreak; FDE_TXTEDTPARAMS m_Param; std::vector<std::unique_ptr<CFDE_TxtEdtPage>> m_PagePtrArray; std::vector<std::unique_ptr<CFDE_TxtEdtParag>> m_ParagPtrArray; |