summaryrefslogtreecommitdiff
path: root/xfa/fde/css/fde_cssdatatable.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-01-17 16:35:16 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-01-17 22:04:45 +0000
commit3285c56b0dd6b83c2fcc8b8f714324185a09c920 (patch)
tree1da61ece5e7ca7f8a99cdb00ad0f5f41e2020afb /xfa/fde/css/fde_cssdatatable.cpp
parentda489976371eb928d8b4d004744667fdf82b90d4 (diff)
downloadpdfium-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.cpp')
-rw-r--r--xfa/fde/css/fde_cssdatatable.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/xfa/fde/css/fde_cssdatatable.cpp b/xfa/fde/css/fde_cssdatatable.cpp
index 569a6f2bf9..82a29e2f06 100644
--- a/xfa/fde/css/fde_cssdatatable.cpp
+++ b/xfa/fde/css/fde_cssdatatable.cpp
@@ -6,6 +6,8 @@
#include "xfa/fde/css/fde_cssdatatable.h"
+#include <utility>
+
#include "core/fxcrt/fx_ext.h"
#include "xfa/fde/css/fde_cssstyleselector.h"
#include "xfa/fgas/crt/fgas_codepage.h"
@@ -535,20 +537,19 @@ bool FDE_ParseCSSColor(const FX_WCHAR* pszValue,
}
CFDE_CSSValueList::CFDE_CSSValueList(
- const CFX_ArrayTemplate<CFDE_CSSValue*>& list)
- : CFDE_CSSValue(FDE_CSSVALUETYPE_List) {
- m_iCount = list.GetSize();
- m_ppList = FX_Alloc(CFDE_CSSValue*, m_iCount);
- FXSYS_memcpy(m_ppList, list.GetData(), m_iCount * sizeof(CFDE_CSSValue*));
-}
+ std::vector<CFX_RetainPtr<CFDE_CSSValue>>& list)
+ : CFDE_CSSValue(FDE_CSSVALUETYPE_List), m_ppList(std::move(list)) {}
+
+CFDE_CSSValueList::~CFDE_CSSValueList() {}
int32_t CFDE_CSSValueList::CountValues() const {
- return m_iCount;
+ return m_ppList.size();
}
CFDE_CSSValue* CFDE_CSSValueList::GetValue(int32_t index) const {
- return m_ppList[index];
+ return m_ppList[index].Get();
}
+
bool CFDE_CSSValueListParser::NextValue(FDE_CSSPrimitiveType& eType,
const FX_WCHAR*& pStart,
int32_t& iLength) {
@@ -651,9 +652,6 @@ int32_t CFDE_CSSValueListParser::SkipTo(FX_WCHAR wch,
return m_pCur - pStart;
}
-CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(
- const CFDE_CSSPrimitiveValue& src) = default;
-
CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(FX_ARGB color)
: CFDE_CSSValue(FDE_CSSVALUETYPE_Primitive),
m_eType(FDE_CSSPrimitiveType::RGB),
@@ -678,10 +676,13 @@ CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(FDE_CSSPrimitiveType eType,
ASSERT(m_pString);
}
-CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(CFDE_CSSFunction* pFunction)
+CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(
+ std::unique_ptr<CFDE_CSSFunction> pFunction)
: CFDE_CSSValue(FDE_CSSVALUETYPE_Primitive),
m_eType(FDE_CSSPrimitiveType::Function),
- m_pFunction(pFunction) {}
+ m_pFunction(std::move(pFunction)) {}
+
+CFDE_CSSPrimitiveValue::~CFDE_CSSPrimitiveValue() {}
FDE_CSSPrimitiveType CFDE_CSSPrimitiveValue::GetPrimitiveType() const {
return m_eType;
@@ -724,3 +725,11 @@ CFDE_CSSValue* CFDE_CSSPrimitiveValue::GetArgs(int32_t index) const {
ASSERT(m_eType == FDE_CSSPrimitiveType::Function);
return m_pFunction->GetArgs(index);
}
+
+CFDE_CSSFunction::CFDE_CSSFunction(const FX_WCHAR* pszFuncName,
+ CFX_RetainPtr<CFDE_CSSValueList> pArgList)
+ : m_pArgList(pArgList), m_pszFuncName(pszFuncName) {
+ ASSERT(pArgList);
+}
+
+CFDE_CSSFunction::~CFDE_CSSFunction() {}