diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-12-14 20:43:53 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-12-14 20:43:53 +0000 |
commit | 51ef4a6ca3b4ae9b618cb1c96f84697a2bf4a2b1 (patch) | |
tree | a365a0c3f25fff2f6511fbc23fd0e4d6b8d4eada /xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | |
parent | 8489e901fb16fe508e23a36cd3eff93d8332c2a2 (diff) | |
download | pdfium-51ef4a6ca3b4ae9b618cb1c96f84697a2bf4a2b1.tar.xz |
Change CXFA_Node::GetChild to return proper types
Currently CXFA_Node::GetChild always returns a CXFA_Node* object. We
know the type we want when we call GetChild, so this CL changes the code
to add a template parameter to GetChild and return the correct CXFA_Node
subtype for the desired element.
Change-Id: I5aecf2e840504235dc246483abee48e0564841fe
Reviewed-on: https://pdfium-review.googlesource.com/21210
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_layoutpagemgr.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index 4d70d7d50f..21b3aca235 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -10,12 +10,14 @@ #include "third_party/base/stl_util.h" #include "xfa/fxfa/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" +#include "xfa/fxfa/parser/cxfa_contentarea.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_itemlayoutprocessor.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_measurement.h" +#include "xfa/fxfa/parser/cxfa_medium.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_nodeiteratortemplate.h" #include "xfa/fxfa/parser/cxfa_object.h" @@ -318,7 +320,8 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) { return false; CXFA_Document* pDocument = pTemplateNode->GetDocument(); - pPageArea = m_pTemplatePageSetRoot->GetChild(0, XFA_Element::PageArea, false); + pPageArea = m_pTemplatePageSetRoot->GetChild<CXFA_Node>( + 0, XFA_Element::PageArea, false); if (!pPageArea) { pPageArea = pDocument->CreateNode(m_pTemplatePageSetRoot->GetPacketType(), XFA_Element::PageArea); @@ -328,11 +331,11 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) { m_pTemplatePageSetRoot->InsertChild(pPageArea, nullptr); pPageArea->SetFlag(XFA_NodeFlag_Initialized, true); } - CXFA_Node* pContentArea = - pPageArea->GetChild(0, XFA_Element::ContentArea, false); + CXFA_ContentArea* pContentArea = + pPageArea->GetChild<CXFA_ContentArea>(0, XFA_Element::ContentArea, false); if (!pContentArea) { - pContentArea = pDocument->CreateNode(pPageArea->GetPacketType(), - XFA_Element::ContentArea); + pContentArea = static_cast<CXFA_ContentArea*>(pDocument->CreateNode( + pPageArea->GetPacketType(), XFA_Element::ContentArea)); if (!pContentArea) return false; @@ -347,10 +350,11 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) { pContentArea->JSObject()->SetMeasure( XFA_Attribute::H, CXFA_Measurement(10.5f, XFA_Unit::In), false); } - CXFA_Node* pMedium = pPageArea->GetChild(0, XFA_Element::Medium, false); + CXFA_Medium* pMedium = + pPageArea->GetChild<CXFA_Medium>(0, XFA_Element::Medium, false); if (!pMedium) { - pMedium = - pDocument->CreateNode(pPageArea->GetPacketType(), XFA_Element::Medium); + pMedium = static_cast<CXFA_Medium*>( + pDocument->CreateNode(pPageArea->GetPacketType(), XFA_Element::Medium)); if (!pContentArea) return false; |