From 1ca42167e5913eddf57f137fd7b4cc2110b6cd1f Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 22 Jan 2018 22:01:57 +0000 Subject: Convert CXFA_FFWidgetHandler to use CXFA_Node This CL removes CXFA_WidgetAcc from CXFA_FFWidgetHandler and uses CXFA_Node directly. Change-Id: I88cf1edc53f4489aeac018a95e9d5936d85106db Reviewed-on: https://pdfium-review.googlesource.com/23450 Commit-Queue: dsinclair Reviewed-by: Henrique Nakashima --- xfa/fxfa/parser/cxfa_node.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'xfa/fxfa/parser/cxfa_node.cpp') diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 026e013dae..6d670c462d 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -1840,8 +1840,8 @@ int32_t CXFA_Node::ProcessEvent(CXFA_FFDocView* docView, if (GetElementType() == XFA_Element::Draw) return XFA_EVENTERROR_NotExist; - std::vector eventArray = GetWidgetAcc()->GetEventByActivity( - iActivity, pEventParam->m_bIsFormReady); + std::vector eventArray = + GetEventByActivity(iActivity, pEventParam->m_bIsFormReady); bool first = true; int32_t iRet = XFA_EVENTERROR_NotExist; for (CXFA_Event* event : eventArray) { @@ -2430,3 +2430,30 @@ CFX_RectF CXFA_Node::GetUIMargin() { return CFX_RectF(left.value_or(0.0), top.value_or(0.0), right.value_or(0.0), bottom.value_or(0.0)); } + +std::vector CXFA_Node::GetEventByActivity( + XFA_AttributeEnum iActivity, + bool bIsFormReady) { + std::vector events; + for (CXFA_Node* node : GetNodeList(0, XFA_Element::Event)) { + auto* event = static_cast(node); + if (event->GetActivity() != iActivity) + continue; + + if (iActivity != XFA_AttributeEnum::Ready) { + events.push_back(event); + continue; + } + + WideString wsRef = event->GetRef(); + if (bIsFormReady) { + if (wsRef == WideStringView(L"$form")) + events.push_back(event); + continue; + } + + if (wsRef == WideStringView(L"$layout")) + events.push_back(event); + } + return events; +} -- cgit v1.2.3