From 8a0941d6deeee75bf1f9f51a00e61a15d3aa18d1 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 23 Jan 2018 16:52:14 +0000 Subject: Remove CXFA_WidgetAcc from CXFA_FFDocView methods This CL updates CXFA_FFDocView methods and members to use CXFA_Node objects instead of CXFA_WidgetAcc objects. Change-Id: Ic79af39ef49152a6d50ed5acfc153063db39353d Reviewed-on: https://pdfium-review.googlesource.com/23590 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/cxfa_ffcheckbutton.cpp | 4 +-- xfa/fxfa/cxfa_ffcombobox.cpp | 2 +- xfa/fxfa/cxfa_ffdocview.cpp | 76 ++++++++++++++++++++--------------------- xfa/fxfa/cxfa_ffdocview.h | 18 +++++----- xfa/fxfa/cxfa_fffield.cpp | 2 +- xfa/fxfa/cxfa_ffnotify.cpp | 18 ++++------ xfa/fxfa/parser/cxfa_node.cpp | 2 +- 7 files changed, 57 insertions(+), 65 deletions(-) (limited to 'xfa') diff --git a/xfa/fxfa/cxfa_ffcheckbutton.cpp b/xfa/fxfa/cxfa_ffcheckbutton.cpp index 4f9f402fff..a52bcb7d14 100644 --- a/xfa/fxfa/cxfa_ffcheckbutton.cpp +++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp @@ -314,8 +314,8 @@ void CXFA_FFCheckButton::OnProcessEvent(CFWL_Event* pEvent) { if (ProcessCommittedData()) { eParam.m_pTarget = exclNode; if (exclNode) { - m_pDocView->AddValidateWidget(exclNode->GetWidgetAcc()); - m_pDocView->AddCalculateWidgetAcc(exclNode->GetWidgetAcc()); + m_pDocView->AddValidateNode(exclNode); + m_pDocView->AddCalculateNode(exclNode); exclNode->ProcessEvent(GetDocView(), XFA_AttributeEnum::Change, &eParam); } diff --git a/xfa/fxfa/cxfa_ffcombobox.cpp b/xfa/fxfa/cxfa_ffcombobox.cpp index 3f3cfe3d36..fcb8eb1aa5 100644 --- a/xfa/fxfa/cxfa_ffcombobox.cpp +++ b/xfa/fxfa/cxfa_ffcombobox.cpp @@ -307,7 +307,7 @@ void CXFA_FFComboBox::OnSelectChanged(CFWL_Widget* pWidget, bool bLButtonUp) { eParam.m_wsPrevText = m_pNode->GetWidgetAcc()->GetValue(XFA_VALUEPICTURE_Raw); FWLEventSelChange(&eParam); if (m_pNode->GetWidgetAcc()->IsChoiceListCommitOnSelect() && bLButtonUp) - m_pDocView->SetFocusWidgetAcc(nullptr); + m_pDocView->SetFocusNode(nullptr); } void CXFA_FFComboBox::OnPreOpen(CFWL_Widget* pWidget) { diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index 50fa5033fe..376f2d412d 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -134,9 +134,9 @@ void CXFA_FFDocView::StopLayout() { if (RunLayout()) ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true); - m_CalculateAccs.clear(); - if (m_pFocusAcc && !m_pFocusWidget) - SetFocusWidgetAcc(m_pFocusAcc.Get()); + m_CalculateNodes.clear(); + if (m_pFocusNode && !m_pFocusWidget) + SetFocusNode(m_pFocusNode.Get()); m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_End; } @@ -186,7 +186,7 @@ void CXFA_FFDocView::UpdateDocView() { RunEventLayoutReady(); m_bLayoutEvent = false; - m_CalculateAccs.clear(); + m_CalculateNodes.clear(); RunInvalidate(); UnlockUpdate(); } @@ -216,7 +216,7 @@ bool CXFA_FFDocView::ResetSingleNodeData(CXFA_Node* pNode) { if (!validate) return true; - AddValidateWidget(pNode->GetWidgetAcc()); + AddValidateNode(pNode); validate->SetFlag(XFA_NodeFlag_NeedsInitApp, false); return true; } @@ -296,23 +296,23 @@ bool CXFA_FFDocView::SetFocus(CXFA_FFWidget* hWidget) { } if (pNewFocus) { CXFA_Node* node = pNewFocus->GetNode(); - m_pFocusAcc = node->IsWidgetReady() ? node->GetWidgetAcc() : nullptr; + m_pFocusNode = node->IsWidgetReady() ? node : nullptr; } else { - m_pFocusAcc = nullptr; + m_pFocusNode = nullptr; } m_pFocusWidget = pNewFocus; m_pOldFocusWidget = m_pFocusWidget; return true; } -void CXFA_FFDocView::SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { +void CXFA_FFDocView::SetFocusNode(CXFA_Node* node) { CXFA_FFWidget* pNewFocus = nullptr; - if (pWidgetAcc) - pNewFocus = GetWidgetForNode(pWidgetAcc->GetNode()); + if (node) + pNewFocus = GetWidgetForNode(node); if (!SetFocus(pNewFocus)) return; - m_pFocusAcc = pWidgetAcc; + m_pFocusNode = node; if (m_iStatus != XFA_DOCVIEW_LAYOUTSTATUS_End) return; @@ -321,10 +321,10 @@ void CXFA_FFDocView::SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { } void CXFA_FFDocView::DeleteLayoutItem(CXFA_FFWidget* pWidget) { - if (m_pFocusAcc && m_pFocusAcc->GetNode() != pWidget->GetNode()) + if (m_pFocusNode != pWidget->GetNode()) return; - m_pFocusAcc = nullptr; + m_pFocusNode = nullptr; m_pFocusWidget = nullptr; m_pOldFocusWidget = nullptr; } @@ -514,11 +514,11 @@ void CXFA_FFDocView::RunDocClose() { ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose, false, true); } -void CXFA_FFDocView::AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { - CXFA_WidgetAcc* pCurrentAcc = - !m_CalculateAccs.empty() ? m_CalculateAccs.back() : nullptr; - if (pCurrentAcc != pWidgetAcc) - m_CalculateAccs.push_back(pWidgetAcc); +void CXFA_FFDocView::AddCalculateNode(CXFA_Node* node) { + CXFA_Node* pCurrentNode = + !m_CalculateNodes.empty() ? m_CalculateNodes.back() : nullptr; + if (pCurrentNode != node) + m_CalculateNodes.push_back(node); } void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) { @@ -528,13 +528,13 @@ void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) { for (auto* pResult : pGlobalData->m_Globals) { if (!pResult->HasRemovedChildren() && pResult->IsWidgetReady()) - AddCalculateWidgetAcc(pResult->GetWidgetAcc()); + AddCalculateNode(pResult); } } size_t CXFA_FFDocView::RunCalculateRecursive(size_t index) { - while (index < m_CalculateAccs.size()) { - CXFA_Node* node = m_CalculateAccs[index]->GetNode(); + while (index < m_CalculateNodes.size()) { + CXFA_Node* node = m_CalculateNodes[index]; AddCalculateNodeNotify(node); size_t recurse = node->JSObject()->GetCalcRecursionCount() + 1; @@ -543,7 +543,7 @@ size_t CXFA_FFDocView::RunCalculateRecursive(size_t index) { break; if (node->ProcessCalculate(this) == XFA_EVENTERROR_Success && node->IsWidgetReady()) { - AddValidateWidget(node->GetWidgetAcc()); + AddValidateNode(node); } index = RunCalculateRecursive(++index); @@ -554,28 +554,28 @@ size_t CXFA_FFDocView::RunCalculateRecursive(size_t index) { int32_t CXFA_FFDocView::RunCalculateWidgets() { if (!m_pDoc->GetDocEnvironment()->IsCalculationsEnabled(m_pDoc.Get())) return XFA_EVENTERROR_Disabled; - if (!m_CalculateAccs.empty()) + if (!m_CalculateNodes.empty()) RunCalculateRecursive(0); - for (CXFA_WidgetAcc* pCurAcc : m_CalculateAccs) - pCurAcc->GetNode()->JSObject()->SetCalcRecursionCount(0); + for (CXFA_Node* node : m_CalculateNodes) + node->JSObject()->SetCalcRecursionCount(0); - m_CalculateAccs.clear(); + m_CalculateNodes.clear(); return XFA_EVENTERROR_Success; } -void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) { - if (!pdfium::ContainsValue(m_ValidateAccs, pWidget)) - m_ValidateAccs.push_back(pWidget); +void CXFA_FFDocView::AddValidateNode(CXFA_Node* node) { + if (!pdfium::ContainsValue(m_ValidateNodes, node)) + m_ValidateNodes.push_back(node); } void CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) { ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate, false, true); } -void CXFA_FFDocView::ProcessValueChanged(CXFA_WidgetAcc* widgetAcc) { - AddValidateWidget(widgetAcc); - AddCalculateWidgetAcc(widgetAcc); +void CXFA_FFDocView::ProcessValueChanged(CXFA_Node* node) { + AddValidateNode(node); + AddCalculateNode(node); RunCalculateWidgets(); RunValidate(); } @@ -585,7 +585,7 @@ bool CXFA_FFDocView::InitValidate(CXFA_Node* pNode) { return false; ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate, false, true); - m_ValidateAccs.clear(); + m_ValidateNodes.clear(); return true; } @@ -593,12 +593,11 @@ bool CXFA_FFDocView::RunValidate() { if (!m_pDoc->GetDocEnvironment()->IsValidationsEnabled(m_pDoc.Get())) return false; - for (CXFA_WidgetAcc* pAcc : m_ValidateAccs) { - CXFA_Node* node = pAcc->GetNode(); + for (CXFA_Node* node : m_ValidateNodes) { if (!node->HasRemovedChildren()) node->ProcessValidate(this, 0); } - m_ValidateAccs.clear(); + m_ValidateNodes.clear(); return true; } @@ -622,7 +621,6 @@ void CXFA_FFDocView::RunBindItems() { if (!pWidgetNode->IsWidgetReady()) continue; - CXFA_WidgetAcc* pAcc = pWidgetNode->GetWidgetAcc(); CFXJSE_Engine* pScriptContext = pWidgetNode->GetDocument()->GetScriptContext(); WideString wsRef = item->GetRef(); @@ -632,7 +630,7 @@ void CXFA_FFDocView::RunBindItems() { XFA_RESOLVENODE_RS rs; pScriptContext->ResolveObjects(pWidgetNode, wsRef.AsStringView(), &rs, dwStyle, nullptr); - pAcc->DeleteItem(-1, false, false); + pWidgetNode->GetWidgetAcc()->DeleteItem(-1, false, false); if (rs.dwFlags != XFA_ResolveNode_RSType_Nodes || rs.objects.empty()) continue; @@ -669,7 +667,7 @@ void CXFA_FFDocView::RunBindItems() { } else { wsLabel = wsValue; } - pAcc->InsertItem(wsLabel, wsValue, false); + pWidgetNode->GetWidgetAcc()->InsertItem(wsLabel, wsValue, false); } } m_BindItems.clear(); diff --git a/xfa/fxfa/cxfa_ffdocview.h b/xfa/fxfa/cxfa_ffdocview.h index d21d64c7ba..b3cc5b83b7 100644 --- a/xfa/fxfa/cxfa_ffdocview.h +++ b/xfa/fxfa/cxfa_ffdocview.h @@ -19,8 +19,8 @@ class CXFA_BindItems; class CXFA_FFWidgetHandler; class CXFA_FFDoc; class CXFA_FFWidget; +class CXFA_Node; class CXFA_Subform; -class CXFA_WidgetAcc; class CXFA_ReadyNodeIterator; extern const XFA_AttributeEnum gs_EventActivity[]; @@ -72,19 +72,19 @@ class CXFA_FFDocView { void RunInvalidate(); void RunDocClose(); - void ProcessValueChanged(CXFA_WidgetAcc* widgetAcc); + void ProcessValueChanged(CXFA_Node* node); void SetChangeMark(); - void AddValidateWidget(CXFA_WidgetAcc* pWidget); + void AddValidateNode(CXFA_Node* node); void AddCalculateNodeNotify(CXFA_Node* pNodeChange); - void AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc); + void AddCalculateNode(CXFA_Node* node); bool RunLayout(); void AddNewFormNode(CXFA_Node* pNode); void AddIndexChangedSubform(CXFA_Node* pNode); - CXFA_WidgetAcc* GetFocusWidgetAcc() const { return m_pFocusAcc.Get(); } - void SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc); + CXFA_Node* GetFocusNode() const { return m_pFocusNode.Get(); } + void SetFocusNode(CXFA_Node* pNode); void DeleteLayoutItem(CXFA_FFWidget* pWidget); int32_t ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, XFA_EVENTTYPE eEventType, @@ -116,12 +116,12 @@ class CXFA_FFDocView { UnownedPtr const m_pDoc; std::unique_ptr m_pWidgetHandler; CXFA_LayoutProcessor* m_pXFADocLayout = nullptr; // Not owned. - UnownedPtr m_pFocusAcc; + UnownedPtr m_pFocusNode; UnownedPtr m_pFocusWidget; UnownedPtr m_pOldFocusWidget; std::map> m_mapPageInvalidate; - std::vector m_ValidateAccs; - std::vector m_CalculateAccs; + std::vector m_ValidateNodes; + std::vector m_CalculateNodes; std::vector m_BindItems; std::vector m_NewAddedNodes; std::vector m_IndexChangedSubforms; diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp index 971936a86d..64e8e00340 100644 --- a/xfa/fxfa/cxfa_fffield.cpp +++ b/xfa/fxfa/cxfa_fffield.cpp @@ -630,7 +630,7 @@ bool CXFA_FFField::ProcessCommittedData() { return false; m_pDocView->SetChangeMark(); - m_pDocView->AddValidateWidget(m_pNode->GetWidgetAcc()); + m_pDocView->AddValidateNode(m_pNode.Get()); return true; } diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp index 072359b621..91d1a65997 100644 --- a/xfa/fxfa/cxfa_ffnotify.cpp +++ b/xfa/fxfa/cxfa_ffnotify.cpp @@ -240,8 +240,8 @@ void CXFA_FFNotify::AddCalcValidate(CXFA_Node* pNode) { if (!pNode->GetWidgetAcc()) return; - pDocView->AddCalculateWidgetAcc(pNode->GetWidgetAcc()); - pDocView->AddValidateWidget(pNode->GetWidgetAcc()); + pDocView->AddCalculateNode(pNode); + pDocView->AddValidateNode(pNode); } CXFA_FFDoc* CXFA_FFNotify::GetHDOC() { @@ -315,20 +315,14 @@ void CXFA_FFNotify::RunSubformIndexChange(CXFA_Node* pSubformNode) { CXFA_Node* CXFA_FFNotify::GetFocusWidgetNode() { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) - return nullptr; - - return pDocView->GetFocusWidgetAcc() - ? pDocView->GetFocusWidgetAcc()->GetNode() - : nullptr; + return pDocView ? pDocView->GetFocusNode() : nullptr; } void CXFA_FFNotify::SetFocusWidgetNode(CXFA_Node* pNode) { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); if (!pDocView) return; - - pDocView->SetFocusWidgetAcc(pNode ? pNode->GetWidgetAcc() : nullptr); + pDocView->SetFocusNode(pNode); } void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) { @@ -423,8 +417,8 @@ void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender, if (bIsContainerNode) { pWidgetNode->GetWidgetAcc()->UpdateUIDisplay(m_pDoc->GetDocView(), nullptr); - pDocView->AddCalculateWidgetAcc(pWidgetNode->GetWidgetAcc()); - pDocView->AddValidateWidget(pWidgetNode->GetWidgetAcc()); + pDocView->AddCalculateNode(pWidgetNode); + pDocView->AddValidateNode(pWidgetNode); } else if (pWidgetNode->GetParent()->GetElementType() == XFA_Element::ExclGroup) { pWidgetNode->GetWidgetAcc()->UpdateUIDisplay(m_pDoc->GetDocView(), diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index fb2f012e0c..ba882a2b9d 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -2206,7 +2206,7 @@ std::pair CXFA_Node::ExecuteBoolScript( (GetRawValue() != pEventParam->m_wsResult)) { GetWidgetAcc()->SetValue(XFA_VALUEPICTURE_Raw, pEventParam->m_wsResult); - docView->AddValidateWidget(GetWidgetAcc()); + docView->AddValidateNode(this); } } for (CXFA_Node* pRefNode : refNodes) { -- cgit v1.2.3