From 604f5b9e042267cffd8949f309a86c370a3d01d4 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Wed, 13 Dec 2017 21:57:12 +0000 Subject: Refactor CFXA_*List constructors This removes the double adding to the cache list in the engine that is occuring for TreeList. It also sets the correct TreeList specific values at the Object level. BUG=pdfium:665 Change-Id: Ie972daee4c638f34ad207f6502dc6d34cbebf1b6 Reviewed-on: https://pdfium-review.googlesource.com/21171 Reviewed-by: dsinclair Commit-Queue: Ryan Harrison --- xfa/fxfa/parser/cxfa_list.cpp | 17 ++++++++++++----- xfa/fxfa/parser/cxfa_list.h | 5 +++++ xfa/fxfa/parser/cxfa_treelist.cpp | 9 +++++---- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/xfa/fxfa/parser/cxfa_list.cpp b/xfa/fxfa/parser/cxfa_list.cpp index 3d56cac140..6f5fc29ca5 100644 --- a/xfa/fxfa/parser/cxfa_list.cpp +++ b/xfa/fxfa/parser/cxfa_list.cpp @@ -15,11 +15,18 @@ #include "xfa/fxfa/parser/cxfa_node.h" CXFA_List::CXFA_List(CXFA_Document* pDocument, std::unique_ptr obj) - : CXFA_Object(pDocument, - XFA_ObjectType::List, - XFA_Element::List, - WideStringView(L"list"), - std::move(obj)) { + : CXFA_List(pDocument, + XFA_ObjectType::List, + XFA_Element::List, + WideStringView(L"list"), + std::move(obj)) {} + +CXFA_List::CXFA_List(CXFA_Document* pDocument, + XFA_ObjectType objectType, + XFA_Element eType, + const WideStringView& elementName, + std::unique_ptr obj) + : CXFA_Object(pDocument, objectType, eType, elementName, std::move(obj)) { m_pDocument->GetScriptContext()->AddToCacheList( std::unique_ptr(this)); } diff --git a/xfa/fxfa/parser/cxfa_list.h b/xfa/fxfa/parser/cxfa_list.h index 2141a8fb10..5736747dba 100644 --- a/xfa/fxfa/parser/cxfa_list.h +++ b/xfa/fxfa/parser/cxfa_list.h @@ -25,6 +25,11 @@ class CXFA_List : public CXFA_Object { protected: CXFA_List(CXFA_Document* doc, std::unique_ptr js_obj); + CXFA_List(CXFA_Document* pDocument, + XFA_ObjectType objectType, + XFA_Element eType, + const WideStringView& elementName, + std::unique_ptr obj); }; #endif // XFA_FXFA_PARSER_CXFA_LIST_H_ diff --git a/xfa/fxfa/parser/cxfa_treelist.cpp b/xfa/fxfa/parser/cxfa_treelist.cpp index 520818c94a..754c80d661 100644 --- a/xfa/fxfa/parser/cxfa_treelist.cpp +++ b/xfa/fxfa/parser/cxfa_treelist.cpp @@ -16,10 +16,11 @@ #include "xfa/fxfa/parser/cxfa_node.h" CXFA_TreeList::CXFA_TreeList(CXFA_Document* pDocument) - : CXFA_List(pDocument, pdfium::MakeUnique(this)) { - m_pDocument->GetScriptContext()->AddToCacheList( - std::unique_ptr(this)); -} + : CXFA_List(pDocument, + XFA_ObjectType::TreeList, + XFA_Element::TreeList, + WideStringView(L"treeList"), + pdfium::MakeUnique(this)) {} CXFA_TreeList::~CXFA_TreeList() {} -- cgit v1.2.3