summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2017-01-03 12:41:21 -0800
committerCommit bot <commit-bot@chromium.org>2017-01-03 12:41:21 -0800
commiteda80ef83f1a28166bbf86c6808dda5f6623f08c (patch)
treefa99e89cc99a2cc4784d2b9f9860d880e06d37c6 /xfa
parentb38c5dfcbb76dc5b731fb969423e4bedcbca19f6 (diff)
downloadpdfium-eda80ef83f1a28166bbf86c6808dda5f6623f08c.tar.xz
Kill last use of CFX_PtrList.
I'd been waiting on this hoping the code would be refactored out of existence, but it looks to be used. Use tests against x.end() in place of a "null position". This is greatly complicated by the use of "tail position", which now calcluated by std::prev(x.end()) unless the list is empty. Review-Url: https://codereview.chromium.org/2592163002
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp92
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.h20
2 files changed, 53 insertions, 59 deletions
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index 1be6d27129..1a3da9ecb3 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -243,7 +243,7 @@ CXFA_LayoutPageMgr::CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor)
m_pTemplatePageSetRoot(nullptr),
m_pPageSetLayoutItemRoot(nullptr),
m_pPageSetCurRoot(nullptr),
- m_pCurrentContainerRecord(nullptr),
+ m_CurrentContainerRecordIter(m_ProposedContainerRecords.end()),
m_pCurPageArea(nullptr),
m_nAvailPages(0),
m_nCurPageCount(0),
@@ -378,23 +378,26 @@ bool CXFA_LayoutPageMgr::PrepareFirstPage(CXFA_Node* pRootSubform) {
CXFA_Node *pLeader, *pTrailer;
if (pBreakBeforeNode &&
ExecuteBreakBeforeOrAfter(pBreakBeforeNode, true, pLeader, pTrailer)) {
- m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition();
+ m_CurrentContainerRecordIter = m_ProposedContainerRecords.begin();
return true;
}
return AppendNewPage(true);
}
bool CXFA_LayoutPageMgr::AppendNewPage(bool bFirstTemPage) {
- if (m_pCurrentContainerRecord !=
- m_rgProposedContainerRecord.GetTailPosition()) {
+ if (m_CurrentContainerRecordIter != GetTailPosition())
return true;
- }
+
CXFA_Node* pPageNode = GetNextAvailPageArea(nullptr);
if (!pPageNode)
return false;
- if (bFirstTemPage && !m_pCurrentContainerRecord)
- m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition();
- return !bFirstTemPage || m_pCurrentContainerRecord;
+
+ if (bFirstTemPage &&
+ m_CurrentContainerRecordIter == m_ProposedContainerRecords.end()) {
+ m_CurrentContainerRecordIter = m_ProposedContainerRecords.begin();
+ }
+ return !bFirstTemPage ||
+ m_CurrentContainerRecordIter != m_ProposedContainerRecords.end();
}
void CXFA_LayoutPageMgr::RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord,
@@ -444,11 +447,10 @@ void CXFA_LayoutPageMgr::SubmitContentItem(
if (eStatus != XFA_ItemLayoutProcessorResult_Done) {
if (eStatus == XFA_ItemLayoutProcessorResult_PageFullBreak &&
- m_pCurrentContainerRecord ==
- m_rgProposedContainerRecord.GetTailPosition()) {
+ m_CurrentContainerRecordIter == GetTailPosition()) {
AppendNewPage();
}
- m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetTailPosition();
+ m_CurrentContainerRecordIter = GetTailPosition();
m_pCurPageArea = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode;
}
}
@@ -463,10 +465,8 @@ FX_FLOAT CXFA_LayoutPageMgr::GetAvailHeight() {
pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt);
if (fAvailHeight >= XFA_LAYOUT_FLOAT_PERCISION)
return fAvailHeight;
- if (m_pCurrentContainerRecord ==
- m_rgProposedContainerRecord.GetHeadPosition()) {
+ if (m_CurrentContainerRecordIter == m_ProposedContainerRecords.begin())
return 0.0f;
- }
return XFA_LAYOUT_FLOAT_MAX;
}
@@ -484,10 +484,10 @@ CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord(
CXFA_Node* pPageNode,
bool bCreateNew) {
CXFA_ContainerRecord* pNewRecord = new CXFA_ContainerRecord();
- if (m_pCurrentContainerRecord) {
+ if (m_CurrentContainerRecordIter != m_ProposedContainerRecords.end()) {
if (!IsPageSetRootOrderedOccurrence() || !pPageNode) {
*pNewRecord = *GetCurrentContainerRecord();
- m_rgProposedContainerRecord.AddTail(pNewRecord);
+ m_ProposedContainerRecords.push_back(pNewRecord);
return pNewRecord;
}
CXFA_Node* pPageSet = pPageNode->GetNodeItem(XFA_NODEITEM_Parent);
@@ -546,7 +546,7 @@ CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord(
pNewRecord->pCurPageSet = m_pPageSetLayoutItemRoot;
}
}
- m_rgProposedContainerRecord.AddTail(pNewRecord);
+ m_ProposedContainerRecords.push_back(pNewRecord);
return pNewRecord;
}
@@ -748,7 +748,8 @@ bool CXFA_LayoutPageMgr::RunBreak(XFA_Element eBreakType,
case XFA_ATTRIBUTEENUM_ContentArea:
if (pTarget && pTarget->GetElementType() != XFA_Element::ContentArea)
pTarget = nullptr;
- if (!pTarget || !m_pCurrentContainerRecord ||
+ if (!pTarget ||
+ m_CurrentContainerRecordIter == m_ProposedContainerRecords.end() ||
pTarget !=
GetCurrentContainerRecord()->pCurContentArea->m_pFormNode ||
bStartNew) {
@@ -763,7 +764,8 @@ bool CXFA_LayoutPageMgr::RunBreak(XFA_Element eBreakType,
case XFA_ATTRIBUTEENUM_PageArea:
if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea)
pTarget = nullptr;
- if (!pTarget || !m_pCurrentContainerRecord ||
+ if (!pTarget ||
+ m_CurrentContainerRecordIter == m_ProposedContainerRecords.end() ||
pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode ||
bStartNew) {
CXFA_Node* pPageArea = GetNextAvailPageArea(pTarget, nullptr, true);
@@ -816,9 +818,8 @@ bool CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
bStartNew)) {
return true;
}
- if (m_rgProposedContainerRecord.GetCount() > 0 &&
- m_pCurrentContainerRecord ==
- m_rgProposedContainerRecord.GetHeadPosition() &&
+ if (!m_ProposedContainerRecords.empty() &&
+ m_CurrentContainerRecordIter == m_ProposedContainerRecords.begin() &&
eType == XFA_Element::BreakBefore) {
CXFA_Node* pParentNode = pFormNode->GetNodeItem(
XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
@@ -1101,9 +1102,10 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet(CXFA_Node* pPageSet,
pTargetPageArea, pTargetContentArea,
bNewPage, bQuery);
}
- XFA_ATTRIBUTEENUM ePreferredPosition = m_pCurrentContainerRecord
- ? XFA_ATTRIBUTEENUM_Rest
- : XFA_ATTRIBUTEENUM_First;
+ XFA_ATTRIBUTEENUM ePreferredPosition =
+ m_CurrentContainerRecordIter != m_ProposedContainerRecords.end()
+ ? XFA_ATTRIBUTEENUM_Rest
+ : XFA_ATTRIBUTEENUM_First;
return FindPageAreaFromPageSet_SimplexDuplex(
pPageSet, pStartChild, pTargetPageArea, pTargetContentArea, bNewPage,
bQuery, ePreferredPosition);
@@ -1528,21 +1530,18 @@ bool CXFA_LayoutPageMgr::GetNextAvailContentHeight(FX_FLOAT fChildHeight) {
if (m_nCurPageCount == iMax) {
CXFA_Node* pSrcPage = m_pCurPageArea;
int32_t nSrcPageCount = m_nCurPageCount;
- FX_POSITION psSrcRecord = m_rgProposedContainerRecord.GetTailPosition();
+ auto psSrcIter = GetTailPosition();
CXFA_Node* pNextPage =
GetNextAvailPageArea(nullptr, nullptr, false, true);
m_pCurPageArea = pSrcPage;
m_nCurPageCount = nSrcPageCount;
- CXFA_ContainerRecord* pPrevRecord = static_cast<CXFA_ContainerRecord*>(
- m_rgProposedContainerRecord.GetNext(psSrcRecord));
- while (psSrcRecord) {
- FX_POSITION psSaveRecord = psSrcRecord;
- CXFA_ContainerRecord* pInsertRecord =
- static_cast<CXFA_ContainerRecord*>(
- m_rgProposedContainerRecord.GetNext(psSrcRecord));
+ CXFA_ContainerRecord* pPrevRecord = *psSrcIter++;
+ while (psSrcIter != m_ProposedContainerRecords.end()) {
+ auto psSaveIter = psSrcIter;
+ CXFA_ContainerRecord* pInsertRecord = *psSrcIter++;
RemoveLayoutRecord(pInsertRecord, pPrevRecord);
delete pInsertRecord;
- m_rgProposedContainerRecord.RemoveAt(psSaveRecord);
+ m_ProposedContainerRecords.erase(psSaveIter);
}
if (pNextPage) {
CXFA_Node* pContentArea =
@@ -1570,23 +1569,16 @@ bool CXFA_LayoutPageMgr::GetNextAvailContentHeight(FX_FLOAT fChildHeight) {
}
void CXFA_LayoutPageMgr::ClearData() {
- ClearRecordList();
-}
-
-void CXFA_LayoutPageMgr::ClearRecordList() {
if (!m_pTemplatePageSetRoot)
return;
- if (m_rgProposedContainerRecord.GetCount() > 0) {
- FX_POSITION sPos;
- sPos = m_rgProposedContainerRecord.GetHeadPosition();
- while (sPos) {
- CXFA_ContainerRecord* pRecord = static_cast<CXFA_ContainerRecord*>(
- m_rgProposedContainerRecord.GetNext(sPos));
- delete pRecord;
- }
- m_rgProposedContainerRecord.RemoveAll();
+
+ auto sPos = m_ProposedContainerRecords.begin();
+ while (sPos != m_ProposedContainerRecords.end()) {
+ CXFA_ContainerRecord* pRecord = *sPos++;
+ delete pRecord;
}
- m_pCurrentContainerRecord = nullptr;
+ m_ProposedContainerRecords.clear();
+ m_CurrentContainerRecordIter = m_ProposedContainerRecords.end();
m_pCurPageArea = nullptr;
m_nCurPageCount = 0;
m_bCreateOverFlowPage = false;
@@ -1942,7 +1934,7 @@ void CXFA_LayoutPageMgr::SyncLayoutData() {
pNotify->OnPageEvent(pPage, XFA_PAGEVIEWEVENT_PostRemoved);
delete pPage;
}
- ClearRecordList();
+ ClearData();
}
void XFA_ReleaseLayoutItem_NoPageArea(CXFA_LayoutItem* pLayoutItem) {
@@ -1961,7 +1953,7 @@ void CXFA_LayoutPageMgr::PrepareLayout() {
m_pPageSetCurRoot = nullptr;
m_ePageSetMode = XFA_ATTRIBUTEENUM_OrderedOccurrence;
m_nAvailPages = 0;
- ClearRecordList();
+ ClearData();
if (!m_pPageSetLayoutItemRoot)
return;
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.h b/xfa/fxfa/parser/cxfa_layoutpagemgr.h
index 3f0410f74c..b466f3ad1f 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.h
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.h
@@ -7,6 +7,9 @@
#ifndef XFA_FXFA_PARSER_CXFA_LAYOUTPAGEMGR_H_
#define XFA_FXFA_PARSER_CXFA_LAYOUTPAGEMGR_H_
+#include <iterator>
+#include <list>
+
#include "xfa/fxfa/parser/xfa_layout_itemlayout.h"
class CXFA_ContainerRecord;
@@ -54,12 +57,12 @@ class CXFA_LayoutPageMgr {
CXFA_ContainerRecord* pPrevRecord);
void RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord,
CXFA_ContainerRecord* pPrevRecord);
- inline CXFA_ContainerRecord* GetCurrentContainerRecord() {
- CXFA_ContainerRecord* result =
- ((CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetAt(
- m_pCurrentContainerRecord));
- ASSERT(result);
- return result;
+ CXFA_ContainerRecord* GetCurrentContainerRecord() {
+ return *m_CurrentContainerRecordIter;
+ }
+ std::list<CXFA_ContainerRecord*>::iterator GetTailPosition() {
+ auto iter = m_ProposedContainerRecords.end();
+ return !m_ProposedContainerRecords.empty() ? std::prev(iter) : iter;
}
CXFA_ContainerRecord* CreateContainerRecord(CXFA_Node* pPageNode = nullptr,
bool bCreateNew = false);
@@ -120,7 +123,6 @@ class CXFA_LayoutPageMgr {
return m_ePageSetMode == XFA_ATTRIBUTEENUM_OrderedOccurrence;
}
void ClearData();
- void ClearRecordList();
void MergePageSetContents();
void LayoutPageSetContents();
void PrepareLayout();
@@ -129,8 +131,8 @@ class CXFA_LayoutPageMgr {
CXFA_Node* m_pTemplatePageSetRoot;
CXFA_ContainerLayoutItem* m_pPageSetLayoutItemRoot;
CXFA_ContainerLayoutItem* m_pPageSetCurRoot;
- FX_POSITION m_pCurrentContainerRecord;
- CFX_PtrList m_rgProposedContainerRecord;
+ std::list<CXFA_ContainerRecord*> m_ProposedContainerRecords;
+ std::list<CXFA_ContainerRecord*>::iterator m_CurrentContainerRecordIter;
CXFA_Node* m_pCurPageArea;
int32_t m_nAvailPages;
int32_t m_nCurPageCount;