summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-27 15:51:19 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-27 15:51:19 -0700
commit0e5f87a278e8502dc5c64e6882f4d2bf6c298783 (patch)
tree3c828de230a5a3ec0ac96b766a3eacb9d58945ca
parent15bfe1bd8b28f9654dcea4af51305e3559a78cd8 (diff)
downloadpdfium-0e5f87a278e8502dc5c64e6882f4d2bf6c298783.tar.xz
Replace CFX_PtrArray with type-safe CFX_ArrayTemplate, Part 2
Capitalize m_bindItems while we're at it. Review-Url: https://codereview.chromium.org/1932513002
-rw-r--r--xfa/fxfa/app/xfa_ffdocview.cpp44
-rw-r--r--xfa/fxfa/app/xfa_ffnotify.cpp2
-rw-r--r--xfa/fxfa/include/xfa_ffdocview.h11
3 files changed, 25 insertions, 32 deletions
diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp
index 405e4103a6..c168e4b63d 100644
--- a/xfa/fxfa/app/xfa_ffdocview.cpp
+++ b/xfa/fxfa/app/xfa_ffdocview.cpp
@@ -175,7 +175,7 @@ void CXFA_FFDocView::UpdateDocView() {
LockUpdate();
int32_t iNewAdds = m_NewAddedNodes.GetSize();
for (int32_t i = 0; i < iNewAdds; i++) {
- CXFA_Node* pNode = reinterpret_cast<CXFA_Node*>(m_NewAddedNodes[i]);
+ CXFA_Node* pNode = m_NewAddedNodes[i];
InitCalculate(pNode);
InitValidate(pNode);
ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, TRUE);
@@ -599,8 +599,7 @@ FX_BOOL CXFA_FFDocView::RunLayout() {
void CXFA_FFDocView::RunSubformIndexChange() {
int32_t iSubforms = m_IndexChangedSubforms.GetSize();
for (int32_t i = 0; i < iSubforms; i++) {
- CXFA_Node* pSubformNode =
- reinterpret_cast<CXFA_Node*>(m_IndexChangedSubforms[i]);
+ CXFA_Node* pSubformNode = m_IndexChangedSubforms[i];
CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pSubformNode->GetWidgetData();
if (!pWidgetAcc) {
continue;
@@ -633,7 +632,7 @@ void CXFA_FFDocView::DestroyDocView() {
m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_None;
m_iLock = 0;
m_ValidateAccs.RemoveAll();
- m_bindItems.RemoveAll();
+ m_BindItems.RemoveAll();
m_CalculateAccs.RemoveAll();
}
FX_BOOL CXFA_FFDocView::IsStaticNotify() {
@@ -642,8 +641,7 @@ FX_BOOL CXFA_FFDocView::IsStaticNotify() {
void CXFA_FFDocView::AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) {
int32_t iAccs = m_CalculateAccs.GetSize();
CXFA_WidgetAcc* pCurrentAcc =
- (iAccs < 1) ? (CXFA_WidgetAcc*)NULL
- : (CXFA_WidgetAcc*)m_CalculateAccs[iAccs - 1];
+ iAccs > 0 ? m_CalculateAccs[iAccs - 1] : nullptr;
if (pCurrentAcc != pWidgetAcc) {
m_CalculateAccs.Add(pWidgetAcc);
}
@@ -659,8 +657,7 @@ void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) {
}
int32_t iAccs = m_CalculateAccs.GetSize();
CXFA_WidgetAcc* pCurrentAcc =
- (iAccs < 1) ? (CXFA_WidgetAcc*)NULL
- : (CXFA_WidgetAcc*)m_CalculateAccs[iAccs - 1];
+ iAccs > 0 ? m_CalculateAccs[iAccs - 1] : nullptr;
if (pCurrentAcc != pResultAcc) {
m_CalculateAccs.Add(pResultAcc);
}
@@ -668,7 +665,7 @@ void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) {
}
void CXFA_FFDocView::RunCalculateRecursive(int32_t& iIndex) {
while (iIndex < m_CalculateAccs.GetSize()) {
- CXFA_WidgetAcc* pCurAcc = (CXFA_WidgetAcc*)m_CalculateAccs[iIndex];
+ CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[iIndex];
AddCalculateNodeNotify(pCurAcc->GetNode());
int32_t iRefCount =
(int32_t)(uintptr_t)pCurAcc->GetNode()->GetUserData(XFA_CalcRefCount);
@@ -695,16 +692,15 @@ int32_t CXFA_FFDocView::RunCalculateWidgets() {
RunCalculateRecursive(iIndex);
}
for (int32_t i = 0; i < m_CalculateAccs.GetSize(); i++) {
- CXFA_WidgetAcc* pCurAcc = (CXFA_WidgetAcc*)m_CalculateAccs[i];
+ CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[i];
pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (void*)(uintptr_t)0);
}
m_CalculateAccs.RemoveAll();
return XFA_EVENTERROR_Success;
}
void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) {
- if (m_ValidateAccs.Find(pWidget) < 0) {
+ if (m_ValidateAccs.Find(pWidget) < 0)
m_ValidateAccs.Add(pWidget);
- }
}
FX_BOOL CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) {
ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate);
@@ -724,7 +720,7 @@ FX_BOOL CXFA_FFDocView::RunValidate() {
}
int32_t iCounts = m_ValidateAccs.GetSize();
for (int32_t i = 0; i < iCounts; i++) {
- CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)m_ValidateAccs[i];
+ CXFA_WidgetAcc* pAcc = m_ValidateAccs[i];
if (pAcc->GetNode()->HasFlag(XFA_NODEFLAG_HasRemoved)) {
continue;
}
@@ -744,19 +740,17 @@ FX_BOOL CXFA_FFDocView::RunEventLayoutReady() {
return TRUE;
}
void CXFA_FFDocView::RunBindItems() {
- int32_t iCount = m_bindItems.GetSize();
+ int32_t iCount = m_BindItems.GetSize();
for (int32_t i = 0; i < iCount; i++) {
- if (reinterpret_cast<CXFA_Node*>(m_bindItems[i])
- ->HasFlag(XFA_NODEFLAG_HasRemoved)) {
+ if (m_BindItems[i]->HasFlag(XFA_NODEFLAG_HasRemoved))
continue;
- }
- CXFA_Node* pWidgetNode = reinterpret_cast<CXFA_Node*>(m_bindItems[i])
- ->GetNodeItem(XFA_NODEITEM_Parent);
+
+ CXFA_Node* pWidgetNode = m_BindItems[i]->GetNodeItem(XFA_NODEITEM_Parent);
CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pWidgetNode->GetWidgetData();
- if (!pAcc) {
+ if (!pAcc)
continue;
- }
- CXFA_BindItems binditems(reinterpret_cast<CXFA_Node*>(m_bindItems[i]));
+
+ CXFA_BindItems binditems(m_BindItems[i]);
CXFA_ScriptContext* pScriptContext =
pWidgetNode->GetDocument()->GetScriptContext();
CFX_WideStringC wsRef;
@@ -768,9 +762,9 @@ void CXFA_FFDocView::RunBindItems() {
pScriptContext->ResolveObjects(pWidgetNode, wsRef, rs, dwStyle);
int32_t iCount = rs.nodes.GetSize();
pAcc->DeleteItem(-1);
- if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || iCount < 1) {
+ if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || iCount < 1)
continue;
- }
+
CFX_WideStringC wsValueRef, wsLabelRef;
binditems.GetValueRef(wsValueRef);
binditems.GetLabelRef(wsLabelRef);
@@ -812,7 +806,7 @@ void CXFA_FFDocView::RunBindItems() {
pAcc->InsertItem(wsLabel, wsValue);
}
}
- m_bindItems.RemoveAll();
+ m_BindItems.RemoveAll();
}
void CXFA_FFDocView::SetChangeMark() {
if (m_iStatus < XFA_DOCVIEW_LAYOUTSTATUS_End) {
diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp
index 571593fc63..b6e64d04b7 100644
--- a/xfa/fxfa/app/xfa_ffnotify.cpp
+++ b/xfa/fxfa/app/xfa_ffnotify.cpp
@@ -327,7 +327,7 @@ void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) {
}
switch (iType) {
case XFA_ELEMENT_BindItems:
- pDocView->m_bindItems.Add(pNode);
+ pDocView->m_BindItems.Add(pNode);
break;
case XFA_ELEMENT_Validate: {
pNode->SetFlag(XFA_NODEFLAG_NeedsInitApp, false);
diff --git a/xfa/fxfa/include/xfa_ffdocview.h b/xfa/fxfa/include/xfa_ffdocview.h
index 539100116c..7f1c631da3 100644
--- a/xfa/fxfa/include/xfa_ffdocview.h
+++ b/xfa/fxfa/include/xfa_ffdocview.h
@@ -116,12 +116,11 @@ class CXFA_FFDocView {
CXFA_FFWidget* m_pFocusWidget;
CXFA_FFWidget* m_pOldFocusWidget;
CFX_MapPtrToPtr m_mapPageInvalidate;
- CFX_PtrArray m_ValidateAccs;
- CFX_PtrArray m_bindItems;
- CFX_PtrArray m_CalculateAccs;
-
- CFX_PtrArray m_NewAddedNodes;
- CFX_PtrArray m_IndexChangedSubforms;
+ CFX_ArrayTemplate<CXFA_WidgetAcc*> m_ValidateAccs;
+ CFX_ArrayTemplate<CXFA_WidgetAcc*> m_CalculateAccs;
+ CFX_ArrayTemplate<CXFA_Node*> m_BindItems;
+ CFX_ArrayTemplate<CXFA_Node*> m_NewAddedNodes;
+ CFX_ArrayTemplate<CXFA_Node*> m_IndexChangedSubforms;
XFA_DOCVIEW_LAYOUTSTATUS m_iStatus;
int32_t m_iLock;
friend class CXFA_FFNotify;