diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-09-21 15:49:49 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-09-21 20:17:31 +0000 |
commit | 0b95042db2e6dab5876abd12ce485fff0a8e08fe (patch) | |
tree | 02132ed53945fde30bfbf230ff4e9b5308dd7732 /core/fxcrt | |
parent | a5eb9f05b7c3f82630784e043ccf75c4e019b18f (diff) | |
download | pdfium-0b95042db2e6dab5876abd12ce485fff0a8e08fe.tar.xz |
Rename CFX_RetainPtr to RetainPtr
This CL renames CFX_RetainPtr to RetainPtr and places in the fxcrt
namespace.
Bug: pdfium:898
Change-Id: I8798a9f79cb0840d3f037e8d04937cedd742914e
Reviewed-on: https://pdfium-review.googlesource.com/14616
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt')
40 files changed, 236 insertions, 239 deletions
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp index dd4dbd99e2..2d343ffd11 100644 --- a/core/fxcrt/bytestring.cpp +++ b/core/fxcrt/bytestring.cpp @@ -298,7 +298,7 @@ void ByteString::ReallocBeforeWrite(FX_STRSIZE nNewLength) { return; } - CFX_RetainPtr<StringData> pNewData(StringData::Create(nNewLength)); + RetainPtr<StringData> pNewData(StringData::Create(nNewLength)); if (m_pData) { FX_STRSIZE nCopyLength = std::min(m_pData->m_nDataLength, nNewLength); pNewData->CopyContents(m_pData->m_String, nCopyLength); @@ -365,7 +365,7 @@ char* ByteString::GetBuffer(FX_STRSIZE nMinBufLength) { if (nMinBufLength == 0) return nullptr; - CFX_RetainPtr<StringData> pNewData(StringData::Create(nMinBufLength)); + RetainPtr<StringData> pNewData(StringData::Create(nMinBufLength)); pNewData->CopyContents(*m_pData); pNewData->m_nDataLength = m_pData->m_nDataLength; m_pData.Swap(pNewData); @@ -408,7 +408,7 @@ void ByteString::Concat(const char* pSrcData, FX_STRSIZE nSrcLen) { return; } - CFX_RetainPtr<StringData> pNewData( + RetainPtr<StringData> pNewData( StringData::Create(m_pData->m_nDataLength + nSrcLen)); pNewData->CopyContents(*m_pData); pNewData->CopyContentsAt(m_pData->m_nDataLength, pSrcData, nSrcLen); @@ -454,7 +454,7 @@ void ByteString::AllocCopy(ByteString& dest, if (nCopyLen == 0) return; - CFX_RetainPtr<StringData> pNewData( + RetainPtr<StringData> pNewData( StringData::Create(m_pData->m_String + nCopyIndex, nCopyLen)); dest.m_pData.Swap(pNewData); } @@ -637,7 +637,7 @@ FX_STRSIZE ByteString::Replace(const ByteStringView& pOld, return nCount; } - CFX_RetainPtr<StringData> pNewData(StringData::Create(nNewLength)); + RetainPtr<StringData> pNewData(StringData::Create(nNewLength)); pStart = m_pData->m_String; char* pDest = pNewData->m_String; for (FX_STRSIZE i = 0; i < nCount; i++) { diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h index 0220e707cd..7342fdbea7 100644 --- a/core/fxcrt/bytestring.h +++ b/core/fxcrt/bytestring.h @@ -12,9 +12,9 @@ #include <sstream> #include <utility> -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_string_data_template.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/string_view_template.h" #include "third_party/base/optional.h" @@ -195,7 +195,7 @@ class ByteString { void AssignCopy(const char* pSrcData, FX_STRSIZE nSrcLen); void Concat(const char* lpszSrcData, FX_STRSIZE nSrcLen); - CFX_RetainPtr<StringData> m_pData; + RetainPtr<StringData> m_pData; friend ByteString_Concat_Test; friend fxcrt_ByteStringPool_Test; diff --git a/core/fxcrt/cfx_char.h b/core/fxcrt/cfx_char.h index 74f0a4f9cd..fb625ee038 100644 --- a/core/fxcrt/cfx_char.h +++ b/core/fxcrt/cfx_char.h @@ -40,7 +40,7 @@ class CFX_Char { int16_t m_iBidiOrder; int32_t m_iFontSize; uint32_t m_dwIdentity; - CFX_RetainPtr<CFX_Retainable> m_pUserData; + RetainPtr<Retainable> m_pUserData; private: uint16_t m_wCharCode; diff --git a/core/fxcrt/cfx_checksumcontext.cpp b/core/fxcrt/cfx_checksumcontext.cpp index c75e440231..3d3409dceb 100644 --- a/core/fxcrt/cfx_checksumcontext.cpp +++ b/core/fxcrt/cfx_checksumcontext.cpp @@ -105,7 +105,7 @@ void CFX_ChecksumContext::StartChecksum() { } bool CFX_ChecksumContext::UpdateChecksum( - const CFX_RetainPtr<IFX_SeekableReadStream>& pSrcFile, + const RetainPtr<IFX_SeekableReadStream>& pSrcFile, FX_FILESIZE offset, size_t size) { if (!m_pSAXReader || !pSrcFile) diff --git a/core/fxcrt/cfx_checksumcontext.h b/core/fxcrt/cfx_checksumcontext.h index 4231e09a83..6d7963ad93 100644 --- a/core/fxcrt/cfx_checksumcontext.h +++ b/core/fxcrt/cfx_checksumcontext.h @@ -19,7 +19,7 @@ class CFX_ChecksumContext { void StartChecksum(); void Update(const ByteStringView& bsText); - bool UpdateChecksum(const CFX_RetainPtr<IFX_SeekableReadStream>& pSrcFile, + bool UpdateChecksum(const RetainPtr<IFX_SeekableReadStream>& pSrcFile, FX_FILESIZE offset = 0, size_t size = 0); void FinishChecksum(); diff --git a/core/fxcrt/cfx_crtfileaccess.cpp b/core/fxcrt/cfx_crtfileaccess.cpp index 2479c95654..b6a6a74d1c 100644 --- a/core/fxcrt/cfx_crtfileaccess.cpp +++ b/core/fxcrt/cfx_crtfileaccess.cpp @@ -11,7 +11,7 @@ CFX_CRTFileAccess::CFX_CRTFileAccess(const WideStringView& wsPath) CFX_CRTFileAccess::~CFX_CRTFileAccess() {} -CFX_RetainPtr<IFX_SeekableStream> CFX_CRTFileAccess::CreateFileStream( +RetainPtr<IFX_SeekableStream> CFX_CRTFileAccess::CreateFileStream( uint32_t dwModes) { return IFX_SeekableStream::CreateFromFilename(m_path.c_str(), dwModes); } diff --git a/core/fxcrt/cfx_crtfileaccess.h b/core/fxcrt/cfx_crtfileaccess.h index 3c63aa30c3..962a6d122f 100644 --- a/core/fxcrt/cfx_crtfileaccess.h +++ b/core/fxcrt/cfx_crtfileaccess.h @@ -7,16 +7,16 @@ #ifndef CORE_FXCRT_CFX_CRTFILEACCESS_H_ #define CORE_FXCRT_CFX_CRTFILEACCESS_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_stream.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" -class CFX_CRTFileAccess : public CFX_Retainable { +class CFX_CRTFileAccess : public Retainable { public: template <typename T, typename... Args> - friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); + friend RetainPtr<T> pdfium::MakeRetain(Args&&... args); - CFX_RetainPtr<IFX_SeekableStream> CreateFileStream(uint32_t dwModes); + RetainPtr<IFX_SeekableStream> CreateFileStream(uint32_t dwModes); private: explicit CFX_CRTFileAccess(const WideStringView& wsPath); diff --git a/core/fxcrt/cfx_memorystream.h b/core/fxcrt/cfx_memorystream.h index 2112280237..ef66080420 100644 --- a/core/fxcrt/cfx_memorystream.h +++ b/core/fxcrt/cfx_memorystream.h @@ -9,15 +9,15 @@ #include <vector> -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_stream.h" +#include "core/fxcrt/retain_ptr.h" class CFX_MemoryStream : public IFX_SeekableStream { public: enum Type { kConsecutive = 1 << 0, kTakeOver = 1 << 1 }; template <typename T, typename... Args> - friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); + friend RetainPtr<T> pdfium::MakeRetain(Args&&... args); // IFX_SeekableStream FX_FILESIZE GetSize() override; diff --git a/core/fxcrt/cfx_seekablestreamproxy.cpp b/core/fxcrt/cfx_seekablestreamproxy.cpp index 6a6c6e6c3e..611c3eb03c 100644 --- a/core/fxcrt/cfx_seekablestreamproxy.cpp +++ b/core/fxcrt/cfx_seekablestreamproxy.cpp @@ -134,7 +134,7 @@ void SwapByteOrder(wchar_t* pStr, FX_STRSIZE iLength) { #define BOM_UTF16_LE 0x0000FEFF CFX_SeekableStreamProxy::CFX_SeekableStreamProxy( - const CFX_RetainPtr<IFX_SeekableStream>& stream, + const RetainPtr<IFX_SeekableStream>& stream, bool isWriteStream) : m_IsWriteStream(isWriteStream), m_wCodePage(FX_CODEPAGE_DefANSI), diff --git a/core/fxcrt/cfx_seekablestreamproxy.h b/core/fxcrt/cfx_seekablestreamproxy.h index fc041b49b5..cadc96816d 100644 --- a/core/fxcrt/cfx_seekablestreamproxy.h +++ b/core/fxcrt/cfx_seekablestreamproxy.h @@ -9,11 +9,11 @@ #include <algorithm> -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_stream.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" -class CFX_SeekableStreamProxy : public CFX_Retainable { +class CFX_SeekableStreamProxy : public Retainable { public: enum class From { Begin = 0, @@ -21,7 +21,7 @@ class CFX_SeekableStreamProxy : public CFX_Retainable { }; template <typename T, typename... Args> - friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); + friend RetainPtr<T> pdfium::MakeRetain(Args&&... args); FX_FILESIZE GetLength() const { return m_pStream->GetSize(); } FX_FILESIZE GetPosition() { return m_iPosition; } @@ -37,7 +37,7 @@ class CFX_SeekableStreamProxy : public CFX_Retainable { void SetCodePage(uint16_t wCodePage); private: - CFX_SeekableStreamProxy(const CFX_RetainPtr<IFX_SeekableStream>& stream, + CFX_SeekableStreamProxy(const RetainPtr<IFX_SeekableStream>& stream, bool isWriteSteam); CFX_SeekableStreamProxy(uint8_t* data, FX_STRSIZE size); ~CFX_SeekableStreamProxy() override; @@ -48,7 +48,7 @@ class CFX_SeekableStreamProxy : public CFX_Retainable { uint16_t m_wCodePage; FX_STRSIZE m_wBOMLength; FX_FILESIZE m_iPosition; - CFX_RetainPtr<IFX_SeekableStream> m_pStream; + RetainPtr<IFX_SeekableStream> m_pStream; }; #endif // CORE_FXCRT_CFX_SEEKABLESTREAMPROXY_H_ diff --git a/core/fxcrt/cfx_shared_copy_on_write.h b/core/fxcrt/cfx_shared_copy_on_write.h index c87d96509d..f897368813 100644 --- a/core/fxcrt/cfx_shared_copy_on_write.h +++ b/core/fxcrt/cfx_shared_copy_on_write.h @@ -7,8 +7,8 @@ #ifndef CORE_FXCRT_CFX_SHARED_COPY_ON_WRITE_H_ #define CORE_FXCRT_CFX_SHARED_COPY_ON_WRITE_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" // A shared object with Copy on Write semantics that makes it appear as // if each one were independent. @@ -79,7 +79,7 @@ class CFX_SharedCopyOnWrite { intptr_t m_RefCount; }; - CFX_RetainPtr<CountedObj> m_pObject; + RetainPtr<CountedObj> m_pObject; }; #endif // CORE_FXCRT_CFX_SHARED_COPY_ON_WRITE_H_ diff --git a/core/fxcrt/cfx_weak_ptr.h b/core/fxcrt/cfx_weak_ptr.h index 4aca1c3218..da96000a1b 100644 --- a/core/fxcrt/cfx_weak_ptr.h +++ b/core/fxcrt/cfx_weak_ptr.h @@ -11,8 +11,8 @@ #include <memory> #include <utility> -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" template <class T, class D = std::default_delete<T>> class CFX_WeakPtr { @@ -80,7 +80,7 @@ class CFX_WeakPtr { std::unique_ptr<T, D> m_pObj; }; - CFX_RetainPtr<Handle> m_pHandle; + RetainPtr<Handle> m_pHandle; }; #endif // CORE_FXCRT_CFX_WEAK_PTR_H_ diff --git a/core/fxcrt/css/cfx_csscomputedstyle.h b/core/fxcrt/css/cfx_csscomputedstyle.h index b05339ac02..4b44a6d87c 100644 --- a/core/fxcrt/css/cfx_csscomputedstyle.h +++ b/core/fxcrt/css/cfx_csscomputedstyle.h @@ -15,7 +15,7 @@ class CFX_CSSValueList; -class CFX_CSSComputedStyle : public CFX_Retainable { +class CFX_CSSComputedStyle : public Retainable { public: class InheritedData { public: @@ -25,7 +25,7 @@ class CFX_CSSComputedStyle : public CFX_Retainable { CFX_CSSLength m_LetterSpacing; CFX_CSSLength m_WordSpacing; CFX_CSSLength m_TextIndent; - CFX_RetainPtr<CFX_CSSValueList> m_pFontFamily; + RetainPtr<CFX_CSSValueList> m_pFontFamily; float m_fFontSize; float m_fLineHeight; FX_ARGB m_dwFontColor; @@ -98,7 +98,7 @@ class CFX_CSSComputedStyle : public CFX_Retainable { private: template <typename T, typename... Args> - friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); + friend RetainPtr<T> pdfium::MakeRetain(Args&&... args); CFX_CSSComputedStyle(); ~CFX_CSSComputedStyle() override; diff --git a/core/fxcrt/css/cfx_cssdeclaration.cpp b/core/fxcrt/css/cfx_cssdeclaration.cpp index f2c7d3930b..c44c878196 100644 --- a/core/fxcrt/css/cfx_cssdeclaration.cpp +++ b/core/fxcrt/css/cfx_cssdeclaration.cpp @@ -285,7 +285,7 @@ CFX_CSSDeclaration::CFX_CSSDeclaration() {} CFX_CSSDeclaration::~CFX_CSSDeclaration() {} -CFX_RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::GetProperty( +RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::GetProperty( CFX_CSSProperty eProperty, bool* bImportant) const { for (const auto& p : properties_) { @@ -298,7 +298,7 @@ CFX_RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::GetProperty( } void CFX_CSSDeclaration::AddPropertyHolder(CFX_CSSProperty eProperty, - CFX_RetainPtr<CFX_CSSValue> pValue, + RetainPtr<CFX_CSSValue> pValue, bool bImportant) { auto pHolder = pdfium::MakeUnique<CFX_CSSPropertyHolder>(); pHolder->bImportant = bImportant; @@ -335,7 +335,7 @@ void CFX_CSSDeclaration::AddProperty(const CFX_CSSPropertyTable* pTable, if (dwMatch == 0) { continue; } - CFX_RetainPtr<CFX_CSSValue> pCSSValue; + RetainPtr<CFX_CSSValue> pCSSValue; switch (dwMatch) { case CFX_CSSVALUETYPE_MaybeNumber: pCSSValue = ParseNumber(pszValue, iValueLen); @@ -363,7 +363,7 @@ void CFX_CSSDeclaration::AddProperty(const CFX_CSSPropertyTable* pTable, break; } case CFX_CSSVALUETYPE_Shorthand: { - CFX_RetainPtr<CFX_CSSValue> pWidth; + RetainPtr<CFX_CSSValue> pWidth; switch (pTable->eName) { case CFX_CSSProperty::Font: ParseFontProperty(pszValue, iValueLen, bImportant); @@ -428,9 +428,8 @@ void CFX_CSSDeclaration::AddProperty(const WideString& prop, pdfium::MakeUnique<CFX_CSSCustomProperty>(prop, value)); } -CFX_RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseNumber( - const wchar_t* pszValue, - int32_t iValueLen) { +RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseNumber(const wchar_t* pszValue, + int32_t iValueLen) { float fValue; CFX_CSSNumberType eUnit; if (!ParseCSSNumber(pszValue, iValueLen, fValue, eUnit)) @@ -438,26 +437,23 @@ CFX_RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseNumber( return pdfium::MakeRetain<CFX_CSSNumberValue>(eUnit, fValue); } -CFX_RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseEnum( - const wchar_t* pszValue, - int32_t iValueLen) { +RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseEnum(const wchar_t* pszValue, + int32_t iValueLen) { const CFX_CSSPropertyValueTable* pValue = GetCSSPropertyValueByName(WideStringView(pszValue, iValueLen)); return pValue ? pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName) : nullptr; } -CFX_RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseColor( - const wchar_t* pszValue, - int32_t iValueLen) { +RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseColor(const wchar_t* pszValue, + int32_t iValueLen) { FX_ARGB dwColor; if (!ParseCSSColor(pszValue, iValueLen, &dwColor)) return nullptr; return pdfium::MakeRetain<CFX_CSSColorValue>(dwColor); } -CFX_RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseString( - const wchar_t* pszValue, - int32_t iValueLen) { +RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseString(const wchar_t* pszValue, + int32_t iValueLen) { int32_t iOffset; if (!ParseCSSString(pszValue, iValueLen, &iOffset, &iValueLen)) return nullptr; @@ -480,7 +476,7 @@ void CFX_CSSDeclaration::ParseValueListProperty( const uint32_t dwType = pTable->dwType; CFX_CSSPrimitiveType eType; - std::vector<CFX_RetainPtr<CFX_CSSValue>> list; + std::vector<RetainPtr<CFX_CSSValue>> list; while (parser.NextValue(eType, pszValue, iValueLen)) { switch (eType) { case CFX_CSSPrimitiveType::Number: @@ -556,7 +552,7 @@ void CFX_CSSDeclaration::ParseValueListProperty( } void CFX_CSSDeclaration::Add4ValuesProperty( - const std::vector<CFX_RetainPtr<CFX_CSSValue>>& list, + const std::vector<RetainPtr<CFX_CSSValue>>& list, bool bImportant, CFX_CSSProperty eLeft, CFX_CSSProperty eTop, @@ -595,7 +591,7 @@ void CFX_CSSDeclaration::Add4ValuesProperty( bool CFX_CSSDeclaration::ParseBorderProperty( const wchar_t* pszValue, int32_t iValueLen, - CFX_RetainPtr<CFX_CSSValue>& pWidth) const { + RetainPtr<CFX_CSSValue>& pWidth) const { pWidth.Reset(nullptr); CFX_CSSValueListParser parser(pszValue, iValueLen, ' '); @@ -650,12 +646,12 @@ void CFX_CSSDeclaration::ParseFontProperty(const wchar_t* pszValue, int32_t iValueLen, bool bImportant) { CFX_CSSValueListParser parser(pszValue, iValueLen, '/'); - CFX_RetainPtr<CFX_CSSValue> pStyle; - CFX_RetainPtr<CFX_CSSValue> pVariant; - CFX_RetainPtr<CFX_CSSValue> pWeight; - CFX_RetainPtr<CFX_CSSValue> pFontSize; - CFX_RetainPtr<CFX_CSSValue> pLineHeight; - std::vector<CFX_RetainPtr<CFX_CSSValue>> familyList; + RetainPtr<CFX_CSSValue> pStyle; + RetainPtr<CFX_CSSValue> pVariant; + RetainPtr<CFX_CSSValue> pWeight; + RetainPtr<CFX_CSSValue> pFontSize; + RetainPtr<CFX_CSSValue> pLineHeight; + std::vector<RetainPtr<CFX_CSSValue>> familyList; CFX_CSSPrimitiveType eType; while (parser.NextValue(eType, pszValue, iValueLen)) { switch (eType) { diff --git a/core/fxcrt/css/cfx_cssdeclaration.h b/core/fxcrt/css/cfx_cssdeclaration.h index dba1d44fc7..7dd0bba90e 100644 --- a/core/fxcrt/css/cfx_cssdeclaration.h +++ b/core/fxcrt/css/cfx_cssdeclaration.h @@ -34,8 +34,8 @@ class CFX_CSSDeclaration { CFX_CSSDeclaration(); ~CFX_CSSDeclaration(); - CFX_RetainPtr<CFX_CSSValue> GetProperty(CFX_CSSProperty eProperty, - bool* bImportant) const; + RetainPtr<CFX_CSSValue> GetProperty(CFX_CSSProperty eProperty, + bool* bImportant) const; const_prop_iterator begin() const { return properties_.begin(); } const_prop_iterator end() const { return properties_.end(); } @@ -63,27 +63,26 @@ class CFX_CSSDeclaration { bool bImportant); bool ParseBorderProperty(const wchar_t* pszValue, int32_t iValueLen, - CFX_RetainPtr<CFX_CSSValue>& pWidth) const; + RetainPtr<CFX_CSSValue>& pWidth) const; void ParseValueListProperty(const CFX_CSSPropertyTable* pTable, const wchar_t* pszValue, int32_t iValueLen, bool bImportant); - void Add4ValuesProperty(const std::vector<CFX_RetainPtr<CFX_CSSValue>>& list, + void Add4ValuesProperty(const std::vector<RetainPtr<CFX_CSSValue>>& list, bool bImportant, CFX_CSSProperty eLeft, CFX_CSSProperty eTop, CFX_CSSProperty eRight, CFX_CSSProperty eBottom); - CFX_RetainPtr<CFX_CSSValue> ParseNumber(const wchar_t* pszValue, - int32_t iValueLen); - CFX_RetainPtr<CFX_CSSValue> ParseEnum(const wchar_t* pszValue, - int32_t iValueLen); - CFX_RetainPtr<CFX_CSSValue> ParseColor(const wchar_t* pszValue, - int32_t iValueLen); - CFX_RetainPtr<CFX_CSSValue> ParseString(const wchar_t* pszValue, - int32_t iValueLen); + RetainPtr<CFX_CSSValue> ParseNumber(const wchar_t* pszValue, + int32_t iValueLen); + RetainPtr<CFX_CSSValue> ParseEnum(const wchar_t* pszValue, int32_t iValueLen); + RetainPtr<CFX_CSSValue> ParseColor(const wchar_t* pszValue, + int32_t iValueLen); + RetainPtr<CFX_CSSValue> ParseString(const wchar_t* pszValue, + int32_t iValueLen); void AddPropertyHolder(CFX_CSSProperty eProperty, - CFX_RetainPtr<CFX_CSSValue> pValue, + RetainPtr<CFX_CSSValue> pValue, bool bImportant); std::vector<std::unique_ptr<CFX_CSSPropertyHolder>> properties_; diff --git a/core/fxcrt/css/cfx_csspropertyholder.h b/core/fxcrt/css/cfx_csspropertyholder.h index ab0e0ae1fb..a271bdafc7 100644 --- a/core/fxcrt/css/cfx_csspropertyholder.h +++ b/core/fxcrt/css/cfx_csspropertyholder.h @@ -7,9 +7,9 @@ #ifndef CORE_FXCRT_CSS_CFX_CSSPROPERTYHOLDER_H_ #define CORE_FXCRT_CSS_CFX_CSSPROPERTYHOLDER_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/css/cfx_css.h" #include "core/fxcrt/css/cfx_cssvalue.h" +#include "core/fxcrt/retain_ptr.h" class CFX_CSSPropertyHolder { public: @@ -18,7 +18,7 @@ class CFX_CSSPropertyHolder { CFX_CSSProperty eProperty; bool bImportant; - CFX_RetainPtr<CFX_CSSValue> pValue; + RetainPtr<CFX_CSSValue> pValue; }; #endif // CORE_FXCRT_CSS_CFX_CSSPROPERTYHOLDER_H_ diff --git a/core/fxcrt/css/cfx_cssstyleselector.cpp b/core/fxcrt/css/cfx_cssstyleselector.cpp index 9ae2b876f7..cb9ab2f499 100644 --- a/core/fxcrt/css/cfx_cssstyleselector.cpp +++ b/core/fxcrt/css/cfx_cssstyleselector.cpp @@ -31,7 +31,7 @@ void CFX_CSSStyleSelector::SetDefFontSize(float fFontSize) { m_fDefFontSize = fFontSize; } -CFX_RetainPtr<CFX_CSSComputedStyle> CFX_CSSStyleSelector::CreateComputedStyle( +RetainPtr<CFX_CSSComputedStyle> CFX_CSSStyleSelector::CreateComputedStyle( CFX_CSSComputedStyle* pParentStyle) { auto pStyle = pdfium::MakeRetain<CFX_CSSComputedStyle>(); if (pParentStyle) @@ -168,10 +168,9 @@ void CFX_CSSStyleSelector::AppendInlineStyle(CFX_CSSDeclaration* pDecl, } } -void CFX_CSSStyleSelector::ApplyProperty( - CFX_CSSProperty eProperty, - const CFX_RetainPtr<CFX_CSSValue>& pValue, - CFX_CSSComputedStyle* pComputedStyle) { +void CFX_CSSStyleSelector::ApplyProperty(CFX_CSSProperty eProperty, + const RetainPtr<CFX_CSSValue>& pValue, + CFX_CSSComputedStyle* pComputedStyle) { if (pValue->GetType() != CFX_CSSPrimitiveType::List) { CFX_CSSPrimitiveType eType = pValue->GetType(); switch (eProperty) { @@ -192,7 +191,7 @@ void CFX_CSSStyleSelector::ApplyProperty( } break; case CFX_CSSProperty::LineHeight: if (eType == CFX_CSSPrimitiveType::Number) { - CFX_RetainPtr<CFX_CSSNumberValue> v = pValue.As<CFX_CSSNumberValue>(); + RetainPtr<CFX_CSSNumberValue> v = pValue.As<CFX_CSSNumberValue>(); if (v->Kind() == CFX_CSSNumberType::Number) { pComputedStyle->m_InheritedData.m_fLineHeight = v->Value() * pComputedStyle->m_InheritedData.m_fFontSize; @@ -392,7 +391,7 @@ void CFX_CSSStyleSelector::ApplyProperty( break; } } else if (pValue->GetType() == CFX_CSSPrimitiveType::List) { - CFX_RetainPtr<CFX_CSSValueList> pList = pValue.As<CFX_CSSValueList>(); + RetainPtr<CFX_CSSValueList> pList = pValue.As<CFX_CSSValueList>(); int32_t iCount = pList->CountValues(); if (iCount > 0) { switch (eProperty) { @@ -473,10 +472,10 @@ CFX_CSSFontStyle CFX_CSSStyleSelector::ToFontStyle( bool CFX_CSSStyleSelector::SetLengthWithPercent( CFX_CSSLength& width, CFX_CSSPrimitiveType eType, - const CFX_RetainPtr<CFX_CSSValue>& pValue, + const RetainPtr<CFX_CSSValue>& pValue, float fFontSize) { if (eType == CFX_CSSPrimitiveType::Number) { - CFX_RetainPtr<CFX_CSSNumberValue> v = pValue.As<CFX_CSSNumberValue>(); + RetainPtr<CFX_CSSNumberValue> v = pValue.As<CFX_CSSNumberValue>(); if (v->Kind() == CFX_CSSNumberType::Percent) { width.Set(CFX_CSSLengthUnit::Percent, pValue.As<CFX_CSSNumberValue>()->Value() / 100.0f); @@ -560,10 +559,10 @@ CFX_CSSVerticalAlign CFX_CSSStyleSelector::ToVerticalAlign( } uint32_t CFX_CSSStyleSelector::ToTextDecoration( - const CFX_RetainPtr<CFX_CSSValueList>& pValue) { + const RetainPtr<CFX_CSSValueList>& pValue) { uint32_t dwDecoration = 0; for (int32_t i = pValue->CountValues() - 1; i >= 0; --i) { - const CFX_RetainPtr<CFX_CSSValue> pVal = pValue->GetValue(i); + const RetainPtr<CFX_CSSValue> pVal = pValue->GetValue(i); if (pVal->GetType() != CFX_CSSPrimitiveType::Enum) continue; diff --git a/core/fxcrt/css/cfx_cssstyleselector.h b/core/fxcrt/css/cfx_cssstyleselector.h index b59e3048d6..13a0f74427 100644 --- a/core/fxcrt/css/cfx_cssstyleselector.h +++ b/core/fxcrt/css/cfx_cssstyleselector.h @@ -32,7 +32,7 @@ class CFX_CSSStyleSelector { void SetUAStyleSheet(std::unique_ptr<CFX_CSSStyleSheet> pSheet); void UpdateStyleIndex(); - CFX_RetainPtr<CFX_CSSComputedStyle> CreateComputedStyle( + RetainPtr<CFX_CSSComputedStyle> CreateComputedStyle( CFX_CSSComputedStyle* pParentStyle); // Note, the dest style has to be an out param because the CXFA_TextParser @@ -55,7 +55,7 @@ class CFX_CSSStyleSelector { const CFX_CSSDeclaration* extraDecl, CFX_CSSComputedStyle* pDestStyle); void ApplyProperty(CFX_CSSProperty eProperty, - const CFX_RetainPtr<CFX_CSSValue>& pValue, + const RetainPtr<CFX_CSSValue>& pValue, CFX_CSSComputedStyle* pComputedStyle); void ExtractValues(const CFX_CSSDeclaration* decl, std::vector<const CFX_CSSPropertyHolder*>* importants, @@ -64,7 +64,7 @@ class CFX_CSSStyleSelector { bool SetLengthWithPercent(CFX_CSSLength& width, CFX_CSSPrimitiveType eType, - const CFX_RetainPtr<CFX_CSSValue>& pValue, + const RetainPtr<CFX_CSSValue>& pValue, float fFontSize); float ToFontSize(CFX_CSSPropertyValue eValue, float fCurFontSize); CFX_CSSDisplay ToDisplay(CFX_CSSPropertyValue eValue); @@ -72,7 +72,7 @@ class CFX_CSSStyleSelector { uint16_t ToFontWeight(CFX_CSSPropertyValue eValue); CFX_CSSFontStyle ToFontStyle(CFX_CSSPropertyValue eValue); CFX_CSSVerticalAlign ToVerticalAlign(CFX_CSSPropertyValue eValue); - uint32_t ToTextDecoration(const CFX_RetainPtr<CFX_CSSValueList>& pList); + uint32_t ToTextDecoration(const RetainPtr<CFX_CSSValueList>& pList); CFX_CSSFontVariant ToFontVariant(CFX_CSSPropertyValue eValue); float m_fDefFontSize; diff --git a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp index abcd2f6972..30298243bc 100644 --- a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp +++ b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp @@ -51,7 +51,7 @@ class CFX_CSSStyleSheetTest : public testing::Test { ASSERT(decl_); bool important; - CFX_RetainPtr<CFX_CSSValue> v = decl_->GetProperty(prop, &important); + RetainPtr<CFX_CSSValue> v = decl_->GetProperty(prop, &important); EXPECT_EQ(v->GetType(), CFX_CSSPrimitiveType::Number); EXPECT_EQ(v.As<CFX_CSSNumberValue>()->Kind(), type); EXPECT_EQ(v.As<CFX_CSSNumberValue>()->Value(), val); @@ -61,7 +61,7 @@ class CFX_CSSStyleSheetTest : public testing::Test { ASSERT(decl_); bool important; - CFX_RetainPtr<CFX_CSSValue> v = decl_->GetProperty(prop, &important); + RetainPtr<CFX_CSSValue> v = decl_->GetProperty(prop, &important); EXPECT_EQ(v->GetType(), CFX_CSSPrimitiveType::Enum); EXPECT_EQ(v.As<CFX_CSSEnumValue>()->Value(), val); } @@ -71,12 +71,12 @@ class CFX_CSSStyleSheetTest : public testing::Test { ASSERT(decl_); bool important; - CFX_RetainPtr<CFX_CSSValueList> list = + RetainPtr<CFX_CSSValueList> list = decl_->GetProperty(prop, &important).As<CFX_CSSValueList>(); EXPECT_EQ(list->CountValues(), pdfium::CollectionSize<int32_t>(values)); for (size_t i = 0; i < values.size(); i++) { - CFX_RetainPtr<CFX_CSSValue> val = list->GetValue(i); + RetainPtr<CFX_CSSValue> val = list->GetValue(i); EXPECT_EQ(val->GetType(), CFX_CSSPrimitiveType::Enum); EXPECT_EQ(val.As<CFX_CSSEnumValue>()->Value(), values[i]); } diff --git a/core/fxcrt/css/cfx_cssvalue.h b/core/fxcrt/css/cfx_cssvalue.h index 4f11e4e0d7..f143e96036 100644 --- a/core/fxcrt/css/cfx_cssvalue.h +++ b/core/fxcrt/css/cfx_cssvalue.h @@ -9,7 +9,7 @@ #include "core/fxcrt/css/cfx_css.h" -class CFX_CSSValue : public CFX_Retainable { +class CFX_CSSValue : public Retainable { public: CFX_CSSPrimitiveType GetType() const { return m_value; } diff --git a/core/fxcrt/css/cfx_cssvaluelist.cpp b/core/fxcrt/css/cfx_cssvaluelist.cpp index 18b5d82054..b96f1658af 100644 --- a/core/fxcrt/css/cfx_cssvaluelist.cpp +++ b/core/fxcrt/css/cfx_cssvaluelist.cpp @@ -10,8 +10,7 @@ #include "core/fxcrt/css/cfx_css.h" -CFX_CSSValueList::CFX_CSSValueList( - std::vector<CFX_RetainPtr<CFX_CSSValue>>& list) +CFX_CSSValueList::CFX_CSSValueList(std::vector<RetainPtr<CFX_CSSValue>>& list) : CFX_CSSValue(CFX_CSSPrimitiveType::List), m_ppList(std::move(list)) {} CFX_CSSValueList::~CFX_CSSValueList() {} @@ -20,6 +19,6 @@ int32_t CFX_CSSValueList::CountValues() const { return m_ppList.size(); } -CFX_RetainPtr<CFX_CSSValue> CFX_CSSValueList::GetValue(int32_t index) const { +RetainPtr<CFX_CSSValue> CFX_CSSValueList::GetValue(int32_t index) const { return m_ppList[index]; } diff --git a/core/fxcrt/css/cfx_cssvaluelist.h b/core/fxcrt/css/cfx_cssvaluelist.h index 475abf4066..d2b0c6e7d1 100644 --- a/core/fxcrt/css/cfx_cssvaluelist.h +++ b/core/fxcrt/css/cfx_cssvaluelist.h @@ -13,14 +13,14 @@ class CFX_CSSValueList : public CFX_CSSValue { public: - explicit CFX_CSSValueList(std::vector<CFX_RetainPtr<CFX_CSSValue>>& list); + explicit CFX_CSSValueList(std::vector<RetainPtr<CFX_CSSValue>>& list); ~CFX_CSSValueList() override; int32_t CountValues() const; - CFX_RetainPtr<CFX_CSSValue> GetValue(int32_t index) const; + RetainPtr<CFX_CSSValue> GetValue(int32_t index) const; protected: - std::vector<CFX_RetainPtr<CFX_CSSValue>> m_ppList; + std::vector<RetainPtr<CFX_CSSValue>> m_ppList; }; #endif // CORE_FXCRT_CSS_CFX_CSSVALUELIST_H_ diff --git a/core/fxcrt/fx_stream.cpp b/core/fxcrt/fx_stream.cpp index a04e781d0d..e15fdb0a81 100644 --- a/core/fxcrt/fx_stream.cpp +++ b/core/fxcrt/fx_stream.cpp @@ -20,7 +20,7 @@ namespace { class CFX_CRTFileStream final : public IFX_SeekableStream { public: template <typename T, typename... Args> - friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); + friend RetainPtr<T> pdfium::MakeRetain(Args&&... args); // IFX_SeekableStream: FX_FILESIZE GetSize() override { return m_pFile->GetSize(); } @@ -50,7 +50,7 @@ class CFX_CRTFileStream final : public IFX_SeekableStream { } // namespace // static -CFX_RetainPtr<IFX_SeekableStream> IFX_SeekableStream::CreateFromFilename( +RetainPtr<IFX_SeekableStream> IFX_SeekableStream::CreateFromFilename( const char* filename, uint32_t dwModes) { std::unique_ptr<IFX_FileAccess> pFA = IFX_FileAccess::Create(); @@ -60,7 +60,7 @@ CFX_RetainPtr<IFX_SeekableStream> IFX_SeekableStream::CreateFromFilename( } // static -CFX_RetainPtr<IFX_SeekableStream> IFX_SeekableStream::CreateFromFilename( +RetainPtr<IFX_SeekableStream> IFX_SeekableStream::CreateFromFilename( const wchar_t* filename, uint32_t dwModes) { std::unique_ptr<IFX_FileAccess> pFA = IFX_FileAccess::Create(); @@ -70,8 +70,8 @@ CFX_RetainPtr<IFX_SeekableStream> IFX_SeekableStream::CreateFromFilename( } // static -CFX_RetainPtr<IFX_SeekableReadStream> -IFX_SeekableReadStream::CreateFromFilename(const char* filename) { +RetainPtr<IFX_SeekableReadStream> IFX_SeekableReadStream::CreateFromFilename( + const char* filename) { return IFX_SeekableStream::CreateFromFilename(filename, FX_FILEMODE_ReadOnly); } diff --git a/core/fxcrt/fx_stream.h b/core/fxcrt/fx_stream.h index 08331e9bf0..d7944167c6 100644 --- a/core/fxcrt/fx_stream.h +++ b/core/fxcrt/fx_stream.h @@ -7,9 +7,9 @@ #ifndef CORE_FXCRT_FX_STREAM_H_ #define CORE_FXCRT_FX_STREAM_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #include <direct.h> @@ -36,7 +36,7 @@ void FX_CloseFolder(FX_FileHandle* handle); #define FX_FILEMODE_ReadOnly 1 #define FX_FILEMODE_Truncate 2 -class IFX_WriteStream : virtual public CFX_Retainable { +class IFX_WriteStream : virtual public Retainable { public: virtual bool WriteBlock(const void* pData, size_t size) = 0; virtual bool WriteString(const ByteStringView& str) = 0; @@ -49,7 +49,7 @@ class IFX_ArchiveStream : public IFX_WriteStream { virtual FX_FILESIZE CurrentOffset() const = 0; }; -class IFX_ReadStream : virtual public CFX_Retainable { +class IFX_ReadStream : virtual public Retainable { public: virtual bool IsEOF() = 0; virtual FX_FILESIZE GetPosition() = 0; @@ -70,7 +70,7 @@ class IFX_SeekableWriteStream : public IFX_WriteStream { class IFX_SeekableReadStream : public IFX_ReadStream { public: - static CFX_RetainPtr<IFX_SeekableReadStream> CreateFromFilename( + static RetainPtr<IFX_SeekableReadStream> CreateFromFilename( const char* filename); // IFX_ReadStream: @@ -85,11 +85,10 @@ class IFX_SeekableReadStream : public IFX_ReadStream { class IFX_SeekableStream : public IFX_SeekableReadStream, public IFX_SeekableWriteStream { public: - static CFX_RetainPtr<IFX_SeekableStream> CreateFromFilename( - const char* filename, - uint32_t dwModes); + static RetainPtr<IFX_SeekableStream> CreateFromFilename(const char* filename, + uint32_t dwModes); - static CFX_RetainPtr<IFX_SeekableStream> CreateFromFilename( + static RetainPtr<IFX_SeekableStream> CreateFromFilename( const wchar_t* filename, uint32_t dwModes); diff --git a/core/fxcrt/fx_unicode.h b/core/fxcrt/fx_unicode.h index a4a237ae6d..18657bd0e1 100644 --- a/core/fxcrt/fx_unicode.h +++ b/core/fxcrt/fx_unicode.h @@ -7,7 +7,7 @@ #ifndef CORE_FXCRT_FX_UNICODE_H_ #define CORE_FXCRT_FX_UNICODE_H_ -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" uint32_t FX_GetUnicodeProperties(wchar_t wch); wchar_t FX_GetMirrorChar(wchar_t wch); diff --git a/core/fxcrt/cfx_retain_ptr.h b/core/fxcrt/retain_ptr.h index d3896ba6ae..481bfbba56 100644 --- a/core/fxcrt/cfx_retain_ptr.h +++ b/core/fxcrt/retain_ptr.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CORE_FXCRT_CFX_RETAIN_PTR_H_ -#define CORE_FXCRT_CFX_RETAIN_PTR_H_ +#ifndef CORE_FXCRT_RETAIN_PTR_H_ +#define CORE_FXCRT_RETAIN_PTR_H_ #include <functional> #include <memory> @@ -11,6 +11,8 @@ #include "core/fxcrt/fx_system.h" +namespace fxcrt { + // Used with std::unique_ptr to Release() objects that can't be deleted. template <class T> struct ReleaseDeleter { @@ -19,27 +21,27 @@ struct ReleaseDeleter { // Analogous to base's scoped_refptr. template <class T> -class CFX_RetainPtr { +class RetainPtr { public: - explicit CFX_RetainPtr(T* pObj) : m_pObj(pObj) { + explicit RetainPtr(T* pObj) : m_pObj(pObj) { if (m_pObj) m_pObj->Retain(); } - CFX_RetainPtr() {} - CFX_RetainPtr(const CFX_RetainPtr& that) : CFX_RetainPtr(that.Get()) {} - CFX_RetainPtr(CFX_RetainPtr&& that) noexcept { Swap(that); } + RetainPtr() {} + RetainPtr(const RetainPtr& that) : RetainPtr(that.Get()) {} + RetainPtr(RetainPtr&& that) noexcept { Swap(that); } // Deliberately implicit to allow returning nullptrs. // NOLINTNEXTLINE(runtime/explicit) - CFX_RetainPtr(std::nullptr_t ptr) {} + RetainPtr(std::nullptr_t ptr) {} template <class U> - CFX_RetainPtr(const CFX_RetainPtr<U>& that) : CFX_RetainPtr(that.Get()) {} + RetainPtr(const RetainPtr<U>& that) : RetainPtr(that.Get()) {} template <class U> - CFX_RetainPtr<U> As() const { - return CFX_RetainPtr<U>(static_cast<U*>(Get())); + RetainPtr<U> As() const { + return RetainPtr<U>(static_cast<U*>(Get())); } void Reset(T* obj = nullptr) { @@ -49,29 +51,27 @@ class CFX_RetainPtr { } T* Get() const { return m_pObj.get(); } - void Swap(CFX_RetainPtr& that) { m_pObj.swap(that.m_pObj); } + void Swap(RetainPtr& that) { m_pObj.swap(that.m_pObj); } // Useful for passing notion of object ownership across a C API. T* Leak() { return m_pObj.release(); } void Unleak(T* ptr) { m_pObj.reset(ptr); } - CFX_RetainPtr& operator=(const CFX_RetainPtr& that) { + RetainPtr& operator=(const RetainPtr& that) { if (*this != that) Reset(that.Get()); return *this; } - CFX_RetainPtr& operator=(CFX_RetainPtr&& that) { + RetainPtr& operator=(RetainPtr&& that) { m_pObj.reset(that.Leak()); return *this; } - bool operator==(const CFX_RetainPtr& that) const { - return Get() == that.Get(); - } - bool operator!=(const CFX_RetainPtr& that) const { return !(*this == that); } + bool operator==(const RetainPtr& that) const { return Get() == that.Get(); } + bool operator!=(const RetainPtr& that) const { return !(*this == that); } - bool operator<(const CFX_RetainPtr& that) const { + bool operator<(const RetainPtr& that) const { return std::less<T*>()(Get(), that.Get()); } @@ -84,19 +84,19 @@ class CFX_RetainPtr { }; // Trivial implementation - internal ref count with virtual destructor. -class CFX_Retainable { +class Retainable { public: bool HasOneRef() const { return m_nRefCount == 1; } protected: - virtual ~CFX_Retainable() {} + virtual ~Retainable() {} private: template <typename U> friend struct ReleaseDeleter; template <typename U> - friend class CFX_RetainPtr; + friend class RetainPtr; void Retain() { ++m_nRefCount; } void Release() { @@ -108,17 +108,23 @@ class CFX_Retainable { intptr_t m_nRefCount = 0; }; +} // namespace fxcrt + +using fxcrt::ReleaseDeleter; +using fxcrt::RetainPtr; +using fxcrt::Retainable; + namespace pdfium { -// Helper to make a CFX_RetainPtr along the lines of std::make_unique<>(), +// Helper to make a RetainPtr along the lines of std::make_unique<>(), // or pdfium::MakeUnique<>(). Arguments are forwarded to T's constructor. -// Classes managed by CFX_RetainPtr should have protected (or private) +// Classes managed by RetainPtr should have protected (or private) // constructors, and should friend this function. template <typename T, typename... Args> -CFX_RetainPtr<T> MakeRetain(Args&&... args) { - return CFX_RetainPtr<T>(new T(std::forward<Args>(args)...)); +RetainPtr<T> MakeRetain(Args&&... args) { + return RetainPtr<T>(new T(std::forward<Args>(args)...)); } } // namespace pdfium -#endif // CORE_FXCRT_CFX_RETAIN_PTR_H_ +#endif // CORE_FXCRT_RETAIN_PTR_H_ diff --git a/core/fxcrt/cfx_retain_ptr_unittest.cpp b/core/fxcrt/retain_ptr_unittest.cpp index eae542fe88..3e14478dbf 100644 --- a/core/fxcrt/cfx_retain_ptr_unittest.cpp +++ b/core/fxcrt/retain_ptr_unittest.cpp @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" #include <utility> #include <vector> @@ -26,15 +26,15 @@ class PseudoRetainable { } // namespace -TEST(fxcrt, RetainPtrNull) { - CFX_RetainPtr<PseudoRetainable> ptr; +TEST(RetainPtr, Null) { + RetainPtr<PseudoRetainable> ptr; EXPECT_EQ(nullptr, ptr.Get()); } -TEST(fxcrt, RetainPtrNormal) { +TEST(RetainPtr, Normal) { PseudoRetainable obj; { - CFX_RetainPtr<PseudoRetainable> ptr(&obj); + RetainPtr<PseudoRetainable> ptr(&obj); EXPECT_EQ(&obj, ptr.Get()); EXPECT_EQ(1, obj.retain_count()); EXPECT_EQ(0, obj.release_count()); @@ -43,12 +43,12 @@ TEST(fxcrt, RetainPtrNormal) { EXPECT_EQ(1, obj.release_count()); } -TEST(fxcrt, RetainPtrCopyCtor) { +TEST(RetainPtr, CopyCtor) { PseudoRetainable obj; { - CFX_RetainPtr<PseudoRetainable> ptr1(&obj); + RetainPtr<PseudoRetainable> ptr1(&obj); { - CFX_RetainPtr<PseudoRetainable> ptr2(ptr1); + RetainPtr<PseudoRetainable> ptr2(ptr1); EXPECT_EQ(2, obj.retain_count()); EXPECT_EQ(0, obj.release_count()); } @@ -59,12 +59,12 @@ TEST(fxcrt, RetainPtrCopyCtor) { EXPECT_EQ(2, obj.release_count()); } -TEST(fxcrt, RetainPtrMoveCtor) { +TEST(RetainPtr, MoveCtor) { PseudoRetainable obj; { - CFX_RetainPtr<PseudoRetainable> ptr1(&obj); + RetainPtr<PseudoRetainable> ptr1(&obj); { - CFX_RetainPtr<PseudoRetainable> ptr2(std::move(ptr1)); + RetainPtr<PseudoRetainable> ptr2(std::move(ptr1)); EXPECT_EQ(nullptr, ptr1.Get()); EXPECT_EQ(&obj, ptr2.Get()); EXPECT_EQ(1, obj.retain_count()); @@ -77,10 +77,10 @@ TEST(fxcrt, RetainPtrMoveCtor) { EXPECT_EQ(1, obj.release_count()); } -TEST(fxcrt, RetainPtrResetNull) { +TEST(RetainPtr, ResetNull) { PseudoRetainable obj; { - CFX_RetainPtr<PseudoRetainable> ptr(&obj); + RetainPtr<PseudoRetainable> ptr(&obj); ptr.Reset(); EXPECT_EQ(1, obj.retain_count()); EXPECT_EQ(1, obj.release_count()); @@ -89,11 +89,11 @@ TEST(fxcrt, RetainPtrResetNull) { EXPECT_EQ(1, obj.release_count()); } -TEST(fxcrt, RetainPtrReset) { +TEST(RetainPtr, Reset) { PseudoRetainable obj1; PseudoRetainable obj2; { - CFX_RetainPtr<PseudoRetainable> ptr(&obj1); + RetainPtr<PseudoRetainable> ptr(&obj1); ptr.Reset(&obj2); EXPECT_EQ(1, obj1.retain_count()); EXPECT_EQ(1, obj1.release_count()); @@ -106,13 +106,13 @@ TEST(fxcrt, RetainPtrReset) { EXPECT_EQ(1, obj2.release_count()); } -TEST(fxcrt, RetainPtrSwap) { +TEST(RetainPtr, Swap) { PseudoRetainable obj1; PseudoRetainable obj2; { - CFX_RetainPtr<PseudoRetainable> ptr1(&obj1); + RetainPtr<PseudoRetainable> ptr1(&obj1); { - CFX_RetainPtr<PseudoRetainable> ptr2(&obj2); + RetainPtr<PseudoRetainable> ptr2(&obj2); ptr1.Swap(ptr2); EXPECT_EQ(1, obj1.retain_count()); EXPECT_EQ(0, obj1.release_count()); @@ -130,11 +130,11 @@ TEST(fxcrt, RetainPtrSwap) { EXPECT_EQ(1, obj2.release_count()); } -TEST(fxcrt, RetainPtrLeak) { +TEST(RetainPtr, Leak) { PseudoRetainable obj; PseudoRetainable* leak; { - CFX_RetainPtr<PseudoRetainable> ptr(&obj); + RetainPtr<PseudoRetainable> ptr(&obj); leak = ptr.Leak(); EXPECT_EQ(1, obj.retain_count()); EXPECT_EQ(0, obj.release_count()); @@ -142,7 +142,7 @@ TEST(fxcrt, RetainPtrLeak) { EXPECT_EQ(1, obj.retain_count()); EXPECT_EQ(0, obj.release_count()); { - CFX_RetainPtr<PseudoRetainable> ptr; + RetainPtr<PseudoRetainable> ptr; ptr.Unleak(leak); EXPECT_EQ(1, obj.retain_count()); EXPECT_EQ(0, obj.release_count()); @@ -151,12 +151,12 @@ TEST(fxcrt, RetainPtrLeak) { EXPECT_EQ(1, obj.release_count()); } -TEST(fxcrt, RetainPtrSwapNull) { +TEST(RetainPtr, SwapNull) { PseudoRetainable obj1; { - CFX_RetainPtr<PseudoRetainable> ptr1(&obj1); + RetainPtr<PseudoRetainable> ptr1(&obj1); { - CFX_RetainPtr<PseudoRetainable> ptr2; + RetainPtr<PseudoRetainable> ptr2; ptr1.Swap(ptr2); EXPECT_FALSE(ptr1); EXPECT_TRUE(ptr2); @@ -170,12 +170,12 @@ TEST(fxcrt, RetainPtrSwapNull) { EXPECT_EQ(1, obj1.release_count()); } -TEST(fxcrt, RetainPtrAssign) { +TEST(RetainPtr, Assign) { PseudoRetainable obj; { - CFX_RetainPtr<PseudoRetainable> ptr(&obj); + RetainPtr<PseudoRetainable> ptr(&obj); { - CFX_RetainPtr<PseudoRetainable> ptr2; + RetainPtr<PseudoRetainable> ptr2; ptr2 = ptr; EXPECT_EQ(2, obj.retain_count()); EXPECT_EQ(0, obj.release_count()); @@ -187,12 +187,12 @@ TEST(fxcrt, RetainPtrAssign) { EXPECT_EQ(2, obj.release_count()); } -TEST(fxcrt, RetainPtrMoveAssign) { +TEST(RetainPtr, MoveAssign) { PseudoRetainable obj; { - CFX_RetainPtr<PseudoRetainable> ptr1(&obj); + RetainPtr<PseudoRetainable> ptr1(&obj); { - CFX_RetainPtr<PseudoRetainable> ptr2; + RetainPtr<PseudoRetainable> ptr2; EXPECT_EQ(&obj, ptr1.Get()); EXPECT_EQ(nullptr, ptr2.Get()); ptr2 = std::move(ptr1); @@ -208,20 +208,20 @@ TEST(fxcrt, RetainPtrMoveAssign) { EXPECT_EQ(1, obj.release_count()); } -TEST(fxcrt, RetainPtrEquals) { +TEST(RetainPtr, Equals) { PseudoRetainable obj1; PseudoRetainable obj2; - CFX_RetainPtr<PseudoRetainable> null_ptr1; - CFX_RetainPtr<PseudoRetainable> obj1_ptr1(&obj1); - CFX_RetainPtr<PseudoRetainable> obj2_ptr1(&obj2); + RetainPtr<PseudoRetainable> null_ptr1; + RetainPtr<PseudoRetainable> obj1_ptr1(&obj1); + RetainPtr<PseudoRetainable> obj2_ptr1(&obj2); { - CFX_RetainPtr<PseudoRetainable> null_ptr2; + RetainPtr<PseudoRetainable> null_ptr2; EXPECT_TRUE(null_ptr1 == null_ptr2); - CFX_RetainPtr<PseudoRetainable> obj1_ptr2(&obj1); + RetainPtr<PseudoRetainable> obj1_ptr2(&obj1); EXPECT_TRUE(obj1_ptr1 == obj1_ptr2); - CFX_RetainPtr<PseudoRetainable> obj2_ptr2(&obj2); + RetainPtr<PseudoRetainable> obj2_ptr2(&obj2); EXPECT_TRUE(obj2_ptr1 == obj2_ptr2); } EXPECT_FALSE(null_ptr1 == obj1_ptr1); @@ -229,16 +229,16 @@ TEST(fxcrt, RetainPtrEquals) { EXPECT_FALSE(obj1_ptr1 == obj2_ptr1); } -TEST(fxcrt, RetainPtrNotEquals) { +TEST(RetainPtr, NotEquals) { PseudoRetainable obj1; PseudoRetainable obj2; - CFX_RetainPtr<PseudoRetainable> null_ptr1; - CFX_RetainPtr<PseudoRetainable> obj1_ptr1(&obj1); - CFX_RetainPtr<PseudoRetainable> obj2_ptr1(&obj2); + RetainPtr<PseudoRetainable> null_ptr1; + RetainPtr<PseudoRetainable> obj1_ptr1(&obj1); + RetainPtr<PseudoRetainable> obj2_ptr1(&obj2); { - CFX_RetainPtr<PseudoRetainable> null_ptr2; - CFX_RetainPtr<PseudoRetainable> obj1_ptr2(&obj1); - CFX_RetainPtr<PseudoRetainable> obj2_ptr2(&obj2); + RetainPtr<PseudoRetainable> null_ptr2; + RetainPtr<PseudoRetainable> obj1_ptr2(&obj1); + RetainPtr<PseudoRetainable> obj2_ptr2(&obj2); EXPECT_FALSE(null_ptr1 != null_ptr2); EXPECT_FALSE(obj1_ptr1 != obj1_ptr2); EXPECT_FALSE(obj2_ptr1 != obj2_ptr2); @@ -248,46 +248,46 @@ TEST(fxcrt, RetainPtrNotEquals) { EXPECT_TRUE(obj1_ptr1 != obj2_ptr1); } -TEST(fxcrt, RetainPtrLessThan) { +TEST(RetainPtr, LessThan) { PseudoRetainable objs[2]; - CFX_RetainPtr<PseudoRetainable> obj1_ptr(&objs[0]); - CFX_RetainPtr<PseudoRetainable> obj2_ptr(&objs[1]); + RetainPtr<PseudoRetainable> obj1_ptr(&objs[0]); + RetainPtr<PseudoRetainable> obj2_ptr(&objs[1]); EXPECT_TRUE(obj1_ptr < obj2_ptr); EXPECT_FALSE(obj2_ptr < obj1_ptr); } -TEST(fxcrt, RetainPtrBool) { +TEST(RetainPtr, Bool) { PseudoRetainable obj1; - CFX_RetainPtr<PseudoRetainable> null_ptr; - CFX_RetainPtr<PseudoRetainable> obj1_ptr(&obj1); + RetainPtr<PseudoRetainable> null_ptr; + RetainPtr<PseudoRetainable> obj1_ptr(&obj1); bool null_bool = !!null_ptr; bool obj1_bool = !!obj1_ptr; EXPECT_FALSE(null_bool); EXPECT_TRUE(obj1_bool); } -TEST(fxcrt, RetainPtrMakeRetained) { - auto ptr = pdfium::MakeRetain<CFX_Retainable>(); +TEST(RetainPtr, MakeRetained) { + auto ptr = pdfium::MakeRetain<Retainable>(); EXPECT_TRUE(ptr->HasOneRef()); { - CFX_RetainPtr<CFX_Retainable> other = ptr; + RetainPtr<Retainable> other = ptr; EXPECT_FALSE(ptr->HasOneRef()); } EXPECT_TRUE(ptr->HasOneRef()); } -TEST(fxcrt, RetainPtrVectorMove) { +TEST(RetainPtr, VectorMove) { // Proves move ctor is selected by std::vector over copy/delete, this // may require the ctor to be marked "noexcept". PseudoRetainable obj; { - CFX_RetainPtr<PseudoRetainable> ptr(&obj); - std::vector<CFX_RetainPtr<PseudoRetainable>> vec1; + RetainPtr<PseudoRetainable> ptr(&obj); + std::vector<RetainPtr<PseudoRetainable>> vec1; vec1.push_back(std::move(ptr)); EXPECT_EQ(1, obj.retain_count()); EXPECT_EQ(0, obj.release_count()); - std::vector<CFX_RetainPtr<PseudoRetainable>> vec2 = std::move(vec1); + std::vector<RetainPtr<PseudoRetainable>> vec2 = std::move(vec1); EXPECT_EQ(1, obj.retain_count()); EXPECT_EQ(0, obj.release_count()); diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp index fa5c80130d..e90d8ced85 100644 --- a/core/fxcrt/widestring.cpp +++ b/core/fxcrt/widestring.cpp @@ -458,7 +458,7 @@ void WideString::ReallocBeforeWrite(FX_STRSIZE nNewLength) { return; } - CFX_RetainPtr<StringData> pNewData(StringData::Create(nNewLength)); + RetainPtr<StringData> pNewData(StringData::Create(nNewLength)); if (m_pData) { FX_STRSIZE nCopyLength = std::min(m_pData->m_nDataLength, nNewLength); pNewData->CopyContents(m_pData->m_String, nCopyLength); @@ -525,7 +525,7 @@ wchar_t* WideString::GetBuffer(FX_STRSIZE nMinBufLength) { if (nMinBufLength == 0) return nullptr; - CFX_RetainPtr<StringData> pNewData(StringData::Create(nMinBufLength)); + RetainPtr<StringData> pNewData(StringData::Create(nMinBufLength)); pNewData->CopyContents(*m_pData); pNewData->m_nDataLength = m_pData->m_nDataLength; m_pData.Swap(pNewData); @@ -568,7 +568,7 @@ void WideString::Concat(const wchar_t* pSrcData, FX_STRSIZE nSrcLen) { return; } - CFX_RetainPtr<StringData> pNewData( + RetainPtr<StringData> pNewData( StringData::Create(m_pData->m_nDataLength + nSrcLen)); pNewData->CopyContents(*m_pData); pNewData->CopyContentsAt(m_pData->m_nDataLength, pSrcData, nSrcLen); @@ -635,7 +635,7 @@ void WideString::AllocCopy(WideString& dest, if (nCopyLen == 0) return; - CFX_RetainPtr<StringData> pNewData( + RetainPtr<StringData> pNewData( StringData::Create(m_pData->m_String + nCopyIndex, nCopyLen)); dest.m_pData.Swap(pNewData); } @@ -816,7 +816,7 @@ FX_STRSIZE WideString::Replace(const WideStringView& pOld, return count; } - CFX_RetainPtr<StringData> pNewData(StringData::Create(nNewLength)); + RetainPtr<StringData> pNewData(StringData::Create(nNewLength)); pStart = m_pData->m_String; wchar_t* pDest = pNewData->m_String; for (FX_STRSIZE i = 0; i < count; i++) { diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h index 8841c84093..4dc0abbc99 100644 --- a/core/fxcrt/widestring.h +++ b/core/fxcrt/widestring.h @@ -11,10 +11,10 @@ #include <iterator> #include <utility> -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_string_data_template.h" #include "core/fxcrt/fx_memory.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/string_view_template.h" #include "third_party/base/optional.h" @@ -192,7 +192,7 @@ class WideString { // Returns true unless we ran out of space. bool TryVSWPrintf(FX_STRSIZE size, const wchar_t* format, va_list argList); - CFX_RetainPtr<StringData> m_pData; + RetainPtr<StringData> m_pData; friend WideString_ConcatInPlace_Test; friend fxcrt_WideStringPool_Test; diff --git a/core/fxcrt/xml/cfx_saxreader.cpp b/core/fxcrt/xml/cfx_saxreader.cpp index e2c09d14cc..762144f4bb 100644 --- a/core/fxcrt/xml/cfx_saxreader.cpp +++ b/core/fxcrt/xml/cfx_saxreader.cpp @@ -54,7 +54,7 @@ CFX_SAXFile::CFX_SAXFile() CFX_SAXFile::~CFX_SAXFile() {} -bool CFX_SAXFile::StartFile(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile, +bool CFX_SAXFile::StartFile(const RetainPtr<IFX_SeekableReadStream>& pFile, uint32_t dwStart, uint32_t dwLen) { ASSERT(!m_pFile && pFile); @@ -186,7 +186,7 @@ bool CFX_SAXReader::SkipSpace(uint8_t ch) { } int32_t CFX_SAXReader::StartParse( - const CFX_RetainPtr<IFX_SeekableReadStream>& pFile, + const RetainPtr<IFX_SeekableReadStream>& pFile, uint32_t dwStart, uint32_t dwLen, uint32_t dwParseMode) { diff --git a/core/fxcrt/xml/cfx_saxreader.h b/core/fxcrt/xml/cfx_saxreader.h index 51d9e43121..9ff755d053 100644 --- a/core/fxcrt/xml/cfx_saxreader.h +++ b/core/fxcrt/xml/cfx_saxreader.h @@ -11,8 +11,8 @@ #include <stack> #include <vector> -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" class CFX_SAXCommentContext; class CFX_SAXContext; @@ -45,13 +45,13 @@ class CFX_SAXFile { CFX_SAXFile(); ~CFX_SAXFile(); - bool StartFile(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile, + bool StartFile(const RetainPtr<IFX_SeekableReadStream>& pFile, uint32_t dwStart, uint32_t dwLen); bool ReadNextBlock(); void Reset(); - CFX_RetainPtr<IFX_SeekableReadStream> m_pFile; + RetainPtr<IFX_SeekableReadStream> m_pFile; uint32_t m_dwStart; uint32_t m_dwEnd; uint32_t m_dwCur; @@ -99,7 +99,7 @@ class CFX_SAXReader { CFX_SAXReader(); ~CFX_SAXReader(); - int32_t StartParse(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile, + int32_t StartParse(const RetainPtr<IFX_SeekableReadStream>& pFile, uint32_t dwStart = 0, uint32_t dwLen = -1, uint32_t dwParseMode = 0); diff --git a/core/fxcrt/xml/cfx_xmldoc.cpp b/core/fxcrt/xml/cfx_xmldoc.cpp index e9a09b761b..30e4a47e72 100644 --- a/core/fxcrt/xml/cfx_xmldoc.cpp +++ b/core/fxcrt/xml/cfx_xmldoc.cpp @@ -48,7 +48,7 @@ void CFX_XMLDoc::CloseXML() { } void CFX_XMLDoc::SaveXMLNode( - const CFX_RetainPtr<CFX_SeekableStreamProxy>& pXMLStream, + const RetainPtr<CFX_SeekableStreamProxy>& pXMLStream, CFX_XMLNode* pINode) { CFX_XMLNode* pNode = (CFX_XMLNode*)pINode; switch (pNode->GetType()) { diff --git a/core/fxcrt/xml/cfx_xmldoc.h b/core/fxcrt/xml/cfx_xmldoc.h index c182504f6f..28de7fdba1 100644 --- a/core/fxcrt/xml/cfx_xmldoc.h +++ b/core/fxcrt/xml/cfx_xmldoc.h @@ -9,8 +9,8 @@ #include <memory> -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_seekablestreamproxy.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/xml/cfx_xmlnode.h" #include "core/fxcrt/xml/cfx_xmlparser.h" @@ -24,14 +24,14 @@ class CFX_XMLDoc { void CloseXML(); CFX_XMLNode* GetRoot() const { return m_pRoot.get(); } - void SaveXMLNode(const CFX_RetainPtr<CFX_SeekableStreamProxy>& pXMLStream, + void SaveXMLNode(const RetainPtr<CFX_SeekableStreamProxy>& pXMLStream, CFX_XMLNode* pNode); private: int32_t m_iStatus; std::unique_ptr<CFX_XMLNode> m_pRoot; std::unique_ptr<CFX_XMLParser> m_pXMLParser; - CFX_RetainPtr<CFX_SeekableStreamProxy> m_pStream; + RetainPtr<CFX_SeekableStreamProxy> m_pStream; }; #endif // CORE_FXCRT_XML_CFX_XMLDOC_H_ diff --git a/core/fxcrt/xml/cfx_xmlnode.cpp b/core/fxcrt/xml/cfx_xmlnode.cpp index 7a893af4a0..a1e3ac2740 100644 --- a/core/fxcrt/xml/cfx_xmlnode.cpp +++ b/core/fxcrt/xml/cfx_xmlnode.cpp @@ -330,7 +330,7 @@ std::unique_ptr<CFX_XMLNode> CFX_XMLNode::Clone() { } void CFX_XMLNode::SaveXMLNode( - const CFX_RetainPtr<CFX_SeekableStreamProxy>& pXMLStream) { + const RetainPtr<CFX_SeekableStreamProxy>& pXMLStream) { CFX_XMLNode* pNode = (CFX_XMLNode*)this; switch (pNode->GetType()) { case FX_XMLNODE_Instruction: { diff --git a/core/fxcrt/xml/cfx_xmlnode.h b/core/fxcrt/xml/cfx_xmlnode.h index 7cbc2b6642..278b3bf15a 100644 --- a/core/fxcrt/xml/cfx_xmlnode.h +++ b/core/fxcrt/xml/cfx_xmlnode.h @@ -9,8 +9,8 @@ #include <memory> -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_seekablestreamproxy.h" +#include "core/fxcrt/retain_ptr.h" enum FX_XMLNODETYPE { FX_XMLNODE_Unknown = 0, @@ -64,7 +64,7 @@ class CFX_XMLNode { bool InsertNodeItem(CFX_XMLNode::NodeItem eItem, CFX_XMLNode* pNode); CFX_XMLNode* RemoveNodeItem(CFX_XMLNode::NodeItem eItem); - void SaveXMLNode(const CFX_RetainPtr<CFX_SeekableStreamProxy>& pXMLStream); + void SaveXMLNode(const RetainPtr<CFX_SeekableStreamProxy>& pXMLStream); CFX_XMLNode* m_pParent; CFX_XMLNode* m_pChild; diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp index 280c06d3f1..a8bb2c9565 100644 --- a/core/fxcrt/xml/cfx_xmlparser.cpp +++ b/core/fxcrt/xml/cfx_xmlparser.cpp @@ -13,9 +13,8 @@ #include "core/fxcrt/xml/cfx_xmltext.h" #include "third_party/base/ptr_util.h" -CFX_XMLParser::CFX_XMLParser( - CFX_XMLNode* pParent, - const CFX_RetainPtr<CFX_SeekableStreamProxy>& pStream) +CFX_XMLParser::CFX_XMLParser(CFX_XMLNode* pParent, + const RetainPtr<CFX_SeekableStreamProxy>& pStream) : m_nElementStart(0), m_dwCheckStatus(0), m_dwCurrentCheckStatus(0), diff --git a/core/fxcrt/xml/cfx_xmlparser.h b/core/fxcrt/xml/cfx_xmlparser.h index f98b658d9a..0038f6d9b2 100644 --- a/core/fxcrt/xml/cfx_xmlparser.h +++ b/core/fxcrt/xml/cfx_xmlparser.h @@ -10,8 +10,8 @@ #include <memory> #include <stack> -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/xml/cfx_xmlsyntaxparser.h" class CFX_XMLElement; @@ -21,7 +21,7 @@ class CFX_SeekableStreamProxy; class CFX_XMLParser { public: CFX_XMLParser(CFX_XMLNode* pParent, - const CFX_RetainPtr<CFX_SeekableStreamProxy>& pStream); + const RetainPtr<CFX_SeekableStreamProxy>& pStream); ~CFX_XMLParser(); int32_t DoParser(); @@ -33,7 +33,7 @@ class CFX_XMLParser { uint16_t m_dwCurrentCheckStatus; private: - CFX_RetainPtr<CFX_SeekableStreamProxy> m_pStream; + RetainPtr<CFX_SeekableStreamProxy> m_pStream; std::unique_ptr<CFX_XMLSyntaxParser> m_pParser; CFX_XMLNode* m_pParent; CFX_XMLNode* m_pChild; diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp index d55985240d..5dcb867623 100644 --- a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp +++ b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp @@ -76,7 +76,7 @@ bool CFX_XMLSyntaxParser::IsXMLNameChar(wchar_t ch, bool bFirstChar) { } CFX_XMLSyntaxParser::CFX_XMLSyntaxParser( - const CFX_RetainPtr<CFX_SeekableStreamProxy>& pStream) + const RetainPtr<CFX_SeekableStreamProxy>& pStream) : m_pStream(pStream), m_iXMLPlaneSize(32 * 1024), m_iCurrentPos(0), diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser.h b/core/fxcrt/xml/cfx_xmlsyntaxparser.h index d3f4bf2edb..8379aa445b 100644 --- a/core/fxcrt/xml/cfx_xmlsyntaxparser.h +++ b/core/fxcrt/xml/cfx_xmlsyntaxparser.h @@ -11,9 +11,9 @@ #include <vector> #include "core/fxcrt/cfx_blockbuffer.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_seekablestreamproxy.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/xml/cfx_xmlnode.h" enum class FX_XmlSyntaxResult { @@ -39,7 +39,7 @@ class CFX_XMLSyntaxParser { static bool IsXMLNameChar(wchar_t ch, bool bFirstChar); explicit CFX_XMLSyntaxParser( - const CFX_RetainPtr<CFX_SeekableStreamProxy>& pStream); + const RetainPtr<CFX_SeekableStreamProxy>& pStream); ~CFX_XMLSyntaxParser(); FX_XmlSyntaxResult DoSyntaxParse(); @@ -100,7 +100,7 @@ class CFX_XMLSyntaxParser { void ParseTextChar(wchar_t ch); - CFX_RetainPtr<CFX_SeekableStreamProxy> m_pStream; + RetainPtr<CFX_SeekableStreamProxy> m_pStream; FX_STRSIZE m_iXMLPlaneSize; FX_FILESIZE m_iCurrentPos; int32_t m_iCurrentNodeNum; diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser_unittest.cpp b/core/fxcrt/xml/cfx_xmlsyntaxparser_unittest.cpp index c3cc3d26bf..b7f7c416b1 100644 --- a/core/fxcrt/xml/cfx_xmlsyntaxparser_unittest.cpp +++ b/core/fxcrt/xml/cfx_xmlsyntaxparser_unittest.cpp @@ -26,7 +26,7 @@ TEST(CFX_XMLSyntaxParserTest, CData) { L" app.alert(\"Tclams\");\n" L" "; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -74,7 +74,7 @@ TEST(CFX_XMLSyntaxParserTest, CDataWithInnerScript) { L" </script>\n" L" "; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -111,7 +111,7 @@ TEST(CFX_XMLSyntaxParserTest, ArrowBangArrow) { " <!>\n" "</script>"; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -146,7 +146,7 @@ TEST(CFX_XMLSyntaxParserTest, ArrowBangBracketArrow) { " <![>\n" "</script>"; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -176,7 +176,7 @@ TEST(CFX_XMLSyntaxParserTest, IncompleteCData) { " <![CDATA>\n" "</script>"; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -206,7 +206,7 @@ TEST(CFX_XMLSyntaxParserTest, UnClosedCData) { " <![CDATA[\n" "</script>"; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -236,7 +236,7 @@ TEST(CFX_XMLSyntaxParserTest, EmptyCData) { " <![CDATA[]]>\n" "</script>"; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -273,7 +273,7 @@ TEST(CFX_XMLSyntaxParserTest, Comment) { " <!-- A Comment -->\n" "</script>"; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -307,7 +307,7 @@ TEST(CFX_XMLSyntaxParserTest, IncorrectCommentStart) { " <!- A Comment -->\n" "</script>"; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -341,7 +341,7 @@ TEST(CFX_XMLSyntaxParserTest, CommentEmpty) { " <!---->\n" "</script>"; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -375,7 +375,7 @@ TEST(CFX_XMLSyntaxParserTest, CommentThreeDash) { " <!--->\n" "</script>"; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -403,7 +403,7 @@ TEST(CFX_XMLSyntaxParserTest, CommentTwoDash) { " <!-->\n" "</script>"; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -435,7 +435,7 @@ TEST(CFX_XMLSyntaxParserTest, Entities) { "�" "</script>"; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -467,7 +467,7 @@ TEST(CFX_XMLSyntaxParserTest, EntityOverflowHex) { "�" "</script>"; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -499,7 +499,7 @@ TEST(CFX_XMLSyntaxParserTest, EntityOverflowDecimal) { "�" "</script>"; - CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + RetainPtr<CFX_SeekableStreamProxy> stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); |