summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp13
-rw-r--r--xfa/fxfa/cxfa_ffdocview.h1
-rw-r--r--xfa/fxfa/cxfa_ffnotify.cpp20
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp5
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp12
5 files changed, 30 insertions, 21 deletions
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index cb4c72d0b3..5856809167 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -309,6 +309,10 @@ int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam,
return XFA_EVENTERROR_Success;
}
+CXFA_FFWidget* CXFA_FFDocView::GetWidgetForNode(CXFA_Node* node) {
+ return static_cast<CXFA_FFWidget*>(GetXFALayout()->GetLayoutItem(node));
+}
+
CXFA_FFWidgetHandler* CXFA_FFDocView::GetWidgetHandler() {
if (!m_pWidgetHandler)
m_pWidgetHandler = pdfium::MakeUnique<CXFA_FFWidgetHandler>(this);
@@ -376,8 +380,9 @@ bool CXFA_FFDocView::SetFocus(CXFA_FFWidget* hWidget) {
}
void CXFA_FFDocView::SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) {
- CXFA_FFWidget* pNewFocus =
- pWidgetAcc ? pWidgetAcc->GetNextWidget(nullptr) : nullptr;
+ CXFA_FFWidget* pNewFocus = nullptr;
+ if (pWidgetAcc)
+ pNewFocus = GetWidgetForNode(pWidgetAcc->GetNode());
if (!SetFocus(pNewFocus))
return;
@@ -487,7 +492,9 @@ CXFA_FFWidget* CXFA_FFDocView::GetWidgetByName(const WideString& wsName,
CXFA_FFWidget* pRefWidget) {
CXFA_WidgetAcc* pRefAcc = pRefWidget ? pRefWidget->GetDataAcc() : nullptr;
CXFA_WidgetAcc* pAcc = GetWidgetAccByName(wsName, pRefAcc);
- return pAcc ? pAcc->GetNextWidget(nullptr) : nullptr;
+ if (!pAcc)
+ return nullptr;
+ return GetWidgetForNode(pAcc->GetNode());
}
CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName(
diff --git a/xfa/fxfa/cxfa_ffdocview.h b/xfa/fxfa/cxfa_ffdocview.h
index fcaa7162dd..5c8f0176d8 100644
--- a/xfa/fxfa/cxfa_ffdocview.h
+++ b/xfa/fxfa/cxfa_ffdocview.h
@@ -62,6 +62,7 @@ class CXFA_FFDocView {
CXFA_FFWidget* GetFocusWidget() const { return m_pFocusWidget.Get(); }
void KillFocus();
bool SetFocus(CXFA_FFWidget* hWidget);
+ CXFA_FFWidget* GetWidgetForNode(CXFA_Node* node);
CXFA_FFWidget* GetWidgetByName(const WideString& wsName,
CXFA_FFWidget* pRefWidget);
CXFA_WidgetAcc* GetWidgetAccByName(const WideString& wsName,
diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp
index 616edf7507..c7872f662b 100644
--- a/xfa/fxfa/cxfa_ffnotify.cpp
+++ b/xfa/fxfa/cxfa_ffnotify.cpp
@@ -70,8 +70,9 @@ void CXFA_FFNotify::OnWidgetListItemAdded(CXFA_WidgetAcc* pSender,
if (pSender->GetUIType() != XFA_Element::ChoiceList)
return;
- CXFA_FFWidget* pWidget = nullptr;
- while ((pWidget = pSender->GetNextWidget(pWidget)) != nullptr) {
+ CXFA_FFWidget* pWidget =
+ m_pDoc->GetDocView()->GetWidgetForNode(pSender->GetNode());
+ for (; pWidget; pWidget = pSender->GetNextWidget(pWidget)) {
if (pWidget->IsLoaded()) {
if (pSender->IsListBox())
ToListBox(pWidget)->InsertItem(pLabel, iIndex);
@@ -86,8 +87,9 @@ void CXFA_FFNotify::OnWidgetListItemRemoved(CXFA_WidgetAcc* pSender,
if (pSender->GetUIType() != XFA_Element::ChoiceList)
return;
- CXFA_FFWidget* pWidget = nullptr;
- while ((pWidget = pSender->GetNextWidget(pWidget)) != nullptr) {
+ CXFA_FFWidget* pWidget =
+ m_pDoc->GetDocView()->GetWidgetForNode(pSender->GetNode());
+ for (; pWidget; pWidget = pSender->GetNextWidget(pWidget)) {
if (pWidget->IsLoaded()) {
if (pSender->IsListBox())
ToListBox(pWidget)->DeleteItem(iIndex);
@@ -369,8 +371,9 @@ void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, XFA_Attribute eAttr) {
if (!pWidgetAcc)
return;
- CXFA_FFWidget* pWidget = nullptr;
- while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) {
+ CXFA_FFWidget* pWidget =
+ m_pDoc->GetDocView()->GetWidgetForNode(pWidgetAcc->GetNode());
+ for (; pWidget; pWidget = pWidgetAcc->GetNextWidget(pWidget)) {
if (pWidget->IsLoaded())
pWidget->AddInvalidateRect();
}
@@ -432,8 +435,9 @@ void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender,
}
}
- CXFA_FFWidget* pWidget = nullptr;
- while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) {
+ CXFA_FFWidget* pWidget =
+ m_pDoc->GetDocView()->GetWidgetForNode(pWidgetAcc->GetNode());
+ for (; pWidget; pWidget = pWidgetAcc->GetNextWidget(pWidget)) {
if (!pWidget->IsLoaded())
continue;
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 82ed1aeffe..2f4dcb4755 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -36,6 +36,7 @@
#include "xfa/fxfa/parser/cxfa_edge.h"
#include "xfa/fxfa/parser/cxfa_fill.h"
#include "xfa/fxfa/parser/cxfa_image.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxgraphics/cxfa_gecolor.h"
@@ -1282,7 +1283,9 @@ CXFA_FFWidget* CXFA_FFWidget::GetParent() {
CXFA_WidgetAcc* pParentWidgetAcc =
static_cast<CXFA_WidgetAcc*>(pParentNode->GetWidgetAcc());
if (pParentWidgetAcc) {
- return pParentWidgetAcc->GetNextWidget(nullptr);
+ CXFA_LayoutProcessor* layout = GetDocView()->GetXFALayout();
+ return static_cast<CXFA_FFWidget*>(
+ layout->GetLayoutItem(pParentWidgetAcc->GetNode()));
}
}
return nullptr;
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index f735633abe..8851d269c6 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -864,18 +864,12 @@ std::pair<int32_t, bool> CXFA_WidgetAcc::ExecuteBoolScript(
}
CXFA_FFWidget* CXFA_WidgetAcc::GetNextWidget(CXFA_FFWidget* pWidget) {
- CXFA_LayoutItem* pLayout = nullptr;
- if (pWidget)
- pLayout = pWidget->GetNext();
- else
- pLayout = m_pDocView->GetXFALayout()->GetLayoutItem(m_pNode);
-
- return static_cast<CXFA_FFWidget*>(pLayout);
+ return static_cast<CXFA_FFWidget*>(pWidget->GetNext());
}
void CXFA_WidgetAcc::UpdateUIDisplay(CXFA_FFWidget* pExcept) {
- CXFA_FFWidget* pWidget = nullptr;
- while ((pWidget = GetNextWidget(pWidget)) != nullptr) {
+ CXFA_FFWidget* pWidget = m_pDocView->GetWidgetForNode(m_pNode);
+ for (; pWidget; pWidget = GetNextWidget(pWidget)) {
if (pWidget == pExcept || !pWidget->IsLoaded() ||
(GetUIType() != XFA_Element::CheckButton && pWidget->IsFocused())) {
continue;