summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp36
-rw-r--r--xfa/fxfa/cxfa_ffnotify.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp9
-rw-r--r--xfa/fxfa/cxfa_textprovider.cpp2
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp4
-rw-r--r--xfa/fxfa/cxfa_widgetacciterator.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_object.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_object.h11
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp7
10 files changed, 45 insertions, 34 deletions
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index c4e52990d5..b13aa3a0ac 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -374,7 +374,12 @@ bool CXFA_FFDocView::SetFocus(CXFA_FFWidget* hWidget) {
pNewFocus->LoadWidget();
pNewFocus->OnSetFocus(m_pFocusWidget.Get());
}
- m_pFocusAcc = pNewFocus ? pNewFocus->GetNode()->GetWidgetAcc() : nullptr;
+ if (pNewFocus) {
+ CXFA_Node* node = pNewFocus->GetNode();
+ m_pFocusAcc = node->IsWidgetReady() ? node->GetWidgetAcc() : nullptr;
+ } else {
+ m_pFocusAcc = nullptr;
+ }
m_pFocusWidget = pNewFocus;
m_pOldFocusWidget = m_pFocusWidget;
return true;
@@ -455,10 +460,10 @@ int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode,
if (eEventType == XFA_EVENT_IndexChange)
return XFA_EVENTERROR_NotExist;
- CXFA_WidgetAcc* pWidgetAcc = pFormNode->GetWidgetAcc();
- if (!pWidgetAcc)
+ if (!pFormNode->IsWidgetReady())
return XFA_EVENTERROR_NotExist;
+ CXFA_WidgetAcc* pWidgetAcc = pFormNode->GetWidgetAcc();
CXFA_EventParam eParam;
eParam.m_eType = eEventType;
eParam.m_pTarget = pWidgetAcc;
@@ -478,10 +483,10 @@ int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode,
}
}
}
- CXFA_WidgetAcc* pWidgetAcc = pFormNode->GetWidgetAcc();
- if (!pWidgetAcc)
+ if (!pFormNode->IsWidgetReady())
return iRet;
+ CXFA_WidgetAcc* pWidgetAcc = pFormNode->GetWidgetAcc();
CXFA_EventParam eParam;
eParam.m_eType = eEventType;
eParam.m_pTarget = pWidgetAcc;
@@ -493,8 +498,11 @@ int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode,
CXFA_FFWidget* CXFA_FFDocView::GetWidgetByName(const WideString& wsName,
CXFA_FFWidget* pRefWidget) {
- CXFA_WidgetAcc* pRefAcc =
- pRefWidget ? pRefWidget->GetNode()->GetWidgetAcc() : nullptr;
+ CXFA_WidgetAcc* pRefAcc = nullptr;
+ if (pRefWidget) {
+ CXFA_Node* node = pRefWidget->GetNode();
+ pRefAcc = node->IsWidgetReady() ? node->GetWidgetAcc() : nullptr;
+ }
CXFA_WidgetAcc* pAcc = GetWidgetAccByName(wsName, pRefAcc);
if (!pAcc)
return nullptr;
@@ -527,7 +535,7 @@ CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName(
if (resolveNodeRS.dwFlags == XFA_ResolveNode_RSType_Nodes) {
CXFA_Node* pNode = resolveNodeRS.objects.front()->AsNode();
- if (pNode)
+ if (pNode && pNode->IsWidgetReady())
return pNode->GetWidgetAcc();
}
return nullptr;
@@ -584,7 +592,7 @@ bool CXFA_FFDocView::RunLayout() {
void CXFA_FFDocView::RunSubformIndexChange() {
for (CXFA_Node* pSubformNode : m_IndexChangedSubforms) {
- if (!pSubformNode->GetWidgetAcc())
+ if (!pSubformNode->IsWidgetReady())
continue;
CXFA_EventParam eParam;
@@ -637,7 +645,7 @@ void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) {
return;
for (auto* pResult : pGlobalData->m_Globals) {
- if (!pResult->HasRemovedChildren())
+ if (!pResult->HasRemovedChildren() && pResult->IsWidgetReady())
AddCalculateWidgetAcc(pResult->GetWidgetAcc());
}
}
@@ -651,8 +659,10 @@ size_t CXFA_FFDocView::RunCalculateRecursive(size_t index) {
node->JSObject()->SetCalcRecursionCount(recurse);
if (recurse > 11)
break;
- if (node->ProcessCalculate(this) == XFA_EVENTERROR_Success)
+ if (node->ProcessCalculate(this) == XFA_EVENTERROR_Success &&
+ node->IsWidgetReady()) {
AddValidateWidget(node->GetWidgetAcc());
+ }
index = RunCalculateRecursive(++index);
}
@@ -729,10 +739,10 @@ void CXFA_FFDocView::RunBindItems() {
continue;
CXFA_Node* pWidgetNode = item->GetParent();
- CXFA_WidgetAcc* pAcc = pWidgetNode->GetWidgetAcc();
- if (!pAcc)
+ if (!pWidgetNode->IsWidgetReady())
continue;
+ CXFA_WidgetAcc* pAcc = pWidgetNode->GetWidgetAcc();
CFXJSE_Engine* pScriptContext =
pWidgetNode->GetDocument()->GetScriptContext();
WideString wsRef = item->GetRef();
diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp
index 3f41620030..301a8ecf04 100644
--- a/xfa/fxfa/cxfa_ffnotify.cpp
+++ b/xfa/fxfa/cxfa_ffnotify.cpp
@@ -344,7 +344,7 @@ void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) {
return;
if (pNode->HasCreatedUIWidget()) {
- pNode->CreateWidgetAcc();
+ pNode->SetWidgetReady();
return;
}
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 71c45c7620..00bbc0833f 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -564,13 +564,8 @@ bool CXFA_FFWidget::IsLayoutRectEmpty() {
CXFA_FFWidget* CXFA_FFWidget::GetParent() {
CXFA_Node* pParentNode = m_pNode->GetParent();
if (pParentNode) {
- CXFA_WidgetAcc* pParentWidgetAcc =
- static_cast<CXFA_WidgetAcc*>(pParentNode->GetWidgetAcc());
- if (pParentWidgetAcc) {
- CXFA_LayoutProcessor* layout = GetDocView()->GetXFALayout();
- return static_cast<CXFA_FFWidget*>(
- layout->GetLayoutItem(pParentWidgetAcc->GetNode()));
- }
+ CXFA_LayoutProcessor* layout = GetDocView()->GetXFALayout();
+ return static_cast<CXFA_FFWidget*>(layout->GetLayoutItem(pParentNode));
}
return nullptr;
}
diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp
index 55da28182e..a2da41ca40 100644
--- a/xfa/fxfa/cxfa_textprovider.cpp
+++ b/xfa/fxfa/cxfa_textprovider.cpp
@@ -166,7 +166,7 @@ bool CXFA_TextProvider::GetEmbbedObj(bool bURI,
wsAttr.AsStringView());
}
if (pIDNode)
- pEmbAcc = pIDNode->GetWidgetAcc();
+ pEmbAcc = pIDNode->IsWidgetReady() ? pIDNode->GetWidgetAcc() : nullptr;
if (!pEmbAcc)
return false;
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index ad4e08ef73..b7b51ba03b 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -541,10 +541,10 @@ void CXFA_WidgetAcc::ResetData() {
CXFA_Node* pNextChild = m_pNode->GetFirstContainerChild();
while (pNextChild) {
CXFA_Node* pChild = pNextChild;
- CXFA_WidgetAcc* pAcc = pChild->GetWidgetAcc();
- if (!pAcc)
+ if (!pChild->IsWidgetReady())
continue;
+ CXFA_WidgetAcc* pAcc = pChild->GetWidgetAcc();
bool done = false;
if (wsValue.IsEmpty()) {
CXFA_Value* defValue = pAcc->GetNode()->GetDefaultValueIfExists();
diff --git a/xfa/fxfa/cxfa_widgetacciterator.cpp b/xfa/fxfa/cxfa_widgetacciterator.cpp
index ece5604f7d..c92832f029 100644
--- a/xfa/fxfa/cxfa_widgetacciterator.cpp
+++ b/xfa/fxfa/cxfa_widgetacciterator.cpp
@@ -17,7 +17,7 @@ CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext() {
CXFA_Node* pItem = m_pCurWidgetAcc ? m_ContentIterator.MoveToNext()
: m_ContentIterator.GetCurrent();
while (pItem) {
- m_pCurWidgetAcc = pItem->GetWidgetAcc();
+ m_pCurWidgetAcc = pItem->IsWidgetReady() ? pItem->GetWidgetAcc() : nullptr;
if (m_pCurWidgetAcc)
return m_pCurWidgetAcc.Get();
pItem = m_ContentIterator.MoveToNext();
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index ec70271ea0..1d2af4c858 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -586,7 +586,8 @@ CXFA_WidgetAcc* CXFA_Node::GetContainerWidgetAcc() {
for (const auto& pFormNode : *(pDataNode->GetBindItems())) {
if (!pFormNode || pFormNode->HasRemovedChildren())
continue;
- pFieldWidgetAcc = pFormNode->GetWidgetAcc();
+ pFieldWidgetAcc =
+ pFormNode->IsWidgetReady() ? pFormNode->GetWidgetAcc() : nullptr;
if (pFieldWidgetAcc) {
wsPicture =
pFieldWidgetAcc->GetPictureContent(XFA_VALUEPICTURE_DataBind);
diff --git a/xfa/fxfa/parser/cxfa_object.cpp b/xfa/fxfa/parser/cxfa_object.cpp
index 7c73db0ff5..0c866d350a 100644
--- a/xfa/fxfa/parser/cxfa_object.cpp
+++ b/xfa/fxfa/parser/cxfa_object.cpp
@@ -56,8 +56,9 @@ const CXFA_TreeList* CXFA_Object::AsTreeList() const {
return IsTreeList() ? static_cast<const CXFA_TreeList*>(this) : nullptr;
}
-void CXFA_Object::CreateWidgetAcc() {
+void CXFA_Object::SetWidgetReady() {
acc_ = pdfium::MakeUnique<CXFA_WidgetAcc>(AsNode());
+ is_widget_ready_ = true;
}
CXFA_Node* ToNode(CXFA_Object* pObj) {
diff --git a/xfa/fxfa/parser/cxfa_object.h b/xfa/fxfa/parser/cxfa_object.h
index 5d5f31c647..3843aafb33 100644
--- a/xfa/fxfa/parser/cxfa_object.h
+++ b/xfa/fxfa/parser/cxfa_object.h
@@ -78,8 +78,13 @@ class CXFA_Object : public CFXJSE_HostObject {
m_elementType == XFA_Element::Subform ||
m_elementType == XFA_Element::ExclGroup;
}
- void CreateWidgetAcc();
- CXFA_WidgetAcc* GetWidgetAcc() { return acc_.get(); }
+ void SetWidgetReady();
+ bool IsWidgetReady() const { return is_widget_ready_; }
+ CXFA_WidgetAcc* GetWidgetAcc() {
+ ASSERT(IsWidgetReady());
+ ASSERT(acc_.get() != nullptr);
+ return acc_.get();
+ }
XFA_Element GetElementType() const { return m_elementType; }
WideStringView GetClassName() const { return m_elementName; }
@@ -97,7 +102,7 @@ class CXFA_Object : public CFXJSE_HostObject {
UnownedPtr<CXFA_Document> const m_pDocument;
const XFA_ObjectType m_objectType;
const XFA_Element m_elementType;
-
+ bool is_widget_ready_ = false;
const uint32_t m_elementNameHash;
const WideStringView m_elementName;
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index f6f165fe59..422ba4e58a 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -70,9 +70,8 @@ CXFA_Node* FormValueNode_CreateChild(CXFA_Node* pValueNode, XFA_Element iType) {
}
void FormValueNode_MatchNoneCreateChild(CXFA_Node* pFormNode) {
- CXFA_WidgetAcc* pWidgetAcc = pFormNode->GetWidgetAcc();
- ASSERT(pWidgetAcc);
- pWidgetAcc->GetUIType();
+ ASSERT(pFormNode->IsWidgetReady());
+ pFormNode->GetWidgetAcc()->GetUIType();
}
bool FormValueNode_SetChildContent(CXFA_Node* pValueNode,
@@ -132,8 +131,8 @@ void CreateDataBinding(CXFA_Node* pFormNode,
if (eType != XFA_Element::Field && eType != XFA_Element::ExclGroup)
return;
+ ASSERT(pFormNode->IsWidgetReady());
CXFA_WidgetAcc* pWidgetAcc = pFormNode->GetWidgetAcc();
- ASSERT(pWidgetAcc);
XFA_Element eUIType = pWidgetAcc->GetUIType();
auto* defValue = pFormNode->JSObject()->GetOrCreateProperty<CXFA_Value>(
0, XFA_Element::Value);