diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-01-17 16:35:16 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-01-17 22:04:45 +0000 |
commit | 3285c56b0dd6b83c2fcc8b8f714324185a09c920 (patch) | |
tree | 1da61ece5e7ca7f8a99cdb00ad0f5f41e2020afb /xfa/fde/css/fde_cssdatatable.h | |
parent | da489976371eb928d8b4d004744667fdf82b90d4 (diff) | |
download | pdfium-3285c56b0dd6b83c2fcc8b8f714324185a09c920.tar.xz |
Start CSS parser unit tests
Start adding unit tests for the css parser. Fixup memory
leaks that are exposed by the tests.
Change-Id: Id863d9cd5f13ab82626bc7b945de925253c88d43
Reviewed-on: https://pdfium-review.googlesource.com/2180
Reviewed-by: Nicolás Peña <npm@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fde/css/fde_cssdatatable.h')
-rw-r--r-- | xfa/fde/css/fde_cssdatatable.h | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/xfa/fde/css/fde_cssdatatable.h b/xfa/fde/css/fde_cssdatatable.h index 0904b445d9..0b14ffc101 100644 --- a/xfa/fde/css/fde_cssdatatable.h +++ b/xfa/fde/css/fde_cssdatatable.h @@ -7,6 +7,9 @@ #ifndef XFA_FDE_CSS_FDE_CSSDATATABLE_H_ #define XFA_FDE_CSS_FDE_CSSDATATABLE_H_ +#include <memory> +#include <vector> + #include "core/fxcrt/fx_system.h" #include "xfa/fde/css/cfde_cssvalue.h" #include "xfa/fde/css/fde_css.h" @@ -17,10 +20,11 @@ class CFDE_CSSPrimitiveValue : public CFDE_CSSValue { public: explicit CFDE_CSSPrimitiveValue(FX_ARGB color); explicit CFDE_CSSPrimitiveValue(FDE_CSSPropertyValue eValue); - explicit CFDE_CSSPrimitiveValue(CFDE_CSSFunction* pFunction); + explicit CFDE_CSSPrimitiveValue(std::unique_ptr<CFDE_CSSFunction> pFunction); CFDE_CSSPrimitiveValue(FDE_CSSPrimitiveType eType, FX_FLOAT fValue); CFDE_CSSPrimitiveValue(FDE_CSSPrimitiveType eType, const FX_WCHAR* pValue); CFDE_CSSPrimitiveValue(const CFDE_CSSPrimitiveValue& src); + ~CFDE_CSSPrimitiveValue() override; FDE_CSSPrimitiveType GetPrimitiveType() const; FX_ARGB GetRGBColor() const; @@ -37,20 +41,20 @@ class CFDE_CSSPrimitiveValue : public CFDE_CSSValue { FX_FLOAT m_fNumber; const FX_WCHAR* m_pString; FDE_CSSPropertyValue m_eEnum; - CFDE_CSSFunction* m_pFunction; }; + std::unique_ptr<CFDE_CSSFunction> m_pFunction; }; class CFDE_CSSValueList : public CFDE_CSSValue { public: - explicit CFDE_CSSValueList(const CFX_ArrayTemplate<CFDE_CSSValue*>& list); + explicit CFDE_CSSValueList(std::vector<CFX_RetainPtr<CFDE_CSSValue>>& list); + ~CFDE_CSSValueList() override; int32_t CountValues() const; CFDE_CSSValue* GetValue(int32_t index) const; protected: - CFDE_CSSValue** m_ppList; - int32_t m_iCount; + std::vector<CFX_RetainPtr<CFDE_CSSValue>> m_ppList; }; class CFDE_CSSValueListParser { @@ -75,10 +79,10 @@ class CFDE_CSSValueListParser { class CFDE_CSSFunction { public: - CFDE_CSSFunction(const FX_WCHAR* pszFuncName, CFDE_CSSValueList* pArgList) - : m_pArgList(pArgList), m_pszFuncName(pszFuncName) { - ASSERT(pArgList); - } + CFDE_CSSFunction(const FX_WCHAR* pszFuncName, + CFX_RetainPtr<CFDE_CSSValueList> pArgList); + ~CFDE_CSSFunction(); + int32_t CountArgs() const { return m_pArgList->CountValues(); } CFDE_CSSValue* GetArgs(int32_t index) const { return m_pArgList->GetValue(index); @@ -86,7 +90,7 @@ class CFDE_CSSFunction { const FX_WCHAR* GetFuncName() const { return m_pszFuncName; } protected: - CFDE_CSSValueList* m_pArgList; + CFX_RetainPtr<CFDE_CSSValueList> m_pArgList; const FX_WCHAR* m_pszFuncName; }; |