diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-01-10 16:38:10 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-01-10 21:53:32 +0000 |
commit | 0cb9b8cb094532ff868314350680d3fb0ca2fe51 (patch) | |
tree | 60e61f1e9547d5b99c010ee96b8c0ea7c0480e85 /xfa/fxfa | |
parent | 1f5d4988dcdac125e3e822d37c9086a5e4a3e224 (diff) | |
download | pdfium-0cb9b8cb094532ff868314350680d3fb0ca2fe51.tar.xz |
Strip out custom allocator code
This Cl replaces the custom IFX_MemoryAllocator code with new/delete as needed.
Change-Id: Ie786f607c9e0b3035ffd87733bc3e29a4b6426d9
Reviewed-on: https://pdfium-review.googlesource.com/2164
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/app/cxfa_linkuserdata.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_linkuserdata.h | 8 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_pieceline.h | 5 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textlayout.cpp | 30 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textlayout.h | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textparsecontext.h | 5 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textparser.cpp | 24 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textparser.h | 5 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textuserdata.cpp | 20 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textuserdata.h | 11 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_textpiece.h | 4 |
11 files changed, 41 insertions, 80 deletions
diff --git a/xfa/fxfa/app/cxfa_linkuserdata.cpp b/xfa/fxfa/app/cxfa_linkuserdata.cpp index 62a2938d95..f1e15f406d 100644 --- a/xfa/fxfa/app/cxfa_linkuserdata.cpp +++ b/xfa/fxfa/app/cxfa_linkuserdata.cpp @@ -6,9 +6,8 @@ #include "xfa/fxfa/app/cxfa_linkuserdata.h" -CXFA_LinkUserData::CXFA_LinkUserData(IFX_MemoryAllocator* pAllocator, - FX_WCHAR* pszText) - : m_pAllocator(pAllocator), m_dwRefCount(1), m_wsURLContent(pszText) {} +CXFA_LinkUserData::CXFA_LinkUserData(FX_WCHAR* pszText) + : m_dwRefCount(1), m_wsURLContent(pszText) {} CXFA_LinkUserData::~CXFA_LinkUserData() {} @@ -19,7 +18,7 @@ uint32_t CXFA_LinkUserData::Retain() { uint32_t CXFA_LinkUserData::Release() { uint32_t dwRefCount = --m_dwRefCount; if (dwRefCount <= 0) - FXTARGET_DeleteWith(CXFA_LinkUserData, m_pAllocator, this); + delete this; return dwRefCount; } diff --git a/xfa/fxfa/app/cxfa_linkuserdata.h b/xfa/fxfa/app/cxfa_linkuserdata.h index d5ec14e17e..621398ecb3 100644 --- a/xfa/fxfa/app/cxfa_linkuserdata.h +++ b/xfa/fxfa/app/cxfa_linkuserdata.h @@ -10,13 +10,10 @@ #include "core/fxcrt/fx_basic.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" -#include "xfa/fgas/crt/fgas_memory.h" -class IFX_MemoryAllocator; - -class CXFA_LinkUserData : public IFX_Retainable, public CFX_Target { +class CXFA_LinkUserData : public IFX_Retainable { public: - CXFA_LinkUserData(IFX_MemoryAllocator* pAllocator, FX_WCHAR* pszText); + explicit CXFA_LinkUserData(FX_WCHAR* pszText); ~CXFA_LinkUserData() override; // IFX_Retainable: @@ -26,7 +23,6 @@ class CXFA_LinkUserData : public IFX_Retainable, public CFX_Target { const FX_WCHAR* GetLinkURL(); protected: - IFX_MemoryAllocator* m_pAllocator; uint32_t m_dwRefCount; CFX_WideString m_wsURLContent; }; diff --git a/xfa/fxfa/app/cxfa_pieceline.h b/xfa/fxfa/app/cxfa_pieceline.h index 88642d38bc..48dfdae04d 100644 --- a/xfa/fxfa/app/cxfa_pieceline.h +++ b/xfa/fxfa/app/cxfa_pieceline.h @@ -8,14 +8,13 @@ #define XFA_FXFA_APP_CXFA_PIECELINE_H_ #include "core/fxcrt/fx_basic.h" -#include "xfa/fgas/crt/fgas_memory.h" class XFA_TextPiece; -class CXFA_PieceLine : public CFX_Target { +class CXFA_PieceLine { public: CXFA_PieceLine(); - ~CXFA_PieceLine() override; + ~CXFA_PieceLine(); CFX_ArrayTemplate<XFA_TextPiece*> m_textPieces; CFX_ArrayTemplate<int32_t> m_charCounts; diff --git a/xfa/fxfa/app/cxfa_textlayout.cpp b/xfa/fxfa/app/cxfa_textlayout.cpp index c4c2712386..c123668993 100644 --- a/xfa/fxfa/app/cxfa_textlayout.cpp +++ b/xfa/fxfa/app/cxfa_textlayout.cpp @@ -50,18 +50,17 @@ void CXFA_TextLayout::Unload() { for (int32_t i = 0; i < pLine->m_textPieces.GetSize(); i++) { XFA_TextPiece* pPiece = pLine->m_textPieces.GetAt(i); // Release text and widths in a text piece. - m_pAllocator->Free(pPiece->pszText); - m_pAllocator->Free(pPiece->pWidths); + delete pPiece->pszText; + delete pPiece->pWidths; // Release text piece. - FXTARGET_DeleteWith(XFA_TextPiece, m_pAllocator.get(), pPiece); + delete pPiece; } pLine->m_textPieces.RemoveAll(); // Release line. - FXTARGET_DeleteWith(CXFA_PieceLine, m_pAllocator.get(), pLine); + delete pLine; } m_pieceLines.RemoveAll(); m_pBreak.reset(); - m_pAllocator.reset(); } const CFX_ArrayTemplate<CXFA_PieceLine*>* CXFA_TextLayout::GetPieceLines() { @@ -669,9 +668,6 @@ void CXFA_TextLayout::UpdateAlign(FX_FLOAT fHeight, FX_FLOAT fBottom) { bool CXFA_TextLayout::Loader(const CFX_SizeF& szText, FX_FLOAT& fLinePos, bool bSavePieces) { - if (!m_pAllocator) - m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 256, 0); - GetTextDataNode(); if (!m_pTextDataNode) return true; @@ -794,8 +790,7 @@ bool CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode, ASSERT(pElement); pElement->GetString(L"href", wsLinkContent); if (!wsLinkContent.IsEmpty()) { - pLinkData = FXTARGET_NewWith(m_pAllocator.get()) CXFA_LinkUserData( - m_pAllocator.get(), + pLinkData = new CXFA_LinkUserData( wsLinkContent.GetBuffer(wsLinkContent.GetLength())); wsLinkContent.ReleaseBuffer(wsLinkContent.GetLength()); } @@ -852,10 +847,8 @@ bool CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode, if (pLinkData) pLinkData->Retain(); - CXFA_TextUserData* pUserData = FXTARGET_NewWith(m_pAllocator.get()) - CXFA_TextUserData(m_pAllocator.get(), - bContentNode ? pParentStyle : pStyle, - pLinkData); + CXFA_TextUserData* pUserData = new CXFA_TextUserData( + bContentNode ? pParentStyle : pStyle, pLinkData); m_pBreak->SetUserData(pUserData); } @@ -1073,8 +1066,7 @@ void CXFA_TextLayout::AppendTextLine(uint32_t dwStatus, IFDE_CSSComputedStyle* pStyle = nullptr; if (bSavePieces) { - CXFA_PieceLine* pPieceLine = - FXTARGET_NewWith(m_pAllocator.get()) CXFA_PieceLine; + CXFA_PieceLine* pPieceLine = new CXFA_PieceLine; m_pieceLines.Add(pPieceLine); if (m_pTabstopContext) m_pTabstopContext->Reset(); @@ -1088,11 +1080,11 @@ void CXFA_TextLayout::AppendTextLine(uint32_t dwStatus, pStyle = pUserData->m_pStyle; FX_FLOAT fVerScale = pPiece->m_iVerticalScale / 100.0f; - XFA_TextPiece* pTP = FXTARGET_NewWith(m_pAllocator.get()) XFA_TextPiece(); + XFA_TextPiece* pTP = new XFA_TextPiece(); pTP->pszText = - (FX_WCHAR*)m_pAllocator->Alloc(pPiece->m_iChars * sizeof(FX_WCHAR)); + (FX_WCHAR*)FX_Alloc(uint8_t, pPiece->m_iChars * sizeof(FX_WCHAR)); pTP->pWidths = - (int32_t*)m_pAllocator->Alloc(pPiece->m_iChars * sizeof(int32_t)); + (int32_t*)FX_Alloc(uint8_t, pPiece->m_iChars * sizeof(int32_t)); pTP->iChars = pPiece->m_iChars; pPiece->GetString(pTP->pszText); pPiece->GetWidths(pTP->pWidths); diff --git a/xfa/fxfa/app/cxfa_textlayout.h b/xfa/fxfa/app/cxfa_textlayout.h index e21a5de424..e73005afb5 100644 --- a/xfa/fxfa/app/cxfa_textlayout.h +++ b/xfa/fxfa/app/cxfa_textlayout.h @@ -28,7 +28,6 @@ class CXFA_PieceLine; class CXFA_TextProvider; class CXFA_TextTabstopsContext; class IFDE_CSSComputedStyle; -class IFX_MemoryAllocator; class XFA_TextPiece; class CXFA_TextLayout { @@ -121,7 +120,6 @@ class CXFA_TextLayout { CXFA_TextProvider* m_pTextProvider; CXFA_Node* m_pTextDataNode; bool m_bRichText; - std::unique_ptr<IFX_MemoryAllocator> m_pAllocator; std::unique_ptr<CFX_RTFBreak> m_pBreak; std::unique_ptr<CXFA_LoaderContext> m_pLoader; int32_t m_iLines; diff --git a/xfa/fxfa/app/cxfa_textparsecontext.h b/xfa/fxfa/app/cxfa_textparsecontext.h index 2eafacc8fe..94265fb0db 100644 --- a/xfa/fxfa/app/cxfa_textparsecontext.h +++ b/xfa/fxfa/app/cxfa_textparsecontext.h @@ -8,15 +8,14 @@ #define XFA_FXFA_APP_CXFA_TEXTPARSECONTEXT_H_ #include "xfa/fde/css/fde_css.h" -#include "xfa/fgas/crt/fgas_memory.h" class CFDE_CSSDeclaration; class IFDE_CSSComputedStyle; -class CXFA_TextParseContext : public CFX_Target { +class CXFA_TextParseContext { public: CXFA_TextParseContext(); - ~CXFA_TextParseContext() override; + ~CXFA_TextParseContext(); void SetDisplay(FDE_CSSDISPLAY eDisplay) { m_eDisplay = eDisplay; } FDE_CSSDISPLAY GetDisplay() const { return m_eDisplay; } diff --git a/xfa/fxfa/app/cxfa_textparser.cpp b/xfa/fxfa/app/cxfa_textparser.cpp index b865e5e576..50f6cbaea2 100644 --- a/xfa/fxfa/app/cxfa_textparser.cpp +++ b/xfa/fxfa/app/cxfa_textparser.cpp @@ -36,29 +36,25 @@ enum class TabStopStatus { } // namespace -CXFA_TextParser::CXFA_TextParser() : m_pUASheet(nullptr) {} +CXFA_TextParser::CXFA_TextParser() : m_pUASheet(nullptr), m_bParsed(false) {} CXFA_TextParser::~CXFA_TextParser() { if (m_pUASheet) m_pUASheet->Release(); for (auto& pair : m_mapXMLNodeToParseContext) { - if (pair.second) { - FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator.get(), - pair.second); - } + if (pair.second) + delete pair.second; } } void CXFA_TextParser::Reset() { for (auto& pair : m_mapXMLNodeToParseContext) { - if (pair.second) { - FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator.get(), - pair.second); - } + if (pair.second) + delete pair.second; } m_mapXMLNodeToParseContext.clear(); - m_pAllocator.reset(); + m_bParsed = false; } void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) { if (!pTextProvider) @@ -220,11 +216,10 @@ IFDE_CSSComputedStyle* CXFA_TextParser::ComputeStyle( void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer, CXFA_TextProvider* pTextProvider) { - if (!pXMLContainer || !pTextProvider || m_pAllocator) + if (!pXMLContainer || !pTextProvider || m_bParsed) return; - m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, 32, - sizeof(CXFA_CSSTagProvider)); + m_bParsed = true; InitCSSData(pTextProvider); IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider); ParseRichText(pXMLContainer, pRootStyle); @@ -244,8 +239,7 @@ void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, IFDE_CSSComputedStyle* pNewStyle = nullptr; if ((tagProvider.GetTagName() != FX_WSTRC(L"body")) || (tagProvider.GetTagName() != FX_WSTRC(L"html"))) { - CXFA_TextParseContext* pTextContext = - FXTARGET_NewWith(m_pAllocator.get()) CXFA_TextParseContext; + CXFA_TextParseContext* pTextContext = new CXFA_TextParseContext; FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_Inline; if (!tagProvider.m_bContent) { pNewStyle = CreateStyle(pParentStyle); diff --git a/xfa/fxfa/app/cxfa_textparser.h b/xfa/fxfa/app/cxfa_textparser.h index e793c0c9fe..923c07001a 100644 --- a/xfa/fxfa/app/cxfa_textparser.h +++ b/xfa/fxfa/app/cxfa_textparser.h @@ -24,7 +24,6 @@ class CXFA_TextProvider; class CXFA_TextTabstopsContext; class IFDE_CSSComputedStyle; class IFDE_CSSStyleSheet; -class IFX_MemoryAllocator; class CXFA_TextParser { public: @@ -38,7 +37,7 @@ class CXFA_TextParser { IFDE_CSSComputedStyle* ComputeStyle(CFDE_XMLNode* pXMLNode, IFDE_CSSComputedStyle* pParentStyle); - bool IsParsed() const { return !!m_pAllocator; } + bool IsParsed() const { return m_bParsed; } int32_t GetVAlign(CXFA_TextProvider* pTextProvider) const; @@ -92,10 +91,10 @@ class CXFA_TextParser { IFDE_CSSStyleSheet* LoadDefaultSheetStyle(); IFDE_CSSComputedStyle* CreateStyle(IFDE_CSSComputedStyle* pParentStyle); - std::unique_ptr<IFX_MemoryAllocator> m_pAllocator; std::unique_ptr<CFDE_CSSStyleSelector> m_pSelector; IFDE_CSSStyleSheet* m_pUASheet; std::map<CFDE_XMLNode*, CXFA_TextParseContext*> m_mapXMLNodeToParseContext; + bool m_bParsed; }; #endif // XFA_FXFA_APP_CXFA_TEXTPARSER_H_ diff --git a/xfa/fxfa/app/cxfa_textuserdata.cpp b/xfa/fxfa/app/cxfa_textuserdata.cpp index 209e4f2c21..62566deeac 100644 --- a/xfa/fxfa/app/cxfa_textuserdata.cpp +++ b/xfa/fxfa/app/cxfa_textuserdata.cpp @@ -9,25 +9,15 @@ #include "xfa/fde/css/fde_css.h" #include "xfa/fxfa/app/cxfa_linkuserdata.h" -CXFA_TextUserData::CXFA_TextUserData(IFX_MemoryAllocator* pAllocator, - IFDE_CSSComputedStyle* pStyle) - : m_pStyle(pStyle), - m_pLinkData(nullptr), - m_pAllocator(pAllocator), - m_dwRefCount(0) { - ASSERT(m_pAllocator); +CXFA_TextUserData::CXFA_TextUserData(IFDE_CSSComputedStyle* pStyle) + : m_pStyle(pStyle), m_pLinkData(nullptr), m_dwRefCount(0) { if (m_pStyle) m_pStyle->Retain(); } -CXFA_TextUserData::CXFA_TextUserData(IFX_MemoryAllocator* pAllocator, - IFDE_CSSComputedStyle* pStyle, +CXFA_TextUserData::CXFA_TextUserData(IFDE_CSSComputedStyle* pStyle, CXFA_LinkUserData* pLinkData) - : m_pStyle(pStyle), - m_pLinkData(pLinkData), - m_pAllocator(pAllocator), - m_dwRefCount(0) { - ASSERT(m_pAllocator); + : m_pStyle(pStyle), m_pLinkData(pLinkData), m_dwRefCount(0) { if (m_pStyle) m_pStyle->Retain(); } @@ -46,6 +36,6 @@ uint32_t CXFA_TextUserData::Retain() { uint32_t CXFA_TextUserData::Release() { uint32_t dwRefCount = --m_dwRefCount; if (dwRefCount == 0) - FXTARGET_DeleteWith(CXFA_TextUserData, m_pAllocator, this); + delete this; return dwRefCount; } diff --git a/xfa/fxfa/app/cxfa_textuserdata.h b/xfa/fxfa/app/cxfa_textuserdata.h index f9e76f94d8..308475b0dd 100644 --- a/xfa/fxfa/app/cxfa_textuserdata.h +++ b/xfa/fxfa/app/cxfa_textuserdata.h @@ -8,18 +8,14 @@ #define XFA_FXFA_APP_CXFA_TEXTUSERDATA_H_ #include "core/fxcrt/fx_basic.h" -#include "xfa/fgas/crt/fgas_memory.h" class CXFA_LinkUserData; class IFDE_CSSComputedStyle; -class IFX_MemoryAllocator; -class CXFA_TextUserData : public IFX_Retainable, public CFX_Target { +class CXFA_TextUserData : public IFX_Retainable { public: - CXFA_TextUserData(IFX_MemoryAllocator* pAllocator, - IFDE_CSSComputedStyle* pStyle); - CXFA_TextUserData(IFX_MemoryAllocator* pAllocator, - IFDE_CSSComputedStyle* pStyle, + explicit CXFA_TextUserData(IFDE_CSSComputedStyle* pStyle); + CXFA_TextUserData(IFDE_CSSComputedStyle* pStyle, CXFA_LinkUserData* pLinkData); ~CXFA_TextUserData() override; @@ -31,7 +27,6 @@ class CXFA_TextUserData : public IFX_Retainable, public CFX_Target { CXFA_LinkUserData* m_pLinkData; protected: - IFX_MemoryAllocator* m_pAllocator; uint32_t m_dwRefCount; }; diff --git a/xfa/fxfa/app/xfa_textpiece.h b/xfa/fxfa/app/xfa_textpiece.h index 4047cd2d7f..2b74155afd 100644 --- a/xfa/fxfa/app/xfa_textpiece.h +++ b/xfa/fxfa/app/xfa_textpiece.h @@ -15,10 +15,10 @@ class CXFA_LinkUserData; -class XFA_TextPiece : public CFX_Target { +class XFA_TextPiece { public: XFA_TextPiece(); - ~XFA_TextPiece() override; + ~XFA_TextPiece(); FX_WCHAR* pszText; int32_t iChars; |